|
|
049c96 |
From 4e0ecde498d450b10a3bb44ca95816dd2a479f40 Mon Sep 17 00:00:00 2001
|
|
|
049c96 |
From: Phil Sutter <psutter@redhat.com>
|
|
|
049c96 |
Date: Tue, 23 Feb 2016 18:24:51 +0100
|
|
|
049c96 |
Subject: [PATCH] introduce support for slave info data
|
|
|
049c96 |
|
|
|
049c96 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1269528
|
|
|
049c96 |
Upstream Status: iproute2.git commit fbea6115645a1
|
|
|
049c96 |
Conflicts: Changed context due to already applied commit 561e650eff679
|
|
|
049c96 |
("ip link: Shortify printing the usage of link type")
|
|
|
049c96 |
|
|
|
049c96 |
commit fbea6115645a126de87bbcf51371050dde1a5b39
|
|
|
049c96 |
Author: Jiri Pirko <jiri@resnulli.us>
|
|
|
049c96 |
Date: Thu Jan 23 17:52:53 2014 +0100
|
|
|
049c96 |
|
|
|
049c96 |
introduce support for slave info data
|
|
|
049c96 |
|
|
|
049c96 |
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
|
|
|
049c96 |
---
|
|
|
049c96 |
ip/ip_common.h | 4 ++++
|
|
|
049c96 |
ip/ipaddress.c | 54 ++++++++++++++++++++++++++++++++++++------------------
|
|
|
049c96 |
ip/iplink.c | 21 ++++++++++++++++++---
|
|
|
049c96 |
3 files changed, 58 insertions(+), 21 deletions(-)
|
|
|
049c96 |
|
|
|
049c96 |
diff --git a/ip/ip_common.h b/ip/ip_common.h
|
|
|
049c96 |
index 274d12a..917fcf8 100644
|
|
|
049c96 |
--- a/ip/ip_common.h
|
|
|
049c96 |
+++ b/ip/ip_common.h
|
|
|
049c96 |
@@ -66,6 +66,8 @@ static inline int rtm_get_table(struct rtmsg *r, struct rtattr **tb)
|
|
|
049c96 |
|
|
|
049c96 |
extern struct rtnl_handle rth;
|
|
|
049c96 |
|
|
|
049c96 |
+#include <stdbool.h>
|
|
|
049c96 |
+
|
|
|
049c96 |
struct link_util
|
|
|
049c96 |
{
|
|
|
049c96 |
struct link_util *next;
|
|
|
049c96 |
@@ -79,9 +81,11 @@ struct link_util
|
|
|
049c96 |
struct rtattr *);
|
|
|
049c96 |
void (*print_help)(struct link_util *, int, char **,
|
|
|
049c96 |
FILE *);
|
|
|
049c96 |
+ bool slave;
|
|
|
049c96 |
};
|
|
|
049c96 |
|
|
|
049c96 |
struct link_util *get_link_kind(const char *kind);
|
|
|
049c96 |
+struct link_util *get_link_slave_kind(const char *slave_kind);
|
|
|
049c96 |
|
|
|
049c96 |
#ifndef INFINITY_LIFE_TIME
|
|
|
049c96 |
#define INFINITY_LIFE_TIME 0xFFFFFFFFU
|
|
|
049c96 |
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
|
|
|
049c96 |
index 700c40f..8681bf9 100644
|
|
|
049c96 |
--- a/ip/ipaddress.c
|
|
|
049c96 |
+++ b/ip/ipaddress.c
|
|
|
049c96 |
@@ -193,34 +193,52 @@ static void print_linktype(FILE *fp, struct rtattr *tb)
|
|
|
049c96 |
{
|
|
|
049c96 |
struct rtattr *linkinfo[IFLA_INFO_MAX+1];
|
|
|
049c96 |
struct link_util *lu;
|
|
|
049c96 |
+ struct link_util *slave_lu;
|
|
|
049c96 |
char *kind;
|
|
|
049c96 |
+ char *slave_kind;
|
|
|
049c96 |
|
|
|
049c96 |
parse_rtattr_nested(linkinfo, IFLA_INFO_MAX, tb);
|
|
|
049c96 |
|
|
|
049c96 |
- if (!linkinfo[IFLA_INFO_KIND])
|
|
|
049c96 |
- return;
|
|
|
049c96 |
- kind = RTA_DATA(linkinfo[IFLA_INFO_KIND]);
|
|
|
049c96 |
+ if (linkinfo[IFLA_INFO_KIND]) {
|
|
|
049c96 |
+ kind = RTA_DATA(linkinfo[IFLA_INFO_KIND]);
|
|
|
049c96 |
|
|
|
049c96 |
- fprintf(fp, "%s", _SL_);
|
|
|
049c96 |
- fprintf(fp, " %s ", kind);
|
|
|
049c96 |
+ fprintf(fp, "%s", _SL_);
|
|
|
049c96 |
+ fprintf(fp, " %s ", kind);
|
|
|
049c96 |
|
|
|
049c96 |
- lu = get_link_kind(kind);
|
|
|
049c96 |
- if (!lu || !lu->print_opt)
|
|
|
049c96 |
- return;
|
|
|
049c96 |
+ lu = get_link_kind(kind);
|
|
|
049c96 |
+ if (lu && lu->print_opt) {
|
|
|
049c96 |
+ struct rtattr *attr[lu->maxattr+1], **data = NULL;
|
|
|
049c96 |
|
|
|
049c96 |
- if (1) {
|
|
|
049c96 |
- struct rtattr *attr[lu->maxattr+1], **data = NULL;
|
|
|
049c96 |
+ if (linkinfo[IFLA_INFO_DATA]) {
|
|
|
049c96 |
+ parse_rtattr_nested(attr, lu->maxattr,
|
|
|
049c96 |
+ linkinfo[IFLA_INFO_DATA]);
|
|
|
049c96 |
+ data = attr;
|
|
|
049c96 |
+ }
|
|
|
049c96 |
+ lu->print_opt(lu, fp, data);
|
|
|
049c96 |
|
|
|
049c96 |
- if (linkinfo[IFLA_INFO_DATA]) {
|
|
|
049c96 |
- parse_rtattr_nested(attr, lu->maxattr,
|
|
|
049c96 |
- linkinfo[IFLA_INFO_DATA]);
|
|
|
049c96 |
- data = attr;
|
|
|
049c96 |
+ if (linkinfo[IFLA_INFO_XSTATS] && show_stats &&
|
|
|
049c96 |
+ lu->print_xstats)
|
|
|
049c96 |
+ lu->print_xstats(lu, fp, linkinfo[IFLA_INFO_XSTATS]);
|
|
|
049c96 |
}
|
|
|
049c96 |
- lu->print_opt(lu, fp, data);
|
|
|
049c96 |
+ }
|
|
|
049c96 |
|
|
|
049c96 |
- if (linkinfo[IFLA_INFO_XSTATS] && show_stats &&
|
|
|
049c96 |
- lu->print_xstats)
|
|
|
049c96 |
- lu->print_xstats(lu, fp, linkinfo[IFLA_INFO_XSTATS]);
|
|
|
049c96 |
+ if (linkinfo[IFLA_INFO_SLAVE_KIND]) {
|
|
|
049c96 |
+ slave_kind = RTA_DATA(linkinfo[IFLA_INFO_SLAVE_KIND]);
|
|
|
049c96 |
+
|
|
|
049c96 |
+ fprintf(fp, "%s", _SL_);
|
|
|
049c96 |
+ fprintf(fp, " %s_slave ", slave_kind);
|
|
|
049c96 |
+
|
|
|
049c96 |
+ slave_lu = get_link_slave_kind(slave_kind);
|
|
|
049c96 |
+ if (slave_lu && slave_lu->print_opt) {
|
|
|
049c96 |
+ struct rtattr *attr[slave_lu->maxattr+1], **data = NULL;
|
|
|
049c96 |
+
|
|
|
049c96 |
+ if (linkinfo[IFLA_INFO_SLAVE_DATA]) {
|
|
|
049c96 |
+ parse_rtattr_nested(attr, slave_lu->maxattr,
|
|
|
049c96 |
+ linkinfo[IFLA_INFO_SLAVE_DATA]);
|
|
|
049c96 |
+ data = attr;
|
|
|
049c96 |
+ }
|
|
|
049c96 |
+ slave_lu->print_opt(slave_lu, fp, data);
|
|
|
049c96 |
+ }
|
|
|
049c96 |
}
|
|
|
049c96 |
}
|
|
|
049c96 |
|
|
|
049c96 |
diff --git a/ip/iplink.c b/ip/iplink.c
|
|
|
049c96 |
index 3024e99..8d6a2b3 100644
|
|
|
049c96 |
--- a/ip/iplink.c
|
|
|
049c96 |
+++ b/ip/iplink.c
|
|
|
049c96 |
@@ -27,6 +27,7 @@
|
|
|
049c96 |
#include <string.h>
|
|
|
049c96 |
#include <sys/ioctl.h>
|
|
|
049c96 |
#include <linux/sockios.h>
|
|
|
049c96 |
+#include <stdbool.h>
|
|
|
049c96 |
|
|
|
049c96 |
#include "rt_names.h"
|
|
|
049c96 |
#include "utils.h"
|
|
|
049c96 |
@@ -110,14 +111,15 @@ static int on_off(const char *msg, const char *realval)
|
|
|
049c96 |
static void *BODY; /* cached dlopen(NULL) handle */
|
|
|
049c96 |
static struct link_util *linkutil_list;
|
|
|
049c96 |
|
|
|
049c96 |
-struct link_util *get_link_kind(const char *id)
|
|
|
049c96 |
+static struct link_util *__get_link_kind(const char *id, bool slave)
|
|
|
049c96 |
{
|
|
|
049c96 |
void *dlh;
|
|
|
049c96 |
char buf[256];
|
|
|
049c96 |
struct link_util *l;
|
|
|
049c96 |
|
|
|
049c96 |
for (l = linkutil_list; l; l = l->next)
|
|
|
049c96 |
- if (strcmp(l->id, id) == 0)
|
|
|
049c96 |
+ if (strcmp(l->id, id) == 0 &&
|
|
|
049c96 |
+ l->slave == slave)
|
|
|
049c96 |
return l;
|
|
|
049c96 |
|
|
|
049c96 |
snprintf(buf, sizeof(buf), LIBDIR "/ip/link_%s.so", id);
|
|
|
049c96 |
@@ -132,7 +134,10 @@ struct link_util *get_link_kind(const char *id)
|
|
|
049c96 |
}
|
|
|
049c96 |
}
|
|
|
049c96 |
|
|
|
049c96 |
- snprintf(buf, sizeof(buf), "%s_link_util", id);
|
|
|
049c96 |
+ if (slave)
|
|
|
049c96 |
+ snprintf(buf, sizeof(buf), "%s_slave_link_util", id);
|
|
|
049c96 |
+ else
|
|
|
049c96 |
+ snprintf(buf, sizeof(buf), "%s_link_util", id);
|
|
|
049c96 |
l = dlsym(dlh, buf);
|
|
|
049c96 |
if (l == NULL)
|
|
|
049c96 |
return NULL;
|
|
|
049c96 |
@@ -142,6 +147,16 @@ struct link_util *get_link_kind(const char *id)
|
|
|
049c96 |
return l;
|
|
|
049c96 |
}
|
|
|
049c96 |
|
|
|
049c96 |
+struct link_util *get_link_kind(const char *id)
|
|
|
049c96 |
+{
|
|
|
049c96 |
+ return __get_link_kind(id, false);
|
|
|
049c96 |
+}
|
|
|
049c96 |
+
|
|
|
049c96 |
+struct link_util *get_link_slave_kind(const char *id)
|
|
|
049c96 |
+{
|
|
|
049c96 |
+ return __get_link_kind(id, true);
|
|
|
049c96 |
+}
|
|
|
049c96 |
+
|
|
|
049c96 |
static int get_link_mode(const char *mode)
|
|
|
049c96 |
{
|
|
|
049c96 |
if (strcasecmp(mode, "default") == 0)
|
|
|
049c96 |
--
|
|
|
049c96 |
1.8.3.1
|
|
|
049c96 |
|