From nobody Fri Sep 02 19:17:21 2022 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 4MK72p0pcDz4bVLq; Fri, 2 Sep 2022 19:17: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 4MK72p0N5jz3pjf; Fri, 2 Sep 2022 19:17:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662146242; 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=QTa9qYAQ6lRIOFX8jLH05WFntEEPxplI9jooccY/VZo=; b=O/HCbwjUk7I+c0zs+5cZOqBnHCNEFJ7DITUJJvcpI70xdpHBnHk65CLpK6+mXNk8tsXYk0 xej+9bbXt8EtldFjgmOEcpowWUQ+nAeP3wP6QaYfNUOXQKvpHD1W7nLwbkwHOJe5l/bZBN aHjMJndKXNib0ARXJTZEga7cvW7ZnrPQ3s0lmO4yLD0NVdOwEQKhHlPKITKkErWwG2WNO/ jtnIDHPxsxvKMhxv8lcUJ8Fs6ABtvztxmjwYkSv5G46mGVqG6/xRIOyz/9IhHeEDq22x38 ybomY7LR1q1YjyGiGKPC+iVjk4tw/S2wRFHSB+wRT11BeWq4BcZvUgx2kOrL8Q== 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 4MK72n6Djgztw9; Fri, 2 Sep 2022 19:17: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 282JHL9M042799; Fri, 2 Sep 2022 19:17:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 282JHLSM042798; Fri, 2 Sep 2022 19:17:21 GMT (envelope-from git) Date: Fri, 2 Sep 2022 19:17:21 GMT Message-Id: <202209021917.282JHLSM042798@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 74ed2e8ab202 - main - raw ip: fix regression with multicast and RSVP 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: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 74ed2e8ab20264595bfbf67c117462df68b856ce Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662146242; 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=QTa9qYAQ6lRIOFX8jLH05WFntEEPxplI9jooccY/VZo=; b=N30VAjGGwYt8gjrGZe58m29faAwqILZw/DQR3nczO6nu4fcyNDDbMicBGMTKoJJzfe49Hm +yod5HBj8x3W/xAtQ7LRfE5G6dxWYGcb00eXN0NNIpwwfDwUd1V18/4qnKh4iS3ytJQfEK MioG5AgSeLVYyD8ZhWV3qI53gwc0IIv/BYb2O9msUP+d4HK63LDXiXBsfpmTu3i7hAcaqN LdwTF0ZA1HiMfk81t0OJ6+32sGfrNrdmGLcCLKIooCb0Udk0nFnLzDhWPgMNmTlhuZa/Bj dMZA4ypXmMtWF/tGjH8LsRVk0MGqnflHWGCZQn7wo4biiOMbS5XA1FVLN1GkNA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1662146242; a=rsa-sha256; cv=none; b=GWus2+ciXmFXR365fd+PhV3uBeI8wnHViq220T7+hN6kgQhdGpPqgkbiG9hHkkHBWCZ+C4 Ic53dBiYgEE1nKoFDqqi4xl+W/L/Tf+cgZVHqwxSgI1G+jiDpHfthJDeOFue9Ya7PdE3ab BtSQlmwPjYkDRsSRd1zQIu6a+hJw0kEoUxrEtHvmCh8GwU9jwMdOLsoZGCMxwjaPT4J+0m GkeGTl52Aezi/WawFl18GLr/lMINxyADgHbta+3Q6f8WtNV0w7ooitn/xyOKyi8dyElU5Q SV78k0MTlcH1MlABCuRJ0FsgHLEsLT01KVJNy653cndGf8IlfCwFbFvmzr/vMA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=74ed2e8ab20264595bfbf67c117462df68b856ce commit 74ed2e8ab20264595bfbf67c117462df68b856ce Author: Gleb Smirnoff AuthorDate: 2022-09-02 19:17:09 +0000 Commit: Gleb Smirnoff CommitDate: 2022-09-02 19:17:09 +0000 raw ip: fix regression with multicast and RSVP With 61f7427f02a raw sockets protosw has wildcard pr_protocol. Protocol of a specific pcb is stored in inp_ip_p. Reviewed by: karels Reported by: karels Differential revision: https://reviews.freebsd.org/D36429 Fixes: 61f7427f02a307d28af674a12c45dd546e3898e4 --- sys/netinet/ip_input.c | 4 ---- sys/netinet/ip_mroute.c | 6 +----- sys/netinet/raw_ip.c | 8 ++++++++ sys/netinet6/ip6_mroute.c | 7 +------ sys/netinet6/ip6_output.c | 5 ++--- sys/netinet6/raw_ip6.c | 7 +++++-- 6 files changed, 17 insertions(+), 20 deletions(-) diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 059f26869e0e..41ba82ea81dd 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1313,10 +1313,6 @@ int ip_rsvp_init(struct socket *so) { - if (so->so_type != SOCK_RAW || - so->so_proto->pr_protocol != IPPROTO_RSVP) - return EOPNOTSUPP; - if (V_ip_rsvpd != NULL) return EADDRINUSE; diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index f77898fb3aa4..383f2dfc076e 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -686,11 +686,7 @@ static int ip_mrouter_init(struct socket *so, int version) { - CTR3(KTR_IPMF, "%s: so_type %d, pr_protocol %d", __func__, - so->so_type, so->so_proto->pr_protocol); - - if (so->so_type != SOCK_RAW || so->so_proto->pr_protocol != IPPROTO_IGMP) - return EOPNOTSUPP; + CTR2(KTR_IPMF, "%s: so %p", __func__, so); if (version != 1) return ENOPROTOOPT; diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index 3e7c81341c08..fb5628324020 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -693,6 +693,8 @@ rip_ctloutput(struct socket *so, struct sockopt *sopt) error = priv_check(curthread, PRIV_NETINET_MROUTE); if (error != 0) return (error); + if (inp->inp_ip_p != IPPROTO_IGMP) + return (EOPNOTSUPP); error = ip_mrouter_get ? ip_mrouter_get(so, sopt) : EOPNOTSUPP; break; @@ -747,6 +749,8 @@ rip_ctloutput(struct socket *so, struct sockopt *sopt) error = priv_check(curthread, PRIV_NETINET_MROUTE); if (error != 0) return (error); + if (inp->inp_ip_p != IPPROTO_RSVP) + return (EOPNOTSUPP); error = ip_rsvp_init(so); break; @@ -762,6 +766,8 @@ rip_ctloutput(struct socket *so, struct sockopt *sopt) error = priv_check(curthread, PRIV_NETINET_MROUTE); if (error != 0) return (error); + if (inp->inp_ip_p != IPPROTO_RSVP) + return (EOPNOTSUPP); error = ip_rsvp_vif ? ip_rsvp_vif(so, sopt) : EINVAL; break; @@ -781,6 +787,8 @@ rip_ctloutput(struct socket *so, struct sockopt *sopt) error = priv_check(curthread, PRIV_NETINET_MROUTE); if (error != 0) return (error); + if (inp->inp_ip_p != IPPROTO_IGMP) + return (EOPNOTSUPP); error = ip_mrouter_set ? ip_mrouter_set(so, sopt) : EOPNOTSUPP; break; diff --git a/sys/netinet6/ip6_mroute.c b/sys/netinet6/ip6_mroute.c index 9e864859c279..9465c6662018 100644 --- a/sys/netinet6/ip6_mroute.c +++ b/sys/netinet6/ip6_mroute.c @@ -555,12 +555,7 @@ static int ip6_mrouter_init(struct socket *so, int v, int cmd) { - MRT6_DLOG(DEBUG_ANY, "so_type = %d, pr_protocol = %d", - so->so_type, so->so_proto->pr_protocol); - - if (so->so_type != SOCK_RAW || - so->so_proto->pr_protocol != IPPROTO_ICMPV6) - return (EOPNOTSUPP); + MRT6_DLOG(DEBUG_ANY, "%s: socket %p", __func__, so); if (v != 1) return (ENOPROTOOPT); diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index fc330290d6a3..a1504bfb8da6 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -2451,8 +2451,7 @@ ip6_raw_ctloutput(struct socket *so, struct sockopt *sopt) * values or -1 as a special value. */ error = EINVAL; - } else if (so->so_proto->pr_protocol == - IPPROTO_ICMPV6) { + } else if (inp->inp_ip_p == IPPROTO_ICMPV6) { if (optval != icmp6off) error = EINVAL; } else @@ -2460,7 +2459,7 @@ ip6_raw_ctloutput(struct socket *so, struct sockopt *sopt) break; case SOPT_GET: - if (so->so_proto->pr_protocol == IPPROTO_ICMPV6) + if (inp->inp_ip_p == IPPROTO_ICMPV6) optval = icmp6off; else optval = inp->in6p_cksum; diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c index acc6787d59a7..0a5d343f3725 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -596,7 +596,7 @@ release: int rip6_ctloutput(struct socket *so, struct sockopt *sopt) { - struct inpcb *inp; + struct inpcb *inp = sotoinpcb(so); int error; if (sopt->sopt_level == IPPROTO_ICMPV6) @@ -608,7 +608,6 @@ rip6_ctloutput(struct socket *so, struct sockopt *sopt) else if (sopt->sopt_level != IPPROTO_IPV6) { if (sopt->sopt_level == SOL_SOCKET && sopt->sopt_name == SO_SETFIB) { - inp = sotoinpcb(so); INP_WLOCK(inp); inp->inp_inc.inc_fibnum = so->so_fibnum; INP_WUNLOCK(inp); @@ -629,6 +628,8 @@ rip6_ctloutput(struct socket *so, struct sockopt *sopt) case MRT6_ADD_MFC: case MRT6_DEL_MFC: case MRT6_PIM: + if (inp->inp_ip_p != IPPROTO_ICMPV6) + return (EOPNOTSUPP); error = ip6_mrouter_get ? ip6_mrouter_get(so, sopt) : EOPNOTSUPP; break; @@ -650,6 +651,8 @@ rip6_ctloutput(struct socket *so, struct sockopt *sopt) case MRT6_ADD_MFC: case MRT6_DEL_MFC: case MRT6_PIM: + if (inp->inp_ip_p != IPPROTO_ICMPV6) + return (EOPNOTSUPP); error = ip6_mrouter_set ? ip6_mrouter_set(so, sopt) : EOPNOTSUPP; break;