Skip to content

Commit

Permalink
Merge branch 'cls_bpf'
Browse files Browse the repository at this point in the history
Daniel Borkmann says:

====================
Two cls_bpf fixes

Found them while doing a review on act_bpf and going over the
cls_bpf code again. Will also address the first issue in act_bpf
as it needs to be fixed there, too.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Jan 26, 2015
2 parents 9e79ce6 + 3f2ab13 commit b6663ad
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions net/sched/cls_bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ static int cls_bpf_modify_existing(struct net *net, struct tcf_proto *tp,
}

bpf_size = bpf_len * sizeof(*bpf_ops);
if (bpf_size != nla_len(tb[TCA_BPF_OPS])) {
ret = -EINVAL;
goto errout;
}

bpf_ops = kzalloc(bpf_size, GFP_KERNEL);
if (bpf_ops == NULL) {
ret = -ENOMEM;
Expand Down Expand Up @@ -215,15 +220,21 @@ static u32 cls_bpf_grab_new_handle(struct tcf_proto *tp,
struct cls_bpf_head *head)
{
unsigned int i = 0x80000000;
u32 handle;

do {
if (++head->hgen == 0x7FFFFFFF)
head->hgen = 1;
} while (--i > 0 && cls_bpf_get(tp, head->hgen));
if (i == 0)

if (unlikely(i == 0)) {
pr_err("Insufficient number of handles\n");
handle = 0;
} else {
handle = head->hgen;
}

return i;
return handle;
}

static int cls_bpf_change(struct net *net, struct sk_buff *in_skb,
Expand Down

0 comments on commit b6663ad

Please sign in to comment.