]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
tunnels: add _rcu annotations
authorEric Dumazet <eric.dumazet@gmail.com>
Sun, 24 Oct 2010 21:33:16 +0000 (21:33 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 25 Oct 2010 20:09:45 +0000 (13:09 -0700)
(struct ip6_tnl)->next is rcu protected :
(struct ip_tunnel)->next is rcu protected :
(struct xfrm6_tunnel)->next is rcu protected :

add __rcu annotation and proper rcu primitives.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/ip6_tunnel.h
include/net/ipip.h
include/net/xfrm.h
net/ipv4/gre.c
net/ipv6/tunnel6.c

index fc94ec568a50a54db39053b9bdcf0d862c7eba9a..fc73e667b50e4e79d506fa536b9635ac39e787c9 100644 (file)
@@ -13,7 +13,7 @@
 /* IPv6 tunnel */
 
 struct ip6_tnl {
-       struct ip6_tnl *next;   /* next tunnel in list */
+       struct ip6_tnl __rcu *next;     /* next tunnel in list */
        struct net_device *dev; /* virtual device associated with tunnel */
        struct ip6_tnl_parm parms;      /* tunnel configuration parameters */
        struct flowi fl;        /* flowi template for xmit */
index 58abbf966b0c816a3f22d0060fa0ad8aa08113ea..0403fe4c45199e2f5888d44700a9fb3a93df27af 100644 (file)
@@ -16,7 +16,7 @@ struct ip_tunnel_6rd_parm {
 };
 
 struct ip_tunnel {
-       struct ip_tunnel        *next;
+       struct ip_tunnel __rcu  *next;
        struct net_device       *dev;
 
        int                     err_count;      /* Number of arrived ICMP errors */
index f28d7c9b9f8d4d46978e83060e51dbbcda32bf3b..ffcd47820a5b4266f0206b0c04fd17105a9ad739 100644 (file)
@@ -1272,7 +1272,7 @@ struct xfrm6_tunnel {
        int (*handler)(struct sk_buff *skb);
        int (*err_handler)(struct sk_buff *skb, struct inet6_skb_parm *opt,
                           u8 type, u8 code, int offset, __be32 info);
-       struct xfrm6_tunnel *next;
+       struct xfrm6_tunnel __rcu *next;
        int priority;
 };
 
index caea6885fdbd0810ea3e8d9eeefd5f74282a0930..c6933f2ea3105be192c7eaa1ac06045539cd07cc 100644 (file)
@@ -22,7 +22,7 @@
 #include <net/gre.h>
 
 
-static const struct gre_protocol *gre_proto[GREPROTO_MAX] __read_mostly;
+static const struct gre_protocol __rcu *gre_proto[GREPROTO_MAX] __read_mostly;
 static DEFINE_SPINLOCK(gre_proto_lock);
 
 int gre_add_protocol(const struct gre_protocol *proto, u8 version)
@@ -51,7 +51,8 @@ int gre_del_protocol(const struct gre_protocol *proto, u8 version)
                goto err_out;
 
        spin_lock(&gre_proto_lock);
-       if (gre_proto[version] != proto)
+       if (rcu_dereference_protected(gre_proto[version],
+                       lockdep_is_held(&gre_proto_lock)) != proto)
                goto err_out_unlock;
        rcu_assign_pointer(gre_proto[version], NULL);
        spin_unlock(&gre_proto_lock);
index d9864725d0c6a259ba8a4d35cbe08762de5e53f4..4f3cec12aa8575a860f18124f0f4ee7f83cf540d 100644 (file)
 #include <net/protocol.h>
 #include <net/xfrm.h>
 
-static struct xfrm6_tunnel *tunnel6_handlers __read_mostly;
-static struct xfrm6_tunnel *tunnel46_handlers __read_mostly;
+static struct xfrm6_tunnel __rcu *tunnel6_handlers __read_mostly;
+static struct xfrm6_tunnel __rcu *tunnel46_handlers __read_mostly;
 static DEFINE_MUTEX(tunnel6_mutex);
 
 int xfrm6_tunnel_register(struct xfrm6_tunnel *handler, unsigned short family)
 {
-       struct xfrm6_tunnel **pprev;
+       struct xfrm6_tunnel __rcu **pprev;
+       struct xfrm6_tunnel *t;
        int ret = -EEXIST;
        int priority = handler->priority;
 
        mutex_lock(&tunnel6_mutex);
 
        for (pprev = (family == AF_INET6) ? &tunnel6_handlers : &tunnel46_handlers;
-            *pprev; pprev = &(*pprev)->next) {
-               if ((*pprev)->priority > priority)
+            (t = rcu_dereference_protected(*pprev,
+                       lockdep_is_held(&tunnel6_mutex))) != NULL;
+            pprev = &t->next) {
+               if (t->priority > priority)
                        break;
-               if ((*pprev)->priority == priority)
+               if (t->priority == priority)
                        goto err;
        }
 
@@ -65,14 +68,17 @@ EXPORT_SYMBOL(xfrm6_tunnel_register);
 
 int xfrm6_tunnel_deregister(struct xfrm6_tunnel *handler, unsigned short family)
 {
-       struct xfrm6_tunnel **pprev;
+       struct xfrm6_tunnel __rcu **pprev;
+       struct xfrm6_tunnel *t;
        int ret = -ENOENT;
 
        mutex_lock(&tunnel6_mutex);
 
        for (pprev = (family == AF_INET6) ? &tunnel6_handlers : &tunnel46_handlers;
-            *pprev; pprev = &(*pprev)->next) {
-               if (*pprev == handler) {
+            (t = rcu_dereference_protected(*pprev,
+                       lockdep_is_held(&tunnel6_mutex))) != NULL;
+            pprev = &t->next) {
+               if (t == handler) {
                        *pprev = handler->next;
                        ret = 0;
                        break;