Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7803488ybi; Thu, 6 Jun 2019 01:37:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqy9FXk57Lwcck+1YmXc+XwA5koU4PNzYW0x5Hs9j89P8f7tLPxQ6REq1gMl87d05DnHz9Zp X-Received: by 2002:a63:26c7:: with SMTP id m190mr2347040pgm.141.1559810265875; Thu, 06 Jun 2019 01:37:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559810265; cv=none; d=google.com; s=arc-20160816; b=PVOXkKTbg+VOPMuKJVIJc3XlZKyZwt5P125eQPwDeCnKZCG3Jz9XtdDgczfyj1WoM7 ApWSCDPYaWdPwa3Pass1YivHy3t6Rj1zIi+pXXQdloZfCdsHNqPGbdIYkVFayQInTlyG 90/pgbOBx1251NJdN+0ej8C067EIOnRB2drZiTnYBy8JIGo1zSTE56k2jsnJuqFdF2AX pgUf74x9WLuSEUVa9bdyg8CdJTsX0P209F5demzvx76SnZFNFLe/olvhWpDv7mAtinvf GCVGPI086SkyfhbcL1434YeZoBh2xX+9Nt6wJskTaaIpuaVkGRjtSSLa6G3osNDLhlAm wJMA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=UajfkvM7OMJhBvn/3zITvVVwFNbh5QyO0KD2fL7HAfA=; b=uYe9bKslBS1+Xu4czT4M//wDT9t+ii2CfrO0rL3MgLniTPa+iNRiRAZJqyUJ3hiYk6 hZN20CPPsZcD7yUZgbg0xi7+Dk/+zNuwWriCjb3gHycJO9bRhxwSJoB+sAamUdUvrqre E8t4aYFbC6ClXbtTgvl0bM6p57AvQYzTxGTgDkp2fdOLSOpdn7U3mzerX6Km5P9i8mMO FO/HhjjMc3EvKdyJeDRYaEkn+V2gTc3vXPbO25U5Oj+5Cxbkc4vGLGDTx2KXEkn8jxDQ fJeJBhMGGYN+ooYtAoF3rOVqxpoN7TLOhh6knk9vgKUgmkIVoq9h8FtPRUinWn8iGmWb t+MQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=UbM+6nRG; 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 d37si1451370pgd.458.2019.06.06.01.37.28; Thu, 06 Jun 2019 01:37:45 -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=UbM+6nRG; 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 S1727351AbfFFIfH (ORCPT + 99 others); Thu, 6 Jun 2019 04:35:07 -0400 Received: from mail-wr1-f51.google.com ([209.85.221.51]:37817 "EHLO mail-wr1-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727189AbfFFIfH (ORCPT ); Thu, 6 Jun 2019 04:35:07 -0400 Received: by mail-wr1-f51.google.com with SMTP id v14so1460594wrr.4 for ; Thu, 06 Jun 2019 01:35:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=UajfkvM7OMJhBvn/3zITvVVwFNbh5QyO0KD2fL7HAfA=; b=UbM+6nRG7Q9a6hI2VA/6WzMgfRI7Nn9xKWc9A95Qws3o3ixBOObYuWvBMr3Bpuj0WG hRT4h9n1S0g+tLMSOIxisZgD0aUTjd2vWSP6Ko72PWqiiG0dO91cM+flvt6O7JSakFvT zQdIipZToAPYy6A+638GxJzEB11qId921AV4V/woyiyA3N+AwNmKDJsoAlCKnyn9Exlw 3eyKx2rAmo7Rg3z8Llr7xK0Zw2//lV7tfOgPSPdVDmGI/DBK8Vlv1n17XklMq9emhYz/ sfihH313La+yqb7YpPrwnDubl2keaLvIiZEKL0i4ZyWM2J3e9NBEfXI4t/wYi7/fRQ0k 7pYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=UajfkvM7OMJhBvn/3zITvVVwFNbh5QyO0KD2fL7HAfA=; b=bUgSodIP1qz8SZKcz81ca2/uR9ucnCo669pPRgdgoG3zZgQj2LS31/AcFaQl8GzaWu UiwbmWhapIt0nwwsaTlBm0jNszYlU6AtNVkNfT5DJtWQUOaO2u6VfET9HOOQa0DooapA wtsUX5gP0KAyZPy1aMzHr3P+9+rYkV0dcXqxrfkDkD/jiuwTE64g13CkWfdNXVhRsKNX ojKoPy43L4Da7xxX4XceKZuHXE8wFySjFfEcB1IiPThmrkXy5b4Q9wAXMNozyNHvMUcn S+cBrMVeQtABaWVIyfzw8SKCqNHZOcLxm9AyaXuG7myM4+6zR1fyF/pyi/dXse6gnuXb fxuQ== X-Gm-Message-State: APjAAAXliyVmSir04diGFSJ3QLxEfR9Pa3jFfmshnqE38BteRsapF6jE ZK1AP+QII/br/DIKX1AILErV6eAVsfJOoQ== X-Received: by 2002:a5d:6a05:: with SMTP id m5mr20463872wru.161.1559810105316; Thu, 06 Jun 2019 01:35:05 -0700 (PDT) Received: from [192.168.1.2] ([194.53.187.113]) by smtp.gmail.com with ESMTPSA id p2sm1405646wrx.90.2019.06.06.01.35.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Jun 2019 01:35:04 -0700 (PDT) Subject: Re: [BPF v1] tools: bpftool: Fix JSON output when lookup fails To: Krzesimir Nowak , bpf@vger.kernel.org Cc: Alban Crequy , =?UTF-8?Q?Iago_L=c3=b3pez_Galeiras?= , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Jakub Kicinski , Stanislav Fomichev , Prashant Bhole , Okash Khawaja , David Calavera , netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20190605191707.24429-1-krzesimir@kinvolk.io> From: Quentin Monnet Message-ID: <3b26789b-3b51-8c47-b710-8df09b63ce73@netronome.com> Date: Thu, 6 Jun 2019 09:35:03 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20190605191707.24429-1-krzesimir@kinvolk.io> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2019-06-05 21:17 UTC+0200 ~ Krzesimir Nowak > In commit 9a5ab8bf1d6d ("tools: bpftool: turn err() and info() macros > into functions") one case of error reporting was special cased, so it > could report a lookup error for a specific key when dumping the map > element. What the code forgot to do is to wrap the key and value keys > into a JSON object, so an example output of pretty JSON dump of a > sockhash map (which does not support looking up its values) is: > > [ > "key": ["0x0a","0x41","0x00","0x02","0x1f","0x78","0x00","0x00" > ], > "value": { > "error": "Operation not supported" > }, > "key": ["0x0a","0x41","0x00","0x02","0x1f","0x78","0x00","0x01" > ], > "value": { > "error": "Operation not supported" > } > ] > > Note the key-value pairs inside the toplevel array. They should be > wrapped inside a JSON object, otherwise it is an invalid JSON. This > commit fixes this, so the output now is: > > [{ > "key": ["0x0a","0x41","0x00","0x02","0x1f","0x78","0x00","0x00" > ], > "value": { > "error": "Operation not supported" > } > },{ > "key": ["0x0a","0x41","0x00","0x02","0x1f","0x78","0x00","0x01" > ], > "value": { > "error": "Operation not supported" > } > } > ] > > Fixes: 9a5ab8bf1d6d ("tools: bpftool: turn err() and info() macros into functions") > Cc: Quentin Monnet > Signed-off-by: Krzesimir Nowak Thanks for the fix! Quentin