OSDN Git Service

net: sched: make type an argument for ndo_setup_tc
[uclinux-h8/linux.git] / net / sched / cls_bpf.c
index f57bd53..e2bf275 100644 (file)
@@ -151,7 +151,6 @@ static int cls_bpf_offload_cmd(struct tcf_proto *tp, struct cls_bpf_prog *prog,
        struct tc_to_netdev offload;
        int err;
 
-       offload.type = TC_SETUP_CLSBPF;
        offload.cls_bpf = &bpf_offload;
 
        bpf_offload.command = cmd;
@@ -161,7 +160,8 @@ static int cls_bpf_offload_cmd(struct tcf_proto *tp, struct cls_bpf_prog *prog,
        bpf_offload.exts_integrated = prog->exts_integrated;
        bpf_offload.gen_flags = prog->gen_flags;
 
-       err = dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle,
+       err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSBPF,
+                                           tp->q->handle,
                                            tp->chain->index,
                                            tp->protocol, &offload);
 
@@ -382,13 +382,11 @@ static int cls_bpf_prog_from_efd(struct nlattr **tb, struct cls_bpf_prog *prog,
        return 0;
 }
 
-static int cls_bpf_modify_existing(struct net *net, struct tcf_proto *tp,
-                                  struct cls_bpf_prog *prog,
-                                  unsigned long base, struct nlattr **tb,
-                                  struct nlattr *est, bool ovr)
+static int cls_bpf_set_parms(struct net *net, struct tcf_proto *tp,
+                            struct cls_bpf_prog *prog, unsigned long base,
+                            struct nlattr **tb, struct nlattr *est, bool ovr)
 {
        bool is_bpf, is_ebpf, have_exts = false;
-       struct tcf_exts exts;
        u32 gen_flags = 0;
        int ret;
 
@@ -397,30 +395,23 @@ static int cls_bpf_modify_existing(struct net *net, struct tcf_proto *tp,
        if ((!is_bpf && !is_ebpf) || (is_bpf && is_ebpf))
                return -EINVAL;
 
-       ret = tcf_exts_init(&exts, TCA_BPF_ACT, TCA_BPF_POLICE);
+       ret = tcf_exts_validate(net, tp, tb, est, &prog->exts, ovr);
        if (ret < 0)
                return ret;
-       ret = tcf_exts_validate(net, tp, tb, est, &exts, ovr);
-       if (ret < 0)
-               goto errout;
 
        if (tb[TCA_BPF_FLAGS]) {
                u32 bpf_flags = nla_get_u32(tb[TCA_BPF_FLAGS]);
 
-               if (bpf_flags & ~TCA_BPF_FLAG_ACT_DIRECT) {
-                       ret = -EINVAL;
-                       goto errout;
-               }
+               if (bpf_flags & ~TCA_BPF_FLAG_ACT_DIRECT)
+                       return -EINVAL;
 
                have_exts = bpf_flags & TCA_BPF_FLAG_ACT_DIRECT;
        }
        if (tb[TCA_BPF_FLAGS_GEN]) {
                gen_flags = nla_get_u32(tb[TCA_BPF_FLAGS_GEN]);
                if (gen_flags & ~CLS_BPF_SUPPORTED_GEN_FLAGS ||
-                   !tc_flags_valid(gen_flags)) {
-                       ret = -EINVAL;
-                       goto errout;
-               }
+                   !tc_flags_valid(gen_flags))
+                       return -EINVAL;
        }
 
        prog->exts_integrated = have_exts;
@@ -429,19 +420,14 @@ static int cls_bpf_modify_existing(struct net *net, struct tcf_proto *tp,
        ret = is_bpf ? cls_bpf_prog_from_ops(tb, prog) :
                       cls_bpf_prog_from_efd(tb, prog, tp);
        if (ret < 0)
-               goto errout;
+               return ret;
 
        if (tb[TCA_BPF_CLASSID]) {
                prog->res.classid = nla_get_u32(tb[TCA_BPF_CLASSID]);
                tcf_bind_filter(tp, &prog->res, base);
        }
 
-       tcf_exts_change(tp, &prog->exts, &exts);
        return 0;
-
-errout:
-       tcf_exts_destroy(&exts);
-       return ret;
 }
 
 static u32 cls_bpf_grab_new_handle(struct tcf_proto *tp,
@@ -508,8 +494,7 @@ static int cls_bpf_change(struct net *net, struct sk_buff *in_skb,
                goto errout;
        }
 
-       ret = cls_bpf_modify_existing(net, tp, prog, base, tb, tca[TCA_RATE],
-                                     ovr);
+       ret = cls_bpf_set_parms(net, tp, prog, base, tb, tca[TCA_RATE], ovr);
        if (ret < 0)
                goto errout;