Changeset 30954


Ignore:
Timestamp:
2012-03-16T10:21:59+01:00 (6 years ago)
Author:
nbd
Message:

kernel: optimize out remaining netfilter hooks in the bridging code if bridge filtering is disabled

Location:
trunk/target/linux/generic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/target/linux/generic/patches-3.2/644-bridge_optimize_netfilter_hooks.patch

    r30917 r30954  
    1515--- a/net/bridge/br_private.h 
    1616+++ b/net/bridge/br_private.h 
    17 @@ -491,10 +491,12 @@ static inline bool br_multicast_is_route 
     17@@ -491,12 +491,25 @@ static inline bool br_multicast_is_route 
    1818 extern int br_netfilter_init(void); 
    1919 extern void br_netfilter_fini(void); 
     
    2626+#define br_netfilter_run_hooks()       false 
    2727 #endif 
    28   
    29  /* br_stp.c */ 
    30 --- a/net/bridge/br_input.c 
    31 +++ b/net/bridge/br_input.c 
    32 @@ -26,6 +26,17 @@ const u8 br_group_address[ETH_ALEN] = {  
    33  br_should_route_hook_t __rcu *br_should_route_hook __read_mostly; 
    34  EXPORT_SYMBOL(br_should_route_hook); 
    3528  
    3629+static inline int 
     
    4538+} 
    4639+ 
    47  static int br_pass_frame_up(struct sk_buff *skb) 
    48  { 
    49         struct net_device *indev, *brdev = BR_INPUT_SKB_CB(skb)->brdev; 
    50 @@ -40,7 +51,7 @@ static int br_pass_frame_up(struct sk_bu 
     40 /* br_stp.c */ 
     41 extern void br_log_state(const struct net_bridge_port *p); 
     42 extern struct net_bridge_port *br_get_port(struct net_bridge *br, 
     43--- a/net/bridge/br_input.c 
     44+++ b/net/bridge/br_input.c 
     45@@ -40,7 +40,7 @@ static int br_pass_frame_up(struct sk_bu 
    5146        indev = skb->dev; 
    5247        skb->dev = brdev; 
     
    5752 } 
    5853  
    59 @@ -199,7 +210,7 @@ rx_handler_result_t br_handle_frame(stru 
     54@@ -199,7 +199,7 @@ rx_handler_result_t br_handle_frame(stru 
    6055                } 
    6156  
     
    6661                        return RX_HANDLER_CONSUMED; /* consumed by filter */ 
    6762                } else { 
    68 @@ -224,7 +235,7 @@ forward: 
     63@@ -224,7 +224,7 @@ forward: 
    6964                if (!compare_ether_addr(p->br->dev->dev_addr, dest)) 
    7065                        skb->pkt_type = PACKET_HOST; 
     
    7570                break; 
    7671        default: 
     72--- a/net/bridge/br_forward.c 
     73+++ b/net/bridge/br_forward.c 
     74@@ -55,7 +55,7 @@ int br_dev_queue_push_xmit(struct sk_buf 
     75  
     76 int br_forward_finish(struct sk_buff *skb) 
     77 { 
     78-       return NF_HOOK(NFPROTO_BRIDGE, NF_BR_POST_ROUTING, skb, NULL, skb->dev, 
     79+       return BR_HOOK(NFPROTO_BRIDGE, NF_BR_POST_ROUTING, skb, NULL, skb->dev, 
     80                       br_dev_queue_push_xmit); 
     81  
     82 } 
     83@@ -74,7 +74,7 @@ static void __br_deliver(const struct ne 
     84                return; 
     85        } 
     86  
     87-       NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev, 
     88+       BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev, 
     89                br_forward_finish); 
     90 } 
     91  
     92@@ -91,7 +91,7 @@ static void __br_forward(const struct ne 
     93        skb->dev = to->dev; 
     94        skb_forward_csum(skb); 
     95  
     96-       NF_HOOK(NFPROTO_BRIDGE, NF_BR_FORWARD, skb, indev, skb->dev, 
     97+       BR_HOOK(NFPROTO_BRIDGE, NF_BR_FORWARD, skb, indev, skb->dev, 
     98                br_forward_finish); 
     99 } 
     100  
     101--- a/net/bridge/br_multicast.c 
     102+++ b/net/bridge/br_multicast.c 
     103@@ -824,7 +824,7 @@ static void __br_multicast_send_query(st 
     104        if (port) { 
     105                __skb_push(skb, sizeof(struct ethhdr)); 
     106                skb->dev = port->dev; 
     107-               NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev, 
     108+               BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev, 
     109                        dev_queue_xmit); 
     110        } else 
     111                netif_rx(skb); 
     112--- a/net/bridge/br_stp_bpdu.c 
     113+++ b/net/bridge/br_stp_bpdu.c 
     114@@ -52,7 +52,7 @@ static void br_send_bpdu(struct net_brid 
     115  
     116        skb_reset_mac_header(skb); 
     117  
     118-       NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev, 
     119+       BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev, 
     120                dev_queue_xmit); 
     121 } 
     122  
  • trunk/target/linux/generic/patches-3.3/644-bridge_optimize_netfilter_hooks.patch

    r30917 r30954  
    11--- a/net/bridge/br_input.c 
    22+++ b/net/bridge/br_input.c 
    3 @@ -26,6 +26,17 @@ const u8 br_group_address[ETH_ALEN] = {  
    4  br_should_route_hook_t __rcu *br_should_route_hook __read_mostly; 
    5  EXPORT_SYMBOL(br_should_route_hook); 
     3@@ -40,7 +40,7 @@ static int br_pass_frame_up(struct sk_bu 
     4        indev = skb->dev; 
     5        skb->dev = brdev; 
     6  
     7-       return NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, indev, NULL, 
     8+       return BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, indev, NULL, 
     9                       netif_receive_skb); 
     10 } 
     11  
     12@@ -194,7 +194,7 @@ rx_handler_result_t br_handle_frame(stru 
     13                } 
     14  
     15                /* Deliver packet to local host only */ 
     16-               if (NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, skb->dev, 
     17+               if (BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, skb->dev, 
     18                            NULL, br_handle_local_finish)) { 
     19                        return RX_HANDLER_CONSUMED; /* consumed by filter */ 
     20                } else { 
     21@@ -219,7 +219,7 @@ forward: 
     22                if (!compare_ether_addr(p->br->dev->dev_addr, dest)) 
     23                        skb->pkt_type = PACKET_HOST; 
     24  
     25-               NF_HOOK(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL, 
     26+               BR_HOOK(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL, 
     27                        br_handle_frame_finish); 
     28                break; 
     29        default: 
     30--- a/net/bridge/br_netfilter.c 
     31+++ b/net/bridge/br_netfilter.c 
     32@@ -71,6 +71,11 @@ static int brnf_filter_pppoe_tagged __re 
     33 #define IS_ARP(skb) \ 
     34        (!vlan_tx_tag_present(skb) && skb->protocol == htons(ETH_P_ARP)) 
     35  
     36+bool br_netfilter_run_hooks(void) 
     37+{ 
     38+       return brnf_call_iptables | brnf_call_ip6tables | brnf_call_arptables; 
     39+} 
     40+ 
     41 static inline __be16 vlan_proto(const struct sk_buff *skb) 
     42 { 
     43        if (vlan_tx_tag_present(skb)) 
     44--- a/net/bridge/br_private.h 
     45+++ b/net/bridge/br_private.h 
     46@@ -492,12 +492,25 @@ static inline bool br_multicast_is_route 
     47 extern int br_netfilter_init(void); 
     48 extern void br_netfilter_fini(void); 
     49 extern void br_netfilter_rtable_init(struct net_bridge *); 
     50+extern bool br_netfilter_run_hooks(void); 
     51 #else 
     52 #define br_netfilter_init()    (0) 
     53 #define br_netfilter_fini()    do { } while(0) 
     54 #define br_netfilter_rtable_init(x) 
     55+#define br_netfilter_run_hooks()       false 
     56 #endif 
    657  
    758+static inline int 
     
    1667+} 
    1768+ 
    18  static int br_pass_frame_up(struct sk_buff *skb) 
     69 /* br_stp.c */ 
     70 extern void br_log_state(const struct net_bridge_port *p); 
     71 extern struct net_bridge_port *br_get_port(struct net_bridge *br, 
     72--- a/net/bridge/br_forward.c 
     73+++ b/net/bridge/br_forward.c 
     74@@ -55,7 +55,7 @@ int br_dev_queue_push_xmit(struct sk_buf 
     75  
     76 int br_forward_finish(struct sk_buff *skb) 
    1977 { 
    20         struct net_device *indev, *brdev = BR_INPUT_SKB_CB(skb)->brdev; 
    21 @@ -40,7 +51,7 @@ static int br_pass_frame_up(struct sk_bu 
    22         indev = skb->dev; 
    23         skb->dev = brdev; 
     78-       return NF_HOOK(NFPROTO_BRIDGE, NF_BR_POST_ROUTING, skb, NULL, skb->dev, 
     79+       return BR_HOOK(NFPROTO_BRIDGE, NF_BR_POST_ROUTING, skb, NULL, skb->dev, 
     80                       br_dev_queue_push_xmit); 
    2481  
    25 -       return NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, indev, NULL, 
    26 +       return BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, indev, NULL, 
    27                        netif_receive_skb); 
     82 } 
     83@@ -74,7 +74,7 @@ static void __br_deliver(const struct ne 
     84                return; 
     85        } 
     86  
     87-       NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev, 
     88+       BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev, 
     89                br_forward_finish); 
    2890 } 
    2991  
    30 @@ -194,7 +205,7 @@ rx_handler_result_t br_handle_frame(stru 
    31                 } 
     92@@ -91,7 +91,7 @@ static void __br_forward(const struct ne 
     93        skb->dev = to->dev; 
     94        skb_forward_csum(skb); 
    3295  
    33                 /* Deliver packet to local host only */ 
    34 -               if (NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, skb->dev, 
    35 +               if (BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, skb->dev, 
    36                             NULL, br_handle_local_finish)) { 
    37                         return RX_HANDLER_CONSUMED; /* consumed by filter */ 
    38                 } else { 
    39 @@ -219,7 +230,7 @@ forward: 
    40                 if (!compare_ether_addr(p->br->dev->dev_addr, dest)) 
    41                         skb->pkt_type = PACKET_HOST; 
     96-       NF_HOOK(NFPROTO_BRIDGE, NF_BR_FORWARD, skb, indev, skb->dev, 
     97+       BR_HOOK(NFPROTO_BRIDGE, NF_BR_FORWARD, skb, indev, skb->dev, 
     98                br_forward_finish); 
     99 } 
    42100  
    43 -               NF_HOOK(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL, 
    44 +               BR_HOOK(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL, 
    45                         br_handle_frame_finish); 
    46                 break; 
    47         default: 
    48 --- a/net/bridge/br_netfilter.c 
    49 +++ b/net/bridge/br_netfilter.c 
    50 @@ -62,6 +62,11 @@ static int brnf_filter_pppoe_tagged __re 
    51  #define brnf_filter_pppoe_tagged 0 
    52  #endif 
     101--- a/net/bridge/br_multicast.c 
     102+++ b/net/bridge/br_multicast.c 
     103@@ -827,7 +827,7 @@ static void __br_multicast_send_query(st 
     104        if (port) { 
     105                __skb_push(skb, sizeof(struct ethhdr)); 
     106                skb->dev = port->dev; 
     107-               NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev, 
     108+               BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev, 
     109                        dev_queue_xmit); 
     110        } else 
     111                netif_rx(skb); 
     112--- a/net/bridge/br_stp_bpdu.c 
     113+++ b/net/bridge/br_stp_bpdu.c 
     114@@ -52,7 +52,7 @@ static void br_send_bpdu(struct net_brid 
    53115  
    54 +bool br_netfilter_run_hooks(void) 
    55 +{ 
    56 +       return brnf_call_iptables | brnf_call_ip6tables | brnf_call_arptables; 
    57 +} 
    58 + 
    59  static inline __be16 vlan_proto(const struct sk_buff *skb) 
    60  { 
    61         if (vlan_tx_tag_present(skb)) 
    62 --- a/net/bridge/br_private.h 
    63 +++ b/net/bridge/br_private.h 
    64 @@ -492,10 +492,12 @@ static inline bool br_multicast_is_route 
    65  extern int br_netfilter_init(void); 
    66  extern void br_netfilter_fini(void); 
    67  extern void br_netfilter_rtable_init(struct net_bridge *); 
    68 +extern bool br_netfilter_run_hooks(void); 
    69  #else 
    70  #define br_netfilter_init()    (0) 
    71  #define br_netfilter_fini()    do { } while(0) 
    72  #define br_netfilter_rtable_init(x) 
    73 +#define br_netfilter_run_hooks()       false 
    74  #endif 
     116        skb_reset_mac_header(skb); 
    75117  
    76  /* br_stp.c */ 
     118-       NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev, 
     119+       BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev, 
     120                dev_queue_xmit); 
     121 } 
     122  
Note: See TracChangeset for help on using the changeset viewer.