{"id":834090,"url":"http://patchwork.ozlabs.org/api/1.2/patches/834090/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/20171103205630.1083-5-jakub.kicinski@netronome.com/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/1.2/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20171103205630.1083-5-jakub.kicinski@netronome.com>","list_archive_url":null,"date":"2017-11-03T20:56:19","name":"[net-next,v2,04/15] bpftool: print program device bound info","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"d64c0796dd80c35966fb0ffe10eb0af12bbfc192","submitter":{"id":67484,"url":"http://patchwork.ozlabs.org/api/1.2/people/67484/?format=json","name":"Jakub Kicinski","email":"jakub.kicinski@netronome.com"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/1.2/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20171103205630.1083-5-jakub.kicinski@netronome.com/mbox/","series":[{"id":11839,"url":"http://patchwork.ozlabs.org/api/1.2/series/11839/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=11839","date":"2017-11-03T20:56:15","name":"bpf: add offload as a first class citizen","version":2,"mbox":"http://patchwork.ozlabs.org/series/11839/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/834090/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/834090/checks/","tags":{},"related":[],"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=netronome-com.20150623.gappssmtp.com\n\theader.i=@netronome-com.20150623.gappssmtp.com\n\theader.b=\"yRATAqLK\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3yTDlm6Y5hz9sBd\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat,  4 Nov 2017 07:56:52 +1100 (AEDT)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1754284AbdKCU4v (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tFri, 3 Nov 2017 16:56:51 -0400","from mail-pg0-f67.google.com ([74.125.83.67]:51307 \"EHLO\n\tmail-pg0-f67.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1752454AbdKCU4s (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Fri, 3 Nov 2017 16:56:48 -0400","by mail-pg0-f67.google.com with SMTP id p9so3439375pgc.8\n\tfor <netdev@vger.kernel.org>; Fri, 03 Nov 2017 13:56:48 -0700 (PDT)","from jkicinski-Precision-T1700.netronome.com ([75.53.12.129])\n\tby smtp.gmail.com with ESMTPSA id\n\to10sm9989029pgq.69.2017.11.03.13.56.47\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tFri, 03 Nov 2017 13:56:47 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=netronome-com.20150623.gappssmtp.com; s=20150623;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=591TzVct2YqWdirq1I3OLwk6ip+tmdQuwWYWcKqO988=;\n\tb=yRATAqLKadVvu1VZWC69VGa+JSJRE6CSAGjlZalPhkvsEfDBO63i0cwg1YMGBWNUB6\n\tK50c8RoQkOEBZE3kYqi+R8tY7s55uJKJSsdV8PL5sBCL6ylkK4MTSKCKHoyjdiZlgPhw\n\tdL1vVQbH9Ir9pMzlScDVoXCmTxY/P2+H1DQG2jWuRkiEWPbjInxThRKPgkCG5Fx5a/qp\n\tQ+U18lzZBBZ/kqom9kxxm8g4b0z7kPvgjDLQMOYVDoYBe3pNtRLmDAgEUvSX0yIFvmuy\n\tF7276b9UyaaRz4pnSOO8NVbtpgamFn8yqSowqPBR5i80kxKf4246IOTcO3Ri9J6ERcBJ\n\tulPg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=591TzVct2YqWdirq1I3OLwk6ip+tmdQuwWYWcKqO988=;\n\tb=RbxuIUA23EoVGs9MA3zj/LNbOeOeDqLP6LPTOQJwQK2sxprDbAr5ScqhYTXFJinonY\n\tDD17sdYY5RUkh0v33jExExL2q3/2AsUda9R0ZltP5HHTgufRd8Ftff86h68wqEEFEH7W\n\tws9+O6TDMcOXy/ziO63YTPe4bWAtnm1UQFRjHzP+x6QnHNh3bN6rAdPaFA67PV8oPEQx\n\tnd1rLx8//gpkg2yvp5jnzuJPZUVSodTjxle3i9V81SsRBNtEuXNeWFxgpfu0SwGszrZm\n\t81CCWn8y0rb1r4+IIRg/iss5inGgfAWWeZyD1YK/bCCMKNyBIYQnuwzJ4i3z+Mj35+1G\n\tbC/g==","X-Gm-Message-State":"AMCzsaWs+YNfGHTTyKt9n7WKWbaOyagjp+rNKQTZGKViglIXQ33fzrCL\n\t6DGcD34H0LJHjh6q7DNjb6brYmfX","X-Google-Smtp-Source":"ABhQp+SVE1iQnhRV2pcPPew+kuP5QKcPptCsPxrJ4Ku/qJydwedxHjB7obnPeKCaK1A4hokHFWVvaQ==","X-Received":"by 10.98.211.23 with SMTP id q23mr8928091pfg.28.1509742608110;\n\tFri, 03 Nov 2017 13:56:48 -0700 (PDT)","From":"Jakub Kicinski <jakub.kicinski@netronome.com>","To":"netdev@vger.kernel.org","Cc":"oss-drivers@netronome.com, alexei.starovoitov@gmail.com,\n\tdaniel@iogearbox.net, Jakub Kicinski <jakub.kicinski@netronome.com>","Subject":"[PATCH net-next v2 04/15] bpftool: print program device bound info","Date":"Fri,  3 Nov 2017 13:56:19 -0700","Message-Id":"<20171103205630.1083-5-jakub.kicinski@netronome.com>","X-Mailer":"git-send-email 2.14.1","In-Reply-To":"<20171103205630.1083-1-jakub.kicinski@netronome.com>","References":"<20171103205630.1083-1-jakub.kicinski@netronome.com>","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"If program is bound to a device, print the name of the relevant\ninterface or unknown if the netdev has since been removed.\n\nSigned-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>\nReviewed-by: Simon Horman <simon.horman@netronome.com>\nReviewed-by: Quentin Monnet <quentin.monnet@netronome.com>\n---\n tools/bpf/bpftool/prog.c       | 31 +++++++++++++++++++++++++++++++\n tools/include/uapi/linux/bpf.h |  7 +++++++\n 2 files changed, 38 insertions(+)","diff":"diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c\nindex 250f80fd46aa..d3ab808dc882 100644\n--- a/tools/bpf/bpftool/prog.c\n+++ b/tools/bpf/bpftool/prog.c\n@@ -41,6 +41,7 @@\n #include <string.h>\n #include <time.h>\n #include <unistd.h>\n+#include <net/if.h>\n #include <sys/types.h>\n #include <sys/stat.h>\n \n@@ -229,6 +230,21 @@ static void print_prog_json(struct bpf_prog_info *info, int fd)\n \t\t     info->tag[0], info->tag[1], info->tag[2], info->tag[3],\n \t\t     info->tag[4], info->tag[5], info->tag[6], info->tag[7]);\n \n+\tif (info->status & BPF_PROG_STATUS_DEV_BOUND) {\n+\t\tjsonw_name(json_wtr, \"dev\");\n+\t\tif (info->ifindex) {\n+\t\t\tchar name[IF_NAMESIZE];\n+\n+\t\t\tif (!if_indextoname(info->ifindex, name))\n+\t\t\t\tjsonw_printf(json_wtr, \"\\\"ifindex:%d\\\"\",\n+\t\t\t\t\t     info->ifindex);\n+\t\t\telse\n+\t\t\t\tjsonw_printf(json_wtr, \"\\\"%s\\\"\", name);\n+\t\t} else {\n+\t\t\tjsonw_printf(json_wtr, \"\\\"unknown\\\"\");\n+\t\t}\n+\t}\n+\n \tif (info->load_time) {\n \t\tchar buf[32];\n \n@@ -274,6 +290,21 @@ static void print_prog_plain(struct bpf_prog_info *info, int fd)\n \n \tprintf(\"tag \");\n \tfprint_hex(stdout, info->tag, BPF_TAG_SIZE, \"\");\n+\tprintf(\" \");\n+\n+\tif (info->status & BPF_PROG_STATUS_DEV_BOUND) {\n+\t\tprintf(\"dev \");\n+\t\tif (info->ifindex) {\n+\t\t\tchar name[IF_NAMESIZE];\n+\n+\t\t\tif (!if_indextoname(info->ifindex, name))\n+\t\t\t\tprintf(\"ifindex:%d \", info->ifindex);\n+\t\t\telse\n+\t\t\t\tprintf(\"%s \", name);\n+\t\t} else {\n+\t\t\tprintf(\"unknown \");\n+\t\t}\n+\t}\n \tprintf(\"\\n\");\n \n \tif (info->load_time) {\ndiff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h\nindex 7cebba491011..e92f62cf933a 100644\n--- a/tools/include/uapi/linux/bpf.h\n+++ b/tools/include/uapi/linux/bpf.h\n@@ -259,6 +259,7 @@ union bpf_attr {\n \t\t__u32\t\tkern_version;\t/* checked when prog_type=kprobe */\n \t\t__u32\t\tprog_flags;\n \t\tchar\t\tprog_name[BPF_OBJ_NAME_LEN];\n+\t\t__u32\t\tprog_target_ifindex;\t/* ifindex of netdev to prep for */\n \t};\n \n \tstruct { /* anonymous struct used by BPF_OBJ_* commands */\n@@ -893,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@@ -906,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 } __attribute__((aligned(8)));\n \n struct bpf_map_info {\n","prefixes":["net-next","v2","04/15"]}