aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2006-11-30 22:54:05 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2006-12-03 00:32:07 -0500
commit1e9b3d5339d2afd6348e8211f0db695b00261e17 (patch)
tree0dd54ad172b0bfb2e905168913a199cab69e9ab1
parent5f68e4c07c7b97a5b06f0b5e313528d36415a60d (diff)
[NET_SCHED]: policer: restore compatibility with old iproute binaries
The tc actions increased the size of struct tc_police, which broke compatibility with old iproute binaries since both the act_police and the old NET_CLS_POLICE code check for an exact size match. Since the new members are not even used, the simple fix is to also accept the size of the old structure. Dumping is not affected since old userspace will receive a bigger structure, which is handled fine. Signed-off-by: Patrick McHardy <kaber@trash.net> Acked-by: Jamal Hadi Salim <hadi@cyberus.ca> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/sched/act_police.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/net/sched/act_police.c b/net/sched/act_police.c
index fed47b658837..af68e1e83251 100644
--- a/net/sched/act_police.c
+++ b/net/sched/act_police.c
@@ -46,6 +46,18 @@ static struct tcf_hashinfo police_hash_info = {
46 .lock = &police_lock, 46 .lock = &police_lock,
47}; 47};
48 48
49/* old policer structure from before tc actions */
50struct tc_police_compat
51{
52 u32 index;
53 int action;
54 u32 limit;
55 u32 burst;
56 u32 mtu;
57 struct tc_ratespec rate;
58 struct tc_ratespec peakrate;
59};
60
49/* Each policer is serialized by its individual spinlock */ 61/* Each policer is serialized by its individual spinlock */
50 62
51#ifdef CONFIG_NET_CLS_ACT 63#ifdef CONFIG_NET_CLS_ACT
@@ -131,12 +143,15 @@ static int tcf_act_police_locate(struct rtattr *rta, struct rtattr *est,
131 struct tc_police *parm; 143 struct tc_police *parm;
132 struct tcf_police *police; 144 struct tcf_police *police;
133 struct qdisc_rate_table *R_tab = NULL, *P_tab = NULL; 145 struct qdisc_rate_table *R_tab = NULL, *P_tab = NULL;
146 int size;
134 147
135 if (rta == NULL || rtattr_parse_nested(tb, TCA_POLICE_MAX, rta) < 0) 148 if (rta == NULL || rtattr_parse_nested(tb, TCA_POLICE_MAX, rta) < 0)
136 return -EINVAL; 149 return -EINVAL;
137 150
138 if (tb[TCA_POLICE_TBF-1] == NULL || 151 if (tb[TCA_POLICE_TBF-1] == NULL)
139 RTA_PAYLOAD(tb[TCA_POLICE_TBF-1]) != sizeof(*parm)) 152 return -EINVAL;
153 size = RTA_PAYLOAD(tb[TCA_POLICE_TBF-1]);
154 if (size != sizeof(*parm) && size != sizeof(struct tc_police_compat))
140 return -EINVAL; 155 return -EINVAL;
141 parm = RTA_DATA(tb[TCA_POLICE_TBF-1]); 156 parm = RTA_DATA(tb[TCA_POLICE_TBF-1]);
142 157
@@ -415,12 +430,15 @@ struct tcf_police *tcf_police_locate(struct rtattr *rta, struct rtattr *est)
415 struct tcf_police *police; 430 struct tcf_police *police;
416 struct rtattr *tb[TCA_POLICE_MAX]; 431 struct rtattr *tb[TCA_POLICE_MAX];
417 struct tc_police *parm; 432 struct tc_police *parm;
433 int size;
418 434
419 if (rtattr_parse_nested(tb, TCA_POLICE_MAX, rta) < 0) 435 if (rtattr_parse_nested(tb, TCA_POLICE_MAX, rta) < 0)
420 return NULL; 436 return NULL;
421 437
422 if (tb[TCA_POLICE_TBF-1] == NULL || 438 if (tb[TCA_POLICE_TBF-1] == NULL)
423 RTA_PAYLOAD(tb[TCA_POLICE_TBF-1]) != sizeof(*parm)) 439 return NULL;
440 size = RTA_PAYLOAD(tb[TCA_POLICE_TBF-1]);
441 if (size != sizeof(*parm) && size != sizeof(struct tc_police_compat))
424 return NULL; 442 return NULL;
425 443
426 parm = RTA_DATA(tb[TCA_POLICE_TBF-1]); 444 parm = RTA_DATA(tb[TCA_POLICE_TBF-1]);