From: Vlad Yasevich <vyasevich@gmail.com>
To: Jason Wang <jasowang@redhat.com>,
Vlad Yasevich <vyasevic@redhat.com>,
netdev@vger.kernel.org
Cc: mst@redhat.com, kaber@trash.net
Subject: Re: [PATCH net-next 1/2] macvtap: Add support of packet capture on macvtap device.
Date: Thu, 12 Dec 2013 12:23:46 -0500 [thread overview]
Message-ID: <52A9F122.2040108@gmail.com> (raw)
In-Reply-To: <52A9313E.6040602@redhat.com>
On 12/11/2013 10:45 PM, Jason Wang wrote:
> On 12/12/2013 02:27 AM, Vlad Yasevich wrote:
>> Macvtap device currently doesn not allow a user to capture
>> traffic on due to the fact that it steals the packets
>> from the network stack before the skb->dev is set correctly
>> on the receive side, and that use uses macvlan transmit
>> path directly on the send side. As a result, we never
>> get a change to give traffic to the taps while the correct
>> device is set in the skb.
>>
>> This patch makes macvtap device behave almost exaclty like
>> macvlan. On the send side, we switch to using dev_queue_xmit().
>> On the receive side, to deliver packets to macvtap, we now
>> use netif_rx and dev_forward_skb just like macvlan. The only
>> differnce now is that macvtap has its own rx_handler which is
>> attached to the macvtap netdev. It is here that we now steal
>> the packet and provide it to the socket.
>>
>> As a result, we can now capture traffic on the macvtap device:
>> tcpdump -i macvtap0
>>
>> It also gives us the abilit to add tc actions to the macvtap
>> device and actually utilize different bandwidth management
>> queues on output.
>>
>> Signed-off-by: Vlad Yasevich <vyasevic@redhat.com>
>> ---
>> drivers/net/macvtap.c | 59 ++++++++++++++++++++++++++++-----------------------
>> 1 file changed, 32 insertions(+), 27 deletions(-)
>>
>> diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
>> index 4c6f84c..f9847da 100644
>> --- a/drivers/net/macvtap.c
>> +++ b/drivers/net/macvtap.c
>> @@ -70,6 +70,11 @@ static const struct proto_ops macvtap_socket_ops;
>> #define RX_OFFLOADS (NETIF_F_GRO | NETIF_F_LRO)
>> #define TAP_FEATURES (NETIF_F_GSO | NETIF_F_SG)
>>
> [...]
>>
>> static void macvtap_dellink(struct net_device *dev,
>> struct list_head *head)
>> {
>> + netdev_rx_handler_unregister(dev);
>> macvtap_del_queues(dev);
>> macvlan_dellink(dev, head);
>> }
>> @@ -725,9 +731,8 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
>> skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG;
>> }
>> if (vlan) {
>> - local_bh_disable();
>> - macvlan_start_xmit(skb, vlan->dev);
>> - local_bh_enable();
>> + skb->dev = vlan->dev;
>> + dev_queue_xmit(skb);
>> } else {
>> kfree_skb(skb);
>> }
>
> An issue here: macvlan is a NETIF_F_LLTX device with only one transmit
> queue, we may get contention on qdisc lock of macvtap when transmitting
> through multiple tx queues.
Hmm... Yes, it looks like we could. I'll can change this to
dev_start_hard_xmit(skb, vlan->dev, NULL, NULL);
for now.
To use dev_queue_xmit(), we'd need to expose the macvtap queues
as real device queues (similar to what we do with tap). Would this
something we would to do.
I could see a desire to do attach qdiscs to macvtap device itself.
Right not that's not really possible.
Thanks
-vlad
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2013-12-12 17:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-11 18:27 [PATCH net-next 0/2] Add packet capture support on macvtap device Vlad Yasevich
2013-12-11 18:27 ` [PATCH net-next 1/2] macvtap: Add support of packet capture " Vlad Yasevich
2013-12-12 3:45 ` Jason Wang
2013-12-12 17:23 ` Vlad Yasevich [this message]
2013-12-11 18:27 ` [PATCH net-next 2/2] macvlan: Remove custom recieve and forward handlers Vlad Yasevich
2013-12-11 21:44 ` [PATCH net-next 0/2] Add packet capture support on macvtap device David Miller
2013-12-12 18:39 ` David Miller
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=52A9F122.2040108@gmail.com \
--to=vyasevich@gmail.com \
--cc=jasowang@redhat.com \
--cc=kaber@trash.net \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=vyasevic@redhat.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;
as well as URLs for NNTP newsgroup(s).