{"id":819318,"url":"http://patchwork.ozlabs.org/api/patches/819318/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/20170927213756.1254938-5-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-5-kafai@fb.com>","list_archive_url":null,"date":"2017-09-27T21:37:55","name":"[net-next,4/5] bpf: Swap the order of checking prog_info and map_info","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"387ea7afaa2f556b60684b48a2b3841ef3b686ca","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-5-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/819318/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/819318/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=\"Fzoq8wGB\";\n\tdkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3y2WQM6R6xz9t5l\n\tfor <patchwork-incoming@ozlabs.org>;\n\tThu, 28 Sep 2017 07:38:03 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1752144AbdI0ViC (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tWed, 27 Sep 2017 17:38:02 -0400","from mx0a-00082601.pphosted.com ([67.231.145.42]:35862 \"EHLO\n\tmx0a-00082601.pphosted.com\" rhost-flags-OK-OK-OK-OK)\n\tby vger.kernel.org with ESMTP id S1751964AbdI0Vh6 (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Wed, 27 Sep 2017 17:37:58 -0400","from pps.filterd (m0109334.ppops.net [127.0.0.1])\n\tby mx0a-00082601.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id\n\tv8RLbXPL005908\n\tfor <netdev@vger.kernel.org>; Wed, 27 Sep 2017 14:37:57 -0700","from mail.thefacebook.com ([199.201.64.23])\n\tby mx0a-00082601.pphosted.com with ESMTP id 2d8g23sn7j-3\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:57 -0700","from mx-out.facebook.com (192.168.52.123) by\n\tPRN-CHUB10.TheFacebook.com (192.168.16.20) with Microsoft SMTP Server\n\tid 14.3.319.2; Wed, 27 Sep 2017 14:37:57 -0700","by devbig738.prn1.facebook.com (Postfix, from userid 6611)    id\n\t8F45B4500947; 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=QnCVezi2cqF9qh6RE7le0QGrabdoQ48pZQJ+R7f3zl8=; \n\tb=Fzoq8wGBBtj/KeBWAGGMIo/Tuwwlw3S6WfyBSfp6gPHqB3A6z8SC+vVNf9EC3Yd9bSBm\n\tPgk4/C2EHOfj9gB4/2VguG/QYLzFHqaL58Dm4hHlCDGiVd3q3S6xXb4Ng7z9kqujczPL\n\tLFsPRNUhsnd2/fpXf0m+vNFe7pG30XuE3Ro= ","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 4/5] bpf: Swap the order of checking prog_info and\n\tmap_info","Date":"Wed, 27 Sep 2017 14:37:55 -0700","Message-ID":"<20170927213756.1254938-5-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 swaps the checking order.  It now checks the map_info\nfirst and then prog_info.  It is a prep work for adding\ntest to the newly added fields (the map_ids of prog_info field\nin particular).\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 tools/testing/selftests/bpf/test_progs.c | 58 +++++++++++++++++---------------\n 1 file changed, 30 insertions(+), 28 deletions(-)","diff":"diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c\nindex 11ee25cea227..31ae27dc8d04 100644\n--- a/tools/testing/selftests/bpf/test_progs.c\n+++ b/tools/testing/selftests/bpf/test_progs.c\n@@ -316,6 +316,36 @@ static void test_bpf_obj_id(void)\n \t\t\terror_cnt++;\n \t\tassert(!err);\n \n+\t\t/* Insert a magic value to the map */\n+\t\tmap_fds[i] = bpf_find_map(__func__, objs[i], \"test_map_id\");\n+\t\tassert(map_fds[i] >= 0);\n+\t\terr = bpf_map_update_elem(map_fds[i], &array_key,\n+\t\t\t\t\t  &array_magic_value, 0);\n+\t\tassert(!err);\n+\n+\t\t/* Check getting map info */\n+\t\tinfo_len = sizeof(struct bpf_map_info) * 2;\n+\t\tbzero(&map_infos[i], info_len);\n+\t\terr = bpf_obj_get_info_by_fd(map_fds[i], &map_infos[i],\n+\t\t\t\t\t     &info_len);\n+\t\tif (CHECK(err ||\n+\t\t\t  map_infos[i].type != BPF_MAP_TYPE_ARRAY ||\n+\t\t\t  map_infos[i].key_size != sizeof(__u32) ||\n+\t\t\t  map_infos[i].value_size != sizeof(__u64) ||\n+\t\t\t  map_infos[i].max_entries != 1 ||\n+\t\t\t  map_infos[i].map_flags != 0 ||\n+\t\t\t  info_len != sizeof(struct bpf_map_info),\n+\t\t\t  \"get-map-info(fd)\",\n+\t\t\t  \"err %d errno %d type %d(%d) info_len %u(%lu) key_size %u value_size %u max_entries %u map_flags %X\\n\",\n+\t\t\t  err, errno,\n+\t\t\t  map_infos[i].type, BPF_MAP_TYPE_ARRAY,\n+\t\t\t  info_len, sizeof(struct bpf_map_info),\n+\t\t\t  map_infos[i].key_size,\n+\t\t\t  map_infos[i].value_size,\n+\t\t\t  map_infos[i].max_entries,\n+\t\t\t  map_infos[i].map_flags))\n+\t\t\tgoto done;\n+\n \t\t/* Check getting prog info */\n \t\tinfo_len = sizeof(struct bpf_prog_info) * 2;\n \t\tbzero(&prog_infos[i], info_len);\n@@ -347,34 +377,6 @@ static void test_bpf_obj_id(void)\n \t\t\t  !!memcmp(xlated_insns, zeros, sizeof(zeros))))\n \t\t\tgoto done;\n \n-\t\tmap_fds[i] = bpf_find_map(__func__, objs[i], \"test_map_id\");\n-\t\tassert(map_fds[i] >= 0);\n-\t\terr = bpf_map_update_elem(map_fds[i], &array_key,\n-\t\t\t\t\t  &array_magic_value, 0);\n-\t\tassert(!err);\n-\n-\t\t/* Check getting map info */\n-\t\tinfo_len = sizeof(struct bpf_map_info) * 2;\n-\t\tbzero(&map_infos[i], info_len);\n-\t\terr = bpf_obj_get_info_by_fd(map_fds[i], &map_infos[i],\n-\t\t\t\t\t     &info_len);\n-\t\tif (CHECK(err ||\n-\t\t\t  map_infos[i].type != BPF_MAP_TYPE_ARRAY ||\n-\t\t\t  map_infos[i].key_size != sizeof(__u32) ||\n-\t\t\t  map_infos[i].value_size != sizeof(__u64) ||\n-\t\t\t  map_infos[i].max_entries != 1 ||\n-\t\t\t  map_infos[i].map_flags != 0 ||\n-\t\t\t  info_len != sizeof(struct bpf_map_info),\n-\t\t\t  \"get-map-info(fd)\",\n-\t\t\t  \"err %d errno %d type %d(%d) info_len %u(%lu) key_size %u value_size %u max_entries %u map_flags %X\\n\",\n-\t\t\t  err, errno,\n-\t\t\t  map_infos[i].type, BPF_MAP_TYPE_ARRAY,\n-\t\t\t  info_len, sizeof(struct bpf_map_info),\n-\t\t\t  map_infos[i].key_size,\n-\t\t\t  map_infos[i].value_size,\n-\t\t\t  map_infos[i].max_entries,\n-\t\t\t  map_infos[i].map_flags))\n-\t\t\tgoto done;\n \t}\n \n \t/* Check bpf_prog_get_next_id() */\n","prefixes":["net-next","4/5"]}