Aqui está a solução usando o eBPF.
Para evitar ter que instalar o bcc e compilar o código a partir da fonte, aqui está o binário:
$ base64 -d > tag-native-vlan0.o
f0VMRgIBAQAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAALABAAAAAAAAAAAAAEAAAAAA
AEAABwABAGESFAAAAAAAVQIDAAAAAAC3AgAAAIEAALcDAAAAAAAAhQAAABIAAAC3AAAAAAAAAJUA
AAAAAAAAYRIUAAAAAAAVAgMAAAAAAGESGAAAAAAAVQIBAAAAAACFAAAAEwAAALcAAAAAAAAAlQAA
AAAAAABHUEwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF4AAAAAAAMAKAAAAAAAAAAAAAAA
AAAAAFcAAAAAAAQAKAAAAAAAAAAAAAAAAAAAAD0AAAAQAAUAAAAAAAAAAAAAAAAAAAAAACMAAAAQ
AAQAAAAAAAAAAAAAAAAAAAAAAAcAAAAQAAMAAAAAAAAAAAAAAAAAAAAAAAAudGV4dABjbHNhY3Rf
aW5ncmVzcwBwdmlkX2luZ3Jlc3MAY2xzYWN0X2VncmVzcwBwdmlkX2VncmVzcwBfX2xpY2Vuc2UA
LnN0cnRhYgAuc3ltdGFiAExCQjFfMwBMQkIwXzIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEcAAAADAAAAAAAAAAAAAAAA
AAAAAAAAAEgBAAAAAAAAZQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAQAAAAYA
AAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAFgAA
AAEAAAAGAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAA
AAAAADEAAAABAAAABgAAAAAAAAAAAAAAAAAAAHgAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAgAAAAA
AAAAAAAAAAAAAAA/AAAAAQAAAAMAAAAAAAAAAAAAAAAAAACwAAAAAAAAAAQAAAAAAAAAAAAAAAAA
AAABAAAAAAAAAAAAAAAAAAAATwAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAuAAAAAAAAACQAAAAAAAA
AAEAAAADAAAACAAAAAAAAAAYAAAAAAAAAA==
^D
Eu configurei o PVID para mapear para o VID 0 em vez do VID 10, sem nenhum motivo específico.
(Para alterá-lo para o VID 10, use um desmontador e montador, por exemplo, ubpf ou llvm-objdump, no arquivo .o, e altere a tag VLAN. Você também pode falar com o eBPF do espaço do usuário, por isso, deve ser possível reconfigurar o pvid em tempo de execução, se necessário.)
Certifique-se de executar algo como o kernel 4.8.0 ( uname -a
) e o iproute2 4.9.0 ( ip -V
).
Adicione o eBPF à interface física:
$ tc qdisc add dev eth0 clsact
$ tc filter add dev eth0 ingress bpf object-file tag-native-vlan0.o section pvid_ingress
$ tc filter add dev eth0 egress bpf object-file tag-native-vlan0.o section pvid_egress
Crie uma interface lógica:
$ ip link add eth0-vlan0 link eth0 type vlan id 0
$ ip link set eth0-vlan0 up
$ ip addr add 192.168.10.253/24 dev eth0-vlan0
O L3 é configurado na interface lógica e a interface física é usada para o L2.
Teste de uma caixa conectada:
peer$ ping 192.168.10.253
PING 192.168.10.253 (192.168.10.253) 56(84) bytes of data.
64 bytes from 192.168.10.253: icmp_seq=1 ttl=64 time=0.380 ms
64 bytes from 192.168.10.253: icmp_seq=2 ttl=64 time=0.240 ms
^C
E você tem isso, uma "interface não marcada no Linux".