Blame SOURCES/0048-ip-link-proto_down-config-and-display.patch

4aca6e
From 88507d6ca29f372ad4e8ac17933876205b8d4bab Mon Sep 17 00:00:00 2001
4aca6e
From: Phil Sutter <psutter@redhat.com>
4aca6e
Date: Tue, 28 Feb 2017 16:11:06 +0100
4aca6e
Subject: [PATCH] ip link: proto_down config and display.
4aca6e
4aca6e
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1417289
4aca6e
Upstream Status: iproute2.git commit 188648270ae9d
4aca6e
Conflicts: Man page change applied manually due to previously backported
4aca6e
           synopsis syntax fixup.
4aca6e
4aca6e
commit 188648270ae9d5d967fddf496cd2f2a5ac04e2bf
4aca6e
Author: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
4aca6e
Date:   Tue Jul 14 13:43:22 2015 -0700
4aca6e
4aca6e
    ip link: proto_down config and display.
4aca6e
4aca6e
    This patch adds support to set and display protodown on a switch port. The
4aca6e
    switch driver can handle this error state by doing a phys down on the port.
4aca6e
4aca6e
    One example user space application setting this flag is a multi-chassis
4aca6e
    LAG application to handle split-brain situation on peer-link failure.
4aca6e
4aca6e
    Example:
4aca6e
    root@net-next:~# ip link set eth1 protodown on
4aca6e
    root@net-next:~/iproute2# ip link show eth1
4aca6e
    4: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
4aca6e
        link/ether 52:54:00:12:35:01 brd ff:ff:ff:ff:ff:ff protodown on
4aca6e
    root@net-next:~/iproute2# ip link set eth1 protodown off
4aca6e
    root@net-next:~/iproute2# ip link show eth1
4aca6e
    4: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
4aca6e
        link/ether 52:54:00:12:35:01 brd ff:ff:ff:ff:ff:ff
4aca6e
    root@net-next:~/iproute2#
4aca6e
4aca6e
    Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
4aca6e
    Signed-off-by: Andy Gospodarek <gospo@cumulusnetworks.com>
4aca6e
    Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
4aca6e
    Signed-off-by: Wilson Kok <wkok@cumulusnetworks.com>
4aca6e
---
4aca6e
 ip/ipaddress.c        |  5 +++++
4aca6e
 ip/iplink.c           | 13 +++++++++++++
4aca6e
 man/man8/ip-link.8.in |  8 ++++++++
4aca6e
 3 files changed, 26 insertions(+)
4aca6e
4aca6e
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
4aca6e
index 45b47f9..d5bc2dc 100644
4aca6e
--- a/ip/ipaddress.c
4aca6e
+++ b/ip/ipaddress.c
4aca6e
@@ -692,6 +692,11 @@ int print_linkinfo(const struct sockaddr_nl *who,
4aca6e
 			fprintf(fp, " link-netnsid unknown");
4aca6e
 	}
4aca6e
 
4aca6e
+	if (tb[IFLA_PROTO_DOWN]) {
4aca6e
+		if (rta_getattr_u8(tb[IFLA_PROTO_DOWN]))
4aca6e
+			fprintf(fp, " protodown on ");
4aca6e
+	}
4aca6e
+
4aca6e
 	if (tb[IFLA_PROMISCUITY] && show_details)
4aca6e
 		fprintf(fp, " promiscuity %u ",
4aca6e
 			*(int*)RTA_DATA(tb[IFLA_PROMISCUITY]));
4aca6e
diff --git a/ip/iplink.c b/ip/iplink.c
4aca6e
index 10f97af..06b0a6d 100644
4aca6e
--- a/ip/iplink.c
4aca6e
+++ b/ip/iplink.c
4aca6e
@@ -89,6 +89,7 @@ void iplink_usage(void)
4aca6e
 	fprintf(stderr, "			  [ master DEVICE ]\n");
4aca6e
 	fprintf(stderr, "			  [ nomaster ]\n");
4aca6e
 	fprintf(stderr, "			  [ addrgenmode { eui64 | none } ]\n");
4aca6e
+	fprintf(stderr, "	                  [ protodown { on | off } ]\n");
4aca6e
 	fprintf(stderr, "       ip link show [ DEVICE | group GROUP ] [up] [master DEV] [type TYPE]\n");
4aca6e
 
4aca6e
 	if (iplink_have_newlink()) {
4aca6e
@@ -661,6 +662,18 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
4aca6e
 				invarg("Invalid \"link-netnsid\" value\n", *argv);
4aca6e
 			addattr32(&req->n, sizeof(*req), IFLA_LINK_NETNSID,
4aca6e
 				  link_netnsid);
4aca6e
+		} else if (strcmp(*argv, "protodown") == 0) {
4aca6e
+			unsigned int proto_down;
4aca6e
+
4aca6e
+			NEXT_ARG();
4aca6e
+			if (strcmp(*argv, "on") == 0)
4aca6e
+				proto_down = 1;
4aca6e
+			else if (strcmp(*argv, "off") == 0)
4aca6e
+				proto_down = 0;
4aca6e
+			else
4aca6e
+				return on_off("protodown", *argv);
4aca6e
+			addattr8(&req->n, sizeof(*req), IFLA_PROTO_DOWN,
4aca6e
+				 proto_down);
4aca6e
 		} else {
4aca6e
 			if (strcmp(*argv, "dev") == 0) {
4aca6e
 				NEXT_ARG();
4aca6e
diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
4aca6e
index 73cd86d..38e5416 100644
4aca6e
--- a/man/man8/ip-link.8.in
4aca6e
+++ b/man/man8/ip-link.8.in
4aca6e
@@ -66,6 +66,8 @@ ip-link \- network device configuration
4aca6e
 .br
4aca6e
 .RB "[ " promisc " { " on " | " off " } ]"
4aca6e
 .br
4aca6e
+.BR "[ " protodown " { " on " | " off " } ]"
4aca6e
+.br
4aca6e
 .RB "[ " trailers " { " on " | " off " } ]"
4aca6e
 .br
4aca6e
 .RB "[ " txqueuelen
4aca6e
@@ -936,6 +938,12 @@ change the
4aca6e
 flag on the device.
4aca6e
 
4aca6e
 .TP
4aca6e
+.BR "protodown on " or " protodown off"
4aca6e
+change the
4aca6e
+.B PROTODOWN
4aca6e
+state on the device. Indicates that a protocol error has been detected on the port. Switch drivers can react to this error by doing a phys down on the switch port.
4aca6e
+
4aca6e
+.TP
4aca6e
 .BR "dynamic on " or " dynamic off"
4aca6e
 change the
4aca6e
 .B DYNAMIC
4aca6e
-- 
4aca6e
1.8.3.1
4aca6e