{"id":819322,"url":"http://patchwork.ozlabs.org/api/patches/819322/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/20170927213756.1254938-3-kafai@fb.com/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/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":"<20170927213756.1254938-3-kafai@fb.com>","list_archive_url":null,"date":"2017-09-27T21:37:53","name":"[net-next,2/5] bpf: Add map_name to bpf_map_info","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"de73f47f06fa22fd80f9b76a6eaef95af573724c","submitter":{"id":64907,"url":"http://patchwork.ozlabs.org/api/people/64907/?format=json","name":"Martin KaFai Lau","email":"kafai@fb.com"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20170927213756.1254938-3-kafai@fb.com/mbox/","series":[{"id":5453,"url":"http://patchwork.ozlabs.org/api/series/5453/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=5453","date":"2017-09-27T21:37:55","name":"bpf: Extend bpf_{prog,map}_info","version":1,"mbox":"http://patchwork.ozlabs.org/series/5453/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/819322/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/819322/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 (1024-bit key;\n\tunprotected) header.d=fb.com header.i=@fb.com header.b=\"Wt7MVnsQ\";\n\tdkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3y2WQw2Srhz9t5l\n\tfor <patchwork-incoming@ozlabs.org>;\n\tThu, 28 Sep 2017 07:38:32 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1752109AbdI0Vib (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tWed, 27 Sep 2017 17:38:31 -0400","from mx0b-00082601.pphosted.com ([67.231.153.30]:50532 \"EHLO\n\tmx0b-00082601.pphosted.com\" rhost-flags-OK-OK-OK-OK)\n\tby vger.kernel.org with ESMTP id S1751969AbdI0Vh7 (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Wed, 27 Sep 2017 17:37:59 -0400","from pps.filterd (m0109331.ppops.net [127.0.0.1])\n\tby mx0a-00082601.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id\n\tv8RLbmLA029142\n\tfor <netdev@vger.kernel.org>; Wed, 27 Sep 2017 14:37:58 -0700","from mail.thefacebook.com ([199.201.64.23])\n\tby mx0a-00082601.pphosted.com with ESMTP id 2d8fsu9hbp-2\n\t(version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT)\n\tfor <netdev@vger.kernel.org>; Wed, 27 Sep 2017 14:37:58 -0700","from mx-out.facebook.com (192.168.52.123) by\n\tPRN-CHUB01.TheFacebook.com (192.168.16.11) with Microsoft SMTP Server\n\tid 14.3.319.2; Wed, 27 Sep 2017 14:37:56 -0700","by devbig738.prn1.facebook.com (Postfix, from userid 6611)    id\n\t650464500946; Wed, 27 Sep 2017 14:37:56 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com;\n\th=from : to : cc : subject\n\t: date : message-id : in-reply-to : references : mime-version :\n\tcontent-type; s=facebook;\n\tbh=G2+AMnVr6lYA0vUMu5T+/D36NHkm1MJ13SmMmggnPIQ=; \n\tb=Wt7MVnsQd4HTNB9cdhI/qLV5Rmpa5YKwb7BOgjw9hcUCHowOMzdNS20orvnGXm4h+6yZ\n\tOviwOmA/Lsl+3X1JoSgtdbBNvI6/Q5lUpMsHhCk/lXq9CYU0S5mUq2dzmKi5+kX6wGv2\n\tSy+JAFjX6UZFsV2Xe9OSYAFvsvX+Fb3lPkQ= ","Smtp-Origin-Hostprefix":"devbig","From":"Martin KaFai Lau <kafai@fb.com>","Smtp-Origin-Hostname":"devbig738.prn1.facebook.com","To":"<netdev@vger.kernel.org>","CC":"Alexei Starovoitov <ast@fb.com>,\n\tDaniel Borkmann <daniel@iogearbox.net>, <kernel-team@fb.com>","Smtp-Origin-Cluster":"prn1c29","Subject":"[PATCH net-next 2/5] bpf: Add map_name to bpf_map_info","Date":"Wed, 27 Sep 2017 14:37:53 -0700","Message-ID":"<20170927213756.1254938-3-kafai@fb.com>","X-Mailer":"git-send-email 2.9.5","In-Reply-To":"<20170927213756.1254938-1-kafai@fb.com>","References":"<20170927213756.1254938-1-kafai@fb.com>","X-FB-Internal":["Safe","Safe"],"MIME-Version":"1.0","Content-Type":"text/plain","X-Proofpoint-Spam-Reason":"safe","X-Proofpoint-Virus-Version":"vendor=fsecure engine=2.50.10432:, ,\n\tdefinitions=2017-09-27_08:, , signatures=0","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"This patch allows userspace to specify a name for a map\nduring BPF_MAP_CREATE.\n\nThe map's name can later be exported to user space\nvia BPF_OBJ_GET_INFO_BY_FD.\n\nSigned-off-by: Martin KaFai Lau <kafai@fb.com>\nAcked-by: Alexei Starovoitov <ast@fb.com>\nAcked-by: Daniel Borkmann <daniel@iogearbox.net>\n---\n include/linux/bpf.h      | 1 +\n include/uapi/linux/bpf.h | 2 ++\n kernel/bpf/syscall.c     | 7 ++++++-\n 3 files changed, 9 insertions(+), 1 deletion(-)","diff":"diff --git a/include/linux/bpf.h b/include/linux/bpf.h\nindex 33ccc474fb04..252f4bc9eb25 100644\n--- a/include/linux/bpf.h\n+++ b/include/linux/bpf.h\n@@ -56,6 +56,7 @@ struct bpf_map {\n \tstruct work_struct work;\n \tatomic_t usercnt;\n \tstruct bpf_map *inner_map_meta;\n+\tu8 name[BPF_OBJ_NAME_LEN];\n };\n \n /* function argument constraints */\ndiff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h\nindex bd6348269bf5..6d2137b4cf38 100644\n--- a/include/uapi/linux/bpf.h\n+++ b/include/uapi/linux/bpf.h\n@@ -190,6 +190,7 @@ union bpf_attr {\n \t\t__u32\tnuma_node;\t/* numa node (effective only if\n \t\t\t\t\t * BPF_F_NUMA_NODE is set).\n \t\t\t\t\t */\n+\t\t__u8\tmap_name[BPF_OBJ_NAME_LEN];\n \t};\n \n \tstruct { /* anonymous struct used by BPF_MAP_*_ELEM commands */\n@@ -829,6 +830,7 @@ struct bpf_map_info {\n \t__u32 value_size;\n \t__u32 max_entries;\n \t__u32 map_flags;\n+\t__u8  name[BPF_OBJ_NAME_LEN];\n } __attribute__((aligned(8)));\n \n /* User bpf_sock_ops struct to access socket values and specify request ops\ndiff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c\nindex 45970df3f820..11a7f82a55d1 100644\n--- a/kernel/bpf/syscall.c\n+++ b/kernel/bpf/syscall.c\n@@ -339,7 +339,7 @@ static int bpf_obj_name_cpy(char *dst, const char *src)\n \treturn 0;\n }\n \n-#define BPF_MAP_CREATE_LAST_FIELD numa_node\n+#define BPF_MAP_CREATE_LAST_FIELD map_name\n /* called via syscall */\n static int map_create(union bpf_attr *attr)\n {\n@@ -361,6 +361,10 @@ static int map_create(union bpf_attr *attr)\n \tif (IS_ERR(map))\n \t\treturn PTR_ERR(map);\n \n+\terr = bpf_obj_name_cpy(map->name, attr->map_name);\n+\tif (err)\n+\t\tgoto free_map_nouncharge;\n+\n \tatomic_set(&map->refcnt, 1);\n \tatomic_set(&map->usercnt, 1);\n \n@@ -1462,6 +1466,7 @@ static int bpf_map_get_info_by_fd(struct bpf_map *map,\n \tinfo.value_size = map->value_size;\n \tinfo.max_entries = map->max_entries;\n \tinfo.map_flags = map->map_flags;\n+\tmemcpy(info.name, map->name, sizeof(map->name));\n \n \tif (copy_to_user(uinfo, &info, info_len) ||\n \t    put_user(info_len, &uattr->info.info_len))\n","prefixes":["net-next","2/5"]}