git: 5bfc014f2345 - main - udp6: inline udp6_output() into udp6_send()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 07 Dec 2022 19:52:01 UTC
The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=5bfc014f23452367c9ddcabc5a183b4ee975932d commit 5bfc014f23452367c9ddcabc5a183b4ee975932d Author: Gleb Smirnoff <glebius@FreeBSD.org> AuthorDate: 2022-12-07 19:51:48 +0000 Commit: Gleb Smirnoff <glebius@FreeBSD.org> CommitDate: 2022-12-07 19:51:48 +0000 udp6: inline udp6_output() into udp6_send() --- sys/netinet6/udp6_usrreq.c | 42 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index 2d309d938056..79fe7d4cc0fb 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -657,7 +657,7 @@ SYSCTL_PROC(_net_inet6_udp6, OID_AUTO, getcred, "Get the xucred of a UDP6 connection"); static int -udp6_output(struct socket *so, int flags_arg, struct mbuf *m, +udp6_send(struct socket *so, int flags_arg, struct mbuf *m, struct sockaddr *addr6, struct mbuf *control, struct thread *td) { struct inpcb *inp; @@ -673,7 +673,19 @@ udp6_output(struct socket *so, int flags_arg, struct mbuf *m, u_short fport; uint8_t nxt; - /* addr6 has been validated in udp6_send(). */ + if (addr6) { + error = 0; + if (addr6->sa_family != AF_INET6) + error = EAFNOSUPPORT; + else if (addr6->sa_len != sizeof(struct sockaddr_in6)) + error = EINVAL; + if (__predict_false(error != 0)) { + m_freem(control); + m_freem(m); + return (error); + } + } + sin6 = (struct sockaddr_in6 *)addr6; /* @@ -1243,32 +1255,6 @@ udp6_disconnect(struct socket *so) return (0); } -static int -udp6_send(struct socket *so, int flags, struct mbuf *m, - struct sockaddr *addr, struct mbuf *control, struct thread *td) -{ - int error; - - if (addr) { - if (addr->sa_len != sizeof(struct sockaddr_in6)) { - error = EINVAL; - goto bad; - } - if (addr->sa_family != AF_INET6) { - error = EAFNOSUPPORT; - goto bad; - } - } - - return (udp6_output(so, flags, m, addr, control, td)); - -bad: - if (control) - m_freem(control); - m_freem(m); - return (error); -} - #define UDP6_PROTOSW \ .pr_type = SOCK_DGRAM, \ .pr_flags = PR_ATOMIC|PR_ADDR|PR_CAPATTACH, \