Blame SOURCES/0036-proto-add-sctp-crc32-checksum-fixup.patch

acfc56
From 876a1202351264f6d3b105258f10bde693870bd4 Mon Sep 17 00:00:00 2001
acfc56
From: Phil Sutter <psutter@redhat.com>
acfc56
Date: Mon, 7 Dec 2020 18:27:16 +0100
acfc56
Subject: [PATCH] proto: add sctp crc32 checksum fixup
acfc56
acfc56
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1895804
acfc56
Upstream Status: nftables commit 09a3b2ba0c822
acfc56
acfc56
commit 09a3b2ba0c8228d1c6bf0f030cae97addb397351
acfc56
Author: Florian Westphal <fw@strlen.de>
acfc56
Date:   Tue Oct 6 23:16:32 2020 +0200
acfc56
acfc56
    proto: add sctp crc32 checksum fixup
acfc56
acfc56
    Stateless SCTP header mangling doesn't work reliably.
acfc56
    This tells the kernel to update the checksum field using
acfc56
    the sctp crc32 algorithm.
acfc56
acfc56
    Note that this needs additional kernel support to work.
acfc56
acfc56
    Signed-off-by: Florian Westphal <fw@strlen.de>
acfc56
---
acfc56
 include/linux/netfilter/nf_tables.h | 2 ++
acfc56
 include/proto.h                     | 1 +
acfc56
 src/netlink_linearize.c             | 2 +-
acfc56
 src/proto.c                         | 8 ++++++++
acfc56
 4 files changed, 12 insertions(+), 1 deletion(-)
