MCPcopy Create free account
hub / github.com/F-Stack/f-stack / udp6_output

Function udp6_output

freebsd/netinet6/udp6_usrreq.c:699–997  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

697 "Get the xucred of a UDP6 connection");
698
699static int
700udp6_output(struct socket *so, int flags_arg, struct mbuf *m,
701 struct sockaddr *addr6, struct mbuf *control, struct thread *td)
702{
703 struct inpcb *inp;
704 struct ip6_hdr *ip6;
705 struct udphdr *udp6;
706 struct in6_addr *laddr, *faddr, in6a;
707 struct ip6_pktopts *optp, opt;
708 struct sockaddr_in6 *sin6, tmp;
709 struct epoch_tracker et;
710 int cscov_partial, error, flags, hlen, scope_ambiguous;
711 u_int32_t ulen, plen;
712 uint16_t cscov;
713 u_short fport;
714 uint8_t nxt;
715
716 /* addr6 has been validated in udp6_send(). */
717 sin6 = (struct sockaddr_in6 *)addr6;
718
719 /*
720 * In contrast to to IPv4 we do not validate the max. packet length
721 * here due to IPv6 Jumbograms (RFC2675).
722 */
723
724 scope_ambiguous = 0;
725 if (sin6) {
726 /* Protect *addr6 from overwrites. */
727 tmp = *sin6;
728 sin6 = &tmp;
729
730 /*
731 * Application should provide a proper zone ID or the use of
732 * default zone IDs should be enabled. Unfortunately, some
733 * applications do not behave as it should, so we need a
734 * workaround. Even if an appropriate ID is not determined,
735 * we'll see if we can determine the outgoing interface. If we
736 * can, determine the zone ID based on the interface below.
737 */
738 if (sin6->sin6_scope_id == 0 && !V_ip6_use_defzone)
739 scope_ambiguous = 1;
740 if ((error = sa6_embedscope(sin6, V_ip6_use_defzone)) != 0) {
741 if (control)
742 m_freem(control);
743 m_freem(m);
744 return (error);
745 }
746 }
747
748 inp = sotoinpcb(so);
749 KASSERT(inp != NULL, ("%s: inp == NULL", __func__));
750 /*
751 * In the following cases we want a write lock on the inp for either
752 * local operations or for possible route cache updates in the IPv6
753 * output path:
754 * - on connected sockets (sin6 is NULL) for route cache updates,
755 * - when we are not bound to an address and source port (it is
756 * in6_pcbsetport() which will require the write lock).

Callers 1

udp6_sendFunction · 0.85

Calls 13

sa6_embedscopeFunction · 0.85
in6_sin6_2_sin_in_sockFunction · 0.85
ip6_setpktoptsFunction · 0.85
ip6_clearpktoptsFunction · 0.85
in6_selectsrc_socketFunction · 0.85
in6_pcbsetportFunction · 0.85
in6_selecthlimFunction · 0.85
mac_inpcb_create_mbufFunction · 0.85
in6_cksum_partialFunction · 0.85
in6_cksum_pseudoFunction · 0.85
ip6_outputFunction · 0.85
m_freemFunction · 0.50

Tested by

no test coverage detected