Короче, поднял я тестовый MPLS по схеме:
modprobe mpls_router
modprobe mpls_gso
modprobe mpls_iptunnel
sysctl -w net.mpls.conf.lo.input=1
sysctl -w net.mpls.platform_labels=1048575
ip link add veth0 type veth peer name veth1
ip link add veth2 type veth peer name veth3
sysctl -w net.mpls.conf.veth0.input=1
sysctl -w net.mpls.conf.veth2.input=1
ifconfig veth0 10.3.3.1/24 up
ifconfig veth2 10.4.4.1/24 up
ip netns add host1
ip netns add host2
ip link set veth1 netns host1
ip link set veth3 netns host2
ip netns exec host1 ifconfig veth1 10.3.3.2/24 up
ip netns exec host2 ifconfig veth3 10.4.4.2/24 up
ip netns exec host1 ip route add 10.10.10.2/32 encap mpls 112 via inet 10.3.3.1
ip netns exec host2 ip route add 10.10.10.1/32 encap mpls 111 via inet 10.4.4.1
ip -f mpls route add 111 via inet 10.3.3.2
ip -f mpls route add 112 via inet 10.4.4.2
ip netns exec host1 bash
ifconfig lo up
ip addr add 10.10.10.1/32 dev lo
ip netns exec host2 bash
ifconfig lo up
ip addr add 10.10.10.2/32 dev lo
ip netns exec host1 bash
Host1:
root@ne-vlezay80:~# ping 10.10.10.2 -I 10.10.10.1
PING 10.10.10.2 (10.10.10.2) from 10.10.10.1 : 56(84) bytes of data.
64 bytes from 10.10.10.2: icmp_seq=1 ttl=63 time=0.043 ms
64 bytes from 10.10.10.2: icmp_seq=2 ttl=63 time=0.038 ms
64 bytes from 10.10.10.2: icmp_seq=3 ttl=63 time=0.049 ms
64 bytes from 10.10.10.2: icmp_seq=4 ttl=63 time=0.048 ms
64 bytes from 10.10.10.2: icmp_seq=5 ttl=63 time=0.048 ms
64 bytes from 10.10.10.2: icmp_seq=6 ttl=63 time=0.047 ms
64 bytes from 10.10.10.2: icmp_seq=7 ttl=63 time=0.044 ms
64 bytes from 10.10.10.2: icmp_seq=8 ttl=63 time=0.046 ms
^C
--- 10.10.10.2 ping statistics ---
8 packets transmitted, 8 received, 0% packet loss, time 7174ms
rtt min/avg/max/mdev = 0.038/0.045/0.049/0.006 ms
Host2:
root@ne-vlezay80:~# ping 10.10.10.1 -I 10.10.10.2
PING 10.10.10.1 (10.10.10.1) from 10.10.10.2 : 56(84) bytes of data.
64 bytes from 10.10.10.1: icmp_seq=1 ttl=63 time=0.040 ms
64 bytes from 10.10.10.1: icmp_seq=2 ttl=63 time=0.037 ms
64 bytes from 10.10.10.1: icmp_seq=3 ttl=63 time=0.037 ms
64 bytes from 10.10.10.1: icmp_seq=4 ttl=63 time=0.042 ms
64 bytes from 10.10.10.1: icmp_seq=5 ttl=63 time=0.042 ms
64 bytes from 10.10.10.1: icmp_seq=6 ttl=63 time=0.045 ms
64 bytes from 10.10.10.1: icmp_seq=7 ttl=63 time=0.045 ms
64 bytes from 10.10.10.1: icmp_seq=8 ttl=63 time=0.038 ms
^C
--- 10.10.10.1 ping statistics ---
8 packets transmitted, 8 received, 0% packet loss, time 7176ms
rtt min/avg/max/mdev = 0.037/0.040/0.045/0.008 ms
Host1:
iperf3 -s -B 10.10.10.2 -D
Host2:
root@ne-vlezay80:~# ip netns exec host1 bash
root@ne-vlezay80:~# iperf3 -c 10.10.10.2 -B 10.10.10.1
Connecting to host 10.10.10.2, port 5201
[ 4] local 10.10.10.1 port 57039 connected to 10.10.10.2 port 5201
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 2.00 GBytes 17.2 Gbits/sec 0 1.95 MBytes
[ 4] 1.00-2.00 sec 2.01 GBytes 17.2 Gbits/sec 0 1.95 MBytes
[ 4] 2.00-3.00 sec 2.01 GBytes 17.2 Gbits/sec 0 1.95 MBytes
[ 4] 3.00-4.00 sec 2.01 GBytes 17.3 Gbits/sec 0 1.95 MBytes
[ 4] 4.00-5.00 sec 2.01 GBytes 17.2 Gbits/sec 0 1.95 MBytes
[ 4] 5.00-6.00 sec 2.01 GBytes 17.2 Gbits/sec 0 1.95 MBytes
[ 4] 6.00-7.00 sec 2.01 GBytes 17.3 Gbits/sec 0 1.95 MBytes
[ 4] 7.00-8.00 sec 2.01 GBytes 17.3 Gbits/sec 0 1.95 MBytes
[ 4] 8.00-9.00 sec 2.01 GBytes 17.3 Gbits/sec 0 1.95 MBytes
[ 4] 9.00-10.00 sec 2.01 GBytes 17.3 Gbits/sec 0 1.95 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.00 sec 20.1 GBytes 17.3 Gbits/sec 0 sender
[ 4] 0.00-10.00 sec 20.1 GBytes 17.3 Gbits/sec receiver
iperf Done.
root@ne-vlezay80:~# iperf3 -c 10.10.10.2 -B 10.10.10.1 -b -b 1tb
Connecting to host 10.10.10.2, port 5201
[ 4] local 10.10.10.1 port 57609 connected to 10.10.10.2 port 5201
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 2.11 GBytes 18.1 Gbits/sec 0 1.95 MBytes
[ 4] 1.00-2.00 sec 2.11 GBytes 18.1 Gbits/sec 0 1.95 MBytes
[ 4] 2.00-3.00 sec 2.11 GBytes 18.1 Gbits/sec 0 1.95 MBytes
[ 4] 3.00-4.00 sec 2.11 GBytes 18.1 Gbits/sec 0 1.95 MBytes
[ 4] 4.00-5.00 sec 2.11 GBytes 18.1 Gbits/sec 0 1.95 MBytes
[ 4] 5.00-6.00 sec 2.11 GBytes 18.1 Gbits/sec 0 1.95 MBytes
[ 4] 6.00-7.00 sec 2.11 GBytes 18.1 Gbits/sec 0 1.95 MBytes
[ 4] 7.00-8.00 sec 2.11 GBytes 18.1 Gbits/sec 0 1.95 MBytes
[ 4] 8.00-9.00 sec 2.11 GBytes 18.1 Gbits/sec 0 1.95 MBytes
[ 4] 9.00-10.00 sec 2.11 GBytes 18.2 Gbits/sec 0 1.95 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.00 sec 21.1 GBytes 18.1 Gbits/sec 0 sender
[ 4] 0.00-10.00 sec 21.1 GBytes 18.1 Gbits/sec receiver
iperf Done.
tcpdump:
root@ne-vlezay80:~# tcpdump -i veth2 -n
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on veth2, link-type EN10MB (Ethernet), capture size 262144 bytes
07:02:36.886598 IP 10.10.10.1 > 10.10.10.2: ICMP echo request, id 1677, seq 1, length 64
07:02:36.886617 MPLS (label 111, exp 0, [S], ttl 64) IP 10.10.10.2 > 10.10.10.1: ICMP echo reply, id 1677, seq 1, length 64
07:02:37.895065 IP 10.10.10.1 > 10.10.10.2: ICMP echo request, id 1677, seq 2, length 64
07:02:37.895081 MPLS (label 111, exp 0, [S], ttl 64) IP 10.10.10.2 > 10.10.10.1: ICMP echo reply, id 1677, seq 2, length 64
root@ne-vlezay80:~# tcpdump -i veth0 -n
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on veth0, link-type EN10MB (Ethernet), capture size 262144 bytes
07:03:30.368146 MPLS (label 112, exp 0, [S], ttl 64) IP 10.10.10.1 > 10.10.10.2: ICMP echo request, id 1679, seq 1, length 64
07:03:30.368172 IP 10.10.10.2 > 10.10.10.1: ICMP echo reply, id 1679, seq 1, length 64
07:03:31.399057 MPLS (label 112, exp 0, [S], ttl 64) IP 10.10.10.1 > 10.10.10.2: ICMP echo request, id 1679, seq 2, length 64
07:03:31.399080 IP 10.10.10.2 > 10.10.10.1: ICMP echo reply, id 1679, seq 2, length 64
07:03:32.423182 MPLS (label 112, exp 0, [S], ttl 64) IP 10.10.10.1 > 10.10.10.2: ICMP echo request, id 1679, seq 3, length 64
07:03:32.423210 IP 10.10.10.2 > 10.10.10.1: ICMP echo reply, id 1679, seq 3, length 64
07:03:33.447195 MPLS (label 112, exp 0, [S], ttl 64) IP 10.10.10.1 > 10.10.10.2: ICMP echo request, id 1679, seq 4, length 64
07:03:33.447214 IP 10.10.10.2 > 10.10.10.1: ICMP echo reply, id 1679, seq 4, length 64
07:03:34.471219 MPLS (label 112, exp 0, [S], ttl 64) IP 10.10.10.1 > 10.10.10.2: ICMP echo request, id 1679, seq 5, length 64
07:03:34.471239 IP 10.10.10.2 > 10.10.10.1: ICMP echo reply, id 1679, seq 5, length 64
*VPLS
*MPLS в netfilter для фильтрации mpls-пакетов на P уровне. :D
А так впринцепе, всё работает.
В случае чего для стыка с провайдером хватит. Вот связанные проекты: https://frrouting.org/ https://github.com/FRRouting/frr/pull/343
Кстати, вот ifconfig:
root@ne-vlezay80:~# ifconfig
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:2 errors:0 dropped:0 overruns:0 frame:0
TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:100 (100.0 B) TX bytes:100 (100.0 B)
veth1 Link encap:Ethernet HWaddr d2:60:95:e8:a4:d6
inet addr:10.3.3.2 Bcast:10.3.3.255 Mask:255.255.255.0
inet6 addr: fe80::d060:95ff:fee8:a4d6/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1047404 errors:0 dropped:0 overruns:0 frame:0
TX packets:2164674 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:22610878516 (21.0 GiB) TX bytes:104546390092 (97.3 GiB)
Самое прикольное то, что некакой фрагментации нет))