Skip to content

Commit 56b1b7c

Browse files
lxinklassert
authored andcommitted
esp6: calculate transport_header correctly when sel.family != AF_INET6
In esp6_init_state() for beet mode when x->sel.family != AF_INET6: x->props.header_len = sizeof(struct ip_esp_hdr) + crypto_aead_ivsize(aead) + IPV4_BEET_PHMAXLEN + (sizeof(struct ipv6hdr) - sizeof(struct iphdr)) In xfrm6_beet_gso_segment() skb->transport_header is supposed to move to the end of the ph header for IPPROTO_BEETPH, so if x->sel.family != AF_INET6 and it's IPPROTO_BEETPH, it should do: skb->transport_header -= (sizeof(struct ipv6hdr) - sizeof(struct iphdr)); skb->transport_header += ph->hdrlen * 8; And IPV4_BEET_PHMAXLEN is only reserved for PH header, so if x->sel.family != AF_INET6 and it's not IPPROTO_BEETPH, it should do: skb->transport_header -= (sizeof(struct ipv6hdr) - sizeof(struct iphdr)); skb->transport_header -= IPV4_BEET_PHMAXLEN; Thanks Sabrina for looking deep into this issue. Fixes: 7f9e40e ("esp6: add gso_segment for esp6 beet mode") Reported-by: Sabrina Dubroca <[email protected]> Signed-off-by: Xin Long <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent c95c5f5 commit 56b1b7c

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

net/ipv6/esp6_offload.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -175,24 +175,27 @@ static struct sk_buff *xfrm6_beet_gso_segment(struct xfrm_state *x,
175175

176176
skb->transport_header += x->props.header_len;
177177

178-
if (proto == IPPROTO_BEETPH) {
179-
struct ip_beet_phdr *ph = (struct ip_beet_phdr *)skb->data;
178+
if (x->sel.family != AF_INET6) {
179+
skb->transport_header -=
180+
(sizeof(struct ipv6hdr) - sizeof(struct iphdr));
180181

181-
skb->transport_header += ph->hdrlen * 8;
182-
proto = ph->nexthdr;
183-
}
182+
if (proto == IPPROTO_BEETPH) {
183+
struct ip_beet_phdr *ph =
184+
(struct ip_beet_phdr *)skb->data;
185+
186+
skb->transport_header += ph->hdrlen * 8;
187+
proto = ph->nexthdr;
188+
} else {
189+
skb->transport_header -= IPV4_BEET_PHMAXLEN;
190+
}
184191

185-
if (x->sel.family == AF_INET6) {
192+
if (proto == IPPROTO_TCP)
193+
skb_shinfo(skb)->gso_type |= SKB_GSO_TCPV6;
194+
} else {
186195
__be16 frag;
187196

188197
skb->transport_header +=
189198
ipv6_skip_exthdr(skb, 0, &proto, &frag);
190-
} else {
191-
skb->transport_header -=
192-
(sizeof(struct ipv6hdr) - sizeof(struct iphdr));
193-
194-
if (proto == IPPROTO_TCP)
195-
skb_shinfo(skb)->gso_type |= SKB_GSO_TCPV6;
196199
}
197200

198201
__skb_pull(skb, skb_transport_offset(skb));

0 commit comments

Comments
 (0)