naccyde / rpms / iproute

Forked from rpms/iproute 9 months ago
Clone

Blame SOURCES/iproute2-3.10.0-vxlan-add-dstport-option.patch

7787e2
diff --git a/ip/iplink_vxlan.c b/ip/iplink_vxlan.c
7787e2
index 1025326..3450135 100644
7787e2
--- a/ip/iplink_vxlan.c
7787e2
+++ b/ip/iplink_vxlan.c
7787e2
@@ -25,8 +25,8 @@ static void explain(void)
7787e2
 {
7787e2
 	fprintf(stderr, "Usage: ... vxlan id VNI [ group ADDR ] [ local ADDR ]\n");
7787e2
 	fprintf(stderr, "                 [ ttl TTL ] [ tos TOS ] [ dev PHYS_DEV ]\n");
7787e2
-	fprintf(stderr, "                 [ port MIN MAX ] [ [no]learning ]\n");
7787e2
-	fprintf(stderr, "                 [ [no]proxy ] [ [no]rsc ]\n");
7787e2
+	fprintf(stderr, "                 [ dstport PORT ] [ srcport MIN MAX ]\n");
7787e2
+	fprintf(stderr, "                 [ [no]learning ] [ [no]proxy ] [ [no]rsc ]\n");
7787e2
 	fprintf(stderr, "                 [ [no]l2miss ] [ [no]l3miss ]\n");
7787e2
 	fprintf(stderr, "\n");
7787e2
 	fprintf(stderr, "Where: VNI := 0-16777215\n");
7787e2
@@ -53,6 +53,8 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
7787e2
 	__u8 noage = 0;
7787e2
 	__u32 age = 0;
7787e2
 	__u32 maxaddr = 0;
7787e2
+	__u16 dstport = 0;
7787e2
+	int dst_port_set = 0;
7787e2
 	struct ifla_vxlan_port_range range = { 0, 0 };
7787e2
 
7787e2
 	while (argc > 0) {
7787e2
@@ -115,7 +117,8 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
7787e2
 				maxaddr = 0;
7787e2
 			else if (get_u32(&maxaddr, *argv, 0))
7787e2
 				invarg("max addresses", *argv);
7787e2
-		} else if (!matches(*argv, "port")) {
7787e2
+		} else if (!matches(*argv, "port") ||
7787e2
+			   !matches(*argv, "srcport")) {
7787e2
 			__u16 minport, maxport;
7787e2
 			NEXT_ARG();
7787e2
 			if (get_u16(&minport, *argv, 0))
7787e2
@@ -125,6 +128,11 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
7787e2
 				invarg("max port", *argv);
7787e2
 			range.low = htons(minport);
7787e2
 			range.high = htons(maxport);
7787e2
+		} else if (!matches(*argv, "dstport")){
7787e2
+			NEXT_ARG();
7787e2
+			if (get_u16(&dstport, *argv, 0))
7787e2
+				invarg("dst port", *argv);
7787e2
+			dst_port_set = 1;
7787e2
 		} else if (!matches(*argv, "nolearning")) {
7787e2
 			learning = 0;
7787e2
 		} else if (!matches(*argv, "learning")) {
7787e2
@@ -160,6 +168,15 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
7787e2
 		fprintf(stderr, "vxlan: missing virtual network identifier\n");
7787e2
 		return -1;
7787e2
 	}
7787e2
+
7787e2
+	if (!dst_port_set) {
7787e2
+		fprintf(stderr, "vxlan: destination port not specified\n"
7787e2
+			"Will use Linux kernel default (non-standard value)\n");
7787e2
+		fprintf(stderr,
7787e2
+			"Use 'dstport 4789' to get the IANA assigned value\n"
7787e2
+			"Use 'dstport 0' to get default and quiet this message\n");
7787e2
+	}
7787e2
+
7787e2
 	addattr32(n, 1024, IFLA_VXLAN_ID, vni);
7787e2
 	if (gaddr)
7787e2
 		addattr_l(n, 1024, IFLA_VXLAN_GROUP, &gaddr, 4);
7787e2
@@ -184,6 +201,9 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
7787e2
 		addattr_l(n, 1024, IFLA_VXLAN_PORT_RANGE,
7787e2
 			  &range, sizeof(range));
7787e2
 
7787e2
+	if (dstport)
7787e2
+		addattr16(n, 1024, IFLA_VXLAN_PORT, htons(dstport));
7787e2
+
7787e2
 	return 0;
7787e2
 }
7787e2
 
7787e2
@@ -233,9 +253,13 @@ static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
7787e2
 	if (tb[IFLA_VXLAN_PORT_RANGE]) {
7787e2
 		const struct ifla_vxlan_port_range *r
7787e2
 			= RTA_DATA(tb[IFLA_VXLAN_PORT_RANGE]);
7787e2
-		fprintf(f, "port %u %u ", ntohs(r->low), ntohs(r->high));
7787e2
+		fprintf(f, "srcport %u %u ", ntohs(r->low), ntohs(r->high));
7787e2
 	}
7787e2
 
7787e2
+	if (tb[IFLA_VXLAN_PORT])
7787e2
+		fprintf(f, "dstport %u ",
7787e2
+			ntohs(rta_getattr_u16(tb[IFLA_VXLAN_PORT])));
7787e2
+
7787e2
 	if (tb[IFLA_VXLAN_LEARNING] &&
7787e2
 	    !rta_getattr_u8(tb[IFLA_VXLAN_LEARNING]))
7787e2
 		fputs("nolearning ", f);