git: e58c8da0683d - main - Map IPv6 link-local prefix to the link-local ifa.

Alexander V. Chernikov melifaro at FreeBSD.org
Wed Jan 13 10:05:29 UTC 2021


The branch main has been updated by melifaro:

URL: https://cgit.FreeBSD.org/src/commit/?id=e58c8da0683dcff6ce3432bdfa98f7271140cda3

commit e58c8da0683dcff6ce3432bdfa98f7271140cda3
Author:     Alexander V. Chernikov <melifaro at FreeBSD.org>
AuthorDate: 2021-01-12 23:14:03 +0000
Commit:     Alexander V. Chernikov <melifaro at FreeBSD.org>
CommitDate: 2021-01-13 10:03:15 +0000

    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
---
 sys/netinet6/in6_ifattach.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sys/netinet6/in6_ifattach.c b/sys/netinet6/in6_ifattach.c
index 81cd24823f10..1a07fb13b179 100644
--- a/sys/netinet6/in6_ifattach.c
+++ b/sys/netinet6/in6_ifattach.c
@@ -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);
 


More information about the dev-commits-src-all mailing list