From nobody Sat Jun 25 19:41:54 2022 X-Original-To: dev-commits-src-main@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 78A1F86AAAC; Sat, 25 Jun 2022 19:41:54 +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 4LVkry2kzfz3j4x; Sat, 25 Jun 2022 19:41:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656186114; 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=pBmLJfcisz3eR5gaTTGCy4Ercob7xAW8SXBQbci9SAA=; b=BON2RlXJF+xaNOkXuwlVDvyQnldXQUDIpk3HI0AeEC8RU8IsNRz+7rNx37inkWfyclNcBv x+NWEw7gIHsrnJEkuajT2XMyNQiHg2wIbkOnu3EaTePyYpiQjGJGqj2unbD3eFjvRl38Zs Lt9QHxDIs8Am8me90gIjXg1XdIepCVcbfklmBvm0/Ca+/HsWoos4nTS1JmtvBNZRp1peHo 0OPQj8zfAAX/7OFE3znzOLwCu9mTdYOT5i99l59x/CzQDjPPaXGgAdeMxDlDi0aQIcBOGY KQTIKt7Cglal3XSV4J7aeAuuLSTiy3F4cBL2C1zESHkQaDJYcCYpDFLnSS1Drw== 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 3DF332C42; Sat, 25 Jun 2022 19:41:54 +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 25PJfssI057368; Sat, 25 Jun 2022 19:41:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25PJfsaM057367; Sat, 25 Jun 2022 19:41:54 GMT (envelope-from git) Date: Sat, 25 Jun 2022 19:41:54 GMT Message-Id: <202206251941.25PJfsaM057367@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: c260d5cd8e36 - main - routing: fix crash when RTM_CHANGE results in no-op for the multipath route. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: c260d5cd8e364ad448ba714d9f851976c6f8da51 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656186114; 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=pBmLJfcisz3eR5gaTTGCy4Ercob7xAW8SXBQbci9SAA=; b=JP/hhD2TNgtm8RkT4KBfJ4bf87QsSOpC22GGG9RAn85WgEFGVsE3hX2Jbg143eNqVIwquc fPkwd0QMG3clsg1KPHf/i8z+JlFA8OBI4H5xdWcz3CgCSgP6xGproa2wLEse0Rw/8L0ufq jEbRs7Ao2A8gCjGRvmJG/DpgFl2u1OvdDwrAJPmAXbEACFZCPsMsnyPrsqkjwVHoKQWNjL q0mVjNZnjVy0hwr5XN4CjSZqRl/cyN2SVTO0ca3EaCZYv1MLlAKFNV41OfMp7hSZJSxdP9 02HwCEQNW/6E4VaG+4RQqByd2cU0SNFi2gUhE2K7GztJ/ucJqIaRSPmdvcbGKQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1656186114; a=rsa-sha256; cv=none; b=a+gVWyN+7nhenn7uOUvUATLVZMlykW9IN05b03WC08i7KcE25i7O7k3ouizITDh/syZfU+ 4f4utjkygzxZSC95WORND56o4gmMMOrursU4N+L46ZGTl5gz2m3Q6Ku6c5uI7TfX3F6fCG zG8Utwh1EW6Pk6f3UpdrD2DXr4kjPZB6AKbXxFJoODbU0bdawso1KFgNhGOAJOc6y7Kmdy v+jLASjj9r+f8uICGLX65fIEywBxYK+o3ePQ+XY0bXgKfXru/ZO1TN1ksUcn22L2RdLPN9 BUelk9+YcD8kc6wEYxdfDSg1aOv0WtbPsLG/En/Y+kANTqp1LEWxGAQkArtDGw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=c260d5cd8e364ad448ba714d9f851976c6f8da51 commit c260d5cd8e364ad448ba714d9f851976c6f8da51 Author: Alexander V. Chernikov AuthorDate: 2022-06-25 19:32:59 +0000 Commit: Alexander V. Chernikov CommitDate: 2022-06-25 19:35:09 +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 --- 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 bbdd0279a04c..6775f09cfe50 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1124,9 +1124,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; @@ -1163,7 +1166,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