Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 56f8a75c authored by Paul Gortmaker's avatar Paul Gortmaker Committed by David S. Miller
Browse files

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: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f470e5ae
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -3438,7 +3438,7 @@ static int bond_xmit_hash_policy_l34(struct sk_buff *skb, int count)
	int layer4_xor = 0;
	int layer4_xor = 0;


	if (skb->protocol == htons(ETH_P_IP)) {
	if (skb->protocol == htons(ETH_P_IP)) {
		if (!(iph->frag_off & htons(IP_MF|IP_OFFSET)) &&
		if (!ip_is_fragment(iph) &&
		    (iph->protocol == IPPROTO_TCP ||
		    (iph->protocol == IPPROTO_TCP ||
		     iph->protocol == IPPROTO_UDP)) {
		     iph->protocol == IPPROTO_UDP)) {
			layer4_xor = ntohs((*layer4hdr ^ *(layer4hdr + 1)));
			layer4_xor = ntohs((*layer4hdr ^ *(layer4hdr + 1)));
+1 −1
Original line number Original line Diff line number Diff line
@@ -532,7 +532,7 @@ static void ioc3_tcpudp_checksum(struct sk_buff *skb, uint32_t hwsum, int len)
		return;
		return;


	ih = (struct iphdr *) ((char *)eh + ETH_HLEN);
	ih = (struct iphdr *) ((char *)eh + ETH_HLEN);
	if (ih->frag_off & htons(IP_MF | IP_OFFSET))
	if (ip_is_fragment(ih))
		return;
		return;


	proto = ih->protocol;
	proto = ih->protocol;
+1 −1
Original line number Original line Diff line number Diff line
@@ -2257,7 +2257,7 @@ myri10ge_get_frag_header(struct skb_frag_struct *frag, void **mac_hdr,
	*ip_hdr = iph;
	*ip_hdr = iph;
	if (iph->protocol != IPPROTO_TCP)
	if (iph->protocol != IPPROTO_TCP)
		return -1;
		return -1;
	if (iph->frag_off & htons(IP_MF | IP_OFFSET))
	if (ip_is_fragment(iph))
		return -1;
		return -1;
	*hdr_flags |= LRO_TCP;
	*hdr_flags |= LRO_TCP;
	*tcpudp_hdr = (u8 *) (*ip_hdr) + (iph->ihl << 2);
	*tcpudp_hdr = (u8 *) (*ip_hdr) + (iph->ihl << 2);
+1 −1
Original line number Original line Diff line number Diff line
@@ -4109,7 +4109,7 @@ static netdev_tx_t s2io_xmit(struct sk_buff *skb, struct net_device *dev)
			struct tcphdr *th;
			struct tcphdr *th;
			ip = ip_hdr(skb);
			ip = ip_hdr(skb);


			if ((ip->frag_off & htons(IP_OFFSET|IP_MF)) == 0) {
			if (!ip_is_fragment(ip)) {
				th = (struct tcphdr *)(((unsigned char *)ip) +
				th = (struct tcphdr *)(((unsigned char *)ip) +
						       ip->ihl*4);
						       ip->ihl*4);


+1 −1
Original line number Original line Diff line number Diff line
@@ -652,7 +652,7 @@ int efx_filter_rfs(struct net_device *net_dev, const struct sk_buff *skb,
	/* RFS must validate the IP header length before calling us */
	/* RFS must validate the IP header length before calling us */
	EFX_BUG_ON_PARANOID(!pskb_may_pull(skb, nhoff + sizeof(*ip)));
	EFX_BUG_ON_PARANOID(!pskb_may_pull(skb, nhoff + sizeof(*ip)));
	ip = (const struct iphdr *)(skb->data + nhoff);
	ip = (const struct iphdr *)(skb->data + nhoff);
	if (ip->frag_off & htons(IP_MF | IP_OFFSET))
	if (ip_is_fragment(ip))
		return -EPROTONOSUPPORT;
		return -EPROTONOSUPPORT;
	EFX_BUG_ON_PARANOID(!pskb_may_pull(skb, nhoff + 4 * ip->ihl + 4));
	EFX_BUG_ON_PARANOID(!pskb_may_pull(skb, nhoff + 4 * ip->ihl + 4));
	ports = (const __be16 *)(skb->data + nhoff + 4 * ip->ihl);
	ports = (const __be16 *)(skb->data + nhoff + 4 * ip->ihl);
Loading