FreeBSD/sys/netinet/khelp/h_ertt.c
/*
 * Add information about a transmitted segment to a list.
 * This is called via the helper hook in tcp_output.c
 */
Add information about a transmitted segment to a list.
This is called via the helper hook in tcp_output.c
Add information about a transmitted segment to a list . This is called via the helper hook in tcp_output . c
static int
ertt_add_tx_segment_info_hook(int hhook_type, int hhook_id, void *udata,
    void *ctx_data, void *hdata, struct osd *hosd)
{
	struct ertt *e_t;
	struct tcpcb *tp;
	struct tcphdr *th;
	struct tcpopt *to;
	struct tcp_hhook_data *thdp;
	struct txseginfo *txsi;
	long len;
	int tso;
	KASSERT(ctx_data != NULL, ("%s: ctx_data is NULL!", __func__));
	KASSERT(hdata != NULL, ("%s: hdata is NULL!", __func__));
	e_t = (struct ertt *)hdata;
	thdp = ctx_data;
	tp = thdp->tp;
	th = thdp->th;
	to = thdp->to;
	len = thdp->len;
	tso = thdp->tso;
	INP_WLOCK_ASSERT(tp->t_inpcb);
	if (len > 0) {
		txsi = uma_zalloc(txseginfo_zone, M_NOWAIT);
		if (txsi != NULL) {
			txsi->flags = 0; 
			txsi->seq = ntohl(th->th_seq);
			txsi->len = len;
			if (tso)
				txsi->flags |= TXSI_TSO;
			else if (e_t->flags & ERTT_TSO_DISABLED) {
				tp->t_flags |= TF_TSO;
				e_t->flags &= ~ERTT_TSO_DISABLED;
			}
			if (e_t->flags & ERTT_MEASUREMENT_IN_PROGRESS) {
				e_t->bytes_tx_in_rtt += len;
			} else {
				txsi->flags |= TXSI_RTT_MEASURE_START;
				e_t->flags |= ERTT_MEASUREMENT_IN_PROGRESS;
				e_t->bytes_tx_in_rtt = len;
			}
			if (((tp->t_flags & TF_NOOPT) == 0) &&
			    (to->to_flags & TOF_TS)) {
				txsi->tx_ts = ntohl(to->to_tsval) -
				    tp->ts_offset;
				txsi->rx_ts = ntohl(to->to_tsecr);
			} else {
				txsi->tx_ts = tcp_ts_getticks();
				txsi->rx_ts = 0; 
			}
			TAILQ_INSERT_TAIL(&e_t->txsegi_q, txsi, txsegi_lnk);
		}
	}
	return (0);
}
static int ertt_add_tx_segment_info_hook ( int hhook_type , int hhook_id , void * udata , void * ctx_data , void * hdata , struct osd * hosd ) { struct ertt * e_t ; struct tcpcb * tp ; struct tcphdr * th ; struct tcpopt * to ; struct tcp_hhook_data * thdp ; struct txseginfo * txsi ; long len ; int tso ; KASSERT ( ctx_data != NULL , ( " " , __func__ ) ) ; KASSERT ( hdata != NULL , ( " " , __func__ ) ) ; e_t = ( struct ertt * ) hdata ; thdp = ctx_data ; tp = thdp -> tp ; th = thdp -> th ; to = thdp -> to ; len = thdp -> len ; tso = thdp -> tso ; INP_WLOCK_ASSERT ( tp -> t_inpcb ) ; if ( len > 0 ) { txsi = uma_zalloc ( txseginfo_zone , M_NOWAIT ) ; if ( txsi != NULL ) { txsi -> flags = 0 ; txsi -> seq = ntohl ( th -> th_seq ) ; txsi -> len = len ; if ( tso ) txsi -> flags |= TXSI_TSO ; else if ( e_t -> flags & ERTT_TSO_DISABLED ) { tp -> t_flags |= TF_TSO ; e_t -> flags &= ~ ERTT_TSO_DISABLED ; } if ( e_t -> flags & ERTT_MEASUREMENT_IN_PROGRESS ) { e_t -> bytes_tx_in_rtt += len ; } else { txsi -> flags |= TXSI_RTT_MEASURE_START ; e_t -> flags |= ERTT_MEASUREMENT_IN_PROGRESS ; e_t -> bytes_tx_in_rtt = len ; } if ( ( ( tp -> t_flags & TF_NOOPT ) == 0 ) && ( to -> to_flags & TOF_TS ) ) { txsi -> tx_ts = ntohl ( to -> to_tsval ) - tp -> ts_offset ; txsi -> rx_ts = ntohl ( to -> to_tsecr ) ; } else { txsi -> tx_ts = tcp_ts_getticks ( ) ; txsi -> rx_ts = 0 ; } TAILQ_INSERT_TAIL ( & e_t -> txsegi_q , txsi , txsegi_lnk ) ; } } return ( 0 ) ; }
Add information about a transmitted segment to a list.
Add information about a transmitted segment to a list .
/* Construct txsi setting the necessary flags. */ /* Needs to be initialised. */ /* No received time stamp. */