git: ea10694336b9 - stable/13 - Fix nd6 rib_action() handling.

Alexander V. Chernikov melifaro at FreeBSD.org
Tue Feb 23 22:44:02 UTC 2021


The branch stable/13 has been updated by melifaro:

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

commit ea10694336b9a07d58d22187052291976f4906b2
Author:     Alexander V. Chernikov <melifaro at FreeBSD.org>
AuthorDate: 2021-02-23 22:31:07 +0000
Commit:     Alexander V. Chernikov <melifaro at FreeBSD.org>
CommitDate: 2021-02-23 22:42:28 +0000

    Fix nd6 rib_action() handling.
    
    rib_action() guarantees valid rc filling IFF it returns without error.
    Check rib_action() return code instead of checking rc fields.
    
    PR:             253800
    Reported by:    Frederic Denis <freebsdml at hecian.net>
    
    (cherry picked from commit 9c4a8d24f0ffd5243fa5c6fe27178f669f16d1f5)
---
 sys/netinet6/nd6_rtr.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c
index eca704dc2843..51b831a956bc 100644
--- a/sys/netinet6/nd6_rtr.c
+++ b/sys/netinet6/nd6_rtr.c
@@ -698,12 +698,11 @@ defrouter_addreq(struct nd_defrouter *new)
 
 	NET_EPOCH_ASSERT();
 	error = rib_action(fibnum, RTM_ADD, &info, &rc);
-	if (rc.rc_rt != NULL) {
+	if (error == 0) {
 		struct nhop_object *nh = nhop_select(rc.rc_nh_new, 0);
 		rt_routemsg(RTM_ADD, rc.rc_rt, nh, fibnum);
-	}
-	if (error == 0)
 		new->installed = 1;
+	}
 }
 
 /*
@@ -719,6 +718,7 @@ defrouter_delreq(struct nd_defrouter *dr)
 	struct rib_cmd_info rc;
 	struct epoch_tracker et;
 	unsigned int fibnum;
+	int error;
 
 	bzero(&def, sizeof(def));
 	bzero(&mask, sizeof(mask));
@@ -737,8 +737,8 @@ defrouter_delreq(struct nd_defrouter *dr)
 	info.rti_info[RTAX_NETMASK] = (struct sockaddr *)&mask;
 
 	NET_EPOCH_ENTER(et);
-	rib_action(fibnum, RTM_DELETE, &info, &rc);
-	if (rc.rc_rt != NULL) {
+	error = rib_action(fibnum, RTM_DELETE, &info, &rc);
+	if (error == 0) {
 		struct nhop_object *nh = nhop_select(rc.rc_nh_old, 0);
 		rt_routemsg(RTM_DELETE, rc.rc_rt, nh, fibnum);
 	}


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