|
|
049c96 |
From 95014c8dbd2a76b735fed48bd2985d9b51f5f48a Mon Sep 17 00:00:00 2001
|
|
|
049c96 |
From: Phil Sutter <psutter@redhat.com>
|
|
|
049c96 |
Date: Tue, 23 Feb 2016 18:25:58 +0100
|
|
|
049c96 |
Subject: [PATCH] iplink: add support for bonding slave
|
|
|
049c96 |
|
|
|
049c96 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1269528
|
|
|
049c96 |
Upstream Status: iproute2.git commit 730d3f61d91ff
|
|
|
049c96 |
Conflicts: Patch adjusted for missing HSR device support in RHEL7
|
|
|
049c96 |
|
|
|
049c96 |
commit 730d3f61d91ffefd58adcae6d2765e94a14fa3af
|
|
|
049c96 |
Author: Jiri Pirko <jiri@resnulli.us>
|
|
|
049c96 |
Date: Thu Jan 23 17:52:54 2014 +0100
|
|
|
049c96 |
|
|
|
049c96 |
iplink: add support for bonding slave
|
|
|
049c96 |
|
|
|
049c96 |
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
|
|
|
049c96 |
---
|
|
|
049c96 |
ip/Makefile | 2 +-
|
|
|
049c96 |
ip/iplink_bond_slave.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
049c96 |
2 files changed, 91 insertions(+), 1 deletion(-)
|
|
|
049c96 |
create mode 100644 ip/iplink_bond_slave.c
|
|
|
049c96 |
|
|
|
049c96 |
diff --git a/ip/Makefile b/ip/Makefile
|
|
|
049c96 |
index 76878fb..080b079 100644
|
|
|
049c96 |
--- a/ip/Makefile
|
|
|
049c96 |
+++ b/ip/Makefile
|
|
|
049c96 |
@@ -5,7 +5,7 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \
|
|
|
049c96 |
iplink_vlan.o link_veth.o link_gre.o iplink_can.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
|
|
|
049c96 |
+ link_iptnl.o link_gre6.o iplink_bond.o iplink_bond_slave.o
|
|
|
049c96 |
|
|
|
049c96 |
RTMONOBJ=rtmon.o
|
|
|
049c96 |
|
|
|
049c96 |
diff --git a/ip/iplink_bond_slave.c b/ip/iplink_bond_slave.c
|
|
|
049c96 |
new file mode 100644
|
|
|
049c96 |
index 0000000..bb4e1d6
|
|
|
049c96 |
--- /dev/null
|
|
|
049c96 |
+++ b/ip/iplink_bond_slave.c
|
|
|
049c96 |
@@ -0,0 +1,90 @@
|
|
|
049c96 |
+/*
|
|
|
049c96 |
+ * iplink_bond_slave.c Bonding slave 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 <sys/socket.h>
|
|
|
049c96 |
+#include <linux/if_bonding.h>
|
|
|
049c96 |
+
|
|
|
049c96 |
+#include "rt_names.h"
|
|
|
049c96 |
+#include "utils.h"
|
|
|
049c96 |
+#include "ip_common.h"
|
|
|
049c96 |
+
|
|
|
049c96 |
+static const char *slave_states[] = {
|
|
|
049c96 |
+ [BOND_STATE_ACTIVE] = "ACTIVE",
|
|
|
049c96 |
+ [BOND_STATE_BACKUP] = "BACKUP",
|
|
|
049c96 |
+};
|
|
|
049c96 |
+
|
|
|
049c96 |
+static void print_slave_state(FILE *f, struct rtattr *tb)
|
|
|
049c96 |
+{
|
|
|
049c96 |
+ unsigned int state = rta_getattr_u8(tb);
|
|
|
049c96 |
+
|
|
|
049c96 |
+ if (state >= sizeof(slave_states) / sizeof(slave_states[0]))
|
|
|
049c96 |
+ fprintf(f, "state %d ", state);
|
|
|
049c96 |
+ else
|
|
|
049c96 |
+ fprintf(f, "state %s ", slave_states[state]);
|
|
|
049c96 |
+}
|
|
|
049c96 |
+
|
|
|
049c96 |
+static const char *slave_mii_status[] = {
|
|
|
049c96 |
+ [BOND_LINK_UP] = "UP",
|
|
|
049c96 |
+ [BOND_LINK_FAIL] = "GOING_DOWN",
|
|
|
049c96 |
+ [BOND_LINK_DOWN] = "DOWN",
|
|
|
049c96 |
+ [BOND_LINK_BACK] = "GOING_BACK",
|
|
|
049c96 |
+};
|
|
|
049c96 |
+
|
|
|
049c96 |
+static void print_slave_mii_status(FILE *f, struct rtattr *tb)
|
|
|
049c96 |
+{
|
|
|
049c96 |
+ unsigned int status = rta_getattr_u8(tb);
|
|
|
049c96 |
+
|
|
|
049c96 |
+ fprintf(f, "mii_status %d ", status);
|
|
|
049c96 |
+ if (status >= sizeof(slave_mii_status) / sizeof(slave_mii_status[0]))
|
|
|
049c96 |
+ fprintf(f, "mii_status %d ", status);
|
|
|
049c96 |
+ else
|
|
|
049c96 |
+ fprintf(f, "mii_status %s ", slave_mii_status[status]);
|
|
|
049c96 |
+}
|
|
|
049c96 |
+
|
|
|
049c96 |
+static void bond_slave_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
|
|
|
049c96 |
+{
|
|
|
049c96 |
+ SPRINT_BUF(b1);
|
|
|
049c96 |
+ if (!tb)
|
|
|
049c96 |
+ return;
|
|
|
049c96 |
+
|
|
|
049c96 |
+ if (tb[IFLA_BOND_SLAVE_STATE])
|
|
|
049c96 |
+ print_slave_state(f, tb[IFLA_BOND_SLAVE_STATE]);
|
|
|
049c96 |
+
|
|
|
049c96 |
+ if (tb[IFLA_BOND_SLAVE_MII_STATUS])
|
|
|
049c96 |
+ print_slave_mii_status(f, tb[IFLA_BOND_SLAVE_MII_STATUS]);
|
|
|
049c96 |
+
|
|
|
049c96 |
+ if (tb[IFLA_BOND_SLAVE_LINK_FAILURE_COUNT])
|
|
|
049c96 |
+ fprintf(f, "link_failure_count %d ",
|
|
|
049c96 |
+ rta_getattr_u32(tb[IFLA_BOND_SLAVE_LINK_FAILURE_COUNT]));
|
|
|
049c96 |
+
|
|
|
049c96 |
+ if (tb[IFLA_BOND_SLAVE_PERM_HWADDR])
|
|
|
049c96 |
+ fprintf(f, "perm_hwaddr %s ",
|
|
|
049c96 |
+ ll_addr_n2a(RTA_DATA(tb[IFLA_BOND_SLAVE_PERM_HWADDR]),
|
|
|
049c96 |
+ RTA_PAYLOAD(tb[IFLA_BOND_SLAVE_PERM_HWADDR]),
|
|
|
049c96 |
+ 0, b1, sizeof(b1)));
|
|
|
049c96 |
+
|
|
|
049c96 |
+ if (tb[IFLA_BOND_SLAVE_QUEUE_ID])
|
|
|
049c96 |
+ fprintf(f, "queue_id %d ",
|
|
|
049c96 |
+ rta_getattr_u16(tb[IFLA_BOND_SLAVE_QUEUE_ID]));
|
|
|
049c96 |
+
|
|
|
049c96 |
+ if (tb[IFLA_BOND_SLAVE_AD_AGGREGATOR_ID])
|
|
|
049c96 |
+ fprintf(f, "ad_aggregator_id %d ",
|
|
|
049c96 |
+ rta_getattr_u16(tb[IFLA_BOND_SLAVE_AD_AGGREGATOR_ID]));
|
|
|
049c96 |
+}
|
|
|
049c96 |
+
|
|
|
049c96 |
+struct link_util bond_slave_link_util = {
|
|
|
049c96 |
+ .id = "bond",
|
|
|
049c96 |
+ .maxattr = IFLA_BOND_SLAVE_MAX,
|
|
|
049c96 |
+ .print_opt = bond_slave_print_opt,
|
|
|
049c96 |
+ .slave = true,
|
|
|
049c96 |
+};
|
|
|
049c96 |
+
|
|
|
049c96 |
--
|
|
|
049c96 |
1.8.3.1
|
|
|
049c96 |
|