Skip to content

Commit 3c96ec5

Browse files
lxinklassert
authored andcommitted
esp6: get the right proto for transport mode in esp6_gso_encap
For transport mode, when ipv6 nexthdr is set, the packet format might be like: ---------------------------------------------------- | | dest | | | | ESP | ESP | | IP6 hdr| opts.| ESP | TCP | Data | Trailer | ICV | ---------------------------------------------------- What it wants to get for x-proto in esp6_gso_encap() is the proto that will be set in ESP nexthdr. So it should skip all ipv6 nexthdrs and get the real transport protocol. Othersize, the wrong proto number will be set into ESP nexthdr. This patch is to skip all ipv6 nexthdrs by calling ipv6_skip_exthdr() in esp6_gso_encap(). Fixes: 7862b40 ("esp: Add gso handlers for esp4 and esp6") Signed-off-by: Xin Long <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent 06a0afc commit 3c96ec5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

net/ipv6/esp6_offload.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,16 @@ static void esp6_gso_encap(struct xfrm_state *x, struct sk_buff *skb)
123123
struct ip_esp_hdr *esph;
124124
struct ipv6hdr *iph = ipv6_hdr(skb);
125125
struct xfrm_offload *xo = xfrm_offload(skb);
126-
int proto = iph->nexthdr;
126+
u8 proto = iph->nexthdr;
127127

128128
skb_push(skb, -skb_network_offset(skb));
129+
130+
if (x->outer_mode.encap == XFRM_MODE_TRANSPORT) {
131+
__be16 frag;
132+
133+
ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr), &proto, &frag);
134+
}
135+
129136
esph = ip_esp_hdr(skb);
130137
*skb_mac_header(skb) = IPPROTO_ESP;
131138

0 commit comments

Comments
 (0)