]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - net/core/neighbour.c
Merge master.kernel.org:/pub/scm/linux/kernel/git/acme/net-2.6
[linux-2.6.git] / net / core / neighbour.c
index f6bdcad47da6451a9603db531d626077fa946e6d..1dcf7fa1f0fead6dc2469d0a478025284921e804 100644 (file)
@@ -32,6 +32,7 @@
 #include <net/sock.h>
 #include <linux/rtnetlink.h>
 #include <linux/random.h>
+#include <linux/string.h>
 
 #define NEIGH_DEBUG 1
 
@@ -60,7 +61,9 @@ static int pneigh_ifdown(struct neigh_table *tbl, struct net_device *dev);
 void neigh_changeaddr(struct neigh_table *tbl, struct net_device *dev);
 
 static struct neigh_table *neigh_tables;
+#ifdef CONFIG_PROC_FS
 static struct file_operations neigh_stat_seq_fops;
+#endif
 
 /*
    Neighbour hash table buckets are protected with rwlock tbl->lock.
@@ -172,39 +175,10 @@ static void pneigh_queue_purge(struct sk_buff_head *list)
        }
 }
 
-void neigh_changeaddr(struct neigh_table *tbl, struct net_device *dev)
+static void neigh_flush_dev(struct neigh_table *tbl, struct net_device *dev)
 {
        int i;
 
-       write_lock_bh(&tbl->lock);
-
-       for (i=0; i <= tbl->hash_mask; i++) {
-               struct neighbour *n, **np;
-
-               np = &tbl->hash_buckets[i];
-               while ((n = *np) != NULL) {
-                       if (dev && n->dev != dev) {
-                               np = &n->next;
-                               continue;
-                       }
-                       *np = n->next;
-                       write_lock_bh(&n->lock);
-                       n->dead = 1;
-                       neigh_del_timer(n);
-                       write_unlock_bh(&n->lock);
-                       neigh_release(n);
-               }
-       }
-
-        write_unlock_bh(&tbl->lock);
-}
-
-int neigh_ifdown(struct neigh_table *tbl, struct net_device *dev)
-{
-       int i;
-
-       write_lock_bh(&tbl->lock);
-
        for (i = 0; i <= tbl->hash_mask; i++) {
                struct neighbour *n, **np = &tbl->hash_buckets[i];
 
@@ -240,7 +214,19 @@ int neigh_ifdown(struct neigh_table *tbl, struct net_device *dev)
                        neigh_release(n);
                }
        }
+}
+
+void neigh_changeaddr(struct neigh_table *tbl, struct net_device *dev)
+{
+       write_lock_bh(&tbl->lock);
+       neigh_flush_dev(tbl, dev);
+       write_unlock_bh(&tbl->lock);
+}
 
+int neigh_ifdown(struct neigh_table *tbl, struct net_device *dev)
+{
+       write_lock_bh(&tbl->lock);
+       neigh_flush_dev(tbl, dev);
        pneigh_ifdown(tbl, dev);
        write_unlock_bh(&tbl->lock);
 
@@ -724,6 +710,14 @@ static __inline__ int neigh_max_probes(struct neighbour *n)
                p->ucast_probes + p->app_probes + p->mcast_probes);
 }
 
+static inline void neigh_add_timer(struct neighbour *n, unsigned long when)
+{
+       if (unlikely(mod_timer(&n->timer, when))) {
+               printk("NEIGH: BUG, double timer add, state is %x\n",
+                      n->nud_state);
+               dump_stack();
+       }
+}
 
 /* Called when a timer expires for a neighbour entry. */
 
@@ -805,11 +799,10 @@ static void neigh_timer_handler(unsigned long arg)
        }
 
        if (neigh->nud_state & NUD_IN_TIMER) {
-               neigh_hold(neigh);
                if (time_before(next, jiffies + HZ/2))
                        next = jiffies + HZ/2;
-               neigh->timer.expires = next;
-               add_timer(&neigh->timer);
+               if (!mod_timer(&neigh->timer, next))
+                       neigh_hold(neigh);
        }
        if (neigh->nud_state & (NUD_INCOMPLETE | NUD_PROBE)) {
                struct sk_buff *skb = skb_peek(&neigh->arp_queue);
@@ -851,8 +844,7 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
                        atomic_set(&neigh->probes, neigh->parms->ucast_probes);
                        neigh->nud_state     = NUD_INCOMPLETE;
                        neigh_hold(neigh);
-                       neigh->timer.expires = now + 1;
-                       add_timer(&neigh->timer);
+                       neigh_add_timer(neigh, now + 1);
                } else {
                        neigh->nud_state = NUD_FAILED;
                        write_unlock_bh(&neigh->lock);
@@ -865,8 +857,8 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
                NEIGH_PRINTK2("neigh %p is delayed.\n", neigh);
                neigh_hold(neigh);
                neigh->nud_state = NUD_DELAY;
-               neigh->timer.expires = jiffies + neigh->parms->delay_probe_time;
-               add_timer(&neigh->timer);
+               neigh_add_timer(neigh,
+                               jiffies + neigh->parms->delay_probe_time);
        }
 
        if (neigh->nud_state == NUD_INCOMPLETE) {
@@ -1012,10 +1004,10 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
                neigh_del_timer(neigh);
                if (new & NUD_IN_TIMER) {
                        neigh_hold(neigh);
-                       neigh->timer.expires = jiffies + 
+                       neigh_add_timer(neigh, (jiffies + 
                                                ((new & NUD_REACHABLE) ? 
-                                                neigh->parms->reachable_time : 0);
-                       add_timer(&neigh->timer);
+                                                neigh->parms->reachable_time :
+                                                0)));
                }
                neigh->nud_state = new;
        }
