git: 0e77fc2a79ed - stable/13 - routing: Fix newly-added rt_get_inet[6]_parent() api.

Alexander V. Chernikov melifaro at FreeBSD.org
Tue Sep 7 21:13:03 UTC 2021


The branch stable/13 has been updated by melifaro:

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

commit 0e77fc2a79ed047cfddd0190795aff21dddf4a1c
Author:     Alexander V. Chernikov <melifaro at FreeBSD.org>
AuthorDate: 2021-08-30 21:10:37 +0000
Commit:     Alexander V. Chernikov <melifaro at FreeBSD.org>
CommitDate: 2021-09-07 21:02:59 +0000

    routing: Fix newly-added rt_get_inet[6]_parent() api.
    
    Correctly handle the case when no default route is present.
    
    Reported by:    Konrad <konrad.kreciwilk at korbank.pl>
    
    (cherry picked from commit f84c30106e8b725774b4e9a32c8dd11c90da8c25)
---
 sys/net/route/route_helpers.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/sys/net/route/route_helpers.c b/sys/net/route/route_helpers.c
index 569e13a308eb..0696eec416b1 100644
--- a/sys/net/route/route_helpers.c
+++ b/sys/net/route/route_helpers.c
@@ -434,6 +434,9 @@ get_inet_parent_prefix(uint32_t fibnum, struct in_addr addr, int plen)
 	struct radix_node *rn;
 
 	rt = fib4_lookup_rt(fibnum, addr, 0, NHR_UNLOCKED, &rnd);
+	if (rt == NULL)
+		return (NULL);
+
 	rt_get_inet_prefix_plen(rt, &addr4, &parent_plen, &scopeid);
 	if (parent_plen <= plen)
 		return (rt);
@@ -503,6 +506,9 @@ get_inet6_parent_prefix(uint32_t fibnum, const struct in6_addr *paddr, int plen)
 	struct radix_node *rn;
 
 	rt = fib6_lookup_rt(fibnum, paddr, 0, NHR_UNLOCKED, &rnd);
+	if (rt == NULL)
+		return (NULL);
+
 	rt_get_inet6_prefix_plen(rt, &addr6, &parent_plen, &scopeid);
 	if (parent_plen <= plen)
 		return (rt);


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