Skip to content

Commit b6c02ef

Browse files
HenrikBjoernlundkuba-moo
authored andcommitted
bridge: Netlink interface fix.
This commit is correcting NETLINK br_fill_ifinfo() to be able to handle 'filter_mask' with multiple flags asserted. Fixes: 36a8e8e ("bridge: Extend br_fill_ifinfo to return MPR status") Signed-off-by: Henrik Bjoernlund <henrik.bjoernlund@microchip.com> Reviewed-by: Horatiu Vultur <horatiu.vultur@microchip.com> Suggested-by: Nikolay Aleksandrov <nikolay@nvidia.com> Tested-by: Horatiu Vultur <horatiu.vultur@microchip.com> Acked-by: Nikolay Aleksandrov <nikolay@nvidia.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent d91dc43 commit b6c02ef

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

net/bridge/br_netlink.c

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ static int br_fill_ifinfo(struct sk_buff *skb,
380380
u32 filter_mask, const struct net_device *dev)
381381
{
382382
u8 operstate = netif_running(dev) ? dev->operstate : IF_OPER_DOWN;
383+
struct nlattr *af = NULL;
383384
struct net_bridge *br;
384385
struct ifinfomsg *hdr;
385386
struct nlmsghdr *nlh;
@@ -423,11 +424,18 @@ static int br_fill_ifinfo(struct sk_buff *skb,
423424
nla_nest_end(skb, nest);
424425
}
425426

427+
if (filter_mask & (RTEXT_FILTER_BRVLAN |
428+
RTEXT_FILTER_BRVLAN_COMPRESSED |
429+
RTEXT_FILTER_MRP)) {
430+
af = nla_nest_start_noflag(skb, IFLA_AF_SPEC);
431+
if (!af)
432+
goto nla_put_failure;
433+
}
434+
426435
/* Check if the VID information is requested */
427436
if ((filter_mask & RTEXT_FILTER_BRVLAN) ||
428437
(filter_mask & RTEXT_FILTER_BRVLAN_COMPRESSED)) {
429438
struct net_bridge_vlan_group *vg;
430-
struct nlattr *af;
431439
int err;
432440

433441
/* RCU needed because of the VLAN locking rules (rcu || rtnl) */
@@ -441,11 +449,6 @@ static int br_fill_ifinfo(struct sk_buff *skb,
441449
rcu_read_unlock();
442450
goto done;
443451
}
444-
af = nla_nest_start_noflag(skb, IFLA_AF_SPEC);
445-
if (!af) {
446-
rcu_read_unlock();
447-
goto nla_put_failure;
448-
}
449452
if (filter_mask & RTEXT_FILTER_BRVLAN_COMPRESSED)
450453
err = br_fill_ifvlaninfo_compressed(skb, vg);
451454
else
@@ -456,32 +459,25 @@ static int br_fill_ifinfo(struct sk_buff *skb,
456459
rcu_read_unlock();
457460
if (err)
458461
goto nla_put_failure;
459-
460-
nla_nest_end(skb, af);
461462
}
462463

463464
if (filter_mask & RTEXT_FILTER_MRP) {
464-
struct nlattr *af;
465465
int err;
466466

467467
if (!br_mrp_enabled(br) || port)
468468
goto done;
469469

470-
af = nla_nest_start_noflag(skb, IFLA_AF_SPEC);
471-
if (!af)
472-
goto nla_put_failure;
473-
474470
rcu_read_lock();
475471
err = br_mrp_fill_info(skb, br);
476472
rcu_read_unlock();
477473

478474
if (err)
479475
goto nla_put_failure;
480-
481-
nla_nest_end(skb, af);
482476
}
483477

484478
done:
479+
if (af)
480+
nla_nest_end(skb, af);
485481
nlmsg_end(skb, nlh);
486482
return 0;
487483

0 commit comments

Comments
 (0)