Message ID | 1400092762-23287-1-git-send-email-xiyou.wangcong@gmail.com |
---|---|
State | Rejected, archived |
Delegated to: | David Miller |
Headers | show |
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(). -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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? -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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 */