From: Masatake YAMATO <yamato@redhat.com>
To: netdev@vger.kernel.org
Cc: yamato@redhat.com
Subject: [PATCH] ip: Showing peer of veth type dev in ip link (ip cmd side)
Date: Fri, 4 Oct 2013 11:35:55 +0900 [thread overview]
Message-ID: <1380854155-30174-1-git-send-email-yamato@redhat.com> (raw)
Implement print_opt method to veth to show peer ifindex
as ethtool -S does.
A patch submitted with following subject is needed:
veth: Showing peer of veth type dev in ip link (kernel side)
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
---
ip/link_veth.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/ip/link_veth.c b/ip/link_veth.c
index 7730f39..bd84815 100644
--- a/ip/link_veth.c
+++ b/ip/link_veth.c
@@ -11,6 +11,7 @@
*/
#include <string.h>
+#include <inttypes.h>
#include <net/if.h>
#include <linux/veth.h>
@@ -57,7 +58,22 @@ static int veth_parse_opt(struct link_util *lu, int argc, char **argv,
return argc - 1 - err;
}
+static void veth_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
+{
+ if (!tb)
+ return;
+
+ if (tb[VETH_INFO_PEER] &&
+ RTA_PAYLOAD(tb[VETH_INFO_PEER]) < sizeof(__u64))
+ return;
+
+ fprintf(f, "peer_ifindex %"PRIu64,
+ (uint64_t)rta_getattr_u64(tb[VETH_INFO_PEER]));
+}
+
struct link_util veth_link_util = {
.id = "veth",
+ .maxattr = VETH_INFO_MAX,
.parse_opt = veth_parse_opt,
+ .print_opt = veth_print_opt,
};
--
1.8.3.1
next reply other threads:[~2013-10-04 18:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-04 2:35 Masatake YAMATO [this message]
-- strict thread matches above, loose matches on Subject: below --
2013-10-04 4:06 [PATCH] ip: Showing peer of veth type dev in ip link (ip cmd side) Masatake YAMATO
2013-10-04 18:23 ` Stephen Hemminger
2013-10-04 18:42 ` Masatake YAMATO
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1380854155-30174-1-git-send-email-yamato@redhat.com \
--to=yamato@redhat.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).