Release 4.11 net/sched/sch_netem.c
/*
* net/sched/sch_netem.c Network emulator
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License.
*
* Many of the algorithms and ideas for this came from
* NIST Net which is not copyrighted.
*
* Authors: Stephen Hemminger <shemminger@osdl.org>
* Catalin(ux aka Dino) BOIE <catab at umbrella dot ro>
*/
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/skbuff.h>
#include <linux/vmalloc.h>
#include <linux/rtnetlink.h>
#include <linux/reciprocal_div.h>
#include <linux/rbtree.h>
#include <net/netlink.h>
#include <net/pkt_sched.h>
#include <net/inet_ecn.h>
#define VERSION "1.3"
/* Network Emulation Queuing algorithm.
====================================
Sources: [1] Mark Carson, Darrin Santay, "NIST Net - A Linux-based
Network Emulation Tool
[2] Luigi Rizzo, DummyNet for FreeBSD
----------------------------------------------------------------
This started out as a simple way to delay outgoing packets to
test TCP but has grown to include most of the functionality
of a full blown network emulator like NISTnet. It can delay
packets and add random jitter (and correlation). The random
distribution can be loaded from a table as well to provide
normal, Pareto, or experimental curves. Packet loss,
duplication, and reordering can also be emulated.
This qdisc does not do classification that can be handled in
layering other disciplines. It does not need to do bandwidth
control either since that can be handled by using token
bucket or other rate control.
Correlated Loss Generator models
Added generation of correlated loss according to the
"Gilbert-Elliot" model, a 4-state markov model.
References:
[1] NetemCLG Home http://netgroup.uniroma2.it/NetemCLG
[2] S. Salsano, F. Ludovici, A. Ordine, "Definition of a general
and intuitive loss model for packet networks and its implementation
in the Netem module in the Linux kernel", available in [1]
Authors: Stefano Salsano <stefano.salsano at uniroma2.it
Fabio Ludovici <fabio.ludovici at yahoo.it>
*/
struct netem_sched_data {
/* internal t(ime)fifo qdisc uses t_root and sch->limit */
struct rb_root t_root;
/* optional qdisc for classful handling (NULL at netem init) */
struct Qdisc *qdisc;
struct qdisc_watchdog watchdog;
psched_tdiff_t latency;
psched_tdiff_t jitter;
u32 loss;
u32 ecn;
u32 limit;
u32 counter;
u32 gap;
u32 duplicate;
u32 reorder;
u32 corrupt;
u64 rate;
s32 packet_overhead;
u32 cell_size;
struct reciprocal_value cell_size_reciprocal;
s32 cell_overhead;
struct crndstate {
u32 last;
u32 rho;
}
delay_cor, loss_cor, dup_cor, reorder_cor, corrupt_cor;
struct disttable {
u32 size;
s16 table[0];
}
*delay_dist;
enum {
CLG_RANDOM,
CLG_4_STATES,
CLG_GILB_ELL,
}
loss_model;
enum {
TX_IN_GAP_PERIOD = 1,
TX_IN_BURST_PERIOD,
LOST_IN_GAP_PERIOD,
LOST_IN_BURST_PERIOD,
}
_4_state_model;
enum {
GOOD_STATE = 1,
BAD_STATE,
}
GE_state_model;
/* Correlated Loss Generation models */
struct clgstate {
/* state of the Markov chain */
u8 state;
/* 4-states and Gilbert-Elliot models */
u32 a1; /* p13 for 4-states or p for GE */
u32 a2; /* p31 for 4-states or r for GE */
u32 a3; /* p32 for 4-states or h for GE */
u32 a4; /* p14 for 4-states or 1-k for GE */
u32 a5; /* p23 used only in 4-states */
}
clg;
};
/* Time stamp put into socket buffer control block
* Only valid when skbs are in our internal t(ime)fifo queue.
*
* As skb->rbnode uses same storage than skb->next, skb->prev and skb->tstamp,
* and skb->next & skb->prev are scratch space for a qdisc,
* we save skb->tstamp value in skb->cb[] before destroying it.
*/
struct netem_skb_cb {
psched_time_t time_to_send;
ktime_t tstamp_save;
};
static struct sk_buff *netem_rb_to_skb(struct rb_node *rb)
{
return rb_entry(rb, struct sk_buff, rbnode);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Eric Dumazet | 23 | 95.83% | 2 | 66.67% |
Geliang Tang | 1 | 4.17% | 1 | 33.33% |
Total | 24 | 100.00% | 3 | 100.00% |
static inline struct netem_skb_cb *netem_skb_cb(struct sk_buff *skb)
{
/* we assume we can use skb next/prev/tstamp as storage for rb_node */
qdisc_cb_private_validate(skb, sizeof(struct netem_skb_cb));
return (struct netem_skb_cb *)qdisc_skb_cb(skb)->data;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jussi Kivilinna | 36 | 92.31% | 2 | 50.00% |
David S. Miller | 2 | 5.13% | 1 | 25.00% |
Eric Dumazet | 1 | 2.56% | 1 | 25.00% |
Total | 39 | 100.00% | 4 | 100.00% |
/* init_crandom - initialize correlated random number generator
* Use entropy source for initial seed.
*/
static void init_crandom(struct crndstate *state, unsigned long rho)
{
state->rho = rho;
state->last = prandom_u32();
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Stephen Hemminger | 27 | 96.43% | 1 | 50.00% |
Aruna-Hewapathirane | 1 | 3.57% | 1 | 50.00% |
Total | 28 | 100.00% | 2 | 100.00% |
/* get_crandom - correlated random number generator
* Next number depends on last value.
* rho is scaled to avoid floating point.
*/
static u32 get_crandom(struct crndstate *state)
{
u64 value, rho;
unsigned long answer;
if (state->rho == 0) /* no correlation */
return prandom_u32();
value = prandom_u32();
rho = (u64)state->rho + 1;
answer = (value * ((1ull<<32) - rho) + state->last * rho) >> 32;
state->last = answer;
return answer;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Stephen Hemminger | 80 | 97.56% | 4 | 80.00% |
Aruna-Hewapathirane | 2 | 2.44% | 1 | 20.00% |
Total | 82 | 100.00% | 5 | 100.00% |
/* loss_4state - 4-state model loss generator
* Generates losses according to the 4-state Markov chain adopted in
* the GI (General and Intuitive) loss model.
*/
static bool loss_4state(struct netem_sched_data *q)
{
struct clgstate *clg = &q->clg;
u32 rnd = prandom_u32();
/*
* Makes a comparison between rnd and the transition
* probabilities outgoing from the current state, then decides the
* next state and if the next packet has to be transmitted or lost.
* The four states correspond to:
* TX_IN_GAP_PERIOD => successfully transmitted packets within a gap period
* LOST_IN_BURST_PERIOD => isolated losses within a gap period
* LOST_IN_GAP_PERIOD => lost packets within a burst period
* TX_IN_GAP_PERIOD => successfully transmitted packets within a burst period
*/
switch (clg->state) {
case TX_IN_GAP_PERIOD:
if (rnd < clg->a4) {
clg->state = LOST_IN_BURST_PERIOD;
return true;
} else if (clg->a4 < rnd && rnd < clg->a1 + clg->a4) {
clg->state = LOST_IN_GAP_PERIOD;
return true;
} else if (clg->a1 + clg->a4 < rnd) {
clg->state = TX_IN_GAP_PERIOD;
}
break;
case TX_IN_BURST_PERIOD:
if (rnd < clg->a5) {
clg->state = LOST_IN_GAP_PERIOD;
return true;
} else {
clg->state = TX_IN_BURST_PERIOD;
}
break;
case LOST_IN_GAP_PERIOD:
if (rnd < clg->a3)
clg->state = TX_IN_BURST_PERIOD;
else if (clg->a3 < rnd && rnd < clg->a2 + clg->a3) {
clg->state = TX_IN_GAP_PERIOD;
} else if (clg->a2 + clg->a3 < rnd) {
clg->state = LOST_IN_GAP_PERIOD;
return true;
}
break;
case LOST_IN_BURST_PERIOD:
clg->state = TX_IN_GAP_PERIOD;
break;
}
return false;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Stephen Hemminger | 205 | 91.52% | 2 | 50.00% |
Yang Yingliang | 18 | 8.04% | 1 | 25.00% |
Aruna-Hewapathirane | 1 | 0.45% | 1 | 25.00% |
Total | 224 | 100.00% | 4 | 100.00% |
/* loss_gilb_ell - Gilbert-Elliot model loss generator
* Generates losses according to the Gilbert-Elliot loss model or
* its special cases (Gilbert or Simple Gilbert)
*
* Makes a comparison between random number and the transition
* probabilities outgoing from the current state, then decides the
* next state. A second random number is extracted and the comparison
* with the loss probability of the current state decides if the next
* packet will be transmitted or lost.
*/
static bool loss_gilb_ell(struct netem_sched_data *q)
{
struct clgstate *clg = &q->clg;
switch (clg->state) {
case GOOD_STATE:
if (prandom_u32() < clg->a1)
clg->state = BAD_STATE;
if (prandom_u32() < clg->a4)
return true;
break;
case BAD_STATE:
if (prandom_u32() < clg->a2)
clg->state = GOOD_STATE;
if (prandom_u32() > clg->a3)
return true;
}
return false;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Stephen Hemminger | 85 | 91.40% | 3 | 60.00% |
Aruna-Hewapathirane | 4 | 4.30% | 1 | 20.00% |
Yang Yingliang | 4 | 4.30% | 1 | 20.00% |
Total | 93 | 100.00% | 5 | 100.00% |
static bool loss_event(struct netem_sched_data *q)
{
switch (q->loss_model) {
case CLG_RANDOM:
/* Random packet drop 0 => none, ~0 => all */
return q->loss && q->loss >= get_crandom(&q->loss_cor);
case CLG_4_STATES:
/* 4state loss model algorithm (used also for GI model)
* Extracts a value from the markov 4 state loss generator,
* if it is 1 drops a packet and if needed writes the event in
* the kernel logs
*/
return loss_4state(q);
case CLG_GILB_ELL:
/* Gilbert-Elliot loss model algorithm
* Extracts a value from the Gilbert-Elliot loss generator,
* if it is 1 drops a packet and if needed writes the event in
* the kernel logs
*/
return loss_gilb_ell(q);
}
return false; /* not reached */
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Stephen Hemminger | 64 | 100.00% | 1 | 100.00% |
Total | 64 | 100.00% | 1 | 100.00% |
/* tabledist - return a pseudo-randomly distributed value with mean mu and
* std deviation sigma. Uses table lookup to approximate the desired
* distribution, and a uniformly-distributed pseudo-random source.
*/
static psched_tdiff_t tabledist(psched_tdiff_t mu, psched_tdiff_t sigma,
struct crndstate *state,
const struct disttable *dist)
{
psched_tdiff_t x;
long t;
u32 rnd;
if (sigma == 0)
return mu;
rnd = get_crandom(state);
/* default uniform distribution */
if (dist == NULL)
return (rnd % (2*sigma)) - sigma + mu;
t = dist->table[rnd % dist->size];
x = (sigma % NETEM_DIST_SCALE) * t;
if (x >= 0)
x += NETEM_DIST_SCALE/2;
else
x -= NETEM_DIST_SCALE/2;
return x / NETEM_DIST_SCALE + (sigma / NETEM_DIST_SCALE) * t + mu;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Stephen Hemminger | 127 | 100.00% | 5 | 100.00% |
Total | 127 | 100.00% | 5 | 100.00% |
static psched_time_t packet_len_2_sched_time(unsigned int len, struct netem_sched_data *q)
{
u64 ticks;
len += q->packet_overhead;
if (q->cell_size) {
u32 cells = reciprocal_divide(len, q->cell_size_reciprocal);
if (len > cells * q->cell_size) /* extra cell needed for remainder */
cells++;
len = cells * (q->cell_size + q->cell_overhead);
}
ticks = (u64)len * NSEC_PER_SEC;
do_div(ticks, q->rate);
return PSCHED_NS2TICKS(ticks);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Hagen Paul Pfeifer | 83 | 86.46% | 2 | 66.67% |
Eric Dumazet | 13 | 13.54% | 1 | 33.33% |
Total | 96 | 100.00% | 3 | 100.00% |
static void tfifo_reset(struct Qdisc *sch)
{
struct netem_sched_data *q = qdisc_priv(sch);
struct rb_node *p;
while ((p = rb_first(&q->t_root))) {
struct sk_buff *skb = netem_rb_to_skb(p);
rb_erase(p, &q->t_root);
rtnl_kfree_skbs(skb, skb);
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Stephen Hemminger | 66 | 95.65% | 1 | 50.00% |
Eric Dumazet | 3 | 4.35% | 1 | 50.00% |
Total | 69 | 100.00% | 2 | 100.00% |
static void tfifo_enqueue(struct sk_buff *nskb, struct Qdisc *sch)
{
struct netem_sched_data *q = qdisc_priv(sch);
psched_time_t tnext = netem_skb_cb(nskb)->time_to_send;
struct rb_node **p = &q->t_root.rb_node, *parent = NULL;
while (*p) {
struct sk_buff *skb;
parent = *p;
skb = netem_rb_to_skb(parent);
if (tnext >= netem_skb_cb(skb)->time_to_send)
p = &parent->rb_right;
else
p = &parent->rb_left;
}
rb_link_node(&nskb->rbnode, parent, p);
rb_insert_color(&nskb->rbnode, &q->t_root);
sch->q.qlen++;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Eric Dumazet | 136 | 100.00% | 4 | 100.00% |
Total | 136 | 100.00% | 4 | 100.00% |
/* netem can't properly corrupt a megapacket (like we get from GSO), so instead
* when we statistically choose to corrupt one, we instead segment it, returning
* the first packet to be corrupted, and re-enqueue the remaining frames
*/
static struct sk_buff *netem_segment(struct sk_buff *skb, struct Qdisc *sch,
struct sk_buff **to_free)
{
struct sk_buff *segs;
netdev_features_t features = netif_skb_features(skb);
segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK);
if (IS_ERR_OR_NULL(segs)) {
qdisc_drop(skb, sch, to_free);
return NULL;
}
consume_skb(skb);
return segs;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Horman | 69 | 88.46% | 1 | 33.33% |
Eric Dumazet | 8 | 10.26% | 1 | 33.33% |
Florian Westphal | 1 | 1.28% | 1 | 33.33% |
Total | 78 | 100.00% | 3 | 100.00% |
static void netem_enqueue_skb_head(struct qdisc_skb_head *qh, struct sk_buff *skb)
{
skb->next = qh->head;
if (!qh->head)
qh->tail = skb;
qh->head = skb;
qh->qlen++;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Westphal | 48 | 100.00% | 1 | 100.00% |
Total | 48 | 100.00% | 1 | 100.00% |
/*
* Insert one skb into qdisc.
* Note: parent depends on return value to account for queue length.
* NET_XMIT_DROP: queue length didn't change.
* NET_XMIT_SUCCESS: one skb was queued.
*/
static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch,
struct sk_buff **to_free)
{
struct netem_sched_data *q = qdisc_priv(sch);
/* We don't fill cb now as skb_unshare() may invalidate it */
struct netem_skb_cb *cb;
struct sk_buff *skb2;
struct sk_buff *segs = NULL;
unsigned int len = 0, last_len, prev_len = qdisc_pkt_len(skb);
int nb = 0;
int count = 1;
int rc = NET_XMIT_SUCCESS;
/* Random duplication */
if (q->duplicate && q->duplicate >= get_crandom(&q->dup_cor))
++count;
/* Drop packet? */
if (loss_event(q)) {
if (q->ecn && INET_ECN_set_ce(skb))
qdisc_qstats_drop(sch); /* mark packet */
else
--count;
}
if (count == 0) {
qdisc_qstats_drop(sch);
__qdisc_drop(skb, to_free);
return NET_XMIT_SUCCESS | __NET_XMIT_BYPASS;
}
/* If a delay is expected, orphan the skb. (orphaning usually takes
* place at TX completion time, so _before_ the link transit delay)
*/
if (q->latency || q->jitter)
skb_orphan_partial(skb);
/*
* If we need to duplicate packet, then re-insert at top of the
* qdisc tree, since parent queuer expects that only one
* skb will be queued.
*/
if (count > 1 && (skb2 = skb_clone(skb, GFP_ATOMIC)) != NULL) {
struct Qdisc *rootq = qdisc_root(sch);
u32 dupsave = q->duplicate; /* prevent duplicating a dup... */
q->duplicate = 0;
rootq->enqueue(skb2, rootq, to_free);
q->duplicate = dupsave;
}
/*
* Randomized packet corruption.
* Make copy if needed since we are modifying
* If packet is going to be hardware checksummed, then
* do it now in software before we mangle it.
*/
if (q->corrupt && q->corrupt >= get_crandom(&q->corrupt_cor)) {
if (skb_is_gso(skb)) {
segs = netem_segment(skb, sch, to_free);
if (!segs)
return NET_XMIT_DROP;
} else {
segs = skb;
}
skb = segs;
segs = segs->next;
skb = skb_unshare(skb, GFP_ATOMIC);
if (unlikely(!skb)) {
qdisc_qstats_drop(sch);
goto finish_segs;
}
if (skb->ip_summed == CHECKSUM_PARTIAL &&
skb_checksum_help(skb)) {
qdisc_drop(skb, sch, to_free);
goto finish_segs;
}
skb->data[prandom_u32() % skb_headlen(skb)] ^=
1<<(prandom_u32() % 8);
}
if (unlikely(sch->q.qlen >= sch->limit))
return qdisc_drop(skb, sch, to_free);
qdisc_qstats_backlog_inc(sch, skb);
cb = netem_skb_cb(skb);
if (q->gap == 0 || /* not doing reordering */
q->counter < q->gap - 1 || /* inside last reordering gap */
q->reorder < get_crandom(&q->reorder_cor)) {
psched_time_t now;
psched_tdiff_t delay;
delay = tabledist(q->latency, q->jitter,
&q->delay_cor, q->delay_dist);
now = psched_get_time();
if (q->rate) {
struct sk_buff *last;
if (sch->q.qlen)
last = sch->q.tail;
else
last = netem_rb_to_skb(rb_last(&q->t_root));
if (last) {
/*
* Last packet in queue is reference point (now),
* calculate this time bonus and subtract
* from delay.
*/
delay -= netem_skb_cb(last)->time_to_send - now;
delay = max_t(psched_tdiff_t, 0, delay);
now = netem_skb_cb(last)->time_to_send;
}
delay += packet_len_2_sched_time(qdisc_pkt_len(skb), q);
}
cb->time_to_send = now + delay;
cb->tstamp_save = skb->tstamp;
++q->counter;
tfifo_enqueue(skb, sch);
} else {
/*
* Do re-ordering by putting one out of N packets at the front
* of the queue.
*/
cb->time_to_send = psched_get_time();
q->counter = 0;
netem_enqueue_skb_head(&sch->q, skb);
sch->qstats.requeues++;
}
finish_segs:
if (segs) {
while (segs) {
skb2 = segs->next;
segs->next = NULL;
qdisc_skb_cb(segs)->pkt_len = segs->len;
last_len = segs->len;
rc = qdisc_enqueue(segs, sch, to_free);
if (rc != NET_XMIT_SUCCESS) {
if (net_xmit_drop_count(rc))
qdisc_qstats_drop(sch);
} else {
nb++;
len += last_len;
}
segs = skb2;
}
sch->q.qlen += nb;
if (nb > 1)
qdisc_tree_reduce_backlog(sch, 1 - nb, prev_len - len);
}
return NET_XMIT_SUCCESS;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Stephen Hemminger | 298 | 39.31% | 17 | 34.69% |
Neil Horman | 192 | 25.33% | 1 | 2.04% |
Eric Dumazet | 143 | 18.87% | 10 | 20.41% |
Hagen Paul Pfeifer | 34 | 4.49% | 2 | 4.08% |
Johannes Naab | 23 | 3.03% | 1 | 2.04% |
Jarek Poplawski | 15 | 1.98% | 2 | 4.08% |
Patrick McHardy | 11 | 1.45% | 3 | 6.12% |
John Fastabend | 9 | 1.19% | 1 | 2.04% |
Florian Westphal | 8 | 1.06% | 3 | 6.12% |
David S. Miller | 7 | 0.92% | 2 | 4.08% |
Guillaume Chazarain | 6 | 0.79% | 1 | 2.04% |
Yang Yingliang | 3 | 0.40% | 1 | 2.04% |
Vijay Subramanian | 2 | 0.26% | 1 | 2.04% |
Aruna-Hewapathirane | 2 | 0.26% | 1 | 2.04% |
Jussi Kivilinna | 2 | 0.26% | 1 | 2.04% |
Joe Perches | 2 | 0.26% | 1 | 2.04% |
Hideaki Yoshifuji / 吉藤英明 | 1 | 0.13% | 1 | 2.04% |
Total | 758 | 100.00% | 49 | 100.00% |
static struct sk_buff *netem_dequeue(struct Qdisc *sch)
{
struct netem_sched_data *q = qdisc_priv(sch);
struct sk_buff *skb;
struct rb_node *p;
tfifo_dequeue:
skb = __qdisc_dequeue_head(&sch->q);
if (skb) {
qdisc_qstats_backlog_dec(sch, skb);
deliver:
qdisc_bstats_update(sch, skb);
return skb;
}
p = rb_first(&q->t_root);
if (p) {
psched_time_t time_to_send;
skb = netem_rb_to_skb(p);
/* if more time remaining? */
time_to_send = netem_skb_cb(skb)->time_to_send;
if (time_to_send <= psched_get_time()) {
rb_erase(p, &q->t_root);
sch->q.qlen--;
qdisc_qstats_backlog_dec(sch, skb);
skb->next = NULL;
skb->prev = NULL;
skb->tstamp = netem_skb_cb(skb)->tstamp_save;
#ifdef CONFIG_NET_CLS_ACT
/*
* If it's at ingress let's pretend the delay is
* from the network (tstamp will be updated).
*/
if (skb->tc_redirected && skb->tc_from_ingress)
skb->tstamp = 0;
#endif
if (q->qdisc) {
unsigned int pkt_len = qdisc_pkt_len(skb);
struct sk_buff *to_free = NULL;
int err;
err = qdisc_enqueue(skb, q->qdisc, &to_free);
kfree_skb_list(to_free);
if (err != NET_XMIT_SUCCESS &&
net_xmit_drop_count(err)) {
qdisc_qstats_drop(sch);
qdisc_tree_reduce_backlog(sch, 1,
pkt_len);
}
goto tfifo_dequeue;
}
goto deliver;
}
if (q->qdisc) {
skb = q->qdisc->ops->dequeue(q->qdisc);
if (skb)
goto deliver;
}
qdisc_watchdog_schedule(&q->watchdog, time_to_send);
}
if (q->qdisc) {
skb = q->qdisc->ops->dequeue(q->qdisc);
if (skb)
goto deliver;
}
return NULL;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Eric Dumazet | 227 | 67.56% | 7 | 25.93% |
Stephen Hemminger | 62 | 18.45% | 10 | 37.04% |
Jarek Poplawski | 21 | 6.25% | 3 | 11.11% |
Beshay, Joseph | 9 | 2.68% | 1 | 3.70% |
John Fastabend | 6 | 1.79% | 1 | 3.70% |
Willem de Bruijn | 5 | 1.49% | 1 | 3.70% |
Américo Wang | 2 | 0.60% | 1 | 3.70% |
Jussi Kivilinna | 2 | 0.60% | 1 | 3.70% |
Florian Westphal | 1 | 0.30% | 1 | 3.70% |
Patrick McHardy | 1 | 0.30% | 1 | 3.70% |
Total | 336 | 100.00% | 27 | 100.00% |
static void netem_reset(struct Qdisc *sch)
{
struct netem_sched_data *q = qdisc_priv(sch);
qdisc_reset_queue(sch);
tfifo_reset(sch);
if (q->qdisc)
qdisc_reset(q->qdisc);
qdisc_watchdog_cancel(&q->watchdog);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Stephen Hemminger | 39 | 75.00% | 5 | 71.43% |
Eric Dumazet | 11 | 21.15% | 1 | 14.29% |
Patrick McHardy | 2 | 3.85% | 1 | 14.29% |
Total | 52 | 100.00% | 7 | 100.00% |
static void dist_free(struct disttable *d)
{
kvfree(d);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Stephen Hemminger | 15 | 93.75% | 1 | 50.00% |
Américo Wang | 1 | 6.25% | 1 | 50.00% |
Total | 16 | 100.00% | 2 | 100.00% |
/*
* Distribution data is a variable size payload containing
* signed 16 bit values.
*/
static int get_dist_table(struct Qdisc *sch, const struct nlattr *attr)
{
struct netem_sched_data *q = qdisc_priv(sch);
size_t n = nla_len(attr)/sizeof(__s16);
const __s16 *data = nla_data(attr);
spinlock_t *root_lock;
struct disttable *d;
int i;
size_t s;
if (n > NETEM_DIST_MAX)
return -EINVAL;
s = sizeof(struct disttable) + n * sizeof(s16);
d = kmalloc(s, GFP_KERNEL | __GFP_NOWARN);
if (!d)
d = vmalloc(s);
if (!d)
return -ENOMEM;
d->size = n;
for (i = 0; i < n; i++)
d->table[i] = data[i];
root_lock = qdisc_root_sleeping_lock(sch);
spin_lock_bh(root_lock);
swap(q->delay_dist, d);
spin_unlock_bh(root_lock);
dist_free(d);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Stephen Hemminger | 159 | 85.03% | 8 | 61.54% |
David S. Miller | 12 | 6.42% | 1 | 7.69% |
Eric Dumazet | 10 | 5.35% | 1 | 7.69% |
Patrick McHardy | 5 | 2.67% | 2 | 15.38% |
Jarek Poplawski | 1 | 0.53% | 1 | 7.69% |
Total | 187 | 100.00% | 13 | 100.00% |
static void get_correlation(struct netem_sched_data *q, const struct nlattr *attr)
{
const struct tc_netem_corr *c = nla_data(attr);
init_crandom(&q->delay_cor, c->delay_corr);
init_crandom(&q->loss_cor, c->loss_corr);
init_crandom(&q->dup_cor, c->dup_corr);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Stephen Hemminger | 60 | 93.75% | 4 | 66.67% |
Yang Yingliang | 2 | 3.12% | 1 | 16.67% |
Patrick McHardy | 2 | 3.12% | 1 | 16.67% |
Total | 64 | 100.00% | 6 | 100.00% |
static void get_reorder(struct netem_sched_data *q, const struct nlattr *attr)
{
const struct tc_netem_reorder *r = nla_data(attr);
q->reorder = r->probability;
init_crandom(&q->reorder_cor, r->correlation);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Stephen Hemminger | 44 | 91.67% | 2 | 50.00% |
Yang Yingliang | 2 | 4.17% | 1 | 25.00% |
Patrick McHardy | 2 | 4.17% | 1 | 25.00% |
Total | 48 | 100.00% | 4 | 100.00% |
static void get_corrupt(struct netem_sched_data *q, const struct nlattr *attr)
{
const struct tc_netem_corrupt *r = nla_data(attr);
q->corrupt = r->probability;
init_crandom(&q->corrupt_cor, r->correlation);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Stephen Hemminger | 44 | 91.67% | 3 | 60.00% |
Yang Yingliang | 2 | 4.17% | 1 | 20.00% |
Patrick McHardy | 2 | 4.17% | 1 | 20.00% |
Total | 48 | 100.00% | 5 | 100.00% |
static void get_rate(struct netem_sched_data *q, const struct nlattr *attr)
{
const struct tc_netem_rate *r = nla_data(attr);
q->rate = r->rate;
q->packet_overhead = r->packet_overhead;
q->cell_size = r->cell_size;
q->cell_overhead = r->cell_overhead;
if (q->cell_size)
q->cell_size_reciprocal = reciprocal_value(q->cell_size);
else
q->cell_size_reciprocal = (struct reciprocal_value) { 0 };
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Hagen Paul Pfeifer | 71 | 78.89% | 2 | 50.00% |
Hannes Frederic Sowa | 17 | 18.89% | 1 | 25.00% |
Yang Yingliang | 2 | 2.22% | 1 | 25.00% |
Total | 90 | 100.00% | 4 | 100.00% |
static int get_loss_clg(struct netem_sched_data *q, const struct nlattr *