]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - net/sched/act_bpf.c
Merge tag 'libnvdimm-for-4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdim...
[karo-tx-linux.git] / net / sched / act_bpf.c
index bfa870731e74db7010ec8fe780e36ec3a3cb6eb6..1c60317f01214ad77c17415bb2d7bc194b124615 100644 (file)
@@ -28,24 +28,20 @@ struct tcf_bpf_cfg {
        struct bpf_prog *filter;
        struct sock_filter *bpf_ops;
        const char *bpf_name;
-       u32 bpf_fd;
        u16 bpf_num_ops;
        bool is_ebpf;
 };
 
-static int bpf_net_id;
+static unsigned int bpf_net_id;
 static struct tc_action_ops act_bpf_ops;
 
 static int tcf_bpf(struct sk_buff *skb, const struct tc_action *act,
                   struct tcf_result *res)
 {
+       bool at_ingress = skb_at_tc_ingress(skb);
        struct tcf_bpf *prog = to_bpf(act);
        struct bpf_prog *filter;
        int action, filter_res;
-       bool at_ingress = G_TC_AT(skb->tc_verd) & AT_INGRESS;
-
-       if (unlikely(!skb_mac_header_was_set(skb)))
-               return TC_ACT_UNSPEC;
 
        tcf_lastuse_update(&prog->tcf_tm);
        bstats_cpu_update(this_cpu_ptr(prog->common.cpu_bstats), skb);
@@ -121,13 +117,19 @@ static int tcf_bpf_dump_bpf_info(const struct tcf_bpf *prog,
 static int tcf_bpf_dump_ebpf_info(const struct tcf_bpf *prog,
                                  struct sk_buff *skb)
 {
-       if (nla_put_u32(skb, TCA_ACT_BPF_FD, prog->bpf_fd))
-               return -EMSGSIZE;
+       struct nlattr *nla;
 
        if (prog->bpf_name &&
            nla_put_string(skb, TCA_ACT_BPF_NAME, prog->bpf_name))
                return -EMSGSIZE;
 
+       nla = nla_reserve(skb, TCA_ACT_BPF_DIGEST,
+                         sizeof(prog->filter->digest));
+       if (nla == NULL)
+               return -EMSGSIZE;
+
+       memcpy(nla_data(nla), prog->filter->digest, nla_len(nla));
+
        return 0;
 }
 
@@ -229,16 +231,13 @@ static int tcf_bpf_init_from_efd(struct nlattr **tb, struct tcf_bpf_cfg *cfg)
                return PTR_ERR(fp);
 
        if (tb[TCA_ACT_BPF_NAME]) {
-               name = kmemdup(nla_data(tb[TCA_ACT_BPF_NAME]),
-                              nla_len(tb[TCA_ACT_BPF_NAME]),
-                              GFP_KERNEL);
+               name = nla_memdup(tb[TCA_ACT_BPF_NAME], GFP_KERNEL);
                if (!name) {
                        bpf_prog_put(fp);
                        return -ENOMEM;
                }
        }
 
-       cfg->bpf_fd = bpf_fd;
        cfg->bpf_name = name;
        cfg->filter = fp;
        cfg->is_ebpf = true;
@@ -337,8 +336,6 @@ static int tcf_bpf_init(struct net *net, struct nlattr *nla,
 
        if (cfg.bpf_num_ops)
                prog->bpf_num_ops = cfg.bpf_num_ops;
-       if (cfg.bpf_fd)
-               prog->bpf_fd = cfg.bpf_fd;
 
        prog->tcf_action = parm->action;
        rcu_assign_pointer(prog->filter, cfg.filter);