From nobody Fri Jan 13 21:25:21 2023 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 4Ntvb6436Bz2ql9Z; Fri, 13 Jan 2023 21:25:22 +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 4Ntvb554b7z427G; Fri, 13 Jan 2023 21:25:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673645121; 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=IlrduouJmb9IyUOq2B7dnhWmSvF32mpFuiC3WAOLqCI=; b=jLpTOGO/QvaLRy01SP/apBf1xlJ34kRUmBbGKMOeOUE4ffYMIjyxoq0OSzSFgwRmyiJM4k D2+YVUoYM0iHYFnWFMrDwws5q+KJ2Nk6xg9e1rIOlWdyNWqgLU49ZoBIeTkJWzvne36VwZ b21yYIfHTTH6ZnIIqYIjkIfG2KHESxZc93XSeDc8ELa0NJHWeTAu1P9Z9BaLN56PJic6Ex uYUXxqAUO41QOYzpYw4iENRh+dhMwKWBlMZEKwqi5vrIxrTyU/EMIk04KtuTpoM2RuRS+w VnUArwiGDxfnagpCMliqVtx0I5VKWhfppbH4h7qNm+KfwVGClL8LfYPSOljplA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673645121; 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=IlrduouJmb9IyUOq2B7dnhWmSvF32mpFuiC3WAOLqCI=; b=CHSRAef0yuR8OtkGxchSqhohVzaZhmNCmKt0cUBNN7PNAu3dJn8iqRiIjwNNN5VZVieZYK Kg52dIyJDDUBsSnmIfHLmhRnjvuqjs91jBcKFAZS9EbBxSkrOpYda6RP+PGQf6CdIYCKzz QB8Ji+/Zo46cpMpdZque5lgSppl2/HddMSw+Oo+MVgzXYyG5REykxUBxcvvdbefHHSEQkN a1Mo9NdbPCG/dNyd2zH2fbt49n46jQEqX1ED4QuB3nKsg895DmhQd4p0HVgYF4sirz6+F8 TLsPPr0g9WchH5ZLpCrE83XmU8EnOX0HKchfLD/15z7pXiDfOFMsJkzlseJUDw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673645121; a=rsa-sha256; cv=none; b=AOjYIVutmUqjaiBY/DvkWXOjL0ohV9g70wGHk/S+adLoaW43Ss5Rv7ylvGAWCqxKroRzNI sAVHag4SNXUZ8CRjPN9q0VSNxiblUap4aS/xJtfQcbtfVUMItxe/5NcvOPkkfaM7FhzXFs h5k/SUmZDLdlVSg1UvritxCBmEdu35NaQI2J0q/3LhRa+SICscP2lD67oqwW6UrNtAtDzo mSbRnr4ewZWZwtST3IvM6ktJdL4rSM9pEuq7ysb9eDKJS3PNSMk+RumPLoMbghLWDZ0HCr V4b6f8ArS86c6gvYcAYvzB9lI8cgrx5GvA+FgsgsSZLAvBmL30kqdUyOfYpUNg== 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 4Ntvb54BB1zMrW; Fri, 13 Jan 2023 21:25:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 30DLPLMQ041733; Fri, 13 Jan 2023 21:25:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30DLPLoR041732; Fri, 13 Jan 2023 21:25:21 GMT (envelope-from git) Date: Fri, 13 Jan 2023 21:25:21 GMT Message-Id: <202301132125.30DLPLoR041732@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: 4ed0eef0db41 - stable/13 - routing: fix crash when RTM_CHANGE results in no-op for the multipath 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: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 4ed0eef0db41afaf54bdb1d5bc436a5d7845a651 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=4ed0eef0db41afaf54bdb1d5bc436a5d7845a651 commit 4ed0eef0db41afaf54bdb1d5bc436a5d7845a651 Author: Alexander V. Chernikov AuthorDate: 2022-06-25 19:32:59 +0000 Commit: Alexander V. Chernikov 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 Tested by: Claudio Jeker (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