Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp159734imm; Thu, 21 Jun 2018 15:53:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLmC/xhobeh/LlFH+GjN2UqzlG4Kz0pyoX5QgHFk2hmgybFshwGco2PXWbHKhzb0OyY5lY0 X-Received: by 2002:a65:47cc:: with SMTP id f12-v6mr24084873pgs.173.1529621639307; Thu, 21 Jun 2018 15:53:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529621639; cv=none; d=google.com; s=arc-20160816; b=BMfaMxOpKuDKqiNga6WQa5sKnfZEu4nlVDkwoWAkNG1EqSfXykSvZPf2GYPtLhumDd IhIUfiJAbqzpUXRgcVEIbWzn8lOzWe9P+3mVF4mOcHEPARkei/PrI37vUD1BGGRHdMov vFsj8kX4cKhB2Fku/qttMmOV4I1Z8Q+nvXAFVftTrO0NfskB/L1FAXjvBS64iSsLa9YY 8kfYHOT0EZ88VLS0iZfsABrD8vE8ns5qZ4bOYkWw/mzysFU8haQWTIqTbhveWD9lAkdd PVfN3cijpJj1mwZCY8WaZiVN+AFLfc88+zjhTsjv+X7HxASdQmMjEjQlPSgGn+VduVI3 Mbtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=aH9G8xCtT7vAM0z5sguFFQkYZZQ+4EYwnbwAMR+n2H8=; b=ea0gf0j9bBHH2xNWZrpEMcCSykPmHAbutaCXboPOdMF6/nGx857rqJOc9HWDhn9pJT 5ZQ5lHHYxk1Y8mh7P7lMRPxEn2WSl6eIkzQZBN0D0Xw3El5ASPlQAnr26tKaVw8URYmL SEac8C6gdMgYjnRm6ybFYFOgG9JwOcO1wNiSqa1RiRwaO/RJxfmHESPWPlamHkJh1VPT fgy/Ws6ReJgPATOnW+gawuWtYaIDS/JivrN3L9xDQqHESpxb5+WeQZnZDH6bCkpkuW6z GGtRiLolTlC86L9iTaJkuQN0r/DQKv8I8wEyLUfqWrCxzLJ95Uxn682wmbxx3YVpSNNa 1ihQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=q3ZHkU8I; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 83-v6si1581623pgf.378.2018.06.21.15.53.44; Thu, 21 Jun 2018 15:53:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=q3ZHkU8I; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933996AbeFUWvu (ORCPT + 99 others); Thu, 21 Jun 2018 18:51:50 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:39694 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933393AbeFUWvs (ORCPT ); Thu, 21 Jun 2018 18:51:48 -0400 Received: from pps.filterd (m0148460.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5LMmpa0010536; Thu, 21 Jun 2018 15:51:24 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=facebook; bh=aH9G8xCtT7vAM0z5sguFFQkYZZQ+4EYwnbwAMR+n2H8=; b=q3ZHkU8IMMM94bXX1Xwm66DpxPWR8htBF18/2gTQClljlXMhc9vaibsrs4rtsB1mDK/U y9Y/aXgMJsYEAbish/g1w1YSftaV05K6/UcZRGgFFeWkIyfomf7ODxK7b4hdVkMqOwfF mkHz9ChfmoCDHtczKxYbmH19LHauvku9Yh4= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2jrmp3g2dv-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 21 Jun 2018 15:51:24 -0700 Received: from kafai-mbp.dhcp.thefacebook.com (192.168.52.123) by mail.thefacebook.com (192.168.16.16) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 21 Jun 2018 15:51:18 -0700 Date: Thu, 21 Jun 2018 15:51:17 -0700 From: Martin KaFai Lau To: Jakub Kicinski CC: Okash Khawaja , Daniel Borkmann , "Alexei Starovoitov" , Yonghong Song , Quentin Monnet , "David S. Miller" , , , Subject: Re: [PATCH bpf-next 2/3] bpf: btf: add btf json print functionality Message-ID: <20180621225117.dhrkrtmkfbeihbe4@kafai-mbp.dhcp.thefacebook.com> References: <20180620203051.223156973@fb.com> <20180620203703.101156292@fb.com> <20180621145935.41ff8974@cakuba.netronome.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20180621145935.41ff8974@cakuba.netronome.com> User-Agent: NeoMutt/20180512 X-Originating-IP: [192.168.52.123] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-06-21_10:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 21, 2018 at 02:59:35PM -0700, Jakub Kicinski wrote: > On Wed, 20 Jun 2018 13:30:53 -0700, Okash Khawaja wrote: > > $ sudo bpftool map dump -p id 14 > > [{ > > "key": 0 > > },{ > > "value": { > > "m": 1, > > "n": 2, > > "o": "c", > > "p": [15,16,17,18,15,16,17,18 > > ], > > "q": [[25,26,27,28,25,26,27,28 > > ],[35,36,37,38,35,36,37,38 > > ],[45,46,47,48,45,46,47,48 > > ],[55,56,57,58,55,56,57,58 > > ] > > ], > > "r": 1, > > "s": 0x7ffff6f70568, > > "t": { > > "x": 5, > > "y": 10 > > }, > > "u": 100, > > "v": 20, > > "w1": 0x7, > > "w2": 0x3 > > } > > } > > ] > > I don't think this format is okay, JSON output is an API you shouldn't > break. You can change the non-JSON output whatever way you like, but > JSON must remain backwards compatible. > > The dump today has object per entry, e.g.: > > { > "key":["0x00","0x00","0x00","0x00", > ], > "value": ["0x02","0x00","0x00","0x00","0x00","0x00","0x00","0x00" > ] > } > > This format must remain, you may only augment it with new fields. E.g.: > > { > "key":["0x00","0x00","0x00","0x00", > ], > "key_struct":{ > "index":0 > }, > "value": ["0x02","0x00","0x00","0x00","0x00","0x00","0x00","0x00" > ], > "value_struct":{ > "src_ip":2, > "dst_ip:0 > } > } I am not sure how useful to have both "key|value" and "(key|value)_struct" while most people would prefer "key_struct"/"value_struct" if it is available. How about introducing a new option, like "-b", to print the map with BTF (if available) such that it won't break the existing one (-j or -p) while the "-b" output can keep using the "key" and "value". The existing json can be kept as is. > > The name XYZ_struct may not be the best, perhaps you can come up with a > better one? > > Does that make sense? Am I missing what you're doing here? > > One process note - please make sure you run checkpatch.pl --strict on > bpftool patches before posting. > > Thanks for working on this!