naccyde / rpms / iproute

Forked from rpms/iproute 8 months ago
Clone

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

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