All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch net] loopback: explicitly set pkt_type to PACKET_HOST
@ 2014-05-14 18:39 Cong Wang
  2014-05-14 21:24 ` Cong Wang
  2014-05-15 20:34 ` David Miller
  0 siblings, 2 replies; 6+ messages in thread
From: Cong Wang @ 2014-05-14 18:39 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Eric W. Biederman, Cong Wang, Cong Wang

From: Cong Wang <cwang@twopensource.com>

In a corner case where I redirect the packets from veth to lo,
packets are dropped silently when entering IP stack. This is
due to we have a different MAC addr on veth, so the packets are
marked as PACKET_OTHERHOST. And after they are redirect to lo,
this value is kept since lo has the same MAC addr with the packets.
Loopback should explicitly set it to PACKET_HOST before calling
eth_type_trans() for this specific case.

Cc: David S. Miller <davem@davemloft.net>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Cong Wang <cwang@twopensource.com>

---
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index bb96409..52b6625 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -81,6 +81,7 @@ static netdev_tx_t loopback_xmit(struct sk_buff *skb,
 	 */
 	skb_dst_force(skb);
 
+	skb->pkt_type = PACKET_HOST;
 	skb->protocol = eth_type_trans(skb, dev);
 
 	/* it's OK to use per_cpu_ptr() because BHs are off */

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

* Re: [Patch net] loopback: explicitly set pkt_type to PACKET_HOST
  2014-05-14 18:39 [Patch net] loopback: explicitly set pkt_type to PACKET_HOST Cong Wang
@ 2014-05-14 21:24 ` Cong Wang
  2014-05-15 20:34 ` David Miller
  1 sibling, 0 replies; 6+ messages in thread
From: Cong Wang @ 2014-05-14 21:24 UTC (permalink / raw)
  To: Linux Kernel Network Developers
  Cc: David S. Miller, Eric W. Biederman, Cong Wang, Cong Wang

On Wed, May 14, 2014 at 11:39 AM, Cong Wang <xiyou.wangcong@gmail.com> wrote:
> From: Cong Wang <cwang@twopensource.com>
>
> In a corner case where I redirect the packets from veth to lo,
> packets are dropped silently when entering IP stack. This is
> due to we have a different MAC addr on veth, so the packets are
> marked as PACKET_OTHERHOST. And after they are redirect to lo,
> this value is kept since lo has the same MAC addr with the packets.
> Loopback should explicitly set it to PACKET_HOST before calling
> eth_type_trans() for this specific case.
>

Note, I am not quite sure about this. There might be some other case
we xmit a packet with !PACKET_HOST via loopback?

PACKET_BROADCAST, PACKET_MULTICAST and PACKET_OTHERHOST
could be fixed up by eth_type_trans().

PACKET_USER and PACKET_KERNEL are only used by netlink.

PACKET_FASTROUTE is unused.

PACKET_OUTGOING seems only used by packet socket and decnet.

PACKET_LOOPBACK is used by multicast but should completely skip loopback
device via dev_loopback_xmit().

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

* Re: [Patch net] loopback: explicitly set pkt_type to PACKET_HOST
  2014-05-14 18:39 [Patch net] loopback: explicitly set pkt_type to PACKET_HOST Cong Wang
  2014-05-14 21:24 ` Cong Wang
@ 2014-05-15 20:34 ` David Miller
  2014-05-16 17:52   ` Cong Wang
  1 sibling, 1 reply; 6+ messages in thread
From: David Miller @ 2014-05-15 20:34 UTC (permalink / raw)
  To: xiyou.wangcong; +Cc: netdev, ebiederm, cwang

From: Cong Wang <xiyou.wangcong@gmail.com>
Date: Wed, 14 May 2014 11:39:22 -0700

> From: Cong Wang <cwang@twopensource.com>
> 
> In a corner case where I redirect the packets from veth to lo,
> packets are dropped silently when entering IP stack. This is
> due to we have a different MAC addr on veth, so the packets are
> marked as PACKET_OTHERHOST. And after they are redirect to lo,
> this value is kept since lo has the same MAC addr with the packets.
> Loopback should explicitly set it to PACKET_HOST before calling
> eth_type_trans() for this specific case.
> 
> Cc: David S. Miller <davem@davemloft.net>
> Cc: "Eric W. Biederman" <ebiederm@xmission.com>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
> Signed-off-by: Cong Wang <cwang@twopensource.com>

How exactly are you performing this redirection?

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

* Re: [Patch net] loopback: explicitly set pkt_type to PACKET_HOST
  2014-05-15 20:34 ` David Miller
@ 2014-05-16 17:52   ` Cong Wang
  2014-05-16 19:17     ` David Miller
  0 siblings, 1 reply; 6+ messages in thread
From: Cong Wang @ 2014-05-16 17:52 UTC (permalink / raw)
  To: David Miller
  Cc: Linux Kernel Network Developers, Eric W. Biederman, Cong Wang

On Thu, May 15, 2014 at 1:34 PM, David Miller <davem@davemloft.net> wrote:
> From: Cong Wang <xiyou.wangcong@gmail.com>
> Date: Wed, 14 May 2014 11:39:22 -0700
>
>> From: Cong Wang <cwang@twopensource.com>
>>
>> In a corner case where I redirect the packets from veth to lo,
>> packets are dropped silently when entering IP stack. This is
>> due to we have a different MAC addr on veth, so the packets are
>> marked as PACKET_OTHERHOST. And after they are redirect to lo,
>> this value is kept since lo has the same MAC addr with the packets.
>> Loopback should explicitly set it to PACKET_HOST before calling
>> eth_type_trans() for this specific case.
>>
>> Cc: David S. Miller <davem@davemloft.net>
>> Cc: "Eric W. Biederman" <ebiederm@xmission.com>
>> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
>> Signed-off-by: Cong Wang <cwang@twopensource.com>
>
> How exactly are you performing this redirection?

Oh, I meant using tc mirred action to redirect packets from vethX to lo.
Sorry for confusing.

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

* Re: [Patch net] loopback: explicitly set pkt_type to PACKET_HOST
  2014-05-16 17:52   ` Cong Wang
@ 2014-05-16 19:17     ` David Miller
  2014-05-16 20:57       ` Cong Wang
  0 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2014-05-16 19:17 UTC (permalink / raw)
  To: xiyou.wangcong; +Cc: netdev, ebiederm, cwang

From: Cong Wang <xiyou.wangcong@gmail.com>
Date: Fri, 16 May 2014 10:52:09 -0700

> On Thu, May 15, 2014 at 1:34 PM, David Miller <davem@davemloft.net> wrote:
>> From: Cong Wang <xiyou.wangcong@gmail.com>
>> Date: Wed, 14 May 2014 11:39:22 -0700
>>
>>> From: Cong Wang <cwang@twopensource.com>
>>>
>>> In a corner case where I redirect the packets from veth to lo,
>>> packets are dropped silently when entering IP stack. This is
>>> due to we have a different MAC addr on veth, so the packets are
>>> marked as PACKET_OTHERHOST. And after they are redirect to lo,
>>> this value is kept since lo has the same MAC addr with the packets.
>>> Loopback should explicitly set it to PACKET_HOST before calling
>>> eth_type_trans() for this specific case.
>>>
>>> Cc: David S. Miller <davem@davemloft.net>
>>> Cc: "Eric W. Biederman" <ebiederm@xmission.com>
>>> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
>>> Signed-off-by: Cong Wang <cwang@twopensource.com>
>>
>> How exactly are you performing this redirection?
> 
> Oh, I meant using tc mirred action to redirect packets from vethX to lo.
> Sorry for confusing.

I think you can't expect arbitrary redirection of packets from an outgoing
interface back into the stack via loopback to work like that.

The is never any legitimate reason in this type of flow to override the
decisions made by eth_type_trans() as to the disposition of the packet type.

I'm not applying this, sorry.

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

* Re: [Patch net] loopback: explicitly set pkt_type to PACKET_HOST
  2014-05-16 19:17     ` David Miller
@ 2014-05-16 20:57       ` Cong Wang
  0 siblings, 0 replies; 6+ messages in thread
From: Cong Wang @ 2014-05-16 20:57 UTC (permalink / raw)
  To: David Miller
  Cc: Linux Kernel Network Developers, Eric W. Biederman, Cong Wang

On Fri, May 16, 2014 at 12:17 PM, David Miller <davem@davemloft.net> wrote:
> From: Cong Wang <xiyou.wangcong@gmail.com>
>> Oh, I meant using tc mirred action to redirect packets from vethX to lo.
>> Sorry for confusing.
>
> I think you can't expect arbitrary redirection of packets from an outgoing
> interface back into the stack via loopback to work like that.
>
> The is never any legitimate reason in this type of flow to override the
> decisions made by eth_type_trans() as to the disposition of the packet type.
>

Yeah, it's ok, probably setting the right mac on vethX is the real fix
to this problem in my case.

Thanks.

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

end of thread, other threads:[~2014-05-16 20:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-14 18:39 [Patch net] loopback: explicitly set pkt_type to PACKET_HOST Cong Wang
2014-05-14 21:24 ` Cong Wang
2014-05-15 20:34 ` David Miller
2014-05-16 17:52   ` Cong Wang
2014-05-16 19:17     ` David Miller
2014-05-16 20:57       ` Cong Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.