bridge: Do not send empty IFLA_AF_SPEC attribute
Subsystems (3)
PATCH 1/1 bridge: Do not send empty IFLA_AF_SPEC attribute
After commit b6c02ef54913 ("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.
--- net/bridge/br_netlink.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
net/bridge/br_netlink.c +6 -2
@@ -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 ;
Signature · 1 line
2.36.1
Quoted 30 lines · Benjamin Poirier
After commit
b6c02ef54913("bridge: Netlink interface fix."),br_fill_ifinfo()started to send an emptyIFLA_AF_SPECattribute 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_SPECdata was added.Fixes b6c02ef54913 ("bridge: Netlink interface fix.")Reviewed-by Ido Schimmel <[email protected]>Signed-off-by Benjamin Poirier <[email protected]>--- net/bridge/br_netlink.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)net/bridge/br_netlink.c +2
-0@@ -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 ))
net/bridge/br_netlink.c static int br_fill_ifinfo(struct sk_buff *skb, · line 601
Quoted 10 lines
net/bridge/br_netlink.c +4
-2+nla_nest_end (skb, af); + else +nla_nest_cancel (skb ,af ); + } -if (af) -nla_nest_end (skb, af);nlmsg_end (skb, nlh);return 0 ;
br_fill_ifinfo has been a mess, at some point we have to refactor it.
Anyway, thanks for the patch:
This patch was applied to netdev/net.git (master) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to netdev/net.git (master)
by Paolo Abeni <[email protected]>:
Quoted 5 lines · On Mon, 25 Jul 2022 09:12:36 +0900 you wrote:
After commit
b6c02ef54913("bridge: Netlink interface fix."),br_fill_ifinfo()started to send an emptyIFLA_AF_SPECattribute when a bridge vlan dump is requested but an interface does not have any vlans configured.
Quoted 7 lines
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.[...]
Here is the summary with links:
- [net] bridge: Do not send empty IFLA_AF_SPEC attribute
https://git.kernel.org/netdev/net/c/9b134b1694ec
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html