Skip to content

Commit d3e5e00

Browse files
Eric Dumazetdavem330
authored andcommitted
ipv6: gso: make ipv6_gso_segment() stackable
In order to support GSO on SIT tunnels, we need to make inet_gso_segment() stackable. It should not assume network header starts right after mac header. Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 212124d commit d3e5e00

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

net/ipv6/ip6_offload.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb,
9090
u8 *prevhdr;
9191
int offset = 0;
9292
bool tunnel;
93+
int nhoff;
9394

9495
if (unlikely(skb_shinfo(skb)->gso_type &
9596
~(SKB_GSO_UDP |
@@ -103,10 +104,16 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb,
103104
0)))
104105
goto out;
105106

107+
skb_reset_network_header(skb);
108+
nhoff = skb_network_header(skb) - skb_mac_header(skb);
106109
if (unlikely(!pskb_may_pull(skb, sizeof(*ipv6h))))
107110
goto out;
108111

109-
tunnel = skb->encapsulation;
112+
tunnel = SKB_GSO_CB(skb)->encap_level > 0;
113+
if (tunnel)
114+
features = skb->dev->hw_enc_features & netif_skb_features(skb);
115+
SKB_GSO_CB(skb)->encap_level += sizeof(*ipv6h);
116+
110117
ipv6h = ipv6_hdr(skb);
111118
__skb_pull(skb, sizeof(*ipv6h));
112119
segs = ERR_PTR(-EPROTONOSUPPORT);
@@ -123,13 +130,17 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb,
123130
goto out;
124131

125132
for (skb = segs; skb; skb = skb->next) {
126-
ipv6h = ipv6_hdr(skb);
127-
ipv6h->payload_len = htons(skb->len - skb->mac_len -
128-
sizeof(*ipv6h));
133+
ipv6h = (struct ipv6hdr *)(skb_mac_header(skb) + nhoff);
134+
ipv6h->payload_len = htons(skb->len - nhoff - sizeof(*ipv6h));
135+
if (tunnel) {
136+
skb_reset_inner_headers(skb);
137+
skb->encapsulation = 1;
138+
}
139+
skb->network_header = (u8 *)ipv6h - skb->head;
140+
129141
if (!tunnel && proto == IPPROTO_UDP) {
130142
unfrag_ip6hlen = ip6_find_1stfragopt(skb, &prevhdr);
131-
fptr = (struct frag_hdr *)(skb_network_header(skb) +
132-
unfrag_ip6hlen);
143+
fptr = (struct frag_hdr *)((u8 *)ipv6h + unfrag_ip6hlen);
133144
fptr->frag_off = htons(offset);
134145
if (skb->next != NULL)
135146
fptr->frag_off |= htons(IP6_MF);

0 commit comments

Comments
 (0)