From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Antonio Ojea <aojea@google.com>
Cc: netfilter-devel@vger.kernel.org, fw@strlen.de,
willemb@google.com, edumazet@google.com
Subject: Re: [PATCH net-next 1/2] netfilter: nft_queue: compute SCTP checksum
Date: Tue, 7 May 2024 00:30:27 +0200 [thread overview]
Message-ID: <ZjlaAyG9yF47pxcA@calendula> (raw)
In-Reply-To: <CAAdXToSN6h9vf8wSA3aQz6wU7pkuWsE5=tQ5qNRX_oQhTxNu=Q@mail.gmail.com>
On Fri, May 03, 2024 at 02:46:27PM +0200, Antonio Ojea wrote:
> On Fri, May 3, 2024 at 1:35 PM Antonio Ojea <aojea@google.com> wrote:
> >
> > when the packet is processed with GSO and is SCTP it has to take into
> > account the SCTP checksum.
> >
> > Signed-off-by: Antonio Ojea <aojea@google.com>
> > ---
> > net/netfilter/nfnetlink_queue.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
> > index 00f4bd21c59b..428014aea396 100644
> > --- a/net/netfilter/nfnetlink_queue.c
> > +++ b/net/netfilter/nfnetlink_queue.c
> > @@ -600,6 +600,7 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue,
> > case NFQNL_COPY_PACKET:
> > if (!(queue->flags & NFQA_CFG_F_GSO) &&
> > entskb->ip_summed == CHECKSUM_PARTIAL &&
> > + (skb_csum_is_sctp(entskb) && skb_crc32c_csum_help(entskb)) &&
>
> My bad, this is wrong, it should be an OR so skb_checksum_help is
> always evaluated.
> Pablo suggested in the bugzilla to use a helper, so I'm not sure this
> is the right fix, I've tried
> to look for similar solutions to find a more consistent solution but
> I'm completely new to the
> kernel codebase so some guidance will be appreciated.
skb_crc32c_csum_help() returns 0 on success.
> - skb_checksum_help(entskb))
> + ((skb_csum_is_sctp(entskb) &&
> skb_crc32c_csum_help(entskb)) ||
> + skb_checksum_help(entskb)))
skb_crc32c_csum_help() returns 0 on success, then this calls
skb_checksum_help() which is TCP/UDP specific, which corrupts the
packet.
I think you have to move this to a helper function like:
static int nf_queue_checksum_help(struct sk_buff *entskb)
{
if (skb_csum_is_sctp(entskb))
return skb_crc32c_csum_help(entskb);
return skb_checksum_help(entskb);
}
I can see skb_crc32c_csum_help() could return -EINVAL, the fallback to
skb_checksum_help() is not wanted there in such case.
Thanks.
next prev parent reply other threads:[~2024-05-06 22:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-03 11:34 [PATCH net-next 0/2] netfilter: nfqueue: incorrect sctp checksum Antonio Ojea
2024-05-03 11:34 ` [PATCH net-next 1/2] netfilter: nft_queue: compute SCTP checksum Antonio Ojea
2024-05-03 12:46 ` Antonio Ojea
2024-05-03 13:09 ` Antonio Ojea
2024-05-06 22:30 ` Pablo Neira Ayuso [this message]
2024-05-04 1:51 ` kernel test robot
2024-05-03 11:34 ` [PATCH net-next 2/2] selftests: net: netfilter: nft_queue.sh: sctp checksum Antonio Ojea
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=ZjlaAyG9yF47pxcA@calendula \
--to=pablo@netfilter.org \
--cc=aojea@google.com \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=willemb@google.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.