forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
af_packet: don't emit packet on orig fanout group
If a packet is emitted on one socket in one group of fanout sockets, it is transmitted again. It is thus read again on one of the sockets of the fanout group. This result in a loop for software which generate packets when receiving one. This retransmission is not the intended behavior: a fanout group must behave like a single socket. The packet should not be transmitted on a socket if it originates from a socket belonging to the same fanout group. This patch fixes the issue by changing the transmission check to take fanout group info account. Reported-by: Aleksandr Kotov <[email protected]> Signed-off-by: Eric Leblond <[email protected]> Signed-off-by: David S. Miller <[email protected]>
Showing
3 changed files
with
25 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1642,6 +1642,19 @@ static inline int deliver_skb(struct sk_buff *skb, | |
return pt_prev->func(skb, skb->dev, pt_prev, orig_dev); | ||
} | ||
|
||
static inline bool skb_loop_sk(struct packet_type *ptype, struct sk_buff *skb) | ||
{ | ||
if (ptype->af_packet_priv == NULL) | ||
return false; | ||
|
||
if (ptype->id_match) | ||
return ptype->id_match(ptype, skb->sk); | ||
else if ((struct sock *)ptype->af_packet_priv == skb->sk) | ||
return true; | ||
|
||
return false; | ||
} | ||
|
||
/* | ||
* Support routine. Sends outgoing frames to any network | ||
* taps currently in use. | ||
|
@@ -1659,8 +1672,7 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev) | |
* they originated from - MvS ([email protected]) | ||
*/ | ||
if ((ptype->dev == dev || !ptype->dev) && | ||
(ptype->af_packet_priv == NULL || | ||
(struct sock *)ptype->af_packet_priv != skb->sk)) { | ||
(!skb_loop_sk(ptype, skb))) { | ||
if (pt_prev) { | ||
deliver_skb(skb2, pt_prev, skb->dev); | ||
pt_prev = ptype; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters