From nobody Thu Aug 11 16:20:18 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 4M3X8f4zhyz4YqN4; Thu, 11 Aug 2022 16:20:18 +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 4M3X8f4Kwvz3lfP; Thu, 11 Aug 2022 16:20:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660234818; 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=DNK3EkaFbw0gQIumWQ8w8bHzTnUYlHn60bSn0MaevQI=; b=MJLfS0OaonpX1wZEKGWKuujAeBBTk3Bf0D3U40TcWJ9FK/8SiNLbqnly1HW/Wiz2bNvFrh XGoIDJjuek8jWdgXvw6vq6flB0cifUfftnZD6vQpKqKgZI8otGLkbPklMBzsFKuFxfHohI oFtW4aJMKg7rq/ljE88znv6IQdbiEjOCRBu49hJ+XqbPEZvx54UA35rhPFQNJNK/MGqsY9 kmeTwPHRvW4umebKcV9kODG6NKahmtlZXVwPZuc0bhLLfAQbxf8zBemuvzSAYNmPulovko QRTo1LvYu8YIG99pk1a5ZW93ZcdB+npuTEZMjsUZmS2USSuRwyKim6ASsahqLw== 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 4M3X8f3K4Nzxqq; Thu, 11 Aug 2022 16:20:18 +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 27BGKIW3048550; Thu, 11 Aug 2022 16:20:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27BGKI8U048547; Thu, 11 Aug 2022 16:20:18 GMT (envelope-from git) Date: Thu, 11 Aug 2022 16:20:18 GMT Message-Id: <202208111620.27BGKI8U048547@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: e0b405003a2a - main - raw ip6: merge rip6_output() into rip6_send() 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: e0b405003a2adb9f0b065a20eed7fc751001af36 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660234818; 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=DNK3EkaFbw0gQIumWQ8w8bHzTnUYlHn60bSn0MaevQI=; b=EoijDaVj+ge2lZjqN6ucxSML7oshUjYjdvVxTrtAJLKZjr9aYjyYGDWbWNEX6iYqo0HZtT BNWFyPz7HAd43BAZ7sv6/hN5TsOO4ydt5HzlF4CxdYPb+0dQPEt/HDQeEUOrHactXsVFaq TRgjtNk1JBaLnzc2ZOHOAdPSMBrSCVaMnSIlx424G/Tu3Q8MCW9YumPItHNcGw5AIjUdGP XZKjqNYNLeVcrZTlXwB34b49W4iGk50eguaHcwCRFGflROkOuVNu5qnfQ/b62eTMWBfAjJ A4Gk2YwWHGYLbc9PY8q8uYfYdWxAO3m5zTa4dSXs1jZxnhsfSEBquGt/J6JJWA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1660234818; a=rsa-sha256; cv=none; b=UTRuELZT5k4T9K/ZMPUPJbZ7zHraRsyBaIO9eWv91EChWE8wFDI7YqQsQS9Ivt7PnTXJoV AzAeIiaDBlc/t1vThqu/6CgrIvxnybo6ubQZPVpBPSquqxh+7cOuY2eY/2TSYglo3Iz/g7 LdlwJXWWB53f5N48B2bMof9CEYYc02GEJs8Iuo1Iw2xkpC5wN2+yX92XnzLrg5rutYY9pA FfPQMg3Z93cPP0A0QgtzFGsqvbo+ArHotPeH2b8M0fW0wC8dlx4an376fUxFDWDplNIYIy 1hwhxSnBTCzLpm9MpGpApERKfPsHVvB7vtXEAQgoYdLhICLkzKNsri7BLhKFng== 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=e0b405003a2adb9f0b065a20eed7fc751001af36 commit e0b405003a2adb9f0b065a20eed7fc751001af36 Author: Gleb Smirnoff AuthorDate: 2022-08-11 16:19:37 +0000 Commit: Gleb Smirnoff CommitDate: 2022-08-11 16:19:37 +0000 raw ip6: merge rip6_output() into rip6_send() While here remove some code that was compat legacy back in 2005, added in a1f7e5f8ee7fe. Reviewed by: melifaro Differential revision: https://reviews.freebsd.org/D36128 --- sys/netinet6/ip6_var.h | 1 - sys/netinet6/raw_ip6.c | 124 +++++++++++++++++++------------------------------ 2 files changed, 48 insertions(+), 77 deletions(-) diff --git a/sys/netinet6/ip6_var.h b/sys/netinet6/ip6_var.h index 76aa304288bf..9717230fb160 100644 --- a/sys/netinet6/ip6_var.h +++ b/sys/netinet6/ip6_var.h @@ -402,7 +402,6 @@ void rip6_init(void); int rip6_input(struct mbuf **, int *, int); void rip6_ctlinput(int, struct sockaddr *, void *); int rip6_ctloutput(struct socket *, struct sockopt *); -int rip6_output(struct mbuf *, struct socket *, ...); int rip6_usrreq(struct socket *, int, struct mbuf *, struct mbuf *, struct mbuf *, struct thread *); diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c index ab0b6771fe99..678121b0ca32 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -364,32 +364,62 @@ rip6_ctlinput(int cmd, struct sockaddr *sa, void *d) * Generate IPv6 header and pass packet to ip6_output. Tack on options user * may have setup with control call. */ -int -rip6_output(struct mbuf *m, struct socket *so, ...) +static int +rip6_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, + struct mbuf *control, struct thread *td) { struct epoch_tracker et; - struct mbuf *control; + struct inpcb *inp; + struct sockaddr_in6 tmp, *dstsock; struct m_tag *mtag; - struct sockaddr_in6 *dstsock; struct ip6_hdr *ip6; - struct inpcb *inp; u_int plen = m->m_pkthdr.len; - int error = 0; struct ip6_pktopts opt, *optp; struct ifnet *oifp = NULL; + int error; int type = 0, code = 0; /* for ICMPv6 output statistics only */ int scope_ambiguous = 0; int use_defzone = 0; int hlim = 0; struct in6_addr in6a; - va_list ap; - - va_start(ap, so); - dstsock = va_arg(ap, struct sockaddr_in6 *); - control = va_arg(ap, struct mbuf *); - va_end(ap); inp = sotoinpcb(so); + KASSERT(inp != NULL, ("rip6_send: inp == NULL")); + + /* Always copy sockaddr to avoid overwrites. */ + /* Unlocked read. */ + if (so->so_state & SS_ISCONNECTED) { + if (nam) { + error = EISCONN; + goto release; + } + tmp = (struct sockaddr_in6 ){ + .sin6_family = AF_INET6, + .sin6_len = sizeof(struct sockaddr_in6), + }; + INP_RLOCK(inp); + bcopy(&inp->in6p_faddr, &tmp.sin6_addr, + sizeof(struct in6_addr)); + INP_RUNLOCK(inp); + dstsock = &tmp; + } else { + if (nam == NULL) + error = ENOTCONN; + else if (nam->sa_family != AF_INET6) + error = EAFNOSUPPORT; + else if (nam->sa_len != sizeof(struct sockaddr_in6)) + error = EINVAL; + else + error = 0; + if (error != 0) + goto release; + dstsock = (struct sockaddr_in6 *)nam; + if (dstsock->sin6_family != AF_INET6) { + error = EAFNOSUPPORT; + goto release; + } + } + INP_WLOCK(inp); if (control != NULL) { @@ -555,6 +585,12 @@ rip6_output(struct mbuf *m, struct socket *so, ...) } INP_WUNLOCK(inp); return (error); + +release: + if (control != NULL) + m_freem(control); + m_freem(m); + return (error); } /* @@ -833,70 +869,6 @@ rip6_shutdown(struct socket *so) return (0); } -static int -rip6_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, - struct mbuf *control, struct thread *td) -{ - struct inpcb *inp; - struct sockaddr_in6 tmp; - struct sockaddr_in6 *dst; - int error; - - inp = sotoinpcb(so); - KASSERT(inp != NULL, ("rip6_send: inp == NULL")); - - /* Always copy sockaddr to avoid overwrites. */ - /* Unlocked read. */ - if (so->so_state & SS_ISCONNECTED) { - if (nam) { - error = EISCONN; - goto release; - } - /* XXX */ - bzero(&tmp, sizeof(tmp)); - tmp.sin6_family = AF_INET6; - tmp.sin6_len = sizeof(struct sockaddr_in6); - INP_RLOCK(inp); - bcopy(&inp->in6p_faddr, &tmp.sin6_addr, - sizeof(struct in6_addr)); - INP_RUNLOCK(inp); - dst = &tmp; - } else { - error = 0; - if (nam == NULL) - error = ENOTCONN; - else if (nam->sa_family != AF_INET6) - error = EAFNOSUPPORT; - else if (nam->sa_len != sizeof(struct sockaddr_in6)) - error = EINVAL; - if (error != 0) - goto release; - tmp = *(struct sockaddr_in6 *)nam; - dst = &tmp; - - if (dst->sin6_family == AF_UNSPEC) { - /* - * XXX: we allow this case for backward - * compatibility to buggy applications that - * rely on old (and wrong) kernel behavior. - */ - log(LOG_INFO, "rip6 SEND: address family is " - "unspec. Assume AF_INET6\n"); - dst->sin6_family = AF_INET6; - } else if (dst->sin6_family != AF_INET6) { - error = EAFNOSUPPORT; - goto release; - } - } - return (rip6_output(m, so, dst, control)); - -release: - if (control != NULL) - m_freem(control); - m_freem(m); - return (error); -} - struct pr_usrreqs rip6_usrreqs = { .pru_abort = rip6_abort, .pru_attach = rip6_attach,