]> git.ipfire.org Git - thirdparty/iproute2.git/commit
bridge: Do not print stray prefixes in monitor mode
authorBenjamin Poirier <bpoirier@nvidia.com>
Thu, 22 Sep 2022 06:19:35 +0000 (15:19 +0900)
committerStephen Hemminger <stephen@networkplumber.org>
Fri, 30 Sep 2022 19:36:40 +0000 (12:36 -0700)
commit7e0a889b54945af13b22b80bcfbb683fb310c2d0
tree1d95af2e142b9d1e5f07848f424af86f865d123e
parent35ad983cc8e347527f8288753c24ba7b11fd076a
bridge: Do not print stray prefixes in monitor mode

When using `bridge monitor` with the '-timestamp' option or the "all"
parameter, prefixes are printed before the actual event descriptions.
Currently, those prefixes are printed for each netlink message that's
received. However, some netlink messages do not lead to an event
description being printed. That's usually because a message is not related
to AF_BRIDGE. This results in stray prefixes being printed.

Restructure accept_msg() and its callees such that prefixes are only
printed after a message has been checked for eligibility.

The issue can be witnessed using the following commands:
ip link add dummy0 type dummy
# Start `bridge monitor all` now in another terminal.
# Cause a stray "[LINK]" to be printed (family 10).
# It does not appear yet because the output is line buffered.
ip link set dev dummy0 up
# Cause a stray "[NEIGH]" to be printed (family 2).
ip neigh add 10.0.0.1 lladdr 02:00:00:00:00:01 dev dummy0
# Cause a genuine entry to be printed, which flushes the previous
# output.
bridge fdb add 02:00:00:00:00:01 dev dummy0
# We now see:
# [LINK][NEIGH][NEIGH]02:00:00:00:00:01 dev dummy0 self permanent

Fixes: d04bc300c3e3 ("Add bridge command")
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
bridge/br_common.h
bridge/fdb.c
bridge/link.c
bridge/mdb.c
bridge/monitor.c
bridge/vlan.c
bridge/vni.c