All of lore.kernel.org
 help / color / mirror / Atom feed
From: Antonio Ojea <aojea@google.com>
To: netfilter-devel@vger.kernel.org
Cc: pablo@netfilter.org, fw@strlen.de, Antonio Ojea <aojea@google.com>
Subject: [PATCH v3 1/2] netfilter: nft_queue: compute SCTP checksum
Date: Mon, 13 May 2024 22:00:32 +0000	[thread overview]
Message-ID: <20240513220033.2874981-2-aojea@google.com> (raw)
In-Reply-To: <20240513220033.2874981-1-aojea@google.com>

when packet is enqueued with nfqueue and GSO is enabled, checksum
calculation has to take into account the protocol, as SCTP uses a
32 bits CRC checksum.

Signed-off-by: Antonio Ojea <aojea@google.com>
---
V1 -> V2: add a helper function to process the checksum
V2 -> V3: use tabs instead of whitespaces

 net/netfilter/nfnetlink_queue.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
index 00f4bd21c59b..13802907ddb8 100644
--- a/net/netfilter/nfnetlink_queue.c
+++ b/net/netfilter/nfnetlink_queue.c
@@ -538,6 +538,14 @@ static int nfqnl_put_bridge(struct nf_queue_entry *entry, struct sk_buff *skb)
 	return -1;
 }
 
+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);
+}
+
 static struct sk_buff *
 nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue,
 			   struct nf_queue_entry *entry,
@@ -600,7 +608,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_checksum_help(entskb))
+		    nf_queue_checksum_help(entskb))
 			return NULL;
 
 		data_len = READ_ONCE(queue->copy_range);
-- 
2.45.0.118.g7fe29c98d7-goog


  reply	other threads:[~2024-05-13 22:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-13 22:00 [PATCH v3 0/2] netfilter: nfqueue: incorrect sctp checksum Antonio Ojea
2024-05-13 22:00 ` Antonio Ojea [this message]
2024-05-13 22:18   ` [PATCH v3 1/2] netfilter: nft_queue: compute SCTP checksum Florian Westphal
2024-05-13 22:00 ` [PATCH v3 2/2] selftests: net: netfilter: nft_queue.sh: sctp checksum Antonio Ojea
2024-05-13 22:18   ` Florian Westphal
2024-05-20 11:27 ` [PATCH v3 0/2] netfilter: nfqueue: incorrect " Pablo Neira Ayuso
2024-05-20 15:44   ` Pablo Neira Ayuso
2024-05-20 18:33     ` Pablo Neira Ayuso
2024-05-20 18:47       ` Pablo Neira Ayuso
2024-05-20 18:59         ` Antonio Ojea
2024-05-21 10:48           ` Pablo Neira Ayuso
2024-05-21 10:51             ` Florian Westphal
2024-05-21 12:07               ` Pablo Neira Ayuso
2024-05-21 12:48                 ` Florian Westphal
2024-05-21 12:58                   ` Pablo Neira Ayuso

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=20240513220033.2874981-2-aojea@google.com \
    --to=aojea@google.com \
    --cc=fw@strlen.de \
    --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 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.