netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] bridge: ebtables: fix reception of frames DNAT-ed to bridge device
@ 2017-03-15  3:18 Linus Lüssing
  2017-03-15 10:26 ` Florian Westphal
  2017-03-15 10:34 ` Pablo Neira Ayuso
  0 siblings, 2 replies; 12+ messages in thread
From: Linus Lüssing @ 2017-03-15  3:18 UTC (permalink / raw)
  To: netdev
  Cc: bridge, linux-kernel, coreteam, netfilter-devel,
	Jozsef Kadlecsik, David S . Miller, Pablo Neira Ayuso

When trying to redirect bridged frames to the bridge device itself
via the ebtables nat-prerouting chain and the dnat target then this
currently fails:

The ethernet destination of the frame is dnat'ed to the MAC address of
the bridge itself just fine and the correctly altered frame can even
be captured via a tcpdump on br0 (with or without promisc mode).

However, the IP code drops it in the beginning of ip_input.c/ip_rcv()
as the dnat target did not update the skb->pkt_type. If after
dnat'ing the packet is now destined to us then the skb->pkt_type
needs to be updated from PACKET_OTHERHOST to PACKET_HOST, too.

Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
---
 net/bridge/br_input.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
index 013f2290b..ec83175 100644
--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
@@ -198,8 +198,12 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb
 	if (dst) {
 		unsigned long now = jiffies;
 
-		if (dst->is_local)
+		if (dst->is_local) {
+			/* fix up potential DNAT mess */
+			skb->pkt_type = PACKET_HOST;
+
 			return br_pass_frame_up(skb);
+		}
 
 		if (now != dst->used)
 			dst->used = now;
-- 
2.1.4

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

end of thread, other threads:[~2017-03-21 10:11 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-15  3:18 [PATCH net] bridge: ebtables: fix reception of frames DNAT-ed to bridge device Linus Lüssing
2017-03-15 10:26 ` Florian Westphal
2017-03-15 10:42   ` Pablo Neira Ayuso
2017-03-15 14:27     ` Linus Lüssing
2017-03-15 18:15       ` Pablo Neira Ayuso
2017-03-15 21:16         ` Linus Lüssing
2017-03-15 22:06           ` Pablo Neira Ayuso
2017-03-17 13:10             ` Pablo Neira Ayuso
2017-03-19 16:55               ` Linus Lüssing
2017-03-21  0:09                 ` Linus Lüssing
2017-03-21 10:11                   ` Pablo Neira Ayuso
2017-03-15 10:34 ` Pablo Neira Ayuso

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