]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
bridge: fdb: Fix FDB dump with strict checking disabled
authorIdo Schimmel <idosch@mellanox.com>
Fri, 25 Jan 2019 17:09:17 +0000 (17:09 +0000)
committerStephen Hemminger <stephen@networkplumber.org>
Tue, 5 Feb 2019 23:27:28 +0000 (15:27 -0800)
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 <idosch@mellanox.com>
Reported-by: LiLiang <liali@redhat.com>
Acked-by: David Ahern <dsahern@gmail.com>
Acked-by: Ivan Vecera <ivecera@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
bridge/fdb.c
include/libnetlink.h
lib/libnetlink.c

index f75e953a80e242d8d888e24dac752e869729e8ff..c4bf40390f42b770626d1af6e5ddef0e6fa161e6 100644 (file)
@@ -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);
index 0854d6ad2fabec5ad41756c5c6fbab1318e87c3a..503b3ec11bb6bda345e663f04adedde39289c338 100644 (file)
@@ -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,
index 3beb4342d890af45ef78c75234bd8dbf2bc583b4..1892a02ab5d0d73776c9882ffc77edcd2c663d01 100644 (file)
@@ -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 {