git: a48df53e4249 - main - nd6: Fix the routing table subscription

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Thu, 25 Jul 2024 14:27:49 UTC
The branch main has been updated by markj:

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

commit a48df53e4249499be3e8779dd30888a405aa81ae
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-07-25 14:26:36 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-07-25 14:27:39 +0000

    nd6: Fix the routing table subscription
    
    The nd6 code listens for RTM_DELETE events so that it can mark the
    corresponding default router as inactive in the case where the default
    route is deleted.  A subsequent RA from the router may then reinstall
    the default route.
    
    Commit fedeb08b6a58e broke this for non-multipath routes, as
    rib_decompose_notification() only invokes the callback for multipath
    routes.  Restore the old behaviour.  Also ensure that we update the
    router only for RTM_DELETE notifications, lost in commit 2259a03020fe0.
    
    Reviewed by:    bz
    Fixes:  fedeb08b6a58 ("Introduce scalable route multipath.")
    Fixes:  2259a03020fe ("Rework part of routing code to reduce difference to D26449.")
    MFC after:      2 weeks
    Sponsored by:   Klara, Inc.
    Sponsored by:   Bell Tower Integration
    Differential Revision:  https://reviews.freebsd.org/D46020
---
 sys/netinet6/nd6.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c
index 3eacb05f88d7..e1fd421060df 100644
--- a/sys/netinet6/nd6.c
+++ b/sys/netinet6/nd6.c
@@ -1614,8 +1614,7 @@ check_release_defrouter(const struct rib_cmd_info *rc, void *_cbdata)
 	struct nhop_object *nh;
 
 	nh = rc->rc_nh_old;
-
-	if ((nh != NULL) && (nh->nh_flags & NHF_DEFAULT)) {
+	if (rc->rc_cmd == RTM_DELETE && (nh->nh_flags & NHF_DEFAULT) != 0) {
 		dr = defrouter_lookup(&nh->gw6_sa.sin6_addr, nh->nh_ifp);
 		if (dr != NULL) {
 			dr->installed = 0;
@@ -1627,9 +1626,10 @@ check_release_defrouter(const struct rib_cmd_info *rc, void *_cbdata)
 void
 nd6_subscription_cb(struct rib_head *rnh, struct rib_cmd_info *rc, void *arg)
 {
-
 #ifdef ROUTE_MPATH
 	rib_decompose_notification(rc, check_release_defrouter, NULL);
+	if (rc->rc_cmd == RTM_DELETE && !NH_IS_NHGRP(rc->rc_nh_old))
+		check_release_defrouter(rc, NULL);
 #else
 	check_release_defrouter(rc, NULL);
 #endif