]> err.no Git - linux-2.6/blobdiff - net/sched/act_api.c
[NET_SCHED]: kill obsolete NET_CLS_POLICE option
[linux-2.6] / net / sched / act_api.c
index 711dd26c95c325a42937ba083f970c5d8b77b197..81506474a4f769bde9cb0e5349d2977962923cce 100644 (file)
  *
  */
 
-#include <asm/uaccess.h>
-#include <asm/system.h>
-#include <linux/bitops.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
-#include <linux/mm.h>
-#include <linux/socket.h>
-#include <linux/sockios.h>
-#include <linux/in.h>
 #include <linux/errno.h>
-#include <linux/interrupt.h>
-#include <linux/netdevice.h>
 #include <linux/skbuff.h>
 #include <linux/init.h>
 #include <linux/kmod.h>
+#include <net/net_namespace.h>
 #include <net/sock.h>
 #include <net/sch_generic.h>
 #include <net/act_api.h>
@@ -42,10 +34,8 @@ void tcf_hash_destroy(struct tcf_common *p, struct tcf_hashinfo *hinfo)
                        write_lock_bh(hinfo->lock);
                        *p1p = p->tcfc_next;
                        write_unlock_bh(hinfo->lock);
-#ifdef CONFIG_NET_ESTIMATOR
                        gen_kill_estimator(&p->tcfc_bstats,
                                           &p->tcfc_rate_est);
-#endif
                        kfree(p);
                        return;
                }
@@ -80,7 +70,7 @@ static int tcf_dump_walker(struct sk_buff *skb, struct netlink_callback *cb,
        int err = 0, index = -1,i = 0, s_i = 0, n_i = 0;
        struct rtattr *r ;
 
-       read_lock(hinfo->lock);
+       read_lock_bh(hinfo->lock);
 
        s_i = cb->args[0];
 
@@ -108,7 +98,7 @@ static int tcf_dump_walker(struct sk_buff *skb, struct netlink_callback *cb,
                }
        }
 done:
-       read_unlock(hinfo->lock);
+       read_unlock_bh(hinfo->lock);
        if (n_i)
                cb->args[0] += n_i;
        return n_i;
@@ -168,13 +158,13 @@ struct tcf_common *tcf_hash_lookup(u32 index, struct tcf_hashinfo *hinfo)
 {
        struct tcf_common *p;
 
-       read_lock(hinfo->lock);
+       read_lock_bh(hinfo->lock);
        for (p = hinfo->htab[tcf_hash(index, hinfo->hmask)]; p;
             p = p->tcfc_next) {
                if (p->tcfc_index == index)
                        break;
        }
-       read_unlock(hinfo->lock);
+       read_unlock_bh(hinfo->lock);
 
        return p;
 }
@@ -232,15 +222,12 @@ struct tcf_common *tcf_hash_create(u32 index, struct rtattr *est, struct tc_acti
                p->tcfc_bindcnt = 1;
 
        spin_lock_init(&p->tcfc_lock);
-       p->tcfc_stats_lock = &p->tcfc_lock;
        p->tcfc_index = index ? index : tcf_hash_new_index(idx_gen, hinfo);
        p->tcfc_tm.install = jiffies;
        p->tcfc_tm.lastuse = jiffies;
-#ifdef CONFIG_NET_ESTIMATOR
        if (est)
                gen_new_estimator(&p->tcfc_bstats, &p->tcfc_rate_est,
-                                 p->tcfc_stats_lock, est);
-#endif
+                                 &p->tcfc_lock, est);
        a->priv = (void *) p;
        return p;
 }
@@ -599,12 +586,12 @@ int tcf_action_copy_stats(struct sk_buff *skb, struct tc_action *a,
        if (compat_mode) {
                if (a->type == TCA_OLD_COMPAT)
                        err = gnet_stats_start_copy_compat(skb, 0,
-                               TCA_STATS, TCA_XSTATS, h->tcf_stats_lock, &d);
+                               TCA_STATS, TCA_XSTATS, &h->tcf_lock, &d);
                else
                        return 0;
        } else
                err = gnet_stats_start_copy(skb, TCA_ACT_STATS,
-                       h->tcf_stats_lock, &d);
+                                           &h->tcf_lock, &d);
 
        if (err < 0)
                goto errout;
