Move the inline functions that are used one place from 
netfilter_bridge include to the file they are used in.

Change nf_bridge_alloc to use kzalloc.

Signed-off-by: Stephen Hemminger <[EMAIL PROTECTED]>


--- br-fix.orig/include/linux/netfilter_bridge.h
+++ br-fix/include/linux/netfilter_bridge.h
@@ -47,46 +47,6 @@ enum nf_br_hook_priorities {
 #define BRNF_BRIDGED                   0x08
 #define BRNF_NF_BRIDGE_PREROUTING      0x10
 
-static inline
-struct nf_bridge_info *nf_bridge_alloc(struct sk_buff *skb)
-{
-       struct nf_bridge_info **nf_bridge = &(skb->nf_bridge);
-
-       if ((*nf_bridge = kmalloc(sizeof(**nf_bridge), GFP_ATOMIC)) != NULL) {
-               atomic_set(&(*nf_bridge)->use, 1);
-               (*nf_bridge)->mask = 0;
-               (*nf_bridge)->physindev = (*nf_bridge)->physoutdev = NULL;
-#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
-               (*nf_bridge)->netoutdev = NULL;
-#endif
-       }
-
-       return *nf_bridge;
-}
-
-/* Only used in br_forward.c */
-static inline
-void nf_bridge_maybe_copy_header(struct sk_buff *skb)
-{
-       if (skb->nf_bridge) {
-               if (skb->protocol == __constant_htons(ETH_P_8021Q)) {
-                       memcpy(skb->data - 18, skb->nf_bridge->data, 18);
-                       skb_push(skb, 4);
-               } else
-                       memcpy(skb->data - 16, skb->nf_bridge->data, 16);
-       }
-}
-
-static inline
-void nf_bridge_save_header(struct sk_buff *skb)
-{
-        int header_size = 16;
-
-       if (skb->protocol == __constant_htons(ETH_P_8021Q))
-               header_size = 18;
-
-       memcpy(skb->nf_bridge->data, skb->data - header_size, header_size);
-}
 
 /* This is called by the IP fragmenting code and it ensures there is
  * enough room for the encapsulating header (if there is one). */
--- br-fix.orig/net/bridge/br_forward.c
+++ br-fix/net/bridge/br_forward.c
@@ -19,6 +19,18 @@
 #include <linux/netfilter_bridge.h>
 #include "br_private.h"
 
+/* Only used in br_forward.c */
+static inline void nf_bridge_maybe_copy_header(struct sk_buff *skb)
+{
+       if (skb->nf_bridge) {
+               if (skb->protocol == __constant_htons(ETH_P_8021Q)) {
+                       memcpy(skb->data - 18, skb->nf_bridge->data, 18);
+                       skb_push(skb, 4);
+               } else
+                       memcpy(skb->data - 16, skb->nf_bridge->data, 16);
+       }
+}
+
 static inline int should_deliver(const struct net_bridge_port *p, 
                                 const struct sk_buff *skb)
 {
--- br-fix.orig/net/bridge/br_netfilter.c
+++ br-fix/net/bridge/br_netfilter.c
@@ -98,6 +98,27 @@ static struct rtable __fake_rtable = {
        .rt_flags       = 0,
 };
 
+static struct nf_bridge_info *nf_bridge_alloc(void)
+{
+       struct nf_bridge_info *nf_bridge;
+
+       nf_bridge = kzalloc(sizeof(struct nf_bridge_info), GFP_ATOMIC);
+       if (nf_bridge)
+               atomic_set(&(nf_bridge->use), 1);
+
+       return nf_bridge;
+}
+
+
+static void nf_bridge_save_header(struct sk_buff *skb)
+{
+        int header_size = 16;
+
+       if (skb->protocol == __constant_htons(ETH_P_8021Q))
+               header_size = 18;
+
+       memcpy(skb->nf_bridge->data, skb->data - header_size, header_size);
+}
 
 /* PF_BRIDGE/PRE_ROUTING *********************************************/
 /* Undo the changes made for ip6tables PREROUTING and continue the
@@ -345,7 +366,6 @@ static unsigned int br_nf_pre_routing_ip
 {
        struct ipv6hdr *hdr;
        u32 pkt_len;
-       struct nf_bridge_info *nf_bridge;
 
        if (skb->len < sizeof(struct ipv6hdr))
                goto inhdr_error;
@@ -374,8 +394,11 @@ static unsigned int br_nf_pre_routing_ip
                        goto inhdr_error;
 
        nf_bridge_put(skb->nf_bridge);
-       if ((nf_bridge = nf_bridge_alloc(skb)) == NULL)
+
+       skb->nf_bridge = nf_bridge_alloc();
+       if (!skb->nf_bridge)
                return NF_DROP;
+
        setup_pre_routing(skb);
 
        NF_HOOK(PF_INET6, NF_IP6_PRE_ROUTING, skb, skb->dev, NULL,
@@ -401,7 +424,6 @@ static unsigned int br_nf_pre_routing(un
        struct iphdr *iph;
        __u32 len;
        struct sk_buff *skb = *pskb;
-       struct nf_bridge_info *nf_bridge;
        struct vlan_ethhdr *hdr = vlan_eth_hdr(*pskb);
 
        if (skb->protocol == __constant_htons(ETH_P_IPV6) || IS_VLAN_IPV6) {
@@ -463,8 +485,10 @@ static unsigned int br_nf_pre_routing(un
        }
 
        nf_bridge_put(skb->nf_bridge);
-       if ((nf_bridge = nf_bridge_alloc(skb)) == NULL)
+       skb->nf_bridge = nf_bridge_alloc();
+       if (!skb->nf_bridge)
                return NF_DROP;
+
        setup_pre_routing(skb);
        store_orig_dstaddr(skb);
 
@@ -842,7 +866,8 @@ static unsigned int ip_sabotage_out(unsi
 #endif
                        if (hook == NF_IP_POST_ROUTING)
                                return NF_ACCEPT;
-                       if (!nf_bridge_alloc(skb))
+                       skb->nf_bridge = nf_bridge_alloc();
+                       if (!skb->nf_bridge)
                                return NF_DROP;
                }
 

--
Stephen Hemminger <[EMAIL PROTECTED]>
OSDL http://developer.osdl.org/~shemminger

-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to