Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] The fix does not deliver what its commit message promises.
--
netfilter: flowtable: update skb csum after pppoe header push
This patch adds a skb_postpush_rcsum() call to nf_flow_pppoe_push(). The
goal is for skb->csum on CHECKSUM_COMPLETE skbs to cover the newly pushed
8 byte PPPoE session header. It follows what the vlan push path already
does.
> diff --git a/net/netfilter/nf_flow_table_ip.c b/net/netfilter/nf_flow_table_ip.c
> index 19cafae748abe..a0b541b811b40 100644
> --- a/net/netfilter/nf_flow_table_ip.c
> +++ b/net/netfilter/nf_flow_table_ip.c
> @@ -585,6 +585,8 @@ static int nf_flow_pppoe_push(struct sk_buff *skb, u16 id,
> ph->proto = proto;
> skb->protocol = htons(ETH_P_PPP_SES);
>
> + skb_postpush_rcsum(skb, skb->data, PPPOE_SES_HLEN);
> +
[Severity: High]
Does this actually leave skb->csum covering everything from skb->data
onwards by the time the skb reaches later consumers?
nf_flow_queue_xmit() calls nf_flow_encap_push() and then
__nf_flow_queue_xmit(). That pushes the Ethernet header right after the
PPPoE header, with no rcsum update:
net/netfilter/nf_flow_table_ip.c:__nf_flow_queue_xmit() {
...
skb->dev = dev;
dev_hard_header(skb, dev, ntohs(skb->protocol),
xmit->dest, xmit->source, skb->len);
dev_queue_xmit(skb);
}
eth_header() does a plain skb_push(skb, ETH_HLEN). After it runs,
skb->data points at the Ethernet header. skb->csum still covers only
PPPoE plus L3 onward. The checksum is still stale, just off by 14 bytes
instead of 22.
The consumers that keep CHECKSUM_COMPLETE across L2 expect skb->csum to
cover the MAC header. For example, with a veth egress device,
__dev_forward_skb2() in net/core/dev.c does:
reason = eth_type_trans_careful(skb, dev);
...
skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);
This subtracts Ethernet bytes that were never added. The tc mirred
egress to ingress redirect in tcf_mirred_to_dev() does the same thing
with skb_pull_rcsum(skb_to_send, mac_len). Will these still compute a
wrong checksum after this patch?
There is also an earlier problem on IPv6 flows. nf_flow_offload_ipv6_forward()
changes L3 bytes without updating skb->csum:
ip6h->hop_limit--;
So for IPv6, skb->csum is already stale before nf_flow_pppoe_push() runs,
and folding in the pushed header cannot make it correct again.
The core forwarding paths handle this by downgrading CHECKSUM_COMPLETE
with skb_forward_csum(). That is done in ip_forward(), in ip6_forward()
before the hop_limit decrement, and in the bridge forward path.
nf_flow_table_ip.c never calls skb_forward_csum() and never sets
ip_summed.
Flowtable hooks are only registered at NF_NETDEV_INGRESS, so
NIC-provided CHECKSUM_COMPLETE skbs from ordinary forwarded traffic reach
this path. nf_flow_vlan_push(), cited in the commit message as the
precedent, has the same limitation.
Would calling skb_forward_csum() in the flowtable forward paths, as the
core stack does, be a better fix? That would make the per-header rcsum
calls unnecessary. The other option is to also fold the L2 header pushed
by dev_hard_header() and every L3 change, such as the IPv6 hop_limit
decrement, into skb->csum.
> return 0;
> }
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/2026…%40cmss.chinamobile.com