[p4, controller] hack NDP reply

This commit is contained in:
Nico Schottelius 2019-02-28 10:56:22 +01:00
commit b29cf1a296
5 changed files with 229 additions and 12 deletions

View file

@ -9,9 +9,9 @@
| | | |
| 2019-02-23 | python2 / ipaddress is buggy | x |
| | p4utils is python2 only support | |
| | bmpy_utils is not installable with pip | |
| | bmpy_utils is not installable with pip | |
| | python2 / latest ipaddress==1.0.22 still has the bug | |
| | ipaddress.ip_network("2001:db8:61::/64") | |
| | ipaddress.ip_network("2001:db8:61::/64") | |
| | IPv6Network(u'3230:3031:3a64:6238:3a36:313a:3a2f:3634/128') | |
| | | |
| | egress routing | x |
@ -20,7 +20,21 @@
| | | |
| | | |
| 2019-02-28 | Meet Laurent #2 | |
| | - Setup base code | |
| | - Parser for all protocols (udp,tcp,icmp,icmp6) | |
| | - Started with icmp translation | |
| | - Investigating into IPv6 based checksums | |
| | - Some issues with python2 (ipaddr) - slowing down | |
| | - Reading into various RFCs, NDP, MLD | |
| | - Reading about multicast / trying to figure out dynamic membership | |
| | | |
| | - Questions | |
| | * Re-using code (lee howard) | |
| | * Multicast | |
| | * A lot of redundant code / different tables / repeating | |
| | | |
| | - Next steps: | |
| | * Supporting MLD | |
| | | |
| | | |
| 2019-02-22 | Have rough definition of tasks | |
@ -63,7 +77,7 @@
*** DONE Get feature list of tayga
*** DONE Setup P4 base / structure
*** DONE Create minimal controller for populating tables
*** TODO Checkout / review egress settings
*** DONE Checkout / review egress settings
*** TODO Implement ICMP <-> ICMP6 translation
**** DONE Parse icmp
**** DONE Parse icmpv6
@ -71,6 +85,9 @@
**** DONE Calculate ICMP6 checksums
**** TODO Implement minimal neighbor discovery
***** TODO For the switch
****** DONE Register IPv6 address in table
****** TODO Parse ICMPv6 up to neighbor solicitation
****** TODO Use NDP (Neighbor Solicitation (NDP) , Neighbor Advertisement (NDP))
***** TODO For other nodes -> multicast
***** TODO Maybe implement link local addresses (missing at the moment)
****** ff02::/??
@ -231,6 +248,106 @@ root@ubuntu:~/master-thesis/p4app# ls -1 /proc/sys/net/ipv6/conf/*/disable_ipv6
/proc/sys/net/ipv6/conf/lo/disable_ipv6
root@ubuntu:~/master-thesis/p4app#
Works on mininet
mininet> h2 bash
root@line:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: h2-eth0@if93: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 32:0e:1e:bf:3c:4b brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 10.0.0.2/8 brd 10.255.255.255 scope global h2-eth0
valid_lft forever preferred_lft forever
inet6 fe80::300e:1eff:febf:3c4b/64 scope link
valid_lft forever preferred_lft forever
root@line:~# ip addr add 2001:db8:61::42/64 dev h2-eth0
root@line:~# ^Dexit
mininet> h1 bash
root@line:~# ip addr add 2001:db8:61::42/64^[[D^[[D^?^?^?^?^?^?^?^?^?^?^?^C^C
root@line:~# ^Dexit
mininet> h1 ip addr add 2001:db8:61::2/64 dev h1-eth0
mininet> h2 ping6 -c2 2001:db8:61::2
PING 2001:db8:61::2(2001:db8:61::2) 56 data bytes
64 bytes from 2001:db8:61::2: icmp_seq=1 ttl=64 time=0.230 ms
64 bytes from 2001:db8:61::2: icmp_seq=2 ttl=64 time=0.138 ms
--- 2001:db8:61::2 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1018ms
rtt min/avg/max/mdev = 0.138/0.184/0.230/0.046 ms
mininet>
mininet on VM also works
mininet> h1 ip addr add 2001:db8:61::1/64 dev h1-eth0
mininet> h2 ip addr add 2001:db8:61::2/64 dev h2-eth0
mininet> h2 ping6 -c2 2001:db8:61::2
PING 2001:db8:61::2(2001:db8:61::2) 56 data bytes
64 bytes from 2001:db8:61::2: icmp_seq=1 ttl=64 time=0.053 ms
64 bytes from 2001:db8:61::2: icmp_seq=2 ttl=64 time=0.082 ms
--- 2001:db8:61::2 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.053/0.067/0.082/0.016 ms
mininet>
WORKING trace on mininet on the VM
19:38:49.852088 IP6 2001:db8:61::2 > ff02::1:ff00:1: ICMP6, neighbor solicitation, who has 2001:db8:61::1, length 32
19:38:49.852144 IP6 2001:db8:61::1 > 2001:db8:61::2: ICMP6, neighbor advertisement, tgt is 2001:db8:61::1, length 32
19:38:49.852163 IP6 2001:db8:61::2 > 2001:db8:61::1: ICMP6, echo request, seq 1, length 64
19:38:49.852176 IP6 2001:db8:61::1 > 2001:db8:61::2: ICMP6, echo reply, seq 1, length 64
checking ipv6 in p4-utils
p4@ubuntu:~/p4-utils$ grep -ri ipv6 .
./p4utils/mininetlib/p4_mininet.py: # disable IPv6
./p4utils/mininetlib/p4_mininet.py: self.cmd("sysctl -w net.ipv6.conf.all.disable_ipv6=1")
./p4utils/mininetlib/p4_mininet.py: self.cmd("sysctl -w net.ipv6.conf.default.disable_ipv6=1")
./p4utils/mininetlib/p4_mininet.py: self.cmd("sysctl -w net.ipv6.conf.lo.disable_ipv6=1")
./p4utils/mininetlib/p4net.py: #remove Ipv6 for all the interfaces
./p4utils/mininetlib/p4net.py: cmd2 = "sysctl net.ipv6.conf.{0}.disable_ipv6=1"
./p4utils/mininetlib/p4net.py: #remove ipv6
Binary file ./p4utils/mininetlib/p4_mininet.pyc matches
Binary file ./p4utils/mininetlib/p4net.pyc matches
Binary file ./p4utils/utils/runtime_API.pyc matches
./p4utils/utils/runtime_API.py:class UIn_BadIPv6Error(UIn_Error):
./p4utils/utils/runtime_API.py:def ipv6Addr_to_bytes(addr):
./p4utils/utils/runtime_API.py: from ipaddr import IPv6Address
./p4utils/utils/runtime_API.py: ip = IPv6Address(addr)
./p4utils/utils/runtime_API.py: raise UIn_BadIPv6Error()
./p4utils/utils/runtime_API.py: raise UIn_BadIPv6Error()
./p4utils/utils/runtime_API.py: return ipv6Addr_to_bytes(input_str)
./p4utils/utils/runtime_API.py: except UIn_BadIPv6Error:
./p4utils/utils/runtime_API.py: raise UIn_BadParamError("Invalid IPv6 address")
p4@ubuntu:~/p4-utils$
Messages we see in the controller on startup
DEBUG:main:INCOMING: <Ether dst=33:33:00:00:00:16 src=00:00:0a:00:00:02 type=0x86dd |<IPv6 version=6 tc=0 fl=0 plen=56 nh=Hop-by-Hop Option Header hlim=1 src=:: dst=ff02::16 |<IPv6ExtHdrHopByHop nh=ICMPv6 len=0 autopad=On options=[<RouterAlert otype=Router Alert [00: skip, 0: Don't change en-route] optlen=2 value=Datagram contains a MLD message |>, <PadN otype=PadN [00: skip, 0: Don't change en-route] optlen=0 |>] |<ICMPv6MLReport2 type=MLD Report Version 2 res=0 cksum=0x6d6d reserved=0 records_number=2 records=[<ICMPv6MLDMultAddrRec rtype=4 auxdata_len=0 sources_number=0 dst=ff02::1:ff00:1 sources=[ ] auxdata='' |<ICMPv6MLDMultAddrRec rtype=4 auxdata_len=0 sources_number=0 dst=ff02::1:ff00:2 |>>] |>>>>
DEBUG:main:INCOMING: <Ether dst=33:33:00:00:00:16 src=00:01:0a:00:00:02 type=0x86dd |<IPv6 version=6 tc=0 fl=0 plen=36 nh=Hop-by-Hop Option Header hlim=1 src=fe80::201:aff:fe00:2 dst=ff02::16 |<IPv6ExtHdrHopByHop nh=ICMPv6 len=0 autopad=On options=[<RouterAlert otype=Router Alert [00: skip, 0: Don't change en-route] optlen=2 value=Datagram contains a MLD message |>, <PadN otype=PadN [00: skip, 0: Don't change en-route] optlen=0 |>] |<ICMPv6MLReport2 type=MLD Report Version 2 res=0 cksum=0x6604 reserved=0 records_number=1 records=[<ICMPv6MLDMultAddrRec rtype=4 auxdata_len=0 sources_number=0 dst=ff02::1:ff00:2 |>] |>>>>
DEBUG:main:INCOMING: <Ether dst=33:33:00:00:00:16 src=00:00:0a:00:00:01 type=0x86dd |<IPv6 version=6 tc=0 fl=0 plen=36 nh=Hop-by-Hop Option Header hlim=1 src=fe80::200:aff:fe00:1 dst=ff02::16 |<IPv6ExtHdrHopByHop nh=ICMPv6 len=0 autopad=On options=[<RouterAlert otype=Router Alert [00: skip, 0: Don't change en-route] optlen=2 value=Datagram contains a MLD message |>, <PadN otype=PadN [00: skip, 0: Don't change en-route] optlen=0 |>] |<ICMPv6MLReport2 type=MLD Report Version 2 res=0 cksum=0x6607 reserved=0 records_number=1 records=[<ICMPv6MLDMultAddrRec rtype=4 auxdata_len=0 sources_number=0 dst=ff02::1:ff00:1 |>] |>>>>
DEBUG:main:INCOMING: <Ether dst=33:33:00:00:00:02 src=00:00:0a:00:00:01 type=0x86dd |<IPv6 version=6 tc=0 fl=0 plen=16 nh=ICMPv6 hlim=255 src=fe80::200:aff:fe00:1 dst=ff02::2 |<ICMPv6ND_RS type=Router Solicitation code=0 cksum=0xf72e res=0 |<ICMPv6NDOptSrcLLAddr type=1 len=1 lladdr=00:00:0a:00:00:01 |>>>>
DEBUG:main:INCOMING: <Ether dst=33:33:00:00:00:16 src=00:00:0a:00:00:02 type=0x86dd |<IPv6 version=6 tc=0 fl=0 plen=56 nh=Hop-by-Hop Option Header hlim=1 src=:: dst=ff02::16 |<IPv6ExtHdrHopByHop nh=ICMPv6 len=0 autopad=On options=[<RouterAlert otype=Router Alert [00: skip, 0: Don't change en-route] optlen=2 value=Datagram contains a MLD message |>, <PadN otype=PadN [00: skip, 0: Don't change en-route] optlen=0 |>] |<ICMPv6MLReport2 type=MLD Report Version 2 res=0 cksum=0x6d6d reserved=0 records_number=2 records=[<ICMPv6MLDMultAddrRec rtype=4 auxdata_len=0 sources_number=0 dst=ff02::1:ff00:1 sources=[ ] auxdata='' |<ICMPv6MLDMultAddrRec rtype=4 auxdata_len=0 sources_number=0 dst=ff02::1:ff00:2 |>>] |>>>>
DEBUG:main:INCOMING: <Ether dst=33:33:00:00:00:16 src=00:00:0a:00:00:01 type=0x86dd |<IPv6 version=6 tc=0 fl=0 plen=36 nh=Hop-by-Hop Option Header hlim=1 src=fe80::200:aff:fe00:1 dst=ff02::16 |<IPv6ExtHdrHopByHop nh=ICMPv6 len=0 autopad=On options=[<RouterAlert otype=Router Alert [00: skip, 0: Don't change en-route] optlen=2 value=Datagram contains a MLD message |>, <PadN otype=PadN [00: skip, 0: Don't change en-route] optlen=0 |>] |<ICMPv6MLReport2 type=MLD Report Version 2 res=0 cksum=0x6607 reserved=0 records_number=1 records=[<ICMPv6MLDMultAddrRec rtype=4 auxdata_len=0 sources_number=0 dst=ff02::1:ff00:1 |>] |>>>>
DEBUG:main:INCOMING: <Ether dst=33:33:00:00:00:16 src=00:00:0a:00:00:02 type=0x86dd |<IPv6 version=6 tc=0 fl=0 plen=56 nh=Hop-by-Hop Option Header hlim=1 src=fe80::200:aff:fe00:2 dst=ff02::16 |<IPv6ExtHdrHopByHop nh=ICMPv6 len=0 autopad=On options=[<RouterAlert otype=Router Alert [00: skip, 0: Don't change en-route] optlen=2 value=Datagram contains a MLD message |>, <PadN otype=PadN [00: skip, 0: Don't change en-route] optlen=0 |>] |<ICMPv6MLReport2 type=MLD Report Version 2 res=0 cksum=0x63ea reserved=0 records_number=2 records=[<ICMPv6MLDMultAddrRec rtype=4 auxdata_len=0 sources_number=0 dst=ff02::1:ff00:1 sources=[ ] auxdata='' |<ICMPv6MLDMultAddrRec rtype=4 auxdata_len=0 sources_number=0 dst=ff02::1:ff00:2 |>>] |>>>>
DEBUG:main:INCOMING: <Ether dst=33:33:00:00:00:02 src=00:00:0a:00:00:02 type=0x86dd |<IPv6 version=6 tc=0 fl=0 plen=16 nh=ICMPv6 hlim=255 src=fe80::200:aff:fe00:2 dst=ff02::2 |<ICMPv6ND_RS type=Router Solicitation code=0 cksum=0xf72d res=0 |<ICMPv6NDOptSrcLLAddr type=1 len=1 lladdr=00:00:0a:00:00:02 |>>>>
DEBUG:main:INCOMING: <Ether dst=33:33:00:00:00:16 src=00:00:0a:00:00:02 type=0x86dd |<IPv6 version=6 tc=0 fl=0 plen=56 nh=Hop-by-Hop Option Header hlim=1 src=fe80::200:aff:fe00:2 dst=ff02::16 |<IPv6ExtHdrHopByHop nh=ICMPv6 len=0 autopad=On options=[<RouterAlert otype=Router Alert [00: skip, 0: Don't change en-route] optlen=2 value=Datagram contains a MLD message |>, <PadN otype=PadN [00: skip, 0: Don't change en-route] optlen=0 |>] |<ICMPv6MLReport2 type=MLD Report Version 2 res=0 cksum=0x63ea reserved=0 records_number=2 records=[<ICMPv6MLDMultAddrRec rtype=4 auxdata_len=0 sources_number=0 dst=ff02::1:ff00:1 sources=[ ] auxdata='' |<ICMPv6MLDMultAddrRec rtype=4 auxdata_len=0 sources_number=0 dst=ff02::1:ff00:2 |>>] |>>>>
DEBUG:main:INCOMING: <Ether dst=33:33:00:00:00:02 src=00:00:0a:00:00:01 type=0x86dd |<IPv6 version=6 tc=0 fl=0 plen=16 nh=ICMPv6 hlim=255 src=fe80::200:aff:fe00:1 dst=ff02::2 |<ICMPv6ND_RS type=Router Solicitation code=0 cksum=0xf72e res=0 |<ICMPv6NDOptSrcLLAddr type=1 len=1 lladdr=00:00:0a:00:00:01 |>>>>
DEBUG:main:INCOMING: <Ether dst=33:33:00:00:00:02 src=00:00:0a:00:00:02 type=0x86dd |<IPv6 version=6 tc=0 fl=0 plen=16 nh=ICMPv6 hlim=255 src=fe80::200:aff:fe00:2 dst=ff02::2 |<ICMPv6ND_RS type=Router Solicitation code=0 cksum=0xf72d res=0 |<ICMPv6NDOptSrcLLAddr type=1 len=1 lladdr=00:00:0a:00:00:02 |>>>>
DEBUG:main:INCOMING: <Ether dst=33:33:00:00:00:02 src=00:00:0a:00:00:01 type=0x86dd |<IPv6 version=6 tc=0 fl=0 plen=16 nh=ICMPv6 hlim=255 src=fe80::200:aff:fe00:1 dst=ff02::2 |<ICMPv6ND_RS type=Router Solicitation code=0 cksum=0xf72e res=0 |<ICMPv6NDOptSrcLLAddr type=1 len=1 lladdr=00:00:0a:00:00:01 |>>>>
DEBUG:main:INCOMING: <Ether dst=33:33:00:00:00:02 src=00:00:0a:00:00:02 type=0x86dd |<IPv6 version=6 tc=0 fl=0 plen=16 nh=ICMPv6 hlim=255 src=fe80::200:aff:fe00:2 dst=ff02::2 |<ICMPv6ND_RS type=Router Solicitation code=0 cksum=0xf72d res=0 |<ICMPv6NDOptSrcLLAddr type=1 len=1 lladdr=00:00:0a:00:00:02 |>>>>
***** Ignored ICMPv6 packets
We are not using router advertisements, so we ignore RS packets
DEBUG:main:INCOMING: <Ether dst=33:33:00:00:00:02 src=00:00:0a:00:00:01 type=0x86dd |<IPv6 version=6 tc=0 fl=0 plen=16 nh=ICMPv6 hlim=255 src=fe80::200:aff:fe00:1 dst=ff02::2 |<ICMPv6ND_RS type=Router Solicitation code=0 cksum=0xf72e res=0 |<ICMPv6NDOptSrcLLAddr type=1 len=1 lladdr=00:00:0a:00:00:01 |>>>>
**** Static mappings
- likely need table(s)
@ -276,6 +393,10 @@ listening on h1-eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
4 packets received by filter
0 packets dropped by kernel
root@ubuntu:~/master-thesis#
***** When pinging we see
DEBUG:main:INCOMING: <Ether dst=33:33:ff:00:00:42 src=00:00:0a:00:00:01 type=0x86dd |<IPv6 version=6 tc=0 fl=0 plen=32 nh=ICMPv6 hlim=255 src=2001:db8:61::1 dst=ff02::1:ff00:42 |<ICMPv6ND_NS type=Neighbor Solicitation code=0 cksum=0xd343 res=0 tgt=2001:db8:61::42 |<ICMPv6NDOptSrcLLAddr type=1 len=1 lladdr=00:00:0a:00:00:01 |>>>>
DEBUG:main:INCOMING: <Ether dst=33:33:ff:00:00:42 src=00:00:0a:00:00:01 type=0x86dd |<IPv6 version=6 tc=0 fl=0 plen=32 nh=ICMPv6 hlim=255 src=2001:db8:61::1 dst=ff02::1:ff00:42 |<ICMPv6ND_NS type=Neighbor Solicitation code=0 cksum=0xd343 res=0 tgt=2001:db8:61::42 |<ICMPv6NDOptSrcLLAddr type=1 len=1 lladdr=00:00:0a:00:00:01 |>>>>
@ -292,12 +413,13 @@ DEBUG:main:INCOMING: <Ether dst=33:33:ff:00:00:42 src=00:00:0a:00:00:01 type=0x
**** Not included
- DNS64 - has already been solved in a different domain
*** References / Follow up
**** RFC 2460 IPv6 (Checksum https://tools.ietf.org/html/rfc2460#section-8.1)
**** RFC 3810 MLD2 https://tools.ietf.org/html/rfc3810
**** RFC 4443 ICMPv6 https://tools.ietf.org/html/rfc4443
**** RFC 4861: https://tools.ietf.org/html/rfc4861 Neighbor discovery
**** RFC 6052: https://tools.ietf.org/html/rfc6052 IPv6 Addressing of IPv4/IPv6 Translators
**** RFC 6586 for deployment experiences using Stateful NAT64.
**** RFC 7757 Explicit Address Mappings for Stateless IP/ICMP Translation
**** RFC 4443 ICMPv6 https://tools.ietf.org/html/rfc4443
**** RFC 4861: https://tools.ietf.org/html/rfc4861 Neighbor discovery
**** RFC 2460 IPv6 (Checksum https://tools.ietf.org/html/rfc2460#section-8.1)
**** EAMT/Jool: https://www.jool.mx/en/eamt.html
**** Solicited node multicast address https://en.wikipedia.org/wiki/Solicited-node_multicast_address
* Proposal / task description
@ -366,3 +488,24 @@ to challenge this notion with three different methods:
As the IPv4 header does not allow embedding IPv6 addresses due to size
limitations, embedding the destination address in a secondary header
might be necessary (possibly encapsulated in UDP).
* Detail LOG
** 2019-02-28
*** pinging in router mode: nothing shown in the controller, multicast forwarded -> "ok"
root@ubuntu:~/master-thesis/p4app# ping6 -c1 2001:db8:61::42
PING 2001:db8:61::42(2001:db8:61::42) 56 data bytes
From 2001:db8:61::1 icmp_seq=1 Destination unreachable: Address unreachable
--- 2001:db8:61::42 ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms
root@ubuntu:~/master-thesis/p4app#
sudo: unable to resolve host ubuntu
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on h1-eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
09:47:07.191569 IP6 2001:db8:61::1 > ff02::1:ff00:42: ICMP6, neighbor solicitation, who has 2001:db8:61::42, length 32
09:47:08.190331 IP6 2001:db8:61::1 > ff02::1:ff00:42: ICMP6, neighbor solicitation, who has 2001:db8:61::42, length 32
09:47:09.190279 IP6 2001:db8:61::1 > ff02::1:ff00:42: ICMP6, neighbor solicitation, who has 2001:db8:61::42, length 32
*** TODO special rule for ff02::1:ff00:42