QinQ 剥离标签

QinQ 剥离标签

在内核为 4.9.110 的 Debian 机器上,我有一个为 QinQ 配置的 NIC,以 802.1AD 作为外部标记,以 802.1Q 作为内部标记:

root@pgen:/home/jlixfeld# ip -d link show eth4.10.11
3: eth4.10.11@eth4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 00:0c:bd:08:80:9a brd ff:ff:ff:ff:ff:ff promiscuity 0
    vlan protocol 802.1Q id 11 <REORDER_HDR> addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
root@pgen:/home/jlixfeld# ip -d link show eth4.10
2: eth4.10@eth4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 00:0c:bd:08:80:9a brd ff:ff:ff:ff:ff:ff promiscuity 0
    vlan protocol 802.1ad id 10 <REORDER_HDR> addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
root@pgen:/home/jlixfeld#

root@pgen:/home/jlixfeld# ip -d a show eth4.10
2: eth4.10@eth4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:0c:bd:08:80:9a brd ff:ff:ff:ff:ff:ff promiscuity 0
    vlan protocol 802.1ad id 10 <REORDER_HDR> numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
    inet 1.0.10.4/24 scope global eth4.10
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:bdff:fe08:809a/64 scope link
       valid_lft forever preferred_lft forever
root@pgen:/home/jlixfeld# ip -d a show eth4.10.11
3: eth4.10.11@eth4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:0c:bd:08:80:9a brd ff:ff:ff:ff:ff:ff promiscuity 0
    vlan protocol 802.1Q id 11 <REORDER_HDR> numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
    inet 1.10.11.4/24 scope global eth4.10.11
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:bdff:fe08:809a/64 scope link
       valid_lft forever preferred_lft forever
root@pgen:/home/jlixfeld#

查看来自 eth4 的流量,我没有看到我期望看到的标签堆栈。

如果我从 1.10.11.4 生成流量,我希望看到双重标记的帧,但我只看到一个标记。

root@pgen:/home/jlixfeld# ip netns exec eth4 tcpdump -vvvlnei eth4
tcpdump: listening on eth4, link-type EN10MB (Ethernet), capture size 262144 bytes
16:26:41.789907 00:0c:bd:08:80:9a > 00:0c:bd:08:80:9b, ethertype 802.1Q (0x8100), length 102: vlan 11, p 0, ethertype IPv4, (tos 0x0, ttl 64, id 11681, offset 0, flags [DF], proto ICMP (1), length 84)
    1.10.11.4 > 1.10.11.5: ICMP echo request, id 12947, seq 1, length 64

如果我从 1.0.11.4 生成流量,我会看到一个标签,它是 802.1AD 标签。这很好。

我最初运行这个特定测试是为了查看转发 802.1AD 是否存在问题,但事实并非如此。

root@pgen:/home/jlixfeld# ip netns exec eth4 tcpdump -vvvlnei eth4
16:29:59.033928 00:0c:bd:08:80:9a > 00:0c:bd:08:80:9b, ethertype 802.1Q-QinQ (0x88a8), length 102: vlan 10, p 0, ethertype IPv4, (tos 0x0, ttl 64, id 14413, offset 0, flags [DF], proto ICMP (1), length 84)
    1.0.10.4 > 1.0.10.5: ICMP echo request, id 12957, seq 1, length 64

因此看起来好像它可以转发 802.1AD,也可以转发 802.1Q,但不能转发堆栈。

我是不是在某个地方漏掉了一些胶水?

答案1

对于 eth4.10.11,主接口定义不正确。

原来的:

ip netns exec eth4 ip link add link eth4 name eth4.10 type vlan proto 802.1ad id 10
ip netns exec eth4 ip link add link eth4 name eth4.10.11 type vlan proto 802.1q id 11

固定的:

ip netns exec eth4 ip link add link eth4 name eth4.10 type vlan proto 802.1ad id 10
ip netns exec eth4 ip link add link eth4.10 name eth4.10.11 type vlan proto 802.1q id 11
root@pgen:/home/jlixfeld# ip netns exec eth4 ip -d link show
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN mode DEFAULT group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 promiscuity 0 addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
2: eth4.10@eth4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 00:0c:bd:08:80:9a brd ff:ff:ff:ff:ff:ff promiscuity 0
    vlan protocol 802.1ad id 10 <REORDER_HDR> addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
3: [email protected]: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 00:0c:bd:08:80:9a brd ff:ff:ff:ff:ff:ff promiscuity 0
    vlan protocol 802.1Q id 11 <REORDER_HDR> addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
6: eth4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether 00:0c:bd:08:80:9a brd ff:ff:ff:ff:ff:ff promiscuity 1 addrgenmode eui64 numtxqueues 64 numrxqueues 64 gso_max_size 65536 gso_max_segs 65535
root@pgen:/home/jlixfeld#

tcpdump 现在显示正确的标签堆栈:

05:30:21.169830 00:0c:bd:08:80:9a > 00:0c:bd:08:80:9b, ethertype 802.1Q-QinQ (0x88a8), length 106: vlan 10, p 0, ethertype 802.1Q, vlan 11, p 0, ethertype IPv4, (tos 0x0, ttl 64, id 32347, offset 0, flags [DF], proto ICMP (1), length 84)
    1.10.11.4 > 1.10.11.5: ICMP echo request, id 6827, seq 1, length 64

相关内容