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

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