netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Li,Rongqing" <lirongqing@baidu.com>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: "netfilter-devel@vger.kernel.org" <netfilter-devel@vger.kernel.org>
Subject: 答复: [PATCH] netfilter: only call csum_tcpudp_magic for TCP/UDP packets
Date: Wed, 13 Nov 2019 01:13:04 +0000	[thread overview]
Message-ID: <1072b63d920747948e87f6536d38458c@baidu.com> (raw)
In-Reply-To: <20191112213018.6uay6m3jxycjyks2@salvia>



> -----邮件原件-----
> 发件人: netfilter-devel-owner@vger.kernel.org
> [mailto:netfilter-devel-owner@vger.kernel.org] 代表 Pablo Neira Ayuso
> 发送时间: 2019年11月13日 5:30
> 收件人: Li,Rongqing <lirongqing@baidu.com>
> 抄送: netfilter-devel@vger.kernel.org
> 主题: Re: [PATCH] netfilter: only call csum_tcpudp_magic for TCP/UDP packets
> 
> On Sat, Nov 09, 2019 at 03:50:17PM +0800, Li RongQing wrote:
> > csum_tcpudp_magic should not be called to compute checksum for
> > non-TCP/UDP packets, like ICMP with wrong checksum
> 
> This is fixing 5d1549847c76b1ffcf8e388ef4d0f229bdd1d7e8.
> 
> > Signed-off-by: Li RongQing <lirongqing@baidu.com>
> > ---
> >  net/netfilter/utils.c | 9 ++++++---
> >  1 file changed, 6 insertions(+), 3 deletions(-)
> >
> > diff --git a/net/netfilter/utils.c b/net/netfilter/utils.c index
> > 51b454d8fa9c..72eace52874e 100644
> > --- a/net/netfilter/utils.c
> > +++ b/net/netfilter/utils.c
> > @@ -17,9 +17,12 @@ __sum16 nf_ip_checksum(struct sk_buff *skb,
> unsigned int hook,
> >  	case CHECKSUM_COMPLETE:
> >  		if (hook != NF_INET_PRE_ROUTING && hook != NF_INET_LOCAL_IN)
> >  			break;
> > -		if ((protocol != IPPROTO_TCP && protocol != IPPROTO_UDP &&
> > -		    !csum_fold(skb->csum)) ||
> > -		    !csum_tcpudp_magic(iph->saddr, iph->daddr,
> > +		if (protocol != IPPROTO_TCP && protocol != IPPROTO_UDP) {
> > +			if (!csum_fold(skb->csum)) {
> > +				skb->ip_summed = CHECKSUM_UNNECESSARY;
> > +				break;
> > +			}
> > +		} else if (!csum_tcpudp_magic(iph->saddr, iph->daddr,
> >  				       skb->len - dataoff, protocol,
> >  				       skb->csum)) {
> 
> Probably disentangle this code with the following snippet?
> 
>                 switch (protocol) {
>                 case IPPROTO_TCP:
>                 case IPPROTO_UDP:
>                         if (!csum_tcpudp_magic(iph->saddr, iph->daddr,
>                                                skb->len - dataoff,
> protocol,
>                                                skb->csum))
>                                  skb->ip_summed =
> CHECKSUM_UNNECESSARY;
>                         break;
>                 default:
>                         if (!csum_fold(skb->csum))
>                                 skb->ip_summed =
> CHECKSUM_UNNECESSARY;
>                         break;
>                 }
> 
OK ,I will send V2, thanks

-RongQing

      reply	other threads:[~2019-11-13  2:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-09  7:50 [PATCH] netfilter: only call csum_tcpudp_magic for TCP/UDP packets Li RongQing
2019-11-12 21:30 ` Pablo Neira Ayuso
2019-11-13  1:13   ` Li,Rongqing [this message]

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=1072b63d920747948e87f6536d38458c@baidu.com \
    --to=lirongqing@baidu.com \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.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).