xen-netfront: Add support for IPv6 offloads
Subsystems (2)
PATCH 1/1 xen-netfront: Add support for IPv6 offloads
This patch adds support for IPv6 checksum offload and GSO when those fetaures are available in the backend.
--- drivers/net/xen-netfront.c | 263 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 231 insertions(+), 32 deletions(-)
drivers/net/xen-netfront.c +231 -32
@@ -616,7 +616,9 @@ static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev) tx->flags |= XEN_NETTXF_extra_info; gso->u.gso.size =skb_shinfo (skb)->gso_size; - gso->u.gso.type =XEN_NETIF_GSO_TYPE_TCPV4 ; + gso->u.gso.type = (skb_shinfo (skb)->gso_type &SKB_GSO_TCPV6 ) ? +XEN_NETIF_GSO_TYPE_TCPV6 : +XEN_NETIF_GSO_TYPE_TCPV4 ; gso->u.gso.pad =0 ; gso->u.gso.features =0 ;
@@ -808,15 +810,18 @@ static int xennet_set_skb_gso(struct sk_buff *skb,return -EINVAL ; } -/* Currently only TCPv4 S.O. is supported. */ -if (gso->u.gso.type !=XEN_NETIF_GSO_TYPE_TCPV4 ) { +if (gso->u.gso.type !=XEN_NETIF_GSO_TYPE_TCPV4 && + gso->u.gso.type !=XEN_NETIF_GSO_TYPE_TCPV6 ) {if (net_ratelimit ())pr_warn ("Bad GSO type %d\n" , gso->u.gso.type);return -EINVAL ; }skb_shinfo (skb)->gso_size = gso->u.gso.size; -skb_shinfo (skb)->gso_type =SKB_GSO_TCPV4 ; +skb_shinfo (skb)->gso_type = + (gso->u.gso.type ==XEN_NETIF_GSO_TYPE_TCPV4 ) ? +SKB_GSO_TCPV4 : +SKB_GSO_TCPV6 ;/* Header must be checked, and gso_segs computed. */ skb_shinfo (skb)->gso_type |=SKB_GSO_DODGY ;
@@ -856,62 +861,72 @@ static RING_IDX xennet_fill_frags(struct netfront_info *np,return cons; } -static int checksum_setup (struct net_device *dev,struct sk_buff *skb) +static inline void maybe_pull_tail (struct sk_buff *skb,unsigned int len) { -struct iphdr *iph; -int err = -EPROTO ; -int recalculate_partial_csum =0 ; - -/* -* A GSO SKB must be CHECKSUM_PARTIAL. However some buggy -* peers can fail to set NETRXF_csum_blank when sending a GSO -* frame. In this case force the SKB to CHECKSUM_PARTIAL and -* recalculate the partial checksum. -*/ -if (skb->ip_summed !=CHECKSUM_PARTIAL &&skb_is_gso (skb)) { -struct netfront_info *np =netdev_priv (dev); - np->rx_gso_checksum_fixup++; - skb->ip_summed =CHECKSUM_PARTIAL ; - recalculate_partial_csum =1 ; +if (skb_is_nonlinear (skb) &&skb_headlen (skb) < len) { +/* If we need to pullup then pullup to the max, so we +* won't need to do it again. +*/ +int target =min_t (int, skb->len,MAX_TCP_HEADER ); +__pskb_pull_tail (skb, target -skb_headlen (skb)); } +} -/* A non-CHECKSUM_PARTIAL SKB does not require setup. */ -if (skb->ip_summed !=CHECKSUM_PARTIAL ) -return 0 ; +static int checksum_setup_ip (struct sk_buff *skb,int recalculate_partial_csum) +{ +struct iphdr *iph = (void *)skb->data; +unsigned int header_size; +unsigned int off; +int err = -EPROTO ; -if (skb->protocol !=htons (ETH_P_IP )) - goto out; + off =sizeof (struct iphdr ); - iph = (void *)skb->data; + header_size = skb->network_header + off +MAX_IPOPTLEN ; +maybe_pull_tail (skb, header_size); + + off = iph->ihl *4 ;switch (iph->protocol) {case IPPROTO_TCP : -if (!skb_partial_csum_set (skb,4 * iph->ihl, +if (!skb_partial_csum_set (skb, off, offsetof(struct tcphdr , check))) goto out;if (recalculate_partial_csum) {struct tcphdr *tcph =tcp_hdr (skb); + + header_size = skb->network_header + + off + +sizeof (struct tcphdr ); +maybe_pull_tail (skb, header_size); + tcph->check = ~csum_tcpudp_magic (iph->saddr, iph->daddr, - skb->len - iph->ihl*4 , + skb->len - off,IPPROTO_TCP ,0 ); }break ;case IPPROTO_UDP : -if (!skb_partial_csum_set (skb,4 * iph->ihl, +if (!skb_partial_csum_set (skb, off, offsetof(struct udphdr , check))) goto out;if (recalculate_partial_csum) {struct udphdr *udph =udp_hdr (skb); + + header_size = skb->network_header + + off + +sizeof (struct udphdr ); +maybe_pull_tail (skb, header_size); + udph->check = ~csum_tcpudp_magic (iph->saddr, iph->daddr, - skb->len - iph->ihl*4 , + skb->len - off,IPPROTO_UDP ,0 ); }break ;default :if (net_ratelimit ()) -pr_err ("Attempting to checksum a non-TCP/UDP packet, dropping a protocol %d packet\n" , +pr_err ("Attempting to checksum a non-TCP/UDP packet, " +"dropping a protocol %d packet\n" , iph->protocol); goto out; }
@@ -922,6 +937,158 @@ out:return err; } +static int checksum_setup_ipv6 (struct sk_buff *skb,int recalculate_partial_csum) +{ +int err = -EPROTO ; +struct ipv6hdr *ipv6h = (void *)skb->data; +u8 nexthdr; +unsigned int header_size; +unsigned int off; +bool fragment; +bool done; + + done = false; + + off =sizeof (struct ipv6hdr ); + + header_size = skb->network_header + off; +maybe_pull_tail (skb, header_size); + + nexthdr = ipv6h->nexthdr; + +while ((off <=sizeof (struct ipv6hdr ) +ntohs (ipv6h->payload_len)) && + !done) { +switch (nexthdr) { +case IPPROTO_DSTOPTS : +case IPPROTO_HOPOPTS : +case IPPROTO_ROUTING : { +struct ipv6_opt_hdr *hp = (void *)(skb->data + off); + + header_size = skb->network_header + + off + +sizeof (struct ipv6_opt_hdr ); +maybe_pull_tail (skb, header_size); + + nexthdr = hp->nexthdr; + off +=ipv6_optlen (hp); +break ; + } +case IPPROTO_AH : { +struct ip_auth_hdr *hp = (void *)(skb->data + off); + + header_size = skb->network_header + + off + +sizeof (struct ip_auth_hdr ); +maybe_pull_tail (skb, header_size); + + nexthdr = hp->nexthdr; + off += (hp->hdrlen+2 )<<2 ; +break ; + } +case IPPROTO_FRAGMENT : + fragment = true; +/* fall through */ +default : + done = true; +break ; + } + } + +if (!done) { +if (net_ratelimit ()) +pr_err ("Failed to parse packet header\n" ); + goto out; + } + +if (fragment) { +if (net_ratelimit ()) +pr_err ("Packet is a fragment!\n" ); + goto out; + } + +switch (nexthdr) { +case IPPROTO_TCP : +if (!skb_partial_csum_set (skb, off, + offsetof(struct tcphdr , check))) + goto out; + +if (recalculate_partial_csum) { +struct tcphdr *tcph =tcp_hdr (skb); + + header_size = skb->network_header + + off + +sizeof (struct tcphdr ); +maybe_pull_tail (skb, header_size); + + tcph->check = ~csum_ipv6_magic (&ipv6h->saddr, + &ipv6h->daddr, + skb->len - off, +IPPROTO_TCP ,0 ); + } +break ; +case IPPROTO_UDP : +if (!skb_partial_csum_set (skb, off, + offsetof(struct udphdr , check))) + goto out; + +if (recalculate_partial_csum) { +struct udphdr *udph =udp_hdr (skb); + + header_size = skb->network_header + + off + +sizeof (struct udphdr ); +maybe_pull_tail (skb, header_size); + + udph->check = ~csum_ipv6_magic (&ipv6h->saddr, + &ipv6h->daddr, + skb->len - off, +IPPROTO_UDP ,0 ); + } +break ; +default : +if (net_ratelimit ()) +pr_err ("Attempting to checksum a non-TCP/UDP packet, " +"dropping a protocol %d packet\n" , + nexthdr); + goto out; + } + + err =0 ; + +out: +return err; +} + +static int checksum_setup (struct net_device *dev,struct sk_buff *skb) +{ +int err = -EPROTO ; +int recalculate_partial_csum =0 ; + +/* +* A GSO SKB must be CHECKSUM_PARTIAL. However some buggy +* peers can fail to set NETRXF_csum_blank when sending a GSO +* frame. In this case force the SKB to CHECKSUM_PARTIAL and +* recalculate the partial checksum. +*/ +if (skb->ip_summed !=CHECKSUM_PARTIAL &&skb_is_gso (skb)) { +struct netfront_info *np =netdev_priv (dev); + np->rx_gso_checksum_fixup++; + skb->ip_summed =CHECKSUM_PARTIAL ; + recalculate_partial_csum =1 ; + } + +/* A non-CHECKSUM_PARTIAL SKB does not require setup. */ +if (skb->ip_summed !=CHECKSUM_PARTIAL ) +return 0 ; + +if (skb->protocol ==htons (ETH_P_IP )) + err =checksum_setup_ip (skb, recalculate_partial_csum); +else if (skb->protocol ==htons (ETH_P_IPV6 )) + err =checksum_setup_ipv6 (skb, recalculate_partial_csum); + +return err; +} +static int handle_incoming_queue (struct net_device *dev,struct sk_buff_head *rxq) {
@@ -1232,6 +1399,15 @@ static netdev_features_t xennet_fix_features(struct net_device *dev, features &= ~NETIF_F_SG ; } +if (features &NETIF_F_IPV6_CSUM ) { +if (xenbus_scanf (XBT_NIL , np->xbdev->otherend, +"feature-ipv6-csum-offload" ,"%d" , &val) <0 ) + val =0 ; + +if (!val) + features &= ~NETIF_F_IPV6_CSUM ; + } +if (features &NETIF_F_TSO ) {if (xenbus_scanf (XBT_NIL , np->xbdev->otherend,"feature-gso-tcpv4" ,"%d" , &val) <0 )
@@ -1241,6 +1417,15 @@ static netdev_features_t xennet_fix_features(struct net_device *dev, features &= ~NETIF_F_TSO ; } +if (features &NETIF_F_TSO6 ) { +if (xenbus_scanf (XBT_NIL , np->xbdev->otherend, +"feature-gso-tcpv6" ,"%d" , &val) <0 ) + val =0 ; + +if (!val) + features &= ~NETIF_F_TSO6 ; + } +return features; }
@@ -1373,7 +1558,9 @@ static struct net_device *xennet_create_dev(struct xenbus_device *dev)netif_napi_add (netdev, &np->napi, xennet_poll,64 ); netdev->features =NETIF_F_IP_CSUM |NETIF_F_RXCSUM |NETIF_F_GSO_ROBUST ; - netdev->hw_features =NETIF_F_IP_CSUM |NETIF_F_SG |NETIF_F_TSO ; + netdev->hw_features =NETIF_F_SG | +NETIF_F_IPV6_CSUM | +NETIF_F_TSO |NETIF_F_TSO6 ;/* * Assume that all hw features are available for now. This set
@@ -1751,6 +1938,18 @@ again: goto abort_transaction; } + err =xenbus_printf (xbt, dev->nodename,"feature-gso-tcpv6" ,"%d" ,1 ); +if (err) { + message ="writing feature-gso-tcpv6" ; + goto abort_transaction; + } + + err =xenbus_printf (xbt, dev->nodename,"feature-ipv6-csum-offload" ,"%d" ,1 ); +if (err) { + message ="writing feature-gso-tcpv6" ; + goto abort_transaction; + } + err =xenbus_transaction_end (xbt,0 );if (err) {if (err == -EAGAIN )
Signature · 1 line
1.7.10.4
Quoted 66 lines · Paul Durrant
This patch adds support for IPv6 checksum offload and GSO when those fetaures are available in the backend.
Signed-off-by Paul Durrant <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>Cc Boris Ostrovsky <[email protected]>Cc David Vrabel <[email protected]>--- drivers/net/xen-netfront.c | 263 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 231 insertions(+), 32 deletions(-)drivers/net/xen-netfront.c +10
-16@@ -616,7 +616,9 @@ static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev) tx->flags |= XEN_NETTXF_extra_info; gso->u.gso.size =skb_shinfo (skb)->gso_size; - gso->u.gso.type =XEN_NETIF_GSO_TYPE_TCPV4 ; + gso->u.gso.type = (skb_shinfo (skb)->gso_type &SKB_GSO_TCPV6 ) ? +XEN_NETIF_GSO_TYPE_TCPV6 : +XEN_NETIF_GSO_TYPE_TCPV4 ; gso->u.gso.pad =0 ; gso->u.gso.features =0 ;@@ -808,15 +810,18 @@ static int xennet_set_skb_gso(struct sk_buff *skb,return -EINVAL ; } -/* Currently only TCPv4 S.O. is supported. */ -if (gso->u.gso.type !=XEN_NETIF_GSO_TYPE_TCPV4 ) { +if (gso->u.gso.type !=XEN_NETIF_GSO_TYPE_TCPV4 && + gso->u.gso.type !=XEN_NETIF_GSO_TYPE_TCPV6 ) {if (net_ratelimit ())pr_warn ("Bad GSO type %d\n" , gso->u.gso.type);return -EINVAL ; }skb_shinfo (skb)->gso_size = gso->u.gso.size; -skb_shinfo (skb)->gso_type =SKB_GSO_TCPV4 ; +skb_shinfo (skb)->gso_type = + (gso->u.gso.type ==XEN_NETIF_GSO_TYPE_TCPV4 ) ? +SKB_GSO_TCPV4 : +SKB_GSO_TCPV6 ;/* Header must be checked, and gso_segs computed. */ skb_shinfo (skb)->gso_type |=SKB_GSO_DODGY ;@@ -856,62 +861,72 @@ static RING_IDX xennet_fill_frags(struct netfront_info *np,return cons; } -static int checksum_setup (struct net_device *dev,struct sk_buff *skb) +static inline void maybe_pull_tail (struct sk_buff *skb,unsigned int len) { -struct iphdr *iph; -int err = -EPROTO ; -int recalculate_partial_csum =0 ; - -/* -* A GSO SKB must be CHECKSUM_PARTIAL. However some buggy -* peers can fail to set NETRXF_csum_blank when sending a GSO -* frame. In this case force the SKB to CHECKSUM_PARTIAL and -* recalculate the partial checksum. -*/ -if (skb->ip_summed !=CHECKSUM_PARTIAL &&skb_is_gso (skb)) {
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct netfront_info *np, · line 871
Quoted 10 lines
drivers/net/xen-netfront.c +6
-4-struct netfront_info *np =netdev_priv (dev); - np->rx_gso_checksum_fixup++; - skb->ip_summed =CHECKSUM_PARTIAL ; - recalculate_partial_csum =1 ; +if (skb_is_nonlinear (skb) &&skb_headlen (skb) < len) { +/* If we need to pullup then pullup to the max, so we +* won't need to do it again. +*/ +int target =min_t (int, skb->len,MAX_TCP_HEADER ); +__pskb_pull_tail (skb, target -skb_headlen (skb));
Should the functions "len" argument not be involved somewhere in this? What if it is bigger than MAX_TCP_HEADER for example?
Quoted 11 lines
drivers/net/xen-netfront.c +5
-3} +} -/* A non-CHECKSUM_PARTIAL SKB does not require setup. */ -if (skb->ip_summed !=CHECKSUM_PARTIAL ) -return 0 ; +static int checksum_setup_ip (struct sk_buff *skb,int recalculate_partial_csum) +{ +struct iphdr *iph = (void *)skb->data; +unsigned int header_size;
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct netfront_info *np, · line 901
Quoted 10 lines
drivers/net/xen-netfront.c +5
-3+unsigned int off; +int err = -EPROTO ; -if (skb->protocol !=htons (ETH_P_IP )) - goto out; + off =sizeof (struct iphdr ); - iph = (void *)skb->data; + header_size = skb->network_header + off +MAX_IPOPTLEN ; +maybe_pull_tail (skb, header_size);
You never reuse header_size other than setting it and immediately passing it to maybe_pull_tail, it could be inlined into the function call?
(I found it confusing because you reset it in the recalculate_partial rather than extending it which is what I expected)
maybe_pull_tail doesn't guarantee to pull up to the length of the given parameter, e.g. if it is more then skb->len. Which I think means you need some other explicit skb len checks around the place, don't you? Otherwise you risk running past the end of the skb for a malformed frame.
Quoted 39 lines
drivers/net/xen-netfront.c +17
-3+ + off = iph->ihl *4 ;switch (iph->protocol) {case IPPROTO_TCP : -if (!skb_partial_csum_set (skb,4 * iph->ihl, +if (!skb_partial_csum_set (skb, off, offsetof(struct tcphdr , check))) goto out;if (recalculate_partial_csum) {struct tcphdr *tcph =tcp_hdr (skb); + + header_size = skb->network_header + + off + +sizeof (struct tcphdr ); +maybe_pull_tail (skb, header_size); + tcph->check = ~csum_tcpudp_magic (iph->saddr, iph->daddr, - skb->len - iph->ihl*4 , + skb->len - off,IPPROTO_TCP ,0 ); }break ;case IPPROTO_UDP : -if (!skb_partial_csum_set (skb,4 * iph->ihl, +if (!skb_partial_csum_set (skb, off, offsetof(struct udphdr , check))) goto out;if (recalculate_partial_csum) {struct udphdr *udph =udp_hdr (skb); + + header_size = skb->network_header + + off + +sizeof (struct udphdr ); +maybe_pull_tail (skb, header_size); + udph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr,
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct netfront_info *np, · line 929
Quoted 10 lines
drivers/net/xen-netfront.c +3
-2- skb->len - iph->ihl*4 , + skb->len - off, IPPROTO_UDP, 0); }break ;default :if (net_ratelimit ()) - pr_err("Attempting to checksum a non-TCP/UDP packet, dropping a protocol %d packet\n", + pr_err("Attempting to checksum a non-TCP/UDP packet, " + "dropping a protocol %d packet\n",
I think Linux's coding style explicitly relaxes the 80-column limit for string literals.
Quoted 13 lines
drivers/net/xen-netfront.c +0
-0iph->protocol); goto out;drivers/net/xen-netfront.c +6
-0}@@ -922,6 +937,158 @@ out:return err; } +static int checksum_setup_ipv6 (struct sk_buff *skb,int recalculate_partial_csum) +{ +int err = -EPROTO ; +struct ipv6hdr *ipv6h = (void *)skb->data; +u8 nexthdr; +unsigned int header_size;
drivers/net/xen-netfront.c out: · line 955
Quoted 10 lines
drivers/net/xen-netfront.c +10
-0+unsigned int off; +bool fragment; +bool done; + + done = false; + + off =sizeof (struct ipv6hdr ); + + header_size = skb->network_header + off; +maybe_pull_tail (skb, header_size);
Same comment about skb lengths?
Quoted 20 lines
drivers/net/xen-netfront.c +20
-0+ + nexthdr = ipv6h->nexthdr; + +while ((off <=sizeof (struct ipv6hdr ) +ntohs (ipv6h->payload_len)) && + !done) { +switch (nexthdr) { +case IPPROTO_DSTOPTS : +case IPPROTO_HOPOPTS : +case IPPROTO_ROUTING : { +struct ipv6_opt_hdr *hp = (void *)(skb->data + off); + + header_size = skb->network_header + + off + +sizeof (struct ipv6_opt_hdr ); +maybe_pull_tail (skb, header_size); + + nexthdr = hp->nexthdr; + off +=ipv6_optlen (hp); +break ; + }
drivers/net/xen-netfront.c out: · line 985
Quoted 10 lines
drivers/net/xen-netfront.c +10
-0+case IPPROTO_AH : { +struct ip_auth_hdr *hp = (void *)(skb->data + off); + + header_size = skb->network_header + + off + +sizeof (struct ip_auth_hdr ); +maybe_pull_tail (skb, header_size); + + nexthdr = hp->nexthdr; + off += (hp->hdrlen+2 )<<2 ;
I wonder if the core header would welcome a ipv6_ahlen cf optlen?
Quoted 4 lines
drivers/net/xen-netfront.c +4
-0+break ; + } +case IPPROTO_FRAGMENT : + fragment = true;
drivers/net/xen-netfront.c out: · line 999
Quoted 10 lines
drivers/net/xen-netfront.c +10
-0+/* fall through */ +default : + done = true; +break ; + } + } + +if (!done) { +if (net_ratelimit ()) +pr_err ("Failed to parse packet header\n" );
Is it a requirement of the protocol that the list of IPPROTO_* we handle must be followed by some other header? Do we really care or is it more the upper stacks problem? Presumably it can get similarly malformed packets off the wire?
Also you can use net_err_ratelimited.
drivers/net/xen-netfront.c out: · line 1005
Quoted 6 lines
drivers/net/xen-netfront.c +6
-0+ goto out; + } + +if (fragment) { +if (net_ratelimit ()) +pr_err ("Packet is a fragment!\n" );
Is that a bad thing?
Quoted 58 lines
drivers/net/xen-netfront.c +58
-0+ goto out; + } + +switch (nexthdr) { +case IPPROTO_TCP : +if (!skb_partial_csum_set (skb, off, + offsetof(struct tcphdr , check))) + goto out; + +if (recalculate_partial_csum) { +struct tcphdr *tcph =tcp_hdr (skb); + + header_size = skb->network_header + + off + +sizeof (struct tcphdr ); +maybe_pull_tail (skb, header_size); + + tcph->check = ~csum_ipv6_magic (&ipv6h->saddr, + &ipv6h->daddr, + skb->len - off, +IPPROTO_TCP ,0 ); + } +break ; +case IPPROTO_UDP : +if (!skb_partial_csum_set (skb, off, + offsetof(struct udphdr , check))) + goto out; + +if (recalculate_partial_csum) { +struct udphdr *udph =udp_hdr (skb); + + header_size = skb->network_header + + off + +sizeof (struct udphdr ); +maybe_pull_tail (skb, header_size); + + udph->check = ~csum_ipv6_magic (&ipv6h->saddr, + &ipv6h->daddr, + skb->len - off, +IPPROTO_UDP ,0 ); + } +break ; +default : +if (net_ratelimit ()) +pr_err ("Attempting to checksum a non-TCP/UDP packet, " +"dropping a protocol %d packet\n" , + nexthdr); + goto out; + } + + err =0 ; + +out: +return err; +} + +static int checksum_setup (struct net_device *dev,struct sk_buff *skb) +{
drivers/net/xen-netfront.c out: · line 1073
Quoted 10 lines
drivers/net/xen-netfront.c +10
-0+int err = -EPROTO ; +int recalculate_partial_csum =0 ; + +/* +* A GSO SKB must be CHECKSUM_PARTIAL. However some buggy +* peers can fail to set NETRXF_csum_blank when sending a GSO +* frame. In this case force the SKB to CHECKSUM_PARTIAL and +* recalculate the partial checksum. +*/ +if (skb->ip_summed !=CHECKSUM_PARTIAL &&skb_is_gso (skb)) {
Is it worth making this ipv4 only. Assuming that anything which adds v6 support has already fixed this bug? That would save time in checksum_setup_ipv6.
Speaking of which can checksum_setup_* be shared with netfront somehow? Or maybe even put in common code? (Perhaps as a future cleanup)
Quoted 19 lines
drivers/net/xen-netfront.c +18
-0+struct netfront_info *np =netdev_priv (dev); + np->rx_gso_checksum_fixup++; + skb->ip_summed =CHECKSUM_PARTIAL ; + recalculate_partial_csum =1 ; + } + +/* A non-CHECKSUM_PARTIAL SKB does not require setup. */ +if (skb->ip_summed !=CHECKSUM_PARTIAL ) +return 0 ; + +if (skb->protocol ==htons (ETH_P_IP )) + err =checksum_setup_ip (skb, recalculate_partial_csum); +else if (skb->protocol ==htons (ETH_P_IPV6 )) + err =checksum_setup_ipv6 (skb, recalculate_partial_csum); + +return err; +} + static int handle_incoming_queue(struct net_device *dev,
[...]
Quoted 85 lines
-----Original Message-----
From: Ian Campbell
Sent: 07 November 2013 10:49
To: Paul Durrant
Cc: [email protected]; Boris Ostrovsky; David Vrabel
Subject: Re: [Xen-devel] [PATCH net-next] xen-netfront: Add support for IPv6 offloadsQuoted 9 lines · Paul Durrant
This patch adds support for IPv6 checksum offload and GSO when those fetaures are available in the backend.
Signed-off-by Paul Durrant <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>Cc Boris Ostrovsky <[email protected]>Cc David Vrabel <[email protected]>--- drivers/net/xen-netfront.c | 263++++++++++++++++++++++++++++++++++++++------
drivers/net/xen-netfront.c static int xennet_start_xmit(struct sk_buff *skb,
Quoted 7 lines
1 file changed, 231 insertions(+), 32 deletions(-)drivers/net/xen-netfront.c +0
-0@@ -616,7 +616,9 @@ static int xennet_start_xmit(struct sk_buff *skb,struct
net_device*dev)drivers/net/xen-netfront.c static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)
Quoted 5 lines
drivers/net/xen-netfront.c +1
-1tx->flags |= XEN_NETTXF_extra_info; gso->u.gso.size =skb_shinfo (skb)->gso_size; - gso->u.gso.type =XEN_NETIF_GSO_TYPE_TCPV4 ; + gso->u.gso.type = (skb_shinfo(skb)->gso_type &
SKB_GSO_TCPV6) ?drivers/net/xen-netfront.c static int xennet_set_skb_gso(struct sk_buff
Quoted 6 lines
drivers/net/xen-netfront.c +2
-0+ XEN_NETIF_GSO_TYPE_TCPV6 : +XEN_NETIF_GSO_TYPE_TCPV4 ; gso->u.gso.pad =0 ; gso->u.gso.features =0 ;@@ -808,15 +810,18 @@ static int xennet_set_skb_gso(struct sk_buff*skb,
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct
Quoted 22 lines
drivers/net/xen-netfront.c +6
-3return -EINVAL ; } -/* Currently only TCPv4 S.O. is supported. */ -if (gso->u.gso.type !=XEN_NETIF_GSO_TYPE_TCPV4 ) { +if (gso->u.gso.type !=XEN_NETIF_GSO_TYPE_TCPV4 && + gso->u.gso.type !=XEN_NETIF_GSO_TYPE_TCPV6 ) {if (net_ratelimit ())pr_warn ("Bad GSO type %d\n" , gso->u.gso.type);return -EINVAL ; }skb_shinfo (skb)->gso_size = gso->u.gso.size; -skb_shinfo (skb)->gso_type =SKB_GSO_TCPV4 ; +skb_shinfo (skb)->gso_type = + (gso->u.gso.type ==XEN_NETIF_GSO_TYPE_TCPV4 ) ? +SKB_GSO_TCPV4 : +SKB_GSO_TCPV6 ;/* Header must be checked, and gso_segs computed. */ skb_shinfo (skb)->gso_type |=SKB_GSO_DODGY ;@@ -856,62 +861,72 @@ static RING_IDX xennet_fill_frags(struct
netfront_info*np,Quoted 22 lines
drivers/net/xen-netfront.c +2
-16return cons; } -static int checksum_setup (struct net_device *dev,struct sk_buff *skb) +static inline void maybe_pull_tail (struct sk_buff *skb,unsigned int len) { -struct iphdr *iph; -int err = -EPROTO ; -int recalculate_partial_csum =0 ; - -/* -* A GSO SKB must be CHECKSUM_PARTIAL. However some buggy -* peers can fail to set NETRXF_csum_blank when sending a GSO -* frame. In this case force the SKB to CHECKSUM_PARTIAL and -* recalculate the partial checksum. -*/ -if (skb->ip_summed !=CHECKSUM_PARTIAL &&skb_is_gso (skb)) { -struct netfront_info *np =netdev_priv (dev); - np->rx_gso_checksum_fixup++; - skb->ip_summed =CHECKSUM_PARTIAL ; - recalculate_partial_csum =1 ; +if (skb_is_nonlinear (skb) &&skb_headlen (skb) < len) {
Quoted 8 lines
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct netfront_info *np, · line 871
Quoted 5 lines
drivers/net/xen-netfront.c +5
-0+/* If we need to pullup then pullup to the max, so we +* won't need to do it again. +*/ +int target =min_t (int, skb->len,MAX_TCP_HEADER ); +__pskb_pull_tail (skb, target -skb_headlen (skb));Should the functions "len" argument not be involved somewhere in this? What if it is bigger than
MAX_TCP_HEADERfor example?
Hmm, good point.
Quoted 20 lines
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct netfront_info *np,
Quoted 8 lines
drivers/net/xen-netfront.c +2
-3} +} -/* A non-CHECKSUM_PARTIAL SKB does not require setup. */ -if (skb->ip_summed !=CHECKSUM_PARTIAL ) -return 0 ; +static int checksum_setup_ip(struct sk_buff *skb, int
recalculate_partial_csum)Quoted 11 lines
drivers/net/xen-netfront.c +6
-2+{ +struct iphdr *iph = (void *)skb->data; +unsigned int header_size; +unsigned int off; +int err = -EPROTO ; -if (skb->protocol !=htons (ETH_P_IP )) - goto out; + off =sizeof (struct iphdr );
Quoted 8 lines
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct netfront_info *np, · line 885
Quoted 3 lines
drivers/net/xen-netfront.c +2
-1- iph = (void *)skb->data; + header_size = skb->network_header + off +MAX_IPOPTLEN ; +maybe_pull_tail (skb, header_size);You never reuse
header_sizeother than setting it and immediately passing it tomaybe_pull_tail, it could be inlined into the function call?
Yes, it could but I thought this was tidier. It's also the same as the code in netback.
Quoted 9 lines
(I found it confusing because you reset it in the
recalculate_partialrather than extending it which is what I expected)
maybe_pull_taildoesn't guarantee to pull up to the length of the given parameter, e.g. if it is more thenskb->len. Which I think means you need some other explicit skb len checks around the place, don't you? Otherwise you risk running past the end of the skb for a malformed frame.
Yes, that's true. Probably best to have maybe_pull_tail() return a failure if it doesn't managed to pullup the requested amount then.
Quoted 50 lines
Quoted 30 lines
drivers/net/xen-netfront.c +11
-3+ + off = iph->ihl *4 ;switch (iph->protocol) {case IPPROTO_TCP : -if (!skb_partial_csum_set (skb,4 * iph->ihl, +if (!skb_partial_csum_set (skb, off, offsetof(struct tcphdr , check))) goto out;if (recalculate_partial_csum) {struct tcphdr *tcph =tcp_hdr (skb); + + header_size = skb->network_header + + off + +sizeof (struct tcphdr ); +maybe_pull_tail (skb, header_size); + tcph->check = ~csum_tcpudp_magic (iph->saddr, iph- daddr, - skb->len - iph->ihl*4 , + skb->len - off,IPPROTO_TCP ,0 ); }break ;case IPPROTO_UDP : -if (!skb_partial_csum_set (skb,4 * iph->ihl, +if (!skb_partial_csum_set (skb, off, offsetof(struct udphdr , check))) goto out;drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct netfront_info *np,
Quoted 10 lines
drivers/net/xen-netfront.c +6
-0if (recalculate_partial_csum) {struct udphdr *udph =udp_hdr (skb); + + header_size = skb->network_header + + off + +sizeof (struct udphdr ); +maybe_pull_tail (skb, header_size); + udph->check = ~csum_tcpudp_magic(iph->saddr,
iph->daddr,drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct netfront_info *np,
Quoted 8 lines
drivers/net/xen-netfront.c +1
-2- skb->len - iph->ihl*4 , + skb->len - off, IPPROTO_UDP, 0); }break ;default :if (net_ratelimit ()) - pr_err("Attempting to checksum a non-TCP/UDPpacket, dropping a protocol %d packet\n",
Quoted 7 lines
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct · line 930
Quoted 1 line
drivers/net/xen-netfront.c +1
-0+ pr_err("Attempting to checksum a non-TCP/UDPpacket, "
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct · line 931
Quoted 1 line
drivers/net/xen-netfront.c +1
-0+ "dropping a protocol %d packet\n",I think Linux's coding style explicitly relaxes the 80-column limit for string literals.
Ok. Good to know.
Quoted 52 lines
drivers/net/xen-netfront.c out: · line 940
Quoted 8 lines
drivers/net/xen-netfront.c +0
-0iph->protocol);drivers/net/xen-netfront.c +1
-0goto out; }@@ -922,6 +937,158 @@ out:return err; } +static int checksum_setup_ipv6(struct sk_buff *skb, int
recalculate_partial_csum)Quoted 5 lines
drivers/net/xen-netfront.c +5
-0+{ +int err = -EPROTO ; +struct ipv6hdr *ipv6h = (void *)skb->data; +u8 nexthdr; +unsigned int header_size;drivers/net/xen-netfront.c out: · line 955
Quoted 10 lines
drivers/net/xen-netfront.c +10
-0+unsigned int off; +bool fragment; +bool done; + + done = false; + + off =sizeof (struct ipv6hdr ); + + header_size = skb->network_header + off; +maybe_pull_tail (skb, header_size);Same comment about skb lengths?
drivers/net/xen-netfront.c out:
Quoted 4 lines
drivers/net/xen-netfront.c +4
-0+ + nexthdr = ipv6h->nexthdr; + + while ((off <= sizeof(struct ipv6hdr) + ntohs(ipv6h->payload_len))&&
Quoted 20 lines
drivers/net/xen-netfront.c +20
-0+ !done) { +switch (nexthdr) { +case IPPROTO_DSTOPTS : +case IPPROTO_HOPOPTS : +case IPPROTO_ROUTING : { +struct ipv6_opt_hdr *hp = (void *)(skb->data + off); + + header_size = skb->network_header + + off + +sizeof (struct ipv6_opt_hdr ); +maybe_pull_tail (skb, header_size); + + nexthdr = hp->nexthdr; + off +=ipv6_optlen (hp); +break ; + } +case IPPROTO_AH : { +struct ip_auth_hdr *hp = (void *)(skb->data + off); + + header_size = skb->network_header +
Quoted 9 lines
drivers/net/xen-netfront.c out: · line 985
Quoted 6 lines
drivers/net/xen-netfront.c +6
-0+ off + +sizeof (struct ip_auth_hdr ); +maybe_pull_tail (skb, header_size); + + nexthdr = hp->nexthdr; + off += (hp->hdrlen+2 )<<2 ;I wonder if the core header would welcome a
ipv6_ahlencf optlen?
Yes, it would be nicer wouldn't it.
Quoted 11 lines
Quoted 11 lines
drivers/net/xen-netfront.c +11
-0+break ; + } +case IPPROTO_FRAGMENT : + fragment = true; +/* fall through */ +default : + done = true; +break ; + } + } +
Quoted 8 lines
drivers/net/xen-netfront.c out: · line 999
Quoted 3 lines
drivers/net/xen-netfront.c +3
-0+if (!done) { +if (net_ratelimit ()) +pr_err ("Failed to parse packet header\n" );Is it a requirement of the protocol that the list of IPPROTO_* we handle must be followed by some other header? Do we really care or is it more the upper stacks problem? Presumably it can get similarly malformed packets off the wire?
I'd have to check but I'm pretty sure none of the protos we handle can be terminating so if done is not set then the packet is malformed.
Quoted 2 lines
Also you can use
net_err_ratelimited.
Ok.
Quoted 10 lines
drivers/net/xen-netfront.c out: · line 1005
Quoted 7 lines
drivers/net/xen-netfront.c +6
-0+ goto out; + } + +if (fragment) { +if (net_ratelimit ()) +pr_err ("Packet is a fragment!\n" );Is that a bad thing?
Well, you can't do TCP or UDP checksum offload on a fragment, can you?
Quoted 65 lines
Quoted 35 lines
drivers/net/xen-netfront.c +35
-0+ goto out; + } + +switch (nexthdr) { +case IPPROTO_TCP : +if (!skb_partial_csum_set (skb, off, + offsetof(struct tcphdr , check))) + goto out; + +if (recalculate_partial_csum) { +struct tcphdr *tcph =tcp_hdr (skb); + + header_size = skb->network_header + + off + +sizeof (struct tcphdr ); +maybe_pull_tail (skb, header_size); + + tcph->check = ~csum_ipv6_magic (&ipv6h->saddr, + &ipv6h->daddr, + skb->len - off, +IPPROTO_TCP ,0 ); + } +break ; +case IPPROTO_UDP : +if (!skb_partial_csum_set (skb, off, + offsetof(struct udphdr , check))) + goto out; + +if (recalculate_partial_csum) { +struct udphdr *udph =udp_hdr (skb); + + header_size = skb->network_header + + off + +sizeof (struct udphdr ); +maybe_pull_tail (skb, header_size);drivers/net/xen-netfront.c out:
Quoted 10 lines
drivers/net/xen-netfront.c +10
-0+ + udph->check = ~csum_ipv6_magic (&ipv6h->saddr, + &ipv6h->daddr, + skb->len - off, +IPPROTO_UDP ,0 ); + } +break ; +default : +if (net_ratelimit ()) + pr_err("Attempting to checksum a non-TCP/UDPpacket, "
Quoted 19 lines
drivers/net/xen-netfront.c +19
-0+"dropping a protocol %d packet\n" , + nexthdr); + goto out; + } + + err =0 ; + +out: +return err; +} + +static int checksum_setup (struct net_device *dev,struct sk_buff *skb) +{ +int err = -EPROTO ; +int recalculate_partial_csum =0 ; + +/* +* A GSO SKB must be CHECKSUM_PARTIAL. However some buggy +* peers can fail to set NETRXF_csum_blank when sending a GSO
Quoted 9 lines
drivers/net/xen-netfront.c out: · line 1073
Quoted 4 lines
drivers/net/xen-netfront.c +4
-0+* frame. In this case force the SKB to CHECKSUM_PARTIAL and +* recalculate the partial checksum. +*/ +if (skb->ip_summed !=CHECKSUM_PARTIAL &&skb_is_gso (skb)) {Is it worth making this ipv4 only. Assuming that anything which adds v6 support has already fixed this bug? That would save time in
checksum_setup_ipv6.
That's true.
Quoted 4 lines
Speaking of which can checksum_setup_* be shared with netfront somehow?
Or maybe even put in common code? (Perhaps as a future cleanup)
I think it really should be in common code, but I think that would be better handled as a separate patch to remove the duplication.
Thanks for the comprehensive review!
Paul
Quoted 20 lines
Quoted 19 lines
drivers/net/xen-netfront.c +18
-0+struct netfront_info *np =netdev_priv (dev); + np->rx_gso_checksum_fixup++; + skb->ip_summed =CHECKSUM_PARTIAL ; + recalculate_partial_csum =1 ; + } + +/* A non-CHECKSUM_PARTIAL SKB does not require setup. */ +if (skb->ip_summed !=CHECKSUM_PARTIAL ) +return 0 ; + +if (skb->protocol ==htons (ETH_P_IP )) + err =checksum_setup_ip (skb, recalculate_partial_csum); +else if (skb->protocol ==htons (ETH_P_IPV6 )) + err =checksum_setup_ipv6 (skb, recalculate_partial_csum); + +return err; +} + static int handle_incoming_queue(struct net_device *dev,[...]
Quoted 10 lines · Paul Durrant
Quoted 9 lines
(I found it confusing because you reset it in the
recalculate_partialrather than extending it which is what I expected)
maybe_pull_taildoesn't guarantee to pull up to the length of the given parameter, e.g. if it is more thenskb->len. Which I think means you need some other explicit skb len checks around the place, don't you? Otherwise you risk running past the end of the skb for a malformed frame.
Quoted 2 lines
Yes, that's true. Probably best to have
maybe_pull_tail()return a failure if it doesn't managed to pullup the requested amount then.
That would work.
Quoted 7 lines
Quoted 4 lines
Is it a requirement of the protocol that the list of IPPROTO_* we handle must be followed by some other header? Do we really care or is it more the upper stacks problem? Presumably it can get similarly malformed packets off the wire?
I'd have to check but I'm pretty sure none of the protos we handle can be terminating so if done is not set then the packet is malformed.
OK. I'm not sure this is "our" problem though. we could just silently throw this corrupt frame up at the stack without trying to redo the checksum. Isn't that what would happen with real hardware?
Quoted 11 lines
Quoted 9 lines
drivers/net/xen-netfront.c out: · line 1005
Quoted 6 lines
drivers/net/xen-netfront.c +6
-0+ goto out; + } + +if (fragment) { +if (net_ratelimit ()) +pr_err ("Packet is a fragment!\n" );Is that a bad thing?
Well, you can't do TCP or UDP checksum offload on a fragment, can you?
I guess I meant (as above), why do we particularly care? We could just throw it at the stack, who will account it as a RX error and carry on
Quoted 7 lines
Quoted 4 lines
Speaking of which can checksum_setup_* be shared with netfront somehow?
Or maybe even put in common code? (Perhaps as a future cleanup)I think it really should be in common code, but I think that would be better handled as a separate patch to remove the duplication.
I'm ok with that. (I'm not netfront maintainer though...)
Quoted 1 line
Thanks for the comprehensive review!
No problem!
Quoted 103 lines
-----Original Message-----
From: [email protected] [mailto:xen-devel- [email protected]] On Behalf Of Paul Durrant
Sent: 07 November 2013 11:02
To: Ian Campbell
Cc: Boris Ostrovsky; David Vrabel; [email protected]
Subject: Re: [Xen-devel] [PATCH net-next] xen-netfront: Add support for IPv6 offloadsQuoted 85 lines
-----Original Message-----
From: Ian Campbell
Sent: 07 November 2013 10:49
To: Paul Durrant
Cc: [email protected]; Boris Ostrovsky; David Vrabel
Subject: Re: [Xen-devel] [PATCH net-next] xen-netfront: Add support for IPv6 offloadsQuoted 9 lines · Paul Durrant
This patch adds support for IPv6 checksum offload and GSO when those fetaures are available in the backend.
Signed-off-by Paul Durrant <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>Cc Boris Ostrovsky <[email protected]>Cc David Vrabel <[email protected]>--- drivers/net/xen-netfront.c | 263++++++++++++++++++++++++++++++++++++++------
drivers/net/xen-netfront.c static int xennet_start_xmit(struct sk_buff *skb,
Quoted 7 lines
1 file changed, 231 insertions(+), 32 deletions(-)drivers/net/xen-netfront.c +0
-0@@ -616,7 +616,9 @@ static int xennet_start_xmit(struct sk_buff *skb,struct
net_device*dev)drivers/net/xen-netfront.c static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)
Quoted 5 lines
drivers/net/xen-netfront.c +1
-1tx->flags |= XEN_NETTXF_extra_info; gso->u.gso.size =skb_shinfo (skb)->gso_size; - gso->u.gso.type =XEN_NETIF_GSO_TYPE_TCPV4 ; + gso->u.gso.type = (skb_shinfo(skb)->gso_type &
SKB_GSO_TCPV6) ?drivers/net/xen-netfront.c static int xennet_set_skb_gso(struct sk_buff
Quoted 6 lines
drivers/net/xen-netfront.c +2
-0+ XEN_NETIF_GSO_TYPE_TCPV6 : +XEN_NETIF_GSO_TYPE_TCPV4 ; gso->u.gso.pad =0 ; gso->u.gso.features =0 ;@@ -808,15 +810,18 @@ static int xennet_set_skb_gso(struct sk_buff*skb,
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct
Quoted 22 lines
drivers/net/xen-netfront.c +6
-3return -EINVAL ; } -/* Currently only TCPv4 S.O. is supported. */ -if (gso->u.gso.type !=XEN_NETIF_GSO_TYPE_TCPV4 ) { +if (gso->u.gso.type !=XEN_NETIF_GSO_TYPE_TCPV4 && + gso->u.gso.type !=XEN_NETIF_GSO_TYPE_TCPV6 ) {if (net_ratelimit ())pr_warn ("Bad GSO type %d\n" , gso->u.gso.type);return -EINVAL ; }skb_shinfo (skb)->gso_size = gso->u.gso.size; -skb_shinfo (skb)->gso_type =SKB_GSO_TCPV4 ; +skb_shinfo (skb)->gso_type = + (gso->u.gso.type ==XEN_NETIF_GSO_TYPE_TCPV4 ) ? +SKB_GSO_TCPV4 : +SKB_GSO_TCPV6 ;/* Header must be checked, and gso_segs computed. */ skb_shinfo (skb)->gso_type |=SKB_GSO_DODGY ;@@ -856,62 +861,72 @@ static RING_IDX xennet_fill_frags(struct
netfront_info*np,Quoted 22 lines
drivers/net/xen-netfront.c +2
-16return cons; } -static int checksum_setup (struct net_device *dev,struct sk_buff *skb) +static inline void maybe_pull_tail (struct sk_buff *skb,unsigned int len) { -struct iphdr *iph; -int err = -EPROTO ; -int recalculate_partial_csum =0 ; - -/* -* A GSO SKB must be CHECKSUM_PARTIAL. However some buggy -* peers can fail to set NETRXF_csum_blank when sending a GSO -* frame. In this case force the SKB to CHECKSUM_PARTIAL and -* recalculate the partial checksum. -*/ -if (skb->ip_summed !=CHECKSUM_PARTIAL &&skb_is_gso (skb)) { -struct netfront_info *np =netdev_priv (dev); - np->rx_gso_checksum_fixup++; - skb->ip_summed =CHECKSUM_PARTIAL ; - recalculate_partial_csum =1 ; +if (skb_is_nonlinear (skb) &&skb_headlen (skb) < len) {Quoted 8 lines
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct netfront_info *np, · line 871
Quoted 5 lines
drivers/net/xen-netfront.c +5
-0+/* If we need to pullup then pullup to the max, so we +* won't need to do it again. +*/ +int target =min_t (int, skb->len,MAX_TCP_HEADER ); +__pskb_pull_tail (skb, target -skb_headlen (skb));Should the functions "len" argument not be involved somewhere in this? What if it is bigger than
MAX_TCP_HEADERfor example?
Quoted 2 lines
Hmm, good point.
Actually, now I look again, this is correct. The if statement checks len to see if a pullup is necessary, but if one is necessary then it always pulls up to the max. I still need to add a failure return to indicate the pullup did not achieve the desired length though.
Paul
Quoted 324 lines
Quoted 20 lines
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct netfront_info *np,
Quoted 8 lines
drivers/net/xen-netfront.c +2
-3} +} -/* A non-CHECKSUM_PARTIAL SKB does not require setup. */ -if (skb->ip_summed !=CHECKSUM_PARTIAL ) -return 0 ; +static int checksum_setup_ip(struct sk_buff *skb, int
recalculate_partial_csum)Quoted 11 lines
drivers/net/xen-netfront.c +6
-2+{ +struct iphdr *iph = (void *)skb->data; +unsigned int header_size; +unsigned int off; +int err = -EPROTO ; -if (skb->protocol !=htons (ETH_P_IP )) - goto out; + off =sizeof (struct iphdr );Quoted 8 lines
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct netfront_info *np, · line 885
Quoted 3 lines
drivers/net/xen-netfront.c +2
-1- iph = (void *)skb->data; + header_size = skb->network_header + off +MAX_IPOPTLEN ; +maybe_pull_tail (skb, header_size);You never reuse
header_sizeother than setting it and immediately passing it tomaybe_pull_tail, it could be inlined into the function call?Yes, it could but I thought this was tidier. It's also the same as the code in netback.
Quoted 9 lines
(I found it confusing because you reset it in the
recalculate_partialrather than extending it which is what I expected)
maybe_pull_taildoesn't guarantee to pull up to the length of the given parameter, e.g. if it is more thenskb->len. Which I think means you need some other explicit skb len checks around the place, don't you? Otherwise you risk running past the end of the skb for a malformed frame.Yes, that's true. Probably best to have
maybe_pull_tail()return a failure if it doesn't managed to pullup the requested amount then.Quoted 50 lines
Quoted 30 lines
drivers/net/xen-netfront.c +11
-3+ + off = iph->ihl *4 ;switch (iph->protocol) {case IPPROTO_TCP : -if (!skb_partial_csum_set (skb,4 * iph->ihl, +if (!skb_partial_csum_set (skb, off, offsetof(struct tcphdr , check))) goto out;if (recalculate_partial_csum) {struct tcphdr *tcph =tcp_hdr (skb); + + header_size = skb->network_header + + off + +sizeof (struct tcphdr ); +maybe_pull_tail (skb, header_size); + tcph->check = ~csum_tcpudp_magic (iph->saddr, iph- daddr, - skb->len - iph->ihl*4 , + skb->len - off,IPPROTO_TCP ,0 ); }break ;case IPPROTO_UDP : -if (!skb_partial_csum_set (skb,4 * iph->ihl, +if (!skb_partial_csum_set (skb, off, offsetof(struct udphdr , check))) goto out;drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct netfront_info *np,
Quoted 10 lines
drivers/net/xen-netfront.c +6
-0if (recalculate_partial_csum) {struct udphdr *udph =udp_hdr (skb); + + header_size = skb->network_header + + off + +sizeof (struct udphdr ); +maybe_pull_tail (skb, header_size); + udph->check = ~csum_tcpudp_magic(iph->saddr,
iph->daddr,drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct netfront_info *np,
Quoted 8 lines
drivers/net/xen-netfront.c +1
-2- skb->len - iph->ihl*4 , + skb->len - off, IPPROTO_UDP, 0); }break ;default :if (net_ratelimit ()) - pr_err("Attempting to checksum a non-TCP/UDPpacket, dropping a protocol %d packet\n",
Quoted 7 lines
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct · line 930
Quoted 1 line
drivers/net/xen-netfront.c +1
-0+ pr_err("Attempting to checksum a non-TCP/UDPpacket, "
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct · line 931
Quoted 1 line
drivers/net/xen-netfront.c +1
-0+ "dropping a protocol %d packet\n",I think Linux's coding style explicitly relaxes the 80-column limit for string literals.
Ok. Good to know.
Quoted 52 lines
drivers/net/xen-netfront.c out: · line 940
Quoted 8 lines
drivers/net/xen-netfront.c +0
-0iph->protocol);drivers/net/xen-netfront.c +1
-0goto out; }@@ -922,6 +937,158 @@ out:return err; } +static int checksum_setup_ipv6(struct sk_buff *skb, int
recalculate_partial_csum)Quoted 5 lines
drivers/net/xen-netfront.c +5
-0+{ +int err = -EPROTO ; +struct ipv6hdr *ipv6h = (void *)skb->data; +u8 nexthdr; +unsigned int header_size;drivers/net/xen-netfront.c out: · line 955
Quoted 10 lines
drivers/net/xen-netfront.c +10
-0+unsigned int off; +bool fragment; +bool done; + + done = false; + + off =sizeof (struct ipv6hdr ); + + header_size = skb->network_header + off; +maybe_pull_tail (skb, header_size);Same comment about skb lengths?
drivers/net/xen-netfront.c out:
Quoted 4 lines
drivers/net/xen-netfront.c +4
-0+ + nexthdr = ipv6h->nexthdr; + + while ((off <= sizeof(struct ipv6hdr) + ntohs(ipv6h->payload_len))&&
Quoted 20 lines
drivers/net/xen-netfront.c +20
-0+ !done) { +switch (nexthdr) { +case IPPROTO_DSTOPTS : +case IPPROTO_HOPOPTS : +case IPPROTO_ROUTING : { +struct ipv6_opt_hdr *hp = (void *)(skb->data + off); + + header_size = skb->network_header + + off + +sizeof (struct ipv6_opt_hdr ); +maybe_pull_tail (skb, header_size); + + nexthdr = hp->nexthdr; + off +=ipv6_optlen (hp); +break ; + } +case IPPROTO_AH : { +struct ip_auth_hdr *hp = (void *)(skb->data + off); + + header_size = skb->network_header +Quoted 9 lines
drivers/net/xen-netfront.c out: · line 985
Quoted 6 lines
drivers/net/xen-netfront.c +6
-0+ off + +sizeof (struct ip_auth_hdr ); +maybe_pull_tail (skb, header_size); + + nexthdr = hp->nexthdr; + off += (hp->hdrlen+2 )<<2 ;I wonder if the core header would welcome a
ipv6_ahlencf optlen?Yes, it would be nicer wouldn't it.
Quoted 11 lines
Quoted 11 lines
drivers/net/xen-netfront.c +11
-0+break ; + } +case IPPROTO_FRAGMENT : + fragment = true; +/* fall through */ +default : + done = true; +break ; + } + } +Quoted 8 lines
drivers/net/xen-netfront.c out: · line 999
Quoted 3 lines
drivers/net/xen-netfront.c +3
-0+if (!done) { +if (net_ratelimit ()) +pr_err ("Failed to parse packet header\n" );Is it a requirement of the protocol that the list of IPPROTO_* we handle must be followed by some other header? Do we really care or is it more the upper stacks problem? Presumably it can get similarly malformed packets off the wire?
I'd have to check but I'm pretty sure none of the protos we handle can be terminating so if done is not set then the packet is malformed.
Quoted 2 lines
Also you can use
net_err_ratelimited.Ok.
Quoted 10 lines
drivers/net/xen-netfront.c out: · line 1005
Quoted 7 lines
drivers/net/xen-netfront.c +6
-0+ goto out; + } + +if (fragment) { +if (net_ratelimit ()) +pr_err ("Packet is a fragment!\n" );Is that a bad thing?
Well, you can't do TCP or UDP checksum offload on a fragment, can you?
Quoted 65 lines
Quoted 35 lines
drivers/net/xen-netfront.c +35
-0+ goto out; + } + +switch (nexthdr) { +case IPPROTO_TCP : +if (!skb_partial_csum_set (skb, off, + offsetof(struct tcphdr , check))) + goto out; + +if (recalculate_partial_csum) { +struct tcphdr *tcph =tcp_hdr (skb); + + header_size = skb->network_header + + off + +sizeof (struct tcphdr ); +maybe_pull_tail (skb, header_size); + + tcph->check = ~csum_ipv6_magic (&ipv6h->saddr, + &ipv6h->daddr, + skb->len - off, +IPPROTO_TCP ,0 ); + } +break ; +case IPPROTO_UDP : +if (!skb_partial_csum_set (skb, off, + offsetof(struct udphdr , check))) + goto out; + +if (recalculate_partial_csum) { +struct udphdr *udph =udp_hdr (skb); + + header_size = skb->network_header + + off + +sizeof (struct udphdr ); +maybe_pull_tail (skb, header_size);drivers/net/xen-netfront.c out:
Quoted 10 lines
drivers/net/xen-netfront.c +10
-0+ + udph->check = ~csum_ipv6_magic (&ipv6h->saddr, + &ipv6h->daddr, + skb->len - off, +IPPROTO_UDP ,0 ); + } +break ; +default : +if (net_ratelimit ()) + pr_err("Attempting to checksum a non-TCP/UDPpacket, "
Quoted 19 lines
drivers/net/xen-netfront.c +19
-0+"dropping a protocol %d packet\n" , + nexthdr); + goto out; + } + + err =0 ; + +out: +return err; +} + +static int checksum_setup (struct net_device *dev,struct sk_buff *skb) +{ +int err = -EPROTO ; +int recalculate_partial_csum =0 ; + +/* +* A GSO SKB must be CHECKSUM_PARTIAL. However some buggy +* peers can fail to set NETRXF_csum_blank when sending a GSO Quoted 9 lines
drivers/net/xen-netfront.c out: · line 1073
Quoted 4 lines
drivers/net/xen-netfront.c +4
-0+* frame. In this case force the SKB to CHECKSUM_PARTIAL and +* recalculate the partial checksum. +*/ +if (skb->ip_summed !=CHECKSUM_PARTIAL &&skb_is_gso (skb)) {Is it worth making this ipv4 only. Assuming that anything which adds v6 support has already fixed this bug? That would save time in
checksum_setup_ipv6.That's true.
Quoted 4 lines
Speaking of which can checksum_setup_* be shared with netfront somehow?
Or maybe even put in common code? (Perhaps as a future cleanup)I think it really should be in common code, but I think that would be better handled as a separate patch to remove the duplication.
Thanks for the comprehensive review!
Paul
Quoted 12 lines
Quoted 12 lines
drivers/net/xen-netfront.c +12
-0+struct netfront_info *np =netdev_priv (dev); + np->rx_gso_checksum_fixup++; + skb->ip_summed =CHECKSUM_PARTIAL ; + recalculate_partial_csum =1 ; + } + +/* A non-CHECKSUM_PARTIAL SKB does not require setup. */ +if (skb->ip_summed !=CHECKSUM_PARTIAL ) +return 0 ; + +if (skb->protocol ==htons (ETH_P_IP )) + err =checksum_setup_ip (skb, recalculate_partial_csum);Quoted 8 lines
Quoted 7 lines
drivers/net/xen-netfront.c +6
-0+else if (skb->protocol ==htons (ETH_P_IPV6 )) + err =checksum_setup_ipv6 (skb, recalculate_partial_csum); + +return err; +} + static int handle_incoming_queue(struct net_device *dev,[...]
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 103 lines · Paul Durrant
Quoted 103 lines
-----Original Message-----
From: [email protected] [mailto:xen-devel- [email protected]] On Behalf Of Paul Durrant
Sent: 07 November 2013 11:02
To: Ian Campbell
Cc: Boris Ostrovsky; David Vrabel; [email protected]
Subject: Re: [Xen-devel] [PATCH net-next] xen-netfront: Add support for IPv6 offloadsQuoted 93 lines
-----Original Message-----
From: Ian Campbell
Sent: 07 November 2013 10:49
To: Paul Durrant
Cc: [email protected]; Boris Ostrovsky; David Vrabel
Subject: Re: [Xen-devel] [PATCH net-next] xen-netfront: Add support for IPv6 offloadsQuoted 9 lines · Paul Durrant
This patch adds support for IPv6 checksum offload and GSO when those fetaures are available in the backend.
Signed-off-by Paul Durrant <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>Cc Boris Ostrovsky <[email protected]>Cc David Vrabel <[email protected]>--- drivers/net/xen-netfront.c | 263++++++++++++++++++++++++++++++++++++++------
drivers/net/xen-netfront.c static int xennet_start_xmit(struct sk_buff *skb,
Quoted 7 lines
1 file changed, 231 insertions(+), 32 deletions(-)drivers/net/xen-netfront.c +0
-0@@ -616,7 +616,9 @@ static int xennet_start_xmit(struct sk_buff *skb,struct
net_device*dev)drivers/net/xen-netfront.c static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)
Quoted 5 lines
drivers/net/xen-netfront.c +1
-1tx->flags |= XEN_NETTXF_extra_info; gso->u.gso.size =skb_shinfo (skb)->gso_size; - gso->u.gso.type =XEN_NETIF_GSO_TYPE_TCPV4 ; + gso->u.gso.type = (skb_shinfo(skb)->gso_type &
SKB_GSO_TCPV6) ?drivers/net/xen-netfront.c static int xennet_set_skb_gso(struct sk_buff
Quoted 6 lines
drivers/net/xen-netfront.c +2
-0+ XEN_NETIF_GSO_TYPE_TCPV6 : +XEN_NETIF_GSO_TYPE_TCPV4 ; gso->u.gso.pad =0 ; gso->u.gso.features =0 ;@@ -808,15 +810,18 @@ static int xennet_set_skb_gso(struct sk_buff*skb,
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct
Quoted 22 lines
drivers/net/xen-netfront.c +6
-3return -EINVAL ; } -/* Currently only TCPv4 S.O. is supported. */ -if (gso->u.gso.type !=XEN_NETIF_GSO_TYPE_TCPV4 ) { +if (gso->u.gso.type !=XEN_NETIF_GSO_TYPE_TCPV4 && + gso->u.gso.type !=XEN_NETIF_GSO_TYPE_TCPV6 ) {if (net_ratelimit ())pr_warn ("Bad GSO type %d\n" , gso->u.gso.type);return -EINVAL ; }skb_shinfo (skb)->gso_size = gso->u.gso.size; -skb_shinfo (skb)->gso_type =SKB_GSO_TCPV4 ; +skb_shinfo (skb)->gso_type = + (gso->u.gso.type ==XEN_NETIF_GSO_TYPE_TCPV4 ) ? +SKB_GSO_TCPV4 : +SKB_GSO_TCPV6 ;/* Header must be checked, and gso_segs computed. */ skb_shinfo (skb)->gso_type |=SKB_GSO_DODGY ;@@ -856,62 +861,72 @@ static RING_IDX xennet_fill_frags(struct
netfront_info*np,Quoted 17 lines
drivers/net/xen-netfront.c +1
-12return cons; } -static int checksum_setup (struct net_device *dev,struct sk_buff *skb) +static inline void maybe_pull_tail (struct sk_buff *skb,unsigned int len) { -struct iphdr *iph; -int err = -EPROTO ; -int recalculate_partial_csum =0 ; - -/* -* A GSO SKB must be CHECKSUM_PARTIAL. However some buggy -* peers can fail to set NETRXF_csum_blank when sending a GSO -* frame. In this case force the SKB to CHECKSUM_PARTIAL and -* recalculate the partial checksum. -*/ -if (skb->ip_summed !=CHECKSUM_PARTIAL &&skb_is_gso (skb)) {drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct netfront_info *np, · line 871
Quoted 10 lines
drivers/net/xen-netfront.c +6
-4-struct netfront_info *np =netdev_priv (dev); - np->rx_gso_checksum_fixup++; - skb->ip_summed =CHECKSUM_PARTIAL ; - recalculate_partial_csum =1 ; +if (skb_is_nonlinear (skb) &&skb_headlen (skb) < len) { +/* If we need to pullup then pullup to the max, so we +* won't need to do it again. +*/ +int target =min_t (int, skb->len,MAX_TCP_HEADER ); +__pskb_pull_tail (skb, target -skb_headlen (skb));Should the functions "len" argument not be involved somewhere in this? What if it is bigger than
MAX_TCP_HEADERfor example?
Quoted 6 lines
Quoted 2 lines
Hmm, good point.
Actually, now I look again, this is correct. The if statement checks len to see if a pullup is necessary, but if one is necessary then it always pulls up to the max.
So it is guaranteed that len <= MAX_TCP_HEADER in all circumstances? That might surprise some callers, since the name doesn't really indicate this has anything to do with TCP. How about passing max in as an argument, where all callers would currently pass MAX_TCP_HEADER?
Quoted 329 lines
I still need to add a failure return to indicate the pullup did not
achieve the desired length though.Paul
Quoted 324 lines
Quoted 20 lines
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct netfront_info *np,
Quoted 8 lines
drivers/net/xen-netfront.c +2
-3} +} -/* A non-CHECKSUM_PARTIAL SKB does not require setup. */ -if (skb->ip_summed !=CHECKSUM_PARTIAL ) -return 0 ; +static int checksum_setup_ip(struct sk_buff *skb, int
recalculate_partial_csum)Quoted 11 lines
drivers/net/xen-netfront.c +6
-2+{ +struct iphdr *iph = (void *)skb->data; +unsigned int header_size; +unsigned int off; +int err = -EPROTO ; -if (skb->protocol !=htons (ETH_P_IP )) - goto out; + off =sizeof (struct iphdr );Quoted 8 lines
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct netfront_info *np, · line 885
Quoted 3 lines
drivers/net/xen-netfront.c +2
-1- iph = (void *)skb->data; + header_size = skb->network_header + off +MAX_IPOPTLEN ; +maybe_pull_tail (skb, header_size);You never reuse
header_sizeother than setting it and immediately passing it tomaybe_pull_tail, it could be inlined into the function call?Yes, it could but I thought this was tidier. It's also the same as the code in netback.
Quoted 9 lines
(I found it confusing because you reset it in the
recalculate_partialrather than extending it which is what I expected)
maybe_pull_taildoesn't guarantee to pull up to the length of the given parameter, e.g. if it is more thenskb->len. Which I think means you need some other explicit skb len checks around the place, don't you? Otherwise you risk running past the end of the skb for a malformed frame.Yes, that's true. Probably best to have
maybe_pull_tail()return a failure if it doesn't managed to pullup the requested amount then.Quoted 50 lines
Quoted 30 lines
drivers/net/xen-netfront.c +11
-3+ + off = iph->ihl *4 ;switch (iph->protocol) {case IPPROTO_TCP : -if (!skb_partial_csum_set (skb,4 * iph->ihl, +if (!skb_partial_csum_set (skb, off, offsetof(struct tcphdr , check))) goto out;if (recalculate_partial_csum) {struct tcphdr *tcph =tcp_hdr (skb); + + header_size = skb->network_header + + off + +sizeof (struct tcphdr ); +maybe_pull_tail (skb, header_size); + tcph->check = ~csum_tcpudp_magic (iph->saddr, iph- daddr, - skb->len - iph->ihl*4 , + skb->len - off,IPPROTO_TCP ,0 ); }break ;case IPPROTO_UDP : -if (!skb_partial_csum_set (skb,4 * iph->ihl, +if (!skb_partial_csum_set (skb, off, offsetof(struct udphdr , check))) goto out;drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct netfront_info *np,
Quoted 10 lines
drivers/net/xen-netfront.c +6
-0if (recalculate_partial_csum) {struct udphdr *udph =udp_hdr (skb); + + header_size = skb->network_header + + off + +sizeof (struct udphdr ); +maybe_pull_tail (skb, header_size); + udph->check = ~csum_tcpudp_magic(iph->saddr,
iph->daddr,drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct netfront_info *np,
Quoted 8 lines
drivers/net/xen-netfront.c +1
-2- skb->len - iph->ihl*4 , + skb->len - off, IPPROTO_UDP, 0); }break ;default :if (net_ratelimit ()) - pr_err("Attempting to checksum a non-TCP/UDPpacket, dropping a protocol %d packet\n",
Quoted 7 lines
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct · line 930
Quoted 1 line
drivers/net/xen-netfront.c +1
-0+ pr_err("Attempting to checksum a non-TCP/UDPpacket, "
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct · line 931
Quoted 1 line
drivers/net/xen-netfront.c +1
-0+ "dropping a protocol %d packet\n",I think Linux's coding style explicitly relaxes the 80-column limit for string literals.
Ok. Good to know.
Quoted 52 lines
drivers/net/xen-netfront.c out: · line 940
Quoted 8 lines
drivers/net/xen-netfront.c +0
-0iph->protocol);drivers/net/xen-netfront.c +1
-0goto out; }@@ -922,6 +937,158 @@ out:return err; } +static int checksum_setup_ipv6(struct sk_buff *skb, int
recalculate_partial_csum)Quoted 5 lines
drivers/net/xen-netfront.c +5
-0+{ +int err = -EPROTO ; +struct ipv6hdr *ipv6h = (void *)skb->data; +u8 nexthdr; +unsigned int header_size;drivers/net/xen-netfront.c out: · line 955
Quoted 10 lines
drivers/net/xen-netfront.c +10
-0+unsigned int off; +bool fragment; +bool done; + + done = false; + + off =sizeof (struct ipv6hdr ); + + header_size = skb->network_header + off; +maybe_pull_tail (skb, header_size);Same comment about skb lengths?
drivers/net/xen-netfront.c out:
Quoted 4 lines
drivers/net/xen-netfront.c +4
-0+ + nexthdr = ipv6h->nexthdr; + + while ((off <= sizeof(struct ipv6hdr) + ntohs(ipv6h->payload_len))&&
Quoted 20 lines
drivers/net/xen-netfront.c +20
-0+ !done) { +switch (nexthdr) { +case IPPROTO_DSTOPTS : +case IPPROTO_HOPOPTS : +case IPPROTO_ROUTING : { +struct ipv6_opt_hdr *hp = (void *)(skb->data + off); + + header_size = skb->network_header + + off + +sizeof (struct ipv6_opt_hdr ); +maybe_pull_tail (skb, header_size); + + nexthdr = hp->nexthdr; + off +=ipv6_optlen (hp); +break ; + } +case IPPROTO_AH : { +struct ip_auth_hdr *hp = (void *)(skb->data + off); + + header_size = skb->network_header +Quoted 9 lines
drivers/net/xen-netfront.c out: · line 985
Quoted 6 lines
drivers/net/xen-netfront.c +6
-0+ off + +sizeof (struct ip_auth_hdr ); +maybe_pull_tail (skb, header_size); + + nexthdr = hp->nexthdr; + off += (hp->hdrlen+2 )<<2 ;I wonder if the core header would welcome a
ipv6_ahlencf optlen?Yes, it would be nicer wouldn't it.
Quoted 11 lines
Quoted 11 lines
drivers/net/xen-netfront.c +11
-0+break ; + } +case IPPROTO_FRAGMENT : + fragment = true; +/* fall through */ +default : + done = true; +break ; + } + } +Quoted 8 lines
drivers/net/xen-netfront.c out: · line 999
Quoted 3 lines
drivers/net/xen-netfront.c +3
-0+if (!done) { +if (net_ratelimit ()) +pr_err ("Failed to parse packet header\n" );Is it a requirement of the protocol that the list of IPPROTO_* we handle must be followed by some other header? Do we really care or is it more the upper stacks problem? Presumably it can get similarly malformed packets off the wire?
I'd have to check but I'm pretty sure none of the protos we handle can be terminating so if done is not set then the packet is malformed.
Quoted 2 lines
Also you can use
net_err_ratelimited.Ok.
Quoted 10 lines
drivers/net/xen-netfront.c out: · line 1005
Quoted 7 lines
drivers/net/xen-netfront.c +6
-0+ goto out; + } + +if (fragment) { +if (net_ratelimit ()) +pr_err ("Packet is a fragment!\n" );Is that a bad thing?
Well, you can't do TCP or UDP checksum offload on a fragment, can you?
Quoted 65 lines
Quoted 35 lines
drivers/net/xen-netfront.c +35
-0+ goto out; + } + +switch (nexthdr) { +case IPPROTO_TCP : +if (!skb_partial_csum_set (skb, off, + offsetof(struct tcphdr , check))) + goto out; + +if (recalculate_partial_csum) { +struct tcphdr *tcph =tcp_hdr (skb); + + header_size = skb->network_header + + off + +sizeof (struct tcphdr ); +maybe_pull_tail (skb, header_size); + + tcph->check = ~csum_ipv6_magic (&ipv6h->saddr, + &ipv6h->daddr, + skb->len - off, +IPPROTO_TCP ,0 ); + } +break ; +case IPPROTO_UDP : +if (!skb_partial_csum_set (skb, off, + offsetof(struct udphdr , check))) + goto out; + +if (recalculate_partial_csum) { +struct udphdr *udph =udp_hdr (skb); + + header_size = skb->network_header + + off + +sizeof (struct udphdr ); +maybe_pull_tail (skb, header_size);drivers/net/xen-netfront.c out:
Quoted 10 lines
drivers/net/xen-netfront.c +10
-0+ + udph->check = ~csum_ipv6_magic (&ipv6h->saddr, + &ipv6h->daddr, + skb->len - off, +IPPROTO_UDP ,0 ); + } +break ; +default : +if (net_ratelimit ()) + pr_err("Attempting to checksum a non-TCP/UDPpacket, "
Quoted 19 lines
drivers/net/xen-netfront.c +19
-0+"dropping a protocol %d packet\n" , + nexthdr); + goto out; + } + + err =0 ; + +out: +return err; +} + +static int checksum_setup (struct net_device *dev,struct sk_buff *skb) +{ +int err = -EPROTO ; +int recalculate_partial_csum =0 ; + +/* +* A GSO SKB must be CHECKSUM_PARTIAL. However some buggy +* peers can fail to set NETRXF_csum_blank when sending a GSO Quoted 9 lines
drivers/net/xen-netfront.c out: · line 1073
Quoted 4 lines
drivers/net/xen-netfront.c +4
-0+* frame. In this case force the SKB to CHECKSUM_PARTIAL and +* recalculate the partial checksum. +*/ +if (skb->ip_summed !=CHECKSUM_PARTIAL &&skb_is_gso (skb)) {Is it worth making this ipv4 only. Assuming that anything which adds v6 support has already fixed this bug? That would save time in
checksum_setup_ipv6.That's true.
Quoted 4 lines
Speaking of which can checksum_setup_* be shared with netfront somehow?
Or maybe even put in common code? (Perhaps as a future cleanup)I think it really should be in common code, but I think that would be better handled as a separate patch to remove the duplication.
Thanks for the comprehensive review!
Paul
Quoted 12 lines
Quoted 12 lines
drivers/net/xen-netfront.c +12
-0+struct netfront_info *np =netdev_priv (dev); + np->rx_gso_checksum_fixup++; + skb->ip_summed =CHECKSUM_PARTIAL ; + recalculate_partial_csum =1 ; + } + +/* A non-CHECKSUM_PARTIAL SKB does not require setup. */ +if (skb->ip_summed !=CHECKSUM_PARTIAL ) +return 0 ; + +if (skb->protocol ==htons (ETH_P_IP )) + err =checksum_setup_ip (skb, recalculate_partial_csum);Quoted 8 lines
Quoted 7 lines
drivers/net/xen-netfront.c +6
-0+else if (skb->protocol ==htons (ETH_P_IPV6 )) + err =checksum_setup_ipv6 (skb, recalculate_partial_csum); + +return err; +} + static int handle_incoming_queue(struct net_device *dev,[...]
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 128 lines
-----Original Message-----
From: Ian Campbell
Sent: 19 November 2013 10:29
To: Paul Durrant
Cc: Boris Ostrovsky; David Vrabel; [email protected]
Subject: Re: [Xen-devel] [PATCH net-next] xen-netfront: Add support for IPv6 offloadsQuoted 9 lines · Paul Durrant
Quoted 9 lines
-----Original Message-----
From: [email protected] [mailto:xen-devel- [email protected]] On Behalf Of Paul Durrant
Sent: 07 November 2013 11:02
To: Ian Campbell
Cc: Boris Ostrovsky; David Vrabel; [email protected]
Subject: Re: [Xen-devel] [PATCH net-next] xen-netfront: Add support for IPv6 offloadsQuoted 6 lines
Quoted 6 lines
Quoted 6 lines
-----Original Message-----
From: Ian Campbell
Sent: 07 November 2013 10:49
To: Paul Durrant
Cc: [email protected]; Boris Ostrovsky; David Vrabel
Subject: Re: [Xen-devel] [PATCH net-next] xen-netfront: Add supportfor
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
IPv6 offloads
Quoted 1 line · Paul Durrant
This patch adds support for IPv6 checksum offload and GSO when
those
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
fetaures are available in the backend.
Signed-off-by Paul Durrant <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>Cc Boris Ostrovsky <[email protected]>Cc David Vrabel <[email protected]>--- drivers/net/xen-netfront.c | 263Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
++++++++++++++++++++++++++++++++++++++------
drivers/net/xen-netfront.c static int xennet_start_xmit(struct sk_buff
Quoted 7 lines
1 file changed, 231 insertions(+), 32 deletions(-)drivers/net/xen-netfront.c +0
-0@@ -616,7 +616,9 @@ static int xennet_start_xmit(struct sk_buff*skb,
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
struct
net_device*dev)drivers/net/xen-netfront.c static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)
Quoted 5 lines
drivers/net/xen-netfront.c +1
-1tx->flags |= XEN_NETTXF_extra_info; gso->u.gso.size =skb_shinfo (skb)->gso_size; - gso->u.gso.type =XEN_NETIF_GSO_TYPE_TCPV4 ; + gso->u.gso.type = (skb_shinfo(skb)->gso_type &
SKB_GSO_TCPV6) ?Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/net/xen-netfront.c static int xennet_set_skb_gso(struct
Quoted 6 lines
drivers/net/xen-netfront.c +2
-0+ XEN_NETIF_GSO_TYPE_TCPV6 : +XEN_NETIF_GSO_TYPE_TCPV4 ; gso->u.gso.pad =0 ; gso->u.gso.features =0 ;@@ -808,15 +810,18 @@ static int xennet_set_skb_gso(struct
sk_buffQuoted 11 lines
Quoted 10 lines
Quoted 10 lines
*skb,
drivers/net/xen-netfront.c static int xennet_set_skb_gso(struct sk_buff *skb,
Quoted 9 lines
drivers/net/xen-netfront.c +2
-2return -EINVAL ; } -/* Currently only TCPv4 S.O. is supported. */ -if (gso->u.gso.type !=XEN_NETIF_GSO_TYPE_TCPV4 ) { +if (gso->u.gso.type !=XEN_NETIF_GSO_TYPE_TCPV4 && + gso->u.gso.type !=XEN_NETIF_GSO_TYPE_TCPV6 ) {if (net_ratelimit ()) pr_warn("Bad GSO type %d\n", gso-u.gso.type);
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/net/xen-netfront.c static int xennet_set_skb_gso(struct sk_buff *skb,
Quoted 7 lines
drivers/net/xen-netfront.c +2
-1return -EINVAL ; }skb_shinfo (skb)->gso_size = gso->u.gso.size; -skb_shinfo (skb)->gso_type =SKB_GSO_TCPV4 ; +skb_shinfo (skb)->gso_type = + (gso->u.gso.type ==XEN_NETIF_GSO_TYPE_TCPV4 )?
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct
Quoted 6 lines
drivers/net/xen-netfront.c +2
-0+ SKB_GSO_TCPV4 : +SKB_GSO_TCPV6 ;/* Header must be checked, and gso_segs computed. */ skb_shinfo (skb)->gso_type |=SKB_GSO_DODGY ;@@ -856,62 +861,72 @@ static RING_IDX xennet_fill_frags(struct
netfront_info*np,Quoted 4 lines
drivers/net/xen-netfront.c +0
-1return cons; } -static int checksum_setup(struct net_device *dev, struct sk_buff*skb)
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct · line 864
Quoted 1 line
drivers/net/xen-netfront.c +1
-0+static inline void maybe_pull_tail(struct sk_buff *skb, unsigned intlen)
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct netfront_info *np,
Quoted 7 lines
drivers/net/xen-netfront.c +0
-6{ -struct iphdr *iph; -int err = -EPROTO ; -int recalculate_partial_csum =0 ; - -/* -* A GSO SKB must be CHECKSUM_PARTIAL. However some buggy
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct · line 867
Quoted 1 line
drivers/net/xen-netfront.c +0
-1-* peers can fail to set NETRXF_csum_blank when sending a GSO
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct · line 868
Quoted 1 line
drivers/net/xen-netfront.c +0
-1-* frame. In this case force the SKB to CHECKSUM_PARTIAL and
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct netfront_info *np,
Quoted 3 lines
drivers/net/xen-netfront.c +0
-3-* recalculate the partial checksum. -*/ - if (skb->ip_summed != CHECKSUM_PARTIAL &&
skb_is_gso(skb)) {Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/net/xen-netfront.c +0
-4-struct netfront_info *np =netdev_priv (dev); - np->rx_gso_checksum_fixup++; - skb->ip_summed =CHECKSUM_PARTIAL ; - recalculate_partial_csum =1 ;Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct netfront_info *np, · line 871
Quoted 6 lines
drivers/net/xen-netfront.c +6
-0+if (skb_is_nonlinear (skb) &&skb_headlen (skb) < len) { +/* If we need to pullup then pullup to the max, so we +* won't need to do it again. +*/ +int target =min_t (int, skb->len,MAX_TCP_HEADER ); +__pskb_pull_tail (skb, target -skb_headlen (skb));Should the functions "len" argument not be involved somewhere in
this?
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
What if it is bigger than
MAX_TCP_HEADERfor example?Hmm, good point.
Quoted 9 lines
Quoted 3 lines
Actually, now I look again, this is correct. The if statement checks len to see if a pullup is necessary, but if one is necessary then it always pulls up to the max.
So it is guaranteed that len <=
MAX_TCP_HEADERin all circumstances? That might surprise some callers, since the name doesn't really indicate this has anything to do with TCP. How about passing max in as an argument, where all callers would currently passMAX_TCP_HEADER?
Ok, that sounds reasonable. It's unclear to me whether there is any upper bound on the size of an IPv6 header, but google hits a recent thread in the IETF mail archives (starting at http://www.ietf.org/mail-archive/web/ipv6/current/msg18199.html ) suggesting that 256 might be a good number to choose but I agree it's not directly related to 256, so maybe an argument and a local #define IPV6_MAX_HEADER of 256 would be better.
Paul
Quoted 362 lines
Quoted 10 lines
I still need to add a failure return to indicate the pullup did not
achieve the desired length though.Paul
Quoted 5 lines
Quoted 5 lines
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct netfront_info *np,
Quoted 5 lines
drivers/net/xen-netfront.c +1
-1} +} -/* A non-CHECKSUM_PARTIAL SKB does not require setup. */
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct netfront_info *np,
Quoted 3 lines
drivers/net/xen-netfront.c +1
-2-if (skb->ip_summed !=CHECKSUM_PARTIAL ) -return 0 ; +static int checksum_setup_ip(struct sk_buff *skb, int
recalculate_partial_csum)Quoted 7 lines
drivers/net/xen-netfront.c +5
-0+{ +struct iphdr *iph = (void *)skb->data; +unsigned int header_size; +unsigned int off; +int err = -EPROTO ;Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct netfront_info *np,
Quoted 6 lines
drivers/net/xen-netfront.c +2
-3-if (skb->protocol !=htons (ETH_P_IP )) - goto out; + off =sizeof (struct iphdr ); - iph = (void *)skb->data; + header_size = skb->network_header + off +
MAX_IPOPTLEN;Quoted 13 lines
Quoted 13 lines
Quoted 6 lines
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct · line 886
Quoted 1 line
drivers/net/xen-netfront.c +1
-0+maybe_pull_tail (skb, header_size);You never reuse
header_sizeother than setting it and immediately passing it tomaybe_pull_tail, it could be inlined into the function call?Yes, it could but I thought this was tidier. It's also the same as the code in netback.
Quoted 3 lines
(I found it confusing because you reset it in the
recalculate_partialrather than extending it which is what I expected)Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
maybe_pull_taildoesn't guarantee to pull up to the length of the given parameter, e.g. if it is more thenskb->len. Which I think means you need some other explicit skb len checks around the place, don't you? Otherwise you risk running past the end of the skb for a malformed frame.Yes, that's true. Probably best to have
maybe_pull_tail()return a failure ifit
Quoted 10 lines
Quoted 10 lines
doesn't managed to pullup the requested amount then.
Quoted 8 lines
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct netfront_info *np,
Quoted 8 lines
drivers/net/xen-netfront.c +3
-1+ + off = iph->ihl * 4; switch (iph->protocol) { case IPPROTO_TCP: - if (!skb_partial_csum_set(skb, 4 * iph->ihl, + if (!skb_partial_csum_set(skb, off, offsetof(struct tcphdr,check)))
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct netfront_info *np,
Quoted 11 lines
drivers/net/xen-netfront.c +6
-0goto out;if (recalculate_partial_csum) {struct tcphdr *tcph =tcp_hdr (skb); + + header_size = skb->network_header + + off + +sizeof (struct tcphdr ); +maybe_pull_tail (skb, header_size); + tcph->check = ~csum_tcpudp_magic(iph-saddr, iph-
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct · line 898
Quoted 2 lines
drivers/net/xen-netfront.c +0
-1daddr, - skb->len -iph->ihl*4,
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct · line 906
Quoted 1 line
drivers/net/xen-netfront.c +1
-0+ skb->len -off,
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
IPPROTO_TCP, 0);Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct netfront_info *np,
Quoted 6 lines
drivers/net/xen-netfront.c +1
-1}break ;case IPPROTO_UDP : - if (!skb_partial_csum_set(skb, 4 * iph->ihl, + if (!skb_partial_csum_set(skb, off, offsetof(struct udphdr,check)))
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct netfront_info *np,
Quoted 11 lines
drivers/net/xen-netfront.c +6
-0goto out;if (recalculate_partial_csum) {struct udphdr *udph =udp_hdr (skb); + + header_size = skb->network_header + + off + +sizeof (struct udphdr ); +maybe_pull_tail (skb, header_size); + udph->check = ~csum_tcpudp_magic(iph-saddr,
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
iph->daddr,drivers/net/xen-netfront.c
Quoted 1 line
drivers/net/xen-netfront.c +0
-1- skb->len -iph->ihl*4,
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/net/xen-netfront.c
Quoted 1 line
drivers/net/xen-netfront.c +1
-0+ skb->len -off,
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
IPPROTO_UDP, 0);Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/net/xen-netfront.c static RING_IDX xennet_fill_frags(struct netfront_info *np,
Quoted 5 lines
drivers/net/xen-netfront.c +0
-1}break ;default :if (net_ratelimit ()) - pr_err("Attempting to checksum a non-TCP/UDP
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
packet, dropping a protocol %d packet\n",
drivers/net/xen-netfront.c
Quoted 1 line
drivers/net/xen-netfront.c +1
-0+ pr_err("Attempting to checksum a non-TCP/UDP
Quoted 41 lines
Quoted 36 lines
Quoted 6 lines
packet, "
drivers/net/xen-netfront.c
Quoted 1 line
drivers/net/xen-netfront.c +1
-0+ "dropping a protocol %d packet\n",I think Linux's coding style explicitly relaxes the 80-column limit for string literals.
Ok. Good to know.
Quoted 27 lines
drivers/net/xen-netfront.c out: · line 940
Quoted 8 lines
drivers/net/xen-netfront.c +1
-0iph->protocol); goto out; }@@ -922,6 +937,158 @@ out:return err; } +static int checksum_setup_ipv6(struct sk_buff *skb, int
recalculate_partial_csum)Quoted 5 lines
drivers/net/xen-netfront.c +5
-0+{ +int err = -EPROTO ; +struct ipv6hdr *ipv6h = (void *)skb->data; +u8 nexthdr; +unsigned int header_size;drivers/net/xen-netfront.c out: · line 955
Quoted 10 lines
drivers/net/xen-netfront.c +10
-0+unsigned int off; +bool fragment; +bool done; + + done = false; + + off =sizeof (struct ipv6hdr ); + + header_size = skb->network_header + off; +maybe_pull_tail (skb, header_size);Same comment about skb lengths?
Quoted 4 lines
Quoted 4 lines
drivers/net/xen-netfront.c out:
Quoted 4 lines
drivers/net/xen-netfront.c +4
-0+ + nexthdr = ipv6h->nexthdr; + + while ((off <= sizeof(struct ipv6hdr) + ntohs(ipv6h-
payload_len))Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
&&
drivers/net/xen-netfront.c out:
Quoted 6 lines
drivers/net/xen-netfront.c +6
-0+ !done) { +switch (nexthdr) { +case IPPROTO_DSTOPTS : +case IPPROTO_HOPOPTS : +case IPPROTO_ROUTING : { + struct ipv6_opt_hdr *hp = (void *)(skb->data+ off);
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/net/xen-netfront.c +4
-0+ + header_size = skb->network_header + + off + +sizeof (struct ipv6_opt_hdr );Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/net/xen-netfront.c out:
Quoted 8 lines
drivers/net/xen-netfront.c +8
-0+maybe_pull_tail (skb, header_size); + + nexthdr = hp->nexthdr; + off +=ipv6_optlen (hp); +break ; + } +case IPPROTO_AH : { + struct ip_auth_hdr *hp = (void *)(skb->data+ off);
Quoted 55 lines
Quoted 55 lines
Quoted 11 lines
drivers/net/xen-netfront.c out: · line 985
Quoted 8 lines
drivers/net/xen-netfront.c +8
-0+ + header_size = skb->network_header + + off + +sizeof (struct ip_auth_hdr ); +maybe_pull_tail (skb, header_size); + + nexthdr = hp->nexthdr; + off += (hp->hdrlen+2 )<<2 ;I wonder if the core header would welcome a
ipv6_ahlencf optlen?Yes, it would be nicer wouldn't it.
Quoted 11 lines
Quoted 11 lines
drivers/net/xen-netfront.c +11
-0+break ; + } +case IPPROTO_FRAGMENT : + fragment = true; +/* fall through */ +default : + done = true; +break ; + } + } +Quoted 8 lines
drivers/net/xen-netfront.c out: · line 999
Quoted 3 lines
drivers/net/xen-netfront.c +3
-0+if (!done) { +if (net_ratelimit ()) +pr_err ("Failed to parse packet header\n" );Is it a requirement of the protocol that the list of IPPROTO_* we handle must be followed by some other header? Do we really care or is it more the upper stacks problem? Presumably it can get similarly malformed packets off the wire?
I'd have to check but I'm pretty sure none of the protos we handle can be terminating so if done is not set then the packet is malformed.
Quoted 2 lines
Also you can use
net_err_ratelimited.Ok.
Quoted 10 lines
drivers/net/xen-netfront.c out: · line 1005
Quoted 7 lines
drivers/net/xen-netfront.c +6
-0+ goto out; + } + +if (fragment) { +if (net_ratelimit ()) +pr_err ("Packet is a fragment!\n" );Is that a bad thing?
Well, you can't do TCP or UDP checksum offload on a fragment, can you?
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/net/xen-netfront.c out:
Quoted 7 lines
drivers/net/xen-netfront.c +7
-0+ goto out; + } + + switch (nexthdr) { + case IPPROTO_TCP: + if (!skb_partial_csum_set(skb, off, + offsetof(struct tcphdr,check)))
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines
drivers/net/xen-netfront.c out:
Quoted 11 lines
drivers/net/xen-netfront.c +11
-0+ goto out; + +if (recalculate_partial_csum) { +struct tcphdr *tcph =tcp_hdr (skb); + + header_size = skb->network_header + + off + +sizeof (struct tcphdr ); +maybe_pull_tail (skb, header_size); + + tcph->check = ~csum_ipv6_magic(&ipv6h-saddr,
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/net/xen-netfront.c out:
Quoted 8 lines
drivers/net/xen-netfront.c +8
-0+ &ipv6h->daddr, + skb->len - off, + IPPROTO_TCP, 0); + } +break ; +case IPPROTO_UDP : + if (!skb_partial_csum_set(skb, off, + offsetof(struct udphdr,check)))
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines
drivers/net/xen-netfront.c out:
Quoted 11 lines
drivers/net/xen-netfront.c +11
-0+ goto out; + +if (recalculate_partial_csum) { +struct udphdr *udph =udp_hdr (skb); + + header_size = skb->network_header + + off + +sizeof (struct udphdr ); +maybe_pull_tail (skb, header_size); + + udph->check = ~csum_ipv6_magic(&ipv6h-saddr,
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/net/xen-netfront.c out:
Quoted 8 lines
drivers/net/xen-netfront.c +8
-0+ &ipv6h->daddr, + skb->len - off, + IPPROTO_UDP, 0); + } +break ; +default : +if (net_ratelimit ()) + pr_err("Attempting to checksum a non-TCP/UDP
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
packet, "
drivers/net/xen-netfront.c out:
Quoted 12 lines
drivers/net/xen-netfront.c +12
-0+"dropping a protocol %d packet\n" , + nexthdr); + goto out; + } + + err =0 ; + +out: +return err; +} + +static int checksum_setup(struct net_device *dev, struct sk_buff*skb)
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/net/xen-netfront.c out:
Quoted 6 lines
drivers/net/xen-netfront.c +6
-0+{ +int err = -EPROTO ; +int recalculate_partial_csum =0 ; + +/* +* A GSO SKB must be CHECKSUM_PARTIAL. However some buggy
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/net/xen-netfront.c out: · line 1069
Quoted 1 line
drivers/net/xen-netfront.c +1
-0+* peers can fail to set NETRXF_csum_blank when sending a GSO
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/net/xen-netfront.c out: · line 1070
Quoted 1 line
drivers/net/xen-netfront.c +1
-0+* frame. In this case force the SKB to CHECKSUM_PARTIAL and
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/net/xen-netfront.c out:
Quoted 3 lines
drivers/net/xen-netfront.c +3
-0+* recalculate the partial checksum. +*/ + if (skb->ip_summed != CHECKSUM_PARTIAL &&
skb_is_gso(skb)) {Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Is it worth making this ipv4 only. Assuming that anything which adds v6 support has already fixed this bug? That would save time in
checksum_setup_ipv6.Quoted 8 lines
Quoted 8 lines
That's true.
Quoted 4 lines
Speaking of which can checksum_setup_* be shared with netfront somehow?
Or maybe even put in common code? (Perhaps as a future cleanup)I think it really should be in common code, but I think that would be
better
Quoted 6 lines
Quoted 6 lines
handled as a separate patch to remove the duplication.
Thanks for the comprehensive review!
Paul
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/net/xen-netfront.c out:
Quoted 7 lines
drivers/net/xen-netfront.c +7
-0+struct netfront_info *np =netdev_priv (dev); + np->rx_gso_checksum_fixup++; + skb->ip_summed =CHECKSUM_PARTIAL ; + recalculate_partial_csum =1 ; + } + +/* A non-CHECKSUM_PARTIAL SKB does not require setup. */
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/net/xen-netfront.c out:
Quoted 5 lines
drivers/net/xen-netfront.c +5
-0+if (skb->ip_summed !=CHECKSUM_PARTIAL ) +return 0 ; + +if (skb->protocol ==htons (ETH_P_IP )) + err = checksum_setup_ip(skb,
recalculate_partial_csum);Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/net/xen-netfront.c out: · line 1087
Quoted 2 lines
drivers/net/xen-netfront.c +2
-0+else if (skb->protocol ==htons (ETH_P_IPV6 )) + err = checksum_setup_ipv6(skb,
recalculate_partial_csum);Quoted 11 lines
Quoted 11 lines
Quoted 6 lines
Quoted 5 lines
drivers/net/xen-netfront.c +4
-0+ +return err; +} + static int handle_incoming_queue(struct net_device *dev,[...]
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel