netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Resolve packet capturing on macvlan lowerdev
@ 2011-04-21 13:31 David Ward
  2011-04-21 13:31 ` [PATCH 1/2] net: Export dev_queue_xmit_nit for use by macvlan driver David Ward
  2011-04-21 13:31 ` [PATCH 2/2] macvlan: Send frames to AF_PACKET sockets attached to lowerdev David Ward
  0 siblings, 2 replies; 4+ messages in thread
From: David Ward @ 2011-04-21 13:31 UTC (permalink / raw)
  To: netdev, kaber; +Cc: David Ward

The following two patches address situations where macvlan interfaces on 
the same lowerdev are created inside separate containers/namespaces, and 
traffic between these interfaces needs to be captured by monitoring the 
lowerdev outside the containers/namespaces using tcpdump or Wireshark. 
The only case where this doesn't work now is for unicast frames when the 
macvlan interfaces are operating in bridge mode; this fixes that case.

Should the dev_queue_xmit_nit function be renamed to something more 
meaningful, which would indicate its role in sending outgoing frames to 
AF_PACKET sockets? It is currently a misnomer: this function used to be 
invoked by dev_queue_xmit, but that is no longer the case.

Thanks,

David


David Ward (2):
  net: Export dev_queue_xmit_nit for use by macvlan driver
  macvlan: Send frames to AF_PACKET sockets attached to lowerdev

 drivers/net/macvlan.c     |    1 +
 include/linux/netdevice.h |    2 ++
 net/core/dev.c            |   14 +++++++++-----
 3 files changed, 12 insertions(+), 5 deletions(-)

-- 
1.7.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] net: Export dev_queue_xmit_nit for use by macvlan driver
  2011-04-21 13:31 [PATCH 0/2] Resolve packet capturing on macvlan lowerdev David Ward
@ 2011-04-21 13:31 ` David Ward
  2011-04-21 13:31 ` [PATCH 2/2] macvlan: Send frames to AF_PACKET sockets attached to lowerdev David Ward
  1 sibling, 0 replies; 4+ messages in thread
From: David Ward @ 2011-04-21 13:31 UTC (permalink / raw)
  To: netdev, kaber; +Cc: David Ward

Export dev_queue_xmit_nit for use by the macvlan virtual network device
driver. Also, use 'dev' instead of 'skb->dev' in this function.

Signed-off-by: David Ward <david.ward@ll.mit.edu>
---
 include/linux/netdevice.h |    2 ++
 net/core/dev.c            |   14 +++++++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index cb8178a..b63e517 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2099,6 +2099,8 @@ extern int		dev_hard_start_xmit(struct sk_buff *skb,
 					    struct netdev_queue *txq);
 extern int		dev_forward_skb(struct net_device *dev,
 					struct sk_buff *skb);
+extern void		dev_queue_xmit_nit(struct sk_buff *skb,
+					   struct net_device *dev);
 
 extern int		netdev_budget;
 
diff --git a/net/core/dev.c b/net/core/dev.c
index 3871bf6..e851227 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1520,11 +1520,13 @@ static inline int deliver_skb(struct sk_buff *skb,
 }
 
 /*
- *	Support routine. Sends outgoing frames to any network
- *	taps currently in use.
+ * dev_queue_xmit_nit - send outgoing frame to AF_PACKET sockets
+ *
+ * @skb: buffer to send
+ * @dev: network device that AF_PACKET sockets are attached to (if any)
  */
 
-static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
+void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
 {
 	struct packet_type *ptype;
 	struct sk_buff *skb2 = NULL;
@@ -1539,7 +1541,8 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
 		    (ptype->af_packet_priv == NULL ||
 		     (struct sock *)ptype->af_packet_priv != skb->sk)) {
 			if (pt_prev) {
-				deliver_skb(skb2, pt_prev, skb->dev);
+				atomic_inc(&skb2->users);
+				pt_prev->func(skb2, dev, pt_prev, dev);
 				pt_prev = ptype;
 				continue;
 			}
@@ -1572,9 +1575,10 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
 		}
 	}
 	if (pt_prev)
-		pt_prev->func(skb2, skb->dev, pt_prev, skb->dev);
+		pt_prev->func(skb2, dev, pt_prev, dev);
 	rcu_read_unlock();
 }
+EXPORT_SYMBOL(dev_queue_xmit_nit);
 
 /* netif_setup_tc - Handle tc mappings on real_num_tx_queues change
  * @dev: Network device
-- 
1.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] macvlan: Send frames to AF_PACKET sockets attached to lowerdev
  2011-04-21 13:31 [PATCH 0/2] Resolve packet capturing on macvlan lowerdev David Ward
  2011-04-21 13:31 ` [PATCH 1/2] net: Export dev_queue_xmit_nit for use by macvlan driver David Ward
@ 2011-04-21 13:31 ` David Ward
  2011-04-28  6:09   ` David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: David Ward @ 2011-04-21 13:31 UTC (permalink / raw)
  To: netdev, kaber; +Cc: David Ward

In bridge mode, unicast frames can be forwarded directly between macvlan
interfaces attached to the same lowerdev without calling dev_queue_xmit.
These frames should still be sent to any AF_PACKET sockets (network taps)
attached to the lowerdev.

Signed-off-by: David Ward <david.ward@ll.mit.edu>
---
 drivers/net/macvlan.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 3ad5425..2b1ee81 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -237,6 +237,7 @@ static int macvlan_queue_xmit(struct sk_buff *skb, struct net_device *dev)
 
 		dest = macvlan_hash_lookup(port, eth->h_dest);
 		if (dest && dest->mode == MACVLAN_MODE_BRIDGE) {
+			dev_queue_xmit_nit(skb, vlan->lowerdev);
 			unsigned int length = skb->len + ETH_HLEN;
 			int ret = dest->forward(dest->dev, skb);
 			macvlan_count_rx(dest, length,
-- 
1.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] macvlan: Send frames to AF_PACKET sockets attached to lowerdev
  2011-04-21 13:31 ` [PATCH 2/2] macvlan: Send frames to AF_PACKET sockets attached to lowerdev David Ward
@ 2011-04-28  6:09   ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2011-04-28  6:09 UTC (permalink / raw)
  To: david.ward; +Cc: netdev, kaber

From: David Ward <david.ward@ll.mit.edu>
Date: Thu, 21 Apr 2011 09:31:33 -0400

>  		dest = macvlan_hash_lookup(port, eth->h_dest);
>  		if (dest && dest->mode == MACVLAN_MODE_BRIDGE) {
> +			dev_queue_xmit_nit(skb, vlan->lowerdev);
>  			unsigned int length = skb->len + ETH_HLEN;
>  			int ret = dest->forward(dest->dev, skb);
>  			macvlan_count_rx(dest, length,

Don't put actual code before variable declarations in a basic
block, modern variants of C accept this but this isn't C++.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-04-28  6:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-21 13:31 [PATCH 0/2] Resolve packet capturing on macvlan lowerdev David Ward
2011-04-21 13:31 ` [PATCH 1/2] net: Export dev_queue_xmit_nit for use by macvlan driver David Ward
2011-04-21 13:31 ` [PATCH 2/2] macvlan: Send frames to AF_PACKET sockets attached to lowerdev David Ward
2011-04-28  6:09   ` David Miller

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).