AF_PACKET + PACKET_FANOUT: tx packet delivered back in rx

2 messages, 2 authors, 2012-08-16 · open the first message on its own page

AF_PACKET + PACKET_FANOUT: tx packet delivered back in rx

From: Aleksandr Kotov <hidden>
Date: 2012-07-12 09:07:42

I have a problem using AF_PACKET socket with PACKET_RX_RING, PACKET_TX_RING and PACKET_FANOUT options enabled.
I am seeing my TX packets get back to the same socket in RX ring. Socket is created and gets bind with ETH_P_ALL protocol type. The problem is in the fanout_add function 
which sets af_packet_priv to "match" variable, but not sk one describing socket and in dev_queue_xmit_nit skb get bounced back to the socket despite the comment left in the function.

fanout_add(struct sock *sk, u16 id, u16 type_flags)
    ....
     match->prot_hook.af_packet_priv = match;
    ....

dev_queue_xmit_nit
       list_for_each_entry_rcu(ptype, &ptype_all, list) {
                /* Never send packets back to the socket
                 * they originated from - MvS (miquels@drinkel.ow.org)
                 */
                if ((ptype->dev == dev || !ptype->dev) &&
                    (ptype->af_packet_priv == NULL ||
                     (struct sock *)ptype->af_packet_priv != skb->sk)) {

As said in David Miller comment for PACKET_FANOUT patch:

"The implementation is agnostic to the type of AF_PACKET sockets in
use.  You can use _mmap_ based, and non-mmap based, AF_PACKET sockets.
It simply doesn't care."
So I think it is legal to used mmaped AF_PACKET/.


Is there any way to use it correctly with packets not mirroring in rx? 

Best regard, Aleksandr Kotov

-- 

Re: AF_PACKET + PACKET_FANOUT: tx packet delivered back in rx

From: David Miller <davem@davemloft.net>
Date: 2012-08-16 21:53:23

From: Aleksandr Kotov <redacted>
Date: Thu, 12 Jul 2012 12:30:17 +0400
I have a problem using AF_PACKET socket with PACKET_RX_RING, PACKET_TX_RING and PACKET_FANOUT options enabled.
I am seeing my TX packets get back to the same socket in RX ring. Socket is created and gets bind with ETH_P_ALL protocol type. The problem is in the fanout_add function 
which sets af_packet_priv to "match" variable, but not sk one describing socket and in dev_queue_xmit_nit skb get bounced back to the socket despite the comment left in the function.
Eric Leblong is posting fixes for this problem recently:

http://patchwork.ozlabs.org/patch/178044/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help