aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/act_ipt.c
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2008-01-23 01:11:50 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:11:11 -0500
commit7ba699c604ab811972eee2e041fd6b07659a2e6e (patch)
tree4f76f69a25ce27ee0dd0c417df75acf00b1a36a0 /net/sched/act_ipt.c
parentadd93b610a4e66d36d0cf0b2596c3d3bcfdaee39 (diff)
[NET_SCHED]: Convert actions from rtnetlink to new netlink API
Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/act_ipt.c')
-rw-r--r--net/sched/act_ipt.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/net/sched/act_ipt.c b/net/sched/act_ipt.c
index fa006e06ce33..fee5282637cc 100644
--- a/net/sched/act_ipt.c
+++ b/net/sched/act_ipt.c
@@ -92,10 +92,10 @@ static int tcf_ipt_release(struct tcf_ipt *ipt, int bind)
92 return ret; 92 return ret;
93} 93}
94 94
95static int tcf_ipt_init(struct rtattr *rta, struct rtattr *est, 95static int tcf_ipt_init(struct nlattr *nla, struct nlattr *est,
96 struct tc_action *a, int ovr, int bind) 96 struct tc_action *a, int ovr, int bind)
97{ 97{
98 struct rtattr *tb[TCA_IPT_MAX]; 98 struct nlattr *tb[TCA_IPT_MAX + 1];
99 struct tcf_ipt *ipt; 99 struct tcf_ipt *ipt;
100 struct tcf_common *pc; 100 struct tcf_common *pc;
101 struct ipt_entry_target *td, *t; 101 struct ipt_entry_target *td, *t;
@@ -104,22 +104,22 @@ static int tcf_ipt_init(struct rtattr *rta, struct rtattr *est,
104 u32 hook = 0; 104 u32 hook = 0;
105 u32 index = 0; 105 u32 index = 0;
106 106
107 if (rta == NULL || rtattr_parse_nested(tb, TCA_IPT_MAX, rta) < 0) 107 if (nla == NULL || nla_parse_nested(tb, TCA_IPT_MAX, nla, NULL) < 0)
108 return -EINVAL; 108 return -EINVAL;
109 109
110 if (tb[TCA_IPT_HOOK-1] == NULL || 110 if (tb[TCA_IPT_HOOK] == NULL ||
111 RTA_PAYLOAD(tb[TCA_IPT_HOOK-1]) < sizeof(u32)) 111 nla_len(tb[TCA_IPT_HOOK]) < sizeof(u32))
112 return -EINVAL; 112 return -EINVAL;
113 if (tb[TCA_IPT_TARG-1] == NULL || 113 if (tb[TCA_IPT_TARG] == NULL ||
114 RTA_PAYLOAD(tb[TCA_IPT_TARG-1]) < sizeof(*t)) 114 nla_len(tb[TCA_IPT_TARG]) < sizeof(*t))
115 return -EINVAL; 115 return -EINVAL;
116 td = (struct ipt_entry_target *)RTA_DATA(tb[TCA_IPT_TARG-1]); 116 td = (struct ipt_entry_target *)nla_data(tb[TCA_IPT_TARG]);
117 if (RTA_PAYLOAD(tb[TCA_IPT_TARG-1]) < td->u.target_size) 117 if (nla_len(tb[TCA_IPT_TARG]) < td->u.target_size)
118 return -EINVAL; 118 return -EINVAL;
119 119
120 if (tb[TCA_IPT_INDEX-1] != NULL && 120 if (tb[TCA_IPT_INDEX] != NULL &&
121 RTA_PAYLOAD(tb[TCA_IPT_INDEX-1]) >= sizeof(u32)) 121 nla_len(tb[TCA_IPT_INDEX]) >= sizeof(u32))
122 index = *(u32 *)RTA_DATA(tb[TCA_IPT_INDEX-1]); 122 index = *(u32 *)nla_data(tb[TCA_IPT_INDEX]);
123 123
124 pc = tcf_hash_check(index, a, bind, &ipt_hash_info); 124 pc = tcf_hash_check(index, a, bind, &ipt_hash_info);
125 if (!pc) { 125 if (!pc) {
@@ -136,14 +136,14 @@ static int tcf_ipt_init(struct rtattr *rta, struct rtattr *est,
136 } 136 }
137 ipt = to_ipt(pc); 137 ipt = to_ipt(pc);
138 138
139 hook = *(u32 *)RTA_DATA(tb[TCA_IPT_HOOK-1]); 139 hook = *(u32 *)nla_data(tb[TCA_IPT_HOOK]);
140 140
141 err = -ENOMEM; 141 err = -ENOMEM;
142 tname = kmalloc(IFNAMSIZ, GFP_KERNEL); 142 tname = kmalloc(IFNAMSIZ, GFP_KERNEL);
143 if (unlikely(!tname)) 143 if (unlikely(!tname))
144 goto err1; 144 goto err1;
145 if (tb[TCA_IPT_TABLE - 1] == NULL || 145 if (tb[TCA_IPT_TABLE] == NULL ||
146 rtattr_strlcpy(tname, tb[TCA_IPT_TABLE-1], IFNAMSIZ) >= IFNAMSIZ) 146 nla_strlcpy(tname, tb[TCA_IPT_TABLE], IFNAMSIZ) >= IFNAMSIZ)
147 strcpy(tname, "mangle"); 147 strcpy(tname, "mangle");
148 148
149 t = kmemdup(td, td->u.target_size, GFP_KERNEL); 149 t = kmemdup(td, td->u.target_size, GFP_KERNEL);
@@ -243,25 +243,25 @@ static int tcf_ipt_dump(struct sk_buff *skb, struct tc_action *a, int bind, int
243 243
244 t = kmemdup(ipt->tcfi_t, ipt->tcfi_t->u.user.target_size, GFP_ATOMIC); 244 t = kmemdup(ipt->tcfi_t, ipt->tcfi_t->u.user.target_size, GFP_ATOMIC);
245 if (unlikely(!t)) 245 if (unlikely(!t))
246 goto rtattr_failure; 246 goto nla_put_failure;
247 247
248 c.bindcnt = ipt->tcf_bindcnt - bind; 248 c.bindcnt = ipt->tcf_bindcnt - bind;
249 c.refcnt = ipt->tcf_refcnt - ref; 249 c.refcnt = ipt->tcf_refcnt - ref;
250 strcpy(t->u.user.name, ipt->tcfi_t->u.kernel.target->name); 250 strcpy(t->u.user.name, ipt->tcfi_t->u.kernel.target->name);
251 251
252 RTA_PUT(skb, TCA_IPT_TARG, ipt->tcfi_t->u.user.target_size, t); 252 NLA_PUT(skb, TCA_IPT_TARG, ipt->tcfi_t->u.user.target_size, t);
253 RTA_PUT(skb, TCA_IPT_INDEX, 4, &ipt->tcf_index); 253 NLA_PUT(skb, TCA_IPT_INDEX, 4, &ipt->tcf_index);
254 RTA_PUT(skb, TCA_IPT_HOOK, 4, &ipt->tcfi_hook); 254 NLA_PUT(skb, TCA_IPT_HOOK, 4, &ipt->tcfi_hook);
255 RTA_PUT(skb, TCA_IPT_CNT, sizeof(struct tc_cnt), &c); 255 NLA_PUT(skb, TCA_IPT_CNT, sizeof(struct tc_cnt), &c);
256 RTA_PUT(skb, TCA_IPT_TABLE, IFNAMSIZ, ipt->tcfi_tname); 256 NLA_PUT(skb, TCA_IPT_TABLE, IFNAMSIZ, ipt->tcfi_tname);
257 tm.install = jiffies_to_clock_t(jiffies - ipt->tcf_tm.install); 257 tm.install = jiffies_to_clock_t(jiffies - ipt->tcf_tm.install);
258 tm.lastuse = jiffies_to_clock_t(jiffies - ipt->tcf_tm.lastuse); 258 tm.lastuse = jiffies_to_clock_t(jiffies - ipt->tcf_tm.lastuse);
259 tm.expires = jiffies_to_clock_t(ipt->tcf_tm.expires); 259 tm.expires = jiffies_to_clock_t(ipt->tcf_tm.expires);
260 RTA_PUT(skb, TCA_IPT_TM, sizeof (tm), &tm); 260 NLA_PUT(skb, TCA_IPT_TM, sizeof (tm), &tm);
261 kfree(t); 261 kfree(t);
262 return skb->len; 262 return skb->len;
263 263
264rtattr_failure: 264nla_put_failure:
265 nlmsg_trim(skb, b); 265 nlmsg_trim(skb, b);
266 kfree(t); 266 kfree(t);
267 return -1; 267 return -1;