From patchwork Fri Oct 4 02:35:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masatake YAMATO X-Patchwork-Id: 280693 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id BD3D92C0094 for ; Sat, 5 Oct 2013 04:28:35 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753717Ab3JDS2c (ORCPT ); Fri, 4 Oct 2013 14:28:32 -0400 Received: from h219-110-095-248.catv01.itscom.jp ([219.110.95.248]:34287 "EHLO localhost.localdomain" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751161Ab3JDS2b (ORCPT ); Fri, 4 Oct 2013 14:28:31 -0400 X-Greylist: delayed 318 seconds by postgrey-1.27 at vger.kernel.org; Fri, 04 Oct 2013 14:28:31 EDT Received: from localhost.localdomain (localhost [127.0.0.1]) by localhost.localdomain (8.14.7/8.14.7) with ESMTP id r942Zvsl030210; Fri, 4 Oct 2013 11:35:57 +0900 Received: (from yamato@localhost) by localhost.localdomain (8.14.7/8.14.7/Submit) id r942Zv4q030209; Fri, 4 Oct 2013 11:35:57 +0900 X-Authentication-Warning: localhost.localdomain: yamato set sender to yamato@redhat.com using -f From: Masatake YAMATO 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 Message-Id: <1380854155-30174-1-git-send-email-yamato@redhat.com> X-Mailer: git-send-email 1.8.3.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- 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 +#include #include #include @@ -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, };