Fix the VLAN macros in bridge netfilter code. Macros should
not depend on magic variables.  Also, __constant_htons() should
only be for initailizers.

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

--- br-2.6.orig/net/bridge/br_netfilter.c
+++ br-2.6/net/bridge/br_netfilter.c
@@ -61,15 +61,20 @@ static int brnf_filter_vlan_tagged = 1;
 #define brnf_filter_vlan_tagged 1
 #endif
 
-#define IS_VLAN_IP (skb->protocol == __constant_htons(ETH_P_8021Q) &&    \
-       hdr->h_vlan_encapsulated_proto == __constant_htons(ETH_P_IP) &&  \
-       brnf_filter_vlan_tagged)
-#define IS_VLAN_IPV6 (skb->protocol == __constant_htons(ETH_P_8021Q) &&    \
-       hdr->h_vlan_encapsulated_proto == __constant_htons(ETH_P_IPV6) &&  \
-       brnf_filter_vlan_tagged)
-#define IS_VLAN_ARP (skb->protocol == __constant_htons(ETH_P_8021Q) &&   \
-       hdr->h_vlan_encapsulated_proto == __constant_htons(ETH_P_ARP) && \
-       brnf_filter_vlan_tagged)
+#define IS_VLAN_IP(skb) \
+       (skb->protocol == htons(ETH_P_8021Q) &&    \
+        vlan_eth_hdr(skb)->h_vlan_encapsulated_proto == htons(ETH_P_IP) &&     
\
+        brnf_filter_vlan_tagged)
+
+#define IS_VLAN_IPV6(skb) \
+       (skb->protocol == htons(ETH_P_8021Q) &&         \
+        vlan_eth_hdr(skb)->h_vlan_encapsulated_proto == htons(ETH_P_IPV6) &&   
\
+        brnf_filter_vlan_tagged)
+
+#define IS_VLAN_ARP(skb) \
+       (skb->protocol == htons(ETH_P_8021Q) &&               \
+        vlan_eth_hdr(skb)->h_vlan_encapsulated_proto == htons(ETH_P_ARP) &&    
\
+        brnf_filter_vlan_tagged)
 
 /* We need these fake structures to make netfilter happy --
  * lots of places assume that skb->dst != NULL, which isn't
@@ -115,7 +120,7 @@ static inline void nf_bridge_save_header
 {
         int header_size = 16;
 
-       if (skb->protocol == __constant_htons(ETH_P_8021Q))
+       if (skb->protocol == htons(ETH_P_8021Q))
                header_size = 18;
 
        memcpy(skb->nf_bridge->data, skb->data - header_size, header_size);
@@ -138,7 +143,7 @@ static int br_nf_pre_routing_finish_ipv6
        dst_hold(skb->dst);
 
        skb->dev = nf_bridge->physindev;
-       if (skb->protocol == __constant_htons(ETH_P_8021Q)) {
+       if (skb->protocol == htons(ETH_P_8021Q)) {
                skb_push(skb, VLAN_HLEN);
                skb->nh.raw -= VLAN_HLEN;
        }
@@ -214,7 +219,7 @@ static int br_nf_pre_routing_finish_brid
        if (!skb->dev)
                kfree_skb(skb);
        else {
-               if (skb->protocol == __constant_htons(ETH_P_8021Q)) {
+               if (skb->protocol == htons(ETH_P_8021Q)) {
                        skb_pull(skb, VLAN_HLEN);
                        skb->nh.raw += VLAN_HLEN;
                }
@@ -269,8 +274,7 @@ bridged_dnat:
                                 * bridged frame */
                                nf_bridge->mask |= BRNF_BRIDGED_DNAT;
                                skb->dev = nf_bridge->physindev;
-                               if (skb->protocol ==
-                                   __constant_htons(ETH_P_8021Q)) {
+                               if (skb->protocol == htons(ETH_P_8021Q)) {
                                        skb_push(skb, VLAN_HLEN);
                                        skb->nh.raw -= VLAN_HLEN;
                                }
@@ -289,7 +293,7 @@ bridged_dnat:
        }
 
        skb->dev = nf_bridge->physindev;
