]> err.no Git - linux-2.6/blobdiff - net/sched/cls_api.c
Merge branches 'pxa-ian' and 'pxa-xm270' into pxa
[linux-2.6] / net / sched / cls_api.c
index 87be2b2fc29a666007b93cc8314103d8fb5aaa37..9360fc81e8c7e8099e2cd105d67bbec1511324b6 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/init.h>
 #include <linux/kmod.h>
 #include <linux/netlink.h>
+#include <linux/err.h>
 #include <net/net_namespace.h>
 #include <net/sock.h>
 #include <net/netlink.h>
@@ -117,7 +118,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 net *net = sock_net(skb->sk);
        struct nlattr *tca[TCA_MAX + 1];
        struct tcmsg *t;
        u32 protocol;
@@ -219,7 +220,7 @@ replay:
                tp = kzalloc(sizeof(*tp), GFP_KERNEL);
                if (tp == NULL)
                        goto errout;
-               err = -EINVAL;
+               err = -ENOENT;
                tp_ops = tcf_proto_lookup_ops(tca[TCA_KIND]);
                if (tp_ops == NULL) {
 #ifdef CONFIG_KMOD
@@ -336,7 +337,7 @@ static int tcf_fill_node(struct sk_buff *skb, struct tcf_proto *tp,
        tcm->tcm_ifindex = tp->q->dev->ifindex;
        tcm->tcm_parent = tp->classid;
        tcm->tcm_info = TC_H_MAKE(tp->prio, tp->protocol);
-       NLA_PUT(skb, TCA_KIND, IFNAMSIZ, tp->ops->kind);
+       NLA_PUT_STRING(skb, TCA_KIND, tp->ops->kind);
        tcm->tcm_handle = fh;
        if (RTM_DELTFILTER != event) {
                tcm->tcm_handle = 0;
@@ -388,7 +389,7 @@ static int tcf_node_dump(struct tcf_proto *tp, unsigned long n,
 
 static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb)
 {
-       struct net *net = skb->sk->sk_net;
+       struct net *net = sock_net(skb->sk);
        int t;
        int s_t;
        struct net_device *dev;
@@ -481,31 +482,28 @@ EXPORT_SYMBOL(tcf_exts_destroy);
 
 int tcf_exts_validate(struct tcf_proto *tp, struct nlattr **tb,
                  struct nlattr *rate_tlv, struct tcf_exts *exts,
-                 struct tcf_ext_map *map)
+                 const struct tcf_ext_map *map)
 {
        memset(exts, 0, sizeof(*exts));
 
 #ifdef CONFIG_NET_CLS_ACT
        {
-               int err;
                struct tc_action *act;
 
                if (map->police && tb[map->police]) {
-                       act = tcf_action_init_1((struct rtattr *)tb[map->police],
-                                               (struct rtattr *)rate_tlv,
+                       act = tcf_action_init_1(tb[map->police], rate_tlv,
                                                "police", TCA_ACT_NOREPLACE,
-                                               TCA_ACT_BIND, &err);
-                       if (act == NULL)
-                               return err;
+                                               TCA_ACT_BIND);
+                       if (IS_ERR(act))
+                               return PTR_ERR(act);
 
                        act->type = TCA_OLD_COMPAT;
                        exts->action = act;
                } else if (map->action && tb[map->action]) {
-                       act = tcf_action_init((struct rtattr *)tb[map->action],
-                                             (struct rtattr *)rate_tlv, NULL,
-                               TCA_ACT_NOREPLACE, TCA_ACT_BIND, &err);
-                       if (act == NULL)
-                               return err;
+                       act = tcf_action_init(tb[map->action], rate_tlv, NULL,
+                                             TCA_ACT_NOREPLACE, TCA_ACT_BIND);
+                       if (IS_ERR(act))
+                               return PTR_ERR(act);
 
                        exts->action = act;
                }
@@ -537,7 +535,7 @@ void tcf_exts_change(struct tcf_proto *tp, struct tcf_exts *dst,
 EXPORT_SYMBOL(tcf_exts_change);
 
 int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts,
-             struct tcf_ext_map *map)
+                 const struct tcf_ext_map *map)
 {
 #ifdef CONFIG_NET_CLS_ACT
        if (map->action && exts->action) {
@@ -546,18 +544,22 @@ int 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 nlattr *p_rta = (struct nlattr *)skb_tail_pointer(skb);
+               struct nlattr *nest;
 
                if (exts->action->type != TCA_OLD_COMPAT) {
-                       NLA_PUT(skb, map->action, 0, NULL);
+                       nest = nla_nest_start(skb, map->action);
+                       if (nest == NULL)
+                               goto nla_put_failure;
                        if (tcf_action_dump(skb, exts->action, 0, 0) < 0)
                                goto nla_put_failure;
-                       p_rta->nla_len = skb_tail_pointer(skb) - (u8 *)p_rta;
+                       nla_nest_end(skb, nest);
                } else if (map->police) {
-                       NLA_PUT(skb, map->police, 0, NULL);
+                       nest = nla_nest_start(skb, map->police);
+                       if (nest == NULL)
+                               goto nla_put_failure;
                        if (tcf_action_dump_old(skb, exts->action, 0, 0) < 0)
                                goto nla_put_failure;
-                       p_rta->nla_len = skb_tail_pointer(skb) - (u8 *)p_rta;
+                       nla_nest_end(skb, nest);
                }
        }
 #endif
@@ -569,7 +571,7 @@ EXPORT_SYMBOL(tcf_exts_dump);
 
 
 int tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts,
-                       struct tcf_ext_map *map)
+                       const struct tcf_ext_map *map)
 {
 #ifdef CONFIG_NET_CLS_ACT
        if (exts->action)