naccyde / rpms / iproute

Forked from rpms/iproute 5 months ago
Clone

Blame SOURCES/0072-add-bridge-master-device-support.patch

049c96
From 9c8e31c1555b5d06b90a4a0c64ffd4254a1ae28a Mon Sep 17 00:00:00 2001
049c96
From: Phil Sutter <psutter@redhat.com>
049c96
Date: Wed, 24 Feb 2016 10:48:44 +0100
049c96
Subject: [PATCH] add bridge master device support
049c96
049c96
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1270759
049c96
Upstream Status: iproute2.git commit 28d84b429e4e2
049c96
Conflicts: Context changed due to missing HSR device support.
049c96
049c96
commit 28d84b429e4e20e63f6e4746285ccfdb72eac92f
049c96
Author: Jiri Pirko <jiri@resnulli.us>
049c96
Date:   Sun Sep 28 16:33:29 2014 -0700
049c96
049c96
    add bridge master device support
049c96
049c96
    Signed-off-by: Jiri Pirko <jiri@resnulli.us>
049c96
---
049c96
 ip/Makefile        |  2 +-
049c96
 ip/iplink_bridge.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
049c96
 2 files changed, 94 insertions(+), 1 deletion(-)
049c96
 create mode 100644 ip/iplink_bridge.c
049c96
049c96
diff --git a/ip/Makefile b/ip/Makefile
049c96
index 8d4f128..35065d6 100644
049c96
--- a/ip/Makefile
049c96
+++ b/ip/Makefile
049c96
@@ -6,7 +6,7 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \
049c96
     iplink_macvlan.o iplink_macvtap.o ipl2tp.o link_vti.o link_vti6.o \
049c96
     iplink_vxlan.o tcp_metrics.o iplink_ipoib.o ipnetconf.o link_ip6tnl.o \
049c96
     link_iptnl.o link_gre6.o iplink_bond.o iplink_bond_slave.o \
049c96
-    iplink_bridge_slave.o
049c96
+    iplink_bridge.o iplink_bridge_slave.o
049c96
 
049c96
 RTMONOBJ=rtmon.o
049c96
 
049c96
diff --git a/ip/iplink_bridge.c b/ip/iplink_bridge.c
049c96
new file mode 100644
049c96
index 0000000..0cea7d1
049c96
--- /dev/null
049c96
+++ b/ip/iplink_bridge.c
049c96
@@ -0,0 +1,93 @@
049c96
+/*
049c96
+ * iplink_bridge.c	Bridge device support
049c96
+ *
049c96
+ *              This program is free software; you can redistribute it and/or
049c96
+ *              modify it under the terms of the GNU General Public License
049c96
+ *              as published by the Free Software Foundation; either version
049c96
+ *              2 of the License, or (at your option) any later version.
049c96
+ *
049c96
+ * Authors:     Jiri Pirko <jiri@resnulli.us>
049c96
+ */
049c96
+
049c96
+#include <stdio.h>
049c96
+#include <stdlib.h>
049c96
+#include <string.h>
049c96
+#include <linux/if_link.h>
049c96
+
049c96
+#include "utils.h"
049c96
+#include "ip_common.h"
049c96
+
049c96
+static void explain(void)
049c96
+{
049c96
+	fprintf(stderr,
049c96
+		"Usage: ... bridge [ forward_delay FORWARD_DELAY ]\n"
049c96
+		"                  [ hello_time HELLO_TIME ]\n"
049c96
+		"                  [ max_age MAX_AGE ]\n"
049c96
+	);
049c96
+}
049c96
+
049c96
+static int bridge_parse_opt(struct link_util *lu, int argc, char **argv,
049c96
+			    struct nlmsghdr *n)
049c96
+{
049c96
+	__u32 val;
049c96
+
049c96
+	while (argc > 0) {
049c96
+		if (matches(*argv, "forward_delay") == 0) {
049c96
+			NEXT_ARG();
049c96
+			if (get_u32(&val, *argv, 0)) {
049c96
+				invarg("invalid forward_delay", *argv);
049c96
+				return -1;
049c96
+			}
049c96
+			addattr32(n, 1024, IFLA_BR_FORWARD_DELAY, val);
049c96
+		} else if (matches(*argv, "hello_time") == 0) {
049c96
+			NEXT_ARG();
049c96
+			if (get_u32(&val, *argv, 0)) {
049c96
+				invarg("invalid hello_time", *argv);
049c96
+				return -1;
049c96
+			}
049c96
+			addattr32(n, 1024, IFLA_BR_HELLO_TIME, val);
049c96
+		} else if (matches(*argv, "max_age") == 0) {
049c96
+			NEXT_ARG();
049c96
+			if (get_u32(&val, *argv, 0)) {
049c96
+				invarg("invalid max_age", *argv);
049c96
+				return -1;
049c96
+			}
049c96
+			addattr32(n, 1024, IFLA_BR_MAX_AGE, val);
049c96
+		} else if (matches(*argv, "help") == 0) {
049c96
+			explain();
049c96
+			return -1;
049c96
+		} else {
049c96
+			fprintf(stderr, "bridge: unknown command \"%s\"?\n", *argv);
049c96
+			explain();
049c96
+			return -1;
049c96
+		}
049c96
+		argc--, argv++;
049c96
+	}
049c96
+
049c96
+	return 0;
049c96
+}
049c96
+
049c96
+static void bridge_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
049c96
+{
049c96
+	if (!tb)
049c96
+		return;
049c96
+
049c96
+	if (tb[IFLA_BR_FORWARD_DELAY])
049c96
+		fprintf(f, "forward_delay %u ",
049c96
+			rta_getattr_u32(tb[IFLA_BR_FORWARD_DELAY]));
049c96
+
049c96
+	if (tb[IFLA_BR_HELLO_TIME])
049c96
+		fprintf(f, "hello_time %u ",
049c96
+			rta_getattr_u32(tb[IFLA_BR_HELLO_TIME]));
049c96
+
049c96
+	if (tb[IFLA_BR_MAX_AGE])
049c96
+		fprintf(f, "max_age %u ",
049c96
+			rta_getattr_u32(tb[IFLA_BR_MAX_AGE]));
049c96
+}
049c96
+
049c96
+struct link_util bridge_link_util = {
049c96
+	.id		= "bridge",
049c96
+	.maxattr	= IFLA_BR_MAX,
049c96
+	.parse_opt	= bridge_parse_opt,
049c96
+	.print_opt	= bridge_print_opt,
049c96
+};
049c96
-- 
049c96
1.8.3.1
049c96