From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E139C43381 for ; Mon, 25 Feb 2019 18:48:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4FB5C2087C for ; Mon, 25 Feb 2019 18:48:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="jNhutfDT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728564AbfBYSsG (ORCPT ); Mon, 25 Feb 2019 13:48:06 -0500 Received: from mail-qt1-f195.google.com ([209.85.160.195]:33224 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726765AbfBYSsG (ORCPT ); Mon, 25 Feb 2019 13:48:06 -0500 Received: by mail-qt1-f195.google.com with SMTP id z39so11828758qtz.0 for ; Mon, 25 Feb 2019 10:48:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=ZhtvH3yaw+xBt0NzaiZtrcGSGWfkTxDS4YsGgRSqYCw=; b=jNhutfDTjwMD9C9oIIfOn5e7/jGbnGTtTy9u8OgYEiLBzxD1YgD9UX39cFCL+QWk+u w0qrZsHLnXCg8AP2TZb7G0F9IF+smS6C05ClT9vioNb+r1llercTVv6OhLvGIX8U/QiW XnjWQjbkg03uDmoDXZ9+ZQdfGfmfAguyl2aYOLJ9ftlHvWb7YuPZNjGA0+RTz48ZBffW 1f2HscDM2cOZOcnUGetU8/T+sxKhofsnHd+33M/x0cKXE8xm/QD6z5cw1bL7UHYX744V nWxF1vhXO0QtfUVWEToz0KoJgkWmwLU1uI72DaaX4tR/AiGwe1V6mNFeLfwkfWy3enYp 9llA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=ZhtvH3yaw+xBt0NzaiZtrcGSGWfkTxDS4YsGgRSqYCw=; b=kUpZFOkUE/G/qLNpMVxwZ1OS4HGiUNXwEbEaDGmA7assktZF9lvNpr/l81Mt6zzJaM i5IlsxOYe216/sISVYhq68METQuOLGFF7ltfzT6HScr3cxrSXS1KAehE6O78vkMdz/zC Tz5EA14FOEE72BELSEWfsX5sVmApgdYSbgceQPosEhc1bQozKqOKrcVVs3xy0JkWdsbC dBXkNoFp2x9w/IF2NYqG2k41ktnXNlTHCaXEdy5xtyzhQjf+VUJo8ziDbArZN4DVUDEy CbRY5nmOEWWevJfUlbcmDEx240CuEBQf7vmq9KkZ2CBPnGhIzkxjhs1ClwsKOOFa+xer HEPg== X-Gm-Message-State: AHQUAub6/rKriwb5H9w+gyMrCQf5rqRhGp3SfhMVpV4vWw3b23A9B0Qk 3A162rCkwa1fFzoSftKytPaLMw== X-Google-Smtp-Source: AHgI3Ibpn+FlaZUsSSlAlt/t9wVAiqHv3CXGIRrlCkCOVpOPIn7P2dzwWu9LPgFZsC56L3WKMq7RDQ== X-Received: by 2002:ac8:3559:: with SMTP id z25mr8299771qtb.336.1551120484833; Mon, 25 Feb 2019 10:48:04 -0800 (PST) Received: from cakuba.netronome.com ([66.60.152.14]) by smtp.gmail.com with ESMTPSA id c73sm8656731qka.37.2019.02.25.10.48.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Feb 2019 10:48:04 -0800 (PST) Date: Mon, 25 Feb 2019 10:47:57 -0800 From: Jakub Kicinski To: Toke =?UTF-8?B?SMO4aWxhbmQtSsO4cmdlbnNlbg==?= Cc: Jesper Dangaard Brouer , David Miller , netdev@vger.kernel.org, Daniel Borkmann , Alexei Starovoitov Subject: Re: [PATCH net-next 1/2] xdp: Always use a devmap for XDP_REDIRECT to a device Message-ID: <20190225104757.75b622c9@cakuba.netronome.com> In-Reply-To: <875ztawvqh.fsf@toke.dk> References: <155075021399.13610.12521373406832889226.stgit@alrua-x1> <20190221163627.7b8aa2ce@cakuba.netronome.com> <87va1cgmg1.fsf@toke.dk> <20190222133734.1880a88d@cakuba.netronome.com> <20190223114343.5813f18a@carbon> <875ztawvqh.fsf@toke.dk> Organization: Netronome Systems, Ltd. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Sat, 23 Feb 2019 13:11:02 +0100, Toke H=C3=B8iland-J=C3=B8rgensen wrote: > Jesper Dangaard Brouer writes: > > On Fri, 22 Feb 2019 13:37:34 -0800 Jakub Kicinski wrote: > >> On Fri, 22 Feb 2019 11:13:50 +0100, Toke H=C3=B8iland-J=C3=B8rgensen w= rote: =20 > >> > Jakub Kicinski writes: =20 > >> > > On Thu, 21 Feb 2019 12:56:54 +0100, Toke H=C3=B8iland-J=C3=B8rgens= en wrote: =20 > > [...] =20 > >> > > > >> > > BPF programs don't obey by netns boundaries. The fact the program= is > >> > > verified in one ns doesn't mean this is the only ns it will be use= d in :( > >> > > Meaning if any program is using the redirect map you may need a se= cret > >> > > map in every ns.. no? =20 > >> >=20 > >> > Ah, yes, good point. Totally didn't think about the fact that load a= nd > >> > attach are decoupled. Hmm, guess I'll just have to move the call to > >> > alloc_default_map() to the point where the program is attached to an > >> > interface, then... =20 > >>=20 > >> Possibly.. and you also need to handle the case where interface with a > >> program attached is moved, no? =20 >=20 > Yup, alloc on attach was easy enough; the moving turns out to be the > tricky part :) >=20 > > True, we need to handle if e.g. a veth gets an XDP program attached and > > then is moved into a network namespace (as I've already explained to > > Toke in a meeting). =20 >=20 > Yeah, I had somehow convinced myself that the XDP program was being > removed when the interface was being torn down before moving between > namespaces. Jesper pointed out that this was not in fact the case... :P >=20 > > I'm still not sure how to handle this... =20 >=20 > There are a couple of options, I think. At least: >=20 > 1. Maintain a flag on struct net_device indicating that this device > needs the redirect map allocated, and react to that when interfaces > are being moved. >=20 > 2. Lookup the BPF program by ID (which we can get from the driver) on > move, and react to the program flag. >=20 > 3. Keep the allocation on program load, but allocate maps for all active > namespaces (which would probably need a refcnt mechanism to > deallocate things again). >=20 > I think I'm leaning towards #2; possibly combined with a refcnt so we > can actually deallocate the map in the root namespace when it's not > needed anymore. Okay.. what about tail calls? I think #3 is most reasonable complexity- -wise, or some mix of #2 and #3 - cnt the programs with legacy redirects, and then allocate the resources if cnt && name space has any XDP program attached. Can users really not be told to just use the correct helper? ;)