From: Hangbin Liu <liuhangbin@gmail.com> To: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Cc: bpf@vger.kernel.org, netdev@vger.kernel.org, "Toke Høiland-Jørgensen" <toke@redhat.com>, "Jiri Benc" <jbenc@redhat.com>, "Jesper Dangaard Brouer" <brouer@redhat.com>, "Eelco Chaudron" <echaudro@redhat.com>, ast@kernel.org, "Daniel Borkmann" <daniel@iogearbox.net> Subject: Re: [RFC PATCHv2 bpf-next 1/2] xdp: add a new helper for dev map multicast support Date: Wed, 6 May 2020 17:35:57 +0800 Message-ID: <20200506093557.GB102436@dhcp-12-153.nay.redhat.com> (raw) In-Reply-To: <20200424141908.GA6295@localhost.localdomain> Hi Lorenzo, Thanks for the comments, please see replies below. On Fri, Apr 24, 2020 at 04:19:08PM +0200, Lorenzo Bianconi wrote: > > +bool dev_in_exclude_map(struct bpf_dtab_netdev *obj, struct bpf_map *map, > > + int exclude_ifindex) > > +{ > > + struct bpf_dtab_netdev *in_obj = NULL; > > + u32 key, next_key; > > + int err; > > + > > + if (!map) > > + return false; > > doing so it seems mandatory to define an exclude_map even if we want just to do > not forward the packet to the "ingress" interface. > Moreover I was thinking that we can assume to never forward to in the incoming > interface. Doing so the code would be simpler I guess. Is there a use case for > it? (forward even to the ingress interface) Eelco has help answered one use case: VEPA. Another reason I added this flag is that the other syscalls like bpf_redirect() or bpf_redirect_map() are also able to forward to ingress interface. So we need to behave the same by default. > > > +int dev_map_enqueue_multi(struct xdp_buff *xdp, struct net_device *dev_rx, > > + struct bpf_map *map, struct bpf_map *ex_map, > > + bool exclude_ingress) > > +{ [...] > > + } > > Do we need to free 'incoming' xdp buffer here? I think most of the drivers assume > the packet is owned by the stack if xdp_do_redirect returns 0 Yes, we need. I will fix it. > > diff --git a/net/core/filter.c b/net/core/filter.c > > index 7d6ceaa54d21..94d1530e5ac6 100644 > > --- a/net/core/filter.c > > +++ b/net/core/filter.c > > @@ -3473,12 +3473,17 @@ static const struct bpf_func_proto bpf_xdp_adjust_meta_proto = { > > }; > > > > static int __bpf_tx_xdp_map(struct net_device *dev_rx, void *fwd, > > - struct bpf_map *map, struct xdp_buff *xdp) > > + struct bpf_map *map, struct xdp_buff *xdp, > > + struct bpf_map *ex_map, bool exclude_ingress) > > { > > switch (map->map_type) { > > case BPF_MAP_TYPE_DEVMAP: > > case BPF_MAP_TYPE_DEVMAP_HASH: > > - return dev_map_enqueue(fwd, xdp, dev_rx); > > + if (fwd) > > + return dev_map_enqueue(fwd, xdp, dev_rx); > > + else > > + return dev_map_enqueue_multi(xdp, dev_rx, map, ex_map, > > + exclude_ingress); > > I guess it would be better to do not make it the default case. Maybe you can > add a bit in flags to mark it for "multicast" But how do we distinguish the flag bit with other syscalls? e.g. If we define 0x02 as the "do_multicast" flag. What if other syscalls also used this flag. Currently __bpf_tx_xdp_map() is only called by xdp_do_redirect(). If there is a map and no fwd, it must be multicast forward. So we are still safe now. Maybe we need an update in future. Thanks Hangbin
next prev parent reply index Thread overview: 168+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-15 8:54 [RFC PATCH bpf-next 0/2] xdp: add " Hangbin Liu 2020-04-15 8:54 ` [RFC PATCH bpf-next 1/2] " Hangbin Liu 2020-04-20 9:52 ` Hangbin Liu 2020-04-15 8:54 ` [RFC PATCH bpf-next 2/2] sample/bpf: add xdp_redirect_map_multicast test Hangbin Liu 2020-04-24 8:56 ` [RFC PATCHv2 bpf-next 0/2] xdp: add dev map multicast support Hangbin Liu 2020-04-24 8:56 ` [RFC PATCHv2 bpf-next 1/2] xdp: add a new helper for " Hangbin Liu 2020-04-24 14:19 ` Lorenzo Bianconi 2020-04-28 11:09 ` Eelco Chaudron 2020-05-06 9:35 ` Hangbin Liu [this message] 2020-04-24 14:34 ` Toke Høiland-Jørgensen 2020-05-06 9:14 ` Hangbin Liu 2020-05-06 10:00 ` Toke Høiland-Jørgensen 2020-05-08 8:53 ` Hangbin Liu 2020-05-08 14:58 ` Toke Høiland-Jørgensen 2020-05-18 8:45 ` Hangbin Liu 2020-05-19 10:15 ` Jesper Dangaard Brouer 2020-05-20 1:24 ` Hangbin Liu 2020-04-24 8:56 ` [RFC PATCHv2 bpf-next 2/2] sample/bpf: add xdp_redirect_map_multicast test Hangbin Liu 2020-04-24 14:21 ` Lorenzo Bianconi 2020-05-23 6:05 ` [PATCHv3 bpf-next 0/2] xdp: add dev map multicast support Hangbin Liu 2020-05-23 6:05 ` [PATCHv3 bpf-next 1/2] xdp: add a new helper for " Hangbin Liu 2020-05-26 7:34 ` kbuild test robot 2020-05-23 6:05 ` [PATCHv3 bpf-next 2/2] sample/bpf: add xdp_redirect_map_multicast test Hangbin Liu 2020-05-26 14:05 ` [PATCHv4 bpf-next 0/2] xdp: add dev map multicast support Hangbin Liu 2020-05-26 14:05 ` [PATCHv4 bpf-next 1/2] xdp: add a new helper for " Hangbin Liu 2020-05-27 10:29 ` Toke Høiland-Jørgensen 2020-06-10 10:18 ` Jesper Dangaard Brouer 2020-06-12 8:54 ` Hangbin Liu 2020-06-16 8:55 ` Jesper Dangaard Brouer 2020-06-16 10:11 ` Hangbin Liu 2020-06-16 14:38 ` Jesper Dangaard Brouer 2020-06-10 10:21 ` Jesper Dangaard Brouer 2020-06-10 10:29 ` Toke Høiland-Jørgensen 2020-06-16 9:04 ` Jesper Dangaard Brouer 2020-05-26 14:05 ` [PATCHv4 bpf-next 2/2] sample/bpf: add xdp_redirect_map_multicast test Hangbin Liu 2020-05-27 10:21 ` [PATCHv4 bpf-next 0/2] xdp: add dev map multicast support Toke Høiland-Jørgensen 2020-05-27 10:32 ` Eelco Chaudron 2020-05-27 12:38 ` Hangbin Liu 2020-05-27 15:04 ` Toke Høiland-Jørgensen 2020-06-16 9:09 ` Jesper Dangaard Brouer 2020-06-16 9:47 ` Hangbin Liu 2020-06-03 2:40 ` Hangbin Liu 2020-06-03 11:05 ` Toke Høiland-Jørgensen 2020-06-04 4:09 ` Hangbin Liu 2020-06-04 9:44 ` Toke Høiland-Jørgensen 2020-06-04 12:12 ` Hangbin Liu 2020-06-04 12:37 ` Toke Høiland-Jørgensen 2020-06-04 14:41 ` Hangbin Liu 2020-06-04 16:02 ` Toke Høiland-Jørgensen 2020-06-05 6:26 ` Hangbin Liu 2020-06-08 15:32 ` Toke Høiland-Jørgensen 2020-06-09 3:03 ` Hangbin Liu 2020-06-09 20:31 ` Toke Høiland-Jørgensen 2020-06-10 2:35 ` Hangbin Liu 2020-06-10 10:03 ` Jesper Dangaard Brouer 2020-07-01 4:19 ` [PATCHv5 bpf-next 0/3] xdp: add a new helper for " Hangbin Liu 2020-07-01 4:19 ` [PATCHv5 bpf-next 1/3] " Hangbin Liu 2020-07-01 5:09 ` Andrii Nakryiko 2020-07-01 6:51 ` Hangbin Liu 2020-07-01 18:33 ` kernel test robot 2020-07-01 4:19 ` [PATCHv5 bpf-next 2/3] sample/bpf: add xdp_redirect_map_multicast test Hangbin Liu 2020-07-01 4:19 ` [PATCHv5 bpf-next 3/3] selftests/bpf: add xdp_redirect_multi test Hangbin Liu 2020-07-09 1:30 ` [PATCHv6 bpf-next 0/3] xdp: add a new helper for dev map multicast support Hangbin Liu 2020-07-09 1:30 ` [PATCHv6 bpf-next 1/3] " Hangbin Liu 2020-07-09 16:33 ` David Ahern 2020-07-10 6:55 ` Hangbin Liu 2020-07-10 13:46 ` David Ahern 2020-07-11 0:26 ` Hangbin Liu 2020-07-11 16:09 ` David Ahern 2020-07-09 1:30 ` [PATCHv6 bpf-next 2/3] sample/bpf: add xdp_redirect_map_multicast test Hangbin Liu 2020-07-09 22:40 ` Daniel Borkmann 2020-07-10 6:41 ` Hangbin Liu 2020-07-10 14:32 ` Daniel Borkmann 2020-07-11 0:21 ` Hangbin Liu 2020-07-09 1:30 ` [PATCHv6 bpf-next 3/3] selftests/bpf: add xdp_redirect_multi test Hangbin Liu 2020-07-09 22:37 ` [PATCHv6 bpf-next 0/3] xdp: add a new helper for dev map multicast support Daniel Borkmann 2020-07-10 7:36 ` Hangbin Liu 2020-07-10 15:02 ` Daniel Borkmann 2020-07-10 16:52 ` David Ahern 2020-07-14 6:32 ` [PATCHv7 " Hangbin Liu 2020-07-14 6:32 ` [PATCHv7 bpf-next 1/3] " Hangbin Liu 2020-07-14 21:52 ` Toke Høiland-Jørgensen 2020-07-15 12:25 ` Hangbin Liu 2020-07-14 6:32 ` [PATCHv7 bpf-next 2/3] sample/bpf: add xdp_redirect_map_multicast test Hangbin Liu 2020-07-14 6:32 ` [PATCHv7 bpf-next 3/3] selftests/bpf: add xdp_redirect_multi test Hangbin Liu 2020-07-14 12:29 ` [PATCHv7 bpf-next 0/3] xdp: add a new helper for dev map multicast support Toke Høiland-Jørgensen 2020-07-14 17:12 ` David Ahern 2020-07-14 21:53 ` Toke Høiland-Jørgensen 2020-07-15 12:31 ` Hangbin Liu 2020-07-15 3:45 ` Hangbin Liu 2020-07-15 13:08 ` [PATCHv8 " Hangbin Liu 2020-07-15 13:08 ` [PATCHv8 bpf-next 1/3] " Hangbin Liu 2020-07-15 13:08 ` [PATCHv8 bpf-next 2/3] sample/bpf: add xdp_redirect_map_multicast test Hangbin Liu 2020-07-15 13:08 ` [PATCHv8 bpf-next 3/3] selftests/bpf: add xdp_redirect_multi test Hangbin Liu 2020-08-26 13:19 ` [PATCHv9 bpf-next 0/5] xdp: add a new helper for dev map multicast support Hangbin Liu 2020-08-26 13:19 ` [PATCHv9 bpf-next 1/5] bpf: add a new bpf argument type ARG_CONST_MAP_PTR_OR_NULL Hangbin Liu 2020-08-28 21:56 ` Daniel Borkmann 2020-09-03 9:15 ` Hangbin Liu 2020-08-26 13:19 ` [PATCHv9 bpf-next 2/5] xdp: add a new helper for dev map multicast support Hangbin Liu 2020-08-28 22:05 ` Daniel Borkmann 2020-08-26 13:20 ` [PATCHv9 bpf-next 3/5] sample/bpf: add xdp_redirect_map_multicast test Hangbin Liu 2020-08-26 13:20 ` [PATCHv9 bpf-next 4/5] selftests/bpf: add xdp_redirect_multi test Hangbin Liu 2020-08-26 13:20 ` [PATCHv9 bpf-next 5/5] selftests/bpf: Add verifier tests for bpf arg ARG_CONST_MAP_PTR_OR_NULL Hangbin Liu 2020-09-03 10:26 ` [PATCHv10 bpf-next 0/5] xdp: add a new helper for dev map multicast support Hangbin Liu 2020-09-03 10:26 ` [PATCHv10 bpf-next 1/5] bpf: add a new bpf argument type ARG_CONST_MAP_PTR_OR_NULL Hangbin Liu 2020-09-04 14:26 ` Daniel Borkmann 2020-09-03 10:26 ` [PATCHv10 bpf-next 2/5] xdp: add a new helper for dev map multicast support Hangbin Liu 2020-09-04 14:22 ` Daniel Borkmann 2020-09-03 10:26 ` [PATCHv10 bpf-next 3/5] sample/bpf: add xdp_redirect_map_multicast test Hangbin Liu 2020-09-03 10:27 ` [PATCHv10 bpf-next 4/5] selftests/bpf: add xdp_redirect_multi test Hangbin Liu 2020-09-03 10:27 ` [PATCHv10 bpf-next 5/5] selftests/bpf: Add verifier tests for bpf arg ARG_CONST_MAP_PTR_OR_NULL Hangbin Liu 2020-09-07 8:27 ` [PATCHv11 bpf-next 0/5] xdp: add a new helper for dev map multicast support Hangbin Liu 2020-09-07 8:27 ` [PATCHv11 bpf-next 1/5] bpf: add a new bpf argument type ARG_CONST_MAP_PTR_OR_NULL Hangbin Liu 2020-09-07 8:27 ` [PATCHv11 bpf-next 2/5] xdp: add a new helper for dev map multicast support Hangbin Liu 2020-09-09 21:52 ` Alexei Starovoitov 2020-09-10 2:35 ` Hangbin Liu 2020-09-10 3:30 ` David Ahern 2020-09-10 5:35 ` Alexei Starovoitov 2020-09-10 9:44 ` Toke Høiland-Jørgensen 2020-09-10 15:39 ` Alexei Starovoitov 2020-09-10 17:50 ` Jesper Dangaard Brouer 2020-09-10 18:35 ` David Ahern 2020-09-11 7:58 ` Jesper Dangaard Brouer 2020-09-15 16:12 ` David Ahern 2020-09-07 8:27 ` [PATCHv11 bpf-next 3/5] sample/bpf: add xdp_redirect_map_multicast test Hangbin Liu 2020-09-07 8:27 ` [PATCHv11 bpf-next 4/5] selftests/bpf: add xdp_redirect_multi test Hangbin Liu 2020-09-07 8:27 ` [PATCHv11 bpf-next 5/5] selftests/bpf: Add verifier tests for bpf arg ARG_CONST_MAP_PTR_OR_NULL Hangbin Liu 2020-12-16 14:30 ` [PATCHv12 bpf-next 0/6] xdp: add a new helper for dev map multicast support Hangbin Liu 2020-12-16 14:30 ` [PATCHv12 bpf-next 1/6] bpf: run devmap xdp_prog on flush instead of bulk enqueue Hangbin Liu 2020-12-17 16:07 ` David Ahern 2020-12-18 9:43 ` Hangbin Liu 2020-12-21 8:38 ` Hangbin Liu 2020-12-16 14:30 ` [PATCHv12 bpf-next 2/6] bpf: add a new bpf argument type ARG_CONST_MAP_PTR_OR_NULL Hangbin Liu 2020-12-16 14:30 ` [PATCHv12 bpf-next 3/6] xdp: add a new helper for dev map multicast support Hangbin Liu 2020-12-16 14:30 ` [PATCHv12 bpf-next 4/6] sample/bpf: add xdp_redirect_map_multicast test Hangbin Liu 2020-12-16 14:30 ` [PATCHv12 bpf-next 5/6] selftests/bpf: Add verifier tests for bpf arg ARG_CONST_MAP_PTR_OR_NULL Hangbin Liu 2020-12-16 14:30 ` [PATCHv12 bpf-next 6/6] selftests/bpf: add xdp_redirect_multi test Hangbin Liu 2020-12-21 12:34 ` [PATCHv13 bpf-next 0/6] xdp: add a new helper for dev map multicast support Hangbin Liu 2020-12-21 12:35 ` [PATCHv13 bpf-next 1/6] bpf: run devmap xdp_prog on flush instead of bulk enqueue Hangbin Liu 2020-12-21 12:35 ` [PATCHv13 bpf-next 2/6] bpf: add a new bpf argument type ARG_CONST_MAP_PTR_OR_NULL Hangbin Liu 2020-12-21 12:35 ` [PATCHv13 bpf-next 3/6] xdp: add a new helper for dev map multicast support Hangbin Liu 2020-12-21 12:35 ` [PATCHv13 bpf-next 4/6] sample/bpf: add xdp_redirect_map_multicast test Hangbin Liu 2020-12-21 12:35 ` [PATCHv13 bpf-next 5/6] selftests/bpf: Add verifier tests for bpf arg ARG_CONST_MAP_PTR_OR_NULL Hangbin Liu 2020-12-21 12:35 ` [PATCHv13 bpf-next 6/6] selftests/bpf: add xdp_redirect_multi test Hangbin Liu 2021-01-14 14:23 ` [PATCHv14 bpf-next 0/6] xdp: add a new helper for dev map multicast support Hangbin Liu 2021-01-14 14:23 ` [PATCHv14 bpf-next 1/6] bpf: run devmap xdp_prog on flush instead of bulk enqueue Hangbin Liu 2021-01-17 22:57 ` John Fastabend 2021-01-18 10:07 ` Hangbin Liu 2021-01-21 14:33 ` Jesper Dangaard Brouer 2021-01-14 14:23 ` [PATCHv14 bpf-next 2/6] bpf: add a new bpf argument type ARG_CONST_MAP_PTR_OR_NULL Hangbin Liu 2021-01-14 14:23 ` [PATCHv14 bpf-next 3/6] xdp: add a new helper for dev map multicast support Hangbin Liu 2021-01-18 0:10 ` John Fastabend 2021-01-18 8:44 ` Hangbin Liu 2021-01-18 10:47 ` Toke Høiland-Jørgensen 2021-01-18 15:14 ` John Fastabend 2021-01-14 14:23 ` [PATCHv14 bpf-next 4/6] sample/bpf: add xdp_redirect_map_multicast test Hangbin Liu 2021-01-14 14:23 ` [PATCHv14 bpf-next 5/6] selftests/bpf: Add verifier tests for bpf arg ARG_CONST_MAP_PTR_OR_NULL Hangbin Liu 2021-01-14 14:23 ` [PATCHv14 bpf-next 6/6] selftests/bpf: add xdp_redirect_multi test Hangbin Liu 2021-01-20 2:25 ` [PATCHv15 bpf-next 0/6] xdp: add a new helper for dev map multicast support Hangbin Liu 2021-01-20 2:25 ` [PATCHv15 bpf-next 1/6] bpf: run devmap xdp_prog on flush instead of bulk enqueue Hangbin Liu 2021-01-20 22:42 ` Maciej Fijalkowski 2021-01-21 3:54 ` Hangbin Liu 2021-01-21 13:35 ` Maciej Fijalkowski 2021-01-20 2:25 ` [PATCHv15 bpf-next 2/6] bpf: add a new bpf argument type ARG_CONST_MAP_PTR_OR_NULL Hangbin Liu 2021-01-20 2:25 ` [PATCHv15 bpf-next 3/6] xdp: add a new helper for dev map multicast support Hangbin Liu 2021-01-20 2:25 ` [PATCHv15 bpf-next 4/6] sample/bpf: add xdp_redirect_map_multicast test Hangbin Liu 2021-01-20 2:25 ` [PATCHv15 bpf-next 5/6] selftests/bpf: Add verifier tests for bpf arg ARG_CONST_MAP_PTR_OR_NULL Hangbin Liu 2021-01-20 2:25 ` [PATCHv15 bpf-next 6/6] selftests/bpf: add xdp_redirect_multi test Hangbin Liu
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200506093557.GB102436@dhcp-12-153.nay.redhat.com \ --to=liuhangbin@gmail.com \ --cc=ast@kernel.org \ --cc=bpf@vger.kernel.org \ --cc=brouer@redhat.com \ --cc=daniel@iogearbox.net \ --cc=echaudro@redhat.com \ --cc=jbenc@redhat.com \ --cc=lorenzo.bianconi@redhat.com \ --cc=netdev@vger.kernel.org \ --cc=toke@redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
BPF Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/bpf/0 bpf/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 bpf bpf/ https://lore.kernel.org/bpf \ bpf@vger.kernel.org public-inbox-index bpf Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.kernel.vger.bpf AGPL code for this site: git clone https://public-inbox.org/public-inbox.git