[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200715122514.GG2531@dhcp-12-153.nay.redhat.com>
Date: Wed, 15 Jul 2020 20:25:14 +0800
From: Hangbin Liu <liuhangbin@...il.com>
To: Toke Høiland-Jørgensen <toke@...hat.com>
Cc: bpf@...r.kernel.org, netdev@...r.kernel.org,
Jiri Benc <jbenc@...hat.com>,
Jesper Dangaard Brouer <brouer@...hat.com>,
Eelco Chaudron <echaudro@...hat.com>, ast@...nel.org,
Daniel Borkmann <daniel@...earbox.net>,
Lorenzo Bianconi <lorenzo.bianconi@...hat.com>
Subject: Re: [PATCHv7 bpf-next 1/3] xdp: add a new helper for dev map
multicast support
On Tue, Jul 14, 2020 at 11:52:14PM +0200, Toke Høiland-Jørgensen wrote:
> > +bool dev_in_exclude_map(struct bpf_dtab_netdev *obj, struct bpf_map *map,
> > + int exclude_ifindex)
> > +{
> > + struct bpf_dtab *dtab = container_of(map, struct bpf_dtab, map);
> > + struct bpf_dtab_netdev *dev;
> > + struct hlist_head *head;
> > + int i = 0;
> > +
> > + if (obj->dev->ifindex == exclude_ifindex)
> > + return true;
> > +
> > + if (!map || map->map_type != BPF_MAP_TYPE_DEVMAP_HASH)
> > + return false;
>
> The map type should probably be checked earlier and the whole operation
> aborted if it is wrong...
Yes, I have already checked it in the helper, there should no need to double
check. I will remove this check.
>
> > +
> > + for (; i < dtab->n_buckets; i++) {
> > + head = dev_map_index_hash(dtab, i);
> > +
> > + dev = hlist_entry_safe(rcu_dereference_raw(hlist_first_rcu(head)),
> > + struct bpf_dtab_netdev,
> > + index_hlist);
> > +
> > + if (dev && dev->idx == exclude_ifindex)
> > + return true;
> > + }
>
> This looks broken; why are you iterating through the buckets? Shouldn't
> this just be something like:
>
> return __dev_map_hash_lookup_elem(map, obj->dev->ifindex) != NULL;
Ah, yes, I forgot this. I will update the code.
Thanks
Hangbin
Powered by blists - more mailing lists