Changeset View
Changeset View
Standalone View
Standalone View
sys/netgraph/ng_pipe.c
Show First 20 Lines • Show All 768 Lines • ▼ Show 20 Lines | if (hinfo->cfg.drr) { | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* Either create a duplicate and pass it on, or dequeue | * Either create a duplicate and pass it on, or dequeue | ||||
* the original packet... | * the original packet... | ||||
*/ | */ | ||||
if (hinfo->cfg.duplicate && | if (hinfo->cfg.duplicate && | ||||
random() % 100 <= hinfo->cfg.duplicate) { | arc4random() % 100 <= hinfo->cfg.duplicate) { | ||||
ngp_h = uma_zalloc(ngp_zone, M_NOWAIT); | ngp_h = uma_zalloc(ngp_zone, M_NOWAIT); | ||||
KASSERT(ngp_h != NULL, ("ngp_h zalloc failed (3)")); | KASSERT(ngp_h != NULL, ("ngp_h zalloc failed (3)")); | ||||
m = m_dup(m, M_NOWAIT); | m = m_dup(m, M_NOWAIT); | ||||
KASSERT(m != NULL, ("m_dup failed")); | KASSERT(m != NULL, ("m_dup failed")); | ||||
ngp_h->m = m; | ngp_h->m = m; | ||||
} else { | } else { | ||||
TAILQ_REMOVE(&ngp_f->packet_head, ngp_h, ngp_link); | TAILQ_REMOVE(&ngp_f->packet_head, ngp_h, ngp_link); | ||||
hinfo->run.qin_frames--; | hinfo->run.qin_frames--; | ||||
Show All 26 Lines | if (ngp_f->packets) { | ||||
TAILQ_REMOVE(&hinfo->fifo_head, ngp_f, fifo_le); | TAILQ_REMOVE(&hinfo->fifo_head, ngp_f, fifo_le); | ||||
uma_zfree(ngp_zone, ngp_f); | uma_zfree(ngp_zone, ngp_f); | ||||
hinfo->run.fifo_queues--; | hinfo->run.fifo_queues--; | ||||
} | } | ||||
/* Randomly discard the frame, according to BER setting */ | /* Randomly discard the frame, according to BER setting */ | ||||
if (hinfo->cfg.ber) { | if (hinfo->cfg.ber) { | ||||
oldrand = rand; | oldrand = rand; | ||||
rand = random(); | rand = arc4random(); | ||||
if (((oldrand ^ rand) << 17) >= | if (((oldrand ^ rand) << 17) >= | ||||
hinfo->ber_p[priv->overhead + m->m_pkthdr.len]) { | hinfo->ber_p[priv->overhead + m->m_pkthdr.len]) { | ||||
hinfo->stats.out_disc_frames++; | hinfo->stats.out_disc_frames++; | ||||
hinfo->stats.out_disc_octets += m->m_pkthdr.len; | hinfo->stats.out_disc_octets += m->m_pkthdr.len; | ||||
uma_zfree(ngp_zone, ngp_h); | uma_zfree(ngp_zone, ngp_h); | ||||
m_freem(m); | m_freem(m); | ||||
continue; | continue; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 166 Lines • Show Last 20 Lines |