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

Commit 0b4ce8da authored by Matthew Wilcox's avatar Matthew Wilcox
Browse files

cls_bpf: Convert to use idr_alloc_u32



Use the new helper.  This has a modest reduction in both lines of code
and compiled code size.

Signed-off-by: default avatarMatthew Wilcox <mawilcox@microsoft.com>
parent 05af0ebb
Loading
Loading
Loading
Loading
+10 −14
Original line number Original line Diff line number Diff line
@@ -471,7 +471,6 @@ static int cls_bpf_change(struct net *net, struct sk_buff *in_skb,
	struct cls_bpf_prog *oldprog = *arg;
	struct cls_bpf_prog *oldprog = *arg;
	struct nlattr *tb[TCA_BPF_MAX + 1];
	struct nlattr *tb[TCA_BPF_MAX + 1];
	struct cls_bpf_prog *prog;
	struct cls_bpf_prog *prog;
	unsigned long idr_index;
	int ret;
	int ret;


	if (tca[TCA_OPTIONS] == NULL)
	if (tca[TCA_OPTIONS] == NULL)
@@ -498,20 +497,17 @@ static int cls_bpf_change(struct net *net, struct sk_buff *in_skb,
	}
	}


	if (handle == 0) {
	if (handle == 0) {
		ret = idr_alloc_ext(&head->handle_idr, prog, &idr_index,
		handle = 1;
				    1, 0x7FFFFFFF, GFP_KERNEL);
		ret = idr_alloc_u32(&head->handle_idr, prog, &handle,
		if (ret)
				    INT_MAX, GFP_KERNEL);
			goto errout;
	} else if (!oldprog) {
		prog->handle = idr_index;
		ret = idr_alloc_u32(&head->handle_idr, prog, &handle,
	} else {
				    handle, GFP_KERNEL);
		if (!oldprog) {
	}
			ret = idr_alloc_ext(&head->handle_idr, prog, &idr_index,

					    handle, handle + 1, GFP_KERNEL);
	if (ret)
	if (ret)
		goto errout;
		goto errout;
		}
	prog->handle = handle;
	prog->handle = handle;
	}


	ret = cls_bpf_set_parms(net, tp, prog, base, tb, tca[TCA_RATE], ovr,
	ret = cls_bpf_set_parms(net, tp, prog, base, tb, tca[TCA_RATE], ovr,
				extack);
				extack);