Blame SOURCES/0121-tc-cls_flower-Add-dest-UDP-port-to-tunnel-params.patch

4aca6e
From 81c82d64697b25e8b2f7cae85cc4b931a1ad54a0 Mon Sep 17 00:00:00 2001
4aca6e
From: Phil Sutter <psutter@redhat.com>
4aca6e
Date: Fri, 17 Mar 2017 13:23:33 +0100
4aca6e
Subject: [PATCH] tc/cls_flower: Add dest UDP port to tunnel params
4aca6e
4aca6e
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1422629
4aca6e
Upstream Status: iproute2.git commit 41aa17ff4668c
4aca6e
4aca6e
commit 41aa17ff4668ce97ec27e5f4cdc20db7169b549b
4aca6e
Author: Hadar Hen Zion <hadarh@mellanox.com>
4aca6e
Date:   Tue Dec 13 10:07:46 2016 +0200
4aca6e
4aca6e
    tc/cls_flower: Add dest UDP port to tunnel params
4aca6e
4aca6e
    Enhance IP tunnel parameters by adding destination UDP port.
4aca6e
4aca6e
    Signed-off-by: Hadar Hen Zion <hadarh@mellanox.com>
4aca6e
    Reviewed-by: Roi Dayan <roid@mellanox.com>
4aca6e
---
4aca6e
 man/man8/tc-flower.8 |  8 +++++++-
4aca6e
 tc/f_flower.c        | 25 +++++++++++++++++++++++++
4aca6e
 2 files changed, 32 insertions(+), 1 deletion(-)
4aca6e
4aca6e
diff --git a/man/man8/tc-flower.8 b/man/man8/tc-flower.8
4aca6e
index 90fdfba..88df833 100644
4aca6e
--- a/man/man8/tc-flower.8
4aca6e
+++ b/man/man8/tc-flower.8
4aca6e
@@ -39,6 +39,8 @@ flower \- flow based traffic control filter
4aca6e
 .IR KEY-ID " | {"
4aca6e
 .BR enc_dst_ip " | " enc_src_ip " } { "
4aca6e
 .IR ipv4_address " | " ipv6_address " } | "
4aca6e
+.B enc_dst_port
4aca6e
+.IR UDP-PORT " | "
4aca6e
 .SH DESCRIPTION
4aca6e
 The
4aca6e
 .B flower
4aca6e
@@ -129,11 +131,15 @@ which have to be specified in beforehand.
4aca6e
 .BI enc_dst_ip " ADDRESS"
4aca6e
 .TQ
4aca6e
 .BI enc_src_ip " ADDRESS"
4aca6e
+.TQ
4aca6e
+.BI enc_dst_port " NUMBER"
4aca6e
 Match on IP tunnel metadata. Key id
4aca6e
 .I NUMBER
4aca6e
 is a 32 bit tunnel key id (e.g. VNI for VXLAN tunnel).
4aca6e
 .I ADDRESS
4aca6e
-must be a valid IPv4 or IPv6 address.
4aca6e
+must be a valid IPv4 or IPv6 address. Dst port
4aca6e
+.I NUMBER
4aca6e
+is a 16 bit UDP dst port.
4aca6e
 .SH NOTES
4aca6e
 As stated above where applicable, matches of a certain layer implicitly depend
4aca6e
 on the matches of the next lower layer. Precisely, layer one and two matches
4aca6e
diff --git a/tc/f_flower.c b/tc/f_flower.c
4aca6e
index adf7164..00e3ea6 100644
4aca6e
--- a/tc/f_flower.c
4aca6e
+++ b/tc/f_flower.c
4aca6e
@@ -275,6 +275,20 @@ static int flower_parse_key_id(const char *str, int type, struct nlmsghdr *n)
4aca6e
 	return ret;
4aca6e
 }
4aca6e
 
4aca6e
+static int flower_parse_enc_port(char *str, int type, struct nlmsghdr *n)
4aca6e
+{
4aca6e
+	int ret;
4aca6e
+	__be16 port;
4aca6e
+
4aca6e
+	ret = get_be16(&port, str, 10);
4aca6e
+	if (ret)
4aca6e
+		return -1;
4aca6e
+
4aca6e
+	addattr16(n, MAX_MSG, type, port);
4aca6e
+
4aca6e
+	return 0;
4aca6e
+}
4aca6e
+
4aca6e
 static int flower_parse_opt(struct filter_util *qu, char *handle,
4aca6e
 			    int argc, char **argv, struct nlmsghdr *n)
4aca6e
 {
4aca6e
@@ -483,6 +497,14 @@ static int flower_parse_opt(struct filter_util *qu, char *handle,
4aca6e
 				fprintf(stderr, "Illegal \"enc_key_id\"\n");
4aca6e
 				return -1;
4aca6e
 			}
4aca6e
+		} else if (matches(*argv, "enc_dst_port") == 0) {
4aca6e
+			NEXT_ARG();
4aca6e
+			ret = flower_parse_enc_port(*argv,
4aca6e
+						    TCA_FLOWER_KEY_ENC_UDP_DST_PORT, n);
4aca6e
+			if (ret < 0) {
4aca6e
+				fprintf(stderr, "Illegal \"enc_dst_port\"\n");
4aca6e
+				return -1;
4aca6e
+			}
4aca6e
 		} else if (matches(*argv, "action") == 0) {
4aca6e
 			NEXT_ARG();
4aca6e
 			ret = parse_action(&argc, &argv, TCA_FLOWER_ACT, n);
4aca6e
@@ -755,6 +777,9 @@ static int flower_print_opt(struct filter_util *qu, FILE *f,
4aca6e
 	flower_print_key_id(f, "enc_key_id",
4aca6e
 			    tb[TCA_FLOWER_KEY_ENC_KEY_ID]);
4aca6e
 
4aca6e
+	flower_print_port(f, "enc_dst_port",
4aca6e
+			  tb[TCA_FLOWER_KEY_ENC_UDP_DST_PORT]);
4aca6e
+
4aca6e
 	if (tb[TCA_FLOWER_FLAGS]) {
4aca6e
 		__u32 flags = rta_getattr_u32(tb[TCA_FLOWER_FLAGS]);
4aca6e
 
4aca6e
-- 
4aca6e
1.8.3.1
4aca6e