diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1999-10-09 00:00:47 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 1999-10-09 00:00:47 +0000 |
commit | d6434e1042f3b0a6dfe1b1f615af369486f9b1fa (patch) | |
tree | e2be02f33984c48ec019c654051d27964e42c441 /net/decnet/dn_dev.c | |
parent | 609d1e803baf519487233b765eb487f9ec227a18 (diff) |
Merge with 2.3.19.
Diffstat (limited to 'net/decnet/dn_dev.c')
-rw-r--r-- | net/decnet/dn_dev.c | 207 |
1 files changed, 66 insertions, 141 deletions
diff --git a/net/decnet/dn_dev.c b/net/decnet/dn_dev.c index e46fdbcc0..ddd0d630c 100644 --- a/net/decnet/dn_dev.c +++ b/net/decnet/dn_dev.c @@ -49,21 +49,17 @@ static unsigned char dn_eco_version[3] = {0x02,0x00,0x00}; extern struct neigh_table dn_neigh_table; -struct device *decnet_default_device = NULL; +struct net_device *decnet_default_device = NULL; -static struct dn_dev *dn_dev_create(struct device *dev, int *err); -static void dn_dev_delete(struct device *dev); +static struct dn_dev *dn_dev_create(struct net_device *dev, int *err); +static void dn_dev_delete(struct net_device *dev); #ifdef CONFIG_RTNETLINK static void rtmsg_ifa(int event, struct dn_ifaddr *ifa); #endif -static int dn_eth_up(struct device *); -static void dn_send_brd_hello(struct device *dev); -static void dn_send_ptp_hello(struct device *dev); -static int dn_dev_eth_setsrc(struct sk_buff *skb); -static int dn_dev_lo_setsrc(struct sk_buff *skb); -static int dn_dev_ptp_setsrc(struct sk_buff *skb); -static int dn_dev_eth_neigh_setup(struct neighbour *n); +static int dn_eth_up(struct net_device *); +static void dn_send_brd_hello(struct net_device *dev); +static void dn_send_ptp_hello(struct net_device *dev); static struct dn_dev_parms dn_dev_list[] = { { @@ -82,8 +78,6 @@ static struct dn_dev_parms dn_dev_list[] = { NULL, NULL, dn_send_brd_hello, - dn_dev_eth_setsrc, - dn_dev_eth_neigh_setup, NULL }, { @@ -102,8 +96,6 @@ static struct dn_dev_parms dn_dev_list[] = { NULL, NULL, dn_send_brd_hello, - NULL, - NULL, NULL }, #if 0 @@ -123,8 +115,6 @@ static struct dn_dev_parms dn_dev_list[] = { NULL, NULL, dn_send_ptp_hello, - dn_dev_ptp_setsrc, - NULL, NULL }, #endif @@ -145,8 +135,6 @@ static struct dn_dev_parms dn_dev_list[] = { NULL, NULL, dn_send_brd_hello, - dn_dev_ptp_setsrc, - NULL, NULL }, #endif @@ -167,8 +155,6 @@ static struct dn_dev_parms dn_dev_list[] = { NULL, NULL, dn_send_ptp_hello, - dn_dev_ptp_setsrc, - NULL, NULL }, #endif @@ -188,8 +174,6 @@ static struct dn_dev_parms dn_dev_list[] = { NULL, NULL, dn_send_brd_hello, - dn_dev_lo_setsrc, - dn_dev_eth_neigh_setup, NULL } }; @@ -257,7 +241,7 @@ static struct dn_dev_sysctl_table { {{CTL_NET, "net", NULL, 0, 0555, dn_dev_sysctl.dn_dev_proto_dir}, {0}} }; -static void dn_dev_sysctl_register(struct device *dev, struct dn_dev_parms *parms) +static void dn_dev_sysctl_register(struct net_device *dev, struct dn_dev_parms *parms) { struct dn_dev_sysctl_table *t; int i; @@ -361,7 +345,7 @@ static int dn_dev_insert_ifa(struct dn_dev *dn_db, struct dn_ifaddr *ifa) return 0; } -static int dn_dev_set_ifa(struct device *dev, struct dn_ifaddr *ifa) +static int dn_dev_set_ifa(struct net_device *dev, struct dn_ifaddr *ifa) { struct dn_dev *dn_db = dev->dn_ptr; @@ -382,12 +366,15 @@ static int dn_dev_set_ifa(struct device *dev, struct dn_ifaddr *ifa) static struct dn_dev *dn_dev_by_index(int ifindex) { - struct device *dev; + struct net_device *dev; + struct dn_dev *dn_dev = NULL; dev = dev_get_by_index(ifindex); - if (dev) - return dev->dn_ptr; + if (dev) { + dn_dev = dev->dn_ptr; + dev_put(dev); + } - return NULL; + return dn_dev; } @@ -397,7 +384,7 @@ int dn_dev_ioctl(unsigned int cmd, void *arg) struct ifreq *ifr = (struct ifreq *)buffer; struct sockaddr_dn *sdn = (struct sockaddr_dn *)&ifr->ifr_addr; struct dn_dev *dn_db; - struct device *dev; + struct net_device *dev; struct dn_ifaddr *ifa = NULL, **ifap = NULL; int exclusive = 0; int ret = 0; @@ -425,7 +412,7 @@ int dn_dev_ioctl(unsigned int cmd, void *arg) return -EINVAL; } - if ((dev = dev_get(ifr->ifr_name)) == NULL) { + if ((dev = __dev_get_by_name(ifr->ifr_name)) == NULL) { ret = -ENODEV; goto done; } @@ -503,7 +490,7 @@ static int dn_dev_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *a static int dn_dev_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) { struct rtattr **rta = arg; - struct device *dev; + struct net_device *dev; struct dn_dev *dn_db; struct ifaddrmsg *ifm = NLMSG_DATA(nlh); struct dn_ifaddr *ifa; @@ -511,7 +498,7 @@ static int dn_dev_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *a if (rta[IFA_LOCAL-1] == NULL) return -EINVAL; - if ((dev = dev_get_by_index(ifm->ifa_index)) == NULL) + if ((dev = __dev_get_by_index(ifm->ifa_index)) == NULL) return -ENODEV; if ((dn_db = dev->dn_ptr) == NULL) { @@ -547,7 +534,7 @@ static int dn_dev_fill_ifaddr(struct sk_buff *skb, struct dn_ifaddr *ifa, ifm = NLMSG_DATA(nlh); ifm->ifa_family = AF_DECnet; - ifm->ifa_prefixlen = 0; + ifm->ifa_prefixlen = 16; ifm->ifa_flags = ifa->ifa_flags | IFA_F_PERMANENT; ifm->ifa_scope = ifa->ifa_scope; ifm->ifa_index = ifa->ifa_dev->dev->ifindex; @@ -556,6 +543,7 @@ static int dn_dev_fill_ifaddr(struct sk_buff *skb, struct dn_ifaddr *ifa, RTA_PUT(skb, IFA_LABEL, IFNAMSIZ, &ifa->ifa_label); nlh->nlmsg_len = skb->tail - b; return skb->len; + nlmsg_failure: rtattr_failure: skb_trim(skb, b - skb->data); @@ -581,7 +569,7 @@ static void rtmsg_ifa(int event, struct dn_ifaddr *ifa) netlink_broadcast(rtnl, skb, 0, RTMGRP_DECnet_IFADDR, GFP_KERNEL); } -static int dn_dev_fill_ifinfo(struct sk_buff *skb, struct device *dev, +static int dn_dev_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, int type, u32 pid, u32 seq) { struct ifinfomsg *r; @@ -618,13 +606,17 @@ static int dn_dev_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb) { int idx, dn_idx; int s_idx, s_dn_idx; - struct device *dev; + struct net_device *dev; struct dn_dev *dn_db; struct dn_ifaddr *ifa; s_idx = cb->args[0]; s_dn_idx = dn_idx = cb->args[1]; - for(dev = dev_base, idx = 0; dev; dev = dev->next, idx++) { + read_lock(&dev_base_lock); + for(dev = dev_base, idx = 0; dev; dev = dev->next) { + if ((dn_db = dev->dn_ptr) == NULL) + continue; + idx++; if (idx < s_idx) continue; if (idx > s_idx) @@ -641,6 +633,7 @@ static int dn_dev_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb) } } done: + read_unlock(&dev_base_lock); cb->args[0] = idx; cb->args[1] = dn_idx; @@ -651,8 +644,9 @@ static int dn_dev_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb) { int idx; int s_idx = cb->args[0]; - struct device *dev; + struct net_device *dev; + read_lock(&dev_base_lock); for(dev=dev_base, idx=0; dev; dev = dev->next) { if (!dev->dn_ptr) continue; @@ -662,12 +656,13 @@ static int dn_dev_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb) if (dn_dev_fill_ifinfo(skb, dev, RTM_NEWLINK, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq) <= 0) break; } + read_unlock(&dev_base_lock); cb->args[0] = idx; return skb->len; } -static void dn_dev_ifinfo(int type, struct device *dev) +static void dn_dev_ifinfo(int type, struct net_device *dev) { struct sk_buff *skb; int size = NLMSG_GOODSIZE; @@ -686,7 +681,7 @@ static void dn_dev_ifinfo(int type, struct device *dev) } #endif /* CONFIG_RTNETLINK */ -static void dn_send_endnode_hello(struct device *dev) +static void dn_send_endnode_hello(struct net_device *dev) { struct endnode_hello_message *msg; struct sk_buff *skb = NULL; @@ -711,7 +706,7 @@ static void dn_send_endnode_hello(struct device *dev) if (dn_db->router) { struct dn_neigh *dn = (struct dn_neigh *)dn_db->router; - memcpy(msg->neighbor, dn->addr, ETH_ALEN); + dn_dn2eth(msg->neighbor, dn->addr); } msg->timer = dn_htons((unsigned short)dn_db->parms.t3); @@ -724,11 +719,7 @@ static void dn_send_endnode_hello(struct device *dev) skb->nh.raw = skb->data; - if (dev->hard_header(skb,dev, ETH_P_DNA_RT,dn_rt_all_rt_mcast, - decnet_ether_address, skb->len) >= 0) - dn_send_skb(skb); - else - kfree_skb(skb); + dn_rt_finish_output(skb, dn_rt_all_rt_mcast); } @@ -754,13 +745,13 @@ static int dn_am_i_a_router(struct dn_neigh *dn, struct dn_dev *dn_db) if (dn->priority != dn_db->parms.priority) return 0; - if (dn_ntohs(dn_eth2dn(dn->addr)) < dn_ntohs(decnet_address)) + if (dn_ntohs(dn->addr) < dn_ntohs(decnet_address)) return 1; return 0; } -static void dn_send_router_hello(struct device *dev) +static void dn_send_router_hello(struct net_device *dev) { int n; struct dn_dev *dn_db = dev->dn_ptr; @@ -821,24 +812,14 @@ static void dn_send_router_hello(struct device *dev) if (dn_am_i_a_router(dn, dn_db)) { struct sk_buff *skb2 = skb_copy(skb, GFP_ATOMIC); if (skb2) { - if (dev->hard_header(skb2, dev, ETH_P_DNA_RT, - dn_rt_all_end_mcast, - decnet_ether_address, - skb2->len) >= 0) - dn_send_skb(skb2); - else - kfree_skb(skb2); + dn_rt_finish_output(skb2, dn_rt_all_end_mcast); } } - if (dev->hard_header(skb, dev, ETH_P_DNA_RT, dn_rt_all_rt_mcast, - decnet_ether_address, skb->len) >= 0) - dn_send_skb(skb); - else - kfree_skb(skb); + dn_rt_finish_output(skb, dn_rt_all_rt_mcast); } -static void dn_send_brd_hello(struct device *dev) +static void dn_send_brd_hello(struct net_device *dev) { if (decnet_node_type == DN_RT_INFO_ENDN) dn_send_endnode_hello(dev); @@ -846,18 +827,18 @@ static void dn_send_brd_hello(struct device *dev) dn_send_router_hello(dev); } #else -static void dn_send_brd_hello(struct device *dev) +static void dn_send_brd_hello(struct net_device *dev) { dn_send_endnode_hello(dev); } #endif -static void dn_send_ptp_hello(struct device *dev) +static void dn_send_ptp_hello(struct net_device *dev) { int tdlen = 16; int size = dev->hard_header_len + 2 + 4 + tdlen; struct sk_buff *skb = dn_alloc_skb(NULL, size, GFP_ATOMIC); - struct dn_dev *dn_db = dev->dn_ptr; + /* struct dn_dev *dn_db = dev->dn_ptr; */ unsigned char *ptr; int i; @@ -876,28 +857,20 @@ static void dn_send_ptp_hello(struct device *dev) for(i = 0; i < tdlen; i++) *ptr++ = 0252; +#if 0 if (dn_db->router) { struct dn_neigh *dn = (struct dn_neigh *)dn_db->router; if (memcmp(dn->addr, decnet_ether_address, ETH_ALEN) == 0) { struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC); - if (skb2 && dev->hard_header(skb2, dev, ETH_P_DNA_RT, - dn_rt_all_end_mcast, - decnet_ether_address, - skb->len) >= 0) { - - dn_send_skb(skb2); - } + dn_rt_finish_output(skb2, dn_rt_all_end_mcast); } } +#endif - if (dev->hard_header(skb, dev, ETH_P_DNA_RT, dn_rt_all_rt_mcast, - decnet_ether_address, skb->len) < 0); - return; - - dn_send_skb(skb); + dn_rt_finish_output(skb, dn_rt_all_rt_mcast); } -static int dn_eth_up(struct device *dev) +static int dn_eth_up(struct net_device *dev) { struct dn_dev *dn_db = dev->dn_ptr; @@ -914,56 +887,11 @@ static int dn_eth_up(struct device *dev) return 0; } -static int dn_dev_eth_setsrc(struct sk_buff *skb) -{ - struct ethhdr *h = skb->mac.ethernet; - struct dn_skb_cb *cb = (struct dn_skb_cb *)skb->cb; - - if (h == NULL) - return -1; - - cb->neigh = dn_eth2dn(h->h_source); - - return 0; -} - -static int dn_dev_lo_setsrc(struct sk_buff *skb) -{ - struct dn_skb_cb *cb = (struct dn_skb_cb *)skb->cb; - - cb->neigh = decnet_address; - - return 0; -} - -static int dn_dev_eth_neigh_setup(struct neighbour *n) -{ - struct dn_neigh *dn = (struct dn_neigh *)n; - - memcpy(n->ha, dn->addr, ETH_ALEN); - - return 0; -} - -static int dn_dev_ptp_setsrc(struct sk_buff *skb) -{ - struct device *dev = skb->dev; - struct dn_dev *dn_db = dev->dn_ptr; - struct dn_skb_cb *cb = (struct dn_skb_cb *)skb->cb; - - if (!dn_db->peer) - return -1; - - cb->neigh = dn_eth2dn(((struct dn_neigh *)dn_db->peer)->addr); - - return 0; -} - -static void dn_dev_set_timer(struct device *dev); +static void dn_dev_set_timer(struct net_device *dev); static void dn_dev_timer_func(unsigned long arg) { - struct device *dev = (struct device *)arg; + struct net_device *dev = (struct net_device *)arg; struct dn_dev *dn_db = dev->dn_ptr; #ifdef CONFIG_DECNET_ROUTER @@ -989,7 +917,7 @@ static void dn_dev_timer_func(unsigned long arg) dn_dev_set_timer(dev); } -static void dn_dev_set_timer(struct device *dev) +static void dn_dev_set_timer(struct net_device *dev) { struct dn_dev *dn_db = dev->dn_ptr; @@ -1008,7 +936,7 @@ static void dn_dev_set_timer(struct device *dev) add_timer(&dn_db->timer); } -struct dn_dev *dn_dev_create(struct device *dev, int *err) +struct dn_dev *dn_dev_create(struct net_device *dev, int *err) { int i; struct dn_dev_parms *p = dn_dev_list; @@ -1045,7 +973,7 @@ struct dn_dev *dn_dev_create(struct device *dev, int *err) } dn_db->neigh_parms = neigh_parms_alloc(dev, &dn_neigh_table); - dn_db->neigh_parms->neigh_setup = dn_db->parms.neigh_setup; + /* dn_db->neigh_parms->neigh_setup = dn_db->parms.neigh_setup; */ dn_dev_sysctl_register(dev, &dn_db->parms); @@ -1066,7 +994,7 @@ struct dn_dev *dn_dev_create(struct device *dev, int *err) * MAC addreses automatically. Others must be started * specifically. */ -void dn_dev_up(struct device *dev) +void dn_dev_up(struct net_device *dev) { struct dn_ifaddr *ifa; @@ -1088,18 +1016,15 @@ void dn_dev_up(struct device *dev) dn_dev_set_ifa(dev, ifa); } -static void dn_dev_delete(struct device *dev) +static void dn_dev_delete(struct net_device *dev) { struct dn_dev *dn_db = dev->dn_ptr; - unsigned long cpuflags; if (dn_db == NULL) return; - save_flags(cpuflags); - cli(); del_timer(&dn_db->timer); - restore_flags(cpuflags); + synchronize_bh(); #ifdef CONFIG_RTNETLINK dn_dev_ifinfo(RTM_DELLINK, dev); @@ -1127,7 +1052,7 @@ static void dn_dev_delete(struct device *dev) kfree(dn_db); } -void dn_dev_down(struct device *dev) +void dn_dev_down(struct net_device *dev) { struct dn_dev *dn_db = dev->dn_ptr; struct dn_ifaddr *ifa; @@ -1160,7 +1085,7 @@ void dn_dev_hello(struct sk_buff *skb) void dn_dev_devices_off(void) { - struct device *dev; + struct net_device *dev; for(dev = dev_base; dev; dev = dev->next) dn_dev_down(dev); @@ -1169,7 +1094,7 @@ void dn_dev_devices_off(void) void dn_dev_devices_on(void) { - struct device *dev; + struct net_device *dev; for(dev = dev_base; dev; dev = dev->next) { if (dev->flags & IFF_UP) @@ -1185,7 +1110,7 @@ void dn_dev_devices_on(void) * it as a compile time option. Probably you should use the * rtnetlink interface instead. */ -int dnet_gifconf(struct device *dev, char *buf, int len) +int dnet_gifconf(struct net_device *dev, char *buf, int len) { struct dn_dev *dn_db = (struct dn_dev *)dev->dn_ptr; struct dn_ifaddr *ifa; @@ -1242,17 +1167,17 @@ static char *dn_type2asc(char type) static int decnet_dev_get_info(char *buffer, char **start, off_t offset, int length, int dummy) { struct dn_dev *dn_db; - struct device *dev; + struct net_device *dev; int len = 0; off_t pos = 0; off_t begin = 0; char peer_buf[DN_ASCBUF_LEN]; char router_buf[DN_ASCBUF_LEN]; - cli(); len += sprintf(buffer, "Name Flags T1 Timer1 T3 Timer3 BlkSize Pri State DevType Router Peer\n"); + read_lock(&dev_base_lock); for (dev = dev_base; dev; dev = dev->next) { if ((dn_db = (struct dn_dev *)dev->dn_ptr) == NULL) continue; @@ -1279,7 +1204,7 @@ static int decnet_dev_get_info(char *buffer, char **start, off_t offset, int len break; } - sti(); + read_unlock(&dev_base_lock); *start = buffer + (offset - begin); len -= (offset - begin); @@ -1313,12 +1238,12 @@ static struct rtnetlink_link dnet_rtnetlink_table[RTM_MAX-RTM_BASE+1] = #ifdef CONFIG_DECNET_ROUTER { dn_fib_rtm_newroute, NULL, }, { dn_fib_rtm_delroute, NULL, }, - { dn_fib_rtm_getroute, dn_fib_dump, }, + { dn_cache_getroute, dn_fib_dump, }, { NULL, NULL, }, #else { NULL, NULL, }, { NULL, NULL, }, - { NULL, NULL, }, + { dn_cache_getroute, dn_cache_dump, }, { NULL, NULL, }, #endif { NULL, NULL, }, |