]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
bridge: add proper RCU annotation to should_route_hook
authorEric Dumazet <eric.dumazet@gmail.com>
Mon, 15 Nov 2010 06:38:11 +0000 (06:38 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 15 Nov 2010 19:13:16 +0000 (11:13 -0800)
Add br_should_route_hook_t typedef, this is the only way we can
get a clean RCU implementation for function pointer.

Move route_hook to location where it is used.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/if_bridge.h
net/bridge/br.c
net/bridge/br_input.c
net/bridge/netfilter/ebtable_broute.c

index 0d241a5c4909b8bdc99f107b1ba4ac60de9996ae..f7e73c338c40f630f5b0e9bf204c3ab82f00c356 100644 (file)
@@ -102,7 +102,9 @@ struct __fdb_entry {
 #include <linux/netdevice.h>
 
 extern void brioctl_set(int (*ioctl_hook)(struct net *, unsigned int, void __user *));
-extern int (*br_should_route_hook)(struct sk_buff *skb);
+
+typedef int (*br_should_route_hook_t)(struct sk_buff *skb);
+extern br_should_route_hook_t __rcu *br_should_route_hook;
 
 #endif
 
index c8436fa31344000ffebe460a9f496b7cfc339ce8..84bbb82599b2582adcdd0a8ee352a69a1e67c8ec 100644 (file)
@@ -22,8 +22,6 @@
 
 #include "br_private.h"
 
-int (*br_should_route_hook)(struct sk_buff *skb);
-
 static const struct stp_proto br_stp_proto = {
        .rcv    = br_stp_rcv,
 };
@@ -102,8 +100,6 @@ static void __exit br_deinit(void)
        br_fdb_fini();
 }
 
-EXPORT_SYMBOL(br_should_route_hook);
-
 module_init(br_init)
 module_exit(br_deinit)
 MODULE_LICENSE("GPL");
index 25207a1f182be33d9b588a3d5fdbc1273c269409..6f6d8e1b776f704ee45e93d4d827f320f8becf62 100644 (file)
 /* Bridge group multicast address 802.1d (pg 51). */
 const u8 br_group_address[ETH_ALEN] = { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x00 };
 
+/* Hook for brouter */
+br_should_route_hook_t __rcu *br_should_route_hook __read_mostly;
+EXPORT_SYMBOL(br_should_route_hook);
+
 static int br_pass_frame_up(struct sk_buff *skb)
 {
        struct net_device *indev, *brdev = BR_INPUT_SKB_CB(skb)->brdev;
@@ -139,7 +143,7 @@ struct sk_buff *br_handle_frame(struct sk_buff *skb)
 {
        struct net_bridge_port *p;
        const unsigned char *dest = eth_hdr(skb)->h_dest;
-       int (*rhook)(struct sk_buff *skb);
+       br_should_route_hook_t *rhook;
 
        if (unlikely(skb->pkt_type == PACKET_LOOPBACK))
                return skb;
@@ -173,8 +177,8 @@ forward:
        switch (p->state) {
        case BR_STATE_FORWARDING:
                rhook = rcu_dereference(br_should_route_hook);
-               if (rhook != NULL) {
-                       if (rhook(skb))
+               if (rhook) {
+                       if ((*rhook)(skb))
                                return skb;
                        dest = eth_hdr(skb)->h_dest;
                }
index ae3f106c39081c445a65dcd2fd07eff90c8403c8..1bcaf36ad612739f54e411984218f79ec645e808 100644 (file)
@@ -87,7 +87,8 @@ static int __init ebtable_broute_init(void)
        if (ret < 0)
                return ret;
        /* see br_input.c */
-       rcu_assign_pointer(br_should_route_hook, ebt_broute);
+       rcu_assign_pointer(br_should_route_hook,
+                          (br_should_route_hook_t *)ebt_broute);
        return 0;
 }