: Conversion to new netlink API
Subsystems (6)
cover : Conversion to new netlink API
These patches convert the packet schedulers to the new netlink API. This will allow to use the new features like automatic attribute checking and gets rid of the largest rtnetlink.h user we still have. Unfortunately a gradual conversion is not really feasible, so the patches are quite large, but most of them has been generated automatically, so I'm pretty sure they are correct and didn't miss anything. Also included are some minor unrelated cleanups I had queued in the same tree.
Please apply, thanks.
include/net/act_api.h | 8 +- include/net/gen_stats.h | 6 +- include/net/netlink.h | 3 + include/net/pkt_cls.h | 10 +- include/net/pkt_sched.h | 2 +- include/net/sch_generic.h | 8 +- net/core/gen_estimator.c | 8 +- net/core/gen_stats.c | 9 +- net/mac80211/wme.c | 14 ++-- net/netfilter/xt_RATEEST.c | 7 +- net/netlink/attr.c | 19 ++++ net/sched/act_api.c | 221 ++++++++++++++++++++++---------------------- net/sched/act_gact.c | 28 +++--- net/sched/act_ipt.c | 46 +++++----- net/sched/act_mirred.c | 18 ++-- net/sched/act_nat.c | 18 ++-- net/sched/act_pedit.c | 20 ++-- net/sched/act_police.c | 50 +++++----- net/sched/act_simple.c | 24 +++--- net/sched/cls_api.c | 65 +++++++------ net/sched/cls_basic.c | 42 ++++---- net/sched/cls_fw.c | 57 ++++++------ net/sched/cls_route.c | 73 +++++++-------- net/sched/cls_rsvp.h | 48 +++++----- net/sched/cls_tcindex.c | 69 +++++++------- net/sched/cls_u32.c | 81 ++++++++-------- net/sched/em_meta.c | 56 ++++++------ net/sched/em_text.c | 9 +- net/sched/ematch.c | 85 +++++++++--------- net/sched/sch_api.c | 96 +++++++++++--------- net/sched/sch_atm.c | 48 +++++----- net/sched/sch_cbq.c | 156 ++++++++++++++++---------------- net/sched/sch_dsmark.c | 85 ++++++++++------- net/sched/sch_fifo.c | 13 +-- net/sched/sch_generic.c | 23 ++--- net/sched/sch_gred.c | 59 +++++++------ net/sched/sch_hfsc.c | 72 +++++++------- net/sched/sch_htb.c | 68 +++++++------- net/sched/sch_ingress.c | 14 ++-- net/sched/sch_netem.c | 100 ++++++++++---------- net/sched/sch_prio.c | 30 ++++--- net/sched/sch_red.c | 52 ++++++----- net/sched/sch_sfq.c | 12 +- net/sched/sch_tbf.c | 49 +++++----- net/sched/sch_teql.c | 2 +- 45 files changed, 1022 insertions(+), 961 deletions(-)
Patrick McHardy (6):
[NET_SCHED]: Move EXPORT_SYMBOL next to exported symbol [NET_SCHED]: mark classifier ops __read_mostly
[NETLINK]: Add nla_append()
[NET_SCHED]: Convert packet schedulers from rtnetlink to new netlink API [NET_SCHED]: Convert classifiers from rtnetlink to new netlink API [NET_SCHED]: Convert actions from rtnetlink to new netlink API
PATCH 1/6 : Move EXPORT_SYMBOL next to exported symbol
[NET_SCHED]: Move EXPORT_SYMBOL next to exported symbol
---
commit 8b868a47c5bedb1daa8534ae60c2d89fcad26781
tree 93ba760730b3b3e74250c984e871840ace8317a3
parent bae4a7effd59ef0d521de2bc97902fa0a243b544
author Patrick McHardy <[email protected]> Tue, 22 Jan 2008 15:49:30 +0100 committer Patrick McHardy <[email protected]> Tue, 22 Jan 2008 15:49:30 +0100
net/sched/act_api.c | 9 ++++----- net/sched/ematch.c | 11 +++++------ net/sched/sch_api.c | 9 ++++----- net/sched/sch_fifo.c | 3 +-- net/sched/sch_generic.c | 17 ++++++++--------- 5 files changed, 22 insertions(+), 27 deletions(-)
net/sched/act_api.c +4 -5
@@ -263,6 +263,7 @@ int tcf_register_action(struct tc_action_ops *act)write_unlock (&act_mod_lock);return 0 ; } +EXPORT_SYMBOL (tcf_register_action);int tcf_unregister_action (struct tc_action_ops *act) {
@@ -281,6 +282,7 @@ int tcf_unregister_action(struct tc_action_ops *act)write_unlock (&act_mod_lock);return err; } +EXPORT_SYMBOL (tcf_unregister_action);/* lookup by name */ static struct tc_action_ops *tc_lookup_action_n (char *kind)
@@ -377,6 +379,7 @@ repeat: exec_done:return ret; } +EXPORT_SYMBOL (tcf_action_exec);void tcf_action_destroy (struct tc_action *act,int bind) {
@@ -430,6 +433,7 @@ rtattr_failure:nlmsg_trim (skb, b);return -1 ; } +EXPORT_SYMBOL (tcf_action_dump_1);int tcf_action_dump (struct sk_buff *skb,struct tc_action *act,int bind,int ref)
@@ -1077,8 +1081,3 @@ static int __init tc_action_init(void) }subsys_initcall (tc_action_init); - -EXPORT_SYMBOL (tcf_register_action); -EXPORT_SYMBOL (tcf_unregister_action); -EXPORT_SYMBOL (tcf_action_exec); -EXPORT_SYMBOL (tcf_action_dump_1);
net/sched/ematch.c +5 -6
@@ -141,6 +141,7 @@ errout:write_unlock (&ematch_mod_lock);return err; } +EXPORT_SYMBOL (tcf_em_register);/** * tcf_em_unregister - unregster and extended match
@@ -171,6 +172,7 @@ out:write_unlock (&ematch_mod_lock);return err; } +EXPORT_SYMBOL (tcf_em_unregister);static inline struct tcf_ematch *tcf_em_get_match (struct tcf_ematch_tree *tree,int index)
@@ -380,6 +382,7 @@ errout_abort:tcf_em_tree_destroy (tp, tree);return err; } +EXPORT_SYMBOL (tcf_em_tree_validate);/** * tcf_em_tree_destroy - destroy an ematch tree
@@ -413,6 +416,7 @@ void tcf_em_tree_destroy(struct tcf_proto *tp, struct tcf_ematch_tree *tree) tree->hdr.nmatches =0 ;kfree (tree->matches); } +EXPORT_SYMBOL (tcf_em_tree_destroy);/** * tcf_em_tree_dump - dump ematch tree into a rtnl message
@@ -472,6 +476,7 @@ int tcf_em_tree_dump(struct sk_buff *skb, struct tcf_ematch_tree *tree, int tlv) rtattr_failure:return -1 ; } +EXPORT_SYMBOL (tcf_em_tree_dump);static inline int tcf_em_match (struct sk_buff *skb,struct tcf_ematch *em,struct tcf_pkt_info *info)
@@ -529,10 +534,4 @@ stack_overflow:printk ("Local stack overflow, increase NET_EMATCH_STACK\n" );return -1 ; } - -EXPORT_SYMBOL (tcf_em_register); -EXPORT_SYMBOL (tcf_em_unregister); -EXPORT_SYMBOL (tcf_em_tree_validate); -EXPORT_SYMBOL (tcf_em_tree_destroy); -EXPORT_SYMBOL (tcf_em_tree_dump);EXPORT_SYMBOL (__tcf_em_tree_match);
net/sched/sch_api.c +4 -5
@@ -158,6 +158,7 @@ out:write_unlock (&qdisc_mod_lock);return rc; } +EXPORT_SYMBOL (register_qdisc);int unregister_qdisc (struct Qdisc_ops *qops) {
@@ -176,6 +177,7 @@ int unregister_qdisc(struct Qdisc_ops *qops)write_unlock (&qdisc_mod_lock);return err; } +EXPORT_SYMBOL (unregister_qdisc);/* We know handle. Find qdisc among all qdisc's attached to device (root qdisc, all its children, children of children etc.)
@@ -255,6 +257,7 @@ struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r, struct rtattr *ta }return rtab; } +EXPORT_SYMBOL (qdisc_get_rtab);void qdisc_put_rtab (struct qdisc_rate_table *tab) {
@@ -271,6 +274,7 @@ void qdisc_put_rtab(struct qdisc_rate_table *tab) } } } +EXPORT_SYMBOL (qdisc_put_rtab);static enum hrtimer_restart qdisc_watchdog (struct hrtimer *timer) {
@@ -1289,8 +1293,3 @@ static int __init pktsched_init(void) }subsys_initcall (pktsched_init); - -EXPORT_SYMBOL (qdisc_get_rtab); -EXPORT_SYMBOL (qdisc_put_rtab); -EXPORT_SYMBOL (register_qdisc); -EXPORT_SYMBOL (unregister_qdisc);
net/sched/sch_fifo.c +1 -2
@@ -91,6 +91,7 @@ struct Qdisc_ops pfifo_qdisc_ops __read_mostly = { .dump = fifo_dump, .owner = THIS_MODULE, }; +EXPORT_SYMBOL (pfifo_qdisc_ops);struct Qdisc_ops bfifo_qdisc_ops__read_mostly = { .id ="bfifo" ,
@@ -105,6 +106,4 @@ struct Qdisc_ops bfifo_qdisc_ops __read_mostly = { .dump = fifo_dump, .owner = THIS_MODULE, }; -EXPORT_SYMBOL (bfifo_qdisc_ops); -EXPORT_SYMBOL (pfifo_qdisc_ops);
net/sched/sch_generic.c +8 -9
@@ -46,6 +46,7 @@ void qdisc_lock_tree(struct net_device *dev)spin_lock_bh (&dev->queue_lock);spin_lock (&dev->ingress_lock); } +EXPORT_SYMBOL (qdisc_lock_tree); void qdisc_unlock_tree(struct net_device *dev) __releases(dev->ingress_lock)
@@ -54,6 +55,7 @@ void qdisc_unlock_tree(struct net_device *dev)spin_unlock (&dev->ingress_lock);spin_unlock_bh (&dev->queue_lock); } +EXPORT_SYMBOL (qdisc_unlock_tree);static inline int qdisc_qlen (struct Qdisc *q) {
@@ -253,6 +255,7 @@ void netif_carrier_on(struct net_device *dev)__netdev_watchdog_up (dev); } } +EXPORT_SYMBOL (netif_carrier_on);/** * netif_carrier_off - clear carrier
@@ -265,6 +268,7 @@ void netif_carrier_off(struct net_device *dev)if (!test_and_set_bit (__LINK_STATE_NOCARRIER, &dev->state))linkwatch_fire_event (dev); } +EXPORT_SYMBOL (netif_carrier_off);/* "NOOP" scheduler: the best scheduler, recommended for all interfaces under all circumstances. It is difficult to invent anything faster or
@@ -307,6 +311,7 @@ struct Qdisc noop_qdisc = { .ops = &noop_qdisc_ops, .list = LIST_HEAD_INIT(noop_qdisc.list), }; +EXPORT_SYMBOL (noop_qdisc);static struct Qdisc_ops noqueue_qdisc_ops__read_mostly = { .id ="noqueue" ,
@@ -471,6 +476,7 @@ struct Qdisc * qdisc_create_dflt(struct net_device *dev, struct Qdisc_ops *ops, errout:return NULL ; } +EXPORT_SYMBOL (qdisc_create_dflt);/* Under dev->queue_lock and BH! */
@@ -481,6 +487,7 @@ void qdisc_reset(struct Qdisc *qdisc)if (ops->reset) ops->reset (qdisc); } +EXPORT_SYMBOL (qdisc_reset);/* this is the rcu callback function to clean up a qdisc when there * are no further references to it */
@@ -512,6 +519,7 @@ void qdisc_destroy(struct Qdisc *qdisc)dev_put (qdisc->dev);call_rcu (&qdisc->q_rcu, __qdisc_destroy); } +EXPORT_SYMBOL (qdisc_destroy);void dev_activate (struct net_device *dev) {
@@ -626,12 +634,3 @@ void dev_shutdown(struct net_device *dev)BUG_TRAP (!timer_pending (&dev->watchdog_timer));qdisc_unlock_tree (dev); } - -EXPORT_SYMBOL (netif_carrier_on); -EXPORT_SYMBOL (netif_carrier_off); -EXPORT_SYMBOL (noop_qdisc); -EXPORT_SYMBOL (qdisc_create_dflt); -EXPORT_SYMBOL (qdisc_destroy); -EXPORT_SYMBOL (qdisc_reset); -EXPORT_SYMBOL (qdisc_lock_tree); -EXPORT_SYMBOL (qdisc_unlock_tree);
PATCH 2/6 : mark classifier ops __read_mostly
In reply to Patrick McHardy[NET_SCHED]: mark classifier ops __read_mostly
Additionally remove unnecessary NULL initilizations of the next pointer.
---
commit 4cf7dba2c890608fee47fe46487c79abf322dc82
tree 4f29f07adbaf0dfe78f6148205644b6b2dbd1717
parent 8b868a47c5bedb1daa8534ae60c2d89fcad26781
author Patrick McHardy <[email protected]> Tue, 22 Jan 2008 15:49:30 +0100 committer Patrick McHardy <[email protected]> Tue, 22 Jan 2008 15:49:30 +0100
net/sched/cls_api.c | 2 +- net/sched/cls_basic.c | 2 +- net/sched/cls_fw.c | 3 +-- net/sched/cls_route.c | 3 +-- net/sched/cls_tcindex.c | 3 +-- net/sched/cls_u32.c | 3 +-- 6 files changed, 6 insertions(+), 10 deletions(-)
net/sched/cls_api.c +1 -1
@@ -31,7 +31,7 @@/* The list of all installed classifier types */ -static struct tcf_proto_ops *tcf_proto_base; +static struct tcf_proto_ops *tcf_proto_base__read_mostly ;/* Protects list of registered TC modules. It is pure SMP lock. */ static DEFINE_RWLOCK (cls_mod_lock);
net/sched/cls_basic.c +1 -1
@@ -271,7 +271,7 @@ rtattr_failure:return -1 ; } -static struct tcf_proto_ops cls_basic_ops = { +static struct tcf_proto_ops cls_basic_ops__read_mostly = { .kind ="basic" , .classify = basic_classify, .init = basic_init,
net/sched/cls_fw.c +1 -2
@@ -370,8 +370,7 @@ rtattr_failure:return -1 ; } -static struct tcf_proto_ops cls_fw_ops = { - .next =NULL , +static struct tcf_proto_ops cls_fw_ops__read_mostly = { .kind ="fw" , .classify = fw_classify, .init = fw_init,
net/sched/cls_route.c +1 -2
@@ -590,8 +590,7 @@ rtattr_failure:return -1 ; } -static struct tcf_proto_ops cls_route4_ops = { - .next =NULL , +static struct tcf_proto_ops cls_route4_ops__read_mostly = { .kind ="route" , .classify = route4_classify, .init = route4_init,
net/sched/cls_tcindex.c +1 -2
@@ -485,8 +485,7 @@ rtattr_failure:return -1 ; } -static struct tcf_proto_ops cls_tcindex_ops = { - .next =NULL , +static struct tcf_proto_ops cls_tcindex_ops__read_mostly = { .kind ="tcindex" , .classify = tcindex_classify, .init = tcindex_init,
net/sched/cls_u32.c +1 -2
@@ -751,8 +751,7 @@ rtattr_failure:return -1 ; } -static struct tcf_proto_ops cls_u32_ops = { - .next =NULL , +static struct tcf_proto_ops cls_u32_ops__read_mostly = { .kind ="u32" , .classify = u32_classify, .init = u32_init,
PATCH 3/6 : Add nla_append()
In reply to Patrick McHardy[NETLINK]: Add nla_append()
Used to append data to a message without a header or padding.
---
commit 8a6648ddc22e03bbdf6675780c917e8c8519f205
tree 39c68f8b7aea4e94c227fe421031e0969dac92ef
parent 4cf7dba2c890608fee47fe46487c79abf322dc82
author Patrick McHardy <[email protected]> Tue, 22 Jan 2008 15:49:30 +0100 committer Patrick McHardy <[email protected]> Tue, 22 Jan 2008 15:49:30 +0100
include/net/netlink.h | 3 +++ net/netlink/attr.c | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 0 deletions(-)
include/net/netlink.h +3 -0
@@ -91,6 +91,7 @@* nla_reserve_nohdr(skb, len) reserve room for an attribute w/o hdr * nla_put(skb, type, len, data) add attribute to skb * nla_put_nohdr(skb, len, data) add attribute w/o hdr +* nla_append(skb, len, data) append data to skb * * Attribute Construction for Basic Types: * nla_put_u8(skb, type, value) add u8 attribute to skb
@@ -254,6 +255,8 @@ extern int nla_put(struct sk_buff *skb, int attrtype, int attrlen, const void *data);extern int nla_put_nohdr (struct sk_buff *skb,int attrlen,const void *data); +extern int nla_append (struct sk_buff *skb,int attrlen, +const void *data);/************************************************************************** * Netlink Messages
net/netlink/attr.c +19 -0
@@ -430,6 +430,24 @@ int nla_put_nohdr(struct sk_buff *skb, int attrlen, const void *data)return 0 ; } +/** +* nla_append - Add a netlink attribute without header or padding +* @skb: socket buffer to add attribute to +* @attrlen: length of attribute payload +* @data: head of attribute payload +* +* Returns -1 if the tailroom of the skb is insufficient to store +* the attribute payload. +*/ +int nla_append (struct sk_buff *skb,int attrlen,const void *data) +{ +if (unlikely (skb_tailroom (skb) <NLA_ALIGN (attrlen))) +return -1 ; + +memcpy (skb_put (skb, attrlen), data, attrlen); +return 0 ; +} +EXPORT_SYMBOL (nla_validate);EXPORT_SYMBOL (nla_parse);EXPORT_SYMBOL (nla_find);
@@ -445,3 +463,4 @@ EXPORT_SYMBOL(nla_put_nohdr);EXPORT_SYMBOL (nla_memcpy);EXPORT_SYMBOL (nla_memcmp);EXPORT_SYMBOL (nla_strcmp); +EXPORT_SYMBOL (nla_append);
PATCH 4/6 : Convert packet schedulers from rtnetlink to new netlink API
In reply to Patrick McHardy[NET_SCHED]: Convert packet schedulers from rtnetlink to new netlink API
Convert packet schedulers to use the netlink API. Unfortunately a gradual conversion is not possible without breaking compilation in the middle or adding lots of casts, so this patch converts them all in one step. The patch has been mostly generated automatically with some minor edits to at least allow seperate conversion of classifiers and actions.
---
commit 07a5a2c72eb790323d3e11bb2e1131f8fd43ae1d
tree 163a3ee6f3cda46634493eb55dc870294c97fde5
parent 8a6648ddc22e03bbdf6675780c917e8c8519f205
author Patrick McHardy <[email protected]> Tue, 22 Jan 2008 15:49:41 +0100 committer Patrick McHardy <[email protected]> Tue, 22 Jan 2008 15:49:41 +0100
include/net/gen_stats.h | 6 +- include/net/pkt_sched.h | 2 - include/net/sch_generic.h | 6 +- net/core/gen_estimator.c | 8 +- net/core/gen_stats.c | 9 +-- net/mac80211/wme.c | 14 ++-- net/netfilter/xt_RATEEST.c | 7 +- net/sched/act_api.c | 2 - net/sched/act_police.c | 6 +- net/sched/sch_api.c | 87 ++++++++++++++----------- net/sched/sch_atm.c | 48 +++++++------- net/sched/sch_cbq.c | 156 ++++++++++++++++++++++---------------------- net/sched/sch_dsmark.c | 85 ++++++++++++++---------- net/sched/sch_fifo.c | 10 +-- net/sched/sch_generic.c | 6 +- net/sched/sch_gred.c | 59 +++++++++-------- net/sched/sch_hfsc.c | 72 ++++++++++---------- net/sched/sch_htb.c | 68 ++++++++++--------- net/sched/sch_ingress.c | 14 ++-- net/sched/sch_netem.c | 100 ++++++++++++++-------------- net/sched/sch_prio.c | 30 +++++--- net/sched/sch_red.c | 52 ++++++++------- net/sched/sch_sfq.c | 12 ++- net/sched/sch_tbf.c | 49 +++++++------- net/sched/sch_teql.c | 2 - 25 files changed, 474 insertions(+), 436 deletions(-)
include/net/gen_stats.h +3 -3
@@ -10,7 +10,7 @@ struct gnet_dump {spinlock_t * lock;struct sk_buff * skb; -struct rtattr * tail; +struct nlattr * tail;/* Backward compatability */ int compat_tc_stats;
@@ -39,11 +39,11 @@ extern int gnet_stats_finish_copy(struct gnet_dump *d);extern int gen_new_estimator (struct gnet_stats_basic *bstats,struct gnet_stats_rate_est *rate_est, -spinlock_t *stats_lock,struct rtattr *opt); +spinlock_t *stats_lock,struct nlattr *opt);extern void gen_kill_estimator (struct gnet_stats_basic *bstats,struct gnet_stats_rate_est *rate_est);extern int gen_replace_estimator (struct gnet_stats_basic *bstats,struct gnet_stats_rate_est *rate_est, -spinlock_t *stats_lock,struct rtattr *opt); +spinlock_t *stats_lock,struct nlattr *opt);#endif
include/net/pkt_sched.h +1 -1
@@ -77,7 +77,7 @@ extern int unregister_qdisc(struct Qdisc_ops *qops);extern struct Qdisc *qdisc_lookup (struct net_device *dev,u32 handle);extern struct Qdisc *qdisc_lookup_class (struct net_device *dev,u32 handle);extern struct qdisc_rate_table *qdisc_get_rtab (struct tc_ratespec *r, -struct rtattr *tab); +struct nlattr *tab);extern void qdisc_put_rtab (struct qdisc_rate_table *tab);extern void __qdisc_run (struct net_device *dev);
include/net/sch_generic.h +3 -3
@@ -66,7 +66,7 @@ struct Qdisc_class_opsunsigned long (*get)(struct Qdisc *,u32 classid);void (*put)(struct Qdisc *,unsigned long );int (*change)(struct Qdisc *,u32 ,u32 , -struct rtattr **,unsigned long *); +struct nlattr **,unsigned long *);int (*delete)(struct Qdisc *,unsigned long );void (*walk)(struct Qdisc *,struct qdisc_walker * arg);
@@ -95,10 +95,10 @@ struct Qdisc_opsint (*requeue)(struct sk_buff *,struct Qdisc *);unsigned int (*drop)(struct Qdisc *); -int (*init)(struct Qdisc *,struct rtattr *arg); +int (*init)(struct Qdisc *,struct nlattr *arg);void (*reset)(struct Qdisc *);void (*destroy)(struct Qdisc *); -int (*change)(struct Qdisc *,struct rtattr *arg); +int (*change)(struct Qdisc *,struct nlattr *arg);int (*dump)(struct Qdisc *,struct sk_buff *);int (*dump_stats)(struct Qdisc *,struct gnet_dump *);
net/core/gen_estimator.c +4 -4
@@ -159,13 +159,13 @@ skip:int gen_new_estimator (struct gnet_stats_basic *bstats,struct gnet_stats_rate_est *rate_est,spinlock_t *stats_lock, -struct rtattr *opt) +struct nlattr *opt) {struct gen_estimator *est; -struct gnet_estimator *parm =RTA_DATA (opt); +struct gnet_estimator *parm =nla_data (opt);int idx; -if (RTA_PAYLOAD (opt) <sizeof (*parm)) +if (nla_len (opt) <sizeof (*parm))return -EINVAL ;if (parm->interval <-2 || parm->interval >3 )
@@ -254,7 +254,7 @@ void gen_kill_estimator(struct gnet_stats_basic *bstats,*/ int gen_replace_estimator (struct gnet_stats_basic *bstats,struct gnet_stats_rate_est *rate_est, -spinlock_t *stats_lock,struct rtattr *opt) +spinlock_t *stats_lock,struct nlattr *opt) {gen_kill_estimator (bstats, rate_est);return gen_new_estimator (bstats, rate_est, stats_lock, opt);
net/core/gen_stats.c +5 -4
@@ -20,16 +20,17 @@#include <linux/socket.h> #include <linux/rtnetlink.h> #include <linux/gen_stats.h> +#include <net/netlink.h> #include <net/gen_stats.h> static inline int gnet_stats_copy (struct gnet_dump *d,int type,void *buf,int size) { -RTA_PUT (d->skb, type, size, buf); +NLA_PUT (d->skb, type, size, buf);return 0 ; -rtattr_failure: +nla_put_failure:spin_unlock_bh (d->lock);return -1 ; }
@@ -62,7 +63,7 @@ gnet_stats_start_copy_compat(struct sk_buff *skb, int type, int tc_stats_type,spin_lock_bh (lock); d->lock = lock;if (type) - d->tail = (struct rtattr *)skb_tail_pointer (skb); + d->tail = (struct nlattr *)skb_tail_pointer (skb); d->skb = skb; d->compat_tc_stats = tc_stats_type; d->compat_xstats = xstats_type;
@@ -213,7 +214,7 @@ int gnet_stats_finish_copy(struct gnet_dump *d) {if (d->tail) - d->tail->rta_len =skb_tail_pointer (d->skb) - (u8 *)d->tail; + d->tail->nla_len =skb_tail_pointer (d->skb) - (u8 *)d->tail;if (d->compat_tc_stats) if (gnet_stats_copy(d, d->compat_tc_stats, &d->tc_stats,
net/mac80211/wme.c +7 -7
@@ -296,16 +296,16 @@ static void wme_qdiscop_destroy(struct Qdisc* qd)/* called whenever parameters are updated on existing qdisc */ -static int wme_qdiscop_tune (struct Qdisc *qd,struct rtattr *opt) +static int wme_qdiscop_tune (struct Qdisc *qd,struct nlattr *opt) {/* struct ieee80211_sched_data *q = qdisc_priv(qd); */ /* check our options block is the right size */ /* copy any options to our local structure */ /* Ignore options block for now - always use static mapping -struct tc_ieee80211_qopt *qopt = RTA_DATA(opt); +struct tc_ieee80211_qopt *qopt = nla_data(opt); -if (opt->rta_len < RTA_LENGTH(sizeof(*qopt))) +if (opt->nla_len < nla_attr_size(sizeof(*qopt))) return -EINVAL; memcpy(q->tag2queue, qopt->tag2queue, sizeof(qopt->tag2queue)); */
@@ -314,7 +314,7 @@ static int wme_qdiscop_tune(struct Qdisc *qd, struct rtattr *opt)/* called during initial creation of qdisc on device */ -static int wme_qdiscop_init (struct Qdisc *qd,struct rtattr *opt) +static int wme_qdiscop_init (struct Qdisc *qd,struct nlattr *opt) {struct ieee80211_sched_data *q =qdisc_priv (qd);struct net_device *dev = qd->dev;
@@ -369,10 +369,10 @@ static int wme_qdiscop_dump(struct Qdisc *qd, struct sk_buff *skb)struct tc_ieee80211_qopt opt; memcpy(&opt.tag2queue, q->tag2queue, TC_80211_MAX_TAG + 1); -RTA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt); +NLA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt); */ return skb->len;/* -rtattr_failure: +nla_put_failure: skb_trim(skb, p - skb->data);*/ return -1 ; }
@@ -443,7 +443,7 @@ static void wme_classop_put(struct Qdisc *q, unsigned long cl)static int wme_classop_change (struct Qdisc *qd,u32 handle,u32 parent, -struct rtattr **tca,unsigned long *arg) +struct nlattr **tca,unsigned long *arg) {unsigned long cl = *arg;struct ieee80211_local *local =wdev_priv (qd->dev->ieee80211_ptr);
net/netfilter/xt_RATEEST.c +4 -3
@@ -12,6 +12,7 @@#include <linux/rtnetlink.h> #include <linux/random.h> #include <net/gen_stats.h> +#include <net/netlink.h> #include <linux/netfilter/x_tables.h> #include <linux/netfilter/xt_RATEEST.h>
@@ -98,7 +99,7 @@ xt_rateest_tg_checkentry(const char *tablename,struct xt_rateest_target_info *info = (void *)targinfo;struct xt_rateest *est;struct { -struct rtattr opt; +struct nlattr opt;struct gnet_estimator est; } cfg;
@@ -128,8 +129,8 @@ xt_rateest_tg_checkentry(const char *tablename, est->params.interval = info->interval; est->params.ewma_log = info->ewma_log; - cfg.opt.rta_len =RTA_LENGTH (sizeof (cfg.est)); - cfg.opt.rta_type =TCA_STATS_RATE_EST ; + cfg.opt.nla_len =nla_attr_size (sizeof (cfg.est)); + cfg.opt.nla_type =TCA_STATS_RATE_EST ; cfg.est.interval = info->interval; cfg.est.ewma_log = info->ewma_log;
net/sched/act_api.c +1 -1
@@ -227,7 +227,7 @@ struct tcf_common *tcf_hash_create(u32 index, struct rtattr *est, struct tc_acti p->tcfc_tm.lastuse = jiffies;if (est)gen_new_estimator (&p->tcfc_bstats, &p->tcfc_rate_est, - &p->tcfc_lock, est); + &p->tcfc_lock, (struct nlattr *)est); a->priv = (void *) p;return p; }
net/sched/act_police.c +3 -3
@@ -174,12 +174,12 @@ static int tcf_act_police_locate(struct rtattr *rta, struct rtattr *est, override:if (parm->rate.rate) { err = -ENOMEM ; - R_tab =qdisc_get_rtab (&parm->rate, tb[TCA_POLICE_RATE -1 ]); + R_tab =qdisc_get_rtab (&parm->rate, (struct nlattr *)tb[TCA_POLICE_RATE -1 ]);if (R_tab ==NULL ) goto failure;if (parm->peakrate.rate) { P_tab =qdisc_get_rtab (&parm->peakrate, - tb[TCA_POLICE_PEAKRATE -1 ]); + (struct nlattr *)tb[TCA_POLICE_PEAKRATE -1 ]);if (P_tab ==NULL ) {qdisc_put_rtab (R_tab); goto failure;
@@ -216,7 +216,7 @@ override:if (est)gen_replace_estimator (&police->tcf_bstats, &police->tcf_rate_est, - &police->tcf_lock, est); + &police->tcf_lock, (struct nlattr *)est);spin_unlock_bh (&police->tcf_lock);if (ret !=ACT_P_CREATED )
net/sched/sch_api.c +49 -38
263 lines not on this page · raw message
net/sched/sch_atm.c +24 -24
112 lines not on this page · raw message
net/sched/sch_cbq.c +78 -78
332 lines not on this page · raw message
net/sched/sch_dsmark.c +49 -36
165 lines not on this page · raw message
net/sched/sch_fifo.c +5 -5
@@ -43,7 +43,7 @@ static int pfifo_enqueue(struct sk_buff *skb, struct Qdisc* sch)return qdisc_reshape_fail (skb, sch); } -static int fifo_init (struct Qdisc *sch,struct rtattr *opt) +static int fifo_init (struct Qdisc *sch,struct nlattr *opt) {struct fifo_sched_data *q =qdisc_priv (sch);
@@ -55,9 +55,9 @@ static int fifo_init(struct Qdisc *sch, struct rtattr *opt) q->limit = limit; }else { -struct tc_fifo_qopt *ctl =RTA_DATA (opt); +struct tc_fifo_qopt *ctl =nla_data (opt); -if (RTA_PAYLOAD (opt) <sizeof (*ctl)) +if (nla_len (opt) <sizeof (*ctl))return -EINVAL ; q->limit = ctl->limit;
@@ -71,10 +71,10 @@ static int fifo_dump(struct Qdisc *sch, struct sk_buff *skb)struct fifo_sched_data *q =qdisc_priv (sch);struct tc_fifo_qopt opt = { .limit = q->limit }; -RTA_PUT (skb,TCA_OPTIONS ,sizeof (opt), &opt); +NLA_PUT (skb,TCA_OPTIONS ,sizeof (opt), &opt);return skb->len; -rtattr_failure: +nla_put_failure:return -1 ; }
net/sched/sch_generic.c +3 -3
@@ -397,14 +397,14 @@ static int pfifo_fast_dump(struct Qdisc *qdisc, struct sk_buff *skb)struct tc_prio_qopt opt = { .bands =PFIFO_FAST_BANDS };memcpy (&opt.priomap, prio2band,TC_PRIO_MAX +1 ); -RTA_PUT (skb,TCA_OPTIONS ,sizeof (opt), &opt); +NLA_PUT (skb,TCA_OPTIONS ,sizeof (opt), &opt);return skb->len; -rtattr_failure: +nla_put_failure:return -1 ; } -static int pfifo_fast_init (struct Qdisc *qdisc,struct rtattr *opt) +static int pfifo_fast_init (struct Qdisc *qdisc,struct nlattr *opt) {int prio;struct sk_buff_head *list =qdisc_priv (qdisc);
net/sched/sch_gred.c +32 -27
123 lines not on this page · raw message
net/sched/sch_hfsc.c +36 -36
183 lines not on this page · raw message
net/sched/sch_htb.c +34 -34
157 lines not on this page · raw message
net/sched/sch_ingress.c +7 -7
@@ -57,7 +57,7 @@ static void ingress_put(struct Qdisc *sch, unsigned long cl) }static int ingress_change (struct Qdisc *sch,u32 classid,u32 parent, -struct rtattr **tca,unsigned long *arg) +struct nlattr **tca,unsigned long *arg) {return 0 ; }
@@ -156,7 +156,7 @@ static struct nf_hook_ops ing_ops[] __read_mostly = { };#endif -static int ingress_init (struct Qdisc *sch,struct rtattr *opt) +static int ingress_init (struct Qdisc *sch,struct nlattr *opt) {#if !defined(CONFIG_NET_CLS_ACT ) && defined(CONFIG_NETFILTER )printk ("Ingress scheduler: Classifier actions prefered over netfilter\n" );
@@ -184,14 +184,14 @@ static void ingress_destroy(struct Qdisc *sch)static int ingress_dump (struct Qdisc *sch,struct sk_buff *skb) {unsigned char *b =skb_tail_pointer (skb); -struct rtattr *rta; +struct nlattr *nla; - rta = (struct rtattr *)b; -RTA_PUT (skb,TCA_OPTIONS ,0 ,NULL ); - rta->rta_len =skb_tail_pointer (skb) - b; + nla = (struct nlattr *)b; +NLA_PUT (skb,TCA_OPTIONS ,0 ,NULL ); + nla->nla_len =skb_tail_pointer (skb) - b;return skb->len; -rtattr_failure: +nla_put_failure:nlmsg_trim (skb, b);return -1 ; }
net/sched/sch_netem.c +50 -50
237 lines not on this page · raw message
net/sched/sch_prio.c +17 -13
@@ -224,15 +224,15 @@ prio_destroy(struct Qdisc* sch)qdisc_destroy (q->queues[prio]); } -static int prio_tune (struct Qdisc *sch,struct rtattr *opt) +static int prio_tune (struct Qdisc *sch,struct nlattr *opt) {struct prio_sched_data *q =qdisc_priv (sch);struct tc_prio_qopt *qopt; -struct rtattr *tb[TCA_PRIO_MAX ]; +struct nlattr *tb[TCA_PRIO_MAX +1 ];int i; -if (rtattr_parse_nested_compat (tb,TCA_PRIO_MAX , opt, qopt, -sizeof (*qopt))) +if (nla_parse_nested_compat (tb,TCA_PRIO_MAX , opt,NULL , qopt, +sizeof (*qopt)))return -EINVAL ; q->bands = qopt->bands;/* If we're multiqueue, make sure the number of incoming bands
@@ -242,7 +242,7 @@ static int prio_tune(struct Qdisc *sch, struct rtattr *opt)* only one that is enabled for multiqueue, since it's the only one * that interacts with the underlying device. */ - q->mq =RTA_GET_FLAG (tb[TCA_PRIO_MQ -1 ]); + q->mq =nla_get_flag (tb[TCA_PRIO_MQ ]);if (q->mq) {if (sch->parent !=TC_H_ROOT )return -EINVAL ;
@@ -296,7 +296,7 @@ static int prio_tune(struct Qdisc *sch, struct rtattr *opt)return 0 ; } -static int prio_init (struct Qdisc *sch,struct rtattr *opt) +static int prio_init (struct Qdisc *sch,struct nlattr *opt) {struct prio_sched_data *q =qdisc_priv (sch);int i;
@@ -319,20 +319,24 @@ static int prio_dump(struct Qdisc *sch, struct sk_buff *skb) {struct prio_sched_data *q =qdisc_priv (sch);unsigned char *b =skb_tail_pointer (skb); -struct rtattr *nest; +struct nlattr *nest;struct tc_prio_qopt opt; opt.bands = q->bands;memcpy (&opt.priomap, q->prio2band,TC_PRIO_MAX +1 ); - nest =RTA_NEST_COMPAT (skb,TCA_OPTIONS ,sizeof (opt), &opt); -if (q->mq) -RTA_PUT_FLAG (skb,TCA_PRIO_MQ ); -RTA_NEST_COMPAT_END (skb, nest); + nest =nla_nest_compat_start (skb,TCA_OPTIONS ,sizeof (opt), &opt); +if (nest ==NULL ) + goto nla_put_failure; +if (q->mq) { +if (nla_put_flag (skb,TCA_PRIO_MQ ) <0 ) + goto nla_put_failure; + } +nla_nest_compat_end (skb, nest);return skb->len; -rtattr_failure: +nla_put_failure:nlmsg_trim (skb, b);return -1 ; }
@@ -392,7 +396,7 @@ static void prio_put(struct Qdisc *q, unsigned long cl)return ; } -static int prio_change (struct Qdisc *sch,u32 handle,u32 parent,struct rtattr **tca,unsigned long *arg) +static int prio_change (struct Qdisc *sch,u32 handle,u32 parent,struct nlattr **tca,unsigned long *arg) {unsigned long cl = *arg;struct prio_sched_data *q =qdisc_priv (sch);
net/sched/sch_red.c +27 -25
111 lines not on this page · raw message
net/sched/sch_sfq.c +6 -6
@@ -397,13 +397,13 @@ static void sfq_perturbation(unsigned long arg)mod_timer (&q->perturb_timer, jiffies + q->perturb_period); } -static int sfq_change (struct Qdisc *sch,struct rtattr *opt) +static int sfq_change (struct Qdisc *sch,struct nlattr *opt) {struct sfq_sched_data *q =qdisc_priv (sch); -struct tc_sfq_qopt *ctl =RTA_DATA (opt); +struct tc_sfq_qopt *ctl =nla_data (opt);unsigned int qlen; -if (opt->rta_len <RTA_LENGTH (sizeof (*ctl))) +if (opt->nla_len <nla_attr_size (sizeof (*ctl)))return -EINVAL ;sch_tree_lock (sch);
@@ -426,7 +426,7 @@ static int sfq_change(struct Qdisc *sch, struct rtattr *opt)return 0 ; } -static int sfq_init (struct Qdisc *sch,struct rtattr *opt) +static int sfq_init (struct Qdisc *sch,struct nlattr *opt) {struct sfq_sched_data *q =qdisc_priv (sch);int i;
@@ -481,11 +481,11 @@ static int sfq_dump(struct Qdisc *sch, struct sk_buff *skb) opt.divisor =SFQ_HASH_DIVISOR ; opt.flows = q->limit; -RTA_PUT (skb,TCA_OPTIONS ,sizeof (opt), &opt); +NLA_PUT (skb,TCA_OPTIONS ,sizeof (opt), &opt);return skb->len; -rtattr_failure: +nla_put_failure:nlmsg_trim (skb, b);return -1 ; }
net/sched/sch_tbf.c +25 -24
112 lines not on this page · raw message
net/sched/sch_teql.c +1 -1
@@ -168,7 +168,7 @@ teql_destroy(struct Qdisc* sch) } } -static int teql_qdisc_init (struct Qdisc *sch,struct rtattr *opt) +static int teql_qdisc_init (struct Qdisc *sch,struct nlattr *opt) {struct net_device *dev = sch->dev;struct teql_master *m = (struct teql_master *)sch->ops;
PATCH 5/6 : Convert classifiers from rtnetlink to new netlink API
In reply to Patrick McHardy[NET_SCHED]: Convert classifiers from rtnetlink to new netlink API
---
commit 7798bc7f67ba5ffcfc542f5c88762b6db705992e
tree 4a6d67ac7a5f1c667ed025a56264ecb35486118e
parent 07a5a2c72eb790323d3e11bb2e1131f8fd43ae1d
author Patrick McHardy <[email protected]> Tue, 22 Jan 2008 15:49:41 +0100 committer Patrick McHardy <[email protected]> Tue, 22 Jan 2008 15:49:41 +0100
include/net/pkt_cls.h | 10 +++--- include/net/sch_generic.h | 2 + net/sched/cls_api.c | 65 ++++++++++++++++++++------------------ net/sched/cls_basic.c | 40 ++++++++++++----------- net/sched/cls_fw.c | 54 ++++++++++++++++--------------- net/sched/cls_route.c | 70 ++++++++++++++++++++-------------------- net/sched/cls_rsvp.h | 48 ++++++++++++++-------------- net/sched/cls_tcindex.c | 66 +++++++++++++++++++------------------- net/sched/cls_u32.c | 78 +++++++++++++++++++++++---------------------- net/sched/em_meta.c | 56 ++++++++++++++++---------------- net/sched/em_text.c | 9 +++-- net/sched/ematch.c | 74 +++++++++++++++++++++---------------------- 12 files changed, 290 insertions(+), 282 deletions(-)
include/net/pkt_cls.h +5 -5
@@ -129,8 +129,8 @@ tcf_exts_exec(struct sk_buff *skb, struct tcf_exts *exts,return 0 ; } -extern int tcf_exts_validate (struct tcf_proto *tp,struct rtattr **tb, -struct rtattr *rate_tlv,struct tcf_exts *exts, +extern int tcf_exts_validate (struct tcf_proto *tp,struct nlattr **tb, +struct nlattr *rate_tlv,struct tcf_exts *exts,struct tcf_ext_map *map);extern void tcf_exts_destroy (struct tcf_proto *tp,struct tcf_exts *exts); extern void tcf_exts_change(struct tcf_proto *tp, struct tcf_exts *dst,
@@ -247,7 +247,7 @@ struct tcf_ematch_opsextern int tcf_em_register (struct tcf_ematch_ops *);extern int tcf_em_unregister (struct tcf_ematch_ops *); -extern int tcf_em_tree_validate (struct tcf_proto *,struct rtattr *, +extern int tcf_em_tree_validate (struct tcf_proto *,struct nlattr *,struct tcf_ematch_tree *);extern void tcf_em_tree_destroy (struct tcf_proto *,struct tcf_ematch_tree *);extern int tcf_em_tree_dump (struct sk_buff *,struct tcf_ematch_tree *,int );
@@ -338,9 +338,9 @@ static inline int tcf_valid_offset(const struct sk_buff *skb,#include <net/net_namespace.h> static inline int -tcf_change_indev (struct tcf_proto *tp,char *indev,struct rtattr *indev_tlv) +tcf_change_indev (struct tcf_proto *tp,char *indev,struct nlattr *indev_tlv) { -if (rtattr_strlcpy (indev, indev_tlv,IFNAMSIZ ) >=IFNAMSIZ ) +if (nla_strlcpy (indev, indev_tlv,IFNAMSIZ ) >=IFNAMSIZ )return -EINVAL ;return 0 ; }
include/net/sch_generic.h +1 -1
@@ -126,7 +126,7 @@ struct tcf_proto_opsunsigned long (*get)(struct tcf_proto *,u32 handle);void (*put)(struct tcf_proto *,unsigned long );int (*change)(struct tcf_proto *,unsigned long , -u32 handle,struct rtattr **, +u32 handle,struct nlattr **,unsigned long *);int (*delete)(struct tcf_proto *,unsigned long );void (*walk)(struct tcf_proto *,struct tcf_walker *arg);
net/sched/cls_api.c +35 -30
180 lines not on this page · raw message
net/sched/cls_basic.c +20 -20
@@ -130,27 +130,27 @@ static int basic_delete(struct tcf_proto *tp, unsigned long arg) }static inline int basic_set_parms (struct tcf_proto *tp,struct basic_filter *f, -unsigned long base,struct rtattr **tb, -struct rtattr *est) +unsigned long base,struct nlattr **tb, +struct nlattr *est) {int err = -EINVAL ;struct tcf_exts e;struct tcf_ematch_tree t; -if (tb[TCA_BASIC_CLASSID -1 ]) -if (RTA_PAYLOAD (tb[TCA_BASIC_CLASSID -1 ]) <sizeof (u32)) +if (tb[TCA_BASIC_CLASSID ]) +if (nla_len (tb[TCA_BASIC_CLASSID ]) <sizeof (u32))return err; err =tcf_exts_validate (tp, tb, est, &e, &basic_ext_map);if (err <0 )return err; - err =tcf_em_tree_validate (tp, tb[TCA_BASIC_EMATCHES -1 ], &t); + err =tcf_em_tree_validate (tp, tb[TCA_BASIC_EMATCHES ], &t);if (err <0 ) goto errout; -if (tb[TCA_BASIC_CLASSID -1 ]) { - f->res.classid = *(u32 *)RTA_DATA (tb[TCA_BASIC_CLASSID -1 ]); +if (tb[TCA_BASIC_CLASSID ]) { + f->res.classid = *(u32 *)nla_data (tb[TCA_BASIC_CLASSID ]);tcf_bind_filter (tp, &f->res, base); }
@@ -164,23 +164,23 @@ errout: }static int basic_change (struct tcf_proto *tp,unsigned long base,u32 handle, -struct rtattr **tca,unsigned long *arg) +struct nlattr **tca,unsigned long *arg) {int err = -EINVAL ;struct basic_head *head = (struct basic_head *) tp->root; -struct rtattr *tb[TCA_BASIC_MAX ]; +struct nlattr *tb[TCA_BASIC_MAX +1 ];struct basic_filter *f = (struct basic_filter *) *arg; -if (tca[TCA_OPTIONS -1 ] ==NULL ) +if (tca[TCA_OPTIONS ] ==NULL )return -EINVAL ; -if (rtattr_parse_nested (tb,TCA_BASIC_MAX , tca[TCA_OPTIONS -1 ]) <0 ) +if (nla_parse_nested (tb,TCA_BASIC_MAX , tca[TCA_OPTIONS ],NULL ) <0 )return -EINVAL ;if (f !=NULL ) {if (handle && f->handle != handle)return -EINVAL ; -return basic_set_parms (tp, f, base, tb, tca[TCA_RATE -1 ]); +return basic_set_parms (tp, f, base, tb, tca[TCA_RATE ]); } err = -ENOBUFS ;
@@ -206,7 +206,7 @@ static int basic_change(struct tcf_proto *tp, unsigned long base, u32 handle, f->handle = head->hgenerator; } - err =basic_set_parms (tp, f, base, tb, tca[TCA_RATE -1 ]); + err =basic_set_parms (tp, f, base, tb, tca[TCA_RATE ]);if (err <0 ) goto errout;
@@ -246,27 +246,27 @@ static int basic_dump(struct tcf_proto *tp, unsigned long fh, {struct basic_filter *f = (struct basic_filter *) fh;unsigned char *b =skb_tail_pointer (skb); -struct rtattr *rta; +struct nlattr *nla;if (f ==NULL )return skb->len; t->tcm_handle = f->handle; - rta = (struct rtattr *) b; -RTA_PUT (skb,TCA_OPTIONS ,0 ,NULL ); + nla = (struct nlattr *) b; +NLA_PUT (skb,TCA_OPTIONS ,0 ,NULL );if (f->res.classid) -RTA_PUT (skb,TCA_BASIC_CLASSID ,sizeof (u32), &f->res.classid); +NLA_PUT (skb,TCA_BASIC_CLASSID ,sizeof (u32), &f->res.classid);if (tcf_exts_dump (skb, &f->exts, &basic_ext_map) <0 ||tcf_em_tree_dump (skb, &f->ematches,TCA_BASIC_EMATCHES ) <0 ) - goto rtattr_failure; + goto nla_put_failure; - rta->rta_len =skb_tail_pointer (skb) - b; + nla->nla_len =skb_tail_pointer (skb) - b;return skb->len; -rtattr_failure: +nla_put_failure:nlmsg_trim (skb, b);return -1 ; }
net/sched/cls_fw.c +27 -27
129 lines not on this page · raw message
net/sched/cls_route.c +35 -35
172 lines not on this page · raw message
net/sched/cls_rsvp.h +24 -24
122 lines not on this page · raw message
net/sched/cls_tcindex.c +33 -33
141 lines not on this page · raw message
net/sched/cls_u32.c +39 -39
203 lines not on this page · raw message
net/sched/em_meta.c +28 -28
138 lines not on this page · raw message
net/sched/em_text.c +6 -3
@@ -118,11 +118,14 @@ static int em_text_dump(struct sk_buff *skb, struct tcf_ematch *m) conf.pattern_len =textsearch_get_pattern_len (tm->config); conf.pad =0 ; -RTA_PUT_NOHDR (skb,sizeof (conf), &conf); -RTA_APPEND (skb, conf.pattern_len,textsearch_get_pattern (tm->config)); +if (nla_put_nohdr (skb,sizeof (conf), &conf) <0 ) + goto nla_put_failure; +if (nla_append (skb, conf.pattern_len, +textsearch_get_pattern (tm->config)) <0 ) + goto nla_put_failure;return 0 ; -rtattr_failure: +nla_put_failure:return -1 ; }
net/sched/ematch.c +37 -37
172 lines not on this page · raw message
PATCH 6/6 : Convert actions from rtnetlink to new netlink API
In reply to Patrick McHardy[NET_SCHED]: Convert actions from rtnetlink to new netlink API
---
commit 9d8b9cf5c729a718df7861276e6f4c4868a89bd2
tree 64eca29283578c622c492013ec6562bd95f7a7cd
parent 7798bc7f67ba5ffcfc542f5c88762b6db705992e
author Patrick McHardy <[email protected]> Tue, 22 Jan 2008 15:49:42 +0100 committer Patrick McHardy <[email protected]> Tue, 22 Jan 2008 15:49:42 +0100
include/net/act_api.h | 8 +- net/sched/act_api.c | 214 ++++++++++++++++++++++++------------------------ net/sched/act_gact.c | 28 +++--- net/sched/act_ipt.c | 46 +++++----- net/sched/act_mirred.c | 18 ++-- net/sched/act_nat.c | 18 ++-- net/sched/act_pedit.c | 20 ++-- net/sched/act_police.c | 52 ++++++------ net/sched/act_simple.c | 24 +++-- net/sched/cls_api.c | 6 - 10 files changed, 218 insertions(+), 216 deletions(-)
include/net/act_api.h +4 -4
@@ -89,7 +89,7 @@ struct tc_action_ops {int (*dump)(struct sk_buff *,struct tc_action *,int ,int );int (*cleanup)(struct tc_action *,int bind);int (*lookup)(struct tc_action *,u32 ); -int (*init)(struct rtattr *,struct rtattr *,struct tc_action *,int ,int ); +int (*init)(struct nlattr *,struct nlattr *,struct tc_action *,int ,int );int (*walk)(struct sk_buff *,struct netlink_callback *,int ,struct tc_action *); };
@@ -104,7 +104,7 @@ extern u32 tcf_hash_new_index(u32 *idx_gen, struct tcf_hashinfo *hinfo);extern int tcf_hash_search (struct tc_action *a,u32 index);extern struct tcf_common *tcf_hash_check (u32 index,struct tc_action *a,int bind,struct tcf_hashinfo *hinfo); -extern struct tcf_common *tcf_hash_create (u32 index,struct rtattr *est, +extern struct tcf_common *tcf_hash_create (u32 index,struct nlattr *est,struct tc_action *a,int size,int bind,u32 *idx_gen,struct tcf_hashinfo *hinfo);
@@ -114,8 +114,8 @@ extern int tcf_register_action(struct tc_action_ops *a);extern int tcf_unregister_action (struct tc_action_ops *a);extern void tcf_action_destroy (struct tc_action *a,int bind);extern int tcf_action_exec (struct sk_buff *skb,struct tc_action *a,struct tcf_result *res); -extern struct tc_action *tcf_action_init (struct rtattr *rta,struct rtattr *est,char *n,int ovr,int bind,int *err); -extern struct tc_action *tcf_action_init_1 (struct rtattr *rta,struct rtattr *est,char *n,int ovr,int bind,int *err); +extern struct tc_action *tcf_action_init (struct nlattr *nla,struct nlattr *est,char *n,int ovr,int bind,int *err); +extern struct tc_action *tcf_action_init_1 (struct nlattr *nla,struct nlattr *est,char *n,int ovr,int bind,int *err);extern int tcf_action_dump (struct sk_buff *skb,struct tc_action *a,int ,int );extern int tcf_action_dump_old (struct sk_buff *skb,struct tc_action *a,int ,int );extern int tcf_action_dump_1 (struct sk_buff *skb,struct tc_action *a,int ,int );
net/sched/act_api.c +109 -105
556 lines not on this page · raw message
net/sched/act_gact.c +14 -14
@@ -53,26 +53,26 @@ typedef int (*g_rand)(struct tcf_gact *gact);static g_rand gact_rand[MAX_RAND ]= {NULL , gact_net_rand, gact_determ };#endif /* CONFIG_GACT_PROB */ -static int tcf_gact_init (struct rtattr *rta,struct rtattr *est, +static int tcf_gact_init (struct nlattr *nla,struct nlattr *est,struct tc_action *a,int ovr,int bind) { -struct rtattr *tb[TCA_GACT_MAX ]; +struct nlattr *tb[TCA_GACT_MAX +1 ];struct tc_gact *parm;struct tcf_gact *gact;struct tcf_common *pc;int ret =0 ; -if (rta ==NULL ||rtattr_parse_nested (tb,TCA_GACT_MAX , rta) <0 ) +if (nla ==NULL ||nla_parse_nested (tb,TCA_GACT_MAX , nla,NULL ) <0 )return -EINVAL ; -if (tb[TCA_GACT_PARMS -1 ] ==NULL || -RTA_PAYLOAD (tb[TCA_GACT_PARMS -1 ]) <sizeof (*parm)) +if (tb[TCA_GACT_PARMS ] ==NULL || +nla_len (tb[TCA_GACT_PARMS ]) <sizeof (*parm))return -EINVAL ; - parm =RTA_DATA (tb[TCA_GACT_PARMS -1 ]); + parm =nla_data (tb[TCA_GACT_PARMS ]); - if (tb[TCA_GACT_PROB-1] != NULL) + if (tb[TCA_GACT_PROB] != NULL)#ifdef CONFIG_GACT_PROB -if (RTA_PAYLOAD (tb[TCA_GACT_PROB -1 ]) <sizeof (struct tc_gact_p )) +if (nla_len (tb[TCA_GACT_PROB ]) <sizeof (struct tc_gact_p ))return -EINVAL ;#else return -EOPNOTSUPP ;
@@ -97,8 +97,8 @@ static int tcf_gact_init(struct rtattr *rta, struct rtattr *est,spin_lock_bh (&gact->tcf_lock); gact->tcf_action = parm->action;#ifdef CONFIG_GACT_PROB -if (tb[TCA_GACT_PROB -1 ] !=NULL ) { -struct tc_gact_p *p_parm =RTA_DATA (tb[TCA_GACT_PROB -1 ]); +if (tb[TCA_GACT_PROB ] !=NULL ) { +struct tc_gact_p *p_parm =nla_data (tb[TCA_GACT_PROB ]); gact->tcfg_paction = p_parm->paction; gact->tcfg_pval = p_parm->pval; gact->tcfg_ptype = p_parm->ptype;
@@ -154,23 +154,23 @@ static int tcf_gact_dump(struct sk_buff *skb, struct tc_action *a, int bind, int opt.refcnt = gact->tcf_refcnt - ref; opt.bindcnt = gact->tcf_bindcnt - bind; opt.action = gact->tcf_action; -RTA_PUT (skb,TCA_GACT_PARMS ,sizeof (opt), &opt); +NLA_PUT (skb,TCA_GACT_PARMS ,sizeof (opt), &opt);#ifdef CONFIG_GACT_PROB if (gact->tcfg_ptype) {struct tc_gact_p p_opt; p_opt.paction = gact->tcfg_paction; p_opt.pval = gact->tcfg_pval; p_opt.ptype = gact->tcfg_ptype; -RTA_PUT (skb,TCA_GACT_PROB ,sizeof (p_opt), &p_opt); +NLA_PUT (skb,TCA_GACT_PROB ,sizeof (p_opt), &p_opt); }#endif t.install =jiffies_to_clock_t (jiffies - gact->tcf_tm.install); t.lastuse =jiffies_to_clock_t (jiffies - gact->tcf_tm.lastuse); t.expires =jiffies_to_clock_t (gact->tcf_tm.expires); -RTA_PUT (skb,TCA_GACT_TM ,sizeof (t), &t); +NLA_PUT (skb,TCA_GACT_TM ,sizeof (t), &t);return skb->len; -rtattr_failure: +nla_put_failure:nlmsg_trim (skb, b);return -1 ; }
net/sched/act_ipt.c +23 -23
94 lines not on this page · raw message
net/sched/act_mirred.c +9 -9
@@ -54,10 +54,10 @@ static inline int tcf_mirred_release(struct tcf_mirred *m, int bind)return 0 ; } -static int tcf_mirred_init (struct rtattr *rta,struct rtattr *est, +static int tcf_mirred_init (struct nlattr *nla,struct nlattr *est,struct tc_action *a,int ovr,int bind) { -struct rtattr *tb[TCA_MIRRED_MAX ]; +struct nlattr *tb[TCA_MIRRED_MAX +1 ];struct tc_mirred *parm;struct tcf_mirred *m;struct tcf_common *pc;
@@ -65,13 +65,13 @@ static int tcf_mirred_init(struct rtattr *rta, struct rtattr *est,int ret =0 ;int ok_push =0 ; -if (rta ==NULL ||rtattr_parse_nested (tb,TCA_MIRRED_MAX , rta) <0 ) +if (nla ==NULL ||nla_parse_nested (tb,TCA_MIRRED_MAX , nla,NULL ) <0 )return -EINVAL ; -if (tb[TCA_MIRRED_PARMS -1 ] ==NULL || -RTA_PAYLOAD (tb[TCA_MIRRED_PARMS -1 ]) <sizeof (*parm)) +if (tb[TCA_MIRRED_PARMS ] ==NULL || +nla_len (tb[TCA_MIRRED_PARMS ]) <sizeof (*parm))return -EINVAL ; - parm =RTA_DATA (tb[TCA_MIRRED_PARMS -1 ]); + parm =nla_data (tb[TCA_MIRRED_PARMS ]);if (parm->ifindex) { dev =__dev_get_by_index (&init_net, parm->ifindex);
@@ -207,14 +207,14 @@ static int tcf_mirred_dump(struct sk_buff *skb, struct tc_action *a, int bind, i opt.bindcnt = m->tcf_bindcnt - bind; opt.eaction = m->tcfm_eaction; opt.ifindex = m->tcfm_ifindex; -RTA_PUT (skb,TCA_MIRRED_PARMS ,sizeof (opt), &opt); +NLA_PUT (skb,TCA_MIRRED_PARMS ,sizeof (opt), &opt); t.install =jiffies_to_clock_t (jiffies - m->tcf_tm.install); t.lastuse =jiffies_to_clock_t (jiffies - m->tcf_tm.lastuse); t.expires =jiffies_to_clock_t (m->tcf_tm.expires); -RTA_PUT (skb,TCA_MIRRED_TM ,sizeof (t), &t); +NLA_PUT (skb,TCA_MIRRED_TM ,sizeof (t), &t);return skb->len; -rtattr_failure: +nla_put_failure:nlmsg_trim (skb, b);return -1 ; }
net/sched/act_nat.c +9 -9
@@ -40,22 +40,22 @@ static struct tcf_hashinfo nat_hash_info = { .lock = &nat_lock, }; -static int tcf_nat_init (struct rtattr *rta,struct rtattr *est, +static int tcf_nat_init (struct nlattr *nla,struct nlattr *est,struct tc_action *a,int ovr,int bind) { -struct rtattr *tb[TCA_NAT_MAX ]; +struct nlattr *tb[TCA_NAT_MAX +1 ];struct tc_nat *parm;int ret =0 ;struct tcf_nat *p;struct tcf_common *pc; -if (rta ==NULL ||rtattr_parse_nested (tb,TCA_NAT_MAX , rta) <0 ) +if (nla ==NULL ||nla_parse_nested (tb,TCA_NAT_MAX , nla,NULL ) <0 )return -EINVAL ; -if (tb[TCA_NAT_PARMS -1 ] ==NULL || -RTA_PAYLOAD (tb[TCA_NAT_PARMS -1 ]) <sizeof (*parm)) +if (tb[TCA_NAT_PARMS ] ==NULL || +nla_len (tb[TCA_NAT_PARMS ]) <sizeof (*parm))return -EINVAL ; - parm =RTA_DATA (tb[TCA_NAT_PARMS -1 ]); + parm =nla_data (tb[TCA_NAT_PARMS ]); pc =tcf_hash_check (parm->index, a, bind, &nat_hash_info);if (!pc) {
@@ -275,17 +275,17 @@ static int tcf_nat_dump(struct sk_buff *skb, struct tc_action *a, opt->refcnt = p->tcf_refcnt - ref; opt->bindcnt = p->tcf_bindcnt - bind; -RTA_PUT (skb,TCA_NAT_PARMS , s, opt); +NLA_PUT (skb,TCA_NAT_PARMS , s, opt); t.install =jiffies_to_clock_t (jiffies - p->tcf_tm.install); t.lastuse =jiffies_to_clock_t (jiffies - p->tcf_tm.lastuse); t.expires =jiffies_to_clock_t (p->tcf_tm.expires); -RTA_PUT (skb,TCA_NAT_TM ,sizeof (t), &t); +NLA_PUT (skb,TCA_NAT_TM ,sizeof (t), &t);kfree (opt);return skb->len; -rtattr_failure: +nla_put_failure:nlmsg_trim (skb, b);kfree (opt);return -1 ;
net/sched/act_pedit.c +10 -10
@@ -33,10 +33,10 @@ static struct tcf_hashinfo pedit_hash_info = { .lock = &pedit_lock, }; -static int tcf_pedit_init (struct rtattr *rta,struct rtattr *est, +static int tcf_pedit_init (struct nlattr *nla,struct nlattr *est,struct tc_action *a,int ovr,int bind) { -struct rtattr *tb[TCA_PEDIT_MAX ]; +struct nlattr *tb[TCA_PEDIT_MAX +1 ];struct tc_pedit *parm;int ret =0 ;struct tcf_pedit *p;
@@ -44,15 +44,15 @@ static int tcf_pedit_init(struct rtattr *rta, struct rtattr *est,struct tc_pedit_key *keys =NULL ;int ksize; -if (rta ==NULL ||rtattr_parse_nested (tb,TCA_PEDIT_MAX , rta) <0 ) +if (nla ==NULL ||nla_parse_nested (tb,TCA_PEDIT_MAX , nla,NULL ) <0 )return -EINVAL ; -if (tb[TCA_PEDIT_PARMS -1 ] ==NULL || -RTA_PAYLOAD (tb[TCA_PEDIT_PARMS -1 ]) <sizeof (*parm)) +if (tb[TCA_PEDIT_PARMS ] ==NULL || +nla_len (tb[TCA_PEDIT_PARMS ]) <sizeof (*parm))return -EINVAL ; - parm =RTA_DATA (tb[TCA_PEDIT_PARMS -1 ]); + parm =nla_data (tb[TCA_PEDIT_PARMS ]); ksize = parm->nkeys *sizeof (struct tc_pedit_key ); -if (RTA_PAYLOAD (tb[TCA_PEDIT_PARMS -1 ]) <sizeof (*parm) + ksize) +if (nla_len (tb[TCA_PEDIT_PARMS ]) <sizeof (*parm) + ksize)return -EINVAL ; pc =tcf_hash_check (parm->index, a, bind, &pedit_hash_info);
@@ -206,15 +206,15 @@ static int tcf_pedit_dump(struct sk_buff *skb, struct tc_action *a, opt->refcnt = p->tcf_refcnt - ref; opt->bindcnt = p->tcf_bindcnt - bind; -RTA_PUT (skb,TCA_PEDIT_PARMS , s, opt); +NLA_PUT (skb,TCA_PEDIT_PARMS , s, opt); t.install =jiffies_to_clock_t (jiffies - p->tcf_tm.install); t.lastuse =jiffies_to_clock_t (jiffies - p->tcf_tm.lastuse); t.expires =jiffies_to_clock_t (p->tcf_tm.expires); -RTA_PUT (skb,TCA_PEDIT_TM ,sizeof (t), &t); +NLA_PUT (skb,TCA_PEDIT_TM ,sizeof (t), &t);kfree (opt);return skb->len; -rtattr_failure: +nla_put_failure:nlmsg_trim (skb, b);kfree (opt);return -1 ;
net/sched/act_police.c +26 -26
135 lines not on this page · raw message
net/sched/act_simple.c +12 -12
@@ -84,10 +84,10 @@ static int realloc_defdata(struct tcf_defact *d, u32 datalen, void *defdata)return alloc_defdata (d, datalen, defdata); } -static int tcf_simp_init (struct rtattr *rta,struct rtattr *est, +static int tcf_simp_init (struct nlattr *nla,struct nlattr *est,struct tc_action *a,int ovr,int bind) { -struct rtattr *tb[TCA_DEF_MAX ]; +struct nlattr *tb[TCA_DEF_MAX +1 ];struct tc_defact *parm;struct tcf_defact *d;struct tcf_common *pc;
@@ -95,19 +95,19 @@ static int tcf_simp_init(struct rtattr *rta, struct rtattr *est,u32 datalen =0 ;int ret =0 ; -if (rta ==NULL ||rtattr_parse_nested (tb,TCA_DEF_MAX , rta) <0 ) +if (nla ==NULL ||nla_parse_nested (tb,TCA_DEF_MAX , nla,NULL ) <0 )return -EINVAL ; -if (tb[TCA_DEF_PARMS -1 ] ==NULL || -RTA_PAYLOAD (tb[TCA_DEF_PARMS -1 ]) <sizeof (*parm)) +if (tb[TCA_DEF_PARMS ] ==NULL || +nla_len (tb[TCA_DEF_PARMS ]) <sizeof (*parm))return -EINVAL ; - parm =RTA_DATA (tb[TCA_DEF_PARMS -1 ]); - defdata =RTA_DATA (tb[TCA_DEF_DATA -1 ]); + parm =nla_data (tb[TCA_DEF_PARMS ]); + defdata =nla_data (tb[TCA_DEF_DATA ]);if (defdata ==NULL )return -EINVAL ; - datalen =RTA_PAYLOAD (tb[TCA_DEF_DATA -1 ]); + datalen =nla_len (tb[TCA_DEF_DATA ]);if (datalen <=0 )return -EINVAL ;
@@ -164,15 +164,15 @@ static inline int tcf_simp_dump(struct sk_buff *skb, struct tc_action *a, opt.refcnt = d->tcf_refcnt - ref; opt.bindcnt = d->tcf_bindcnt - bind; opt.action = d->tcf_action; -RTA_PUT (skb,TCA_DEF_PARMS ,sizeof (opt), &opt); -RTA_PUT (skb,TCA_DEF_DATA , d->tcfd_datalen, d->tcfd_defdata); +NLA_PUT (skb,TCA_DEF_PARMS ,sizeof (opt), &opt); +NLA_PUT (skb,TCA_DEF_DATA , d->tcfd_datalen, d->tcfd_defdata); t.install =jiffies_to_clock_t (jiffies - d->tcf_tm.install); t.lastuse =jiffies_to_clock_t (jiffies - d->tcf_tm.lastuse); t.expires =jiffies_to_clock_t (d->tcf_tm.expires); -RTA_PUT (skb,TCA_DEF_TM ,sizeof (t), &t); +NLA_PUT (skb,TCA_DEF_TM ,sizeof (t), &t);return skb->len; -rtattr_failure: +nla_put_failure:nlmsg_trim (skb, b);return -1 ; }
net/sched/cls_api.c +2 -4
@@ -491,8 +491,7 @@ int tcf_exts_validate(struct tcf_proto *tp, struct nlattr **tb,struct tc_action *act;if (map->police && tb[map->police]) { - act =tcf_action_init_1 ((struct rtattr *)tb[map->police], - (struct rtattr *)rate_tlv, + act =tcf_action_init_1 (tb[map->police], rate_tlv,"police" ,TCA_ACT_NOREPLACE ,TCA_ACT_BIND , &err);if (act ==NULL )
@@ -501,8 +500,7 @@ int tcf_exts_validate(struct tcf_proto *tp, struct nlattr **tb, act->type =TCA_OLD_COMPAT ; exts->action = act; }else if (map->action && tb[map->action]) { - act =tcf_action_init ((struct rtattr *)tb[map->action], - (struct rtattr *)rate_tlv,NULL , + act =tcf_action_init (tb[map->action], rate_tlv,NULL ,TCA_ACT_NOREPLACE ,TCA_ACT_BIND , &err);if (act ==NULL )return err;
David Miller
maintainerFrom: Patrick McHardy <[email protected]>
Date: Tue, 22 Jan 2008 15:56:08 +0100 (MET)
Quoted 10 lines
These patches convert the packet schedulers to the new netlink API. This will allow to use the new features like automatic attribute checking and gets rid of the largest
rtnetlink.huser we still have. Unfortunately a gradual conversion is not really feasible, so the patches are quite large, but most of them has been generated automatically, so I'm pretty sure they are correct and didn't miss anything. Also included are some minor unrelated cleanups I had queued in the same tree.Please apply, thanks.
Looks good applied, thanks Patrick!