Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp172864imm; Thu, 21 Jun 2018 16:08:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIeuqRE8kJdGBr+Sh5nhhN1NejK5rMUpv9ORQN8dLkYe1/4kkTk8WvgEnT23YZlmzmyy6ga X-Received: by 2002:a62:ca4a:: with SMTP id n71-v6mr29303416pfg.14.1529622502188; Thu, 21 Jun 2018 16:08:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529622502; cv=none; d=google.com; s=arc-20160816; b=GYFXpGMiN5UIqBE+pEU7SJYSePOJ0MMsEJEf2rS1W105t/wGI9BOsOnbDlh8jUbOpV TrudtZy9AoSDZLfOwWnA3zmFAcIFUpAYpgu1HARtvalYz59zTZnN3FzB6eX+h9k0VtoL BbBczCZKmkpFdhw9VqFs23U2JzLgEuHetleVi1shWcjiG57077puJJNGLPfwKx8eDApk Ccurad+RtiPeT4TSyf8qOBH7EBtatgQIdd9MAryT6G1/2Up+KjMspz5XK6Q/a1WJ0HuY Ot7bw4fOBIIQU84nWfV2uQyd57pCKgiwIDjdFLn35m88VpJ633SMLubFu+QUPLyNsX26 9SOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature:arc-authentication-results; bh=mNokjm2Uhy7NbXBsn5iKpe8gH1WVeDXFBL6F/Jjpal4=; b=sJMF8MKNmzsZGGumd1k6XGEKLNy1pd2KrEF/kV0vLHmTxfWR60qCEpeN9T97pLwozm R9E5uzcAIDoEnOk1j9S2jSqVlXW/jOhcEhiGdnPuNfyV1L9eN8u7oVgV36V4AC/+MlVk Zm+6C1fD+pSXFqfkX0VHSAw1vfmaDZEhV2RZckxFhOAkcBVXrY2IM4bkzYXzrYrlICzN sGlLegOlxb8iDaeWANeykcGgyoWUwT5zDTeg1GPrkf+Jp79RoGq3JgwVn08hUFKgvWHe i8qyM6pYnTfwhjjfdSQCEanwcvYs4sb1KJP/yTrvZEoS1nF/ToNIGE1QAJFEW94zb4Q2 wxyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=kUADdREI; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t84-v6si6037090pfj.231.2018.06.21.16.08.07; Thu, 21 Jun 2018 16:08:22 -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=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=kUADdREI; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934035AbeFUXH0 (ORCPT + 99 others); Thu, 21 Jun 2018 19:07:26 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:47038 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933537AbeFUXHY (ORCPT ); Thu, 21 Jun 2018 19:07:24 -0400 Received: by mail-qt0-f196.google.com with SMTP id h5-v6so4420374qtm.13 for ; Thu, 21 Jun 2018 16:07:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=mNokjm2Uhy7NbXBsn5iKpe8gH1WVeDXFBL6F/Jjpal4=; b=kUADdREIm92cH2doZ+dBYMCK3rh/8F1b84ZZhteIgMSeJb0TlmoIXPXCG/O/KteaTF qJEQwB3ihcDjA4ArX/Vu8Y1zcYzTn409wLQ4TPcU9p9NLQo/ljYkjBXrmztgi34nxn8a e+58eSszjXEeR72TiW6CGptiqGfwLvXAY47vxUoLCxUS816QG0oFmNJrwhk20pFmdhfr 5W7fLGaa8N/VCWVqsC78K49Vv8EL9YpnhjH3/JgQDGpy4tDn4GJpLPzxA/cVg4zRdfi4 DwAPpaAmDrINf4yuPpUsoxFjQZ3/Yl2F6LILbA+1UeRr3IoZ/ZsOIKQhqswffK/jmx8Y wMLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=mNokjm2Uhy7NbXBsn5iKpe8gH1WVeDXFBL6F/Jjpal4=; b=qaNQRW8ZvTSOblMGitcO/xI19/megMJuxsTUUYxckOJnxGiHP1Y3iYaud7jo14CP8c ArdTB+RTv9pIiIybu6RrLDdeo72TwjDdywGX2slvplkKRbeg2zwKtOAuggHDtg2l0qpu hAqKl38Y7DdF9eugJExsA2Oz3hEmcQXJF5dXk5tFn8gNoNr4gerDnFeeDxbrQT3P4g7D 68UTNgOxDrX/48ZAr/VqjNlLBqtGHrRrV0d0ITSUMrGmLdzHsQVrmrrPvJFKaPymf77u bCCpAwiSe5aRgSIYmTuTHQpQ8K3lMEpjLkJ3ldqQeHqy1KpUp1Ljs1HaBa4U9WqmJkbT Q6Dw== X-Gm-Message-State: APt69E2BMIxpWkDPSF5czPwMcbumJuRWF82vSu11nBHktswfyzoQR01G i0WCdZy60+r873pAefli+p1NJA== X-Received: by 2002:ac8:c8:: with SMTP id d8-v6mr1514950qtg.202.1529622443695; Thu, 21 Jun 2018 16:07:23 -0700 (PDT) Received: from cakuba.netronome.com ([75.53.12.129]) by smtp.gmail.com with ESMTPSA id k30-v6sm5439268qtc.31.2018.06.21.16.07.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Jun 2018 16:07:23 -0700 (PDT) Date: Thu, 21 Jun 2018 16:07:19 -0700 From: Jakub Kicinski To: Martin KaFai Lau 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: <20180621160719.2cfb4b58@cakuba.netronome.com> In-Reply-To: <20180621225117.dhrkrtmkfbeihbe4@kafai-mbp.dhcp.thefacebook.com> References: <20180620203051.223156973@fb.com> <20180620203703.101156292@fb.com> <20180621145935.41ff8974@cakuba.netronome.com> <20180621225117.dhrkrtmkfbeihbe4@kafai-mbp.dhcp.thefacebook.com> Organization: Netronome Systems, Ltd. MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 21 Jun 2018 15:51:17 -0700, Martin KaFai Lau wrote: > 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. Agreed, it's not that useful, especially with the string-hex debacle :( It's just about the backwards compat. > 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. That was my knee jerk reaction too, but on reflection it doesn't sound that great. We expect people with new-enough bpftool to use btf, so it should be available in the default output, without hiding it behind a switch. We could add a switch to hide the old output, but that doesn't give us back the names... What about Key and Value or k and v? Or key_fields and value_fields? > > 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!