Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/udp_usrreq.c
Show First 20 Lines • Show All 401 Lines • ▼ Show 20 Lines | udp_input(struct mbuf **mp, int *offp, int proto) | ||||
struct udphdr *uh; | struct udphdr *uh; | ||||
struct ifnet *ifp; | struct ifnet *ifp; | ||||
struct inpcb *inp; | struct inpcb *inp; | ||||
uint16_t len, ip_len; | uint16_t len, ip_len; | ||||
struct inpcbinfo *pcbinfo; | struct inpcbinfo *pcbinfo; | ||||
struct ip save_ip; | struct ip save_ip; | ||||
struct sockaddr_in udp_in; | struct sockaddr_in udp_in; | ||||
struct mbuf *m; | struct mbuf *m; | ||||
struct m_tag *fwd_tag; | struct sockaddr_in next_hop; | ||||
int cscov_partial, iphlen; | int cscov_partial, iphlen; | ||||
m = *mp; | m = *mp; | ||||
iphlen = *offp; | iphlen = *offp; | ||||
ifp = m->m_pkthdr.rcvif; | ifp = m->m_pkthdr.rcvif; | ||||
*mp = NULL; | *mp = NULL; | ||||
UDPSTAT_INC(udps_ipackets); | UDPSTAT_INC(udps_ipackets); | ||||
▲ Show 20 Lines • Show All 223 Lines • ▼ Show 20 Lines | inp_lost: | ||||
return (IPPROTO_DONE); | return (IPPROTO_DONE); | ||||
} | } | ||||
/* | /* | ||||
* Locate pcb for datagram. | * Locate pcb for datagram. | ||||
*/ | */ | ||||
/* | /* | ||||
* Grab info from PACKET_TAG_IPFORWARD tag prepended to the chain. | * Grab info from IP forward tag prepended to the chain. | ||||
*/ | */ | ||||
if ((m->m_flags & M_IP_NEXTHOP) && | if (IP_HAS_NEXTHOP(m) && !ip_get_fwdtag(m, &next_hop, NULL)) { | ||||
(fwd_tag = m_tag_find(m, PACKET_TAG_IPFORWARD, NULL)) != NULL) { | |||||
struct sockaddr_in *next_hop; | |||||
next_hop = (struct sockaddr_in *)(fwd_tag + 1); | |||||
/* | /* | ||||
* Transparently forwarded. Pretend to be the destination. | * Transparently forwarded. Pretend to be the destination. | ||||
* Already got one like this? | * Already got one like this? | ||||
*/ | */ | ||||
inp = in_pcblookup_mbuf(pcbinfo, ip->ip_src, uh->uh_sport, | inp = in_pcblookup_mbuf(pcbinfo, ip->ip_src, uh->uh_sport, | ||||
ip->ip_dst, uh->uh_dport, INPLOOKUP_RLOCKPCB, ifp, m); | ip->ip_dst, uh->uh_dport, INPLOOKUP_RLOCKPCB, ifp, m); | ||||
if (!inp) { | if (!inp) { | ||||
/* | /* | ||||
* It's new. Try to find the ambushing socket. | * It's new. Try to find the ambushing socket. | ||||
* Because we've rewritten the destination address, | * Because we've rewritten the destination address, | ||||
* any hardware-generated hash is ignored. | * any hardware-generated hash is ignored. | ||||
*/ | */ | ||||
inp = in_pcblookup(pcbinfo, ip->ip_src, | inp = in_pcblookup(pcbinfo, ip->ip_src, | ||||
uh->uh_sport, next_hop->sin_addr, | uh->uh_sport, next_hop.sin_addr, | ||||
next_hop->sin_port ? htons(next_hop->sin_port) : | next_hop.sin_port ? htons(next_hop.sin_port) : | ||||
uh->uh_dport, INPLOOKUP_WILDCARD | | uh->uh_dport, INPLOOKUP_WILDCARD | | ||||
INPLOOKUP_RLOCKPCB, ifp); | INPLOOKUP_RLOCKPCB, ifp); | ||||
} | } | ||||
/* Remove the tag from the packet. We don't need it anymore. */ | /* Remove the tag from the packet. We don't need it anymore. */ | ||||
m_tag_delete(m, fwd_tag); | ip_flush_fwdtag(m); | ||||
m->m_flags &= ~M_IP_NEXTHOP; | |||||
} else | } else | ||||
inp = in_pcblookup_mbuf(pcbinfo, ip->ip_src, uh->uh_sport, | inp = in_pcblookup_mbuf(pcbinfo, ip->ip_src, uh->uh_sport, | ||||
ip->ip_dst, uh->uh_dport, INPLOOKUP_WILDCARD | | ip->ip_dst, uh->uh_dport, INPLOOKUP_WILDCARD | | ||||
INPLOOKUP_RLOCKPCB, ifp, m); | INPLOOKUP_RLOCKPCB, ifp, m); | ||||
if (inp == NULL) { | if (inp == NULL) { | ||||
if (udp_log_in_vain) { | if (udp_log_in_vain) { | ||||
char buf[4*sizeof "123"]; | char buf[4*sizeof "123"]; | ||||
▲ Show 20 Lines • Show All 1,280 Lines • Show Last 20 Lines |