From nobody Tue Aug 16 19:40:53 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 4M6hMp1RqCz4ZGnn; Tue, 16 Aug 2022 19:40: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 4M6hMp0zZ1z3Vcl; Tue, 16 Aug 2022 19:40:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660678854; 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=FPwWDT92BYv4gf93gwAJOqcghdS9/G4xcLUKWfSyavA=; b=mmGqNgGGnYNj3XDGk+tkHEztKEo2YySyIT7DVHwTmf27Dty1/U/U3RQE06SZU8Ji/D5G2V ds9ZPETGV4ocmS/96Z1hcmo6rR7+MWnATjlA18VpUEB15v6kLXEBTnlyt4t6Y6H3//worw hYcCd4BpO7PXuAnn1WQAKN9A8VbB+RzbyLxaFUDF6kRUcFUZ2lU1SPOi74z9Fzgcao82QO 9gsF1ZKU1Fl5JEqtjuSMs8dujgFIo68HihEynxS2fR8Sy+IlidXM2Alc6ZrWHSPUXbAUp6 5KnCF5fiLC8MmzZaZzGNOcA0cx9uO8zh9Bhtu9dqnZDbdIuC3ksWe9qUOKiIlA== 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 4M6hMp02BCzLl7; Tue, 16 Aug 2022 19:40: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 27GJerCm039481; Tue, 16 Aug 2022 19:40:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27GJercD039480; Tue, 16 Aug 2022 19:40:53 GMT (envelope-from git) Date: Tue, 16 Aug 2022 19:40:53 GMT Message-Id: <202208161940.27GJercD039480@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: c93db4abf454 - main - udp: call UDP methods from UDP over IPv6 directly 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: c93db4abf4545d1bc8cb2b67eacd17f6d1ee6b74 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660678854; 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=FPwWDT92BYv4gf93gwAJOqcghdS9/G4xcLUKWfSyavA=; b=F4qKvwcETKp3u3mQQkjxu584QjqnpSIgZZLtplWKL8tUgR57sTDUQQvKfMTBePf2W55KJk WKptjWtPj+DQ09iDXzInfF+B35ux5tUDbkUE8xKWkWlQm1RcebnYwv3XPQc1oBg41RQfQX AFNy0BkHiqepfkxOCx8omQqSykuh4VjbsUfkXm+Q4y9wKGoMG2FRkS+1+6IG6j5eAzqvA6 LQWdsZl4J30aku0BVO0hDLZJuf7P80a9psPz6BAjskI+DL/StXmWPFVzUYPg9D5YzrP2o5 VAQelCnKB9Apnkk1VZQT5irgfYTnNBqPJ8ks/iODKcGKCpP9945FwRB+wHbfmw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1660678854; a=rsa-sha256; cv=none; b=XEhFa81/ki1RQqIIPcT+FDlgWvgVPcT5AiDfCMaIqjt9qCEsE1B1xeJFDvmj0qFZ1XbRUS s5O+43f8u1LF59qRc3aqqgMSyZPHEvzS3gSZkD2k0xk0aJqwIQuvtT4YduMCXsSnreJZiu ewa34OO3BHZ5wgyTldMxLXePEFbCLKGVjzbypQoIveQiQcBsZqPV3RW2lXU5dWjW177Kaj NztPlkbuhJQbEm1GExup7B7KtGAHIVZIgoqqOgNtaXesKRWYOrFLtUWDWQYAhBz6yZsLwk M1ioY83WDAriwk637QTwl46CCm7kjLIaWdv/6lWkaVyMcknv4lF2BzMM0EjWCA== 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=c93db4abf4545d1bc8cb2b67eacd17f6d1ee6b74 commit c93db4abf4545d1bc8cb2b67eacd17f6d1ee6b74 Author: Gleb Smirnoff AuthorDate: 2022-08-16 19:40:36 +0000 Commit: Gleb Smirnoff CommitDate: 2022-08-16 19:40:36 +0000 udp: call UDP methods from UDP over IPv6 directly Both UDP and UDP Lite use same methods on sockets. Both UDP over IPv4 and over IPv6 use same methods. Don't pretend that methods can switch and remove this unneeded complexity. Reviewed by: melifaro Differential revision: https://reviews.freebsd.org/D36154 --- sys/netinet/udp_usrreq.c | 9 ++++++--- sys/netinet6/udp6_usrreq.c | 37 +++++++++++-------------------------- 2 files changed, 17 insertions(+), 29 deletions(-) diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 86093806dccc..bff82b9718e1 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1490,7 +1490,8 @@ release: return (error); } -static void +pr_abort_t udp_abort; /* shared with udp6_usrreq.c */ +void udp_abort(struct socket *so) { struct inpcb *inp; @@ -1683,7 +1684,8 @@ udp_detach(struct socket *so) udp_discardcb(up); } -static int +pr_disconnect_t udp_disconnect; /* shared with udp6_usrreq.c */ +int udp_disconnect(struct socket *so) { struct inpcb *inp; @@ -1708,7 +1710,8 @@ udp_disconnect(struct socket *so) return (0); } -static int +pr_send_t udp_send; /* shared with udp6_usrreq.c */ +int udp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, struct mbuf *control, struct thread *td) { diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index a7bdfce97707..6a3ac2abd90b 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -131,12 +131,18 @@ VNET_DEFINE(int, zero_checksum_port) = 0; SYSCTL_INT(_net_inet6_udp6, OID_AUTO, rfc6935_port, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(zero_checksum_port), 0, "Zero UDP checksum allowed for traffic to/from this port."); + + +/* netinet/udp_usrreqs.c */ +pr_abort_t udp_abort; +pr_disconnect_t udp_disconnect; +pr_send_t udp_send; + /* * UDP protocol implementation. * Per RFC 768, August, 1980. */ -extern struct protosw inetsw[]; static void udp6_detach(struct socket *so); static int @@ -777,8 +783,6 @@ udp6_output(struct socket *so, int flags_arg, struct mbuf *m, hasv4addr = IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr) ? 1 : 0; if (hasv4addr) { - struct pr_usrreqs *pru; - /* * XXXRW: We release UDP-layer locks before calling * udp_send() in order to avoid recursion. However, @@ -790,9 +794,8 @@ udp6_output(struct socket *so, int flags_arg, struct mbuf *m, INP_UNLOCK(inp); if (sin6) in6_sin6_2_sin_in_sock((struct sockaddr *)sin6); - pru = inetsw[ip_protox[nxt]].pr_usrreqs; /* addr will just be freed in sendit(). */ - return ((*pru->pru_send)(so, flags_arg | PRUS_IPV6, m, + return (udp_send(so, flags_arg | PRUS_IPV6, m, (struct sockaddr *)sin6, control, td)); } } else @@ -1003,14 +1006,8 @@ udp6_abort(struct socket *so) INP_WLOCK(inp); #ifdef INET if (inp->inp_vflag & INP_IPV4) { - struct pr_usrreqs *pru; - uint8_t nxt; - - nxt = (inp->inp_socket->so_proto->pr_protocol == IPPROTO_UDP) ? - IPPROTO_UDP : IPPROTO_UDPLITE; INP_WUNLOCK(inp); - pru = inetsw[ip_protox[nxt]].pr_usrreqs; - (*pru->pru_abort)(so); + udp_abort(so); return; } #endif @@ -1131,14 +1128,8 @@ udp6_close(struct socket *so) INP_WLOCK(inp); #ifdef INET if (inp->inp_vflag & INP_IPV4) { - struct pr_usrreqs *pru; - uint8_t nxt; - - nxt = (inp->inp_socket->so_proto->pr_protocol == IPPROTO_UDP) ? - IPPROTO_UDP : IPPROTO_UDPLITE; INP_WUNLOCK(inp); - pru = inetsw[ip_protox[nxt]].pr_usrreqs; - (*pru->pru_disconnect)(so); + (void)udp_disconnect(so); return; } #endif @@ -1283,14 +1274,8 @@ udp6_disconnect(struct socket *so) INP_WLOCK(inp); #ifdef INET if (inp->inp_vflag & INP_IPV4) { - struct pr_usrreqs *pru; - uint8_t nxt; - - nxt = (inp->inp_socket->so_proto->pr_protocol == IPPROTO_UDP) ? - IPPROTO_UDP : IPPROTO_UDPLITE; INP_WUNLOCK(inp); - pru = inetsw[ip_protox[nxt]].pr_usrreqs; - (void)(*pru->pru_disconnect)(so); + (void)udp_disconnect(so); return (0); } #endif