diff options
author | Matthew Wilcox <mawilcox@microsoft.com> | 2017-11-28 10:46:29 -0500 |
---|---|---|
committer | Matthew Wilcox <mawilcox@microsoft.com> | 2018-02-06 16:41:26 -0500 |
commit | 0b4ce8da79d65f9773601619bfc90d096f0a170e (patch) | |
tree | c0feae011ef7505b4b2624d6869ccaf29ae4a8ae /net/sched | |
parent | 05af0ebb0810ba3f9669649134b4b4ad42540eba (diff) | |
download | linux-0b4ce8da79d65f9773601619bfc90d096f0a170e.tar.bz2 |
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: Matthew Wilcox <mawilcox@microsoft.com>
Diffstat (limited to 'net/sched')
-rw-r--r-- | net/sched/cls_bpf.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c index 8cb3a33b1afd..b07c1fa8bc0d 100644 --- a/net/sched/cls_bpf.c +++ b/net/sched/cls_bpf.c @@ -471,7 +471,6 @@ static int cls_bpf_change(struct net *net, struct sk_buff *in_skb, struct cls_bpf_prog *oldprog = *arg; struct nlattr *tb[TCA_BPF_MAX + 1]; struct cls_bpf_prog *prog; - unsigned long idr_index; int ret; if (tca[TCA_OPTIONS] == NULL) @@ -498,21 +497,18 @@ static int cls_bpf_change(struct net *net, struct sk_buff *in_skb, } if (handle == 0) { - ret = idr_alloc_ext(&head->handle_idr, prog, &idr_index, - 1, 0x7FFFFFFF, GFP_KERNEL); - if (ret) - goto errout; - prog->handle = idr_index; - } else { - if (!oldprog) { - ret = idr_alloc_ext(&head->handle_idr, prog, &idr_index, - handle, handle + 1, GFP_KERNEL); - if (ret) - goto errout; - } - prog->handle = handle; + handle = 1; + ret = idr_alloc_u32(&head->handle_idr, prog, &handle, + INT_MAX, GFP_KERNEL); + } else if (!oldprog) { + ret = idr_alloc_u32(&head->handle_idr, prog, &handle, + handle, GFP_KERNEL); } + if (ret) + goto errout; + prog->handle = handle; + ret = cls_bpf_set_parms(net, tp, prog, base, tb, tca[TCA_RATE], ovr, extack); if (ret < 0) |