diff options
author | Paul Gortmaker <paul.gortmaker@windriver.com> | 2011-06-21 23:33:34 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-06-21 23:33:34 -0400 |
commit | 56f8a75c17abb854b5907f4a815dc4c3f186ba11 (patch) | |
tree | 6ba333b7668ce7dd04cddecf4f15a0a48b335991 /net/ipv4 | |
parent | f470e5ae34d68880a38aa79ee5c102ebc2a1aef6 (diff) |
ip: introduce ip_is_fragment helper inline function
There are enough instances of this:
iph->frag_off & htons(IP_MF | IP_OFFSET)
that a helper function is probably warranted.
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/ip_input.c | 4 | ||||
-rw-r--r-- | net/ipv4/ip_output.c | 2 | ||||
-rw-r--r-- | net/ipv4/ipconfig.c | 2 | ||||
-rw-r--r-- | net/ipv4/netfilter/nf_defrag_ipv4.c | 2 | ||||
-rw-r--r-- | net/ipv4/netfilter/nf_nat_standalone.c | 2 | ||||
-rw-r--r-- | net/ipv4/xfrm4_policy.c | 2 |
6 files changed, 7 insertions, 7 deletions
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c index c8f48efc5fd3..073a9b01c40c 100644 --- a/net/ipv4/ip_input.c +++ b/net/ipv4/ip_input.c | |||
@@ -165,7 +165,7 @@ int ip_call_ra_chain(struct sk_buff *skb) | |||
165 | (!sk->sk_bound_dev_if || | 165 | (!sk->sk_bound_dev_if || |
166 | sk->sk_bound_dev_if == dev->ifindex) && | 166 | sk->sk_bound_dev_if == dev->ifindex) && |
167 | net_eq(sock_net(sk), dev_net(dev))) { | 167 | net_eq(sock_net(sk), dev_net(dev))) { |
168 | if (ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET)) { | 168 | if (ip_is_fragment(ip_hdr(skb))) { |
169 | if (ip_defrag(skb, IP_DEFRAG_CALL_RA_CHAIN)) | 169 | if (ip_defrag(skb, IP_DEFRAG_CALL_RA_CHAIN)) |
170 | return 1; | 170 | return 1; |
171 | } | 171 | } |
@@ -256,7 +256,7 @@ int ip_local_deliver(struct sk_buff *skb) | |||
256 | * Reassemble IP fragments. | 256 | * Reassemble IP fragments. |
257 | */ | 257 | */ |
258 | 258 | ||
259 | if (ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET)) { | 259 | if (ip_is_fragment(ip_hdr(skb))) { |
260 | if (ip_defrag(skb, IP_DEFRAG_LOCAL_DELIVER)) | 260 | if (ip_defrag(skb, IP_DEFRAG_LOCAL_DELIVER)) |
261 | return 0; | 261 | return 0; |
262 | } | 262 | } |
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index a8024eaa0e87..167da8ba416a 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c | |||
@@ -489,7 +489,7 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) | |||
489 | 489 | ||
490 | if (first_len - hlen > mtu || | 490 | if (first_len - hlen > mtu || |
491 | ((first_len - hlen) & 7) || | 491 | ((first_len - hlen) & 7) || |
492 | (iph->frag_off & htons(IP_MF|IP_OFFSET)) || | 492 | ip_is_fragment(iph) || |
493 | skb_cloned(skb)) | 493 | skb_cloned(skb)) |
494 | goto slow_path; | 494 | goto slow_path; |
495 | 495 | ||
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index ab7e5542c1cf..ae93dd5ef401 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c | |||
@@ -932,7 +932,7 @@ static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, str | |||
932 | goto drop; | 932 | goto drop; |
933 | 933 | ||
934 | /* Fragments are not supported */ | 934 | /* Fragments are not supported */ |
935 | if (h->frag_off & htons(IP_OFFSET | IP_MF)) { | 935 | if (ip_is_fragment(h)) { |
936 | if (net_ratelimit()) | 936 | if (net_ratelimit()) |
937 | printk(KERN_ERR "DHCP/BOOTP: Ignoring fragmented " | 937 | printk(KERN_ERR "DHCP/BOOTP: Ignoring fragmented " |
938 | "reply.\n"); | 938 | "reply.\n"); |
diff --git a/net/ipv4/netfilter/nf_defrag_ipv4.c b/net/ipv4/netfilter/nf_defrag_ipv4.c index f3a9b42b16c6..9bb1b8a37a22 100644 --- a/net/ipv4/netfilter/nf_defrag_ipv4.c +++ b/net/ipv4/netfilter/nf_defrag_ipv4.c | |||
@@ -82,7 +82,7 @@ static unsigned int ipv4_conntrack_defrag(unsigned int hooknum, | |||
82 | #endif | 82 | #endif |
83 | #endif | 83 | #endif |
84 | /* Gather fragments. */ | 84 | /* Gather fragments. */ |
85 | if (ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET)) { | 85 | if (ip_is_fragment(ip_hdr(skb))) { |
86 | enum ip_defrag_users user = nf_ct_defrag_user(hooknum, skb); | 86 | enum ip_defrag_users user = nf_ct_defrag_user(hooknum, skb); |
87 | if (nf_ct_ipv4_gather_frags(skb, user)) | 87 | if (nf_ct_ipv4_gather_frags(skb, user)) |
88 | return NF_STOLEN; | 88 | return NF_STOLEN; |
diff --git a/net/ipv4/netfilter/nf_nat_standalone.c b/net/ipv4/netfilter/nf_nat_standalone.c index 483b76d042da..a6e606e84820 100644 --- a/net/ipv4/netfilter/nf_nat_standalone.c +++ b/net/ipv4/netfilter/nf_nat_standalone.c | |||
@@ -88,7 +88,7 @@ nf_nat_fn(unsigned int hooknum, | |||
88 | 88 | ||
89 | /* We never see fragments: conntrack defrags on pre-routing | 89 | /* We never see fragments: conntrack defrags on pre-routing |
90 | and local-out, and nf_nat_out protects post-routing. */ | 90 | and local-out, and nf_nat_out protects post-routing. */ |
91 | NF_CT_ASSERT(!(ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET))); | 91 | NF_CT_ASSERT(!ip_is_fragment(ip_hdr(skb))); |
92 | 92 | ||
93 | ct = nf_ct_get(skb, &ctinfo); | 93 | ct = nf_ct_get(skb, &ctinfo); |
94 | /* Can't track? It's not due to stress, or conntrack would | 94 | /* Can't track? It's not due to stress, or conntrack would |
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c index 981e43eaf704..fc5368ad2b0d 100644 --- a/net/ipv4/xfrm4_policy.c +++ b/net/ipv4/xfrm4_policy.c | |||
@@ -117,7 +117,7 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse) | |||
117 | memset(fl4, 0, sizeof(struct flowi4)); | 117 | memset(fl4, 0, sizeof(struct flowi4)); |
118 | fl4->flowi4_mark = skb->mark; | 118 | fl4->flowi4_mark = skb->mark; |
119 | 119 | ||
120 | if (!(iph->frag_off & htons(IP_MF | IP_OFFSET))) { | 120 | if (!ip_is_fragment(iph)) { |
121 | switch (iph->protocol) { | 121 | switch (iph->protocol) { |
122 | case IPPROTO_UDP: | 122 | case IPPROTO_UDP: |
123 | case IPPROTO_UDPLITE: | 123 | case IPPROTO_UDPLITE: |