Message ID | 20190920044905.31759-6-steffen.klassert@secunet.com |
---|---|
State | RFC |
Delegated to: | David Miller |
Headers | show |
Series | Support fraglist GRO/GSO | expand |
On Fri, Sep 20, 2019 at 12:49 AM Steffen Klassert <steffen.klassert@secunet.com> wrote: > > This patch extends UDP GRO to support fraglist GRO/GSO > by using the previously introduced infrastructure. > All UDP packets that are not targeted to a GRO capable > UDP sockets are going to fraglist GRO now (local input > and forward). > > Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com> > @@ -538,6 +579,15 @@ INDIRECT_CALLABLE_SCOPE int udp4_gro_complete(struct sk_buff *skb, int nhoff) > const struct iphdr *iph = ip_hdr(skb); > struct udphdr *uh = (struct udphdr *)(skb->data + nhoff); > > + if (NAPI_GRO_CB(skb)->is_flist) { > + uh->len = htons(skb->len - nhoff); > + > + skb_shinfo(skb)->gso_type |= (SKB_GSO_FRAGLIST|SKB_GSO_UDP_L4); > + skb_shinfo(skb)->gso_segs = NAPI_GRO_CB(skb)->count; > + > + return 0; > + } > + > if (uh->check) > uh->check = ~udp_v4_check(skb->len - nhoff, iph->saddr, > iph->daddr, 0); > diff --git a/net/ipv6/udp_offload.c b/net/ipv6/udp_offload.c > index 435cfbadb6bd..8836f2b69ef3 100644 > --- a/net/ipv6/udp_offload.c > +++ b/net/ipv6/udp_offload.c > @@ -150,6 +150,15 @@ INDIRECT_CALLABLE_SCOPE int udp6_gro_complete(struct sk_buff *skb, int nhoff) > const struct ipv6hdr *ipv6h = ipv6_hdr(skb); > struct udphdr *uh = (struct udphdr *)(skb->data + nhoff); > > + if (NAPI_GRO_CB(skb)->is_flist) { > + uh->len = htons(skb->len - nhoff); > + > + skb_shinfo(skb)->gso_type |= (SKB_GSO_FRAGLIST|SKB_GSO_UDP_L4); > + skb_shinfo(skb)->gso_segs = NAPI_GRO_CB(skb)->count; > + > + return 0; > + } > + This is the same logic as in udp4_gro_complete. Can it be deduplicated in udp_gro_complete? > if (uh->check) > uh->check = ~udp_v6_check(skb->len - nhoff, &ipv6h->saddr, > &ipv6h->daddr, 0);
On Mon, Sep 23, 2019 at 09:01:13AM -0400, Willem de Bruijn wrote: > On Fri, Sep 20, 2019 at 12:49 AM Steffen Klassert > <steffen.klassert@secunet.com> wrote: > > > > This patch extends UDP GRO to support fraglist GRO/GSO > > by using the previously introduced infrastructure. > > All UDP packets that are not targeted to a GRO capable > > UDP sockets are going to fraglist GRO now (local input > > and forward). > > > > Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com> > > > @@ -538,6 +579,15 @@ INDIRECT_CALLABLE_SCOPE int udp4_gro_complete(struct sk_buff *skb, int nhoff) > > const struct iphdr *iph = ip_hdr(skb); > > struct udphdr *uh = (struct udphdr *)(skb->data + nhoff); > > > > + if (NAPI_GRO_CB(skb)->is_flist) { > > + uh->len = htons(skb->len - nhoff); > > + > > + skb_shinfo(skb)->gso_type |= (SKB_GSO_FRAGLIST|SKB_GSO_UDP_L4); > > + skb_shinfo(skb)->gso_segs = NAPI_GRO_CB(skb)->count; > > + > > + return 0; > > + } > > + > > if (uh->check) > > uh->check = ~udp_v4_check(skb->len - nhoff, iph->saddr, > > iph->daddr, 0); > > diff --git a/net/ipv6/udp_offload.c b/net/ipv6/udp_offload.c > > index 435cfbadb6bd..8836f2b69ef3 100644 > > --- a/net/ipv6/udp_offload.c > > +++ b/net/ipv6/udp_offload.c > > @@ -150,6 +150,15 @@ INDIRECT_CALLABLE_SCOPE int udp6_gro_complete(struct sk_buff *skb, int nhoff) > > const struct ipv6hdr *ipv6h = ipv6_hdr(skb); > > struct udphdr *uh = (struct udphdr *)(skb->data + nhoff); > > > > + if (NAPI_GRO_CB(skb)->is_flist) { > > + uh->len = htons(skb->len - nhoff); > > + > > + skb_shinfo(skb)->gso_type |= (SKB_GSO_FRAGLIST|SKB_GSO_UDP_L4); > > + skb_shinfo(skb)->gso_segs = NAPI_GRO_CB(skb)->count; > > + > > + return 0; > > + } > > + > > This is the same logic as in udp4_gro_complete. Can it be deduplicated > in udp_gro_complete? The code below would mess up the checksum then. We did not change the packets, so the checksum is still correct. > > > if (uh->check) > > uh->check = ~udp_v6_check(skb->len - nhoff, &ipv6h->saddr, > > &ipv6h->daddr, 0);
On Mon, Sep 30, 2019 at 2:30 AM Steffen Klassert <steffen.klassert@secunet.com> wrote: > > On Mon, Sep 23, 2019 at 09:01:13AM -0400, Willem de Bruijn wrote: > > On Fri, Sep 20, 2019 at 12:49 AM Steffen Klassert > > <steffen.klassert@secunet.com> wrote: > > > > > > This patch extends UDP GRO to support fraglist GRO/GSO > > > by using the previously introduced infrastructure. > > > All UDP packets that are not targeted to a GRO capable > > > UDP sockets are going to fraglist GRO now (local input > > > and forward). > > > > > > Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com> > > > > > @@ -538,6 +579,15 @@ INDIRECT_CALLABLE_SCOPE int udp4_gro_complete(struct sk_buff *skb, int nhoff) > > > const struct iphdr *iph = ip_hdr(skb); > > > struct udphdr *uh = (struct udphdr *)(skb->data + nhoff); > > > > > > + if (NAPI_GRO_CB(skb)->is_flist) { > > > + uh->len = htons(skb->len - nhoff); > > > + > > > + skb_shinfo(skb)->gso_type |= (SKB_GSO_FRAGLIST|SKB_GSO_UDP_L4); > > > + skb_shinfo(skb)->gso_segs = NAPI_GRO_CB(skb)->count; > > > + > > > + return 0; > > > + } > > > + > > > if (uh->check) > > > uh->check = ~udp_v4_check(skb->len - nhoff, iph->saddr, > > > iph->daddr, 0); > > > diff --git a/net/ipv6/udp_offload.c b/net/ipv6/udp_offload.c > > > index 435cfbadb6bd..8836f2b69ef3 100644 > > > --- a/net/ipv6/udp_offload.c > > > +++ b/net/ipv6/udp_offload.c > > > @@ -150,6 +150,15 @@ INDIRECT_CALLABLE_SCOPE int udp6_gro_complete(struct sk_buff *skb, int nhoff) > > > const struct ipv6hdr *ipv6h = ipv6_hdr(skb); > > > struct udphdr *uh = (struct udphdr *)(skb->data + nhoff); > > > > > > + if (NAPI_GRO_CB(skb)->is_flist) { > > > + uh->len = htons(skb->len - nhoff); > > > + > > > + skb_shinfo(skb)->gso_type |= (SKB_GSO_FRAGLIST|SKB_GSO_UDP_L4); > > > + skb_shinfo(skb)->gso_segs = NAPI_GRO_CB(skb)->count; > > > + > > > + return 0; > > > + } > > > + > > > > This is the same logic as in udp4_gro_complete. Can it be deduplicated > > in udp_gro_complete? > > The code below would mess up the checksum then. We did not change > the packets, so the checksum is still correct. Uh, right, of course. I guess it's not enough code to create a separate udp_gro_fraglist_complete helper for. Okay, never mind. > > > > > if (uh->check) > > > uh->check = ~udp_v6_check(skb->len - nhoff, &ipv6h->saddr, > > > &ipv6h->daddr, 0);
diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c index 929b12fc7bc5..37daafb06d4c 100644 --- a/net/ipv4/udp_offload.c +++ b/net/ipv4/udp_offload.c @@ -184,6 +184,20 @@ struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb, } EXPORT_SYMBOL(skb_udp_tunnel_segment); +static struct sk_buff *__udp_gso_segment_list(struct sk_buff *skb, + netdev_features_t features) +{ + unsigned int mss = skb_shinfo(skb)->gso_size; + + skb = skb_segment_list(skb, features, skb_mac_header_len(skb)); + if (IS_ERR(skb)) + return skb; + + udp_hdr(skb)->len = htons(sizeof(struct udphdr) + mss); + + return skb; +} + struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb, netdev_features_t features) { @@ -196,6 +210,9 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb, __sum16 check; __be16 newlen; + if (skb_shinfo(gso_skb)->gso_type & SKB_GSO_FRAGLIST) + return __udp_gso_segment_list(gso_skb, features); + mss = skb_shinfo(gso_skb)->gso_size; if (gso_skb->len <= sizeof(*uh) + mss) return ERR_PTR(-EINVAL); @@ -354,6 +371,7 @@ static struct sk_buff *udp_gro_receive_segment(struct list_head *head, struct udphdr *uh2; struct sk_buff *p; unsigned int ulen; + int ret = 0; /* requires non zero csum, for symmetry with GSO */ if (!uh->check) { @@ -369,7 +387,6 @@ static struct sk_buff *udp_gro_receive_segment(struct list_head *head, } /* pull encapsulating udp header */ skb_gro_pull(skb, sizeof(struct udphdr)); - skb_gro_postpull_rcsum(skb, uh, sizeof(struct udphdr)); list_for_each_entry(p, head, list) { if (!NAPI_GRO_CB(p)->same_flow) @@ -383,14 +400,35 @@ static struct sk_buff *udp_gro_receive_segment(struct list_head *head, continue; } + if (NAPI_GRO_CB(skb)->is_flist != NAPI_GRO_CB(p)->is_flist) { + NAPI_GRO_CB(skb)->flush = 1; + return p; + } + /* Terminate the flow on len mismatch or if it grow "too much". * Under small packet flood GRO count could elsewhere grow a lot * leading to excessive truesize values. * On len mismatch merge the first packet shorter than gso_size, * otherwise complete the GRO packet. */ - if (ulen > ntohs(uh2->len) || skb_gro_receive(p, skb) || - ulen != ntohs(uh2->len) || + if (ulen > ntohs(uh2->len)) { + pp = p; + } else { + if (NAPI_GRO_CB(skb)->is_flist) { + if (!pskb_may_pull(skb, skb_gro_offset(skb))) { + NAPI_GRO_CB(skb)->flush = 1; + return NULL; + } + ret = skb_gro_receive_list(p, skb); + } else { + skb_gro_postpull_rcsum(skb, uh, + sizeof(struct udphdr)); + + ret = skb_gro_receive(p, skb); + } + } + + if (ret || ulen != ntohs(uh2->len) || NAPI_GRO_CB(p)->count >= UDP_GRO_CNT_MAX) pp = p; @@ -411,6 +449,9 @@ struct sk_buff *udp_gro_receive(struct list_head *head, struct sk_buff *skb, int flush = 1; if (!sk || !udp_sk(sk)->gro_receive) { + if (skb->dev->features & NETIF_F_GRO_LIST) + NAPI_GRO_CB(skb)->is_flist = sk ? !udp_sk(sk)->gro_enabled: 1; + pp = call_gro_receive(udp_gro_receive_segment, head, skb); return pp; } @@ -538,6 +579,15 @@ INDIRECT_CALLABLE_SCOPE int udp4_gro_complete(struct sk_buff *skb, int nhoff) const struct iphdr *iph = ip_hdr(skb); struct udphdr *uh = (struct udphdr *)(skb->data + nhoff); + if (NAPI_GRO_CB(skb)->is_flist) { + uh->len = htons(skb->len - nhoff); + + skb_shinfo(skb)->gso_type |= (SKB_GSO_FRAGLIST|SKB_GSO_UDP_L4); + skb_shinfo(skb)->gso_segs = NAPI_GRO_CB(skb)->count; + + return 0; + } + if (uh->check) uh->check = ~udp_v4_check(skb->len - nhoff, iph->saddr, iph->daddr, 0); diff --git a/net/ipv6/udp_offload.c b/net/ipv6/udp_offload.c index 435cfbadb6bd..8836f2b69ef3 100644 --- a/net/ipv6/udp_offload.c +++ b/net/ipv6/udp_offload.c @@ -150,6 +150,15 @@ INDIRECT_CALLABLE_SCOPE int udp6_gro_complete(struct sk_buff *skb, int nhoff) const struct ipv6hdr *ipv6h = ipv6_hdr(skb); struct udphdr *uh = (struct udphdr *)(skb->data + nhoff); + if (NAPI_GRO_CB(skb)->is_flist) { + uh->len = htons(skb->len - nhoff); + + skb_shinfo(skb)->gso_type |= (SKB_GSO_FRAGLIST|SKB_GSO_UDP_L4); + skb_shinfo(skb)->gso_segs = NAPI_GRO_CB(skb)->count; + + return 0; + } + if (uh->check) uh->check = ~udp_v6_check(skb->len - nhoff, &ipv6h->saddr, &ipv6h->daddr, 0);
This patch extends UDP GRO to support fraglist GRO/GSO by using the previously introduced infrastructure. All UDP packets that are not targeted to a GRO capable UDP sockets are going to fraglist GRO now (local input and forward). Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com> --- net/ipv4/udp_offload.c | 56 +++++++++++++++++++++++++++++++++++++++--- net/ipv6/udp_offload.c | 9 +++++++ 2 files changed, 62 insertions(+), 3 deletions(-)