From patchwork Sat Sep 29 17:59:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Ahern X-Patchwork-Id: 976664 X-Patchwork-Delegate: dsahern@gmail.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="vZf18oD9"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42MxCJ15GTz9s55 for ; Sun, 30 Sep 2018 03:59:56 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728615AbeI3A2z (ORCPT ); Sat, 29 Sep 2018 20:28:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:40646 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728598AbeI3A2z (ORCPT ); Sat, 29 Sep 2018 20:28:55 -0400 Received: from kenny.it.cumulusnetworks.com. (fw.cumulusnetworks.com [216.129.126.126]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8EAEA20882; Sat, 29 Sep 2018 17:59:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1538243974; bh=7CDzGIW5HeYypIEecAxrcyI52C1PoltVhuOlItk7Zu8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vZf18oD9p6xz4CCt/iQB2zMlw84nKw7Dk6TJ7otsC1g0S6HGW9cxULL5erluP1kgI ZyJ1xh1frQDjoBEI55KLS2D0PfdQy1Bc+hMR8caPL/6r7ehtmS7LHtvoYD+kEXUFfv 0ZihBdP6d8aIwLtE1CdtjVv6AIJHQwBzOk4Q4Iiw= From: David Ahern To: netdev@vger.kernel.org Cc: stephen@networkplumber.org, christian@brauner.io, David Ahern Subject: [PATCH iproute2-next 09/11] libnetlink: Convert GETNSID dumps to use rtnl_nsiddump_req Date: Sat, 29 Sep 2018 10:59:29 -0700 Message-Id: <20180929175931.18448-10-dsahern@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180929175931.18448-1-dsahern@kernel.org> References: <20180929175931.18448-1-dsahern@kernel.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: David Ahern Add rtnl_nsiddump_req for namespace id dumps using the proper rtgenmsg as the header. Convert existing RTM_GETNSID dumps to use it. Signed-off-by: David Ahern --- include/libnetlink.h | 2 ++ ip/ipnetns.c | 2 +- lib/libnetlink.c | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/libnetlink.h b/include/libnetlink.h index 5ccc421b4b0e..f22c92ac03dc 100644 --- a/include/libnetlink.h +++ b/include/libnetlink.h @@ -63,6 +63,8 @@ int rtnl_mdbdump_req(struct rtnl_handle *rth, int family) __attribute__((warn_unused_result)); int rtnl_netconfdump_req(struct rtnl_handle *rth, int family) __attribute__((warn_unused_result)); +int rtnl_nsiddump_req(struct rtnl_handle *rth, int family) + __attribute__((warn_unused_result)); int rtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type) __attribute__((warn_unused_result)); diff --git a/ip/ipnetns.c b/ip/ipnetns.c index 368be0cbc0a4..e8500c773994 100644 --- a/ip/ipnetns.c +++ b/ip/ipnetns.c @@ -346,7 +346,7 @@ static int netns_list_id(int argc, char **argv) return -ENOTSUP; } - if (rtnl_wilddump_request(&rth, AF_UNSPEC, RTM_GETNSID) < 0) { + if (rtnl_nsiddump_req(&rth, AF_UNSPEC) < 0) { perror("Cannot send dump request"); exit(1); } diff --git a/lib/libnetlink.c b/lib/libnetlink.c index c28047e4b055..2dd14ac5ea58 100644 --- a/lib/libnetlink.c +++ b/lib/libnetlink.c @@ -330,6 +330,22 @@ int rtnl_netconfdump_req(struct rtnl_handle *rth, int family) return send(rth->fd, &req, sizeof(req), 0); } +int rtnl_nsiddump_req(struct rtnl_handle *rth, int family) +{ + struct { + struct nlmsghdr nlh; + struct rtgenmsg rtm; + } req = { + .nlh.nlmsg_len = sizeof(req), + .nlh.nlmsg_type = RTM_GETNSID, + .nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST, + .nlh.nlmsg_seq = rth->dump = ++rth->seq, + .rtm.rtgen_family = family, + }; + + return send(rth->fd, &req, sizeof(req), 0); +} + int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type) { return rtnl_wilddump_req_filter(rth, family, type, RTEXT_FILTER_VF);