Commit b6c02ef5 authored by Henrik Bjoernlund's avatar Henrik Bjoernlund Committed by Jakub Kicinski

bridge: Netlink interface fix.

This commit is correcting NETLINK br_fill_ifinfo() to be able to
handle 'filter_mask' with multiple flags asserted.

Fixes: 36a8e8e2 ("bridge: Extend br_fill_ifinfo to return MPR status")
Signed-off-by: default avatarHenrik Bjoernlund <henrik.bjoernlund@microchip.com>
Reviewed-by: default avatarHoratiu Vultur <horatiu.vultur@microchip.com>
Suggested-by: default avatarNikolay Aleksandrov <nikolay@nvidia.com>
Tested-by: default avatarHoratiu Vultur <horatiu.vultur@microchip.com>
Acked-by: default avatarNikolay Aleksandrov <nikolay@nvidia.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent d91dc434
...@@ -380,6 +380,7 @@ static int br_fill_ifinfo(struct sk_buff *skb, ...@@ -380,6 +380,7 @@ static int br_fill_ifinfo(struct sk_buff *skb,
u32 filter_mask, const struct net_device *dev) u32 filter_mask, const struct net_device *dev)
{ {
u8 operstate = netif_running(dev) ? dev->operstate : IF_OPER_DOWN; u8 operstate = netif_running(dev) ? dev->operstate : IF_OPER_DOWN;
struct nlattr *af = NULL;
struct net_bridge *br; struct net_bridge *br;
struct ifinfomsg *hdr; struct ifinfomsg *hdr;
struct nlmsghdr *nlh; struct nlmsghdr *nlh;
...@@ -423,11 +424,18 @@ static int br_fill_ifinfo(struct sk_buff *skb, ...@@ -423,11 +424,18 @@ static int br_fill_ifinfo(struct sk_buff *skb,
nla_nest_end(skb, nest); nla_nest_end(skb, nest);
} }
if (filter_mask & (RTEXT_FILTER_BRVLAN |
RTEXT_FILTER_BRVLAN_COMPRESSED |
RTEXT_FILTER_MRP)) {
af = nla_nest_start_noflag(skb, IFLA_AF_SPEC);
if (!af)
goto nla_put_failure;
}
/* Check if the VID information is requested */ /* Check if the VID information is requested */
if ((filter_mask & RTEXT_FILTER_BRVLAN) || if ((filter_mask & RTEXT_FILTER_BRVLAN) ||
(filter_mask & RTEXT_FILTER_BRVLAN_COMPRESSED)) { (filter_mask & RTEXT_FILTER_BRVLAN_COMPRESSED)) {
struct net_bridge_vlan_group *vg; struct net_bridge_vlan_group *vg;
struct nlattr *af;
int err; int err;
/* RCU needed because of the VLAN locking rules (rcu || rtnl) */ /* RCU needed because of the VLAN locking rules (rcu || rtnl) */
...@@ -441,11 +449,6 @@ static int br_fill_ifinfo(struct sk_buff *skb, ...@@ -441,11 +449,6 @@ static int br_fill_ifinfo(struct sk_buff *skb,
rcu_read_unlock(); rcu_read_unlock();
goto done; goto done;
} }
af = nla_nest_start_noflag(skb, IFLA_AF_SPEC);
if (!af) {
rcu_read_unlock();
goto nla_put_failure;
}
if (filter_mask & RTEXT_FILTER_BRVLAN_COMPRESSED) if (filter_mask & RTEXT_FILTER_BRVLAN_COMPRESSED)
err = br_fill_ifvlaninfo_compressed(skb, vg); err = br_fill_ifvlaninfo_compressed(skb, vg);
else else
...@@ -456,32 +459,25 @@ static int br_fill_ifinfo(struct sk_buff *skb, ...@@ -456,32 +459,25 @@ static int br_fill_ifinfo(struct sk_buff *skb,
rcu_read_unlock(); rcu_read_unlock();
if (err) if (err)
goto nla_put_failure; goto nla_put_failure;
nla_nest_end(skb, af);
} }
if (filter_mask & RTEXT_FILTER_MRP) { if (filter_mask & RTEXT_FILTER_MRP) {
struct nlattr *af;
int err; int err;
if (!br_mrp_enabled(br) || port) if (!br_mrp_enabled(br) || port)
goto done; goto done;
af = nla_nest_start_noflag(skb, IFLA_AF_SPEC);
if (!af)
goto nla_put_failure;
rcu_read_lock(); rcu_read_lock();
err = br_mrp_fill_info(skb, br); err = br_mrp_fill_info(skb, br);
rcu_read_unlock(); rcu_read_unlock();
if (err) if (err)
goto nla_put_failure; goto nla_put_failure;
nla_nest_end(skb, af);
} }
done: done:
if (af)
nla_nest_end(skb, af);
nlmsg_end(skb, nlh); nlmsg_end(skb, nlh);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment