Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_subr.c
Show First 20 Lines • Show All 1,742 Lines • ▼ Show 20 Lines | tcp_respond(struct tcpcb *tp, void *ipgen, struct tcphdr *th, struct mbuf *m, | ||||
tcp_seq ack, tcp_seq seq, int flags) | tcp_seq ack, tcp_seq seq, int flags) | ||||
{ | { | ||||
struct tcpopt to; | struct tcpopt to; | ||||
struct inpcb *inp; | struct inpcb *inp; | ||||
struct ip *ip; | struct ip *ip; | ||||
struct mbuf *optm; | struct mbuf *optm; | ||||
struct udphdr *uh = NULL; | struct udphdr *uh = NULL; | ||||
struct tcphdr *nth; | struct tcphdr *nth; | ||||
struct tcp_log_buffer *lgb; | |||||
u_char *optp; | u_char *optp; | ||||
#ifdef INET6 | #ifdef INET6 | ||||
struct ip6_hdr *ip6; | struct ip6_hdr *ip6; | ||||
int isipv6; | int isipv6; | ||||
#endif /* INET6 */ | #endif /* INET6 */ | ||||
int optlen, tlen, win, ulen; | int optlen, tlen, win, ulen; | ||||
bool incl_opts; | bool incl_opts; | ||||
uint16_t port; | uint16_t port; | ||||
int output_ret; | |||||
KASSERT(tp != NULL || m != NULL, ("tcp_respond: tp and m both NULL")); | KASSERT(tp != NULL || m != NULL, ("tcp_respond: tp and m both NULL")); | ||||
NET_EPOCH_ASSERT(); | NET_EPOCH_ASSERT(); | ||||
#ifdef INET6 | #ifdef INET6 | ||||
isipv6 = ((struct ip *)ipgen)->ip_v == (IPV6_VERSION >> 4); | isipv6 = ((struct ip *)ipgen)->ip_v == (IPV6_VERSION >> 4); | ||||
ip6 = ipgen; | ip6 = ipgen; | ||||
#endif /* INET6 */ | #endif /* INET6 */ | ||||
▲ Show 20 Lines • Show All 314 Lines • ▼ Show 20 Lines | |||||
#endif /* INET */ | #endif /* INET */ | ||||
#ifdef TCPDEBUG | #ifdef TCPDEBUG | ||||
if (tp == NULL || (inp->inp_socket->so_options & SO_DEBUG)) | if (tp == NULL || (inp->inp_socket->so_options & SO_DEBUG)) | ||||
tcp_trace(TA_OUTPUT, 0, tp, mtod(m, void *), th, 0); | tcp_trace(TA_OUTPUT, 0, tp, mtod(m, void *), th, 0); | ||||
#endif | #endif | ||||
TCP_PROBE3(debug__output, tp, th, m); | TCP_PROBE3(debug__output, tp, th, m); | ||||
if (flags & TH_RST) | if (flags & TH_RST) | ||||
TCP_PROBE5(accept__refused, NULL, NULL, m, tp, nth); | TCP_PROBE5(accept__refused, NULL, NULL, m, tp, nth); | ||||
if ((tp != NULL) && (tp->t_logstate != TCP_LOG_STATE_OFF)) { | |||||
union tcp_log_stackspecific log; | |||||
struct timeval tv; | |||||
memset(&log.u_bbr, 0, sizeof(log.u_bbr)); | |||||
log.u_bbr.inhpts = tp->t_inpcb->inp_in_hpts; | |||||
log.u_bbr.ininput = tp->t_inpcb->inp_in_input; | |||||
log.u_bbr.flex8 = 4; | |||||
log.u_bbr.pkts_out = tp->t_maxseg; | |||||
log.u_bbr.timeStamp = tcp_get_usecs(&tv); | |||||
log.u_bbr.delivered = 0; | |||||
lgb = tcp_log_event_(tp, nth, NULL, NULL, TCP_LOG_OUT, ERRNO_UNK, | |||||
0, &log, false, NULL, NULL, 0, &tv); | |||||
} else | |||||
lgb = NULL; | |||||
#ifdef INET6 | #ifdef INET6 | ||||
if (isipv6) { | if (isipv6) { | ||||
TCP_PROBE5(send, NULL, tp, ip6, tp, nth); | TCP_PROBE5(send, NULL, tp, ip6, tp, nth); | ||||
(void)ip6_output(m, NULL, NULL, 0, NULL, NULL, inp); | output_ret = ip6_output(m, NULL, NULL, 0, NULL, NULL, inp); | ||||
} | } | ||||
#endif /* INET6 */ | #endif /* INET6 */ | ||||
#if defined(INET) && defined(INET6) | #if defined(INET) && defined(INET6) | ||||
else | else | ||||
#endif | #endif | ||||
#ifdef INET | #ifdef INET | ||||
{ | { | ||||
TCP_PROBE5(send, NULL, tp, ip, tp, nth); | TCP_PROBE5(send, NULL, tp, ip, tp, nth); | ||||
(void)ip_output(m, NULL, NULL, 0, NULL, inp); | output_ret = ip_output(m, NULL, NULL, 0, NULL, inp); | ||||
} | } | ||||
#endif | #endif | ||||
if (lgb) { | |||||
lgb->tlb_errno = output_ret; | |||||
lgb = NULL; | |||||
} | |||||
} | } | ||||
/* | /* | ||||
* Create a new TCP control block, making an | * Create a new TCP control block, making an | ||||
* empty reassembly queue and hooking it to the argument | * empty reassembly queue and hooking it to the argument | ||||
* protocol control block. The `inp' parameter must have | * protocol control block. The `inp' parameter must have | ||||
* come from the zone allocator set up in tcp_init(). | * come from the zone allocator set up in tcp_init(). | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 2,084 Lines • Show Last 20 Lines |