lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 17 Jun 2011 19:19:24 +0100
From:	Ben Hutchings <bhutchings@...arflare.com>
To:	Paul Gortmaker <paul.gortmaker@...driver.com>
Cc:	davem@...emloft.net, netdev@...r.kernel.org
Subject: Re: [PATCH net-next] ip: introduce ip_is_fragment helper inline
 function

On Fri, 2011-06-17 at 14:08 -0400, Paul Gortmaker wrote:
> There are enough instances of this:
> 
>     iph->frag_off & htons(IP_MF | IP_OFFSET)
> 
> that a helper function is probably warranted.
[...]
> --- a/drivers/net/s2io.c
> +++ b/drivers/net/s2io.c
> @@ -4111,7 +4111,7 @@ static netdev_tx_t s2io_xmit(struct sk_buff *skb, struct net_device *dev)
>  			struct tcphdr *th;
>  			ip = ip_hdr(skb);
>  
> -			if ((ip->frag_off & htons(IP_OFFSET|IP_MF)) == 0) {
> +			if (ip_is_fragment(ip) == 0) {
>  				th = (struct tcphdr *)(((unsigned char *)ip) +
>  						       ip->ihl*4);
>  

The condition should be written more clearly as !ip_is_fragment().

[...]
> diff --git a/include/net/ip.h b/include/net/ip.h
> index e9ea7c7..114a152 100644
> --- a/include/net/ip.h
> +++ b/include/net/ip.h
> @@ -250,6 +250,11 @@ int ip_decrease_ttl(struct iphdr *iph)
>  	return --iph->ttl;
>  }
>  
> +static inline int ip_is_fragment(const struct iphdr *iph)
> +{
> +	return iph->frag_off & htons(IP_MF | IP_OFFSET);
> +}
> +
>  static inline
>  int ip_dont_fragment(struct sock *sk, struct dst_entry *dst)
>  {
[..]

The return type should be bool.

Ben.

-- 
Ben Hutchings, Senior Software Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