[NET_SCHED]: Convert packet schedulers from rtnetlink to new netlink API
[safe/jmp/linux-2.6] / net / sched / cls_route.c
index 02996ac..e70edd0 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/config.h>
-#include <asm/uaccess.h>
-#include <asm/system.h>
-#include <linux/bitops.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
-#include <linux/sched.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/if_ether.h>
-#include <linux/inet.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/notifier.h>
-#include <net/ip.h>
-#include <net/route.h>
 #include <linux/skbuff.h>
-#include <net/sock.h>
+#include <net/dst.h>
+#include <net/route.h>
+#include <net/netlink.h>
 #include <net/act_api.h>
 #include <net/pkt_cls.h>
 
@@ -90,12 +75,12 @@ static __inline__ int route4_fastmap_hash(u32 id, int iif)
 static inline
 void route4_reset_fastmap(struct net_device *dev, struct route4_head *head, u32 id)
 {
-       spin_lock_bh(&dev->queue_lock);
+       qdisc_lock_tree(dev);
        memset(head->fastmap, 0, sizeof(head->fastmap));
-       spin_unlock_bh(&dev->queue_lock);
+       qdisc_unlock_tree(dev);
 }
 
-static void __inline__
+static inline void
 route4_set_fastmap(struct route4_head *head, u32 id, int iif,
                   struct route4_filter *f)
 {
@@ -397,10 +382,9 @@ static int route4_set_parms(struct tcf_proto *tp, unsigned long base,
        h1 = to_hash(nhandle);
        if ((b = head->table[h1]) == NULL) {
                err = -ENOBUFS;
-               b = kmalloc(sizeof(struct route4_bucket), GFP_KERNEL);
+               b = kzalloc(sizeof(struct route4_bucket), GFP_KERNEL);
                if (b == NULL)
                        goto errout;
-               memset(b, 0, sizeof(*b));
 
                tcf_tree_lock(tp);
                head->table[h1] = b;
@@ -476,20 +460,18 @@ static int route4_change(struct tcf_proto *tp, unsigned long base,
 
        err = -ENOBUFS;
        if (head == NULL) {
-               head = kmalloc(sizeof(struct route4_head), GFP_KERNEL);
+               head = kzalloc(sizeof(struct route4_head), GFP_KERNEL);
                if (head == NULL)
                        goto errout;
-               memset(head, 0, sizeof(struct route4_head));
 
                tcf_tree_lock(tp);
                tp->root = head;
                tcf_tree_unlock(tp);
        }
 
-       f = kmalloc(sizeof(struct route4_filter), GFP_KERNEL);
+       f = kzalloc(sizeof(struct route4_filter), GFP_KERNEL);
        if (f == NULL)
                goto errout;
-       memset(f, 0, sizeof(*f));
 
        err = route4_set_parms(tp, base, f, handle, head, tb,
                tca[TCA_RATE-1], 1);
@@ -525,8 +507,7 @@ reinsert:
        return 0;
 
 errout:
-       if (f)
-               kfree(f);
+       kfree(f);
        return err;
 }
 
@@ -568,7 +549,7 @@ static int route4_dump(struct tcf_proto *tp, unsigned long fh,
                       struct sk_buff *skb, struct tcmsg *t)
 {
        struct route4_filter *f = (struct route4_filter*)fh;
-       unsigned char    *b = skb->tail;
+       unsigned char *b = skb_tail_pointer(skb);
        struct rtattr *rta;
        u32 id;
 
@@ -597,7 +578,7 @@ static int route4_dump(struct tcf_proto *tp, unsigned long fh,
        if (tcf_exts_dump(skb, &f->exts, &route_ext_map) < 0)
                goto rtattr_failure;
 
-       rta->rta_len = skb->tail - b;
+       rta->rta_len = skb_tail_pointer(skb) - b;
 
        if (tcf_exts_dump_stats(skb, &f->exts, &route_ext_map) < 0)
                goto rtattr_failure;
@@ -605,12 +586,11 @@ static int route4_dump(struct tcf_proto *tp, unsigned long fh,
        return skb->len;
 
 rtattr_failure:
-       skb_trim(skb, b - skb->data);
+       nlmsg_trim(skb, b);
        return -1;
 }
 
-static struct tcf_proto_ops cls_route4_ops = {
-       .next           =       NULL,
+static struct tcf_proto_ops cls_route4_ops __read_mostly = {
        .kind           =       "route",
        .classify       =       route4_classify,
        .init           =       route4_init,