* [PATCH iproute2 net-next] bridge: mdb: add support for extended router port information
@ 2016-03-03 15:19 Nikolay Aleksandrov
2016-03-03 16:20 ` [PATCH iproute2 net-next v2] " Nikolay Aleksandrov
2016-03-06 20:56 ` [PATCH iproute2 net-next] " Stephen Hemminger
0 siblings, 2 replies; 8+ messages in thread
From: Nikolay Aleksandrov @ 2016-03-03 15:19 UTC (permalink / raw)
To: netdev; +Cc: stephen, roopa, Nikolay Aleksandrov
Recently a new temp router port mode was added and with it the dumped
information was extended similar to how mdb entries were done. This
patch adds support to dump the new information by using the "-s" switch.
Example:
$ bridge -d -s mdb show
dev br0 port eth1 grp ff02::1:ffbf:5716 temp 234.39
dev br0 port eth1 grp 239.0.0.2 temp 97.17
dev br0 port eth1 grp 239.0.0.3 temp 105.36
router ports on br0: eth1 0.00 permanent
router ports on br0: eth2 254.87 temp
It also updates the bridge man page.
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
bridge/br_common.h | 3 +++
bridge/mdb.c | 52 +++++++++++++++++++++++++++++++++++++++++++---------
man/man8/bridge.8 | 6 +++++-
3 files changed, 51 insertions(+), 10 deletions(-)
diff --git a/bridge/br_common.h b/bridge/br_common.h
index 41eb0dc38293..5ea45c9e654d 100644
--- a/bridge/br_common.h
+++ b/bridge/br_common.h
@@ -1,6 +1,9 @@
#define MDB_RTA(r) \
((struct rtattr *)(((char *)(r)) + RTA_ALIGN(sizeof(struct br_mdb_entry))))
+#define MDB_RTR_RTA(r) \
+ ((struct rtattr *)(((char *)(r)) + RTA_ALIGN(sizeof(__u32))))
+
extern int print_linkinfo(const struct sockaddr_nl *who,
struct nlmsghdr *n,
void *arg);
diff --git a/bridge/mdb.c b/bridge/mdb.c
index 09d4b2255857..d0a7d401590e 100644
--- a/bridge/mdb.c
+++ b/bridge/mdb.c
@@ -33,19 +33,55 @@ static void usage(void)
exit(-1);
}
-static void br_print_router_ports(FILE *f, struct rtattr *attr)
+static int is_temp_mcast_rtr(__u8 type)
{
+ if (type == MDB_RTR_TYPE_TEMP_QUERY || type == MDB_RTR_TYPE_TEMP)
+ return 1;
+ else
+ return 0;
+}
+
+static void br_print_router_ports(FILE *f, struct rtattr *attr, __u32 brifidx)
+{
+ struct rtattr *tb[MDBA_ROUTER_PATTR_MAX + 1];
uint32_t *port_ifindex;
struct rtattr *i;
int rem;
+ if (!show_stats)
+ fprintf(f, "router ports on %s: ", ll_index_to_name(brifidx));
+
rem = RTA_PAYLOAD(attr);
for (i = RTA_DATA(attr); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
port_ifindex = RTA_DATA(i);
- fprintf(f, "%s ", ll_index_to_name(*port_ifindex));
+ parse_rtattr(tb, MDBA_ROUTER_PATTR_MAX,
+ MDB_RTR_RTA(RTA_DATA(i)),
+ RTA_PAYLOAD(i) - RTA_ALIGN(sizeof(*port_ifindex)));
+ if (show_stats) {
+ struct timeval tv;
+ __u32 tval = 0;
+ __u8 type = 0;
+
+ if (tb[MDBA_ROUTER_PATTR_TYPE]) {
+ type = rta_getattr_u8(
+ tb[MDBA_ROUTER_PATTR_TYPE]);
+ }
+ if (tb[MDBA_ROUTER_PATTR_TIMER]) {
+ tval = rta_getattr_u32(
+ tb[MDBA_ROUTER_PATTR_TIMER]);
+ }
+ __jiffies_to_tv(&tv, tval);
+ fprintf(f, "router ports on %s: %s %4i.%.2i %s\n",
+ ll_index_to_name(brifidx),
+ ll_index_to_name(*port_ifindex),
+ (int)tv.tv_sec, (int)tv.tv_usec/10000,
+ is_temp_mcast_rtr(type) ? "temp" : "permanent");
+ } else {
+ fprintf(f, "%s ", ll_index_to_name(*port_ifindex));
+ }
}
-
- fprintf(f, "\n");
+ if (!show_stats)
+ fprintf(f, "\n");
}
static void print_mdb_entry(FILE *f, int ifindex, struct br_mdb_entry *e,
@@ -126,11 +162,9 @@ int print_mdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
if (tb[MDBA_ROUTER]) {
if (n->nlmsg_type == RTM_GETMDB) {
- if (show_details) {
- fprintf(fp, "router ports on %s: ",
- ll_index_to_name(r->ifindex));
- br_print_router_ports(fp, tb[MDBA_ROUTER]);
- }
+ if (show_details)
+ br_print_router_ports(fp, tb[MDBA_ROUTER],
+ r->ifindex);
} else {
uint32_t *port_ifindex;
diff --git a/man/man8/bridge.8 b/man/man8/bridge.8
index 0e98edf4762f..08e8a5bf5a08 100644
--- a/man/man8/bridge.8
+++ b/man/man8/bridge.8
@@ -119,6 +119,10 @@ is given multiple times, the amount of information increases.
As a rule, the information is statistics or some time values.
.TP
+.BR "\-d" , " \-details"
+print detailed information about MDB router ports.
+
+.TP
.BR "\-n" , " \-net" , " \-netns " <NETNS>
switches
.B bridge
@@ -506,7 +510,7 @@ a connected router.
.PP
With the
.B -statistics
-option, the command displays timer values for mdb entries.
+option, the command displays timer values for mdb and router port entries.
.SH bridge vlan - VLAN filter list
--
2.4.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH iproute2 net-next v2] bridge: mdb: add support for extended router port information
2016-03-03 15:19 [PATCH iproute2 net-next] bridge: mdb: add support for extended router port information Nikolay Aleksandrov
@ 2016-03-03 16:20 ` Nikolay Aleksandrov
2016-03-07 9:32 ` [PATCH iproute2 net-next v3] " Nikolay Aleksandrov
2016-03-06 20:56 ` [PATCH iproute2 net-next] " Stephen Hemminger
1 sibling, 1 reply; 8+ messages in thread
From: Nikolay Aleksandrov @ 2016-03-03 16:20 UTC (permalink / raw)
To: netdev; +Cc: stephen, roopa, Nikolay Aleksandrov
Recently a new temp router port mode was added and with it the dumped
information was extended similar to how mdb entries were done. This
patch adds support to dump the new information by using the "-s" switch.
Example:
$ bridge -d -s mdb show
dev br0 port eth1 grp ff02::1:ffbf:5716 temp 234.39
dev br0 port eth1 grp 239.0.0.2 temp 97.17
dev br0 port eth1 grp 239.0.0.3 temp 105.36
router ports on br0: eth1 0.00 permanent
router ports on br0: eth2 254.87 temp
It also updates the bridge man page.
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
v2: print the values only if they were provided by the kernel, otherwise
we might print "permanent" for a temporary entry on an older kernel.
bridge/br_common.h | 3 +++
bridge/mdb.c | 57 +++++++++++++++++++++++++++++++++++++++++++++---------
man/man8/bridge.8 | 6 +++++-
3 files changed, 56 insertions(+), 10 deletions(-)
diff --git a/bridge/br_common.h b/bridge/br_common.h
index 41eb0dc38293..5ea45c9e654d 100644
--- a/bridge/br_common.h
+++ b/bridge/br_common.h
@@ -1,6 +1,9 @@
#define MDB_RTA(r) \
((struct rtattr *)(((char *)(r)) + RTA_ALIGN(sizeof(struct br_mdb_entry))))
+#define MDB_RTR_RTA(r) \
+ ((struct rtattr *)(((char *)(r)) + RTA_ALIGN(sizeof(__u32))))
+
extern int print_linkinfo(const struct sockaddr_nl *who,
struct nlmsghdr *n,
void *arg);
diff --git a/bridge/mdb.c b/bridge/mdb.c
index 09d4b2255857..e2cd4960775f 100644
--- a/bridge/mdb.c
+++ b/bridge/mdb.c
@@ -33,19 +33,60 @@ static void usage(void)
exit(-1);
}
-static void br_print_router_ports(FILE *f, struct rtattr *attr)
+static int is_temp_mcast_rtr(__u8 type)
{
+ if (type == MDB_RTR_TYPE_TEMP_QUERY || type == MDB_RTR_TYPE_TEMP)
+ return 1;
+ else
+ return 0;
+}
+
+static void br_print_router_ports(FILE *f, struct rtattr *attr, __u32 brifidx)
+{
+ struct rtattr *tb[MDBA_ROUTER_PATTR_MAX + 1];
uint32_t *port_ifindex;
struct rtattr *i;
int rem;
+ if (!show_stats)
+ fprintf(f, "router ports on %s: ", ll_index_to_name(brifidx));
+
rem = RTA_PAYLOAD(attr);
for (i = RTA_DATA(attr); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
port_ifindex = RTA_DATA(i);
- fprintf(f, "%s ", ll_index_to_name(*port_ifindex));
+ parse_rtattr(tb, MDBA_ROUTER_PATTR_MAX,
+ MDB_RTR_RTA(RTA_DATA(i)),
+ RTA_PAYLOAD(i) - RTA_ALIGN(sizeof(*port_ifindex)));
+ if (show_stats) {
+ fprintf(f, "router ports on %s: %s",
+ ll_index_to_name(brifidx),
+ ll_index_to_name(*port_ifindex));
+ if (tb[MDBA_ROUTER_PATTR_TIMER]) {
+ struct timeval tv;
+ __u32 tval;
+
+ tval = rta_getattr_u32(
+ tb[MDBA_ROUTER_PATTR_TIMER]);
+ __jiffies_to_tv(&tv, tval);
+ fprintf(f, " %4i.%.2i",
+ (int)tv.tv_sec, (int)tv.tv_usec/10000);
+ }
+ if (tb[MDBA_ROUTER_PATTR_TYPE]) {
+ __u8 type;
+
+ type = rta_getattr_u8(
+ tb[MDBA_ROUTER_PATTR_TYPE]);
+ fprintf(f, " %s",
+ is_temp_mcast_rtr(type) ? "temp" :
+ "permanent");
+ }
+ fprintf(f, "\n");
+ } else {
+ fprintf(f, "%s ", ll_index_to_name(*port_ifindex));
+ }
}
-
- fprintf(f, "\n");
+ if (!show_stats)
+ fprintf(f, "\n");
}
static void print_mdb_entry(FILE *f, int ifindex, struct br_mdb_entry *e,
@@ -126,11 +167,9 @@ int print_mdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
if (tb[MDBA_ROUTER]) {
if (n->nlmsg_type == RTM_GETMDB) {
- if (show_details) {
- fprintf(fp, "router ports on %s: ",
- ll_index_to_name(r->ifindex));
- br_print_router_ports(fp, tb[MDBA_ROUTER]);
- }
+ if (show_details)
+ br_print_router_ports(fp, tb[MDBA_ROUTER],
+ r->ifindex);
} else {
uint32_t *port_ifindex;
diff --git a/man/man8/bridge.8 b/man/man8/bridge.8
index 0e98edf4762f..08e8a5bf5a08 100644
--- a/man/man8/bridge.8
+++ b/man/man8/bridge.8
@@ -119,6 +119,10 @@ is given multiple times, the amount of information increases.
As a rule, the information is statistics or some time values.
.TP
+.BR "\-d" , " \-details"
+print detailed information about MDB router ports.
+
+.TP
.BR "\-n" , " \-net" , " \-netns " <NETNS>
switches
.B bridge
@@ -506,7 +510,7 @@ a connected router.
.PP
With the
.B -statistics
-option, the command displays timer values for mdb entries.
+option, the command displays timer values for mdb and router port entries.
.SH bridge vlan - VLAN filter list
--
2.4.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH iproute2 net-next v3] bridge: mdb: add support for extended router port information
2016-03-03 16:20 ` [PATCH iproute2 net-next v2] " Nikolay Aleksandrov
@ 2016-03-07 9:32 ` Nikolay Aleksandrov
2016-03-07 10:10 ` [PATCH iproute2 net-next v4] " Nikolay Aleksandrov
0 siblings, 1 reply; 8+ messages in thread
From: Nikolay Aleksandrov @ 2016-03-07 9:32 UTC (permalink / raw)
To: netdev; +Cc: stephen, roopa, Nikolay Aleksandrov
Recently a new temp router port mode was added and with it the dumped
information was extended similar to how mdb entries were done. This
patch adds support to dump the new information by using the "-s" switch.
Example:
$ bridge -d -s mdb show
dev br0 port eth1 grp ff02::1:ffbf:5716 temp 234.39
dev br0 port eth1 grp 239.0.0.2 temp 97.17
dev br0 port eth1 grp 239.0.0.3 temp 105.36
router ports on br0: eth1 0.00 permanent
router ports on br0: eth2 254.87 temp
It also updates the bridge man page.
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
v3: make is_temp_mcast_rtr bool and return the result directly as per
Stephen's comment
v2: print the values only if they were provided by the kernel, otherwise
we might print "permanent" for a temporary entry on an older kernel.
bridge/br_common.h | 3 +++
bridge/mdb.c | 54 +++++++++++++++++++++++++++++++++++++++++++++---------
man/man8/bridge.8 | 6 +++++-
3 files changed, 53 insertions(+), 10 deletions(-)
diff --git a/bridge/br_common.h b/bridge/br_common.h
index 41eb0dc38293..5ea45c9e654d 100644
--- a/bridge/br_common.h
+++ b/bridge/br_common.h
@@ -1,6 +1,9 @@
#define MDB_RTA(r) \
((struct rtattr *)(((char *)(r)) + RTA_ALIGN(sizeof(struct br_mdb_entry))))
+#define MDB_RTR_RTA(r) \
+ ((struct rtattr *)(((char *)(r)) + RTA_ALIGN(sizeof(__u32))))
+
extern int print_linkinfo(const struct sockaddr_nl *who,
struct nlmsghdr *n,
void *arg);
diff --git a/bridge/mdb.c b/bridge/mdb.c
index 600596c94969..676e4f62f740 100644
--- a/bridge/mdb.c
+++ b/bridge/mdb.c
@@ -33,19 +33,57 @@ static void usage(void)
exit(-1);
}
-static void br_print_router_ports(FILE *f, struct rtattr *attr)
+static bool is_temp_mcast_rtr(__u8 type)
{
+ return type == MDB_RTR_TYPE_TEMP_QUERY || type == MDB_RTR_TYPE_TEMP;
+}
+
+static void br_print_router_ports(FILE *f, struct rtattr *attr, __u32 brifidx)
+{
+ struct rtattr *tb[MDBA_ROUTER_PATTR_MAX + 1];
uint32_t *port_ifindex;
struct rtattr *i;
int rem;
+ if (!show_stats)
+ fprintf(f, "router ports on %s: ", ll_index_to_name(brifidx));
+
rem = RTA_PAYLOAD(attr);
for (i = RTA_DATA(attr); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
port_ifindex = RTA_DATA(i);
- fprintf(f, "%s ", ll_index_to_name(*port_ifindex));
+ parse_rtattr(tb, MDBA_ROUTER_PATTR_MAX,
+ MDB_RTR_RTA(RTA_DATA(i)),
+ RTA_PAYLOAD(i) - RTA_ALIGN(sizeof(*port_ifindex)));
+ if (show_stats) {
+ fprintf(f, "router ports on %s: %s",
+ ll_index_to_name(brifidx),
+ ll_index_to_name(*port_ifindex));
+ if (tb[MDBA_ROUTER_PATTR_TIMER]) {
+ struct timeval tv;
+ __u32 tval;
+
+ tval = rta_getattr_u32(
+ tb[MDBA_ROUTER_PATTR_TIMER]);
+ __jiffies_to_tv(&tv, tval);
+ fprintf(f, " %4i.%.2i",
+ (int)tv.tv_sec, (int)tv.tv_usec/10000);
+ }
+ if (tb[MDBA_ROUTER_PATTR_TYPE]) {
+ __u8 type;
+
+ type = rta_getattr_u8(
+ tb[MDBA_ROUTER_PATTR_TYPE]);
+ fprintf(f, " %s",
+ is_temp_mcast_rtr(type) ? "temp" :
+ "permanent");
+ }
+ fprintf(f, "\n");
+ } else {
+ fprintf(f, "%s ", ll_index_to_name(*port_ifindex));
+ }
}
-
- fprintf(f, "\n");
+ if (!show_stats)
+ fprintf(f, "\n");
}
static void print_mdb_entry(FILE *f, int ifindex, struct br_mdb_entry *e,
@@ -127,11 +165,9 @@ int print_mdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
if (tb[MDBA_ROUTER]) {
if (n->nlmsg_type == RTM_GETMDB) {
- if (show_details) {
- fprintf(fp, "router ports on %s: ",
- ll_index_to_name(r->ifindex));
- br_print_router_ports(fp, tb[MDBA_ROUTER]);
- }
+ if (show_details)
+ br_print_router_ports(fp, tb[MDBA_ROUTER],
+ r->ifindex);
} else {
uint32_t *port_ifindex;
diff --git a/man/man8/bridge.8 b/man/man8/bridge.8
index 0e98edf4762f..08e8a5bf5a08 100644
--- a/man/man8/bridge.8
+++ b/man/man8/bridge.8
@@ -119,6 +119,10 @@ is given multiple times, the amount of information increases.
As a rule, the information is statistics or some time values.
.TP
+.BR "\-d" , " \-details"
+print detailed information about MDB router ports.
+
+.TP
.BR "\-n" , " \-net" , " \-netns " <NETNS>
switches
.B bridge
@@ -506,7 +510,7 @@ a connected router.
.PP
With the
.B -statistics
-option, the command displays timer values for mdb entries.
+option, the command displays timer values for mdb and router port entries.
.SH bridge vlan - VLAN filter list
--
2.4.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH iproute2 net-next v4] bridge: mdb: add support for extended router port information
2016-03-07 9:32 ` [PATCH iproute2 net-next v3] " Nikolay Aleksandrov
@ 2016-03-07 10:10 ` Nikolay Aleksandrov
2016-03-14 6:37 ` Stephen Hemminger
0 siblings, 1 reply; 8+ messages in thread
From: Nikolay Aleksandrov @ 2016-03-07 10:10 UTC (permalink / raw)
To: netdev; +Cc: stephen, roopa, Nikolay Aleksandrov
Recently a new temp router port mode was added and with it the dumped
information was extended similar to how mdb entries were done. This
patch adds support to dump the new information by using the "-s" switch.
Example:
$ bridge -d -s mdb show
dev br0 port eth1 grp ff02::1:ffbf:5716 temp 234.39
dev br0 port eth1 grp 239.0.0.2 temp 97.17
dev br0 port eth1 grp 239.0.0.3 temp 105.36
router ports on br0: eth1 0.00 permanent
router ports on br0: eth2 254.87 temp
It also updates the bridge man page.
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
v4: minor optimization, parse new attributes only when show_stats has been
specified
v3: make is_temp_mcast_rtr bool and return the result directly as per
Stephen's comment
v2: print the values only if they were provided by the kernel, otherwise
we might print "permanent" for a temporary entry on an older kernel.
bridge/br_common.h | 3 +++
bridge/mdb.c | 57 +++++++++++++++++++++++++++++++++++++++++++++---------
man/man8/bridge.8 | 6 +++++-
3 files changed, 56 insertions(+), 10 deletions(-)
diff --git a/bridge/br_common.h b/bridge/br_common.h
index 41eb0dc38293..5ea45c9e654d 100644
--- a/bridge/br_common.h
+++ b/bridge/br_common.h
@@ -1,6 +1,9 @@
#define MDB_RTA(r) \
((struct rtattr *)(((char *)(r)) + RTA_ALIGN(sizeof(struct br_mdb_entry))))
+#define MDB_RTR_RTA(r) \
+ ((struct rtattr *)(((char *)(r)) + RTA_ALIGN(sizeof(__u32))))
+
extern int print_linkinfo(const struct sockaddr_nl *who,
struct nlmsghdr *n,
void *arg);
diff --git a/bridge/mdb.c b/bridge/mdb.c
index 600596c94969..c15f4b8944ef 100644
--- a/bridge/mdb.c
+++ b/bridge/mdb.c
@@ -33,19 +33,60 @@ static void usage(void)
exit(-1);
}
-static void br_print_router_ports(FILE *f, struct rtattr *attr)
+static bool is_temp_mcast_rtr(__u8 type)
+{
+ return type == MDB_RTR_TYPE_TEMP_QUERY || type == MDB_RTR_TYPE_TEMP;
+}
+
+static void br_print_router_ports(FILE *f, struct rtattr *attr, __u32 brifidx)
{
uint32_t *port_ifindex;
struct rtattr *i;
int rem;
+ if (!show_stats)
+ fprintf(f, "router ports on %s: ", ll_index_to_name(brifidx));
+
rem = RTA_PAYLOAD(attr);
for (i = RTA_DATA(attr); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
port_ifindex = RTA_DATA(i);
- fprintf(f, "%s ", ll_index_to_name(*port_ifindex));
+ if (show_stats) {
+ struct rtattr *tb[MDBA_ROUTER_PATTR_MAX + 1];
+
+ parse_rtattr(tb, MDBA_ROUTER_PATTR_MAX,
+ MDB_RTR_RTA(RTA_DATA(i)),
+ RTA_PAYLOAD(i) -
+ RTA_ALIGN(sizeof(*port_ifindex)));
+
+ fprintf(f, "router ports on %s: %s",
+ ll_index_to_name(brifidx),
+ ll_index_to_name(*port_ifindex));
+ if (tb[MDBA_ROUTER_PATTR_TIMER]) {
+ struct timeval tv;
+ __u32 tval;
+
+ tval = rta_getattr_u32(
+ tb[MDBA_ROUTER_PATTR_TIMER]);
+ __jiffies_to_tv(&tv, tval);
+ fprintf(f, " %4i.%.2i",
+ (int)tv.tv_sec, (int)tv.tv_usec/10000);
+ }
+ if (tb[MDBA_ROUTER_PATTR_TYPE]) {
+ __u8 type;
+
+ type = rta_getattr_u8(
+ tb[MDBA_ROUTER_PATTR_TYPE]);
+ fprintf(f, " %s",
+ is_temp_mcast_rtr(type) ? "temp" :
+ "permanent");
+ }
+ fprintf(f, "\n");
+ } else {
+ fprintf(f, "%s ", ll_index_to_name(*port_ifindex));
+ }
}
-
- fprintf(f, "\n");
+ if (!show_stats)
+ fprintf(f, "\n");
}
static void print_mdb_entry(FILE *f, int ifindex, struct br_mdb_entry *e,
@@ -127,11 +168,9 @@ int print_mdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
if (tb[MDBA_ROUTER]) {
if (n->nlmsg_type == RTM_GETMDB) {
- if (show_details) {
- fprintf(fp, "router ports on %s: ",
- ll_index_to_name(r->ifindex));
- br_print_router_ports(fp, tb[MDBA_ROUTER]);
- }
+ if (show_details)
+ br_print_router_ports(fp, tb[MDBA_ROUTER],
+ r->ifindex);
} else {
uint32_t *port_ifindex;
diff --git a/man/man8/bridge.8 b/man/man8/bridge.8
index 0e98edf4762f..08e8a5bf5a08 100644
--- a/man/man8/bridge.8
+++ b/man/man8/bridge.8
@@ -119,6 +119,10 @@ is given multiple times, the amount of information increases.
As a rule, the information is statistics or some time values.
.TP
+.BR "\-d" , " \-details"
+print detailed information about MDB router ports.
+
+.TP
.BR "\-n" , " \-net" , " \-netns " <NETNS>
switches
.B bridge
@@ -506,7 +510,7 @@ a connected router.
.PP
With the
.B -statistics
-option, the command displays timer values for mdb entries.
+option, the command displays timer values for mdb and router port entries.
.SH bridge vlan - VLAN filter list
--
2.4.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH iproute2 net-next v4] bridge: mdb: add support for extended router port information
2016-03-07 10:10 ` [PATCH iproute2 net-next v4] " Nikolay Aleksandrov
@ 2016-03-14 6:37 ` Stephen Hemminger
2016-03-14 10:04 ` [PATCH iproute2 net-next v5] " Nikolay Aleksandrov
0 siblings, 1 reply; 8+ messages in thread
From: Stephen Hemminger @ 2016-03-14 6:37 UTC (permalink / raw)
To: Nikolay Aleksandrov; +Cc: netdev, roopa
On Mon, 7 Mar 2016 11:10:32 +0100
Nikolay Aleksandrov <nikolay@cumulusnetworks.com> wrote:
> rem = RTA_PAYLOAD(attr);
> for (i = RTA_DATA(attr); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
> port_ifindex = RTA_DATA(i);
> - fprintf(f, "%s ", ll_index_to_name(*port_ifindex));
> + if (show_stats) {
> + struct rtattr *tb[MDBA_ROUTER_PATTR_MAX + 1];
> +
> + parse_rtattr(tb, MDBA_ROUTER_PATTR_MAX,
> + MDB_RTR_RTA(RTA_DATA(i)),
> + RTA_PAYLOAD(i) -
> + RTA_ALIGN(sizeof(*port_ifindex)));
> +
> + fprintf(f, "router ports on %s: %s",
> + ll_index_to_name(brifidx),
> + ll_index_to_name(*port_ifindex));
> + if (tb[MDBA_ROUTER_PATTR_TIMER]) {
> + struct timeval tv;
> + __u32 tval;
> +
> + tval = rta_getattr_u32(
> + tb[MDBA_ROUTER_PATTR_TIMER]);
> + __jiffies_to_tv(&tv, tval);
> + fprintf(f, " %4i.%.2i",
> + (int)tv.tv_sec, (int)tv.tv_usec/10000);
> + }
You are having to cut lines short here to fit 80 characters, maybe
good time to make statistics a helper function.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH iproute2 net-next v5] bridge: mdb: add support for extended router port information
2016-03-14 6:37 ` Stephen Hemminger
@ 2016-03-14 10:04 ` Nikolay Aleksandrov
0 siblings, 0 replies; 8+ messages in thread
From: Nikolay Aleksandrov @ 2016-03-14 10:04 UTC (permalink / raw)
To: netdev; +Cc: stephen, roopa, Nikolay Aleksandrov
Recently a new temp router port mode was added and with it the dumped
information was extended similar to how mdb entries were done. This
patch adds support to dump the new information by using the "-s" switch.
Example:
$ bridge -d -s mdb show
dev br0 port eth1 grp ff02::1:ffbf:5716 temp 234.39
dev br0 port eth1 grp 239.0.0.2 temp 97.17
dev br0 port eth1 grp 239.0.0.3 temp 105.36
router ports on br0: eth1 0.00 permanent
router ports on br0: eth2 254.87 temp
It also updates the bridge man page.
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
v5: pull router port stats in their own function, rebase and retest
v4: minor optimization, parse new attributes only when show_stats has been
specified
v3: make is_temp_mcast_rtr bool and return the result directly as per
Stephen's comment
v2: print the values only if they were provided by the kernel, otherwise
we might print "permanent" for a temporary entry on an older kernel.
bridge/br_common.h | 3 +++
bridge/mdb.c | 53 ++++++++++++++++++++++++++++++++++++++++++++---------
man/man8/bridge.8 | 6 +++++-
3 files changed, 52 insertions(+), 10 deletions(-)
diff --git a/bridge/br_common.h b/bridge/br_common.h
index 41eb0dc38293..5ea45c9e654d 100644
--- a/bridge/br_common.h
+++ b/bridge/br_common.h
@@ -1,6 +1,9 @@
#define MDB_RTA(r) \
((struct rtattr *)(((char *)(r)) + RTA_ALIGN(sizeof(struct br_mdb_entry))))
+#define MDB_RTR_RTA(r) \
+ ((struct rtattr *)(((char *)(r)) + RTA_ALIGN(sizeof(__u32))))
+
extern int print_linkinfo(const struct sockaddr_nl *who,
struct nlmsghdr *n,
void *arg);
diff --git a/bridge/mdb.c b/bridge/mdb.c
index 600596c94969..97da4dc98f23 100644
--- a/bridge/mdb.c
+++ b/bridge/mdb.c
@@ -33,19 +33,56 @@ static void usage(void)
exit(-1);
}
-static void br_print_router_ports(FILE *f, struct rtattr *attr)
+static bool is_temp_mcast_rtr(__u8 type)
+{
+ return type == MDB_RTR_TYPE_TEMP_QUERY || type == MDB_RTR_TYPE_TEMP;
+}
+
+static void __print_router_port_stats(FILE *f, struct rtattr *pattr)
+{
+ struct rtattr *tb[MDBA_ROUTER_PATTR_MAX + 1];
+ struct timeval tv;
+ __u8 type;
+
+ parse_rtattr(tb, MDBA_ROUTER_PATTR_MAX, MDB_RTR_RTA(RTA_DATA(pattr)),
+ RTA_PAYLOAD(pattr) - RTA_ALIGN(sizeof(uint32_t)));
+ if (tb[MDBA_ROUTER_PATTR_TIMER]) {
+ __jiffies_to_tv(&tv,
+ rta_getattr_u32(tb[MDBA_ROUTER_PATTR_TIMER]));
+ fprintf(f, " %4i.%.2i",
+ (int)tv.tv_sec, (int)tv.tv_usec/10000);
+ }
+ if (tb[MDBA_ROUTER_PATTR_TYPE]) {
+ type = rta_getattr_u8(tb[MDBA_ROUTER_PATTR_TYPE]);
+ fprintf(f, " %s",
+ is_temp_mcast_rtr(type) ? "temp" : "permanent");
+ }
+}
+
+static void br_print_router_ports(FILE *f, struct rtattr *attr, __u32 brifidx)
{
uint32_t *port_ifindex;
struct rtattr *i;
int rem;
+ if (!show_stats)
+ fprintf(f, "router ports on %s: ", ll_index_to_name(brifidx));
+
rem = RTA_PAYLOAD(attr);
for (i = RTA_DATA(attr); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
port_ifindex = RTA_DATA(i);
- fprintf(f, "%s ", ll_index_to_name(*port_ifindex));
+ if (show_stats) {
+ fprintf(f, "router ports on %s: %s",
+ ll_index_to_name(brifidx),
+ ll_index_to_name(*port_ifindex));
+ __print_router_port_stats(f, i);
+ fprintf(f, "\n");
+ } else {
+ fprintf(f, "%s ", ll_index_to_name(*port_ifindex));
+ }
}
-
- fprintf(f, "\n");
+ if (!show_stats)
+ fprintf(f, "\n");
}
static void print_mdb_entry(FILE *f, int ifindex, struct br_mdb_entry *e,
@@ -127,11 +164,9 @@ int print_mdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
if (tb[MDBA_ROUTER]) {
if (n->nlmsg_type == RTM_GETMDB) {
- if (show_details) {
- fprintf(fp, "router ports on %s: ",
- ll_index_to_name(r->ifindex));
- br_print_router_ports(fp, tb[MDBA_ROUTER]);
- }
+ if (show_details)
+ br_print_router_ports(fp, tb[MDBA_ROUTER],
+ r->ifindex);
} else {
uint32_t *port_ifindex;
diff --git a/man/man8/bridge.8 b/man/man8/bridge.8
index 0e98edf4762f..08e8a5bf5a08 100644
--- a/man/man8/bridge.8
+++ b/man/man8/bridge.8
@@ -119,6 +119,10 @@ is given multiple times, the amount of information increases.
As a rule, the information is statistics or some time values.
.TP
+.BR "\-d" , " \-details"
+print detailed information about MDB router ports.
+
+.TP
.BR "\-n" , " \-net" , " \-netns " <NETNS>
switches
.B bridge
@@ -506,7 +510,7 @@ a connected router.
.PP
With the
.B -statistics
-option, the command displays timer values for mdb entries.
+option, the command displays timer values for mdb and router port entries.
.SH bridge vlan - VLAN filter list
--
2.4.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH iproute2 net-next] bridge: mdb: add support for extended router port information
2016-03-03 15:19 [PATCH iproute2 net-next] bridge: mdb: add support for extended router port information Nikolay Aleksandrov
2016-03-03 16:20 ` [PATCH iproute2 net-next v2] " Nikolay Aleksandrov
@ 2016-03-06 20:56 ` Stephen Hemminger
2016-03-06 21:12 ` Nikolay Aleksandrov
1 sibling, 1 reply; 8+ messages in thread
From: Stephen Hemminger @ 2016-03-06 20:56 UTC (permalink / raw)
To: Nikolay Aleksandrov; +Cc: netdev, roopa
On Thu, 3 Mar 2016 16:19:34 +0100
Nikolay Aleksandrov <nikolay@cumulusnetworks.com> wrote:
> +static int is_temp_mcast_rtr(__u8 type)
> {
> + if (type == MDB_RTR_TYPE_TEMP_QUERY || type == MDB_RTR_TYPE_TEMP)
> + return 1;
> + else
> + return 0;
> +}
> +
Minor style issues, why not much simpler:
static bool is_tmp_mcast_rtr(__u8 type)
{
return (type == MDB_RTR_TYPE_TEMP_QUERY || type == MDB_RTR_TYPE_TEMP);
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH iproute2 net-next] bridge: mdb: add support for extended router port information
2016-03-06 20:56 ` [PATCH iproute2 net-next] " Stephen Hemminger
@ 2016-03-06 21:12 ` Nikolay Aleksandrov
0 siblings, 0 replies; 8+ messages in thread
From: Nikolay Aleksandrov @ 2016-03-06 21:12 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, roopa
On 03/06/2016 09:56 PM, Stephen Hemminger wrote:
> On Thu, 3 Mar 2016 16:19:34 +0100
> Nikolay Aleksandrov <nikolay@cumulusnetworks.com> wrote:
>
>> +static int is_temp_mcast_rtr(__u8 type)
>> {
>> + if (type == MDB_RTR_TYPE_TEMP_QUERY || type == MDB_RTR_TYPE_TEMP)
>> + return 1;
>> + else
>> + return 0;
>> +}
>> +
>
> Minor style issues, why not much simpler:
>
> static bool is_tmp_mcast_rtr(__u8 type)
> {
> return (type == MDB_RTR_TYPE_TEMP_QUERY || type == MDB_RTR_TYPE_TEMP);
> }
>
Yeah, I considered it but I don't know why I went with
the more explicit one. I'll make a v3 with the change. :-)
Thanks,
Nik
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-03-14 10:04 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-03 15:19 [PATCH iproute2 net-next] bridge: mdb: add support for extended router port information Nikolay Aleksandrov
2016-03-03 16:20 ` [PATCH iproute2 net-next v2] " Nikolay Aleksandrov
2016-03-07 9:32 ` [PATCH iproute2 net-next v3] " Nikolay Aleksandrov
2016-03-07 10:10 ` [PATCH iproute2 net-next v4] " Nikolay Aleksandrov
2016-03-14 6:37 ` Stephen Hemminger
2016-03-14 10:04 ` [PATCH iproute2 net-next v5] " Nikolay Aleksandrov
2016-03-06 20:56 ` [PATCH iproute2 net-next] " Stephen Hemminger
2016-03-06 21:12 ` Nikolay Aleksandrov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).