From patchwork Fri Mar 24 02:51:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Ahern X-Patchwork-Id: 743034 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 3vq7H822Qqz9s7s for ; Fri, 24 Mar 2017 13:51:48 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=cumulusnetworks.com header.i=@cumulusnetworks.com header.b="OSZkx+Kz"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934931AbdCXCve (ORCPT ); Thu, 23 Mar 2017 22:51:34 -0400 Received: from mail-pg0-f52.google.com ([74.125.83.52]:32850 "EHLO mail-pg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933818AbdCXCvb (ORCPT ); Thu, 23 Mar 2017 22:51:31 -0400 Received: by mail-pg0-f52.google.com with SMTP id w20so1442424pgc.0 for ; Thu, 23 Mar 2017 19:51:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cumulusnetworks.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=i8ADOdGK7CXd7E+3U1Nn0n19kFTcoC2aNsDtYUuUxlM=; b=OSZkx+KzJAJEh0NyCWhLL753L3V0O8Kabez//+10QFt4364Nj6t+bOlob2OvMzWJfd iRMx58wfXp52MkBrFHtbpHSTk8ipy1JJpKGCjcKVbVaA35VlkPs8gRPtGiwKYTjVokJ8 kHRakn4qkjy2ih0ZBgTxcGseRWj2CLUcbuA9c= 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:in-reply-to :references; bh=i8ADOdGK7CXd7E+3U1Nn0n19kFTcoC2aNsDtYUuUxlM=; b=OLqVTwJzJMx5ya6JjetvHgv/BgJ6uczshvSzm3Gx2kzVnCluC8HD9TdW2WEOO0vRve IQfk3tE0SEiBKM8I1bIfY85ptfqVMFgjvmNKXMW1k4d9ouhDhn0Jx5M02DpG495vERzE vrgcMoSh/ypqLgC0eizO3Nd8YhKCmBUZJMZHYRHOQN0Vo0iwuoUkmYgspzazsn5qpMAt UZAoiCWGDboNVEW6X89CJmISu6/C6fafLMtIOLVKxxXLWStI96WEay0h3IftpeQS+L6N OEWUwpMPzXW48S39EzWeZUewZrV3pJkYRpkgLQUMJTXCoF8O+37HIvmcwU3nFGYXhIN2 UXFA== X-Gm-Message-State: AFeK/H17WT4Tu5WNxgNGaPb/u8ABD4VK7//WO4bY3vNCJpfte1bc9J2Jm48AREoLkxmOSl51 X-Received: by 10.99.131.195 with SMTP id h186mr6197750pge.57.1490323890404; Thu, 23 Mar 2017 19:51:30 -0700 (PDT) Received: from kenny.it.cumulusnetworks.com. ([216.129.126.126]) by smtp.googlemail.com with ESMTPSA id t12sm845510pfg.14.2017.03.23.19.51.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 23 Mar 2017 19:51:29 -0700 (PDT) From: David Ahern To: netdev@vger.kernel.org, stephen@networkplumber.org Cc: nicolas.dichtel@6wind.com, David Ahern Subject: [iproute2 net-next v2 2/3] ip netconf: Show all address families by default in dumps Date: Thu, 23 Mar 2017 19:51:21 -0700 Message-Id: <1490323882-11609-3-git-send-email-dsa@cumulusnetworks.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1490323882-11609-1-git-send-email-dsa@cumulusnetworks.com> References: <1490323882-11609-1-git-send-email-dsa@cumulusnetworks.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Currently, 'ip netconf' only shows ipv4 and ipv6 netconf settings. If IPv6 is not enabled, the dump ends with RTNETLINK answers: Operation not supported when IPv6 request is attempted. Further, if the mpls_router module is also loaded a separate request is needed to get MPLS settings. To make this better going forward, use the new PF_UNSPEC dump all option if the kernel supports it. If the kernel does not, it sets NLMSG_ERROR and returns EOPNOTSUPP which is trapped and we fall back to the existing output to maintain compatibility with existing kernels. Signed-off-by: David Ahern --- ip/ipnetconf.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ip/ipnetconf.c b/ip/ipnetconf.c index af539f5e945c..dc0851025223 100644 --- a/ip/ipnetconf.c +++ b/ip/ipnetconf.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "rt_names.h" #include "utils.h" @@ -197,16 +198,26 @@ static int do_show(int argc, char **argv) } rtnl_listen(&rth, print_netconf, stdout); } else { + rth.flags = RTNL_HANDLE_F_SUPPRESS_NLERR; dump: if (rtnl_wilddump_request(&rth, filter.family, RTM_GETNETCONF) < 0) { perror("Cannot send dump request"); exit(1); } if (rtnl_dump_filter(&rth, print_netconf2, stdout) < 0) { + /* kernel does not support netconf dump on AF_UNSPEC; + * fall back to requesting by family + */ + if (errno == EOPNOTSUPP && + filter.family == AF_UNSPEC) { + filter.family = AF_INET; + goto dump; + } + perror("RTNETLINK answers"); fprintf(stderr, "Dump terminated\n"); exit(1); } - if (preferred_family == AF_UNSPEC) { + if (preferred_family == AF_UNSPEC && filter.family == AF_INET) { preferred_family = AF_INET6; filter.family = AF_INET6; goto dump;