]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/sched/sch_api.c
mac80211: A-MPDU Rx add low level driver API
[linux-2.6-omap-h63xx.git] / net / sched / sch_api.c
index dee0d5fb39c555a5f1f60eaaf4f4dd3df9ae666d..273c628be0540350554f39068489e145eab1b85c 100644 (file)
@@ -28,6 +28,8 @@
 #include <linux/list.h>
 #include <linux/hrtimer.h>
 
+#include <net/net_namespace.h>
+#include <net/sock.h>
 #include <net/netlink.h>
 #include <net/pkt_sched.h>
 
@@ -194,7 +196,7 @@ static struct Qdisc *qdisc_leaf(struct Qdisc *p, u32 classid)
 {
        unsigned long cl;
        struct Qdisc *leaf;
-       struct Qdisc_class_ops *cops = p->ops->cl_ops;
+       const struct Qdisc_class_ops *cops = p->ops->cl_ops;
 
        if (cops == NULL)
                return NULL;
@@ -372,7 +374,7 @@ dev_graft_qdisc(struct net_device *dev, struct Qdisc *qdisc)
 
 void qdisc_tree_decrease_qlen(struct Qdisc *sch, unsigned int n)
 {
-       struct Qdisc_class_ops *cops;
+       const struct Qdisc_class_ops *cops;
        unsigned long cl;
        u32 parentid;
 
@@ -416,7 +418,7 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent,
                        *old = dev_graft_qdisc(dev, new);
                }
        } else {
-               struct Qdisc_class_ops *cops = parent->ops->cl_ops;
+               const struct Qdisc_class_ops *cops = parent->ops->cl_ops;
 
                err = -EINVAL;
 
@@ -580,7 +582,7 @@ static int
 check_loop_fn(struct Qdisc *q, unsigned long cl, struct qdisc_walker *w)
 {
        struct Qdisc *leaf;
-       struct Qdisc_class_ops *cops = q->ops->cl_ops;
+       const struct Qdisc_class_ops *cops = q->ops->cl_ops;
        struct check_loop_arg *arg = (struct check_loop_arg *)w;
 
        leaf = cops->leaf(q, cl);
@@ -598,6 +600,7 @@ check_loop_fn(struct Qdisc *q, unsigned long cl, struct qdisc_walker *w)
 
 static int tc_get_qdisc(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
 {
+       struct net *net = skb->sk->sk_net;
        struct tcmsg *tcm = NLMSG_DATA(n);
        struct rtattr **tca = arg;
        struct net_device *dev;
@@ -606,7 +609,10 @@ static int tc_get_qdisc(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
        struct Qdisc *p = NULL;
        int err;
 
-       if ((dev = __dev_get_by_index(tcm->tcm_ifindex)) == NULL)
+       if (net != &init_net)
+               return -EINVAL;
+
+       if ((dev = __dev_get_by_index(&init_net, tcm->tcm_ifindex)) == NULL)
                return -ENODEV;
 
        if (clid) {
@@ -659,6 +665,7 @@ static int tc_get_qdisc(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
 
 static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
 {
+       struct net *net = skb->sk->sk_net;
        struct tcmsg *tcm;
        struct rtattr **tca;
        struct net_device *dev;
@@ -666,6 +673,9 @@ static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
        struct Qdisc *q, *p;
        int err;
 
+       if (net != &init_net)
+               return -EINVAL;
+
 replay:
        /* Reinit, just in case something touches this. */
        tcm = NLMSG_DATA(n);
@@ -673,7 +683,7 @@ replay:
        clid = tcm->tcm_parent;
        q = p = NULL;
 
-       if ((dev = __dev_get_by_index(tcm->tcm_ifindex)) == NULL)
+       if ((dev = __dev_get_by_index(&init_net, tcm->tcm_ifindex)) == NULL)
                return -ENODEV;
 
        if (clid) {
@@ -862,7 +872,7 @@ static int qdisc_notify(struct sk_buff *oskb, struct nlmsghdr *n,
        }
 
        if (skb->len)
-               return rtnetlink_send(skb, pid, RTNLGRP_TC, n->nlmsg_flags&NLM_F_ECHO);
+               return rtnetlink_send(skb, &init_net, pid, RTNLGRP_TC, n->nlmsg_flags&NLM_F_ECHO);
 
 err_out:
        kfree_skb(skb);
@@ -871,16 +881,20 @@ err_out:
 
 static int tc_dump_qdisc(struct sk_buff *skb, struct netlink_callback *cb)
 {
+       struct net *net = skb->sk->sk_net;
        int idx, q_idx;
        int s_idx, s_q_idx;
        struct net_device *dev;
        struct Qdisc *q;
 
+       if (net != &init_net)
+               return 0;
+
        s_idx = cb->args[0];
        s_q_idx = q_idx = cb->args[1];
        read_lock(&dev_base_lock);
        idx = 0;
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                if (idx < s_idx)
                        goto cont;
                if (idx > s_idx)
@@ -919,11 +933,12 @@ done:
 
 static int tc_ctl_tclass(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
 {
+       struct net *net = skb->sk->sk_net;
        struct tcmsg *tcm = NLMSG_DATA(n);
        struct rtattr **tca = arg;
        struct net_device *dev;
        struct Qdisc *q = NULL;
-       struct Qdisc_class_ops *cops;
+       const struct Qdisc_class_ops *cops;
        unsigned long cl = 0;
        unsigned long new_cl;
        u32 pid = tcm->tcm_parent;
@@ -931,7 +946,10 @@ static int tc_ctl_tclass(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
        u32 qid = TC_H_MAJ(clid);
        int err;
 
-       if ((dev = __dev_get_by_index(tcm->tcm_ifindex)) == NULL)
+       if (net != &init_net)
+               return -EINVAL;
+
+       if ((dev = __dev_get_by_index(&init_net, tcm->tcm_ifindex)) == NULL)
                return -ENODEV;
 
        /*
@@ -1038,7 +1056,7 @@ static int tc_fill_tclass(struct sk_buff *skb, struct Qdisc *q,
        struct nlmsghdr  *nlh;
        unsigned char *b = skb_tail_pointer(skb);
        struct gnet_dump d;
-       struct Qdisc_class_ops *cl_ops = q->ops->cl_ops;
+       const struct Qdisc_class_ops *cl_ops = q->ops->cl_ops;
 
        nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*tcm), flags);
        tcm = NLMSG_DATA(nlh);
@@ -1085,7 +1103,7 @@ static int tclass_notify(struct sk_buff *oskb, struct nlmsghdr *n,
                return -EINVAL;
        }
 
-       return rtnetlink_send(skb, pid, RTNLGRP_TC, n->nlmsg_flags&NLM_F_ECHO);
+       return rtnetlink_send(skb, &init_net, pid, RTNLGRP_TC, n->nlmsg_flags&NLM_F_ECHO);
 }
 
 struct qdisc_dump_args
@@ -1105,6 +1123,7 @@ static int qdisc_class_dump(struct Qdisc *q, unsigned long cl, struct qdisc_walk
 
 static int tc_dump_tclass(struct sk_buff *skb, struct netlink_callback *cb)
 {
+       struct net *net = skb->sk->sk_net;
        int t;
        int s_t;
        struct net_device *dev;
@@ -1112,9 +1131,12 @@ static int tc_dump_tclass(struct sk_buff *skb, struct netlink_callback *cb)
        struct tcmsg *tcm = (struct tcmsg*)NLMSG_DATA(cb->nlh);
        struct qdisc_dump_args arg;
 
+       if (net != &init_net)
+               return 0;
+
        if (cb->nlh->nlmsg_len < NLMSG_LENGTH(sizeof(*tcm)))
                return 0;
-       if ((dev = dev_get_by_index(tcm->tcm_ifindex)) == NULL)
+       if ((dev = dev_get_by_index(&init_net, tcm->tcm_ifindex)) == NULL)
                return 0;
 
        s_t = cb->args[0];
@@ -1225,10 +1247,13 @@ EXPORT_SYMBOL(tcf_destroy_chain);
 #ifdef CONFIG_PROC_FS
 static int psched_show(struct seq_file *seq, void *v)
 {
+       struct timespec ts;
+
+       hrtimer_get_res(CLOCK_MONOTONIC, &ts);
        seq_printf(seq, "%08x %08x %08x %08x\n",
                   (u32)NSEC_PER_USEC, (u32)PSCHED_US2NS(1),
                   1000000,
-                  (u32)NSEC_PER_SEC/(u32)ktime_to_ns(KTIME_MONOTONIC_RES));
+                  (u32)NSEC_PER_SEC/(u32)ktime_to_ns(timespec_to_ktime(ts)));
 
        return 0;
 }
@@ -1251,7 +1276,7 @@ static int __init pktsched_init(void)
 {
        register_qdisc(&pfifo_qdisc_ops);
        register_qdisc(&bfifo_qdisc_ops);
-       proc_net_fops_create("psched", 0, &psched_fops);
+       proc_net_fops_create(&init_net, "psched", 0, &psched_fops);
 
        rtnl_register(PF_UNSPEC, RTM_NEWQDISC, tc_modify_qdisc, NULL);
        rtnl_register(PF_UNSPEC, RTM_DELQDISC, tc_get_qdisc, NULL);