net-gro: reset skb->pkt_type in napi_reuse_skb()
Subsystems (2)
PATCH 1/1 net-gro: reset skb->pkt_type in napi_reuse_skb()
eth_type_trans() assumes initial value for skb->pkt_type is PACKET_HOST.
This is indeed the value right after a fresh skb allocation.
However, it is possible that GRO merged a packet with a different value (like PACKET_OTHERHOST in case macvlan is used), so we need to make sure napi->skb will have pkt_type set back to PACKET_HOST.
Otherwise, valid packets might be dropped by the stack because their pkt_type is not PACKET_HOST.
napi_reuse_skb() was added in commit 96e93eab2033 ("gro: Add internal interfaces for VLAN"), but this bug always has been there.
--- net/core/dev.c | 5 +++++ 1 file changed, 5 insertions(+)
net/core/dev.c +5 -0
@@ -5655,6 +5655,11 @@ static void napi_reuse_skb(struct napi_struct *napi, struct sk_buff *skb) skb->vlan_tci =0 ; skb->dev = napi->dev; skb->skb_iif =0 ; + +/* eth_type_trans() assumes pkt_type is PACKET_HOST */ +WARN_ON_ONCE (skb->pkt_type !=PACKET_HOST ); + skb->pkt_type =PACKET_HOST ; + skb->encapsulation =0 ;skb_shinfo (skb)->gso_type =0 ; skb->truesize =SKB_TRUESIZE (skb_end_offset (skb));
Signature · 1 line
2.19.1.1215.g8438c0b245-goog
Quoted 28 lines · Eric Dumazet
eth_type_trans()assumes initial value forskb->pkt_typeisPACKET_HOST.This is indeed the value right after a fresh skb allocation.
However, it is possible that GRO merged a packet with a different value (like
PACKET_OTHERHOSTin case macvlan is used), so we need to make surenapi->skbwill havepkt_typeset back toPACKET_HOST.Otherwise, valid packets might be dropped by the stack because their
pkt_typeis notPACKET_HOST.
napi_reuse_skb()was added in commit96e93eab2033("gro: Add internal interfaces for VLAN"), but this bug always has been there.Fixes 96e93eab2033 ("gro: Add internal interfaces for VLAN")Signed-off-by Eric Dumazet <[email protected]>--- net/core/dev.c | 5 +++++ 1 file changed, 5 insertions(+)net/core/dev.c +0
-0
net/core/dev.c static void napi_reuse_skb(struct napi_struct *napi, struct sk_buff *skb) · line 5661
Quoted 7 lines
net/core/dev.c +3
-0@@ -5655,6 +5655,11 @@ static void napi_reuse_skb(struct napi_struct *napi, struct sk_buff *skb) skb->vlan_tci =0 ; skb->dev = napi->dev; skb->skb_iif =0 ; + +/* eth_type_trans() assumes pkt_type is PACKET_HOST */ +WARN_ON_ONCE (skb->pkt_type !=PACKET_HOST );
Oops sorry for this bit, I will send a v2 without it of course.
Quoted 6 lines
net/core/dev.c +2
-0+ skb->pkt_type =PACKET_HOST ; + skb->encapsulation =0 ;skb_shinfo (skb)->gso_type =0 ;
skb->truesize= SKB_TRUESIZE(skb_end_offset(skb));