提交 f8a26028 编写于 作者: S Stephen Hemminger 提交者: David S. Miller

[BRIDGE]: netfilter dont use __constant_htons

Only use__constant_htons() for initializers and switch cases.
For other uses, it is just as efficient and clearer to use htons
Signed-off-by: NStephen Hemminger <shemminger@osdl.org>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 789bc3e5
...@@ -61,14 +61,14 @@ static int brnf_filter_vlan_tagged = 1; ...@@ -61,14 +61,14 @@ static int brnf_filter_vlan_tagged = 1;
#define brnf_filter_vlan_tagged 1 #define brnf_filter_vlan_tagged 1
#endif #endif
#define IS_VLAN_IP (skb->protocol == __constant_htons(ETH_P_8021Q) && \ #define IS_VLAN_IP (skb->protocol == htons(ETH_P_8021Q) && \
hdr->h_vlan_encapsulated_proto == __constant_htons(ETH_P_IP) && \ hdr->h_vlan_encapsulated_proto == htons(ETH_P_IP) && \
brnf_filter_vlan_tagged) brnf_filter_vlan_tagged)
#define IS_VLAN_IPV6 (skb->protocol == __constant_htons(ETH_P_8021Q) && \ #define IS_VLAN_IPV6 (skb->protocol == htons(ETH_P_8021Q) && \
hdr->h_vlan_encapsulated_proto == __constant_htons(ETH_P_IPV6) && \ hdr->h_vlan_encapsulated_proto == htons(ETH_P_IPV6) && \
brnf_filter_vlan_tagged) brnf_filter_vlan_tagged)
#define IS_VLAN_ARP (skb->protocol == __constant_htons(ETH_P_8021Q) && \ #define IS_VLAN_ARP (skb->protocol == htons(ETH_P_8021Q) && \
hdr->h_vlan_encapsulated_proto == __constant_htons(ETH_P_ARP) && \ hdr->h_vlan_encapsulated_proto == htons(ETH_P_ARP) && \
brnf_filter_vlan_tagged) brnf_filter_vlan_tagged)
/* We need these fake structures to make netfilter happy -- /* We need these fake structures to make netfilter happy --
...@@ -120,7 +120,7 @@ static int br_nf_pre_routing_finish_ipv6(struct sk_buff *skb) ...@@ -120,7 +120,7 @@ static int br_nf_pre_routing_finish_ipv6(struct sk_buff *skb)
dst_hold(skb->dst); dst_hold(skb->dst);
skb->dev = nf_bridge->physindev; 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_push(skb, VLAN_HLEN);
skb->nh.raw -= VLAN_HLEN; skb->nh.raw -= VLAN_HLEN;
} }
...@@ -196,7 +196,7 @@ static int br_nf_pre_routing_finish_bridge(struct sk_buff *skb) ...@@ -196,7 +196,7 @@ static int br_nf_pre_routing_finish_bridge(struct sk_buff *skb)
if (!skb->dev) if (!skb->dev)
kfree_skb(skb); kfree_skb(skb);
else { else {
if (skb->protocol == __constant_htons(ETH_P_8021Q)) { if (skb->protocol == htons(ETH_P_8021Q)) {
skb_pull(skb, VLAN_HLEN); skb_pull(skb, VLAN_HLEN);
skb->nh.raw += VLAN_HLEN; skb->nh.raw += VLAN_HLEN;
} }
...@@ -252,7 +252,7 @@ static int br_nf_pre_routing_finish(struct sk_buff *skb) ...@@ -252,7 +252,7 @@ static int br_nf_pre_routing_finish(struct sk_buff *skb)
nf_bridge->mask |= BRNF_BRIDGED_DNAT; nf_bridge->mask |= BRNF_BRIDGED_DNAT;
skb->dev = nf_bridge->physindev; skb->dev = nf_bridge->physindev;
if (skb->protocol == if (skb->protocol ==
__constant_htons(ETH_P_8021Q)) { htons(ETH_P_8021Q)) {
skb_push(skb, VLAN_HLEN); skb_push(skb, VLAN_HLEN);
skb->nh.raw -= VLAN_HLEN; skb->nh.raw -= VLAN_HLEN;
} }
...@@ -271,7 +271,7 @@ static int br_nf_pre_routing_finish(struct sk_buff *skb) ...@@ -271,7 +271,7 @@ static int br_nf_pre_routing_finish(struct sk_buff *skb)
} }
skb->dev = nf_bridge->physindev; 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_push(skb, VLAN_HLEN);
skb->nh.raw -= VLAN_HLEN; skb->nh.raw -= VLAN_HLEN;
} }
...@@ -421,7 +421,7 @@ static unsigned int br_nf_pre_routing(unsigned int hook, struct sk_buff **pskb, ...@@ -421,7 +421,7 @@ static unsigned int br_nf_pre_routing(unsigned int hook, struct sk_buff **pskb,
struct nf_bridge_info *nf_bridge; struct nf_bridge_info *nf_bridge;
struct vlan_ethhdr *hdr = vlan_eth_hdr(*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) {
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
if (!brnf_call_ip6tables) if (!brnf_call_ip6tables)
return NF_ACCEPT; return NF_ACCEPT;
...@@ -429,7 +429,7 @@ static unsigned int br_nf_pre_routing(unsigned int hook, struct sk_buff **pskb, ...@@ -429,7 +429,7 @@ static unsigned int br_nf_pre_routing(unsigned int hook, struct sk_buff **pskb,
if ((skb = skb_share_check(*pskb, GFP_ATOMIC)) == NULL) if ((skb = skb_share_check(*pskb, GFP_ATOMIC)) == NULL)
goto out; goto out;
if (skb->protocol == __constant_htons(ETH_P_8021Q)) { if (skb->protocol == htons(ETH_P_8021Q)) {
skb_pull_rcsum(skb, VLAN_HLEN); skb_pull_rcsum(skb, VLAN_HLEN);
skb->nh.raw += VLAN_HLEN; skb->nh.raw += VLAN_HLEN;
} }
...@@ -440,13 +440,13 @@ static unsigned int br_nf_pre_routing(unsigned int hook, struct sk_buff **pskb, ...@@ -440,13 +440,13 @@ static unsigned int br_nf_pre_routing(unsigned int hook, struct sk_buff **pskb,
return NF_ACCEPT; return NF_ACCEPT;
#endif #endif
if (skb->protocol != __constant_htons(ETH_P_IP) && !IS_VLAN_IP) if (skb->protocol != htons(ETH_P_IP) && !IS_VLAN_IP)
return NF_ACCEPT; return NF_ACCEPT;
if ((skb = skb_share_check(*pskb, GFP_ATOMIC)) == NULL) if ((skb = skb_share_check(*pskb, GFP_ATOMIC)) == NULL)
goto out; goto out;
if (skb->protocol == __constant_htons(ETH_P_8021Q)) { if (skb->protocol == htons(ETH_P_8021Q)) {
skb_pull_rcsum(skb, VLAN_HLEN); skb_pull_rcsum(skb, VLAN_HLEN);
skb->nh.raw += VLAN_HLEN; skb->nh.raw += VLAN_HLEN;
} }
...@@ -523,7 +523,7 @@ static int br_nf_forward_finish(struct sk_buff *skb) ...@@ -523,7 +523,7 @@ static int br_nf_forward_finish(struct sk_buff *skb)
struct net_device *in; struct net_device *in;
struct vlan_ethhdr *hdr = vlan_eth_hdr(skb); 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) {
in = nf_bridge->physindev; in = nf_bridge->physindev;
if (nf_bridge->mask & BRNF_PKT_TYPE) { if (nf_bridge->mask & BRNF_PKT_TYPE) {
skb->pkt_type = PACKET_OTHERHOST; skb->pkt_type = PACKET_OTHERHOST;
...@@ -532,7 +532,7 @@ static int br_nf_forward_finish(struct sk_buff *skb) ...@@ -532,7 +532,7 @@ static int br_nf_forward_finish(struct sk_buff *skb)
} else { } else {
in = *((struct net_device **)(skb->cb)); 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_push(skb, VLAN_HLEN);
skb->nh.raw -= VLAN_HLEN; skb->nh.raw -= VLAN_HLEN;
} }
...@@ -564,12 +564,12 @@ static unsigned int br_nf_forward_ip(unsigned int hook, struct sk_buff **pskb, ...@@ -564,12 +564,12 @@ static unsigned int br_nf_forward_ip(unsigned int hook, struct sk_buff **pskb,
if (!parent) if (!parent)
return NF_DROP; return NF_DROP;
if (skb->protocol == __constant_htons(ETH_P_IP) || IS_VLAN_IP) if (skb->protocol == htons(ETH_P_IP) || IS_VLAN_IP)
pf = PF_INET; pf = PF_INET;
else else
pf = PF_INET6; pf = PF_INET6;
if (skb->protocol == __constant_htons(ETH_P_8021Q)) { if (skb->protocol == htons(ETH_P_8021Q)) {
skb_pull(*pskb, VLAN_HLEN); skb_pull(*pskb, VLAN_HLEN);
(*pskb)->nh.raw += VLAN_HLEN; (*pskb)->nh.raw += VLAN_HLEN;
} }
...@@ -604,7 +604,7 @@ static unsigned int br_nf_forward_arp(unsigned int hook, struct sk_buff **pskb, ...@@ -604,7 +604,7 @@ static unsigned int br_nf_forward_arp(unsigned int hook, struct sk_buff **pskb,
return NF_ACCEPT; return NF_ACCEPT;
#endif #endif
if (skb->protocol != __constant_htons(ETH_P_ARP)) { if (skb->protocol != htons(ETH_P_ARP)) {
if (!IS_VLAN_ARP) if (!IS_VLAN_ARP)
return NF_ACCEPT; return NF_ACCEPT;
skb_pull(*pskb, VLAN_HLEN); skb_pull(*pskb, VLAN_HLEN);
...@@ -628,7 +628,7 @@ static unsigned int br_nf_forward_arp(unsigned int hook, struct sk_buff **pskb, ...@@ -628,7 +628,7 @@ static unsigned int br_nf_forward_arp(unsigned int hook, struct sk_buff **pskb,
/* PF_BRIDGE/LOCAL_OUT ***********************************************/ /* PF_BRIDGE/LOCAL_OUT ***********************************************/
static int br_nf_local_out_finish(struct sk_buff *skb) 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_push(skb, VLAN_HLEN);
skb->nh.raw -= VLAN_HLEN; skb->nh.raw -= VLAN_HLEN;
} }
...@@ -673,7 +673,7 @@ static unsigned int br_nf_local_out(unsigned int hook, struct sk_buff **pskb, ...@@ -673,7 +673,7 @@ static unsigned int br_nf_local_out(unsigned int hook, struct sk_buff **pskb,
if (!skb->nf_bridge) if (!skb->nf_bridge)
return NF_ACCEPT; return NF_ACCEPT;
if (skb->protocol == __constant_htons(ETH_P_IP) || IS_VLAN_IP) if (skb->protocol == htons(ETH_P_IP) || IS_VLAN_IP)
pf = PF_INET; pf = PF_INET;
else else
pf = PF_INET6; pf = PF_INET6;
...@@ -699,7 +699,7 @@ static unsigned int br_nf_local_out(unsigned int hook, struct sk_buff **pskb, ...@@ -699,7 +699,7 @@ static unsigned int br_nf_local_out(unsigned int hook, struct sk_buff **pskb,
skb->pkt_type = PACKET_OTHERHOST; skb->pkt_type = PACKET_OTHERHOST;
nf_bridge->mask ^= BRNF_PKT_TYPE; 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_push(skb, VLAN_HLEN);
skb->nh.raw -= VLAN_HLEN; skb->nh.raw -= VLAN_HLEN;
} }
...@@ -717,7 +717,7 @@ static unsigned int br_nf_local_out(unsigned int hook, struct sk_buff **pskb, ...@@ -717,7 +717,7 @@ static unsigned int br_nf_local_out(unsigned int hook, struct sk_buff **pskb,
if (nf_bridge->netoutdev) if (nf_bridge->netoutdev)
realoutdev = nf_bridge->netoutdev; realoutdev = nf_bridge->netoutdev;
#endif #endif
if (skb->protocol == __constant_htons(ETH_P_8021Q)) { if (skb->protocol == htons(ETH_P_8021Q)) {
skb_pull(skb, VLAN_HLEN); skb_pull(skb, VLAN_HLEN);
(*pskb)->nh.raw += VLAN_HLEN; (*pskb)->nh.raw += VLAN_HLEN;
} }
...@@ -772,7 +772,7 @@ static unsigned int br_nf_post_routing(unsigned int hook, struct sk_buff **pskb, ...@@ -772,7 +772,7 @@ static unsigned int br_nf_post_routing(unsigned int hook, struct sk_buff **pskb,
if (!realoutdev) if (!realoutdev)
return NF_DROP; return NF_DROP;
if (skb->protocol == __constant_htons(ETH_P_IP) || IS_VLAN_IP) if (skb->protocol == htons(ETH_P_IP) || IS_VLAN_IP)
pf = PF_INET; pf = PF_INET;
else else
pf = PF_INET6; pf = PF_INET6;
...@@ -791,7 +791,7 @@ static unsigned int br_nf_post_routing(unsigned int hook, struct sk_buff **pskb, ...@@ -791,7 +791,7 @@ static unsigned int br_nf_post_routing(unsigned int hook, struct sk_buff **pskb,
nf_bridge->mask |= BRNF_PKT_TYPE; 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_pull(skb, VLAN_HLEN);
skb->nh.raw += VLAN_HLEN; skb->nh.raw += VLAN_HLEN;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册