* [PATCH net-next v7 1/5] erspan: bound the VLAN tag read in erspan_build_header{,_v2}()
2026-12-01 0:59 [PATCH net-next v7 0/5] ip6_gre, erspan: fix inner header handling for VLAN-tagged and short frames Anton Danilov
@ 2026-12-01 0:59 ` Anton Danilov
2026-12-01 0:59 ` [PATCH net-next v7 2/5] erspan: take the COS from the mirrored frame, not from the tunnel family Anton Danilov
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Anton Danilov @ 2026-12-01 0:59 UTC (permalink / raw)
To: netdev
Cc: Eric Dumazet, Jakub Kicinski, Paolo Abeni, David S. Miller,
Simon Horman, David Ahern, Willem de Bruijn, Ido Schimmel,
Florian Westphal, William Tu, Meenakshi Vohra, Matthias May,
Mazin Al Haddad, Shuah Khan, linux-kselftest, linux-kernel
erspan_build_header() and erspan_build_header_v2() decide whether the
mirrored frame is VLAN tagged by reading the EtherType at offset 12
and, for ETH_P_8021Q, the TCI at offset 14, without checking that the
frame is that long. Shorter frames do reach them: the transmit paths
check the length with pskb_inet_may_pull_reason() on IPv4 and
pskb_inet_may_pull() on IPv6. These only make sure that the IPv4 or
IPv6 header announced by skb->protocol is there. A frame
that announces anything else gets through, whatever its length.
syzbot reported the EtherType read for a short frame redirected into
an erspan device by bpf. It does not take bpf: a 10 byte frame
redirected into erspan or ip6erspan by tc mirred from a tun device
gives "KMSAN: uninit-value in erspan_build_header".
The TCI read has the same problem two bytes further on. A 14 byte
frame that ends right after the 0x8100 EtherType gets two bytes from
past its end copied into the VLAN field of the ERSPAN header, and KMSAN
reports them when the packet is received on the other side.
Read both fields with skb_header_pointer(), so that a frame too short
to carry a tag is treated as untagged.
The TCI read was found by an AI code review agent, in a review of
another series that touches these functions. Both reads were confirmed
in a VM on an unmodified kernel built with KMSAN, with the two frames
above. With this patch and the next one, which bounds the remaining
read of this kind, the same frames give no report on erspan.
Fixes: 84e54fe0a5ea ("gre: introduce native tunnel support for ERSPAN")
Fixes: f551c91de262 ("net: erspan: introduce erspan v2 for ip_gre")
Reported-by: syzbot+9e27778c0edc62cb97d8@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=9e27778c0edc62cb97d8
Signed-off-by: Anton Danilov <littlesmilingcloud@gmail.com>
---
include/net/erspan.h | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/include/net/erspan.h b/include/net/erspan.h
index c6209e7b6c96..6bda757b6da2 100644
--- a/include/net/erspan.h
+++ b/include/net/erspan.h
@@ -174,13 +174,12 @@ static inline void erspan_build_header(struct sk_buff *skb,
u32 id, u32 index,
bool truncate, bool is_ipv4)
{
- struct ethhdr *eth = (struct ethhdr *)skb->data;
enum erspan_encap_type enc_type;
struct erspan_base_hdr *ershdr;
struct qtag_prefix {
__be16 eth_type;
__be16 tci;
- } *qp;
+ } *qp, _qp;
u16 vlan_tci = 0;
u8 tos;
__be32 *idx;
@@ -194,8 +193,8 @@ static inline void erspan_build_header(struct sk_buff *skb,
/* If mirrored packet has vlan tag, extract tci and
* preserve vlan header in the mirrored frame.
*/
- if (eth->h_proto == htons(ETH_P_8021Q)) {
- qp = (struct qtag_prefix *)(skb->data + 2 * ETH_ALEN);
+ qp = skb_header_pointer(skb, 2 * ETH_ALEN, sizeof(_qp), &_qp);
+ if (qp && qp->eth_type == htons(ETH_P_8021Q)) {
vlan_tci = ntohs(qp->tci);
enc_type = ERSPAN_ENCAP_INFRAME;
}
@@ -268,13 +267,12 @@ static inline void erspan_build_header_v2(struct sk_buff *skb,
u32 id, u8 direction, u16 hwid,
bool truncate, bool is_ipv4)
{
- struct ethhdr *eth = (struct ethhdr *)skb->data;
struct erspan_base_hdr *ershdr;
struct erspan_md2 *md2;
struct qtag_prefix {
__be16 eth_type;
__be16 tci;
- } *qp;
+ } *qp, _qp;
u16 vlan_tci = 0;
u8 gra = 0; /* 100 usec */
u8 bso = 0; /* Bad/Short/Oversized */
@@ -288,10 +286,9 @@ static inline void erspan_build_header_v2(struct sk_buff *skb,
/* Unlike v1, v2 does not have En field,
* so only extract vlan tci field.
*/
- if (eth->h_proto == htons(ETH_P_8021Q)) {
- qp = (struct qtag_prefix *)(skb->data + 2 * ETH_ALEN);
+ qp = skb_header_pointer(skb, 2 * ETH_ALEN, sizeof(_qp), &_qp);
+ if (qp && qp->eth_type == htons(ETH_P_8021Q))
vlan_tci = ntohs(qp->tci);
- }
bso = erspan_detect_bso(skb);
skb_push(skb, sizeof(*ershdr) + ERSPAN_V2_MDSIZE);
--
2.47.3
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH net-next v7 2/5] erspan: take the COS from the mirrored frame, not from the tunnel family
2026-12-01 0:59 [PATCH net-next v7 0/5] ip6_gre, erspan: fix inner header handling for VLAN-tagged and short frames Anton Danilov
2026-12-01 0:59 ` [PATCH net-next v7 1/5] erspan: bound the VLAN tag read in erspan_build_header{,_v2}() Anton Danilov
@ 2026-12-01 0:59 ` Anton Danilov
2026-12-01 0:59 ` [PATCH net-next v7 3/5] ip6_gre: classify the inner packet once on transmit Anton Danilov
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Anton Danilov @ 2026-12-01 0:59 UTC (permalink / raw)
To: netdev
Cc: Eric Dumazet, Jakub Kicinski, Paolo Abeni, David S. Miller,
Simon Horman, David Ahern, Willem de Bruijn, Ido Schimmel,
Florian Westphal, William Tu, Meenakshi Vohra, Matthias May,
Mazin Al Haddad, Shuah Khan, linux-kselftest, linux-kernel
erspan_build_header() and erspan_build_header_v2() take the TOS for
the COS field from ip_hdr(skb)->tos when the tunnel is IPv4 and from
the IPv6 traffic class when the tunnel is IPv6. But is_ipv4 describes
the tunnel, not the mirrored frame, so
- an IPv4 frame mirrored to ip6erspan gets its COS from the IPv4
version/IHL byte and the high TOS nibble: always 2, whatever the
DSCP;
- an IPv6 frame mirrored to erspan gets its COS from the low nibble
of the traffic class: 4 instead of 5 for EF;
- a frame that is neither gets its COS from whatever lies at the
network header offset, which for a short frame is past its end.
Pick the IP version by the frame instead: by skb->protocol or, when
that is a VLAN type, by the version field at the network header. Read
the two bytes that hold the TOS or traffic class with
skb_header_pointer(). Return COS 0 if those bytes are unavailable or
the protocol is not recognized as IPv4 or IPv6 by this rule.
Keep the existing DSCP-to-COS mapping. This change bounds the reads
and removes the tunnel family from the interpretation of the inner
IP header; it does not introduce a new QoS policy based on VLAN PCP, MPLS
TC or skb->priority. The latter is a queueing priority, not necessarily
a three-bit class of service, and would need an explicit mapping.
For skb->protocol carrying a VLAN type, the version field is only a
heuristic, not validation of the encapsulated protocol. A non-IP
payload such as an MPLS label can begin with the same nibble as IPv4
or IPv6 and still produce a nonzero COS. Its COS can also differ from
the old tunnel-family-based result. Classifying arbitrary non-IP
VLAN payloads is outside this change; no COS 0 guarantee is made for
them. The two-byte read is bounded regardless of that classification.
The TOS is still read at the network header. That is where the stack,
tc mirred and packet sockets leave the IP header, also for frames that
do not start with an Ethernet header and its tags, such as a packet
mirrored from an L3 device or a frame behind a switch tag mirrored
from a DSA conduit. Where the network header is not on the IP header
the COS stays wrong, as do the other fields read there; one such case
is a tagged frame written by a packet socket under an IP sll_protocol,
whose network header is on the tag.
Drop the is_ipv4 argument, and with it the stale forward declaration
of erspan_build_header() in ip_gre.c, which would have had to follow.
The wrong COS and the read past the end were found by an AI code
review agent, in a review of another series that touches these
functions, and confirmed in a VM on an unmodified kernel:
- EF (DSCP 46) frames mirrored with tc from a veth give COS 2 for
IPv4 over ip6erspan v1 and v2, COS 4 for IPv6 over erspan v1 and
v2, and COS 5 in the other four combinations. With the patch all
eight give COS 5. So do the same frames with the EtherType at
offset 12 overwritten by tc pedit as a switch tag would, sent
through a VLAN device, and IP packets mirrored from a tun device:
48 cases in all;
- a 14 byte non-IP frame gives a KMSAN report when the packet is
received on the other side; with the patch it does not.
Signed-off-by: Anton Danilov <littlesmilingcloud@gmail.com>
---
include/net/erspan.h | 53 ++++++++++++++++++++++++++++++++++++--------
net/ipv4/ip_gre.c | 13 ++++-------
net/ipv6/ip6_gre.c | 10 ++++-----
3 files changed, 52 insertions(+), 24 deletions(-)
diff --git a/include/net/erspan.h b/include/net/erspan.h
index 6bda757b6da2..c272b3fb9bfd 100644
--- a/include/net/erspan.h
+++ b/include/net/erspan.h
@@ -58,9 +58,11 @@
* GRE proto ERSPAN type I/II = 0x88BE, type III = 0x22EB
*/
+#include <linux/if_vlan.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <linux/skbuff.h>
+#include <net/dsfield.h>
#include <uapi/linux/erspan.h>
#define ERSPAN_VERSION 0x1 /* ERSPAN type II */
@@ -170,9 +172,46 @@ static inline u8 tos_to_cos(u8 tos)
return cos;
}
+/* TOS of the mirrored frame, for the COS field, read at the network
+ * header. The IP version comes from skb->protocol or, for a VLAN type,
+ * from the version field there, and not from the tunnel family. The
+ * bytes are read with skb_header_pointer(), so a frame that does not
+ * have them gets 0.
+ */
+static inline u8 erspan_frame_tos(const struct sk_buff *skb)
+{
+ /* Align the two-byte buffer as struct iphdr, since
+ * skb_header_pointer() may return its address as iph.
+ */
+ __be16 _prefix __aligned(__alignof__(struct iphdr));
+ int offset = skb_network_offset(skb);
+ __be16 type = skb->protocol;
+ const struct iphdr *iph;
+
+ if (offset < 0)
+ return 0;
+
+ /* Version and DS field fit in the first 16 bits of either IP header. */
+ iph = skb_header_pointer(skb, offset, sizeof(_prefix), &_prefix);
+ if (!iph)
+ return 0;
+
+ if (eth_type_vlan(type)) {
+ if (iph->version == 4)
+ type = htons(ETH_P_IP);
+ else if (iph->version == 6)
+ type = htons(ETH_P_IPV6);
+ }
+
+ if (type == htons(ETH_P_IP))
+ return iph->tos;
+ if (type == htons(ETH_P_IPV6))
+ return ipv6_get_dsfield((const struct ipv6hdr *)iph);
+ return 0;
+}
+
static inline void erspan_build_header(struct sk_buff *skb,
- u32 id, u32 index,
- bool truncate, bool is_ipv4)
+ u32 id, u32 index, bool truncate)
{
enum erspan_encap_type enc_type;
struct erspan_base_hdr *ershdr;
@@ -184,9 +223,7 @@ static inline void erspan_build_header(struct sk_buff *skb,
u8 tos;
__be32 *idx;
- tos = is_ipv4 ? ip_hdr(skb)->tos :
- (ipv6_hdr(skb)->priority << 4) +
- (ipv6_hdr(skb)->flow_lbl[0] >> 4);
+ tos = erspan_frame_tos(skb);
enc_type = ERSPAN_ENCAP_NOVLAN;
@@ -265,7 +302,7 @@ static inline u8 erspan_detect_bso(struct sk_buff *skb)
static inline void erspan_build_header_v2(struct sk_buff *skb,
u32 id, u8 direction, u16 hwid,
- bool truncate, bool is_ipv4)
+ bool truncate)
{
struct erspan_base_hdr *ershdr;
struct erspan_md2 *md2;
@@ -279,9 +316,7 @@ static inline void erspan_build_header_v2(struct sk_buff *skb,
u8 sgt = 0;
u8 tos;
- tos = is_ipv4 ? ip_hdr(skb)->tos :
- (ipv6_hdr(skb)->priority << 4) +
- (ipv6_hdr(skb)->flow_lbl[0] >> 4);
+ tos = erspan_frame_tos(skb);
/* Unlike v1, v2 does not have En field,
* so only extract vlan tci field.
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index b9754272b1c9..d31252090d87 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -111,9 +111,6 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly;
static const struct header_ops ipgre_header_ops;
static int ipgre_tunnel_init(struct net_device *dev);
-static void erspan_build_header(struct sk_buff *skb,
- u32 id, u32 index,
- bool truncate, bool is_ipv4);
static unsigned int ipgre_net_id __read_mostly;
static unsigned int gre_tap_net_id __read_mostly;
@@ -630,14 +627,14 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev)
if (version == 1) {
erspan_build_header(skb, ntohl(tunnel_id_to_key32(key->tun_id)),
- ntohl(md->u.index), truncate, true);
+ ntohl(md->u.index), truncate);
proto = htons(ETH_P_ERSPAN);
} else if (version == 2) {
erspan_build_header_v2(skb,
ntohl(tunnel_id_to_key32(key->tun_id)),
md->u.md2.dir,
get_hwid(&md->u.md2),
- truncate, true);
+ truncate);
proto = htons(ETH_P_ERSPAN2);
} else {
reason = SKB_DROP_REASON_UNHANDLED_PROTO;
@@ -790,13 +787,11 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,
__clear_bit(IP_TUNNEL_SEQ_BIT, flags);
} else if (tunnel->erspan_ver == 1) {
erspan_build_header(skb, ntohl(tunnel->parms.o_key),
- tunnel->index,
- truncate, true);
+ tunnel->index, truncate);
proto = htons(ETH_P_ERSPAN);
} else if (tunnel->erspan_ver == 2) {
erspan_build_header_v2(skb, ntohl(tunnel->parms.o_key),
- tunnel->dir, tunnel->hwid,
- truncate, true);
+ tunnel->dir, tunnel->hwid, truncate);
proto = htons(ETH_P_ERSPAN2);
} else {
reason = SKB_DROP_REASON_UNHANDLED_PROTO;
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 726636d7815b..d8e239a96841 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -1019,15 +1019,14 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
if (md->version == 1) {
erspan_build_header(skb,
ntohl(tun_id),
- ntohl(md->u.index), truncate,
- false);
+ ntohl(md->u.index), truncate);
proto = htons(ETH_P_ERSPAN);
} else if (md->version == 2) {
erspan_build_header_v2(skb,
ntohl(tun_id),
md->u.md2.dir,
get_hwid(&md->u.md2),
- truncate, false);
+ truncate);
proto = htons(ETH_P_ERSPAN2);
} else {
goto tx_err;
@@ -1053,14 +1052,13 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
if (t->parms.erspan_ver == 1) {
erspan_build_header(skb, ntohl(t->parms.o_key),
- t->parms.index,
- truncate, false);
+ t->parms.index, truncate);
proto = htons(ETH_P_ERSPAN);
} else if (t->parms.erspan_ver == 2) {
erspan_build_header_v2(skb, ntohl(t->parms.o_key),
t->parms.dir,
t->parms.hwid,
- truncate, false);
+ truncate);
proto = htons(ETH_P_ERSPAN2);
} else {
goto tx_err;
--
2.47.3
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH net-next v7 3/5] ip6_gre: classify the inner packet once on transmit
2026-12-01 0:59 [PATCH net-next v7 0/5] ip6_gre, erspan: fix inner header handling for VLAN-tagged and short frames Anton Danilov
2026-12-01 0:59 ` [PATCH net-next v7 1/5] erspan: bound the VLAN tag read in erspan_build_header{,_v2}() Anton Danilov
2026-12-01 0:59 ` [PATCH net-next v7 2/5] erspan: take the COS from the mirrored frame, not from the tunnel family Anton Danilov
@ 2026-12-01 0:59 ` Anton Danilov
2026-12-01 0:59 ` [PATCH net-next v7 4/5] ip6_gre: go by the inner protocol behind VLAN tags in ip6erspan Anton Danilov
2026-12-01 0:59 ` [PATCH net-next v7 5/5] selftests: net: add a test for ip6gretap and ip6erspan with VLAN tags Anton Danilov
4 siblings, 0 replies; 6+ messages in thread
From: Anton Danilov @ 2026-12-01 0:59 UTC (permalink / raw)
To: netdev
Cc: Eric Dumazet, Jakub Kicinski, Paolo Abeni, David S. Miller,
Simon Horman, David Ahern, Willem de Bruijn, Ido Schimmel,
Florian Westphal, William Tu, Meenakshi Vohra, Matthias May,
Mazin Al Haddad, Shuah Khan, linux-kselftest, linux-kernel
ip6gre_tunnel_xmit() and ip6erspan_tunnel_xmit() work out what the
encapsulated packet carries in three places, each by its own rule:
- the length check, pskb_inet_may_pull(), goes by skb->protocol and
makes sure of an IPv4 or IPv6 header at the network header;
- the dispatch in ip6gre_tunnel_xmit() uses skb_protocol(skb, true),
which looks through VLAN tags from skb->data, at a depth taken from
skb->mac_len;
- ip6_tnl_xmit() calls skb_protocol(skb, true) again for the hop limit
to inherit, after the GRE and ERSPAN headers have been pushed, so
this walk starts inside those headers.
For a VLAN-tagged frame the three disagree:
- the check sees a VLAN type and pulls nothing, while the dispatch
finds IPv4 or IPv6 behind the tag and reads the inner header anyway.
A tagged frame too short for that header has it read from past its
end and is sent, while an untagged one is dropped (the syzbot report
below);
- the walk in ip6_tnl_xmit() lines up with the inner EtherType only on
ip6gretap with a 4 byte GRE header and skb->mac_len 0 or 18. With a
key, a checksum, a sequence number, another mac_len, or on
ip6erspan, it reads MAC address or ERSPAN bytes instead: the hop
limit is then not inherited, or, when those bytes read as ETH_P_IP
or ETH_P_IPV6, taken from wherever the network header points,
whatever the frame carries;
- skb->mac_len is no guide here: on transmit it is whatever the device
the skb was received on left, 14 forwarded, 18 from a VLAN device
with reorder_hdr off, 24 from an NBMA gre device, 0 for a local one.
Classify the packet once, on entry, and pass the result down:
- a non-VLAN skb->protocol is taken as it is, with the network header
where the sender left it and the same length check as before;
- a VLAN skb->protocol on ip6gretap and ip6erspan is resolved from the
frame, starting with the EtherType at offset 12 from skb->data,
where __vlan_get_protocol() starts once skb->mac_len is ETH_HLEN.
When the tags lead to IPv4 or IPv6, that header is pulled and the
network header is set on it, and a frame too short for it is dropped
as an untagged one is. Any other frame gets the same check as before
and is sent untouched, with no field taken from it;
- ip6gre has no Ethernet header at skb->data, so no tags are looked
for there and a VLAN skb->protocol is a protocol like any other.
ip6_tnl_xmit() takes the result as a new argument and no longer parses
the packet. ip6_tunnel's own devices pass skb->protocol: they send only
IPv4, IPv6 and MPLS, for which skb_protocol() returned just that.
What changes for traffic that was not broken before:
- the hop limit of a tagged frame is inherited on every ip6gretap and
ip6erspan device, not only on ip6gretap with a 4 byte GRE header and
mac_len 0 or 18;
- a frame that arrives with its network header on a VLAN tag (after tc
act_ife decode, a generic XDP redirect, or tc act_vlan push on an
already tagged frame) gets its traffic class from the IP header, not
from the TCI;
- a VLAN-typed skb on ip6gre, such as an Ethernet frame forwarded to
it by nft fwd, no longer has its traffic class taken through the tag;
its GRE protocol stays the VLAN type, with an Ethernet or mangled IP
header behind it, before and after.
The length check mismatch was reported by syzbot, the walk after the
push by the Sashiko review of v5, and the role of skb->mac_len by an AI
code review agent on an earlier version. All were confirmed in a VM on
an unmodified kernel:
- with KMSAN, an 18 byte tagged ARP frame written by a packet socket
to a keyed ip6gretap or an ip6erspan device, with bytes that read as
ETH_P_IP where the second walk lands, goes out with a hop limit from
past its end; with the patch it goes out with the route's hop limit
and the reports are gone;
- a 20 byte tagged IPv4 frame on a keyed ip6gretap is sent before the
patch and dropped with it;
- IPv4 packets with TTL 33 and hoplimit inherit were sent to ip6gretap
with and without a key and to ip6erspan v1 and v2, in 35 ways: local
stack, VLAN devices with reorder_hdr on and off, a bridge, tc mirred
from ingress and egress, bpf and generic XDP redirect, nft fwd,
packet sockets, act_vlan, act_pedit, act_ife, and a tun device.
Before the patch the tagged frames that reach the device with a VLAN
skb->protocol go out with hop limit 33 only on ip6gretap without a
key and only with skb->mac_len 0, 64 otherwise; with the patch all
go out with 33 on all four devices. Frames that reach with an IP
skb->protocol are unchanged.
gre_gso.sh, l2_tos_ttl_inherit.sh, ip6_gre_headroom.sh, ip6_tunnel.sh
and the mirror_gre and ip6gre forwarding selftests give the same
results before and after.
Fixes: 3f8a8447fd0b ("ip6_gre: use actual protocol to select xmit")
Fixes: b09ab9c92e50 ("ip6_tunnel: allow to inherit from VLAN encapsulated IP")
Reported-by: syzbot+6023ea32e206eef7920a@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=6023ea32e206eef7920a
Suggested-by: Eric Dumazet <edumazet@kernel.org>
Signed-off-by: Anton Danilov <littlesmilingcloud@gmail.com>
---
include/net/ip6_tunnel.h | 3 +-
net/ipv6/ip6_gre.c | 77 ++++++++++++++++++++++++++++++++++------
net/ipv6/ip6_tunnel.c | 9 +++--
3 files changed, 72 insertions(+), 17 deletions(-)
diff --git a/include/net/ip6_tunnel.h b/include/net/ip6_tunnel.h
index d1f0a427e9c8..50caf745a61b 100644
--- a/include/net/ip6_tunnel.h
+++ b/include/net/ip6_tunnel.h
@@ -144,7 +144,8 @@ int ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
int ip6_tnl_xmit_ctl(struct ip6_tnl *t, const struct in6_addr *laddr,
const struct in6_addr *raddr);
int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
- struct flowi6 *fl6, int encap_limit, __u32 *pmtu, __u8 proto);
+ struct flowi6 *fl6, int encap_limit, __u32 *pmtu, __u8 proto,
+ __be16 payload_protocol);
__u16 ip6_tnl_parse_tlv_enc_lim(struct sk_buff *skb, __u8 *raw);
__u32 ip6_tnl_get_cap(struct ip6_tnl *t, const struct in6_addr *laddr,
const struct in6_addr *raddr);
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index d8e239a96841..d7d7fd478200 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -730,7 +730,8 @@ static struct ip_tunnel_info *skb_tunnel_info_txcheck(struct sk_buff *skb)
static netdev_tx_t __gre6_xmit(struct sk_buff *skb,
struct net_device *dev, __u8 dsfield,
struct flowi6 *fl6, int encap_limit,
- __u32 *pmtu, __be16 proto)
+ __u32 *pmtu, __be16 proto,
+ __be16 payload_protocol)
{
struct ip6_tnl *tunnel = netdev_priv(dev);
IP_TUNNEL_DECLARE_FLAGS(flags);
@@ -797,7 +798,7 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb,
}
return ip6_tnl_xmit(skb, dev, dsfield, fl6, encap_limit, pmtu,
- NEXTHDR_GRE);
+ NEXTHDR_GRE, payload_protocol);
}
static inline int ip6gre_xmit_ipv4(struct sk_buff *skb, struct net_device *dev)
@@ -821,7 +822,7 @@ static inline int ip6gre_xmit_ipv4(struct sk_buff *skb, struct net_device *dev)
return -1;
err = __gre6_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu,
- skb->protocol);
+ skb->protocol, htons(ETH_P_IP));
if (err != 0) {
/* XXX: send ICMP error even if DF is not set. */
if (err == -EMSGSIZE)
@@ -860,7 +861,7 @@ static inline int ip6gre_xmit_ipv6(struct sk_buff *skb, struct net_device *dev)
return -1;
err = __gre6_xmit(skb, dev, dsfield, &fl6, encap_limit,
- &mtu, skb->protocol);
+ &mtu, skb->protocol, htons(ETH_P_IPV6));
if (err != 0) {
if (err == -EMSGSIZE)
icmpv6_ndo_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
@@ -870,7 +871,8 @@ static inline int ip6gre_xmit_ipv6(struct sk_buff *skb, struct net_device *dev)
return 0;
}
-static int ip6gre_xmit_other(struct sk_buff *skb, struct net_device *dev)
+static int ip6gre_xmit_other(struct sk_buff *skb, struct net_device *dev,
+ __be16 payload_protocol)
{
struct ip6_tnl *t = netdev_priv(dev);
int encap_limit = -1;
@@ -887,11 +889,64 @@ static int ip6gre_xmit_other(struct sk_buff *skb, struct net_device *dev)
t->parms.o_flags));
if (err)
return err;
- err = __gre6_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu, skb->protocol);
+ err = __gre6_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu,
+ skb->protocol, payload_protocol);
return err;
}
+/* Classify the payload once, on entry to ndo_start_xmit, and make sure
+ * that the header the answer stands for is in the linear area. Nothing
+ * below parses the frame again: the answer is passed down, also to
+ * ip6_tnl_xmit(). It is ETH_P_IP or ETH_P_IPV6 only when that header is
+ * at the network header.
+ *
+ * If skb->protocol is not a VLAN type, it and the network header are
+ * taken as the sender left them.
+ *
+ * If it is a VLAN type on an Ethernet device, the payload type is in the
+ * frame, behind the tags, and is read from there, starting with the
+ * EtherType at offset 12 from skb->data: that is where
+ * __vlan_get_protocol() starts when skb->mac_len is ETH_HLEN. The
+ * skb->mac_len the skb comes with is no guide, it is what the device it
+ * was received on left there, or 0. When the tags lead to IPv4 or IPv6,
+ * that header is pulled and the network header is set on it. Any other
+ * frame gets the same check as before and is sent as it is, with the
+ * network header left alone, and no field is taken from it.
+ *
+ * ip6gre has no Ethernet header at skb->data to find tags in, so a VLAN
+ * skb->protocol there is a protocol like any other.
+ */
+static enum skb_drop_reason
+ip6gre_xmit_classify(struct sk_buff *skb, const struct net_device *dev,
+ __be16 *payload_protocol)
+{
+ enum skb_drop_reason reason;
+ int depth, nhlen;
+ __be16 type;
+
+ *payload_protocol = skb->protocol;
+ if (dev->type != ARPHRD_ETHER || !eth_type_vlan(skb->protocol))
+ return pskb_inet_may_pull_reason(skb);
+
+ skb->mac_len = ETH_HLEN;
+ type = __vlan_get_protocol(skb, skb->protocol, &depth);
+ if (type == htons(ETH_P_IP))
+ nhlen = sizeof(struct iphdr);
+ else if (type == htons(ETH_P_IPV6))
+ nhlen = sizeof(struct ipv6hdr);
+ else
+ return pskb_inet_may_pull_reason(skb);
+
+ reason = pskb_may_pull_reason(skb, depth + nhlen);
+ if (reason)
+ return reason;
+
+ skb_set_network_header(skb, depth);
+ *payload_protocol = type;
+ return SKB_NOT_DROPPED_YET;
+}
+
static netdev_tx_t ip6gre_tunnel_xmit(struct sk_buff *skb,
struct net_device *dev)
{
@@ -900,7 +955,7 @@ static netdev_tx_t ip6gre_tunnel_xmit(struct sk_buff *skb,
__be16 payload_protocol;
int ret;
- if (!pskb_inet_may_pull(skb))
+ if (ip6gre_xmit_classify(skb, dev, &payload_protocol))
goto tx_err;
if (!ip6_tnl_xmit_ctl(t, &t->parms.laddr, &t->parms.raddr))
@@ -909,7 +964,6 @@ static netdev_tx_t ip6gre_tunnel_xmit(struct sk_buff *skb,
if (t->parms.collect_md)
tun_info = skb_tunnel_info_txcheck(skb);
- payload_protocol = skb_protocol(skb, true);
switch (payload_protocol) {
case htons(ETH_P_IP):
ret = ip6gre_xmit_ipv4(skb, dev);
@@ -918,7 +972,7 @@ static netdev_tx_t ip6gre_tunnel_xmit(struct sk_buff *skb,
ret = ip6gre_xmit_ipv6(skb, dev);
break;
default:
- ret = ip6gre_xmit_other(skb, dev);
+ ret = ip6gre_xmit_other(skb, dev, payload_protocol);
break;
}
@@ -941,6 +995,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
struct ip_tunnel_info *tun_info = NULL;
struct ip6_tnl *t = netdev_priv(dev);
IP_TUNNEL_DECLARE_FLAGS(flags) = { };
+ __be16 payload_protocol;
bool truncate = false;
int encap_limit = -1;
__u8 dsfield = false;
@@ -950,7 +1005,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
__u32 mtu;
int nhoff;
- if (!pskb_inet_may_pull(skb))
+ if (ip6gre_xmit_classify(skb, dev, &payload_protocol))
goto tx_err;
if (!ip6_tnl_xmit_ctl(t, &t->parms.laddr, &t->parms.raddr))
@@ -1073,7 +1128,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
htonl(atomic_fetch_inc(&t->o_seqno)));
err = ip6_tnl_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu,
- NEXTHDR_GRE);
+ NEXTHDR_GRE, payload_protocol);
if (err != 0) {
/* XXX: send ICMP error even if DF is not set. */
if (err == -EMSGSIZE) {
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 4912b08228a1..868c49b97a8f 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -1107,6 +1107,8 @@ EXPORT_SYMBOL_GPL(ip6_tnl_xmit_ctl);
* @encap_limit: encapsulation limit
* @pmtu: Path MTU is stored if packet is too big
* @proto: next header value
+ * @payload_protocol: protocol of the inner packet; ETH_P_IP or ETH_P_IPV6
+ * only if that header is at the network header, in the linear area
*
* Description:
* Build new header and do some sanity checks on the packet before sending
@@ -1120,7 +1122,7 @@ EXPORT_SYMBOL_GPL(ip6_tnl_xmit_ctl);
int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
struct flowi6 *fl6, int encap_limit, __u32 *pmtu,
- __u8 proto)
+ __u8 proto, __be16 payload_protocol)
{
struct ip6_tnl *t = netdev_priv(dev);
struct net *net = t->net;
@@ -1132,13 +1134,10 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
unsigned int eth_hlen = t->dev->type == ARPHRD_ETHER ? ETH_HLEN : 0;
unsigned int psh_hlen = sizeof(struct ipv6hdr) + t->encap_hlen;
unsigned int max_headroom = psh_hlen;
- __be16 payload_protocol;
bool use_cache = false;
u8 hop_limit;
int err = -1;
- payload_protocol = skb_protocol(skb, true);
-
if (t->parms.collect_md) {
hop_limit = skb_tunnel_info(skb)->key.ttl;
goto route_lookup;
@@ -1424,7 +1423,7 @@ ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,
skb_set_inner_ipproto(skb, protocol);
err = ip6_tnl_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu,
- protocol);
+ protocol, skb->protocol);
if (err != 0) {
/* XXX: send ICMP error even if DF is not set. */
if (err == -EMSGSIZE)
--
2.47.3
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH net-next v7 4/5] ip6_gre: go by the inner protocol behind VLAN tags in ip6erspan
2026-12-01 0:59 [PATCH net-next v7 0/5] ip6_gre, erspan: fix inner header handling for VLAN-tagged and short frames Anton Danilov
` (2 preceding siblings ...)
2026-12-01 0:59 ` [PATCH net-next v7 3/5] ip6_gre: classify the inner packet once on transmit Anton Danilov
@ 2026-12-01 0:59 ` Anton Danilov
2026-12-01 0:59 ` [PATCH net-next v7 5/5] selftests: net: add a test for ip6gretap and ip6erspan with VLAN tags Anton Danilov
4 siblings, 0 replies; 6+ messages in thread
From: Anton Danilov @ 2026-12-01 0:59 UTC (permalink / raw)
To: netdev
Cc: Eric Dumazet, Jakub Kicinski, Paolo Abeni, David S. Miller,
Simon Horman, David Ahern, Willem de Bruijn, Ido Schimmel,
Florian Westphal, William Tu, Meenakshi Vohra, Matthias May,
Mazin Al Haddad, Shuah Khan, linux-kselftest, linux-kernel
ip6erspan_tunnel_xmit() picks the traffic class and the flow label to
inherit, the ERSPAN truncation bit and the ICMP error to send for a
packet that is too big by skb->protocol, and ip6_tnl_xmit() picks its
minimum MTU the same way. A VLAN-tagged frame therefore gets none of
that: its outer traffic class is 0 where ip6gretap inherits it, the
truncation bit is not set from its IP length, and an IPv4 packet behind
a tag gets an ICMPv6 Packet Too Big built from its IPv4 header.
Use the protocol that the previous patch works out on entry, behind the
tags. The header it stands for has been pulled and the network header
is on it.
Found by an AI code review agent on an earlier version of the previous
patch and confirmed in a VM on an unmodified kernel: an IPv4 packet
with TOS 0xb8 behind a VLAN tag, sent to ip6erspan v1 and v2 with
tclass inherit in each of the ways listed in the previous patch, goes
out with traffic class 0 before this patch and with 0xb8 after it;
untagged packets go out with 0xb8 before and after. The truncation
bit, the ICMP error and the minimum MTU were not measured.
Signed-off-by: Anton Danilov <littlesmilingcloud@gmail.com>
---
net/ipv6/ip6_gre.c | 8 ++++----
net/ipv6/ip6_tunnel.c | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index d7d7fd478200..698cf1cdd4ab 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -1021,11 +1021,11 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
}
nhoff = skb_network_offset(skb);
- if (skb->protocol == htons(ETH_P_IP) &&
+ if (payload_protocol == htons(ETH_P_IP) &&
(ntohs(ip_hdr(skb)->tot_len) > skb->len - nhoff))
truncate = true;
- if (skb->protocol == htons(ETH_P_IPV6)) {
+ if (payload_protocol == htons(ETH_P_IPV6)) {
int thoff;
if (skb_transport_header_was_set(skb))
@@ -1087,7 +1087,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
goto tx_err;
}
} else {
- switch (skb->protocol) {
+ switch (payload_protocol) {
case htons(ETH_P_IP):
memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
prepare_ip6gre_xmit_ipv4(skb, dev, &fl6,
@@ -1132,7 +1132,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
if (err != 0) {
/* XXX: send ICMP error even if DF is not set. */
if (err == -EMSGSIZE) {
- if (skb->protocol == htons(ETH_P_IP))
+ if (payload_protocol == htons(ETH_P_IP))
icmp_ndo_send(skb, ICMP_DEST_UNREACH,
ICMP_FRAG_NEEDED, htonl(mtu));
else
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 868c49b97a8f..8ccc90333c99 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -1227,7 +1227,7 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
max_headroom += 8;
mtu -= 8;
}
- mtu = max(mtu, skb->protocol == htons(ETH_P_IPV6) ?
+ mtu = max(mtu, payload_protocol == htons(ETH_P_IPV6) ?
IPV6_MIN_MTU : IPV4_MIN_MTU);
skb_dst_update_pmtu_no_confirm(skb, mtu);
--
2.47.3
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH net-next v7 5/5] selftests: net: add a test for ip6gretap and ip6erspan with VLAN tags
2026-12-01 0:59 [PATCH net-next v7 0/5] ip6_gre, erspan: fix inner header handling for VLAN-tagged and short frames Anton Danilov
` (3 preceding siblings ...)
2026-12-01 0:59 ` [PATCH net-next v7 4/5] ip6_gre: go by the inner protocol behind VLAN tags in ip6erspan Anton Danilov
@ 2026-12-01 0:59 ` Anton Danilov
4 siblings, 0 replies; 6+ messages in thread
From: Anton Danilov @ 2026-12-01 0:59 UTC (permalink / raw)
To: netdev
Cc: Eric Dumazet, Jakub Kicinski, Paolo Abeni, David S. Miller,
Simon Horman, David Ahern, Willem de Bruijn, Ido Schimmel,
Florian Westphal, William Tu, Meenakshi Vohra, Matthias May,
Mazin Al Haddad, Shuah Khan, linux-kselftest, linux-kernel
Add ip6_gre_vlan_inherit.sh. It sends IPv4 and IPv6 packets with a
given TTL and TOS through ip6gretap, with and without a key, and
through ip6erspan v1 and v2, directly and through a VLAN device on top
of the tunnel, and checks on the receiving side that
- the outer hop limit and traffic class are those of the inner
packet, with a VLAN tag in front of it or without;
- on ip6erspan, the COS field of the ERSPAN header is the one that the
inner TOS asks for, for IPv4 and for IPv6.
The outer header is matched with tc flower and the COS field with tc
u32, and the packets are counted.
Without the previous patches of this series 10 of the 24 checks fail:
the hop limit behind a tag on ip6gretap with a key, the hop limit and
traffic class behind a tag on ip6erspan, and the COS of IPv4 packets on
ip6erspan.
Signed-off-by: Anton Danilov <littlesmilingcloud@gmail.com>
---
tools/testing/selftests/net/Makefile | 1 +
.../selftests/net/ip6_gre_vlan_inherit.sh | 172 ++++++++++++++++++
2 files changed, 173 insertions(+)
create mode 100755 tools/testing/selftests/net/ip6_gre_vlan_inherit.sh
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index fb0a64662053..0d8a5ff31b17 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -53,6 +53,7 @@ TEST_PROGS := \
io_uring_zerocopy_tx.sh \
ioam6.sh \
ip6_gre_headroom.sh \
+ ip6_gre_vlan_inherit.sh \
ip6_tunnel.sh \
ip_defrag.sh \
ip_local_port_range.sh \
diff --git a/tools/testing/selftests/net/ip6_gre_vlan_inherit.sh b/tools/testing/selftests/net/ip6_gre_vlan_inherit.sh
new file mode 100755
index 000000000000..94aed82e9441
--- /dev/null
+++ b/tools/testing/selftests/net/ip6_gre_vlan_inherit.sh
@@ -0,0 +1,172 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# ip6gretap and ip6erspan can take the outer hop limit and traffic class from
+# the packet they carry. Check that they do so for a packet behind a VLAN tag
+# as they do for one without a tag, and that ip6erspan derives the COS field
+# of the ERSPAN header from the carried packet, whether it is IPv4 or IPv6.
+#
+# +-------------------------------+ +---------------------------+
+# | ns1 | | ns2 |
+# | | | |
+# | tun.10 (VLAN 10) | | |
+# | | | | |
+# | tun (ip6gretap/ip6erspan) | | |
+# | : | | |
+# | veth1 ------------------------------------ veth2 |
+# | 2001:db8:1::1/64 | | 2001:db8:1::2/64 |
+# | | | ingress: tc counters |
+# +-------------------------------+ +---------------------------+
+#
+# The packets are sent to neighbours that only exist as static neighbour
+# entries, and are counted in ns2 as they arrive, by their outer header.
+
+# shellcheck disable=SC2154 # ns1 and ns2 are set by setup_ns
+source lib.sh
+
+readonly TTL=33
+readonly TOS=0xb8 # DSCP EF, which makes COS 5
+readonly COS_MATCH="0xa0 0xe0" # COS 5 in the top bits of its byte
+readonly COUNT=5
+readonly LLADDR=00:00:5e:00:53:01
+
+# Offset of the COS byte from the outer IPv6 header: IPv6 (40), GRE with a
+# sequence number (8), then the third byte of the ERSPAN header. The tunnels
+# are created with "encaplimit none", so that no extension header moves it.
+readonly COS_OFF=50
+
+setup()
+{
+ setup_ns ns1 ns2 || exit "$ksft_skip"
+
+ ip -n "$ns1" link add veth1 type veth peer name veth2 netns "$ns2"
+ ip -n "$ns1" address add 2001:db8:1::1/64 dev veth1 nodad
+ ip -n "$ns2" address add 2001:db8:1::2/64 dev veth2 nodad
+ ip -n "$ns1" link set dev veth1 up
+ ip -n "$ns2" link set dev veth2 up
+
+ tc -n "$ns2" qdisc add dev veth2 clsact
+ # Encapsulated packets with the inherited hop limit and traffic class.
+ # flower reads a numeric ip_proto as hexadecimal: 0x2f is GRE.
+ tc -n "$ns2" filter add dev veth2 ingress pref 1 handle 101 \
+ protocol ipv6 flower ip_proto 0x2f \
+ ip_ttl "$TTL" ip_tos "$TOS" \
+ action continue
+ # ERSPAN packets with the expected COS.
+ # shellcheck disable=SC2086 # COS_MATCH is a value and a mask
+ tc -n "$ns2" filter add dev veth2 ingress pref 2 \
+ protocol ipv6 u32 \
+ match u8 47 0xff at 6 \
+ match u8 $COS_MATCH at "$COS_OFF" \
+ action pass
+}
+
+tunnel_create()
+{
+ local kind=$1; shift
+ local -a args
+
+ case "$kind" in
+ ip6gretap)
+ args=(type ip6gretap);;
+ ip6gretap_key)
+ args=(type ip6gretap key 1);;
+ ip6erspan_v1)
+ args=(type ip6erspan seq key 1 erspan_ver 1 erspan 1);;
+ ip6erspan_v2)
+ args=(type ip6erspan seq key 1 erspan_ver 2
+ erspan_dir ingress erspan_hwid 1);;
+ esac
+
+ ip -n "$ns1" link add tun "${args[@]}" \
+ local 2001:db8:1::1 remote 2001:db8:1::2 \
+ tclass inherit hoplimit inherit encaplimit none
+ ip -n "$ns1" link add link tun name tun.10 type vlan id 10
+ ip -n "$ns1" link set dev tun up
+ ip -n "$ns1" link set dev tun.10 up
+
+ ip -n "$ns1" address add 192.0.2.1/28 dev tun
+ ip -n "$ns1" address add 2001:db8:2::1/64 dev tun nodad
+ ip -n "$ns1" address add 192.0.2.17/28 dev tun.10
+ ip -n "$ns1" address add 2001:db8:3::1/64 dev tun.10 nodad
+
+ ip -n "$ns1" neigh add 192.0.2.2 lladdr "$LLADDR" dev tun
+ ip -n "$ns1" neigh add 2001:db8:2::2 lladdr "$LLADDR" dev tun
+ ip -n "$ns1" neigh add 192.0.2.18 lladdr "$LLADDR" dev tun.10
+ ip -n "$ns1" neigh add 2001:db8:3::2 lladdr "$LLADDR" dev tun.10
+}
+
+tunnel_destroy()
+{
+ ip -n "$ns1" link del dev tun
+}
+
+inherit_count()
+{
+ tc_rule_handle_stats_get "dev veth2 ingress" 101 ".packets" "-n $ns2"
+}
+
+cos_count()
+{
+ tc -n "$ns2" -j -s filter show dev veth2 ingress pref 2 |
+ jq '[.[] | select(.options.actions) |
+ .options.actions[0].stats.packets] | add'
+}
+
+# Send COUNT packets and check that as many arrive with the outer header
+# fields that the inner header asks for.
+send_and_check()
+{
+ local kind=$1; shift
+ local what=$1; shift
+ local dst=$1; shift
+ local inherit cos
+
+ inherit=$(inherit_count)
+ cos=$(cos_count)
+
+ # Nobody answers: ping sends COUNT packets and gives up.
+ ip netns exec "$ns1" ping -q -c "$COUNT" -i 0.01 -W 1 \
+ -t "$TTL" -Q "$TOS" "$dst" &> /dev/null
+
+ RET=0
+ busywait "$BUSYWAIT_TIMEOUT" until_counter_is \
+ ">= $((inherit + COUNT))" inherit_count > /dev/null
+ check_err $? "outer hop limit and traffic class not inherited"
+ log_test "$kind: $what, hop limit and traffic class"
+
+ [[ "$kind" == ip6erspan* ]] || return 0
+
+ RET=0
+ busywait "$BUSYWAIT_TIMEOUT" until_counter_is \
+ ">= $((cos + COUNT))" cos_count > /dev/null
+ check_err $? "COS not taken from the inner header"
+ log_test "$kind: $what, ERSPAN COS"
+}
+
+test_kind()
+{
+ local kind=$1; shift
+
+ tunnel_create "$kind"
+
+ send_and_check "$kind" "IPv4" 192.0.2.2
+ send_and_check "$kind" "IPv6" 2001:db8:2::2
+ send_and_check "$kind" "IPv4 in VLAN" 192.0.2.18
+ send_and_check "$kind" "IPv6 in VLAN" 2001:db8:3::2
+
+ tunnel_destroy
+}
+
+require_command jq
+
+trap cleanup_all_ns EXIT
+
+setup
+
+test_kind ip6gretap
+test_kind ip6gretap_key
+test_kind ip6erspan_v1
+test_kind ip6erspan_v2
+
+exit "$EXIT_STATUS"
--
2.47.3
^ permalink raw reply [flat|nested] 6+ messages in thread