net-gro: Prepare GRO stack for the upcoming tunneling support
Subsystems (4)
PATCH 1/1 net-gro: Prepare GRO stack for the upcoming tunneling support
From: Jerry Chu <[email protected]>
This patch modifies the GRO stack to remove the assumption that only one IP hdr is present in the encapsulation chain. It avoids the use of ip_hdr()/ipv6_hdr() macro in IP's *_gro_receive()/ *_gro_complete() functions because there may be more than one IP hdr present in the encapsulation chain when various flavors of IP tunneling support are added. By doing so it also allows multiple level, not just a single level (i.e., with only two IP hdrs like IP-in-IP) of encapsulation to be supported in the future.
With this patch, the GRO stack traversing now is mostly based on skb_gro_offset rather than special hdr offsets saved in skb (e.g., skb->network_header, skb->transport_header,...) As a consequence all but the top layer (which is likely to be the transport layer) must have hdrs of the same length in order for a pkt to be considered for aggregation. Therefore when adding a new layer (e.g., for tunneling), one must check and skip flows (e.g., setting NAPI_GRO_CB(p)->same_flow to 0) that have a different hdr length.
--- include/linux/netdevice.h | 2 +- include/net/tcp.h | 1 + net/core/dev.c | 76 ++++++++++++++++------------------------------- net/core/skbuff.c | 1 - net/ipv4/af_inet.c | 26 +++++++++++----- net/ipv4/tcp_offload.c | 27 ++++++++++------- net/ipv6/ip6_offload.c | 67 ++++++++++++++++++++++++++++++----------- net/ipv6/tcpv6_offload.c | 10 +++---- 8 files changed, 117 insertions(+), 93 deletions(-)
include/linux/netdevice.h +1 -1
@@ -1673,7 +1673,7 @@ struct offload_callbacks {int (*gso_send_check)(struct sk_buff *skb);struct sk_buff **(*gro_receive)(struct sk_buff **head,struct sk_buff *skb); -int (*gro_complete)(struct sk_buff *skb); +int (*gro_complete)(struct sk_buff *skb,int nhoff); };struct packet_offload {
include/net/tcp.h +1 -0
@@ -1549,6 +1549,7 @@ void tcp_v4_destroy_sock(struct sock *sk);struct sk_buff *tcp_gso_segment (struct sk_buff *skb,netdev_features_t features);struct sk_buff **tcp_gro_receive (struct sk_buff **head,struct sk_buff *skb); +int __tcp_gro_complete (struct sk_buff *skb,struct tcphdr *th);int tcp_gro_complete (struct sk_buff *skb);void __tcp_v4_send_check (struct sk_buff *skb,__be32 saddr,__be32 daddr);
net/core/dev.c +25 -51
125 lines not on this page · raw message
net/core/skbuff.c +0 -1
@@ -3083,7 +3083,6 @@ int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb)skb_set_mac_header (nskb,skb_mac_header (p) - p->data);skb_set_network_header (nskb,skb_network_offset (p)); -skb_set_transport_header (nskb,skb_transport_offset (p));__skb_pull (p,skb_gro_offset (p)); memcpy(skb_mac_header(nskb), skb_mac_header(p),
net/ipv4/af_inet.c +19 -7
@@ -1377,8 +1377,12 @@ static struct sk_buff **inet_gro_receive(struct sk_buff **head,if (!NAPI_GRO_CB (p)->same_flow)continue ; - iph2 =ip_hdr (p); - + iph2 = (struct iphdr *)(p->data + off); +/* The above works because, with the exception of the top +* (inner most) layer, we only aggregate pkts with the same +* hdr length so all the hdrs we'll need to verify will start +* at the same offset. +*/ if ((iph->protocol ^ iph2->protocol) | ((__force u32 )iph->saddr ^ (__force u32 )iph2->saddr) | ((__force u32 )iph->daddr ^ (__force u32 )iph2->daddr)) {
@@ -1397,8 +1401,12 @@ static struct sk_buff **inet_gro_receive(struct sk_buff **head, }NAPI_GRO_CB (skb)->flush |= flush; +skb_set_network_header (skb, off); +/* The above will be needed by the transport layer if there is one +* immediately following this IP hdr. +*/ +skb_gro_pull (skb,sizeof (*iph)); -skb_set_transport_header (skb,skb_gro_offset (skb)); pp = ops->callbacks.gro_receive (head, skb);
@@ -1411,10 +1419,10 @@ out:return pp; } -static int inet_gro_complete (struct sk_buff *skb) +static int inet_gro_complete (struct sk_buff *skb,int nhoff) { -__be16 newlen =htons (skb->len -skb_network_offset (skb)); -struct iphdr *iph =ip_hdr (skb); +__be16 newlen =htons (skb->len - nhoff); +struct iphdr *iph = (struct iphdr *)(skb->data + nhoff);const struct net_offload *ops;int proto = iph->protocol;int err = -ENOSYS ;
@@ -1427,7 +1435,11 @@ static int inet_gro_complete(struct sk_buff *skb)if (WARN_ON (!ops || !ops->callbacks.gro_complete)) goto out_unlock; - err = ops->callbacks.gro_complete (skb); +/* Only need to add sizeof(*iph) to get to the next hdr below +* because any hdr with option will have been flushed in +* inet_gro_receive(). +*/ + err = ops->callbacks.gro_complete (skb, nhoff +sizeof (*iph)); out_unlock:rcu_read_unlock ();
net/ipv4/tcp_offload.c +16 -11
@@ -184,7 +184,7 @@ struct sk_buff **tcp_gro_receive(struct sk_buff **head, struct sk_buff *skb)if (!NAPI_GRO_CB (p)->same_flow)continue ; - th2 =tcp_hdr (p); + th2 = (struct tcphdr *)(p->data + off);if (*(u32 *)&th->source ^ *(u32 *)&th2->source) {NAPI_GRO_CB (p)->same_flow =0 ;
@@ -217,7 +217,7 @@ found: } p = *head; - th2 =tcp_hdr (p); + th2 = (struct tcphdr *)(p->data + off);tcp_flag_word (th2) |= flags & (TCP_FLAG_FIN |TCP_FLAG_PSH ); out_check_final:
@@ -236,11 +236,9 @@ out: }EXPORT_SYMBOL (tcp_gro_receive); -int tcp_gro_complete (struct sk_buff *skb) +int __tcp_gro_complete (struct sk_buff *skb,struct tcphdr *th) { -struct tcphdr *th =tcp_hdr (skb); - - skb->csum_start =skb_transport_header (skb) - skb->head; + skb->csum_start = (unsigned char *)th - skb->head; skb->csum_offset = offsetof(struct tcphdr , check); skb->ip_summed =CHECKSUM_PARTIAL ;
@@ -251,6 +249,12 @@ int tcp_gro_complete(struct sk_buff *skb)return 0 ; } +EXPORT_SYMBOL (__tcp_gro_complete); + +int tcp_gro_complete (struct sk_buff *skb) +{ +return __tcp_gro_complete (skb,tcp_hdr (skb)); +}EXPORT_SYMBOL (tcp_gro_complete);static int tcp_v4_gso_send_check (struct sk_buff *skb)
@@ -272,6 +276,7 @@ static int tcp_v4_gso_send_check(struct sk_buff *skb)static struct sk_buff **tcp4_gro_receive (struct sk_buff **head,struct sk_buff *skb) { +/* Use the IP hdr immediately proceeding for this transport */ const struct iphdr *iph =skb_gro_network_header (skb);__wsum wsum;
@@ -303,16 +308,16 @@ skip_csum:return tcp_gro_receive (head, skb); } -static int tcp4_gro_complete (struct sk_buff *skb) +static int tcp4_gro_complete (struct sk_buff *skb,int nhoff) {const struct iphdr *iph =ip_hdr (skb); -struct tcphdr *th =tcp_hdr (skb); +struct tcphdr *th = (struct tcphdr *)(skb->data + nhoff); - th->check = ~tcp_v4_check (skb->len -skb_transport_offset (skb), - iph->saddr, iph->daddr,0 ); + th->check = ~tcp_v4_check (skb->len - nhoff, iph->saddr, + iph->daddr,0 );skb_shinfo (skb)->gso_type =SKB_GSO_TCPV4 ; -return tcp_gro_complete (skb); +return __tcp_gro_complete (skb, th); }static const struct net_offload tcpv4_offload = {
net/ipv6/ip6_offload.c +50 -17
125 lines not on this page · raw message
net/ipv6/tcpv6_offload.c +5 -5
@@ -66,16 +66,16 @@ skip_csum:return tcp_gro_receive (head, skb); } -static int tcp6_gro_complete (struct sk_buff *skb) +static int tcp6_gro_complete (struct sk_buff *skb,int nhoff) {const struct ipv6hdr *iph =ipv6_hdr (skb); -struct tcphdr *th =tcp_hdr (skb); +struct tcphdr *th = (struct tcphdr *)(skb->data + nhoff); - th->check = ~tcp_v6_check (skb->len -skb_transport_offset (skb), - &iph->saddr, &iph->daddr,0 ); + th->check = ~tcp_v6_check (skb->len - nhoff, &iph->saddr, + &iph->daddr,0 );skb_shinfo (skb)->gso_type =SKB_GSO_TCPV6 ; -return tcp_gro_complete (skb); +return __tcp_gro_complete (skb, th); }static const struct net_offload tcpv6_offload = {
Signature · 1 line
1.8.5.1
Quoted 44 lines · H.K. Jerry Chu
From: Jerry Chu <[email protected]>
This patch modifies the GRO stack to remove the assumption that only one IP hdr is present in the encapsulation chain. It avoids the use of ip_hdr()/ipv6_hdr() macro in IP's *_gro_receive()/
*_gro_complete()functions because there may be more than one IP hdr present in the encapsulation chain when various flavors of IP tunneling support are added. By doing so it also allows multiple level, not just a single level (i.e., with only two IP hdrs like IP-in-IP) of encapsulation to be supported in the future.With this patch, the GRO stack traversing now is mostly based on
skb_gro_offsetrather than special hdr offsets saved in skb (e.g.,skb->network_header,skb->transport_header,...) As a consequence all but the top layer (which is likely to be the transport layer) must have hdrs of the same length in order for a pkt to be considered for aggregation. Therefore when adding a new layer (e.g., for tunneling), one must check and skip flows (e.g., setting NAPI_GRO_CB(p)->same_flow to 0) that have a different hdr length.net/core/skbuff.c +0
-1@@ -3083,7 +3083,6 @@ int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb)skb_set_mac_header (nskb,skb_mac_header (p) - p->data);skb_set_network_header (nskb,skb_network_offset (p)); -skb_set_transport_header (nskb,skb_transport_offset (p));__skb_pull (p,skb_gro_offset (p)); memcpy(skb_mac_header(nskb), skb_mac_header(p),net/ipv4/af_inet.c +0
-0@@ -1397,8 +1401,12 @@ static struct sk_buff **inet_gro_receive(struct sk_buff **head, }NAPI_GRO_CB (skb)->flush |= flush;
net/ipv4/af_inet.c static struct sk_buff **inet_gro_receive(struct sk_buff **head, · line 1412
Quoted 10 lines
net/ipv4/af_inet.c +5
-1+skb_set_network_header (skb, off); +/* The above will be needed by the transport layer if there is one +* immediately following this IP hdr. +*/ +skb_gro_pull (skb,sizeof (*iph)); -skb_set_transport_header (skb,skb_gro_offset (skb)); pp = ops->callbacks.gro_receive (head, skb);
I am wondering if you tested installing a qdisc at ingress ?
qdisc_pkt_len_init() depends that GRO packets have set transport header.
Note this might be hidden by the check done in__netif_receive_skb_core()
if (!skb_transport_header_was_set(skb))
skb_reset_transport_header(skb);
To test your changes without playing with ingress qdisc, you could add :
if (!skb_transport_header_was_set(skb)) {
BUG_ON(skb_is_gso(skb))
skb_reset_transport_header(skb);
}Quoted 53 lines · Eric Dumazet
Quoted 52 lines · H.K. Jerry Chu
From: Jerry Chu <[email protected]>
This patch modifies the GRO stack to remove the assumption that only one IP hdr is present in the encapsulation chain. It avoids the use of ip_hdr()/ipv6_hdr() macro in IP's *_gro_receive()/
*_gro_complete()functions because there may be more than one IP hdr present in the encapsulation chain when various flavors of IP tunneling support are added. By doing so it also allows multiple level, not just a single level (i.e., with only two IP hdrs like IP-in-IP) of encapsulation to be supported in the future.With this patch, the GRO stack traversing now is mostly based on
skb_gro_offsetrather than special hdr offsets saved in skb (e.g.,skb->network_header,skb->transport_header,...) As a consequence all but the top layer (which is likely to be the transport layer) must have hdrs of the same length in order for a pkt to be considered for aggregation. Therefore when adding a new layer (e.g., for tunneling), one must check and skip flows (e.g., setting NAPI_GRO_CB(p)->same_flow to 0) that have a different hdr length.net/core/skbuff.c +0
-1@@ -3083,7 +3083,6 @@ int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb)skb_set_mac_header (nskb,skb_mac_header (p) - p->data);skb_set_network_header (nskb,skb_network_offset (p)); -skb_set_transport_header (nskb,skb_transport_offset (p));__skb_pull (p,skb_gro_offset (p)); memcpy(skb_mac_header(nskb), skb_mac_header(p),net/ipv4/af_inet.c +5
-1@@ -1397,8 +1401,12 @@ static struct sk_buff **inet_gro_receive(struct sk_buff **head, }NAPI_GRO_CB (skb)->flush |= flush; +skb_set_network_header (skb, off); +/* The above will be needed by the transport layer if there is one +* immediately following this IP hdr. +*/ +skb_gro_pull (skb,sizeof (*iph)); -skb_set_transport_header (skb,skb_gro_offset (skb));
Quoted 6 lines
net/ipv4/af_inet.c static struct sk_buff **inet_gro_receive(struct sk_buff **head, · line 1412
Quoted 2 lines
net/ipv4/af_inet.c +0
-0pp = ops->callbacks.gro_receive (head, skb);I am wondering if you tested installing a qdisc at ingress ?
qdisc_pkt_len_init()depends that GRO packets have set transport header.
Not sure why ingress qdisc - it seems that qdisc_pkt_len_init() is only called by the egress path (__dev_xmit_skb()).
Quoted 6 lines
Note this might be hidden by the check done in
__netif_receive_skb_core()if (!skb_transport_header_was_set(skb))
skb_reset_transport_header(skb);
Strange why is it the business of *netif_receive_skb*() to set the transport header
before IP has a chance to parse the IP hdr?
Quoted 7 lines
To test your changes without playing with ingress qdisc, you could add :
if (!skb_transport_header_was_set(skb)) { BUG_ON(skb_is_gso(skb)) skb_reset_transport_header(skb); }
Perhaps you meant the forwarding path (ingress followed by egress)? In that case __netif_receive_skb_core() may set the transport header incorrectly (?)
Jerry
Quoted 2 lines
Quoted 3 lines · Jerry Chu
Not sure why ingress qdisc - it seems that
qdisc_pkt_len_init()is only called by the egress path (__dev_xmit_skb())
.
Yeah, Qdisc was meant to be used for egress.
Then to get qdisc for ingress, we use IFB to reinject packets through the qdisc layer.
Sample of script :
ETH=eth0
IFB=ifb0
RTT_HALF=50ms
REORDER=1500us
modprobe ifb
ip link set dev $IFB up
tc qdisc add dev $ETH ingress 2>/dev/null
tc filter add dev $ETH parent ffff: \
protocol ip u32 match u32 0 0 flowid 1:1 action mirred egress \
redirect dev $IFB
tc qdisc del dev $IFB root 2>/dev/null
tc qdisc add dev $IFB root netem limit 100000 delay $RTT_HALF $REORDER
Quoted 4 lines
Strange why is it the business of *netif_receive_skb*() to set the transport header
before IP has a chance to parse the IP hdr?
Maybe you should use git blame ;)
Quoted 10 lines · Eric Dumazet
Quoted 3 lines · Jerry Chu
Not sure why ingress qdisc - it seems that
qdisc_pkt_len_init()is only called by the egress path (__dev_xmit_skb())
.Yeah, Qdisc was meant to be used for egress.
Then to get qdisc for ingress, we use IFB to reinject packets through the qdisc layer.
I don't think anything outside of GRO should be using the fields set by GRO. If they were doing it implicitly before they should be fixed. After all, they would be broken by something as simple as turning GRO off through ethtool, no?
Cheers,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Quoted 9 lines · Herbert Xu
Quoted 8 lines · Eric Dumazet
Quoted 3 lines · Jerry Chu
Not sure why ingress qdisc - it seems that
qdisc_pkt_len_init()is only called by the egress path (__dev_xmit_skb())
.Yeah, Qdisc was meant to be used for egress.
Quoted 7 lines
Quoted 2 lines
Then to get qdisc for ingress, we use IFB to reinject packets through the qdisc layer.
I don't think anything outside of GRO should be using the fields set by GRO. If they were doing it implicitly before they should be fixed. After all, they would be broken by something as simple as turning GRO off through ethtool, no?
Thats not what I said.
Please read 1def9238d4aa2146924994aa4b7dc861f03b9362 changelog for details.
If GRO is off, of course qdisc_pkt_len_init() has no problem.
Quoted 7 lines · Eric Dumazet
Thats not what I said.
Please read
1def9238d4aa2146924994aa4b7dc861f03b9362changelog for details.If GRO is off, of course
qdisc_pkt_len_init()has no problem.
Fair enough. For GSO packets yes transport_header is required. It's been this way from the very start since we need it for checksums too.
Cheers,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Quoted 63 lines · Eric Dumazet
Quoted 44 lines · H.K. Jerry Chu
From: Jerry Chu <[email protected]>
This patch modifies the GRO stack to remove the assumption that only one IP hdr is present in the encapsulation chain. It avoids the use of ip_hdr()/ipv6_hdr() macro in IP's *_gro_receive()/
*_gro_complete()functions because there may be more than one IP hdr present in the encapsulation chain when various flavors of IP tunneling support are added. By doing so it also allows multiple level, not just a single level (i.e., with only two IP hdrs like IP-in-IP) of encapsulation to be supported in the future.With this patch, the GRO stack traversing now is mostly based on
skb_gro_offsetrather than special hdr offsets saved in skb (e.g.,skb->network_header,skb->transport_header,...) As a consequence all but the top layer (which is likely to be the transport layer) must have hdrs of the same length in order for a pkt to be considered for aggregation. Therefore when adding a new layer (e.g., for tunneling), one must check and skip flows (e.g., setting NAPI_GRO_CB(p)->same_flow to 0) that have a different hdr length.net/core/skbuff.c +0
-1@@ -3083,7 +3083,6 @@ int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb)skb_set_mac_header (nskb,skb_mac_header (p) - p->data);skb_set_network_header (nskb,skb_network_offset (p)); -skb_set_transport_header (nskb,skb_transport_offset (p));__skb_pull (p,skb_gro_offset (p)); memcpy(skb_mac_header(nskb), skb_mac_header(p),net/ipv4/af_inet.c +0
-0@@ -1397,8 +1401,12 @@ static struct sk_buff **inet_gro_receive(struct sk_buff **head, }NAPI_GRO_CB (skb)->flush |= flush;net/ipv4/af_inet.c static struct sk_buff **inet_gro_receive(struct sk_buff **head, · line 1412
Quoted 10 lines
net/ipv4/af_inet.c +5
-1+skb_set_network_header (skb, off); +/* The above will be needed by the transport layer if there is one +* immediately following this IP hdr. +*/ +skb_gro_pull (skb,sizeof (*iph)); -skb_set_transport_header (skb,skb_gro_offset (skb)); pp = ops->callbacks.gro_receive (head, skb);I am wondering if you tested installing a qdisc at ingress ?
qdisc_pkt_len_init()depends that GRO packets have set transport header.Note this might be hidden by the check done in
__netif_receive_skb_core()
Quoted 8 lines
if (!skb_transport_header_was_set(skb))
skb_reset_transport_header(skb);To test your changes without playing with ingress qdisc, you could add :
if (!skb_transport_header_was_set(skb)) { BUG_ON(skb_is_gso(skb)) skb_reset_transport_header(skb);
Yes indeed GSO skb will get here w/o transport header set. This has been fixed in the v2 patch.
Thanks,
Jerry
Quoted 3 lines
}
Quoted 23 lines · H.K. Jerry Chu
From: Jerry Chu <[email protected]>
This patch modifies the GRO stack to remove the assumption that only one IP hdr is present in the encapsulation chain. It avoids the use of ip_hdr()/ipv6_hdr() macro in IP's *_gro_receive()/
*_gro_complete()functions because there may be more than one IP hdr present in the encapsulation chain when various flavors of IP tunneling support are added. By doing so it also allows multiple level, not just a single level (i.e., with only two IP hdrs like IP-in-IP) of encapsulation to be supported in the future.With this patch, the GRO stack traversing now is mostly based on
skb_gro_offsetrather than special hdr offsets saved in skb (e.g.,skb->network_header,skb->transport_header,...) As a consequence all but the top layer (which is likely to be the transport layer) must have hdrs of the same length in order for a pkt to be considered for aggregation. Therefore when adding a new layer (e.g., for tunneling), one must check and skip flows (e.g., setting NAPI_GRO_CB(p)->same_flow to 0) that have a different hdr length.Signed-off-by H.K. Jerry Chu <[email protected]>Suggested-by Eric Dumazet <[email protected]>Reviewed-by Eric Dumazet <[email protected]>
[...]
Quoted 2 lines
net/ipv4/tcp_offload.c +0
-0
[...]
net/ipv4/tcp_offload.c skip_csum: · line 311
Quoted 6 lines
net/ipv4/tcp_offload.c +1
-1@@ -303,16 +308,16 @@ skip_csum:return tcp_gro_receive (head, skb); } -static int tcp4_gro_complete (struct sk_buff *skb) +static int tcp4_gro_complete (struct sk_buff *skb,int nhoff)
The offset should definitely be called thoff in this function.
[...]
Quoted 2 lines
net/ipv6/ip6_offload.c +0
-0
[...]
Quoted 4 lines
net/ipv6/ip6_offload.c +0
-0@@ -198,25 +228,28 @@ static struct sk_buff **ipv6_gro_receive(struct sk_buff **head, iph =ipv6_hdr (skb); }
net/ipv6/ip6_offload.c static struct sk_buff **ipv6_gro_receive(struct sk_buff **head, · line 237
Quoted 10 lines
net/ipv6/ip6_offload.c +2
-3-NAPI_GRO_CB (skb)->proto = proto; flush--; - nlen =skb_network_header_len (skb); + nlen = next_header - skb->network_header;for (p = *head; p; p = p->next) { -const struct ipv6hdr *iph2; +struct ipv6hdr *iph2;
Why remove const here?
[...]
Quoted 6 lines
net/ipv6/ip6_offload.c +2
-2-static int ipv6_gro_complete (struct sk_buff *skb) +static int ipv6_gro_complete (struct sk_buff *skb,int nhoff) {const struct net_offload *ops; -struct ipv6hdr *iph =ipv6_hdr (skb); +struct ipv6hdr *iph = (struct ipv6hdr *)(skb->data + nhoff);
net/ipv6/ip6_offload.c out: · line 291
Quoted 10 lines
net/ipv6/ip6_offload.c +3
-3int err = -ENOSYS ; - iph->payload_len =htons (skb->len -skb_network_offset (skb) - -sizeof (*iph)); + iph->payload_len =htons (skb->len - nhoff -sizeof (*iph));rcu_read_lock (); - ops =rcu_dereference (inet6_offloads[NAPI_GRO_CB (skb)->proto]); + + nhoff +=sizeof (*iph) +ipv6_exthdrs_len (iph, &ops);
Would be clearer as:
int thoff; ... thoff = nhoff + ...
Quoted 13 lines
net/ipv6/ip6_offload.c +1
-1if (WARN_ON (!ops || !ops->callbacks.gro_complete)) goto out_unlock; - err = ops->callbacks.gro_complete (skb); + err = ops->callbacks.gro_complete (skb, nhoff); out_unlock:rcu_read_unlock ();net/ipv6/tcpv6_offload.c +0
-0
net/ipv6/tcpv6_offload.c skip_csum: · line 69
Quoted 5 lines
net/ipv6/tcpv6_offload.c +1
-1@@ -66,16 +66,16 @@ skip_csum:return tcp_gro_receive (head, skb); } -static int tcp6_gro_complete (struct sk_buff *skb) +static int tcp6_gro_complete (struct sk_buff *skb,int nhoff)
[...]
Same comment as for tcp4_gro_complete().
Ben.
Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
Quoted 28 lines · Ben Hutchings
Quoted 23 lines · H.K. Jerry Chu
From: Jerry Chu <[email protected]>
This patch modifies the GRO stack to remove the assumption that only one IP hdr is present in the encapsulation chain. It avoids the use of ip_hdr()/ipv6_hdr() macro in IP's *_gro_receive()/
*_gro_complete()functions because there may be more than one IP hdr present in the encapsulation chain when various flavors of IP tunneling support are added. By doing so it also allows multiple level, not just a single level (i.e., with only two IP hdrs like IP-in-IP) of encapsulation to be supported in the future.With this patch, the GRO stack traversing now is mostly based on
skb_gro_offsetrather than special hdr offsets saved in skb (e.g.,skb->network_header,skb->transport_header,...) As a consequence all but the top layer (which is likely to be the transport layer) must have hdrs of the same length in order for a pkt to be considered for aggregation. Therefore when adding a new layer (e.g., for tunneling), one must check and skip flows (e.g., setting NAPI_GRO_CB(p)->same_flow to 0) that have a different hdr length.Signed-off-by H.K. Jerry Chu <[email protected]>Suggested-by Eric Dumazet <[email protected]>Reviewed-by Eric Dumazet <[email protected]>[...]
Quoted 2 lines
net/ipv4/tcp_offload.c +0
-0[...]
Quoted 8 lines
net/ipv4/tcp_offload.c skip_csum: · line 311
Quoted 6 lines
net/ipv4/tcp_offload.c +1
-1@@ -303,16 +308,16 @@ skip_csum:return tcp_gro_receive (head, skb); } -static int tcp4_gro_complete (struct sk_buff *skb) +static int tcp4_gro_complete (struct sk_buff *skb,int nhoff)The offset should definitely be called thoff in this function.
Ok.
Quoted 16 lines
[...]
Quoted 2 lines
net/ipv6/ip6_offload.c +0
-0[...]
Quoted 11 lines
net/ipv6/ip6_offload.c +1
-2@@ -198,25 +228,28 @@ static struct sk_buff **ipv6_gro_receive(struct sk_buff **head, iph =ipv6_hdr (skb); } -NAPI_GRO_CB (skb)->proto = proto; flush--; - nlen =skb_network_header_len (skb); + nlen = next_header - skb->network_header;
Quoted 5 lines
net/ipv6/ip6_offload.c static struct sk_buff **ipv6_gro_receive(struct sk_buff **head, · line 237
Quoted 3 lines
net/ipv6/ip6_offload.c +1
-1for (p = *head; p; p = p->next) { -const struct ipv6hdr *iph2; +struct ipv6hdr *iph2;Why remove const here?
Done to make the compiler happy but now the call to ipv6_exthdrs_len() may not be necessary so i'll put the const back.
Quoted 20 lines
[...]
Quoted 6 lines
net/ipv6/ip6_offload.c +2
-2-static int ipv6_gro_complete (struct sk_buff *skb) +static int ipv6_gro_complete (struct sk_buff *skb,int nhoff) {const struct net_offload *ops; -struct ipv6hdr *iph =ipv6_hdr (skb); +struct ipv6hdr *iph = (struct ipv6hdr *)(skb->data + nhoff);net/ipv6/ip6_offload.c out: · line 291
Quoted 10 lines
net/ipv6/ip6_offload.c +3
-3int err = -ENOSYS ; - iph->payload_len =htons (skb->len -skb_network_offset (skb) - -sizeof (*iph)); + iph->payload_len =htons (skb->len - nhoff -sizeof (*iph));rcu_read_lock (); - ops =rcu_dereference (inet6_offloads[NAPI_GRO_CB (skb)->proto]); + + nhoff +=sizeof (*iph) +ipv6_exthdrs_len (iph, &ops);Would be clearer as:
Quoted 3 lines
int thoff;
...
thoff = nhoff + ...Perhaps...
Quoted 17 lines
Quoted 17 lines
if (WARN_ON(!ops || !ops->callbacks.gro_complete)) goto out_unlock;net/ipv6/ip6_offload.c +1
-1- err = ops->callbacks.gro_complete (skb); + err = ops->callbacks.gro_complete (skb, nhoff); out_unlock:rcu_read_unlock ();net/ipv6/tcpv6_offload.c +0
-0@@ -66,16 +66,16 @@ skip_csum:return tcp_gro_receive (head, skb); }
Quoted 5 lines
net/ipv6/tcpv6_offload.c skip_csum: · line 69
Quoted 2 lines
net/ipv6/tcpv6_offload.c +1
-1-static int tcp6_gro_complete (struct sk_buff *skb) +static int tcp6_gro_complete (struct sk_buff *skb,int nhoff)[...]
Same comment as for
tcp4_gro_complete().
Ok.
Jerry
Quoted 8 lines
Ben.
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.