Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 34ea90ef authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'cls_bpf-next'



Daniel Borkmann says:

====================
Minor cls_bpf updates

Some minor updates resp. follow-ups on cls_bpf, please see
individual patches for details. Will follow with the iproute2
patch after this series.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents e1ffc0cd 5cf8ca0e
Loading
Loading
Loading
Loading
+16 −15
Original line number Diff line number Diff line
@@ -65,11 +65,8 @@ static int cls_bpf_exec_opcode(int code)
{
	switch (code) {
	case TC_ACT_OK:
	case TC_ACT_RECLASSIFY:
	case TC_ACT_SHOT:
	case TC_ACT_PIPE:
	case TC_ACT_STOLEN:
	case TC_ACT_QUEUED:
	case TC_ACT_REDIRECT:
	case TC_ACT_UNSPEC:
		return code;
@@ -265,8 +262,7 @@ static int cls_bpf_prog_from_ops(struct nlattr **tb, struct cls_bpf_prog *prog)
	return 0;
}

static int cls_bpf_prog_from_efd(struct nlattr **tb, struct cls_bpf_prog *prog,
				 const struct tcf_proto *tp)
static int cls_bpf_prog_from_efd(struct nlattr **tb, struct cls_bpf_prog *prog)
{
	struct bpf_prog *fp;
	char *name = NULL;
@@ -308,14 +304,11 @@ static int cls_bpf_modify_existing(struct net *net, struct tcf_proto *tp,
{
	bool is_bpf, is_ebpf, have_exts = false;
	struct tcf_exts exts;
	u32 classid;
	int ret;

	is_bpf = tb[TCA_BPF_OPS_LEN] && tb[TCA_BPF_OPS];
	is_ebpf = tb[TCA_BPF_FD];

	if ((!is_bpf && !is_ebpf) || (is_bpf && is_ebpf) ||
	    !tb[TCA_BPF_CLASSID])
	if ((!is_bpf && !is_ebpf) || (is_bpf && is_ebpf))
		return -EINVAL;

	tcf_exts_init(&exts, TCA_BPF_ACT, TCA_BPF_POLICE);
@@ -323,7 +316,6 @@ static int cls_bpf_modify_existing(struct net *net, struct tcf_proto *tp,
	if (ret < 0)
		return ret;

	classid = nla_get_u32(tb[TCA_BPF_CLASSID]);
	if (tb[TCA_BPF_FLAGS]) {
		u32 bpf_flags = nla_get_u32(tb[TCA_BPF_FLAGS]);

@@ -335,19 +327,21 @@ static int cls_bpf_modify_existing(struct net *net, struct tcf_proto *tp,
		have_exts = bpf_flags & TCA_BPF_FLAG_ACT_DIRECT;
	}

	prog->res.classid = classid;
	prog->exts_integrated = have_exts;

	ret = is_bpf ? cls_bpf_prog_from_ops(tb, prog) :
		       cls_bpf_prog_from_efd(tb, prog, tp);
		       cls_bpf_prog_from_efd(tb, prog);
	if (ret < 0) {
		tcf_exts_destroy(&exts);
		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);
	}

	tcf_exts_change(tp, &prog->exts, &exts);
	return 0;
}

@@ -468,6 +462,7 @@ static int cls_bpf_dump(struct net *net, struct tcf_proto *tp, unsigned long fh,
{
	struct cls_bpf_prog *prog = (struct cls_bpf_prog *) fh;
	struct nlattr *nest;
	u32 bpf_flags = 0;
	int ret;

	if (prog == NULL)
@@ -479,7 +474,8 @@ static int cls_bpf_dump(struct net *net, struct tcf_proto *tp, unsigned long fh,
	if (nest == NULL)
		goto nla_put_failure;

	if (nla_put_u32(skb, TCA_BPF_CLASSID, prog->res.classid))
	if (prog->res.classid &&
	    nla_put_u32(skb, TCA_BPF_CLASSID, prog->res.classid))
		goto nla_put_failure;

	if (cls_bpf_is_ebpf(prog))
@@ -492,6 +488,11 @@ static int cls_bpf_dump(struct net *net, struct tcf_proto *tp, unsigned long fh,
	if (tcf_exts_dump(skb, &prog->exts) < 0)
		goto nla_put_failure;

	if (prog->exts_integrated)
		bpf_flags |= TCA_BPF_FLAG_ACT_DIRECT;
	if (bpf_flags && nla_put_u32(skb, TCA_BPF_FLAGS, bpf_flags))
		goto nla_put_failure;

	nla_nest_end(skb, nest);

	if (tcf_exts_dump_stats(skb, &prog->exts) < 0)