From 3a39ec6d9b87fe65e1896e1da1b460f9b01498fe Mon Sep 17 00:00:00 2001 From: dmiller Date: Tue, 14 Oct 2025 18:43:59 +0000 Subject: [PATCH] Ignore RTN_UNSPEC, possible with -e and -S. Fixes #2955 --- libnetutil/netutil.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libnetutil/netutil.cc b/libnetutil/netutil.cc index e7d0783d7..830bf4c92 100644 --- a/libnetutil/netutil.cc +++ b/libnetutil/netutil.cc @@ -3313,7 +3313,7 @@ static int route_dst_netlink(const struct sockaddr_storage *dst, len -= NLMSG_LENGTH(sizeof(*nlmsg)); /* See rtnetlink(7). Anything matching this route is actually unroutable. */ - if (rtmsg->rtm_type == RTN_UNREACHABLE || rtmsg->rtm_type == RTN_UNSPEC + if (rtmsg->rtm_type == RTN_UNREACHABLE || rtmsg->rtm_type == RTN_BLACKHOLE || rtmsg->rtm_type == RTN_PROHIBIT) return 0; @@ -3353,6 +3353,11 @@ static int route_dst_netlink(const struct sockaddr_storage *dst, if (ii != NULL) { rnfo->ii = *ii; + if (rnfo->srcaddr.ss_family == AF_UNSPEC) { + assert(!spoofss); + assert(rnfo->ii.addr.ss_family == dst->ss_family); + rnfo->srcaddr = rnfo->ii.addr; + } return 1; } else { return 0;