netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] af_packet: loop at reception when using fanout
@ 2012-08-06 14:21 Eric Leblond
  2012-08-16 15:44 ` [RFC PATCH v1.0] af_packet: don't emit packet on orig fanout group Eric Leblond
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Leblond @ 2012-08-06 14:21 UTC (permalink / raw)
  To: netdev, David Miller

[-- Attachment #1: Type: text/plain, Size: 1640 bytes --]

Hello,

When using fanout mode on a AF_PACKET socket, the packet sent via one of
the fanout socket are sent back to one of the socket in the fanout set.
I've read the code and the error seems to be in dev.c.
The code check if skb->sk is not equal to ptype->af_packet_priv but in
the fanout case, we should check that skb->sk is not in the sockets of
the fanout set.

Here's how could look a possible implementation of the fix:

diff --git a/net/core/dev.c b/net/core/dev.c
index 1cb0d8a..63d144f 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1654,7 +1654,12 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
                 */
                if ((ptype->dev == dev || !ptype->dev) &&
                    (ptype->af_packet_priv == NULL ||
-                    (struct sock *)ptype->af_packet_priv != skb->sk)) {
+                       (((struct sock *)ptype->af_packet_priv != skb->sk)
+                       &&
+                        /* MISSING CHECK: af_packet_priv  skb->sk one of the socket in fanout id of skb */
+                       ! packet_sk_in_fanout(ptype, skb->sk)
+                        )
+                       ) {
                        if (pt_prev) {
                                deliver_skb(skb2, pt_prev, skb->dev);
                                pt_prev = ptype;

If this is done, we will have to export one function from the af_packet
module and I don't like the idea. If it is correct way to do it I can
implement this and propose a patch.

BR,
-- 
Eric Leblond 
Blog: http://home.regit.org/ - Portfolio: http://regit.500px.com/

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

end of thread, other threads:[~2012-08-20  9:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-06 14:21 [BUG] af_packet: loop at reception when using fanout Eric Leblond
2012-08-16 15:44 ` [RFC PATCH v1.0] af_packet: don't emit packet on orig fanout group Eric Leblond
2012-08-16 21:52   ` David Miller
2012-08-16 21:52     ` David Miller
2012-08-17  8:02       ` [PATCH v1.1] " Eric Leblond
2012-08-20  9:37         ` David Miller
2012-08-17  8:03     ` [RFC PATCH v1.0] " Ying Xue

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