acfc56
acfc56
diff --git a/include/linux/netfilter/nf_tables.h b/include/linux/netfilter/nf_tables.h
acfc56
index 9b54a86..1328b8e 100644
acfc56
--- a/include/linux/netfilter/nf_tables.h
acfc56
+++ b/include/linux/netfilter/nf_tables.h
acfc56
@@ -707,10 +707,12 @@ enum nft_payload_bases {
acfc56
  *
acfc56
  * @NFT_PAYLOAD_CSUM_NONE: no checksumming
acfc56
  * @NFT_PAYLOAD_CSUM_INET: internet checksum (RFC 791)
acfc56
+ * @NFT_PAYLOAD_CSUM_SCTP: CRC-32c, for use in SCTP header (RFC 3309)
acfc56
  */
acfc56
 enum nft_payload_csum_types {
acfc56
 	NFT_PAYLOAD_CSUM_NONE,
acfc56
 	NFT_PAYLOAD_CSUM_INET,
acfc56
+	NFT_PAYLOAD_CSUM_SCTP,
acfc56
 };
acfc56
 
acfc56
 enum nft_payload_csum_flags {
acfc56
diff --git a/include/proto.h b/include/proto.h
acfc56
index fab48c1..436cbe3 100644
acfc56
--- a/include/proto.h
acfc56
+++ b/include/proto.h
acfc56
@@ -78,6 +78,7 @@ struct proto_hdr_template {
acfc56
 struct proto_desc {
acfc56
 	const char			*name;
acfc56
 	enum proto_bases		base;
acfc56
+	enum nft_payload_csum_types	checksum_type;
acfc56
 	unsigned int			checksum_key;
acfc56
 	unsigned int			protocol_key;
acfc56
 	unsigned int			length;
acfc56
diff --git a/src/netlink_linearize.c b/src/netlink_linearize.c
acfc56
index cb1b7fe..606d97a 100644
acfc56
--- a/src/netlink_linearize.c
acfc56
+++ b/src/netlink_linearize.c
acfc56
@@ -937,7 +937,7 @@ static void netlink_gen_payload_stmt(struct netlink_linearize_ctx *ctx,
acfc56
 			   expr->len / BITS_PER_BYTE);
acfc56
 	if (csum_off) {
acfc56
 		nftnl_expr_set_u32(nle, NFTNL_EXPR_PAYLOAD_CSUM_TYPE,
acfc56
-				   NFT_PAYLOAD_CSUM_INET);
acfc56
+				   desc->checksum_type);
acfc56
 		nftnl_expr_set_u32(nle, NFTNL_EXPR_PAYLOAD_CSUM_OFFSET,
acfc56
 				   csum_off / BITS_PER_BYTE);
acfc56
 	}
acfc56
diff --git a/src/proto.c b/src/proto.c
acfc56
index 40ce590..8360abf 100644
acfc56
--- a/src/proto.c
acfc56
+++ b/src/proto.c
acfc56
@@ -345,6 +345,7 @@ const struct proto_desc proto_icmp = {
acfc56
 	.name		= "icmp",
acfc56
 	.base		= PROTO_BASE_TRANSPORT_HDR,
acfc56
 	.checksum_key	= ICMPHDR_CHECKSUM,
acfc56
+	.checksum_type  = NFT_PAYLOAD_CSUM_INET,
acfc56
 	.templates	= {
acfc56
 		[ICMPHDR_TYPE]		= ICMPHDR_TYPE("type", &icmp_type_type, type),
acfc56
 		[ICMPHDR_CODE]		= ICMPHDR_TYPE("code", &icmp_code_type, code),
acfc56
@@ -397,6 +398,7 @@ const struct proto_desc proto_igmp = {
acfc56
 	.name		= "igmp",
acfc56
 	.base		= PROTO_BASE_TRANSPORT_HDR,
acfc56
 	.checksum_key	= IGMPHDR_CHECKSUM,
acfc56
+	.checksum_type  = NFT_PAYLOAD_CSUM_INET,
acfc56
 	.templates	= {
acfc56
 		[IGMPHDR_TYPE]		= IGMPHDR_TYPE("type", &igmp_type_type, igmp_type),
acfc56
 		[IGMPHDR_MRT]		= IGMPHDR_FIELD("mrt", igmp_code),
acfc56
@@ -417,6 +419,7 @@ const struct proto_desc proto_udp = {
acfc56
 	.name		= "udp",
acfc56
 	.base		= PROTO_BASE_TRANSPORT_HDR,
acfc56
 	.checksum_key	= UDPHDR_CHECKSUM,
acfc56
+	.checksum_type  = NFT_PAYLOAD_CSUM_INET,
acfc56
 	.templates	= {
acfc56
 		[UDPHDR_SPORT]		= INET_SERVICE("sport", struct udphdr, source),
acfc56
 		[UDPHDR_DPORT]		= INET_SERVICE("dport", struct udphdr, dest),
acfc56
@@ -474,6 +477,7 @@ const struct proto_desc proto_tcp = {
acfc56
 	.name		= "tcp",
acfc56
 	.base		= PROTO_BASE_TRANSPORT_HDR,
acfc56
 	.checksum_key	= TCPHDR_CHECKSUM,
acfc56
+	.checksum_type  = NFT_PAYLOAD_CSUM_INET,
acfc56
 	.templates	= {
acfc56
 		[TCPHDR_SPORT]		= INET_SERVICE("sport", struct tcphdr, source),
acfc56
 		[TCPHDR_DPORT]		= INET_SERVICE("dport", struct tcphdr, dest),
acfc56
@@ -553,6 +557,8 @@ const struct proto_desc proto_dccp = {
acfc56
 const struct proto_desc proto_sctp = {
acfc56
 	.name		= "sctp",
acfc56
 	.base		= PROTO_BASE_TRANSPORT_HDR,
acfc56
+	.checksum_key	= SCTPHDR_CHECKSUM,
acfc56
+	.checksum_type  = NFT_PAYLOAD_CSUM_SCTP,
acfc56
 	.templates	= {
acfc56
 		[SCTPHDR_SPORT]		= INET_SERVICE("sport", struct sctphdr, source),
acfc56
 		[SCTPHDR_DPORT]		= INET_SERVICE("dport", struct sctphdr, dest),
acfc56
@@ -650,6 +656,7 @@ const struct proto_desc proto_ip = {
acfc56
 	.name		= "ip",
acfc56
 	.base		= PROTO_BASE_NETWORK_HDR,
acfc56
 	.checksum_key	= IPHDR_CHECKSUM,
acfc56
+	.checksum_type  = NFT_PAYLOAD_CSUM_INET,
acfc56
 	.protocols	= {
acfc56
 		PROTO_LINK(IPPROTO_ICMP,	&proto_icmp),
acfc56
 		PROTO_LINK(IPPROTO_IGMP,	&proto_igmp),
acfc56
@@ -746,6 +753,7 @@ const struct proto_desc proto_icmp6 = {
acfc56
 	.name		= "icmpv6",
acfc56
 	.base		= PROTO_BASE_TRANSPORT_HDR,
acfc56
 	.checksum_key	= ICMP6HDR_CHECKSUM,
acfc56
+	.checksum_type  = NFT_PAYLOAD_CSUM_INET,
acfc56
 	.templates	= {
acfc56
 		[ICMP6HDR_TYPE]		= ICMP6HDR_TYPE("type", &icmp6_type_type, icmp6_type),
acfc56
 		[ICMP6HDR_CODE]		= ICMP6HDR_TYPE("code", &icmpv6_code_type, icmp6_code),
acfc56
-- 
8ff5ad
2.31.1
acfc56