From patchwork Wed Apr 2 16:19:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Decotigny X-Patchwork-Id: 336386 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 82A6314010C for ; Thu, 3 Apr 2014 03:26:47 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932354AbaDBQ0j (ORCPT ); Wed, 2 Apr 2014 12:26:39 -0400 Received: from mail-pd0-f201.google.com ([209.85.192.201]:43500 "EHLO mail-pd0-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932348AbaDBQ0h (ORCPT ); Wed, 2 Apr 2014 12:26:37 -0400 Received: by mail-pd0-f201.google.com with SMTP id x10so69404pdj.0 for ; Wed, 02 Apr 2014 09:26:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mqepDQA2s4PL9Ja3gGZBulcgksT6L3MHhTGiirwcbvs=; b=TcgfpXJw87YTCTIshkMHJkZ1IWU/jQtvegFbpAJIRtDV8/EK73EGGoHO1ULBBZVH4g AChPnBl9tDDLYXtvMbyAdmsVg83QcOApklhODGoZwq+MrpWI0MWWSPRckXC8oejl7HeB 1ikEnFXWUZ6mQImbpLHnkiadh/EmJTI3lJ8Bk3XvuyUBzNE1RfNsDoUNfltPYFDbOOia dmelHHzun9dxCUEQrsMcCA8bsdpKobFsZdMFYSFaBRi+OyJLQKeNYSPYDerAAmx3BVmY jVFsB5gGdxpk0dO8GjZbwrVXGzwo3ygIYQkE1UpVTVc/cZ1atzkTA78tpv7PvHJW0kHb XXJw== X-Gm-Message-State: ALoCoQkIF3j/vDPbmAIhslI+Hjk1ztFxVZi8WlP1TKiB2Sn0+Tic17iFpvigDdyjdVqvOw16QAM/MP2xsZid1IAun5TL3D4ZYixjqojsT4YGbECetu08xhLKLfDWNSB8bWa9IH1rQC1nHZ0NEMZ3RdHfE4Q9W0E/Wow12jdA12AceepPXoXqsjHHPJFO0EhQO7V63kVbtjupfHQcOcsnNcrFkzENlAqHVA== X-Received: by 10.66.241.8 with SMTP id we8mr699828pac.16.1396455542325; Wed, 02 Apr 2014 09:19:02 -0700 (PDT) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id k45si416227yhn.4.2014.04.02.09.19.02 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 Apr 2014 09:19:02 -0700 (PDT) Received: from decotigny.mtv.corp.google.com (decotigny.mtv.corp.google.com [172.18.64.159]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id 2607A5A427B; Wed, 2 Apr 2014 09:19:02 -0700 (PDT) Received: by decotigny.mtv.corp.google.com (Postfix, from userid 128857) id CE29AE0EBA; Wed, 2 Apr 2014 09:19:01 -0700 (PDT) From: David Decotigny To: netdev@vger.kernel.org Cc: David Decotigny Subject: [PATCH iproute2 v1] iproute2: show counter of carrier on<->off transitions Date: Wed, 2 Apr 2014 09:19:00 -0700 Message-Id: <6c78808eaf4b31f98c9de9bef6f29397c67cf09e.1396455409.git.decot@googlers.com> X-Mailer: git-send-email 1.9.1.423.g4596e3a In-Reply-To: References: Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch allows to display the current counter of carrier on<->off transitions (IFLA_CARRIER_CHANGES, see kernel commit "expose number of carrier on/off changes"): ip -s -s link show dev eth0 ... 2: eth0: mtu 1500 etc. link/ether ............ brd ff:ff:ff:ff:ff:ff RX: bytes packets errors dropped overrun mcast 134705 758 0 0 0 0 RX errors: length crc frame fifo missed 0 0 0 0 0 TX: bytes packets errors dropped carrier collsns 77374 731 0 0 0 0 TX errors: aborted fifo window heartbeat 0 0 0 0 link: carrier_changes 4 Tested: - kernel with patch "net-sysfs: expose number of carrier on/off changes": see above - kernel wthout the patch: line "link:" not displayed (as expected) Signed-off-by: David Decotigny --- include/linux/if_link.h | 1 + ip/ipaddress.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/linux/if_link.h b/include/linux/if_link.h index f08505c..84fca1e 100644 --- a/include/linux/if_link.h +++ b/include/linux/if_link.h @@ -144,6 +144,7 @@ enum { IFLA_NUM_RX_QUEUES, IFLA_CARRIER, IFLA_PHYS_PORT_ID, + IFLA_CARRIER_CHANGES, __IFLA_MAX }; diff --git a/ip/ipaddress.c b/ip/ipaddress.c index 14d1720..78b80ee 100644 --- a/ip/ipaddress.c +++ b/ip/ipaddress.c @@ -527,6 +527,11 @@ int print_linkinfo(const struct sockaddr_nl *who, print_link_stats(fp, RTA_DATA(tb[IFLA_STATS])); } + if (do_link && (show_stats > 1) && tb[IFLA_CARRIER_CHANGES]) { + fprintf(fp, "%s link: carrier_changes %u", _SL_, + *(int*)RTA_DATA(tb[IFLA_CARRIER_CHANGES])); + } + if (do_link && tb[IFLA_VFINFO_LIST] && tb[IFLA_NUM_VF]) { struct rtattr *i, *vflist = tb[IFLA_VFINFO_LIST]; int rem = RTA_PAYLOAD(vflist);