Map IPv6 link-local prefix to the link-local ifa.

Currently we create link-local route by creating an always-on IPv6 prefix
 in the prefix list. This prefix is not tied to the link-local ifa.

This leads to the following problems:

First, when flushing interface addresses we skip on-link route, leaving
 fe80::/64 prefix on the interface without any IPv6 addresses.
Second, when creating and removing link-local alias we lose fe80::/64 prefix
 from the routing table.

Fix this by attaching link-local prefix to the ifa at the initial creation.

Reviewed by:	hrs
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D28129
This commit is contained in:
Alexander V. Chernikov 2021-01-12 23:14:03 +00:00
parent a339b4223a
commit e58c8da068

View File

@ -520,8 +520,11 @@ in6_ifattach_linklocal(struct ifnet *ifp, struct ifnet *altifp)
* valid with referring to the old link-local address.
*/
if ((pr = nd6_prefix_lookup(&pr0)) == NULL) {
if ((error = nd6_prelist_add(&pr0, NULL, NULL)) != 0)
if ((error = nd6_prelist_add(&pr0, NULL, &pr)) != 0)
return (error);
/* Reference prefix */
ia->ia6_ndpr = pr;
pr->ndpr_addrcnt++;
} else
nd6_prefix_rele(pr);