Fix determination of the promiscuity counter for links #1001
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Function
LinkDeserialize
checked for presence ofIFF_PROMISC
in the link's flags to determine whether it was in promiscuous mode.This flag only tracks what is set with commands such as
but is not set when you run
tcpdump
orwireshark
for example, which also put the device in promiscuous mode.There is a counter that tracks the number of times promiscuous mode has been requested. It reacts to all the ways,
ip set
, and alsotcpdump
and co.With this change this counter is used instead of checking the flag. This makes the library reflect what
would show in its
promiscuity
field.To test this change, start some processes of
tcpdump
or similar and see the counter increase inip -d link show <link>
as well as in the patched version of this netlink library. With the unpatched version the counter remains 0. Then enable promiscuous mode globally for the interface. This will increase the count in all variants,ip link
, the old unpatched and the patched version of this netlink library.Simple test program for reference: