From mboxrd@z Thu Jan 1 00:00:00 1970 From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= Subject: Re: [RFC 0/5] add XDP support to mt76x2e/mt76x0e drivers Date: Thu, 29 Nov 2018 17:06:54 +0100 Message-ID: <8736rjrhpd.fsf@toke.dk> References: <8736rla4ow.fsf@purkki.adurom.net> <20181128104436.GA2298@localhost.localdomain> <87bm69v0ol.fsf@toke.dk> <20181128164306.0135ca83@redhat.com> <20181129103054.GA6365@localhost.localdomain> <87sgzkqaip.fsf@toke.dk> <20181129135825.GD6365@localhost.localdomain> <87h8g0q8py.fsf@toke.dk> <20181129154502.GA29066@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: Jesper Dangaard Brouer , Kalle Valo , linux-wireless@vger.kernel.org, nbd@nbd.name, Daniel Borkmann , Alexei Starovoitov , "netdev\@vger.kernel.org" To: Lorenzo Bianconi Return-path: Received: from mail.toke.dk ([52.28.52.200]:44539 "EHLO mail.toke.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728635AbeK3DMs (ORCPT ); Thu, 29 Nov 2018 22:12:48 -0500 In-Reply-To: <20181129154502.GA29066@localhost.localdomain> Sender: netdev-owner@vger.kernel.org List-ID: Lorenzo Bianconi writes: >> Lorenzo Bianconi writes: >>=20 >> >> Lorenzo Bianconi writes: >> >>=20 >> >> >> On Wed, 28 Nov 2018 13:36:26 +0100 >> >> >> Toke H=C3=B8iland-J=C3=B8rgensen wrote: >> >> >>=20 > > [...] > >> >> > >> >> > I guess it will be enough to avoid loading a 'non-WiFi' bpf program= on >> >> > a 802.11 netdevice (and vice versa). We could add a flag (or someth= ing >> >> > similar) in XDP_SETUP_PROG section of netdev_bpf data structure and >> >> > use ieee80211_ptr netdevice pointer in order to guarantee that the = bpf >> >> > program will work on the expected 'frame-type' >> >>=20 >> >> Yeah, a flag would be good; we've been discussing that for other XDP = use >> >> cases; it's not a done deal yet, but I think it would be useful. >> > >> > Do you think something wifi specific is ok (e.g bool wifi) or do you p= refer >> > something more general (e.g u32 frame_type)? >>=20 >> My thought was a feature flag where the program can set a flag which >> means "I expect 802.11 frames", and the driver can set a flag saying "I >> emit 802.11 frames", and if those two flags don't match, the verifier >> can refuse to load the program. This would not be fool-proof (an XDP >> program can still corrupt things if written incorrectly), but it would >> at least protect against the most obvious mistakes. > > I guess we can use iee80211_ptr in dev_xdp_install to double check if it = is > allowed to upload a 802.11 (or 802.3) bpf program Yeah, I think it's more an issue of convincing the wider XDP community that support for feature flags is in fact needed ;) -Toke