git: 4ed0eef0db41 - stable/13 - routing: fix crash when RTM_CHANGE results in no-op for the multipath route.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 13 Jan 2023 21:25:21 UTC
The branch stable/13 has been updated by melifaro:
URL: https://cgit.FreeBSD.org/src/commit/?id=4ed0eef0db41afaf54bdb1d5bc436a5d7845a651
commit 4ed0eef0db41afaf54bdb1d5bc436a5d7845a651
Author: Alexander V. Chernikov <melifaro@FreeBSD.org>
AuthorDate: 2022-06-25 19:32:59 +0000
Commit: Alexander V. Chernikov <melifaro@FreeBSD.org>
CommitDate: 2023-01-13 21:24:10 +0000
routing: fix crash when RTM_CHANGE results in no-op for the multipath
route.
Reporting logic assumed there is always some nhop change for every
successful modification operation. Explicitly check that the changed
nexthop indeed exists when reporting back to userland.
MFC after: 2 weeks
Reported by: Claudio Jeker <claudio.jeker@klarasystems.com>
Tested by: Claudio Jeker <claudio.jeker@klarasystems.com>
(cherry picked from commit c260d5cd8e364ad448ba714d9f851976c6f8da51)
---
sys/net/rtsock.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index 6826b4e82368..256c4a96af73 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1137,9 +1137,12 @@ route_output(struct mbuf *m, struct socket *so, ...)
rc = rc_simple;
}
#endif
+ /* nh MAY be empty if RTM_CHANGE request is no-op */
nh = rc.rc_nh_new;
- rtm->rtm_index = nh->nh_ifp->if_index;
- rtm->rtm_flags = rc.rc_rt->rte_flags | nhop_get_rtflags(nh);
+ if (nh != NULL) {
+ rtm->rtm_index = nh->nh_ifp->if_index;
+ rtm->rtm_flags = rc.rc_rt->rte_flags | nhop_get_rtflags(nh);
+ }
}
break;
@@ -1176,7 +1179,7 @@ route_output(struct mbuf *m, struct socket *so, ...)
senderr(EOPNOTSUPP);
}
- if (error == 0) {
+ if (error == 0 && nh != NULL) {
error = update_rtm_from_rc(&info, &rtm, alloc_len, &rc, nh);
/*
* Note that some sockaddr pointers may have changed to