netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Jianfeng Tan <jianfeng.tan@linux.alibaba.com>, netdev@vger.kernel.org
Cc: davem@davemloft.net, mst@redhat.com
Subject: Re: [PATCH] net/packet: fix packet drop as of virtio gso
Date: Mon, 8 Oct 2018 11:14:59 +0800	[thread overview]
Message-ID: <7aed6adf-eea3-c5ea-ead5-8ab31bb9e61a@redhat.com> (raw)
In-Reply-To: <20180929154127.20867-1-jianfeng.tan@linux.alibaba.com>



On 2018年09月29日 23:41, Jianfeng Tan wrote:
> When we use raw socket as the vhost backend, a packet from virito with
> gso offloading information, cannot be sent out in later validaton at
> xmit path, as we did not set correct skb->protocol which is further used
> for looking up the gso function.

Hi:

May I ask the reason for using raw socket for vhost? It was not a common 
setup with little care in the past few years. And it was slow since it 
lacks some recent improvements. Can it be replaced with e.g macvtap?

Thanks

>
> To fix this, we set this field according to virito hdr information.
>
> Fixes: e858fae2b0b8f4 ("virtio_net: use common code for virtio_net_hdr and skb GSO conversion")
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Jianfeng Tan <jianfeng.tan@linux.alibaba.com>
> ---
>   include/linux/virtio_net.h | 18 ++++++++++++++++++
>   net/packet/af_packet.c     | 11 +++++++----
>   2 files changed, 25 insertions(+), 4 deletions(-)
>
> diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
> index 9397628a1967..cb462f9ab7dd 100644
> --- a/include/linux/virtio_net.h
> +++ b/include/linux/virtio_net.h
> @@ -5,6 +5,24 @@
>   #include <linux/if_vlan.h>
>   #include <uapi/linux/virtio_net.h>
>   
> +static inline int virtio_net_hdr_set_proto(struct sk_buff *skb,
> +					   const struct virtio_net_hdr *hdr)
> +{
> +	switch (hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
> +	case VIRTIO_NET_HDR_GSO_TCPV4:
> +	case VIRTIO_NET_HDR_GSO_UDP:
> +		skb->protocol = cpu_to_be16(ETH_P_IP);
> +		break;
> +	case VIRTIO_NET_HDR_GSO_TCPV6:
> +		skb->protocol = cpu_to_be16(ETH_P_IPV6);
> +		break;
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	return 0;
> +}
> +
>   static inline int virtio_net_hdr_to_skb(struct sk_buff *skb,
>   					const struct virtio_net_hdr *hdr,
>   					bool little_endian)
> diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
> index 75c92a87e7b2..d6e94dc7e290 100644
> --- a/net/packet/af_packet.c
> +++ b/net/packet/af_packet.c
> @@ -2715,10 +2715,12 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
>   			}
>   		}
>   
> -		if (po->has_vnet_hdr && virtio_net_hdr_to_skb(skb, vnet_hdr,
> -							      vio_le())) {
> -			tp_len = -EINVAL;
> -			goto tpacket_error;
> +		if (po->has_vnet_hdr) {
> +			if (virtio_net_hdr_to_skb(skb, vnet_hdr, vio_le())) {
> +				tp_len = -EINVAL;
> +				goto tpacket_error;
> +			}
> +			virtio_net_hdr_set_proto(skb, vnet_hdr);
>   		}
>   
>   		skb->destructor = tpacket_destruct_skb;
> @@ -2915,6 +2917,7 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
>   		if (err)
>   			goto out_free;
>   		len += sizeof(vnet_hdr);
> +		virtio_net_hdr_set_proto(skb, &vnet_hdr);
>   	}
>   
>   	skb_probe_transport_header(skb, reserve);

  parent reply	other threads:[~2018-10-08 10:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-29 15:41 [PATCH] net/packet: fix packet drop as of virtio gso Jianfeng Tan
2018-10-05  5:23 ` David Miller
2018-10-08  3:14 ` Jason Wang [this message]
2018-10-27 23:42   ` Jianfeng Tan
2018-10-29  2:40     ` Jason Wang
2018-10-29  3:51       ` Jianfeng Tan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7aed6adf-eea3-c5ea-ead5-8ab31bb9e61a@redhat.com \
    --to=jasowang@redhat.com \
    --cc=davem@davemloft.net \
    --cc=jianfeng.tan@linux.alibaba.com \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).