]> git.ipfire.org Git - thirdparty/iproute2.git/commit
ip: do not print stray prefixes in monitor mode
authorBeniamino Galvani <b.galvani@gmail.com>
Sat, 13 Jul 2024 14:56:41 +0000 (16:56 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Wed, 17 Jul 2024 23:48:25 +0000 (16:48 -0700)
commit554ea3649dd15b19202d7e9791310c3bbb910b34
tree3ab51fdff8ce9d033d1d745da55c7ee7896cc7e7
parentb06341a252a815820c1bbacedec0c158dd80aac8
ip: do not print stray prefixes in monitor mode

When running "ip monitor", accept_msg() first prints the prefix and
then calls the object-specific print function, which also does the
filtering. Therefore, it is possible that the prefix is printed even
for events that get ignored later. For example:

  ip link add dummy1 type dummy
  ip link set dummy1 up
  ip -ts monitor all dev dummy1 &
  ip link add dummy2 type dummy
  ip addr add dev dummy1 192.0.2.1/24

generates:

  [2024-07-12T22:11:26.338342] [LINK][2024-07-12T22:11:26.339846] [ADDR]314: dummy1    inet 192.0.2.1/24 scope global dummy1
       valid_lft forever preferred_lft forever

Fix this by printing the prefix only after the filtering. Now the
output for the commands above is:

 [2024-07-12T22:11:26.339846] [ADDR]314: dummy1    inet 192.0.2.1/24 scope global dummy1
       valid_lft forever preferred_lft forever

See also commit 7e0a889b5494 ("bridge: Do not print stray prefixes in
monitor mode") which fixed the same problem in the bridge tool.

Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
13 files changed:
ip/ip_common.h
ip/ipaddress.c
ip/ipaddrlabel.c
ip/ipmonitor.c
ip/ipmroute.c
ip/ipneigh.c
ip/ipnetconf.c
ip/ipnetns.c
ip/ipnexthop.c
ip/ipprefix.c
ip/iproute.c
ip/iprule.c
ip/ipstats.c