FreeBSD/sys/netpfil/ipfw/ip_dn_io.c
/*
 * Enqueue a packet in q, subject to space and queue management policy
 * (whose parameters are in q->fs).
 * Update stats for the queue and the scheduler.
 * Return 0 on success, 1 on drop. The packet is consumed anyways.
 */
Enqueue a packet in q, subject to space and queue management policy
(whose parameters are in q->fs).
Update stats for the queue and the scheduler.
Return 0 on success, 1 on drop. The packet is consumed anyways.
Enqueue a packet in q subject to space and queue management policy ( whose parameters are in q - > fs ) . Update stats for the queue and the scheduler . Return 0 on success 1 on drop . The packet is consumed anyways .
int
dn_enqueue(struct dn_queue *q, struct mbuf* m, int drop)
{   
	struct dn_fs *f;
	struct dn_flow *ni;	
	uint64_t len;
	if (q->fs == NULL || q->_si == NULL) {
		printf("%s fs %p si %p, dropping\n",
			__FUNCTION__, q->fs, q->_si);
		FREE_PKT(m);
		return 1;
	}
	f = &(q->fs->fs);
	ni = &q->_si->ni;
	len = m->m_pkthdr.len;
	q->ni.tot_bytes += len;
	q->ni.tot_pkts++;
	ni->tot_bytes += len;
	ni->tot_pkts++;
	if (drop)
		goto drop;
	if (f->plr && random() < f->plr)
		goto drop;
#ifdef NEW_AQM
	if (q->fs->aqmfp)
		return q->fs->aqmfp->enqueue(q ,m);
#endif
	if (f->flags & DN_IS_RED && red_drops(q, m->m_pkthdr.len)) {
		if (!(f->flags & DN_IS_ECN) || !ecn_mark(m))
			goto drop;
	}
	if (f->flags & DN_QSIZE_BYTES) {
		if (q->ni.len_bytes > f->qsize)
			goto drop;
	} else if (q->ni.length >= f->qsize) {
		goto drop;
	}
	mq_append(&q->mq, m);
	q->ni.length++;
	q->ni.len_bytes += len;
	ni->length++;
	ni->len_bytes += len;
	return (0);
drop:
	io_pkt_drop++;
	q->ni.drops++;
	ni->drops++;
	FREE_PKT(m);
	return (1);
}
int dn_enqueue ( struct dn_queue * q , struct mbuf * m , int drop ) { struct dn_fs * f ; struct dn_flow * ni ; uint64_t len ; if ( q -> fs == NULL || q -> _si == NULL ) { printf ( " \n " , __FUNCTION__ , q -> fs , q -> _si ) ; FREE_PKT ( m ) ; return 1 ; } f = & ( q -> fs -> fs ) ; ni = & q -> _si -> ni ; len = m -> m_pkthdr . len ; q -> ni . tot_bytes += len ; q -> ni . tot_pkts ++ ; ni -> tot_bytes += len ; ni -> tot_pkts ++ ; if ( drop ) goto drop ; if ( f -> plr && random ( ) < f -> plr ) goto drop ; #ifdef NEW_AQM if ( q -> fs -> aqmfp ) return q -> fs -> aqmfp -> enqueue ( q , m ) ; #endif if ( f -> flags & DN_IS_RED && red_drops ( q , m -> m_pkthdr . len ) ) { if ( ! ( f -> flags & DN_IS_ECN ) || ! ecn_mark ( m ) ) goto drop ; } if ( f -> flags & DN_QSIZE_BYTES ) { if ( q -> ni . len_bytes > f -> qsize ) goto drop ; } else if ( q -> ni . length >= f -> qsize ) { goto drop ; } mq_append ( & q -> mq , m ) ; q -> ni . length ++ ; q -> ni . len_bytes += len ; ni -> length ++ ; ni -> len_bytes += len ; return ( 0 ) ; drop : io_pkt_drop ++ ; q -> ni . drops ++ ; ni -> drops ++ ; FREE_PKT ( m ) ; return ( 1 ) ; }
Enqueue a packet in q, subject to space and queue management policy
 (whose parameters are in q->fs).
Enqueue a packet in q subject to space and queue management policy ( whose parameters are in q - > fs ) .
/* stats for scheduler instance */ /* Update statistics, then check reasons to drop pkt. */ /* Call AQM enqueue function */