naccyde / rpms / iproute

Forked from rpms/iproute 9 months ago
Clone

Blame SOURCES/0035-bridge-link-add-option-self.patch

4aca6e
From fdd7d2f09ca54afb4271b2f50c69fb8991f56db2 Mon Sep 17 00:00:00 2001
4aca6e
From: Phil Sutter <psutter@redhat.com>
4aca6e
Date: Tue, 28 Feb 2017 16:09:45 +0100
4aca6e
Subject: [PATCH] bridge link: add option 'self'
4aca6e
4aca6e
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1417289
4aca6e
Upstream Status: iproute2.git commit 6fdb465869ccd
4aca6e
4aca6e
commit 6fdb465869ccda91d9cc2e6f8ee3aca448df5d33
4aca6e
Author: Roopa Prabhu <roopa@cumulusnetworks.com>
4aca6e
Date:   Sat Dec 6 00:21:01 2014 -0800
4aca6e
4aca6e
    bridge link: add option 'self'
4aca6e
4aca6e
    Currently self is set internally only if hwmode is set.
4aca6e
    This makes it necessary for the hw to have a mode.
4aca6e
    There is no hwmode really required to go to hardware. So, introduce
4aca6e
    self for anybody who wants to target hardware.
4aca6e
4aca6e
    v1 -> v2
4aca6e
        - fix a few bugs. Initialize flags to zero: this was required to
4aca6e
        keep the current behaviour unchanged.
4aca6e
4aca6e
    v2 -> v3
4aca6e
        - fix comment
4aca6e
4aca6e
    Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
4aca6e
    Reviewed-by: Jiri Pirko <jiri@resnulli.us>
4aca6e
---
4aca6e
 bridge/link.c | 18 ++++++++++--------
4aca6e
 1 file changed, 10 insertions(+), 8 deletions(-)
4aca6e
4aca6e
diff --git a/bridge/link.c b/bridge/link.c
4aca6e
index 14e4e5a..4e0fd96 100644
4aca6e
--- a/bridge/link.c
4aca6e
+++ b/bridge/link.c
4aca6e
@@ -261,7 +261,7 @@ static int brlink_modify(int argc, char **argv)
4aca6e
 	__s16 priority = -1;
4aca6e
 	__s8 state = -1;
4aca6e
 	__s16 mode = -1;
4aca6e
-	__u16 flags = BRIDGE_FLAGS_MASTER;
4aca6e
+	__u16 flags = 0;
4aca6e
 	struct rtattr *nest;
4aca6e
 
4aca6e
 	memset(&req, 0, sizeof(req));
4aca6e
@@ -321,6 +321,8 @@ static int brlink_modify(int argc, char **argv)
4aca6e
 					"\"veb\".\n");
4aca6e
 				exit(-1);
4aca6e
 			}
4aca6e
+		} else if (strcmp(*argv, "self") == 0) {
4aca6e
+			flags = BRIDGE_FLAGS_SELF;
4aca6e
 		} else {
4aca6e
 			usage();
4aca6e
 		}
4aca6e
@@ -369,16 +371,16 @@ static int brlink_modify(int argc, char **argv)
4aca6e
 
4aca6e
 	addattr_nest_end(&req.n, nest);
4aca6e
 
4aca6e
-	/* IFLA_AF_SPEC nested attribute.  Contains IFLA_BRIDGE_FLAGS that
4aca6e
-	 * designates master or self operation as well as 'vepa' or 'veb'
4aca6e
-	 * operation modes.  These are only valid in 'self' mode on some
4aca6e
-	 * devices so far.  Thus we only need to include the flags attribute
4aca6e
-	 * if we are setting the hw mode.
4aca6e
+	/* IFLA_AF_SPEC nested attribute. Contains IFLA_BRIDGE_FLAGS that
4aca6e
+	 * designates master or self operation and IFLA_BRIDGE_MODE
4aca6e
+	 * for hw 'vepa' or 'veb' operation modes. The hwmodes are
4aca6e
+	 * only valid in 'self' mode on some devices so far.
4aca6e
 	 */
4aca6e
-	if (mode >= 0) {
4aca6e
+	if (mode >= 0 || flags > 0) {
4aca6e
 		nest = addattr_nest(&req.n, sizeof(req), IFLA_AF_SPEC);
4aca6e
 
4aca6e
-		addattr16(&req.n, sizeof(req), IFLA_BRIDGE_FLAGS, flags);
4aca6e
+		if (flags > 0)
4aca6e
+			addattr16(&req.n, sizeof(req), IFLA_BRIDGE_FLAGS, flags);
4aca6e
 
4aca6e
 		if (mode >= 0)
4aca6e
 			addattr16(&req.n, sizeof(req), IFLA_BRIDGE_MODE, mode);
4aca6e
-- 
4aca6e
1.8.3.1
4aca6e