@@ -614,9 +601,7 @@ int tcf_action_copy_stats(struct sk_buff *skb, struct tc_action *a,
                        goto errout;
 
        if (gnet_stats_copy_basic(&d, &h->tcf_bstats) < 0 ||
-#ifdef CONFIG_NET_ESTIMATOR
            gnet_stats_copy_rate_est(&d, &h->tcf_rate_est) < 0 ||
-#endif
            gnet_stats_copy_queue(&d, &h->tcf_qstats) < 0)
                goto errout;
 
@@ -675,7 +660,7 @@ act_get_notify(u32 pid, struct nlmsghdr *n, struct tc_action *a, int event)
                return -EINVAL;
        }
 
-       return rtnl_unicast(skb, pid);
+       return rtnl_unicast(skb, &init_net, pid);
 }
 
 static struct tc_action *
@@ -796,7 +781,7 @@ static int tca_action_flush(struct rtattr *rta, struct nlmsghdr *n, u32 pid)
        nlh->nlmsg_flags |= NLM_F_ROOT;
        module_put(a->ops->owner);
        kfree(a);
-       err = rtnetlink_send(skb, pid, RTNLGRP_TC, n->nlmsg_flags&NLM_F_ECHO);
+       err = rtnetlink_send(skb, &init_net, pid, RTNLGRP_TC, n->nlmsg_flags&NLM_F_ECHO);
        if (err > 0)
                return 0;
 
@@ -859,7 +844,7 @@ tca_action_gd(struct rtattr *rta, struct nlmsghdr *n, u32 pid, int event)
 
                /* now do the delete */
                tcf_action_destroy(head, 0);
-               ret = rtnetlink_send(skb, pid, RTNLGRP_TC,
+               ret = rtnetlink_send(skb, &init_net, pid, RTNLGRP_TC,
                                     n->nlmsg_flags&NLM_F_ECHO);
                if (ret > 0)
                        return 0;
@@ -903,7 +888,7 @@ static int tcf_add_notify(struct tc_action *a, u32 pid, u32 seq, int event,
        nlh->nlmsg_len = skb_tail_pointer(skb) - b;
        NETLINK_CB(skb).dst_group = RTNLGRP_TC;
 
-       err = rtnetlink_send(skb, pid, RTNLGRP_TC, flags&NLM_F_ECHO);
+       err = rtnetlink_send(skb, &init_net, pid, RTNLGRP_TC, flags&NLM_F_ECHO);
        if (err > 0)
                err = 0;
        return err;
@@ -941,10 +926,14 @@ done:
 
 static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
 {
+       struct net *net = skb->sk->sk_net;
        struct rtattr **tca = arg;
        u32 pid = skb ? NETLINK_CB(skb).pid : 0;
        int ret = 0, ovr = 0;
 
+       if (net != &init_net)
+               return -EINVAL;
+
        if (tca[TCA_ACT_TAB-1] == NULL) {
                printk("tc_ctl_action: received NO action attribs\n");
                return -EINVAL;
@@ -1014,6 +1003,7 @@ find_dump_kind(struct nlmsghdr *n)
 static int
 tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
 {
+       struct net *net = skb->sk->sk_net;
        struct nlmsghdr *nlh;
        unsigned char *b = skb_tail_pointer(skb);
        struct rtattr *x;
@@ -1023,6 +1013,9 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
        struct tcamsg *t = (struct tcamsg *) NLMSG_DATA(cb->nlh);
        struct rtattr *kind = find_dump_kind(cb->nlh);
 
+       if (net != &init_net)
+               return 0;
+
        if (kind == NULL) {
                printk("tc_dump_action: action bad kind\n");
                return 0;