Skip to content

Commit

Permalink
bridge: Do not send empty IFLA_AF_SPEC attribute
Browse files Browse the repository at this point in the history
commit 9b134b1 upstream.

After commit b6c02ef ("bridge: Netlink interface fix."),
br_fill_ifinfo() started to send an empty IFLA_AF_SPEC attribute when a
bridge vlan dump is requested but an interface does not have any vlans
configured.

iproute2 ignores such an empty attribute since commit b262a9becbcb
("bridge: Fix output with empty vlan lists") but older iproute2 versions as
well as other utilities have their output changed by the cited kernel
commit, resulting in failed test cases. Regardless, emitting an empty
attribute is pointless and inefficient.

Avoid this change by canceling the attribute if no AF_SPEC data was added.

Fixes: b6c02ef ("bridge: Netlink interface fix.")
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
Link: https://lore.kernel.org/r/20220725001236.95062-1-bpoirier@nvidia.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
gobenji authored and gregkh committed Aug 3, 2022
1 parent 95226ea commit 3636f62
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions net/bridge/br_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,9 +589,13 @@ static int br_fill_ifinfo(struct sk_buff *skb,
}

done:
if (af) {
if (nlmsg_get_pos(skb) - (void *)af > nla_attr_size(0))
nla_nest_end(skb, af);
else
nla_nest_cancel(skb, af);
}

if (af)
nla_nest_end(skb, af);
nlmsg_end(skb, nlh);
return 0;

Expand Down

0 comments on commit 3636f62

Please sign in to comment.