@@ -1216,7 +1208,7 @@ static void neigh_proxy_process(unsigned long arg)
 
        while (skb != (struct sk_buff *)&tbl->proxy_queue) {
                struct sk_buff *back = skb;
-               long tdif = back->stamp.tv_usec - now;
+               long tdif = NEIGH_CB(back)->sched_next - now;
 
                skb = skb->next;
                if (tdif <= 0) {
@@ -1247,8 +1239,9 @@ void pneigh_enqueue(struct neigh_table *tbl, struct neigh_parms *p,
                kfree_skb(skb);
                return;
        }
-       skb->stamp.tv_sec  = LOCALLY_ENQUEUED;
-       skb->stamp.tv_usec = sched_next;
+
+       NEIGH_CB(skb)->sched_next = sched_next;
+       NEIGH_CB(skb)->flags |= LOCALLY_ENQUEUED;
 
        spin_lock(&tbl->proxy_queue.lock);
        if (del_timer(&tbl->proxy_timer)) {
@@ -1597,6 +1590,8 @@ static int neightbl_fill_info(struct neigh_table *tbl, struct sk_buff *skb,
 
        read_lock_bh(&tbl->lock);
        ndtmsg->ndtm_family = tbl->family;
+       ndtmsg->ndtm_pad1   = 0;
+       ndtmsg->ndtm_pad2   = 0;
 
        RTA_PUT_STRING(skb, NDTA_NAME, tbl->id);
        RTA_PUT_MSECS(skb, NDTA_GC_INTERVAL, tbl->gc_interval);
@@ -1682,6 +1677,8 @@ static int neightbl_fill_param_info(struct neigh_table *tbl,
 
        read_lock_bh(&tbl->lock);
        ndtmsg->ndtm_family = tbl->family;
+       ndtmsg->ndtm_pad1   = 0;
+       ndtmsg->ndtm_pad2   = 0;
        RTA_PUT_STRING(skb, NDTA_NAME, tbl->id);
 
        if (neightbl_fill_parms(skb, parms) < 0)
@@ -1871,6 +1868,8 @@ static int neigh_fill_info(struct sk_buff *skb, struct neighbour *n,
        struct ndmsg *ndm = NLMSG_DATA(nlh);
 
        ndm->ndm_family  = n->ops->family;
+       ndm->ndm_pad1    = 0;
+       ndm->ndm_pad2    = 0;
        ndm->ndm_flags   = n->flags;
        ndm->ndm_type    = n->type;
        ndm->ndm_ifindex = n->dev->ifindex;
@@ -2335,8 +2334,8 @@ void neigh_app_ns(struct neighbour *n)
        }
        nlh                        = (struct nlmsghdr *)skb->data;
        nlh->nlmsg_flags           = NLM_F_REQUEST;
-       NETLINK_CB(skb).dst_groups = RTMGRP_NEIGH;
-       netlink_broadcast(rtnl, skb, 0, RTMGRP_NEIGH, GFP_ATOMIC);
+       NETLINK_CB(skb).dst_group  = RTNLGRP_NEIGH;
+       netlink_broadcast(rtnl, skb, 0, RTNLGRP_NEIGH, GFP_ATOMIC);
 }
 
 static void neigh_app_notify(struct neighbour *n)
@@ -2353,8 +2352,8 @@ static void neigh_app_notify(struct neighbour *n)
                return;
        }
        nlh                        = (struct nlmsghdr *)skb->data;
-       NETLINK_CB(skb).dst_groups = RTMGRP_NEIGH;
-       netlink_broadcast(rtnl, skb, 0, RTMGRP_NEIGH, GFP_ATOMIC);
+       NETLINK_CB(skb).dst_group  = RTNLGRP_NEIGH;
+       netlink_broadcast(rtnl, skb, 0, RTNLGRP_NEIGH, GFP_ATOMIC);
 }
 
 #endif /* CONFIG_ARPD */
@@ -2592,7 +2591,7 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
                t->neigh_vars[17].extra1 = dev;
        }
 
-       dev_name = net_sysctl_strdup(dev_name_source);
+       dev_name = kstrdup(dev_name_source, GFP_KERNEL);
        if (!dev_name) {
                err = -ENOBUFS;
                goto free;