Commit 130549fe ("netfilter: reset nf_trace in nf_reset") added code to reset nf_trace in nf_reset(). This is wrong and unnecessary. nf_reset() is used in the following cases: - when passing packets up the the socket layer, at which point we want to release all netfilter references that might keep modules pinned while the packet is queued. nf_trace doesn't matter anymore at this point. - when encapsulating or decapsulating IPsec packets. We want to continue tracing these packets after IPsec processing. - when passing packets through virtual network devices. Only devices on that encapsulate in IPv4/v6 matter since otherwise nf_trace is not used anymore. Its not entirely clear whether those packets should be traced after that, however we've always done that. - when passing packets through virtual network devices that make the packet cross network namespace boundaries. This is the only cases where we clearly want to reset nf_trace and is also what the original patch intended to fix. Add a new function nf_reset_trace() and use it in dev_forward_skb() to fix this properly.
Unified · Split
| @@ -2641,6 +2641,10 @@ static inline void nf_reset(struct sk_buff *skb) · 2640 unmodified lines | |||
| 2641 | nf_bridge_put(skb->nf_bridge); | 2641 | nf_bridge_put(skb->nf_bridge); |
| 2642 | skb->nf_bridge = NULL; | 2642 | skb->nf_bridge = NULL; |
| 2643 | #endif | 2643 | #endif |
| 2644 | } | ||
| 2645 | |||
| 2646 | static inline void nf_reset_trace(struct sk_buff *skb) | ||
| 2647 | { | ||
| 2644 | #if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE) | 2648 | #if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE) |
| 2645 | skb->nf_trace = 0; | 2649 | skb->nf_trace = 0; |
| 2646 | #endif | 2650 | #endif |
| @@ -1639,6 +1639,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb) · 1638 unmodified lines | |||
| 1639 | skb->mark = 0; | 1639 | skb->mark = 0; |
| 1640 | secpath_reset(skb); | 1640 | secpath_reset(skb); |
| 1641 | nf_reset(skb); | 1641 | nf_reset(skb); |
| 1642 | nf_reset_trace(skb); | ||
| 1642 | return netif_rx(skb); | 1643 | return netif_rx(skb); |
| 1643 | } | 1644 | } |
| 1644 | EXPORT_SYMBOL_GPL(dev_forward_skb); | 1645 | EXPORT_SYMBOL_GPL(dev_forward_skb); |