naccyde / rpms / iproute

Forked from rpms/iproute 7 months ago
Clone

Blame SOURCES/0015-ip-xfrm-add-espintcp-encapsulation.patch

359b1d
From b0312111114ed805f84b1e96d73f468e3a372025 Mon Sep 17 00:00:00 2001
359b1d
From: Andrea Claudi <aclaudi@redhat.com>
359b1d
Date: Fri, 5 Jun 2020 15:42:49 +0200
359b1d
Subject: [PATCH] ip: xfrm: add espintcp encapsulation
359b1d
359b1d
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1844045
359b1d
Upstream Status: iproute2.git commit 22aec42679d57
359b1d
359b1d
commit 22aec42679d57b8e0aef864c4d45feadb727c3ce
359b1d
Author: Sabrina Dubroca <sd@queasysnail.net>
359b1d
Date:   Sun Jan 19 11:32:09 2020 +0100
359b1d
359b1d
    ip: xfrm: add espintcp encapsulation
359b1d
359b1d
    While at it, convert xfrm_xfrma_print and xfrm_encap_type_parse to use
359b1d
    the UAPI macros for encap_type as suggested by David Ahern, and add the
359b1d
    UAPI udp.h header (sync'd from ipsec-next to get the TCP_ENCAP_ESPINTCP
359b1d
    definition).
359b1d
359b1d
    Co-developed-by: Herbert Xu <herbert@gondor.apana.org.au>
359b1d
    Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
359b1d
    Signed-off-by: David Ahern <dsahern@gmail.com>
359b1d
---
359b1d
 ip/ipxfrm.c        | 14 ++++++++++----
359b1d
 ip/xfrm_state.c    |  2 +-
359b1d
 man/man8/ip-xfrm.8 |  4 ++--
359b1d
 3 files changed, 13 insertions(+), 7 deletions(-)
359b1d
359b1d
diff --git a/ip/ipxfrm.c b/ip/ipxfrm.c
359b1d
index 32f560933a477..fec206abc1f03 100644
359b1d
--- a/ip/ipxfrm.c
359b1d
+++ b/ip/ipxfrm.c
359b1d
@@ -34,6 +34,7 @@
359b1d
 #include <netdb.h>
359b1d
 #include <linux/netlink.h>
359b1d
 #include <linux/rtnetlink.h>
359b1d
+#include <linux/udp.h>
359b1d
 
359b1d
 #include "utils.h"
359b1d
 #include "xfrm.h"
359b1d
@@ -753,12 +754,15 @@ void xfrm_xfrma_print(struct rtattr *tb[], __u16 family,
359b1d
 
359b1d
 		fprintf(fp, "type ");
359b1d
 		switch (e->encap_type) {
359b1d
-		case 1:
359b1d
+		case UDP_ENCAP_ESPINUDP_NON_IKE:
359b1d
 			fprintf(fp, "espinudp-nonike ");
359b1d
 			break;
359b1d
-		case 2:
359b1d
+		case UDP_ENCAP_ESPINUDP:
359b1d
 			fprintf(fp, "espinudp ");
359b1d
 			break;
359b1d
+		case TCP_ENCAP_ESPINTCP:
359b1d
+			fprintf(fp, "espintcp ");
359b1d
+			break;
359b1d
 		default:
359b1d
 			fprintf(fp, "%u ", e->encap_type);
359b1d
 			break;
359b1d
@@ -1208,9 +1212,11 @@ int xfrm_encap_type_parse(__u16 *type, int *argcp, char ***argvp)
359b1d
 	char **argv = *argvp;
359b1d
 
359b1d
 	if (strcmp(*argv, "espinudp-nonike") == 0)
359b1d
-		*type = 1;
359b1d
+		*type = UDP_ENCAP_ESPINUDP_NON_IKE;
359b1d
 	else if (strcmp(*argv, "espinudp") == 0)
359b1d
-		*type = 2;
359b1d
+		*type = UDP_ENCAP_ESPINUDP;
359b1d
+	else if (strcmp(*argv, "espintcp") == 0)
359b1d
+		*type = TCP_ENCAP_ESPINTCP;
359b1d
 	else
359b1d
 		invarg("ENCAP-TYPE value is invalid", *argv);
359b1d
 
359b1d
diff --git a/ip/xfrm_state.c b/ip/xfrm_state.c
359b1d
index 44f08ceed24dd..f4bf3356bb01f 100644
359b1d
--- a/ip/xfrm_state.c
359b1d
+++ b/ip/xfrm_state.c
359b1d
@@ -112,7 +112,7 @@ static void usage(void)
359b1d
 		"LIMIT-LIST := [ LIMIT-LIST ] limit LIMIT\n"
359b1d
 		"LIMIT := { time-soft | time-hard | time-use-soft | time-use-hard } SECONDS |\n"
359b1d
 		"         { byte-soft | byte-hard } SIZE | { packet-soft | packet-hard } COUNT\n"
359b1d
-		"ENCAP := { espinudp | espinudp-nonike } SPORT DPORT OADDR\n"
359b1d
+		"ENCAP := { espinudp | espinudp-nonike | espintcp } SPORT DPORT OADDR\n"
359b1d
 		"DIR := in | out\n");
359b1d
 
359b1d
 	exit(-1);
359b1d
diff --git a/man/man8/ip-xfrm.8 b/man/man8/ip-xfrm.8
359b1d
index cfce1e40b7f7d..f99f30bb448a6 100644
359b1d
--- a/man/man8/ip-xfrm.8
359b1d
+++ b/man/man8/ip-xfrm.8
359b1d
@@ -207,7 +207,7 @@ ip-xfrm \- transform configuration
359b1d
 
359b1d
 .ti -8
359b1d
 .IR ENCAP " :="
359b1d
-.RB "{ " espinudp " | " espinudp-nonike " }"
359b1d
+.RB "{ " espinudp " | " espinudp-nonike " | " espintcp " }"
359b1d
 .IR SPORT " " DPORT " " OADDR
359b1d
 
359b1d
 .ti -8
359b1d
@@ -548,7 +548,7 @@ sets limits in seconds, bytes, or numbers of packets.
359b1d
 .TP
359b1d
 .I ENCAP
359b1d
 encapsulates packets with protocol
359b1d
-.BR espinudp " or " espinudp-nonike ","
359b1d
+.BR espinudp ", " espinudp-nonike ", or " espintcp ","
359b1d
 .RI "using source port " SPORT ", destination port "  DPORT
359b1d
 .RI ", and original address " OADDR "."
359b1d
 
359b1d
-- 
359b1d
2.26.2
359b1d