diff options
Diffstat (limited to 'net/sched/act_simple.c')
| -rw-r--r-- | net/sched/act_simple.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/net/sched/act_simple.c b/net/sched/act_simple.c index 8daa1ebc7413..97e84f3ee775 100644 --- a/net/sched/act_simple.c +++ b/net/sched/act_simple.c | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
| 14 | #include <linux/slab.h> | ||
| 14 | #include <linux/init.h> | 15 | #include <linux/init.h> |
| 15 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
| 16 | #include <linux/skbuff.h> | 17 | #include <linux/skbuff.h> |
| @@ -48,7 +49,7 @@ static int tcf_simp(struct sk_buff *skb, struct tc_action *a, struct tcf_result | |||
| 48 | * Example if this was the 3rd packet and the string was "hello" | 49 | * Example if this was the 3rd packet and the string was "hello" |
| 49 | * then it would look like "hello_3" (without quotes) | 50 | * then it would look like "hello_3" (without quotes) |
| 50 | **/ | 51 | **/ |
| 51 | printk("simple: %s_%d\n", | 52 | pr_info("simple: %s_%d\n", |
| 52 | (char *)d->tcfd_defdata, d->tcf_bstats.packets); | 53 | (char *)d->tcfd_defdata, d->tcf_bstats.packets); |
| 53 | spin_unlock(&d->tcf_lock); | 54 | spin_unlock(&d->tcf_lock); |
| 54 | return d->tcf_action; | 55 | return d->tcf_action; |
| @@ -72,10 +73,10 @@ static int tcf_simp_release(struct tcf_defact *d, int bind) | |||
| 72 | 73 | ||
| 73 | static int alloc_defdata(struct tcf_defact *d, char *defdata) | 74 | static int alloc_defdata(struct tcf_defact *d, char *defdata) |
| 74 | { | 75 | { |
| 75 | d->tcfd_defdata = kstrndup(defdata, SIMP_MAX_DATA, GFP_KERNEL); | 76 | d->tcfd_defdata = kzalloc(SIMP_MAX_DATA, GFP_KERNEL); |
| 76 | if (unlikely(!d->tcfd_defdata)) | 77 | if (unlikely(!d->tcfd_defdata)) |
| 77 | return -ENOMEM; | 78 | return -ENOMEM; |
| 78 | 79 | strlcpy(d->tcfd_defdata, defdata, SIMP_MAX_DATA); | |
| 79 | return 0; | 80 | return 0; |
| 80 | } | 81 | } |
| 81 | 82 | ||
| @@ -163,13 +164,14 @@ static inline int tcf_simp_dump(struct sk_buff *skb, struct tc_action *a, | |||
| 163 | { | 164 | { |
| 164 | unsigned char *b = skb_tail_pointer(skb); | 165 | unsigned char *b = skb_tail_pointer(skb); |
| 165 | struct tcf_defact *d = a->priv; | 166 | struct tcf_defact *d = a->priv; |
| 166 | struct tc_defact opt; | 167 | struct tc_defact opt = { |
| 168 | .index = d->tcf_index, | ||
| 169 | .refcnt = d->tcf_refcnt - ref, | ||
| 170 | .bindcnt = d->tcf_bindcnt - bind, | ||
| 171 | .action = d->tcf_action, | ||
| 172 | }; | ||
| 167 | struct tcf_t t; | 173 | struct tcf_t t; |
| 168 | 174 | ||
| 169 | opt.index = d->tcf_index; | ||
| 170 | opt.refcnt = d->tcf_refcnt - ref; | ||
| 171 | opt.bindcnt = d->tcf_bindcnt - bind; | ||
| 172 | opt.action = d->tcf_action; | ||
| 173 | NLA_PUT(skb, TCA_DEF_PARMS, sizeof(opt), &opt); | 175 | NLA_PUT(skb, TCA_DEF_PARMS, sizeof(opt), &opt); |
| 174 | NLA_PUT_STRING(skb, TCA_DEF_DATA, d->tcfd_defdata); | 176 | NLA_PUT_STRING(skb, TCA_DEF_DATA, d->tcfd_defdata); |
| 175 | t.install = jiffies_to_clock_t(jiffies - d->tcf_tm.install); | 177 | t.install = jiffies_to_clock_t(jiffies - d->tcf_tm.install); |
| @@ -204,7 +206,7 @@ static int __init simp_init_module(void) | |||
| 204 | { | 206 | { |
| 205 | int ret = tcf_register_action(&act_simp_ops); | 207 | int ret = tcf_register_action(&act_simp_ops); |
| 206 | if (!ret) | 208 | if (!ret) |
| 207 | printk("Simple TC action Loaded\n"); | 209 | pr_info("Simple TC action Loaded\n"); |
| 208 | return ret; | 210 | return ret; |
| 209 | } | 211 | } |
| 210 | 212 | ||
