Netdev List
 help / color / mirror / Atom feed
From: Anton Ivanov <anton.ivanov@cambridgegreys.com>
To: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Cc: Network Development <netdev@vger.kernel.org>,
	David Miller <davem@davemloft.net>
Subject: Re: BUG:af_packet fails to TX TSO frames
Date: Thu, 12 Oct 2017 16:44:26 +0100	[thread overview]
Message-ID: <e301fbfd-a283-caa1-5915-8be15677ed74@cambridgegreys.com> (raw)
In-Reply-To: <f046dbf4-0b46-2d7c-c82c-fe9f50c11f71@cambridgegreys.com>

Found it.

Two bugs canceling each other.
The bind sequence in:  psock_txring_vnet.c is wrong.

It does the following addr.sll_protocol =    htons(ETH_P_IP);
before calling bind.

If you set addr.sll_protocol to ETH_P_ALL where it should have been in 
the first place the test program blows up with -ENOBUFS

I think what is happening is that this value is taken into account when 
looking at "what should I use to segment it with" in skb_mac_gso_segment 
which is invoked at the end of the verification chain which starts in 
packet_direct_xmit in af_packet.c

I have not tried the other test cases like setting it to ETH_P_IP and 
giving it IPv6 traffic or the opposite, but my guess is that these will 
fail too if they need GSO to be applied.

A.

On 10/12/17 15:12, Anton Ivanov wrote:
>
>
> On 10/12/17 14:39, Willem de Bruijn wrote:
>>> If I produce a real vnet frame out of a live kernel frame using
>>> virtio_net_hdr_from_skb() and try to send it it fails on the check in
>>> af_packet, while succeeding for tap. If I remove the af_packet check 
>>> the
>>> frame is accepted by the hardware too.
>>>
>>> If I produce it a synthetic frame + vnet header using the test 
>>> program - it
>>> works. Go figure.
>> Besides looking at the raw frame bytes, also compare the setup
>> of virtio_net_header, as well as the tcp checksum field. The stack
>> expects the pseudo header to have already been calculated.
>
> I am feeding it a skb which is coming up in the tx routine of a User 
> Mode Linux device which is marked as NETIF_F_HW_CSUM and SG - that 
> results in a skb with csum-ed headers, body set up for CSUM_PARTIAL 
> and multiple fragments (always at least 1 more frag besides the TCP 
> head).
>
> That has everything in order as expected by virtio_net_hdr_from_skb 
> and this is what I use to generate the vnet header. It works correctly 
> for csum and GRO with af_packet and it works correctly for everything 
> using a tap device. It fails only on GSO + af_packet TX.
>
> What I am doing is the same thing virtio_net does - it just takes the 
> output of virtio_net_hdr_from_skb and does nothing more. There should 
> be no need to do anything more :(
>
> It should just work.
>
> Unless there is a gremlin somewhere in the machinery and that gremlin 
> needs some light to be flushed out.
>>
>>> I am going to continue digging into it.
>>>
>>> At the very least I now have a positive test case which uses the same
>>> semantics as my code so I have something to compare to.
>> Glad to hear that the test is helpful. I wrote it because I
>> have run into these exact same issues in the past.
>
> It is. I have changes ready for it so it also supports vector IO, need 
> to finish fighting with it.
>
> A.
>
>>
>

-- 
Anton R. Ivanov

Cambridge Greys Limited, England and Wales company No 10273661
http://www.cambridgegreys.com/

  reply	other threads:[~2017-10-12 15:44 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-11  8:39 BUG:af_packet fails to TX TSO frames Anton Ivanov
2017-10-11 13:39 ` Willem de Bruijn
2017-10-11 13:50   ` Anton Ivanov
2017-10-11 15:54     ` Anton Ivanov
2017-10-11 16:26       ` Willem de Bruijn
2017-10-11 16:32         ` Anton Ivanov
2017-10-11 18:39         ` Anton Ivanov
2017-10-11 18:57           ` Willem de Bruijn
2017-10-11 19:39             ` Anton Ivanov
2017-10-11 21:05               ` Willem de Bruijn
2017-10-11 21:55                 ` Anton Ivanov
2017-10-11 22:01                   ` Anton Ivanov
2017-10-12  0:19                     ` Willem de Bruijn
2017-10-12  6:11                       ` Anton Ivanov
2017-10-12  8:46                         ` Anton Ivanov
2017-10-12 13:39                           ` Willem de Bruijn
2017-10-12 14:12                             ` Anton Ivanov
2017-10-12 15:44                               ` Anton Ivanov [this message]
2017-10-12 15:57                                 ` Anton Ivanov
2017-10-12 16:30                                 ` Willem de Bruijn
2017-10-12 17:25                                   ` Willem de Bruijn
2017-10-12 17:58                                     ` Anton Ivanov
2017-10-12 18:41                                       ` Willem de Bruijn
2017-10-12 19:55                                         ` Anton Ivanov
2017-10-13  7:25   ` Not BUG, feature :) af_packet " Anton Ivanov

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=e301fbfd-a283-caa1-5915-8be15677ed74@cambridgegreys.com \
    --to=anton.ivanov@cambridgegreys.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=willemdebruijn.kernel@gmail.com \
    /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