[{"id":1799067,"web_url":"http://patchwork.ozlabs.org/comment/1799067/","msgid":"<20171104094528.fbrhgkqwsvre2t3u@ast-mbp>","list_archive_url":null,"date":"2017-11-04T09:45:31","subject":"Re: [PATCH net-next v2 03/15] bpf: report offload info to user space","submitter":{"id":42586,"url":"http://patchwork.ozlabs.org/api/people/42586/","name":"Alexei Starovoitov","email":"alexei.starovoitov@gmail.com"},"content":"On Fri, Nov 03, 2017 at 01:56:18PM -0700, Jakub Kicinski wrote:\n> Extend struct bpf_prog_info to contain information about program\n> being bound to a device.  Since the netdev may get destroyed while\n> program still exists we need a flag to indicate the program is\n> loaded for a device, even if the device is gone.\n> \n> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>\n> Reviewed-by: Simon Horman <simon.horman@netronome.com>\n> Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>\n> ---\n>  include/linux/bpf.h      |  1 +\n>  include/uapi/linux/bpf.h |  6 ++++++\n>  kernel/bpf/offload.c     | 12 ++++++++++++\n>  kernel/bpf/syscall.c     |  5 +++++\n>  4 files changed, 24 insertions(+)\n> \n> diff --git a/include/linux/bpf.h b/include/linux/bpf.h\n> index e45d43f9ec92..98bacd0fa5cc 100644\n> --- a/include/linux/bpf.h\n> +++ b/include/linux/bpf.h\n> @@ -506,6 +506,7 @@ static inline int cpu_map_enqueue(struct bpf_cpu_map_entry *rcpu,\n>  \n>  int bpf_prog_offload_compile(struct bpf_prog *prog);\n>  void bpf_prog_offload_destroy(struct bpf_prog *prog);\n> +u32 bpf_prog_offload_ifindex(struct bpf_prog *prog);\n>  \n>  #if defined(CONFIG_NET) && defined(CONFIG_BPF_SYSCALL)\n>  int bpf_prog_offload_init(struct bpf_prog *prog, union bpf_attr *attr);\n> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h\n> index 727a3dba13e6..e92f62cf933a 100644\n> --- a/include/uapi/linux/bpf.h\n> +++ b/include/uapi/linux/bpf.h\n> @@ -894,6 +894,10 @@ enum sk_action {\n>  \n>  #define BPF_TAG_SIZE\t8\n>  \n> +enum bpf_prog_status {\n> +\tBPF_PROG_STATUS_DEV_BOUND\t= (1 << 0),\n> +};\n> +\n>  struct bpf_prog_info {\n>  \t__u32 type;\n>  \t__u32 id;\n> @@ -907,6 +911,8 @@ struct bpf_prog_info {\n>  \t__u32 nr_map_ids;\n>  \t__aligned_u64 map_ids;\n>  \tchar name[BPF_OBJ_NAME_LEN];\n> +\t__u32 ifindex;\n> +\t__u32 status;\n\nwhy status is needed?\nifindex cannot be zero, so if it's set > 0 would mean\nthat the program is bound.\nAlso would be good to have consistent name with prog_load.\nimo prog_target_ifindex is too long.\nMay be call it 'ifindex' both in bpf_attr and in bpf_prog_info ?","headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"n2gufetJ\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3yTYpv4wfyz9s7f\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat,  4 Nov 2017 20:45:43 +1100 (AEDT)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1756568AbdKDJpi (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tSat, 4 Nov 2017 05:45:38 -0400","from mail-pg0-f68.google.com ([74.125.83.68]:51786 \"EHLO\n\tmail-pg0-f68.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1756478AbdKDJph (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Sat, 4 Nov 2017 05:45:37 -0400","by mail-pg0-f68.google.com with SMTP id p9so4451616pgc.8\n\tfor <netdev@vger.kernel.org>; Sat, 04 Nov 2017 02:45:37 -0700 (PDT)","from ast-mbp ([2620:10d:c094:180::1:10a5])\n\tby smtp.gmail.com with ESMTPSA id\n\th67sm15306374pfh.74.2017.11.04.02.45.34\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tSat, 04 Nov 2017 02:45:35 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=gmail.com; s=20161025;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:in-reply-to:user-agent;\n\tbh=bZz256OiOY6CHtEi5y/zOzbE0g6g2oVvQlMwcG3Qvf0=;\n\tb=n2gufetJMCZsnSU0OPRf8qV2Lc8G55s7lIGLS+epgrHpjPoyEv/3GenmSSyquA2DPE\n\tagT14UmhMlH+qGfIRn05di0E+P2gzeoOFSVwrU5yZtlvPgE5m5DVO4SuD8sHg0uyBdIi\n\tlXfwHQj5GCpKgXVSSQqkKOtbkm8Kdm4/5JVoERRskHq1bkQfLWHhxxXa4oYLVGZobIP3\n\t9hWEDtLlgvCvNSrdqj/5kJEEA1sT2cHQZDW0jbQw9EPum2WneieZa+WGdZgpvFqznT+B\n\tFKdAXot2J5Wlk/e8UGyRm3Dka//d11tbI+zFXH8VR5tIRXr/M//uci2lpvtfxVxWQp8p\n\t1r3w==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:in-reply-to:user-agent;\n\tbh=bZz256OiOY6CHtEi5y/zOzbE0g6g2oVvQlMwcG3Qvf0=;\n\tb=FWUSZFFFB94eOXEHWsGehzwB8NeJ7EEPHN4geXTY9snTfBOz+VlKAXPl3STySQdZdg\n\tV8ULQrnhZKkrEuY4nhJwU/t9NQweZGV2oE3Bn8p+NXZD5eVltO9rwveb9KWaGwZNA7bm\n\tN7Iv6uo0qJD247ooH6pu2A6Cwy21o1EKfo3e1F8MYzHlI14Ei27DcQQTjlokbhg1Ds6R\n\tKQaqikM7eAodZC/9g2AhtLNrOgO0yeVSP9yLqIvT/wPVwRJH233+icqYZG0PPl383nDW\n\tEMKtHGf7Hgz2Rp4PV+ukONaPA7THRvMxvJNFQzEgJh8SK2sZGLbi1evYInsr8zCsJzj6\n\tCUkg==","X-Gm-Message-State":"AMCzsaVAT3BmpKuK3zBqFrcB4EhyHwcHrwSBarwB160J1FY0sbd9tq67\n\teVkPi0qagtBbmncshbGogh+NAnXB","X-Google-Smtp-Source":"ABhQp+QqnDIYDuLk04CCuOEeqc4RIimKKMUIdwoUr/2YyXtGex1RyGa+1owpX/8wUG92UW8Wo9fJJA==","X-Received":"by 10.99.56.82 with SMTP id h18mr9832794pgn.281.1509788736841;\n\tSat, 04 Nov 2017 02:45:36 -0700 (PDT)","Date":"Sat, 4 Nov 2017 18:45:31 +0900","From":"Alexei Starovoitov <alexei.starovoitov@gmail.com>","To":"Jakub Kicinski <jakub.kicinski@netronome.com>","Cc":"netdev@vger.kernel.org, oss-drivers@netronome.com, daniel@iogearbox.net","Subject":"Re: [PATCH net-next v2 03/15] bpf: report offload info to user space","Message-ID":"<20171104094528.fbrhgkqwsvre2t3u@ast-mbp>","References":"<20171103205630.1083-1-jakub.kicinski@netronome.com>\n\t<20171103205630.1083-4-jakub.kicinski@netronome.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20171103205630.1083-4-jakub.kicinski@netronome.com>","User-Agent":"NeoMutt/20170421 (1.8.2)","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"}},{"id":1799082,"web_url":"http://patchwork.ozlabs.org/comment/1799082/","msgid":"<20171104033246.0f65f853@cakuba.lan>","list_archive_url":null,"date":"2017-11-04T10:32:46","subject":"Re: [PATCH net-next v2 03/15] bpf: report offload info to user space","submitter":{"id":17220,"url":"http://patchwork.ozlabs.org/api/people/17220/","name":"Jakub Kicinski","email":"kubakici@wp.pl"},"content":"On Sat, 4 Nov 2017 18:45:31 +0900, Alexei Starovoitov wrote:\n> On Fri, Nov 03, 2017 at 01:56:18PM -0700, Jakub Kicinski wrote:\n> > Extend struct bpf_prog_info to contain information about program\n> > being bound to a device.  Since the netdev may get destroyed while\n> > program still exists we need a flag to indicate the program is\n> > loaded for a device, even if the device is gone.\n> > \n> > Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>\n> > Reviewed-by: Simon Horman <simon.horman@netronome.com>\n> > Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>\n> > ---\n> >  include/linux/bpf.h      |  1 +\n> >  include/uapi/linux/bpf.h |  6 ++++++\n> >  kernel/bpf/offload.c     | 12 ++++++++++++\n> >  kernel/bpf/syscall.c     |  5 +++++\n> >  4 files changed, 24 insertions(+)\n> > \n> > diff --git a/include/linux/bpf.h b/include/linux/bpf.h\n> > index e45d43f9ec92..98bacd0fa5cc 100644\n> > --- a/include/linux/bpf.h\n> > +++ b/include/linux/bpf.h\n> > @@ -506,6 +506,7 @@ static inline int cpu_map_enqueue(struct bpf_cpu_map_entry *rcpu,\n> >  \n> >  int bpf_prog_offload_compile(struct bpf_prog *prog);\n> >  void bpf_prog_offload_destroy(struct bpf_prog *prog);\n> > +u32 bpf_prog_offload_ifindex(struct bpf_prog *prog);\n> >  \n> >  #if defined(CONFIG_NET) && defined(CONFIG_BPF_SYSCALL)\n> >  int bpf_prog_offload_init(struct bpf_prog *prog, union bpf_attr *attr);\n> > diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h\n> > index 727a3dba13e6..e92f62cf933a 100644\n> > --- a/include/uapi/linux/bpf.h\n> > +++ b/include/uapi/linux/bpf.h\n> > @@ -894,6 +894,10 @@ enum sk_action {\n> >  \n> >  #define BPF_TAG_SIZE\t8\n> >  \n> > +enum bpf_prog_status {\n> > +\tBPF_PROG_STATUS_DEV_BOUND\t= (1 << 0),\n> > +};\n> > +\n> >  struct bpf_prog_info {\n> >  \t__u32 type;\n> >  \t__u32 id;\n> > @@ -907,6 +911,8 @@ struct bpf_prog_info {\n> >  \t__u32 nr_map_ids;\n> >  \t__aligned_u64 map_ids;\n> >  \tchar name[BPF_OBJ_NAME_LEN];\n> > +\t__u32 ifindex;\n> > +\t__u32 status;  \n> \n> why status is needed?\n> ifindex cannot be zero, so if it's set > 0 would mean\n> that the program is bound.\n\nDevices may come and go, independently from the lifetime of the program,\ntherefore there is a notion of a program which has been loaded for a\nparticular device but the device is gone (and therefore its ifindex is\nmeaningless).  I tried to explain this in the commit message.\n\n> Also would be good to have consistent name with prog_load.\n> imo prog_target_ifindex is too long.\n> May be call it 'ifindex' both in bpf_attr and in bpf_prog_info ?\n\nPerhaps I'm missing something, but bpf_attr is a huge union of (mostly)\nunnamed anonymous structs.  I foresee that we will have to add an\nifindex member for a map command as well, therefore the prog_* prefix\nseems prudent.  Should I go back to prog_ifindex in bpf_attr?\n\nOr perhaps should I duplicate the struct for BPF_PROG_LOAD but this\ntime give it a member name so we can extend it without worrying about\nmember name conflicts?","headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=wp.pl header.i=@wp.pl header.b=\"BcXe4ExM\";\n\tdkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3yTZsV5DPnz9sNr\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat,  4 Nov 2017 21:33:02 +1100 (AEDT)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751580AbdKDKc5 (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tSat, 4 Nov 2017 06:32:57 -0400","from mx3.wp.pl ([212.77.101.9]:19095 \"EHLO mx3.wp.pl\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1750750AbdKDKc4 (ORCPT <rfc822;netdev@vger.kernel.org>);\n\tSat, 4 Nov 2017 06:32:56 -0400","(wp-smtpd smtp.wp.pl 14611 invoked from network);\n\t4 Nov 2017 11:32:53 +0100","from c-73-231-89-118.hsd1.ca.comcast.net (HELO cakuba.lan)\n\t(kubakici@wp.pl@[73.231.89.118]) (envelope-sender <kubakici@wp.pl>)\n\tby smtp.wp.pl (WP-SMTPD) with ECDHE-RSA-AES256-GCM-SHA384 encrypted\n\tSMTP for <alexei.starovoitov@gmail.com>; 4 Nov 2017 11:32:53 +0100"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=wp.pl; s=1024a;\n\tt=1509791574; bh=U1NeidwsravhCUqVuBYsNoC7RN8LMsKnbwBpM2+Nzfk=;\n\th=From:To:Cc:Subject;\n\tb=BcXe4ExM7y72R2Ai8W0ycCnZXP2QCiRGMFKJgxgOF25Z6EaibASivyBE+4mhy9PrN\n\taN8hSP8i8kpL+EGG1xGkJRJgD6i0J+uHKWSQPuiueppko+fvMUerw6bs6iCWWWD0XK\n\tUK3mLbfiseDczZO2TPxKRtfGNfhJedUi7h30FVvY=","Date":"Sat, 4 Nov 2017 03:32:46 -0700","From":"Jakub Kicinski <kubakici@wp.pl>","To":"Alexei Starovoitov <alexei.starovoitov@gmail.com>","Cc":"netdev@vger.kernel.org, oss-drivers@netronome.com, daniel@iogearbox.net","Subject":"Re: [PATCH net-next v2 03/15] bpf: report offload info to user space","Message-ID":"<20171104033246.0f65f853@cakuba.lan>","In-Reply-To":"<20171104094528.fbrhgkqwsvre2t3u@ast-mbp>","References":"<20171103205630.1083-1-jakub.kicinski@netronome.com>\n\t<20171103205630.1083-4-jakub.kicinski@netronome.com>\n\t<20171104094528.fbrhgkqwsvre2t3u@ast-mbp>","MIME-Version":"1.0","Content-Type":"text/plain; charset=US-ASCII","Content-Transfer-Encoding":"7bit","X-WP-MailID":"741f236c0db0223d51bc71ca7a9a57e7","X-WP-AV":"skaner antywirusowy Poczty Wirtualnej Polski","X-WP-SPAM":"NO 000000A [URNk]                               ","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"}}]