Skip to content

Commit 9b134b1

Browse files
gobenjiPaolo Abeni
authored andcommitted
bridge: Do not send empty IFLA_AF_SPEC attribute
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 b262a9b ("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>
1 parent 33881ab commit 9b134b1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

net/bridge/br_netlink.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,9 +589,13 @@ static int br_fill_ifinfo(struct sk_buff *skb,
589589
}
590590

591591
done:
592+
if (af) {
593+
if (nlmsg_get_pos(skb) - (void *)af > nla_attr_size(0))
594+
nla_nest_end(skb, af);
595+
else
596+
nla_nest_cancel(skb, af);
597+
}
592598

593-
if (af)
594-
nla_nest_end(skb, af);
595599
nlmsg_end(skb, nlh);
596600
return 0;
597601

0 commit comments

Comments
 (0)