Changeset View
Changeset View
Standalone View
Standalone View
sys/net/altq/altq_classq.h
Show First 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | _getq_tail(class_queue_t *q) | ||||
return (m); | return (m); | ||||
} | } | ||||
/* randomly select a packet in the queue */ | /* randomly select a packet in the queue */ | ||||
static __inline struct mbuf * | static __inline struct mbuf * | ||||
_getq_random(class_queue_t *q) | _getq_random(class_queue_t *q) | ||||
{ | { | ||||
struct mbuf *m; | struct mbuf *m; | ||||
int i, n; | int i, n; | ||||
cem: Orthogonal change. | |||||
Done Inline ActionsNot completely orthogonal: n will hold an unsigned value (below), which could be higher than MAX_INT if it were not for the modulus operation. pfg: Not completely orthogonal: n will hold an unsigned value (below), which could be higher than… | |||||
if ((m = qtail(q)) == NULL) | if ((m = qtail(q)) == NULL) | ||||
return NULL; | return NULL; | ||||
if (m->m_nextpkt == m) | if (m->m_nextpkt == m) | ||||
qtail(q) = NULL; | qtail(q) = NULL; | ||||
else { | else { | ||||
struct mbuf *prev = NULL; | struct mbuf *prev = NULL; | ||||
n = random() % qlen(q) + 1; | n = arc4random() % qlen(q) + 1; | ||||
Not Done Inline ActionsI don’t know to what extent unpredictability matters in this path or the real world performance impact of arc4random vs random. This should be reviewed by someone more familiar with altq, and use arc4random_uniform(9). cem: I don’t know to what extent unpredictability matters in this path or the real world performance… | |||||
for (i = 0; i < n; i++) { | for (i = 0; i < n; i++) { | ||||
prev = m; | prev = m; | ||||
m = m->m_nextpkt; | m = m->m_nextpkt; | ||||
} | } | ||||
prev->m_nextpkt = m->m_nextpkt; | prev->m_nextpkt = m->m_nextpkt; | ||||
if (m == qtail(q)) | if (m == qtail(q)) | ||||
qtail(q) = prev; | qtail(q) = prev; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines |
Orthogonal change.