From: Guillaume Nault <gnault@redhat.com>
To: David Miller <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org,
Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
David Ahern <dsahern@kernel.org>,
Simon Horman <simon.horman@netronome.com>
Subject: [PATCH net-next 3/6] sit: allow redirecting ip6ip, ipip and mplsip packets to eth devices
Date: Fri, 25 Jun 2021 15:33:08 +0200 [thread overview]
Message-ID: <741ee403015d9241d8005978fc71309930d921ce.1624572003.git.gnault@redhat.com> (raw)
In-Reply-To: <cover.1624572003.git.gnault@redhat.com>
Even though sit transports L3 data (IPv6, IPv4 or MPLS) packets, it
needs to reset the mac_header pointer, so that other parts of the stack
don't mistakenly access the outer header after the packet has been
decapsulated. There are two rx handlers to modify: ipip6_rcv() for the
ip6ip mode and sit_tunnel_rcv() which is used to re-implement the ipip
and mplsip modes of ipip.ko.
This allows to push an Ethernet header to sit packets and redirect
them to an Ethernet device:
$ tc filter add dev sit0 ingress matchall \
action vlan push_eth dst_mac 00:00:5e:00:53:01 \
src_mac 00:00:5e:00:53:00 \
action mirred egress redirect dev eth0
Without this patch, push_eth refuses to add an ethernet header because
the skb appears to already have a MAC header.
Signed-off-by: Guillaume Nault <gnault@redhat.com>
---
net/ipv6/sit.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index e0a39b0bb4c1..df5bea818410 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -710,6 +710,8 @@ static int ipip6_rcv(struct sk_buff *skb)
* old iph is no longer valid
*/
iph = (const struct iphdr *)skb_mac_header(skb);
+ skb_reset_mac_header(skb);
+
err = IP_ECN_decapsulate(iph, skb);
if (unlikely(err)) {
if (log_ecn_error)
@@ -780,6 +782,8 @@ static int sit_tunnel_rcv(struct sk_buff *skb, u8 ipproto)
tpi = &ipip_tpi;
if (iptunnel_pull_header(skb, 0, tpi->proto, false))
goto drop;
+ skb_reset_mac_header(skb);
+
return ip_tunnel_rcv(tunnel, skb, tpi, NULL, log_ecn_error);
}
--
2.21.3
next prev parent reply other threads:[~2021-06-25 13:33 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-25 13:32 [PATCH net-next 0/6] net: reset MAC header consistently across L3 virtual devices Guillaume Nault
2021-06-25 13:33 ` [PATCH net-next 1/6] bareudp: allow redirecting bareudp packets to eth devices Guillaume Nault
2021-06-25 13:33 ` [PATCH net-next 2/6] ipip: allow redirecting ipip and mplsip " Guillaume Nault
2021-06-25 13:33 ` Guillaume Nault [this message]
2021-06-25 13:33 ` [PATCH net-next 4/6] gre: let mac_header point to outer header only when necessary Guillaume Nault
2021-06-25 13:33 ` [PATCH net-next 5/6] ip6_tunnel: allow redirecting ip6gre and ipxip6 packets to eth devices Guillaume Nault
2021-06-25 13:33 ` [PATCH net-next 6/6] gtp: reset mac_header after decap Guillaume Nault
2021-06-26 17:50 ` [PATCH net-next 0/6] net: reset MAC header consistently across L3 virtual devices David Ahern
2021-06-26 20:53 ` Guillaume Nault
2021-06-27 15:56 ` David Ahern
2021-06-28 15:04 ` Guillaume Nault
2021-06-28 18:46 ` David Ahern
2021-06-28 20:40 ` Guillaume Nault
2021-06-28 20:10 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=741ee403015d9241d8005978fc71309930d921ce.1624572003.git.gnault@redhat.com \
--to=gnault@redhat.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=simon.horman@netronome.com \
--cc=yoshfuji@linux-ipv6.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).