-       if (skb->protocol == __constant_htons(ETH_P_8021Q)) {
+       if (skb->protocol == htons(ETH_P_8021Q)) {
                skb_push(skb, VLAN_HLEN);
                skb->nh.raw -= VLAN_HLEN;
        }
@@ -435,9 +439,8 @@ static unsigned int br_nf_pre_routing(un
        struct iphdr *iph;
        __u32 len;
        struct sk_buff *skb = *pskb;
-       struct vlan_ethhdr *hdr = vlan_eth_hdr(*pskb);
 
-       if (skb->protocol == __constant_htons(ETH_P_IPV6) || IS_VLAN_IPV6) {
+       if (skb->protocol == htons(ETH_P_IPV6) || IS_VLAN_IPV6(skb)) {
 #ifdef CONFIG_SYSCTL
                if (!brnf_call_ip6tables)
                        return NF_ACCEPT;
@@ -445,7 +448,7 @@ static unsigned int br_nf_pre_routing(un
                if ((skb = skb_share_check(*pskb, GFP_ATOMIC)) == NULL)
                        goto out;
 
-               if (skb->protocol == __constant_htons(ETH_P_8021Q)) {
+               if (skb->protocol == htons(ETH_P_8021Q)) {
                        u8 *vhdr = skb->data;
                        skb_pull(skb, VLAN_HLEN);
                        skb_postpull_rcsum(skb, vhdr, VLAN_HLEN);
@@ -458,13 +461,13 @@ static unsigned int br_nf_pre_routing(un
                return NF_ACCEPT;
 #endif
 
-       if (skb->protocol != __constant_htons(ETH_P_IP) && !IS_VLAN_IP)
+       if (skb->protocol != htons(ETH_P_IP) && !IS_VLAN_IP(skb))
                return NF_ACCEPT;
 
        if ((skb = skb_share_check(*pskb, GFP_ATOMIC)) == NULL)
                goto out;
 
-       if (skb->protocol == __constant_htons(ETH_P_8021Q)) {
+       if (skb->protocol == htons(ETH_P_8021Q)) {
                u8 *vhdr = skb->data;
                skb_pull(skb, VLAN_HLEN);
                skb_postpull_rcsum(skb, vhdr, VLAN_HLEN);
@@ -541,9 +544,8 @@ static int br_nf_forward_finish(struct s
 {
        struct nf_bridge_info *nf_bridge = skb->nf_bridge;
        struct net_device *in;
-       struct vlan_ethhdr *hdr = vlan_eth_hdr(skb);
 
-       if (skb->protocol != __constant_htons(ETH_P_ARP) && !IS_VLAN_ARP) {
+       if (skb->protocol != htons(ETH_P_ARP) && !IS_VLAN_ARP(skb)) {
                in = nf_bridge->physindev;
                if (nf_bridge->mask & BRNF_PKT_TYPE) {
                        skb->pkt_type = PACKET_OTHERHOST;
@@ -552,7 +554,7 @@ static int br_nf_forward_finish(struct s
        } else {
                in = *((struct net_device **)(skb->cb));
        }
-       if (skb->protocol == __constant_htons(ETH_P_8021Q)) {
+       if (skb->protocol == htons(ETH_P_8021Q)) {
                skb_push(skb, VLAN_HLEN);
                skb->nh.raw -= VLAN_HLEN;
        }
@@ -573,7 +575,6 @@ static unsigned int br_nf_forward_ip(uns
 {
        struct sk_buff *skb = *pskb;
        struct nf_bridge_info *nf_bridge;
-       struct vlan_ethhdr *hdr = vlan_eth_hdr(skb);
        struct net_device *parent;
        int pf;
 
@@ -584,12 +585,12 @@ static unsigned int br_nf_forward_ip(uns
        if (!parent)
                return NF_DROP;
 
-       if (skb->protocol == __constant_htons(ETH_P_IP) || IS_VLAN_IP)
+       if (skb->protocol == htons(ETH_P_IP) || IS_VLAN_IP(skb))
                pf = PF_INET;
        else
                pf = PF_INET6;
 
-       if (skb->protocol == __constant_htons(ETH_P_8021Q)) {
+       if (skb->protocol == htons(ETH_P_8021Q)) {
                skb_pull(*pskb, VLAN_HLEN);
                (*pskb)->nh.raw += VLAN_HLEN;
        }
@@ -616,7 +617,6 @@ static unsigned int br_nf_forward_arp(un
                                      int (*okfn)(struct sk_buff *))
 {
        struct sk_buff *skb = *pskb;
-       struct vlan_ethhdr *hdr = vlan_eth_hdr(skb);
        struct net_device **d = (struct net_device **)(skb->cb);
 
 #ifdef CONFIG_SYSCTL
@@ -624,15 +624,15 @@ static unsigned int br_nf_forward_arp(un
                return NF_ACCEPT;
 #endif
 
-       if (skb->protocol != __constant_htons(ETH_P_ARP)) {
-               if (!IS_VLAN_ARP)
+       if (skb->protocol != htons(ETH_P_ARP)) {
+               if (!IS_VLAN_ARP(skb))
                        return NF_ACCEPT;
                skb_pull(*pskb, VLAN_HLEN);
                (*pskb)->nh.raw += VLAN_HLEN;
        }
 
        if (skb->nh.arph->ar_pln != 4) {
-               if (IS_VLAN_ARP) {
+               if (IS_VLAN_ARP(skb)) {
                        skb_push(*pskb, VLAN_HLEN);
                        (*pskb)->nh.raw -= VLAN_HLEN;
                }
@@ -648,7 +648,7 @@ static unsigned int br_nf_forward_arp(un
 /* PF_BRIDGE/LOCAL_OUT ***********************************************/
 static int br_nf_local_out_finish(struct sk_buff *skb)
 {
-       if (skb->protocol == __constant_htons(ETH_P_8021Q)) {
+       if (skb->protocol == htons(ETH_P_8021Q)) {
                skb_push(skb, VLAN_HLEN);
                skb->nh.raw -= VLAN_HLEN;
        }
@@ -687,13 +687,12 @@ static unsigned int br_nf_local_out(unsi
        struct net_device *realindev, *realoutdev;
        struct sk_buff *skb = *pskb;
        struct nf_bridge_info *nf_bridge;
-       struct vlan_ethhdr *hdr = vlan_eth_hdr(skb);
        int pf;
 
        if (!skb->nf_bridge)
                return NF_ACCEPT;
 
-       if (skb->protocol == __constant_htons(ETH_P_IP) || IS_VLAN_IP)
+       if (skb->protocol == htons(ETH_P_IP) || IS_VLAN_IP(skb))
                pf = PF_INET;
        else
                pf = PF_INET6;
@@ -719,7 +718,7 @@ static unsigned int br_nf_local_out(unsi
                        skb->pkt_type = PACKET_OTHERHOST;
                        nf_bridge->mask ^= BRNF_PKT_TYPE;
                }
-               if (skb->protocol == __constant_htons(ETH_P_8021Q)) {
+               if (skb->protocol == htons(ETH_P_8021Q)) {
                        skb_push(skb, VLAN_HLEN);
                        skb->nh.raw -= VLAN_HLEN;
                }
@@ -737,7 +736,7 @@ static unsigned int br_nf_local_out(unsi
        if (nf_bridge->netoutdev)
                realoutdev = nf_bridge->netoutdev;
 #endif
-       if (skb->protocol == __constant_htons(ETH_P_8021Q)) {
+       if (skb->protocol == htons(ETH_P_8021Q)) {
                skb_pull(skb, VLAN_HLEN);
                (*pskb)->nh.raw += VLAN_HLEN;
        }
@@ -772,7 +771,6 @@ static unsigned int br_nf_post_routing(u
 {
        struct sk_buff *skb = *pskb;
        struct nf_bridge_info *nf_bridge = (*pskb)->nf_bridge;
-       struct vlan_ethhdr *hdr = vlan_eth_hdr(skb);
        struct net_device *realoutdev = bridge_parent(skb->dev);
        int pf;
 
@@ -792,7 +790,7 @@ static unsigned int br_nf_post_routing(u
        if (!realoutdev)
                return NF_DROP;
 
-       if (skb->protocol == __constant_htons(ETH_P_IP) || IS_VLAN_IP)
+       if (skb->protocol == htons(ETH_P_IP) || IS_VLAN_IP(skb))
                pf = PF_INET;
        else
                pf = PF_INET6;
@@ -811,7 +809,7 @@ static unsigned int br_nf_post_routing(u
                nf_bridge->mask |= BRNF_PKT_TYPE;
        }
 
-       if (skb->protocol == __constant_htons(ETH_P_8021Q)) {
+       if (skb->protocol == htons(ETH_P_8021Q)) {
                skb_pull(skb, VLAN_HLEN);
                skb->nh.raw += VLAN_HLEN;
        }
-
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