From nobody Thu Mar 14 08:29:42 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TwLCW1TXNz5FSJl; Thu, 14 Mar 2024 08:29:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TwLCW0zh5z43DB; Thu, 14 Mar 2024 08:29:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1710404983; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6ZKfxLHTUTUxiWlu+7ayETeuuokajA5tPfB1x2w7nRs=; b=ZyNckWSmyTiG1wmMj9RpSGzAjvuG32rvz+lkN5qYP/2AT/WZ5D+UImiCtUYnlLQRTtAdsL nJzg+c/iZef4CBpjjrs6L1kzG/fTiCT8FcRBHSYeWeVPoB1+TqRXs1OkmuiiQcIHzAQF99 V4Sd2snbw7wAcdC1UybqpTJ9SvSBBVsgXLmUpvViZKe7hc1DdD0Au8Rzz/dvvpLt6DFdLP al2taN6GrIvEVUk41mD5JoeJ7ZhreX0Ro5R/+BAnEGQrJGQtGoHAXK4fYHfZv9Zrt1cItD xDv3hG//5s93AB3FxQbS3sI0Z7FrjeZNGIMm8AeXFMP/GdoRcWinT/DVTxUIxQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1710404983; a=rsa-sha256; cv=none; b=jNgr1vwLww/VN2DkW104YeRHyY/rI4X5qpqPeCUrLqQRkJYJQxHse+AxgERL5jZbAhXWdO 52oOY3pGMDW0k0qlYPbFYCX/ErEiG2j/+S+5D/TNCed4g94IecbfVkHifDAjlF3XBbXP2S GssnT65D0p8xIKSNZ6tOm1J+/e10LigLddPjO+dtfqpwZ0jFxK4RjcVRH8YaSDn/LU89Gu Ss5XXhUdcTI1GITvG13pTaiuzEOsa2TWQ+vPkWC68+tzbEBsV7iiP9r19cj4YTnPx82L3o Oc7/E+aeYdN8pxS1aTw+vOs5+mZmaNRlSS5Ex33VeWCCQp9386/nicQG+FN8Uw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1710404983; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6ZKfxLHTUTUxiWlu+7ayETeuuokajA5tPfB1x2w7nRs=; b=bK1TQzHuE0Axh5/usXFj0XWcKqEpR7hVofzey9pRTgWaxDbF4zr6Ne2pdawQ0muBVHwA2b 6l39SjvZXBr5D2bYt5TfCAHDiWLx/fitbvsoDVr/rLUDM80d0+GpMdoprlcu+2za/gz3If PcIepPEQzpCl767rHP2fPb4eLUvhpiZKQ2KQYSAlEa4VR2+wW1vjNlvPU/HH/0h26wLL+S tRl9YwwZROWnXVR/A35tn4qRf5T1tua74tKP6T6FaxzW4T1CQEewBwwPoFKtilE96Y1fDx h3Pt7dSAvaUJhJI/I9QJaWHuPSi+sOD+O30otHhMnnw+JCO0SYcXGEntvB3vOg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TwLCW0SgNzKN2; Thu, 14 Mar 2024 08:29:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 42E8TgtX006366; Thu, 14 Mar 2024 08:29:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 42E8TgRp006363; Thu, 14 Mar 2024 08:29:42 GMT (envelope-from git) Date: Thu, 14 Mar 2024 08:29:42 GMT Message-Id: <202403140829.42E8TgRp006363@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Zhenlei Huang Subject: git: 7a4a122f9731 - stable/14 - netlink: fix adding an interface route List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: zlei X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 7a4a122f9731c589831e1c00d85588ff9813b338 Auto-Submitted: auto-generated The branch stable/14 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=7a4a122f9731c589831e1c00d85588ff9813b338 commit 7a4a122f9731c589831e1c00d85588ff9813b338 Author: KUROSAWA Takahiro AuthorDate: 2023-11-28 18:14:50 +0000 Commit: Zhenlei Huang CommitDate: 2024-03-14 08:27:42 +0000 netlink: fix adding an interface route route add -iface " for a netif without an IPv4/IPv6 address fails with EINVAL. Need to use a link-level ifaddr for gw if an ifaddr for dst is not found as the rtsock-based implementation does. PR: 275341 Reported by: Sean Cody Reviewed by: rcm Tested by: rcm Approved by: kp (mentor) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D41330 (cherry picked from commit f818559774cb0c1516364c4beca361480fd68b5b) --- sys/netlink/route/rt.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sys/netlink/route/rt.c b/sys/netlink/route/rt.c index cfaa2167b0d2..ed09748995dc 100644 --- a/sys/netlink/route/rt.c +++ b/sys/netlink/route/rt.c @@ -750,9 +750,14 @@ finalize_nhop(struct nhop_object *nh, const struct sockaddr *dst, int *perror) struct ifaddr *ifa = ifaof_ifpforaddr(gw_sa, nh->nh_ifp); if (ifa == NULL) { - NL_LOG(LOG_DEBUG, "Unable to determine ifa, skipping"); - *perror = EINVAL; - return (NULL); + /* Try link-level ifa. */ + gw_sa = &nh->gw_sa; + ifa = ifaof_ifpforaddr(gw_sa, nh->nh_ifp); + if (ifa == NULL) { + NL_LOG(LOG_DEBUG, "Unable to determine ifa, skipping"); + *perror = EINVAL; + return (NULL); + } } nhop_set_src(nh, ifa); }