| 697 | "Get the xucred of a UDP6 connection"); |
| 698 | |
| 699 | static int |
| 700 | udp6_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). |
no test coverage detected