diff options
author | Patrick McHardy <kaber@trash.net> | 2008-01-23 23:36:30 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:11:23 -0500 |
commit | 53b2bf3f8a652c9c8e86831f94ae2c5767ea54d7 (patch) | |
tree | eba61efed08a932766a32b0b6a60e766f8b44bcb /net/sched/act_gact.c | |
parent | 6fa8c0144b770dac941cf2c15053b6e24f046c8a (diff) |
[NET_SCHED]: Use nla_policy for attribute validation in actions
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/act_gact.c')
-rw-r--r-- | net/sched/act_gact.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/net/sched/act_gact.c b/net/sched/act_gact.c index df214d47fc92..422872c4f14b 100644 --- a/net/sched/act_gact.c +++ b/net/sched/act_gact.c | |||
@@ -53,6 +53,11 @@ typedef int (*g_rand)(struct tcf_gact *gact); | |||
53 | static g_rand gact_rand[MAX_RAND]= { NULL, gact_net_rand, gact_determ }; | 53 | static g_rand gact_rand[MAX_RAND]= { NULL, gact_net_rand, gact_determ }; |
54 | #endif /* CONFIG_GACT_PROB */ | 54 | #endif /* CONFIG_GACT_PROB */ |
55 | 55 | ||
56 | static const struct nla_policy gact_policy[TCA_GACT_MAX + 1] = { | ||
57 | [TCA_GACT_PARMS] = { .len = sizeof(struct tc_gact) }, | ||
58 | [TCA_GACT_PROB] = { .len = sizeof(struct tc_gact_p) }, | ||
59 | }; | ||
60 | |||
56 | static int tcf_gact_init(struct nlattr *nla, struct nlattr *est, | 61 | static int tcf_gact_init(struct nlattr *nla, struct nlattr *est, |
57 | struct tc_action *a, int ovr, int bind) | 62 | struct tc_action *a, int ovr, int bind) |
58 | { | 63 | { |
@@ -66,20 +71,16 @@ static int tcf_gact_init(struct nlattr *nla, struct nlattr *est, | |||
66 | if (nla == NULL) | 71 | if (nla == NULL) |
67 | return -EINVAL; | 72 | return -EINVAL; |
68 | 73 | ||
69 | err = nla_parse_nested(tb, TCA_GACT_MAX, nla, NULL); | 74 | err = nla_parse_nested(tb, TCA_GACT_MAX, nla, gact_policy); |
70 | if (err < 0) | 75 | if (err < 0) |
71 | return err; | 76 | return err; |
72 | 77 | ||
73 | if (tb[TCA_GACT_PARMS] == NULL || | 78 | if (tb[TCA_GACT_PARMS] == NULL) |
74 | nla_len(tb[TCA_GACT_PARMS]) < sizeof(*parm)) | ||
75 | return -EINVAL; | 79 | return -EINVAL; |
76 | parm = nla_data(tb[TCA_GACT_PARMS]); | 80 | parm = nla_data(tb[TCA_GACT_PARMS]); |
77 | 81 | ||
82 | #ifndef CONFIG_GACT_PROB | ||
78 | if (tb[TCA_GACT_PROB] != NULL) | 83 | if (tb[TCA_GACT_PROB] != NULL) |
79 | #ifdef CONFIG_GACT_PROB | ||
80 | if (nla_len(tb[TCA_GACT_PROB]) < sizeof(struct tc_gact_p)) | ||
81 | return -EINVAL; | ||
82 | #else | ||
83 | return -EOPNOTSUPP; | 84 | return -EOPNOTSUPP; |
84 | #endif | 85 | #endif |
85 | 86 | ||