naccyde / rpms / iproute

Forked from rpms/iproute 10 months ago
Clone

Blame SOURCES/0060-iplink-bridge-export-bridge_id-and-designated_root.patch

4aca6e
From e356155477080e21d9c443fc963b7019bbc579ca Mon Sep 17 00:00:00 2001
4aca6e
From: Phil Sutter <psutter@redhat.com>
4aca6e
Date: Tue, 28 Feb 2017 16:12:00 +0100
4aca6e
Subject: [PATCH] iplink: bridge: export bridge_id and designated_root
4aca6e
4aca6e
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1417289
4aca6e
Upstream Status: iproute2.git commit 70dfb0b8836d8
4aca6e
4aca6e
commit 70dfb0b8836d8fb17009b5473b14f4bc470cb68d
4aca6e
Author: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
4aca6e
Date:   Tue Feb 9 00:14:19 2016 +0100
4aca6e
4aca6e
    iplink: bridge: export bridge_id and designated_root
4aca6e
4aca6e
    Netlink returns the bridge_id and designated_root, we just need to
4aca6e
    make them visible.
4aca6e
4aca6e
    Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
4aca6e
---
4aca6e
 ip/iplink_bridge.c | 26 ++++++++++++++++++++++++++
4aca6e
 1 file changed, 26 insertions(+)
4aca6e
4aca6e
diff --git a/ip/iplink_bridge.c b/ip/iplink_bridge.c
4aca6e
index 1c71f2e..050afaa 100644
4aca6e
--- a/ip/iplink_bridge.c
4aca6e
+++ b/ip/iplink_bridge.c
4aca6e
@@ -13,6 +13,7 @@
4aca6e
 #include <stdlib.h>
4aca6e
 #include <string.h>
4aca6e
 #include <linux/if_link.h>
4aca6e
+#include <netinet/ether.h>
4aca6e
 
4aca6e
 #include "rt_names.h"
4aca6e
 #include "utils.h"
4aca6e
@@ -39,6 +40,15 @@ static void explain(void)
4aca6e
 	print_explain(stderr);
4aca6e
 }
4aca6e
 
4aca6e
+static void br_dump_bridge_id(const struct ifla_bridge_id *id, char *buf,
4aca6e
+			      size_t len)
4aca6e
+{
4aca6e
+	char eaddr[32];
4aca6e
+
4aca6e
+	ether_ntoa_r((const struct ether_addr *)id->addr, eaddr);
4aca6e
+	snprintf(buf, len, "%.2x%.2x.%s", id->prio[0], id->prio[1], eaddr);
4aca6e
+}
4aca6e
+
4aca6e
 static int bridge_parse_opt(struct link_util *lu, int argc, char **argv,
4aca6e
 			    struct nlmsghdr *n)
4aca6e
 {
4aca6e
@@ -161,6 +171,22 @@ static void bridge_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
4aca6e
 			ll_proto_n2a(rta_getattr_u16(tb[IFLA_BR_VLAN_PROTOCOL]),
4aca6e
 				     b1, sizeof(b1)));
4aca6e
 	}
4aca6e
+
4aca6e
+	if (tb[IFLA_BR_BRIDGE_ID]) {
4aca6e
+		char bridge_id[32];
4aca6e
+
4aca6e
+		br_dump_bridge_id(RTA_DATA(tb[IFLA_BR_BRIDGE_ID]), bridge_id,
4aca6e
+				  sizeof(bridge_id));
4aca6e
+		fprintf(f, "bridge_id %s ", bridge_id);
4aca6e
+	}
4aca6e
+
4aca6e
+	if (tb[IFLA_BR_ROOT_ID]) {
4aca6e
+		char root_id[32];
4aca6e
+
4aca6e
+		br_dump_bridge_id(RTA_DATA(tb[IFLA_BR_BRIDGE_ID]), root_id,
4aca6e
+				  sizeof(root_id));
4aca6e
+		fprintf(f, "designated_root %s ", root_id);
4aca6e
+	}
4aca6e
 }
4aca6e
 
4aca6e
 static void bridge_print_help(struct link_util *lu, int argc, char **argv,
4aca6e
-- 
4aca6e
1.8.3.1
4aca6e