Skip to content

Commit

Permalink
[NET_SCHED]: Convert packet schedulers from rtnetlink to new netlink API
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Patrick McHardy <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
kaber authored and davem330 committed Jan 28, 2008
1 parent 01480e1 commit 1e90474
Show file tree
Hide file tree
Showing 25 changed files with 474 additions and 436 deletions.
6 changes: 3 additions & 3 deletions include/net/gen_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion include/net/pkt_sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions include/net/sch_generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct Qdisc_class_ops
unsigned 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);

Expand Down Expand Up @@ -95,10 +95,10 @@ struct Qdisc_ops
int (*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 *);
Expand Down
8 changes: 4 additions & 4 deletions net/core/gen_estimator.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,13 @@ static void est_timer(unsigned long arg)
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)
Expand Down Expand Up @@ -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);
Expand Down
9 changes: 5 additions & 4 deletions net/core/gen_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
14 changes: 7 additions & 7 deletions net/mac80211/wme.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,16 +297,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));
*/
Expand All @@ -315,7 +315,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;
Expand Down Expand Up @@ -370,10 +370,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;
}
Expand Down Expand Up @@ -444,7 +444,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);
Expand Down
7 changes: 4 additions & 3 deletions net/netfilter/xt_RATEEST.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion net/sched/act_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions net/sched/act_police.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -216,7 +216,7 @@ static int tcf_act_police_locate(struct rtattr *rta, struct rtattr *est,
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)
Expand Down
Loading

0 comments on commit 1e90474

Please sign in to comment.