diff options
author | Changli Gao <xiaosuo@gmail.com> | 2010-06-24 12:25:12 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-06-29 02:24:32 -0400 |
commit | 210d6de78c5d7c785fc532556cea340e517955e1 (patch) | |
tree | e4bbac89a8bc16154f51ad61e140be1b7bd2b92d | |
parent | c4ead4c595cd54cf7b1a184d4f888ce0d7cce7d4 (diff) |
act_mirred: don't clone skb when skb isn't shared
don't clone skb when skb isn't shared
When the tcf_action is TC_ACT_STOLEN, and the skb isn't shared, we don't need
to clone a new skb. As the skb will be freed after this function returns, we
can use it freely once we get a reference to it.
Signed-off-by: Changli Gao <xiaosuo@gmail.com>
----
include/net/sch_generic.h | 11 +++++++++--
net/sched/act_mirred.c | 6 +++---
2 files changed, 12 insertions(+), 5 deletions(-)
Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/sch_generic.h | 11 | ||||
-rw-r--r-- | net/sched/act_mirred.c | 6 |
2 files changed, 12 insertions, 5 deletions
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index b35301b0c7b6..977ec06ed0c7 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h | |||
@@ -594,9 +594,16 @@ static inline u32 qdisc_l2t(struct qdisc_rate_table* rtab, unsigned int pktlen) | |||
594 | } | 594 | } |
595 | 595 | ||
596 | #ifdef CONFIG_NET_CLS_ACT | 596 | #ifdef CONFIG_NET_CLS_ACT |
597 | static inline struct sk_buff *skb_act_clone(struct sk_buff *skb, gfp_t gfp_mask) | 597 | static inline struct sk_buff *skb_act_clone(struct sk_buff *skb, gfp_t gfp_mask, |
598 | int action) | ||
598 | { | 599 | { |
599 | struct sk_buff *n = skb_clone(skb, gfp_mask); | 600 | struct sk_buff *n; |
601 | |||
602 | if ((action == TC_ACT_STOLEN || action == TC_ACT_QUEUED) && | ||
603 | !skb_shared(skb)) | ||
604 | n = skb_get(skb); | ||
605 | else | ||
606 | n = skb_clone(skb, gfp_mask); | ||
600 | 607 | ||
601 | if (n) { | 608 | if (n) { |
602 | n->tc_verd = SET_TC_VERD(n->tc_verd, 0); | 609 | n->tc_verd = SET_TC_VERD(n->tc_verd, 0); |
diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c index c0b6863e3b87..2e9a7b91aa10 100644 --- a/net/sched/act_mirred.c +++ b/net/sched/act_mirred.c | |||
@@ -169,13 +169,13 @@ static int tcf_mirred(struct sk_buff *skb, struct tc_action *a, | |||
169 | goto out; | 169 | goto out; |
170 | } | 170 | } |
171 | 171 | ||
172 | skb2 = skb_act_clone(skb, GFP_ATOMIC); | 172 | at = G_TC_AT(skb->tc_verd); |
173 | skb2 = skb_act_clone(skb, GFP_ATOMIC, m->tcf_action); | ||
173 | if (skb2 == NULL) | 174 | if (skb2 == NULL) |
174 | goto out; | 175 | goto out; |
175 | 176 | ||
176 | m->tcf_bstats.bytes += qdisc_pkt_len(skb2); | 177 | m->tcf_bstats.bytes += qdisc_pkt_len(skb2); |
177 | m->tcf_bstats.packets++; | 178 | m->tcf_bstats.packets++; |
178 | at = G_TC_AT(skb->tc_verd); | ||
179 | if (!(at & AT_EGRESS)) { | 179 | if (!(at & AT_EGRESS)) { |
180 | if (m->tcfm_ok_push) | 180 | if (m->tcfm_ok_push) |
181 | skb_push(skb2, skb2->dev->hard_header_len); | 181 | skb_push(skb2, skb2->dev->hard_header_len); |
@@ -185,8 +185,8 @@ static int tcf_mirred(struct sk_buff *skb, struct tc_action *a, | |||
185 | if (m->tcfm_eaction != TCA_EGRESS_MIRROR) | 185 | if (m->tcfm_eaction != TCA_EGRESS_MIRROR) |
186 | skb2->tc_verd = SET_TC_FROM(skb2->tc_verd, at); | 186 | skb2->tc_verd = SET_TC_FROM(skb2->tc_verd, at); |
187 | 187 | ||
188 | skb2->dev = dev; | ||
189 | skb2->skb_iif = skb->dev->ifindex; | 188 | skb2->skb_iif = skb->dev->ifindex; |
189 | skb2->dev = dev; | ||
190 | dev_queue_xmit(skb2); | 190 | dev_queue_xmit(skb2); |
191 | err = 0; | 191 | err = 0; |
192 | 192 | ||