]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/sched/cls_api.c
[NETLINK]: Use nlmsg_trim() where appropriate
[net-next-2.6.git] / net / sched / cls_api.c
index edb8fc97ae11a183734f700aa06bbf84d758f78e..3d0a6cdcaebcd5ab0748d84fff845e9b33728406 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/module.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>
@@ -33,6 +32,8 @@
 #include <linux/rtnetlink.h>
 #include <linux/init.h>
 #include <linux/kmod.h>
+#include <linux/netlink.h>
+#include <net/netlink.h>
 #include <net/sock.h>
 #include <net/pkt_sched.h>
 #include <net/pkt_cls.h>
@@ -286,7 +287,7 @@ replay:
                        goto errout;
        } else {
                switch (n->nlmsg_type) {
-               case RTM_NEWTFILTER:    
+               case RTM_NEWTFILTER:
                        err = -EEXIST;
                        if (n->nlmsg_flags&NLM_F_EXCL)
                                goto errout;
@@ -324,7 +325,7 @@ tcf_fill_node(struct sk_buff *skb, struct tcf_proto *tp, unsigned long fh,
 {
        struct tcmsg *tcm;
        struct nlmsghdr  *nlh;
-       unsigned char    *b = skb->tail;
+       unsigned char *b = skb_tail_pointer(skb);
 
        nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*tcm), flags);
        tcm = NLMSG_DATA(nlh);
@@ -341,12 +342,12 @@ tcf_fill_node(struct sk_buff *skb, struct tcf_proto *tp, unsigned long fh,
                if (tp->ops->dump && tp->ops->dump(tp, fh, skb, tcm) < 0)
                        goto rtattr_failure;
        }
-       nlh->nlmsg_len = skb->tail - b;
+       nlh->nlmsg_len = skb_tail_pointer(skb) - b;
        return skb->len;
 
 nlmsg_failure:
 rtattr_failure:
-       skb_trim(skb, b - skb->data);
+       nlmsg_trim(skb, b);
        return -1;
 }
 
@@ -481,11 +482,11 @@ tcf_exts_destroy(struct tcf_proto *tp, struct tcf_exts *exts)
 
 int
 tcf_exts_validate(struct tcf_proto *tp, struct rtattr **tb,
-                 struct rtattr *rate_tlv, struct tcf_exts *exts,
-                 struct tcf_ext_map *map)
+                 struct rtattr *rate_tlv, struct tcf_exts *exts,
+                 struct tcf_ext_map *map)
 {
        memset(exts, 0, sizeof(*exts));
-       
+
 #ifdef CONFIG_NET_CLS_ACT
        {
                int err;
@@ -511,7 +512,7 @@ tcf_exts_validate(struct tcf_proto *tp, struct rtattr **tb,
 #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;
@@ -530,7 +531,7 @@ tcf_exts_validate(struct tcf_proto *tp, struct rtattr **tb,
 
 void
 tcf_exts_change(struct tcf_proto *tp, struct tcf_exts *dst,
-               struct tcf_exts *src)
+               struct tcf_exts *src)
 {
 #ifdef CONFIG_NET_CLS_ACT
        if (src->action) {
@@ -564,30 +565,30 @@ tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts,
                 * to work with both old and new modes of entering
                 * tc data even if iproute2  was newer - jhs
                 */
-               struct rtattr * p_rta = (struct rtattr*) skb->tail;
+               struct rtattr *p_rta = (struct rtattr *)skb_tail_pointer(skb);
 
                if (exts->action->type != TCA_OLD_COMPAT) {
                        RTA_PUT(skb, map->action, 0, NULL);
                        if (tcf_action_dump(skb, exts->action, 0, 0) < 0)
                                goto rtattr_failure;
-                       p_rta->rta_len = skb->tail - (u8*)p_rta;
+                       p_rta->rta_len = skb_tail_pointer(skb) - (u8 *)p_rta;
                } else if (map->police) {
                        RTA_PUT(skb, map->police, 0, NULL);
                        if (tcf_action_dump_old(skb, exts->action, 0, 0) < 0)
                                goto rtattr_failure;
-                       p_rta->rta_len = skb->tail - (u8*)p_rta;
+                       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;
+               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 - (u8*)p_rta;
+               p_rta->rta_len = skb_tail_pointer(skb) - (u8 *)p_rta;
        }
 #endif
        return 0;
@@ -597,7 +598,7 @@ rtattr_failure: __attribute__ ((unused))
 
 int
 tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts,
-                   struct tcf_ext_map *map)
+                   struct tcf_ext_map *map)
 {
 #ifdef CONFIG_NET_CLS_ACT
        if (exts->action)