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@hecian.net>
MFC after:	immediately
This commit is contained in:
Alexander V. Chernikov 2021-02-23 22:31:07 +00:00
parent bbacb7ce72
commit 9c4a8d24f0

View file

@ -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);
}