Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7211335ybi; Wed, 5 Jun 2019 13:13:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQiugM427fMO/5cq/ZZs4DCeemcO7TgR9tIWtKHdDHmTk0tjYZ196/ox6XSjARxV7AeQ0F X-Received: by 2002:aa7:9825:: with SMTP id q5mr10696497pfl.140.1559765628452; Wed, 05 Jun 2019 13:13:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559765628; cv=none; d=google.com; s=arc-20160816; b=VbgEnHcjQxhNuNpRZ48xuk+Ce8KsjRzt+6wAFNeQFrmToAxc4velHJ0USOQlZFK0qy bjsmADkbXXwFonHTwO3bvgbVfhXA3OXBBShz/vhd/aYeQ28FQxuUO6jpIKhIKp3+Yz8d uHDoLfJQ6b6mMVJkO9hQCv08IRJWVt6TTxacHopubdDeQ3jPOFutUhbbOVIC/Wrrfqrm aJFqgnBkqufOp4lM3g25vW7BcOorFhupXOgM7gKGPsOyrtHYWNIRyfBjx0WGA5AfQIrA Ko9C6W5HpXgUQZhzf1oPbyiQZWY0XkisnEZIcxPfqMxHzU2yY+RtnFDdHobfdfD8MRQ+ qeAg== 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; bh=ZHRhRoWj/v/4eIwJF7zpdmIdGJ13OSu15AyGhpcVMBc=; b=bAzIEr1yPrK7GERCQ6kM2tHotH5qaRZLeYHGlQKIrvYNjTJWL/lWZ5wPaioY4Sx21T SLV5juwsvaOxdfBDFI8clflOxq1HHLrU3MynN1n67Zftbxo8qndDlyCK30uM5W1jpsrU nlOdr5zFCBRMXig4vxmTBlHV+OEY0riQdE7Bmzv4Nr/uhL57p/Cf+X5E7ej/vlT+UvLU mJr4VeMrbAb3/DrPHfQyRwAlO8lmz0PRZE/vRJ0VGWaqkynrNUOFY2cia+ZjdDc/jTfb gpUtMzVhVs4MtBt/RAIaW1r8bIqRb4yd3xbGp3HoIgj/eRccNQBQp8uTYhWb/7OwWoQF m2Og== ARC-Authentication-Results: i=1; mx.google.com; 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 r3si29316088plb.14.2019.06.05.13.13.30; Wed, 05 Jun 2019 13:13:48 -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; 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 S1726649AbfFEUKf (ORCPT + 99 others); Wed, 5 Jun 2019 16:10:35 -0400 Received: from www62.your-server.de ([213.133.104.62]:36612 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726501AbfFEUKf (ORCPT ); Wed, 5 Jun 2019 16:10:35 -0400 Received: from [78.46.172.3] (helo=sslproxy06.your-server.de) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1hYcEx-0002kS-Qb; Wed, 05 Jun 2019 22:10:31 +0200 Received: from [178.197.249.21] (helo=linux.home) by sslproxy06.your-server.de with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1hYcEx-000Xli-JO; Wed, 05 Jun 2019 22:10:31 +0200 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?= , Quentin Monnet , Alexei Starovoitov , 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: Daniel Borkmann Message-ID: Date: Wed, 5 Jun 2019 22:10:30 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.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 X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.100.3/25471/Wed Jun 5 10:12:21 2019) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/05/2019 09:17 PM, Krzesimir Nowak wrote: > 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 Applied, thanks!