Changeset View
Changeset View
Standalone View
Standalone View
sys/netpfil/ipfw/ip_dn_io.c
Show First 20 Lines • Show All 392 Lines • ▼ Show 20 Lines | if (q->avg >= fs->max_th) { /* average queue >= max threshold */ | ||||
* c_2 = max_p * min_th / (max_th - min_th) | * c_2 = max_p * min_th / (max_th - min_th) | ||||
*/ | */ | ||||
p_b = SCALE_MUL((int64_t)fs->c_1, (int64_t)q->avg) - fs->c_2; | p_b = SCALE_MUL((int64_t)fs->c_1, (int64_t)q->avg) - fs->c_2; | ||||
} | } | ||||
if (fs->fs.flags & DN_QSIZE_BYTES) | if (fs->fs.flags & DN_QSIZE_BYTES) | ||||
p_b = div64((p_b * len) , fs->max_pkt_size); | p_b = div64((p_b * len) , fs->max_pkt_size); | ||||
if (++q->count == 0) | if (++q->count == 0) | ||||
q->random = random() & 0xffff; | q->random = arc4random() & 0xffff; | ||||
cem: I don’t believe unpredictability matters here. | |||||
else { | else { | ||||
/* | /* | ||||
* q->count counts packets arrived since last drop, so a greater | * q->count counts packets arrived since last drop, so a greater | ||||
* value of q->count means a greater packet drop probability. | * value of q->count means a greater packet drop probability. | ||||
*/ | */ | ||||
if (SCALE_MUL(p_b, SCALE((int64_t)q->count)) > q->random) { | if (SCALE_MUL(p_b, SCALE((int64_t)q->count)) > q->random) { | ||||
q->count = 0; | q->count = 0; | ||||
/* After a drop we calculate a new random value. */ | /* After a drop we calculate a new random value. */ | ||||
q->random = random() & 0xffff; | q->random = arc4random() & 0xffff; | ||||
return (1); /* drop */ | return (1); /* drop */ | ||||
} | } | ||||
} | } | ||||
/* End of RED algorithm. */ | /* End of RED algorithm. */ | ||||
return (0); /* accept */ | return (0); /* accept */ | ||||
} | } | ||||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | dn_enqueue(struct dn_queue *q, struct mbuf* m, int drop) | ||||
len = m->m_pkthdr.len; | len = m->m_pkthdr.len; | ||||
/* Update statistics, then check reasons to drop pkt. */ | /* Update statistics, then check reasons to drop pkt. */ | ||||
q->ni.tot_bytes += len; | q->ni.tot_bytes += len; | ||||
q->ni.tot_pkts++; | q->ni.tot_pkts++; | ||||
ni->tot_bytes += len; | ni->tot_bytes += len; | ||||
ni->tot_pkts++; | ni->tot_pkts++; | ||||
if (drop) | if (drop) | ||||
goto drop; | goto drop; | ||||
if (f->plr && random() < f->plr) | if (f->plr && (int32_t)arc4random() < f->plr) | ||||
Not Done Inline ActionsThis change makes drop half as likely. Also I doubt this is entropy sensitive. Maybe some ipfw expert can chime in cem: This change makes drop half as likely. Also I doubt this is entropy sensitive. Maybe some ipfw… | |||||
Done Inline ActionsI indeed moved it to its own differential: D22925 pfg: I indeed moved it to its own differential: D22925 | |||||
goto drop; | goto drop; | ||||
if (f->flags & DN_IS_RED && red_drops(q, m->m_pkthdr.len)) { | if (f->flags & DN_IS_RED && red_drops(q, m->m_pkthdr.len)) { | ||||
if (!(f->flags & DN_IS_ECN) || !ecn_mark(m)) | if (!(f->flags & DN_IS_ECN) || !ecn_mark(m)) | ||||
goto drop; | goto drop; | ||||
} | } | ||||
if (f->flags & DN_QSIZE_BYTES) { | if (f->flags & DN_QSIZE_BYTES) { | ||||
if (q->ni.len_bytes > f->qsize) | if (q->ni.len_bytes > f->qsize) | ||||
goto drop; | goto drop; | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
extra_bits(struct mbuf *m, struct dn_schk *s) | extra_bits(struct mbuf *m, struct dn_schk *s) | ||||
{ | { | ||||
int index; | int index; | ||||
uint64_t bits; | uint64_t bits; | ||||
struct dn_profile *pf = s->profile; | struct dn_profile *pf = s->profile; | ||||
if (!pf || pf->samples_no == 0) | if (!pf || pf->samples_no == 0) | ||||
return 0; | return 0; | ||||
index = random() % pf->samples_no; | index = arc4random() % pf->samples_no; | ||||
Not Done Inline ActionsI have no idea if this change is appropriate. cem: I have no idea if this change is appropriate. | |||||
bits = div64((uint64_t)pf->samples[index] * s->link.bandwidth, 1000); | bits = div64((uint64_t)pf->samples[index] * s->link.bandwidth, 1000); | ||||
if (index >= pf->loss_level) { | if (index >= pf->loss_level) { | ||||
struct dn_pkt_tag *dt = dn_tag_get(m); | struct dn_pkt_tag *dt = dn_tag_get(m); | ||||
if (dt) | if (dt) | ||||
dt->dn_dir = DIR_DROP; | dt->dn_dir = DIR_DROP; | ||||
} | } | ||||
return bits; | return bits; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 372 Lines • Show Last 20 Lines |
I don’t believe unpredictability matters here.