Commit 104b0567 authored by Stephen Hemminger's avatar Stephen Hemminger Committed by David S. Miller

[PKT_SCHED]: Two small netem fixes.

- rtnetlink.h needs including
- optimize loss test so that net_random() call is not done
  when no-loss is indicated
Signed-off-by: default avatarStephen Hemminger <shemminger@osdl.org>
Signed-off-by: default avatarDavid S. Miller <davem@redhat.com>
parent 5326baef
......@@ -18,6 +18,7 @@
#include <linux/errno.h>
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <linux/rtnetlink.h>
#include <net/pkt_sched.h>
......@@ -54,7 +55,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
pr_debug("netem_enqueue skb=%p @%lu\n", skb, jiffies);
/* Random packet drop 0 => none, ~0 => all */
if (q->loss >= net_random()) {
if (q->loss && q->loss >= net_random()) {
sch->stats.drops++;
return 0; /* lie about loss so TCP doesn't know */
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment