[NET_SCHED]: act_api: use PTR_ERR in tcf_action_init/tcf_action_get
[h-e-n] / net / sched / sch_ingress.c
index cb8ba8b..f6decbb 100644 (file)
 
 
 /* Thanks to Doron Oz for this hack */
-#ifndef CONFIG_NET_CLS_ACT
-#ifdef CONFIG_NETFILTER
+#if !defined(CONFIG_NET_CLS_ACT) && defined(CONFIG_NETFILTER)
 static int nf_registered;
 #endif
-#endif
 
 struct ingress_qdisc_data {
-       struct Qdisc            *q;
        struct tcf_proto        *filter_list;
 };
 
@@ -36,7 +33,7 @@ struct ingress_qdisc_data {
 static int ingress_graft(struct Qdisc *sch, unsigned long arg,
                         struct Qdisc *new, struct Qdisc **old)
 {
-       return 1;
+       return -EOPNOTSUPP;
 }
 
 static struct Qdisc *ingress_leaf(struct Qdisc *sch, unsigned long arg)
@@ -60,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;
 }
@@ -119,23 +116,7 @@ static int ingress_enqueue(struct sk_buff *skb, struct Qdisc *sch)
        return result;
 }
 
-static struct sk_buff *ingress_dequeue(struct Qdisc *sch)
-{
-       return NULL;
-}
-
-static int ingress_requeue(struct sk_buff *skb, struct Qdisc *sch)
-{
-       return 0;
-}
-
-static unsigned int ingress_drop(struct Qdisc *sch)
-{
-       return 0;
-}
-
-#ifndef CONFIG_NET_CLS_ACT
-#ifdef CONFIG_NETFILTER
+#if !defined(CONFIG_NET_CLS_ACT) && defined(CONFIG_NETFILTER)
 static unsigned int ing_hook(unsigned int hook, struct sk_buff *skb,
                             const struct net_device *indev,
                             const struct net_device *outdev,
@@ -174,25 +155,12 @@ static struct nf_hook_ops ing_ops[] __read_mostly = {
        },
 };
 #endif
-#endif
 
-static int ingress_init(struct Qdisc *sch, struct rtattr *opt)
+static int ingress_init(struct Qdisc *sch, struct nlattr *opt)
 {
-       struct ingress_qdisc_data *p = qdisc_priv(sch);
-
-       /* Make sure either netfilter or preferably CLS_ACT is
-        * compiled in */
-#ifndef CONFIG_NET_CLS_ACT
-#ifndef CONFIG_NETFILTER
-       printk("You MUST compile classifier actions into the kernel\n");
-       return -EINVAL;
-#else
+#if !defined(CONFIG_NET_CLS_ACT) && defined(CONFIG_NETFILTER)
        printk("Ingress scheduler: Classifier actions prefered over netfilter\n");
-#endif
-#endif
 
-#ifndef CONFIG_NET_CLS_ACT
-#ifdef CONFIG_NETFILTER
        if (!nf_registered) {
                if (nf_register_hooks(ing_ops, ARRAY_SIZE(ing_ops)) < 0) {
                        printk("ingress qdisc registration error \n");
@@ -201,16 +169,9 @@ static int ingress_init(struct Qdisc *sch, struct rtattr *opt)
                nf_registered++;
        }
 #endif
-#endif
-       p->q = &noop_qdisc;
        return 0;
 }
 
-static void ingress_reset(struct Qdisc *sch)
-{
-       return;
-}
-
 /* ------------------------------------------------------------- */
 
 static void ingress_destroy(struct Qdisc *sch)
@@ -223,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;
 }
@@ -252,11 +213,7 @@ static struct Qdisc_ops ingress_qdisc_ops __read_mostly = {
        .id             =       "ingress",
        .priv_size      =       sizeof(struct ingress_qdisc_data),
        .enqueue        =       ingress_enqueue,
-       .dequeue        =       ingress_dequeue,
-       .requeue        =       ingress_requeue,
-       .drop           =       ingress_drop,
        .init           =       ingress_init,
-       .reset          =       ingress_reset,
        .destroy        =       ingress_destroy,
        .dump           =       ingress_dump,
        .owner          =       THIS_MODULE,
@@ -264,25 +221,16 @@ static struct Qdisc_ops ingress_qdisc_ops __read_mostly = {
 
 static int __init ingress_module_init(void)
 {
-       int ret = 0;
-
-       if ((ret = register_qdisc(&ingress_qdisc_ops)) < 0) {
-               printk("Unable to register Ingress qdisc\n");
-               return ret;
-       }
-
-       return ret;
+       return register_qdisc(&ingress_qdisc_ops);
 }
 
 static void __exit ingress_module_exit(void)
 {
        unregister_qdisc(&ingress_qdisc_ops);
-#ifndef CONFIG_NET_CLS_ACT
-#ifdef CONFIG_NETFILTER
+#if !defined(CONFIG_NET_CLS_ACT) && defined(CONFIG_NETFILTER)
        if (nf_registered)
                nf_unregister_hooks(ing_ops, ARRAY_SIZE(ing_ops));
 #endif
-#endif
 }
 
 module_init(ingress_module_init)