Re: [PATCH net v2] net: llc: explicitly set skb->transport_header

From: Antonio Pastor
Date: Tue Dec 24 2024 - 20:35:53 EST


On 2024-12-23 13:18, Eric Dumazet wrote:
I see skb->transport_header being advanced at line 61 :

/* Pass the frame on. */
skb->transport_header += 5;

Same treatment as before? Reset after pull?

@@ -58,8 +58,8 @@ static int snap_rcv(struct sk_buff *skb, struct net_device *dev,
        proto = find_snap_client(skb_transport_header(skb));
        if (proto) {
                /* Pass the frame on. */
-               skb->transport_header += 5;
                skb_pull_rcsum(skb, 5);
+               skb_reset_transport_header(skb);
                rc = proto->rcvfunc(skb, dev, &snap_packet_type, orig_dev);
        }
        rcu_read_unlock();

I'll submit that as a separate patch.

Note that setting the transport header (conditionally or not) in
__netif_receive_skb()
is probably a mistake. Only network (ipv4, ipv6) handlers can possibly
know the concept
of transport header.
Not too sure about that, but I don't have specifics. Non-IP stacks are probably all ancient, but some might care.
Hopefully at some point we can remove this defensive code.

diff --git a/net/core/dev.c b/net/core/dev.c
index c7f3dea3e0eb9eb05865e49dd7a8535afb974149..b6722e11ee4e171e6a2f379fc1d0197dfcb1a842
100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5474,8 +5474,6 @@ static int __netif_receive_skb_core(struct
sk_buff **pskb, bool pfmemalloc,
orig_dev = skb->dev;

skb_reset_network_header(skb);
- if (!skb_transport_header_was_set(skb))
- skb_reset_transport_header(skb);
skb_reset_mac_len(skb);

pt_prev = NULL;

I don't know the code well enough to identify all possible paths after this point to ensure all of them set transport header. I'd expect IPv4/IPv6 are OK and we are making LLC whole, but don't know what else to test beyond that. My testing is limited to SNAP... taking that out requires regression testing at a level I'm not comfortable running.