From patchwork Sun Nov 14 21:12:03 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: stephen hemminger X-Patchwork-Id: 71152 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 0E792B7110 for ; Mon, 15 Nov 2010 08:18:22 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756970Ab0KNVST (ORCPT ); Sun, 14 Nov 2010 16:18:19 -0500 Received: from suva.vyatta.com ([76.74.103.44]:52960 "EHLO suva.vyatta.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755473Ab0KNVSM (ORCPT ); Sun, 14 Nov 2010 16:18:12 -0500 Received: from suva.vyatta.com (suva [127.0.0.1]) by suva.vyatta.com (8.13.7/8.13.7) with ESMTP id oAELHwAF016824; Sun, 14 Nov 2010 13:17:58 -0800 Received: (from shemminger@localhost) by suva.vyatta.com (8.13.7/8.13.7/Submit) id oAELHwEZ016823; Sun, 14 Nov 2010 13:17:58 -0800 Message-Id: <20101114211515.189232651@vyatta.com> User-Agent: quilt/0.48-1 Date: Sun, 14 Nov 2010 13:12:03 -0800 From: Stephen Hemminger To: David Miller , Eric Dumazet Cc: netdev@vger.kernel.org, bridge@lists.linux-foundation.org Subject: [PATCH 2/5] bridge: add proper RCU annotation to should_route_hook References: <20101114211201.678755903@vyatta.com> Content-Disposition: inline; filename=bridge-hook-typedef.patch Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Eric Dumazet Add br_should_route_hook_t typedef, this is the only way we can get a clean RCU implementation for function pointer. Signed-off-by: Eric Dumazet Signed-off-by: Stephen Hemminger --- include/linux/if_bridge.h | 4 +++- net/bridge/br.c | 4 ---- net/bridge/br_input.c | 10 +++++++--- net/bridge/netfilter/ebtable_broute.c | 3 ++- 4 files changed, 12 insertions(+), 9 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/net/bridge/br.c 2010-11-14 11:18:54.048692005 -0800 +++ b/net/bridge/br.c 2010-11-14 11:19:47.347027185 -0800 @@ -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"); --- a/net/bridge/br_input.c 2010-11-14 11:18:54.048692005 -0800 +++ b/net/bridge/br_input.c 2010-11-14 11:41:40.558700481 -0800 @@ -21,6 +21,10 @@ /* 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 s { 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; } --- a/include/linux/if_bridge.h 2010-11-14 11:18:54.048692005 -0800 +++ b/include/linux/if_bridge.h 2010-11-14 11:19:47.351028008 -0800 @@ -102,7 +102,9 @@ struct __fdb_entry { #include 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 --- a/net/bridge/netfilter/ebtable_broute.c 2010-11-14 11:20:39.745149494 -0800 +++ b/net/bridge/netfilter/ebtable_broute.c 2010-11-14 11:21:01.020917528 -0800 @@ -87,7 +87,8 @@ static int __init ebtable_broute_init(vo 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; }