[IPSEC]: Added xfrm_decode_session_reverse and xfrmX_policy_check_reverse
[safe/jmp/linux-2.6] / net / sched / cls_api.c
index ebf94ed..80dccac 100644 (file)
  *
  */
 
-#include <asm/uaccess.h>
-#include <asm/system.h>
-#include <linux/bitops.h>
 #include <linux/module.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 <linux/netlink.h>
-#include <net/netlink.h>
+#include <net/net_namespace.h>
 #include <net/sock.h>
+#include <net/netlink.h>
 #include <net/pkt_sched.h>
 #include <net/pkt_cls.h>
 
@@ -129,6 +121,7 @@ static __inline__ u32 tcf_auto_prio(struct tcf_proto *tp)
 
 static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
 {
+       struct net *net = skb->sk->sk_net;
        struct rtattr **tca;
        struct tcmsg *t;
        u32 protocol;
@@ -140,11 +133,14 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
        struct tcf_proto **back, **chain;
        struct tcf_proto *tp;
        struct tcf_proto_ops *tp_ops;
-       struct Qdisc_class_ops *cops;
+       const struct Qdisc_class_ops *cops;
        unsigned long cl;
        unsigned long fh;
        int err;
 
+       if (net != &init_net)
+               return -EINVAL;
+
 replay:
        tca = arg;
        t = NLMSG_DATA(n);
@@ -164,7 +160,7 @@ replay:
        /* Find head of filter chain. */
 
        /* Find link */
-       if ((dev = __dev_get_by_index(t->tcm_ifindex)) == NULL)
+       if ((dev = __dev_get_by_index(&init_net, t->tcm_ifindex)) == NULL)
                return -ENODEV;
 
        /* Find qdisc */
@@ -365,7 +361,7 @@ static int tfilter_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 tcf_dump_args
@@ -385,6 +381,7 @@ static int tcf_node_dump(struct tcf_proto *tp, unsigned long n, struct tcf_walke
 
 static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb)
 {
+       struct net *net = skb->sk->sk_net;
        int t;
        int s_t;
        struct net_device *dev;
@@ -392,12 +389,15 @@ static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb)
        struct tcf_proto *tp, **chain;
        struct tcmsg *tcm = (struct tcmsg*)NLMSG_DATA(cb->nlh);
        unsigned long cl = 0;
-       struct Qdisc_class_ops *cops;
+       const struct Qdisc_class_ops *cops;
        struct tcf_dump_args arg;
 
+       if (net != &init_net)
+               return 0;
+
        if (cb->nlh->nlmsg_len < NLMSG_LENGTH(sizeof(*tcm)))
                return skb->len;
-       if ((dev = dev_get_by_index(tcm->tcm_ifindex)) == NULL)
+       if ((dev = dev_get_by_index(&init_net, tcm->tcm_ifindex)) == NULL)
                return skb->len;
 
        if (!tcm->tcm_parent)
@@ -468,11 +468,6 @@ tcf_exts_destroy(struct tcf_proto *tp, struct tcf_exts *exts)
                tcf_action_destroy(exts->action, TCA_ACT_UNBIND);
                exts->action = NULL;
        }
-#elif defined CONFIG_NET_CLS_POLICE
-       if (exts->police) {
-               tcf_police_release(exts->police, TCA_ACT_UNBIND);
-               exts->police = NULL;
-       }
 #endif
 }
 
@@ -506,17 +501,6 @@ tcf_exts_validate(struct tcf_proto *tp, struct rtattr **tb,
                        exts->action = act;
                }
        }
-#elif defined CONFIG_NET_CLS_POLICE
-       if (map->police && tb[map->police-1]) {
-               struct tcf_police *p;
-
-               p = tcf_police_locate(tb[map->police-1], rate_tlv);
-               if (p == NULL)
-                       return -EINVAL;
-
-               exts->police = p;
-       } else if (map->action && tb[map->action-1])
-               return -EOPNOTSUPP;
 #else
        if ((map->action && tb[map->action-1]) ||
            (map->police && tb[map->police-1]))
@@ -539,15 +523,6 @@ tcf_exts_change(struct tcf_proto *tp, struct tcf_exts *dst,
                if (act)
                        tcf_action_destroy(act, TCA_ACT_UNBIND);
        }
-#elif defined CONFIG_NET_CLS_POLICE
-       if (src->police) {
-               struct tcf_police *p;
-               tcf_tree_lock(tp);
-               p = xchg(&dst->police, src->police);
-               tcf_tree_unlock(tp);
-               if (p)
-                       tcf_police_release(p, TCA_ACT_UNBIND);
-       }
 #endif
 }
 
@@ -576,17 +551,6 @@ tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts,
                        p_rta->rta_len = skb_tail_pointer(skb) - (u8 *)p_rta;
                }
        }
-#elif defined CONFIG_NET_CLS_POLICE
-       if (map->police && exts->police) {
-               struct rtattr *p_rta = (struct rtattr *)skb_tail_pointer(skb);
-
-               RTA_PUT(skb, map->police, 0, NULL);
-
-               if (tcf_police_dump(skb, exts->police) < 0)
-                       goto rtattr_failure;
-
-               p_rta->rta_len = skb_tail_pointer(skb) - (u8 *)p_rta;
-       }
 #endif
        return 0;
 rtattr_failure: __attribute__ ((unused))
@@ -601,10 +565,6 @@ tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts,
        if (exts->action)
                if (tcf_action_copy_stats(skb, exts->action, 1) < 0)
                        goto rtattr_failure;
-#elif defined CONFIG_NET_CLS_POLICE
-       if (exts->police)
-               if (tcf_police_dump_stats(skb, exts->police) < 0)
-                       goto rtattr_failure;
 #endif
        return 0;
 rtattr_failure: __attribute__ ((unused))