From patchwork Fri Jan 20 14:04:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Aleksandrov X-Patchwork-Id: 717730 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 3v4jMv23Qpz9sDF for ; Sat, 21 Jan 2017 01:12:43 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=cumulusnetworks.com header.i=@cumulusnetworks.com header.b="dgrDkTY0"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752504AbdATOMk (ORCPT ); Fri, 20 Jan 2017 09:12:40 -0500 Received: from mail-wm0-f45.google.com ([74.125.82.45]:36387 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752428AbdATOMi (ORCPT ); Fri, 20 Jan 2017 09:12:38 -0500 Received: by mail-wm0-f45.google.com with SMTP id c85so38668357wmi.1 for ; Fri, 20 Jan 2017 06:12:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cumulusnetworks.com; s=google; h=from:to:cc:subject:date:message-id; bh=FLqqR6BlXaq3gwMaBqiNwgcotbaavtyOeqeK3SsiMmY=; b=dgrDkTY0fC9BVoWnExD8OAwPlTOag/7ugVksgjolpE+mMYX7C85qjEF/tJIF/2rfcZ dVl4cgFh1MT9IumwaKJ7pgEDrXIHxZ2WQqzupmLvBgcoaWqTHKFK8ctvl7bApVXkLjc4 lM21N2sfmwUXwVaXKGwJb749zWGN2WBLOh6Uk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=FLqqR6BlXaq3gwMaBqiNwgcotbaavtyOeqeK3SsiMmY=; b=VUp3J/xONu7bLBk62StaH/4X4yczMz6Vo4D8fkNDkI1Nq4XdP5l2QqQxAGgJgYVxvh lxDTJ3TnGTWIRppStMqfQJsnIjnPhh7e6adApZEJhG4vsHc3XmBAonmXqbvt+zng1Hze w35meqU2fiLGgEa6c/1s1rrOQNYSQAeuzDxpHCS58de3cOKMwE+Odjba7yXq12eMZVS+ 0ctZCXZJbsvBKeWR392nEaZaA78rkRczWNQOxH3u4lKMFX3lKDax79YkhQ5ojkHMFHVu ehVdO8lD9iCV3Bd5S98zFBJpmb9IfYwFNZmRqAQvonvf+fDiIBYal/JE3fACZAG3bS2p vMoA== X-Gm-Message-State: AIkVDXJD2tOY5gdrn98L9FL9a5zJVNp/K/AqsAU439L/y9SCkxGOU6b+w8iAS4frR5vdbvjY X-Received: by 10.28.129.5 with SMTP id c5mr3312449wmd.23.1484921076422; Fri, 20 Jan 2017 06:04:36 -0800 (PST) Received: from localhost.localdomain (ip4-62-4-104-109.cust.nbox.cz. [62.4.104.109]) by smtp.gmail.com with ESMTPSA id 191sm6299983wmo.21.2017.01.20.06.04.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 20 Jan 2017 06:04:35 -0800 (PST) From: Nikolay Aleksandrov To: netdev@vger.kernel.org Cc: stephen@networkplumber.org, roopa@cumulusnetworks.com, Nikolay Aleksandrov Subject: [PATCH iproute2 net-next] ipmroute: add support for RTNH_F_UNRESOLVED Date: Fri, 20 Jan 2017 15:04:22 +0100 Message-Id: <1484921062-23379-1-git-send-email-nikolay@cumulusnetworks.com> X-Mailer: git-send-email 2.1.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch adds a new field that is printed in the end of the line which denotes the real entry state. Before this patch an entry's IIF could disappear and it would look like an unresolved one (iif = unresolved): (3.0.16.1, 225.11.16.1) Iif: unresolved with no way to really distinguish it from an unresolved entry. After the patch if the dumped entry has RTNH_F_UNRESOLVED set we get: (3.0.16.1, 225.11.16.1) Iif: unresolved State: unresolved for unresolved entries and: (0.0.0.0, 225.11.11.11) Iif: eth4 Oifs: eth3 State: resolved for resolved entries after the OIF list. Note that "State:" has ':' in it so it cannot be mistaken for an interface name. And for the example above, we'd get: (0.0.0.0, 225.11.11.11) Iif: unresolved State: resolved Also when dumping all routes via ip route show table all, it will show up as: multicast 225.11.16.1/32 from 3.0.16.1/32 table default proto 17 unresolved Signed-off-by: Nikolay Aleksandrov --- ip/ipmroute.c | 6 ++++++ ip/iproute.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/ip/ipmroute.c b/ip/ipmroute.c index 512afcd2086e..913f3fd28e14 100644 --- a/ip/ipmroute.c +++ b/ip/ipmroute.c @@ -159,6 +159,12 @@ int print_mroute(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) nh = RTNH_NEXT(nh); } } + fprintf(fp, " State: "); + if (r->rtm_flags & RTNH_F_UNRESOLVED) + fprintf(fp, "unresolved"); + else + fprintf(fp, "resolved"); + if (show_stats && tb[RTA_MFC_STATS]) { struct rta_mfc_stats *mfcs = RTA_DATA(tb[RTA_MFC_STATS]); diff --git a/ip/iproute.c b/ip/iproute.c index e433de8be189..c19578337f71 100644 --- a/ip/iproute.c +++ b/ip/iproute.c @@ -448,6 +448,8 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) fprintf(fp, "notify "); if (r->rtm_flags & RTNH_F_LINKDOWN) fprintf(fp, "linkdown "); + if (r->rtm_flags & RTNH_F_UNRESOLVED) + fprintf(fp, "unresolved "); if (tb[RTA_MARK]) { unsigned int mark = *(unsigned int *)RTA_DATA(tb[RTA_MARK]);