Page MenuHomeFreeBSD

[lltable] Add support for "child" LLEs holding encap for IPv4oIPv6 entries.
ClosedPublic

Authored by melifaro on Aug 2 2021, 10:32 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Sep 27, 6:13 PM
Unknown Object (File)
Fri, Sep 27, 12:31 AM
Unknown Object (File)
Wed, Sep 25, 5:09 AM
Unknown Object (File)
Tue, Sep 24, 4:20 PM
Unknown Object (File)
Mon, Sep 23, 9:33 PM
Unknown Object (File)
Mon, Sep 23, 9:30 PM
Unknown Object (File)
Mon, Sep 23, 9:25 PM
Unknown Object (File)
Mon, Sep 23, 9:24 PM
Subscribers

Details

Summary

Currently we use pre-calculated headers inside the LLE entries as prepend data for if_output functions. Using these headers allows saving some CPU cycles/memory accesses on the fast path.

However, this approach makes adding L2 header for IPv4 traffic with IPv6 nexthops a bit complex, as we are not able to store multiple pre-calculated headers per lle. Additionally, the solution space is limited by the fact that PCB caching saves LLEs in addition to the nexthop.

Thus, add support for creating special "child" LLEs for the purpose of holding custom family encaps and store pending mbufs.
These LLEs are stored in a linked-list inside a "parent" (e.g. normal) LLE and are not visible when iterating LLE table.
They leverage RTF_STATIC logic, avoiding complex state machine used by the standard LLEs.
"Child" LLE lifetime is bound to the "parent" LLE lifetime - it is not possible to delete "child" LLE if parent is alive.

Note: the code below uses LLE_SF() macro which packs family and flags in a single int field. This is done to simplify merging back to stable/ branch. Once this code lands, most of the cases will be converted to use a dedicated family paremeter.

Test Plan
20:27 [0] m@devel2 s /usr/obj/usr/home/melifaro/free/head/amd64.amd64/sbin/route/route add -host 10.1.1.1 fe80::5054:ff:fe42:fef%vtnet0

20:30 [0] m@devel2 netstat -4rnW
Routing tables

Internet:
Destination        Gateway            Flags   Nhop#    Mtu      Netif Expire
default            10.0.0.1           UGS         4   1500     vtnet0
10.0.0.0/24        link#1             U           2   1500     vtnet0
10.0.0.8           link#1             UHS         3  16384        lo0
10.1.1.1           fe80::5054:ff:fe42:fef%vtnet0 UGHS      5   1500     vtnet0
127.0.0.1          link#2             UH          1  16384        lo0
20:30 [0] m@devel2 netstat -4onW
Nexthop data

Internet:
Idx   Type         IFA                Gateway             Flags      Use Mtu         Netif     Addrif Refcnt Prepend
1       v4/resolve 127.0.0.1          lo0/resolve        H             0  16384        lo0               2
2       v4/resolve 10.0.0.8           vtnet0/resolve                1007   1500     vtnet0               3
3       v4/resolve 127.0.0.1          lo0/resolve        HS            0  16384        lo0    vtnet0     2
4            v4/gw 10.0.0.8           10.0.0.1           GS           16   1500     vtnet0               2
5            v4/gw 10.0.0.8           fe80::5054:ff:fe42:fef%vtnet0 GHS        0   1500     vtnet0               2

20:31 [0] m@devel2 ndp -an
Neighbor                             Linklayer Address  Netif Expire    S Flags
2a01:4f8:13a:70c:ffff::1             52:54:00:d7:5f:09 vtnet0 23h56m3s  S R
2a01:4f8:13a:70c:ffff::8             52:54:00:14:e3:19 vtnet0 permanent R
fe80::5054:ff:fe14:e319%vtnet0       52:54:00:14:e3:19 vtnet0 permanent R
fe80::5054:ff:fed7:5f09%vtnet0       52:54:00:d7:5f:09 vtnet0 23h56m14s S R
20:31 [0] m@devel2
20:31 [0] m@devel2
20:31 [0] m@devel2
20:31 [0] m@devel2 ping -c1 10.1.1.1
PING 10.1.1.1 (10.1.1.1): 56 data bytes
64 bytes from 10.1.1.1: icmp_seq=0 ttl=64 time=0.744 ms

--- 10.1.1.1 ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.744/0.744/0.744/0.000 ms
20:31 [0] m@devel2 ndp -an
Neighbor                             Linklayer Address  Netif Expire    S Flags
2a01:4f8:13a:70c:ffff::1             52:54:00:d7:5f:09 vtnet0 23h55m50s S R
2a01:4f8:13a:70c:ffff::8             52:54:00:14:e3:19 vtnet0 permanent R
fe80::5054:ff:fe14:e319%vtnet0       52:54:00:14:e3:19 vtnet0 permanent R
fe80::5054:ff:fe42:fef%vtnet0        52:54:00:42:0f:ef vtnet0 29s       R
fe80::5054:ff:fed7:5f09%vtnet0       52:54:00:d7:5f:09 vtnet0 23h56m1s  S R

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

melifaro edited the test plan for this revision. (Show Details)

.

sbin/route/route.c
1195 ↗(On Diff #93144)

I'm currently passing IPv6 next-hop like this:
route add -host 10.1.1.1 inet6 fe80::5054:ff:fe42:fef%vtnet0 , so we do not need to guess the address family.

sys/net/if_llatbl.c
496

This has been committed in main. Better to exclude this to help reviewing :)

761

I'm not familiar with CK_SLIST, but it seems that child_lle is not removed from child_lle->lle_parent->lle_children .

sys/netinet6/nd6.c
2345

Possible null pointer here. Missing else ?

sbin/route/route.c
1195 ↗(On Diff #93144)

Oh yeah,

sys/net/if_llatbl.c
496

Yeah, I’ll commit another part of the diff and update this one today.
Could you actually rebase your diff based on this one, so we can have a clean testable diff chain?

761

Yeah, this looks misleading. The rationale here is the following - we never delete a child wo deleting a parent, so we dont need to bother w/ll and the complexity of the lock ordering. I’ll look at this once again

sys/netinet6/nd6.c
2345

Whoops, good catch!

Fix missed AF_INET6 in nd6_resolve_slow().

This revision is now accepted and ready to land.Aug 20 2021, 3:35 PM