Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_log_buf.c
/*- | /*- | ||||
tuexen: Is it intended to add an empty first line in the file? | |||||
* SPDX-License-Identifier: BSD-2-Clause | * SPDX-License-Identifier: BSD-2-Clause | ||||
* | * | ||||
* Copyright (c) 2016-2018 Netflix, Inc. | * Copyright (c) 2016-2018 Netflix, Inc. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
* modification, are permitted provided that the following conditions | * modification, are permitted provided that the following conditions | ||||
* are met: | * are met: | ||||
* 1. Redistributions of source code must retain the above copyright | * 1. Redistributions of source code must retain the above copyright | ||||
▲ Show 20 Lines • Show All 2,837 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
void | void | ||||
tcp_log_sendfile(struct socket *so, off_t offset, size_t nbytes, int flags) | tcp_log_sendfile(struct socket *so, off_t offset, size_t nbytes, int flags) | ||||
{ | { | ||||
struct inpcb *inp; | struct inpcb *inp; | ||||
struct tcpcb *tp; | struct tcpcb *tp; | ||||
#ifdef TCP_REQUEST_TRK | #ifdef TCP_REQUEST_TRK | ||||
struct http_sendfile_track *ent; | struct tcp_sendfile_track *ent; | ||||
int i, fnd; | int i, fnd; | ||||
#endif | #endif | ||||
inp = sotoinpcb(so); | inp = sotoinpcb(so); | ||||
KASSERT(inp != NULL, ("tcp_log_sendfile: inp == NULL")); | KASSERT(inp != NULL, ("tcp_log_sendfile: inp == NULL")); | ||||
/* quick check to see if logging is enabled for this connection */ | /* quick check to see if logging is enabled for this connection */ | ||||
tp = intotcpcb(inp); | tp = intotcpcb(inp); | ||||
Show All 16 Lines | if (tp->_t_logstate != TCP_LOG_STATE_OFF) { | ||||
log.u_sf.flags = flags; | log.u_sf.flags = flags; | ||||
TCP_LOG_EVENTP(tp, NULL, | TCP_LOG_EVENTP(tp, NULL, | ||||
&tptosocket(tp)->so_rcv, | &tptosocket(tp)->so_rcv, | ||||
&tptosocket(tp)->so_snd, | &tptosocket(tp)->so_snd, | ||||
TCP_LOG_SENDFILE, 0, 0, &log, false, &tv); | TCP_LOG_SENDFILE, 0, 0, &log, false, &tv); | ||||
} | } | ||||
#ifdef TCP_REQUEST_TRK | #ifdef TCP_REQUEST_TRK | ||||
if (tp->t_http_req == 0) { | if (tp->t_tcpreq_req == 0) { | ||||
/* No http requests to track */ | /* No http requests to track */ | ||||
goto done; | goto done; | ||||
} | } | ||||
fnd = 0; | fnd = 0; | ||||
if (tp->t_http_closed == 0) { | if (tp->t_tcpreq_closed == 0) { | ||||
/* No closed end req to track */ | /* No closed end req to track */ | ||||
goto skip_closed_req; | goto skip_closed_req; | ||||
} | } | ||||
for(i = 0; i < MAX_TCP_HTTP_REQ; i++) { | for(i = 0; i < MAX_TCP_TRK_REQ; i++) { | ||||
/* Lets see if this one can be found */ | /* Lets see if this one can be found */ | ||||
ent = &tp->t_http_info[i]; | ent = &tp->t_tcpreq_info[i]; | ||||
if (ent->flags == TCP_HTTP_TRACK_FLG_EMPTY) { | if (ent->flags == TCP_TRK_TRACK_FLG_EMPTY) { | ||||
/* Not used */ | /* Not used */ | ||||
continue; | continue; | ||||
} | } | ||||
if (ent->flags & TCP_HTTP_TRACK_FLG_OPEN) { | if (ent->flags & TCP_TRK_TRACK_FLG_OPEN) { | ||||
/* This pass does not consider open requests */ | /* This pass does not consider open requests */ | ||||
continue; | continue; | ||||
} | } | ||||
if (ent->flags & TCP_HTTP_TRACK_FLG_COMP) { | if (ent->flags & TCP_TRK_TRACK_FLG_COMP) { | ||||
/* Don't look at what we have completed */ | /* Don't look at what we have completed */ | ||||
continue; | continue; | ||||
} | } | ||||
/* If we reach here its a allocated closed end request */ | /* If we reach here its a allocated closed end request */ | ||||
if ((ent->start == offset) || | if ((ent->start == offset) || | ||||
((offset > ent->start) && (offset < ent->end))){ | ((offset > ent->start) && (offset < ent->end))){ | ||||
/* Its within this request?? */ | /* Its within this request?? */ | ||||
fnd = 1; | fnd = 1; | ||||
} | } | ||||
if (fnd) { | if (fnd) { | ||||
/* | /* | ||||
* It is at or past the end, its complete. | * It is at or past the end, its complete. | ||||
*/ | */ | ||||
ent->flags |= TCP_HTTP_TRACK_FLG_SEQV; | ent->flags |= TCP_TRK_TRACK_FLG_SEQV; | ||||
/* | /* | ||||
* When an entry completes we can take (snd_una + sb_cc) and know where | * When an entry completes we can take (snd_una + sb_cc) and know where | ||||
* the end of the range really is. Note that this works since two | * the end of the range really is. Note that this works since two | ||||
* requests must be sequential and sendfile now is complete for *this* request. | * requests must be sequential and sendfile now is complete for *this* request. | ||||
* we must use sb_ccc since the data may still be in-flight in TLS. | * we must use sb_ccc since the data may still be in-flight in TLS. | ||||
* | * | ||||
* We always cautiously move the end_seq only if our calculations | * We always cautiously move the end_seq only if our calculations | ||||
* show it happened (just in case sf has the call to here at the wrong | * show it happened (just in case sf has the call to here at the wrong | ||||
* place). When we go COMP we will stop coming here and hopefully be | * place). When we go COMP we will stop coming here and hopefully be | ||||
* left with the correct end_seq. | * left with the correct end_seq. | ||||
*/ | */ | ||||
if (SEQ_GT((tp->snd_una + so->so_snd.sb_ccc), ent->end_seq)) | if (SEQ_GT((tp->snd_una + so->so_snd.sb_ccc), ent->end_seq)) | ||||
ent->end_seq = tp->snd_una + so->so_snd.sb_ccc; | ent->end_seq = tp->snd_una + so->so_snd.sb_ccc; | ||||
if ((offset + nbytes) >= ent->end) { | if ((offset + nbytes) >= ent->end) { | ||||
ent->flags |= TCP_HTTP_TRACK_FLG_COMP; | ent->flags |= TCP_TRK_TRACK_FLG_COMP; | ||||
tcp_http_log_req_info(tp, ent, i, TCP_HTTP_REQ_LOG_COMPLETE, offset, nbytes); | tcp_req_log_req_info(tp, ent, i, TCP_TRK_REQ_LOG_COMPLETE, offset, nbytes); | ||||
} else { | } else { | ||||
tcp_http_log_req_info(tp, ent, i, TCP_HTTP_REQ_LOG_MOREYET, offset, nbytes); | tcp_req_log_req_info(tp, ent, i, TCP_TRK_REQ_LOG_MOREYET, offset, nbytes); | ||||
} | } | ||||
/* We assume that sendfile never sends overlapping requests */ | /* We assume that sendfile never sends overlapping requests */ | ||||
goto done; | goto done; | ||||
} | } | ||||
} | } | ||||
skip_closed_req: | skip_closed_req: | ||||
if (!fnd) { | if (!fnd) { | ||||
/* Ok now lets look for open requests */ | /* Ok now lets look for open requests */ | ||||
for(i = 0; i < MAX_TCP_HTTP_REQ; i++) { | for(i = 0; i < MAX_TCP_TRK_REQ; i++) { | ||||
ent = &tp->t_http_info[i]; | ent = &tp->t_tcpreq_info[i]; | ||||
if (ent->flags == TCP_HTTP_TRACK_FLG_EMPTY) { | if (ent->flags == TCP_TRK_TRACK_FLG_EMPTY) { | ||||
/* Not used */ | /* Not used */ | ||||
continue; | continue; | ||||
} | } | ||||
if ((ent->flags & TCP_HTTP_TRACK_FLG_OPEN) == 0) | if ((ent->flags & TCP_TRK_TRACK_FLG_OPEN) == 0) | ||||
continue; | continue; | ||||
/* If we reach here its an allocated open request */ | /* If we reach here its an allocated open request */ | ||||
if (ent->start == offset) { | if (ent->start == offset) { | ||||
/* It begins this request */ | /* It begins this request */ | ||||
ent->start_seq = tp->snd_una + | ent->start_seq = tp->snd_una + | ||||
tptosocket(tp)->so_snd.sb_ccc; | tptosocket(tp)->so_snd.sb_ccc; | ||||
ent->flags |= TCP_HTTP_TRACK_FLG_SEQV; | ent->flags |= TCP_TRK_TRACK_FLG_SEQV; | ||||
break; | break; | ||||
} else if (offset > ent->start) { | } else if (offset > ent->start) { | ||||
ent->flags |= TCP_HTTP_TRACK_FLG_SEQV; | ent->flags |= TCP_TRK_TRACK_FLG_SEQV; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
#endif | #endif | ||||
done: | done: | ||||
INP_WUNLOCK(inp); | INP_WUNLOCK(inp); | ||||
} | } |
Is it intended to add an empty first line in the file?