From patchwork Thu Jan 3 04:38:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Ahern X-Patchwork-Id: 1020168 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="sP+5uPFr"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43VZtW5SYxz9s2P for ; Thu, 3 Jan 2019 15:38:43 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728628AbfACEig (ORCPT ); Wed, 2 Jan 2019 23:38:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:34052 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729272AbfACEig (ORCPT ); Wed, 2 Jan 2019 23:38:36 -0500 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 5FBA4214C6; Thu, 3 Jan 2019 04:38:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546490315; bh=pEJ+FKB8z0kJUfhPb5dIsRa2QiGp75xQd5w7mnuxlLY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sP+5uPFrf4n/Pl1+BlR3CnXpsEq4mrnu591OGTITZctl9nZk1REF0oVtUDo2mu1+m i+FjC7QwLCRBzK2ZYZi16LPndgMD9bbdrJfy+Q3uFWfvCcKo4AgyqnquuqX9DjbVyb eN18H1nQdd2L6fNoPSpywaDXXmqe3FXEGaBhBq9c= From: David Ahern To: netdev@vger.kernel.org Cc: idosch@mellanox.com, stephen@networkplumber.org, David Ahern Subject: [PATCH iproute2-next 5/5] bridge: fdb: Fix filtering with strict checking disabled Date: Wed, 2 Jan 2019 20:38:32 -0800 Message-Id: <20190103043832.3748-6-dsahern@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190103043832.3748-1-dsahern@kernel.org> References: <20190103043832.3748-1-dsahern@kernel.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: David Ahern Older kernels expect an ifinfomsg struct as the ancillary header, and after kernel commit bd961c9bc664 ("rtnetlink: fix rtnl_fdb_dump() for ndmsg header") can handle either ifinfomsg or ndmsg. Strict data checking only allows ndmsg. Use the new RTNL_HANDLE_F_STRICT_CHK flag to know which header to send. Signed-off-by: David Ahern Reviewed-by: Ido Schimmel Tested-by: Ido Schimmel --- bridge/fdb.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/bridge/fdb.c b/bridge/fdb.c index 676267e15ddc..a0fdac00e094 100644 --- a/bridge/fdb.c +++ b/bridge/fdb.c @@ -256,6 +256,25 @@ int print_fdb(struct nlmsghdr *n, void *arg) return 0; } +static int fdb_linkdump_filter(struct nlmsghdr *nlh, int reqlen) +{ + int err; + + if (filter_index) { + struct ifinfomsg *ifm = NLMSG_DATA(nlh); + + ifm->ifi_index = filter_index; + } + + if (filter_master) { + err = addattr32(nlh, reqlen, IFLA_MASTER, filter_master); + if (err) + return err; + } + + return 0; +} + static int fdb_dump_filter(struct nlmsghdr *nlh, int reqlen) { int err; @@ -279,6 +298,7 @@ static int fdb_show(int argc, char **argv) { char *filter_dev = NULL; char *br = NULL; + int rc; while (argc > 0) { if ((strcmp(*argv, "brport") == 0) || strcmp(*argv, "dev") == 0) { @@ -323,7 +343,12 @@ static int fdb_show(int argc, char **argv) return nodev(filter_dev); } - if (rtnl_neighdump_req(&rth, PF_BRIDGE, fdb_dump_filter) < 0) { + if (rth.flags & RTNL_HANDLE_F_STRICT_CHK) + rc = rtnl_neighdump_req(&rth, PF_BRIDGE, fdb_dump_filter); + else + rc = rtnl_linkdump_req_filter_fn(&rth, PF_BRIDGE, + fdb_linkdump_filter); + if (rc < 0) { perror("Cannot send dump request"); exit(1); }