Commit 4c30719f authored by Stephen Hemminger's avatar Stephen Hemminger Committed by David S. Miller

[PKT_SCHED] dsmark: handle cloned and non-linear skb's

Make dsmark work properly with non-linear and cloned skb's
Before modifying the header, it needs to check that skb header is
writeable.

Note: this makes the assumption, that if it queues a good skb
then a good skb will come out of the embedded qdisc.
Signed-off-by: default avatarStephen Hemminger <shemminger@vyatta.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5b0ac72b
...@@ -187,13 +187,19 @@ static int dsmark_enqueue(struct sk_buff *skb,struct Qdisc *sch) ...@@ -187,13 +187,19 @@ static int dsmark_enqueue(struct sk_buff *skb,struct Qdisc *sch)
pr_debug("dsmark_enqueue(skb %p,sch %p,[qdisc %p])\n", skb, sch, p); pr_debug("dsmark_enqueue(skb %p,sch %p,[qdisc %p])\n", skb, sch, p);
if (p->set_tc_index) { if (p->set_tc_index) {
/* FIXME: Safe with non-linear skbs? --RR */
switch (skb->protocol) { switch (skb->protocol) {
case __constant_htons(ETH_P_IP): case __constant_htons(ETH_P_IP):
if (skb_cow_head(skb, sizeof(struct iphdr)))
goto drop;
skb->tc_index = ipv4_get_dsfield(ip_hdr(skb)) skb->tc_index = ipv4_get_dsfield(ip_hdr(skb))
& ~INET_ECN_MASK; & ~INET_ECN_MASK;
break; break;
case __constant_htons(ETH_P_IPV6): case __constant_htons(ETH_P_IPV6):
if (skb_cow_head(skb, sizeof(struct ipv6hdr)))
goto drop;
skb->tc_index = ipv6_get_dsfield(ipv6_hdr(skb)) skb->tc_index = ipv6_get_dsfield(ipv6_hdr(skb))
& ~INET_ECN_MASK; & ~INET_ECN_MASK;
break; break;
...@@ -217,14 +223,14 @@ static int dsmark_enqueue(struct sk_buff *skb,struct Qdisc *sch) ...@@ -217,14 +223,14 @@ static int dsmark_enqueue(struct sk_buff *skb,struct Qdisc *sch)
case TC_ACT_STOLEN: case TC_ACT_STOLEN:
kfree_skb(skb); kfree_skb(skb);
return NET_XMIT_SUCCESS; return NET_XMIT_SUCCESS;
case TC_ACT_SHOT: case TC_ACT_SHOT:
kfree_skb(skb); goto drop;
sch->qstats.drops++;
return NET_XMIT_BYPASS;
#endif #endif
case TC_ACT_OK: case TC_ACT_OK:
skb->tc_index = TC_H_MIN(res.classid); skb->tc_index = TC_H_MIN(res.classid);
break; break;
default: default:
if (p->default_index != NO_DEFAULT_INDEX) if (p->default_index != NO_DEFAULT_INDEX)
skb->tc_index = p->default_index; skb->tc_index = p->default_index;
...@@ -243,6 +249,11 @@ static int dsmark_enqueue(struct sk_buff *skb,struct Qdisc *sch) ...@@ -243,6 +249,11 @@ static int dsmark_enqueue(struct sk_buff *skb,struct Qdisc *sch)
sch->q.qlen++; sch->q.qlen++;
return NET_XMIT_SUCCESS; return NET_XMIT_SUCCESS;
drop:
kfree_skb(skb);
sch->qstats.drops++;
return NET_XMIT_BYPASS;
} }
static struct sk_buff *dsmark_dequeue(struct Qdisc *sch) static struct sk_buff *dsmark_dequeue(struct Qdisc *sch)
......
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