Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bpf: Differentiate skb tracking reasons
By differentiating skb track reason (filter/skb/stackid), we can avoid a mismatching issue that leads to confusing output. I saw an issue when --filter-track-skb and --filter-track-skb-by-stackid are used together: 1. At func1, an skb matches the pcap filter, we then fill the map stackid_skb[stackid] = skb for --filter-track-skb-by-stackid; 2. At func2, the skb arg doesn't match the pcap filter, but stackid can be found in map stackid_skb. We therefore store the map entry skb_addresses[skb] = true for --filter-track-skb; 3. Due to some reasons, this skb never gets freed by kfree_skbmem(), so pwru keeps matching "wrong" packets due to permanent entry in map skb_addresses for --filter-track-skb; This patch mitigates these risks by not storing new entry in skb_addresses if the skb is tracked by stackid. This doesn't harm the original purpose of --filter-track-skb-by-stack, which is designed for non-skb function tracing on the same stack. On the otherhand, calling bpf_update_map() only for specific track reasons improves performance a little bit. For example, if an skb is already in map skb_addresses, now we don't need to put it in the map again. Signed-off-by: gray <[email protected]>
- Loading branch information