From: Paul Gortmaker <paul.gortmaker@windriver.com>
To: Ben Hutchings <bhutchings@solarflare.com>
Cc: <davem@davemloft.net>, <netdev@vger.kernel.org>
Subject: Re: [PATCH net-next] ip: introduce ip_is_fragment helper inline function
Date: Fri, 17 Jun 2011 14:24:14 -0400 [thread overview]
Message-ID: <4DFB9BCE.2060000@windriver.com> (raw)
In-Reply-To: <1308334764.2831.18.camel@bwh-desktop>
On 11-06-17 02:19 PM, Ben Hutchings wrote:
> 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().
Agreed, and I actually had that but then "un-did" it since
I didn't want to force my choices of coding style down
into drivers. Maybe I was just being overcautious.
>
> [...]
>> 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.
I can make that change. I'll sit on it for a bit in case anyone
else sees anything else needing a tweak.
Thanks Ben,
Paul.
>
> Ben.
>
next prev parent reply other threads:[~2011-06-17 18:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-17 18:08 [PATCH net-next] ip: introduce ip_is_fragment helper inline function Paul Gortmaker
2011-06-17 18:19 ` Ben Hutchings
2011-06-17 18:24 ` Paul Gortmaker [this message]
2011-06-20 15:35 ` Flavio Leitner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4DFB9BCE.2060000@windriver.com \
--to=paul.gortmaker@windriver.com \
--cc=bhutchings@solarflare.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).