From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A74CC282C0 for ; Fri, 25 Jan 2019 18:01:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D8276218B0 for ; Fri, 25 Jan 2019 18:01:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728653AbfAYSA7 (ORCPT ); Fri, 25 Jan 2019 13:00:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49132 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726335AbfAYSA7 (ORCPT ); Fri, 25 Jan 2019 13:00:59 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 20F8A796E8; Fri, 25 Jan 2019 18:00:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0952B189F4; Fri, 25 Jan 2019 18:00:59 +0000 (UTC) Received: from zmail17.collab.prod.int.phx2.redhat.com (zmail17.collab.prod.int.phx2.redhat.com [10.5.83.19]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id DEBCB18005AF; Fri, 25 Jan 2019 18:00:58 +0000 (UTC) Date: Fri, 25 Jan 2019 13:00:58 -0500 (EST) From: Ivan Vecera To: Ido Schimmel Cc: netdev@vger.kernel.org, stephen@networkplumber.org, dsahern@gmail.com, liali@redhat.com, mlxsw Message-ID: <182310943.98756277.1548439258643.JavaMail.zimbra@redhat.com> In-Reply-To: <20190125170837.6434-1-idosch@mellanox.com> References: <20190125170837.6434-1-idosch@mellanox.com> Subject: Re: [PATCH iproute2-master] bridge: fdb: Fix FDB dump with strict checking disabled MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [37.188.177.88, 10.4.196.2, 10.5.100.50, 10.4.195.18] Thread-Topic: [PATCH iproute2-master] bridge: fdb: Fix FDB dump with strict checking disabled Thread-Index: AQHUtNC0Wyx19Ov3yUyJ9u31uwPk5AOS9f3L X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 25 Jan 2019 18:00:59 +0000 (UTC) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org ----- Ido Schimmel wrote: > While iproute2 correctly uses ifinfomsg struct as the ancillary header > when requesting an FDB dump on old kernels, it sets the message type to > RTM_GETLINK. This results in wrong reply being returned. > > Fix this by using RTM_GETNEIGH instead. > > Before: > $ bridge fdb show brport dummy0 > Not RTM_NEWNEIGH: 00000158 00000010 00000002 > > After: > $ bridge fdb show brport dummy0 > 2a:0b:41:1c:92:d3 vlan 1 master br0 permanent > 2a:0b:41:1c:92:d3 master br0 permanent > 33:33:00:00:00:01 self permanent > 01:00:5e:00:00:01 self permanent > > Fixes: 05880354c2cf ("bridge: fdb: Fix filtering with strict checking disabled") > Signed-off-by: Ido Schimmel > Reported-by: LiLiang > --- > bridge/fdb.c | 3 +-- > include/libnetlink.h | 3 +++ > lib/libnetlink.c | 23 +++++++++++++++++++++++ > 3 files changed, 27 insertions(+), 2 deletions(-) > > diff --git a/bridge/fdb.c b/bridge/fdb.c > index f75e953a80e2..c4bf40390f42 100644 > --- a/bridge/fdb.c > +++ b/bridge/fdb.c > @@ -346,8 +346,7 @@ static int fdb_show(int argc, char **argv) > 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); > + rc = rtnl_fdb_linkdump_req_filter_fn(&rth, fdb_linkdump_filter); > if (rc < 0) { > perror("Cannot send dump request"); > exit(1); > diff --git a/include/libnetlink.h b/include/libnetlink.h > index 0854d6ad2fab..503b3ec11bb6 100644 > --- a/include/libnetlink.h > +++ b/include/libnetlink.h > @@ -81,6 +81,9 @@ int rtnl_linkdump_req_filter(struct rtnl_handle *rth, int fam, __u32 filt_mask) > int rtnl_linkdump_req_filter_fn(struct rtnl_handle *rth, int fam, > req_filter_fn_t fn) > __attribute__((warn_unused_result)); > +int rtnl_fdb_linkdump_req_filter_fn(struct rtnl_handle *rth, > + req_filter_fn_t filter_fn) > + __attribute__((warn_unused_result)); > int rtnl_statsdump_req_filter(struct rtnl_handle *rth, int fam, __u32 filt_mask) > __attribute__((warn_unused_result)); > int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, > diff --git a/lib/libnetlink.c b/lib/libnetlink.c > index 110f47bcd65a..7b392862cb91 100644 > --- a/lib/libnetlink.c > +++ b/lib/libnetlink.c > @@ -503,6 +503,29 @@ int rtnl_linkdump_req_filter_fn(struct rtnl_handle *rth, int family, > return __rtnl_linkdump_req(rth, family); > } > > +int rtnl_fdb_linkdump_req_filter_fn(struct rtnl_handle *rth, > + req_filter_fn_t filter_fn) > +{ > + struct { > + struct nlmsghdr nlh; > + struct ifinfomsg ifm; > + char buf[128]; > + } req = { > + .nlh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)), > + .nlh.nlmsg_type = RTM_GETNEIGH, > + .nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST, > + .nlh.nlmsg_seq = rth->dump = ++rth->seq, > + .ifm.ifi_family = PF_BRIDGE, > + }; > + int err; > + > + err = filter_fn(&req.nlh, sizeof(req)); > + if (err) > + return err; > + > + return send(rth->fd, &req, sizeof(req), 0); > +} > + > int rtnl_statsdump_req_filter(struct rtnl_handle *rth, int fam, __u32 filt_mask) > { > struct { > -- > 2.20.1 > Acked-by: Ivan Vecera