From patchwork Thu Dec 1 21:41:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonard Crestez X-Patchwork-Id: 13061841 X-Patchwork-Delegate: dsahern@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A072DC4321E for ; Thu, 1 Dec 2022 21:41:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230328AbiLAVlV (ORCPT ); Thu, 1 Dec 2022 16:41:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229755AbiLAVlU (ORCPT ); Thu, 1 Dec 2022 16:41:20 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76CE9A85CB for ; Thu, 1 Dec 2022 13:41:19 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id h12so4916601wrv.10 for ; Thu, 01 Dec 2022 13:41:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ITfVqjrQNG7fWql8z6Uk87ufUs8LJ0NiEA7WM1x2p2Q=; b=gWbN/olPmiW0rZbS28dI75pNo1bYaNNwqLxqvpdhwOvMeoTem7t8JwO0A/0tWd7x/l n88E4mIfsfBn39yHJAKfkL/XoOb/V+0pwvWCJHdA4T5cb3aWM74Z5/rPh5QeJQB6qRXG B7FQ4jIUTiKW3VfpDA1VGcVl6ytbkP2DanSwh2onBvR/b8/lcmYcXD5VYwGjix6WcEIU XrxQhOgFNhNSSEQJb3MSK4hvsIdFl9b5Axt7BErjE6yjN6a5vNkoH6xo8knuUqnFXFq3 2TRhu3vpBXRLvnd97jWFBY1IFdgAf3f1ch4pDJfkelplLkC7MBO9jj+1RvMCzY6oAgOS Axcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ITfVqjrQNG7fWql8z6Uk87ufUs8LJ0NiEA7WM1x2p2Q=; b=wZeRz252gocMQ6RUbGMFMOpWRZtEOOe2otBrJBgM+oUTS7V00Z63qvRmzZ1AohdF1u yYuJ/e2IzUlzRQLvksRk4yVIj1OZXQmI4xEs6/EJciJVkKgyJXo3kWOGL6cfWaKAk02W zENQm/MxooicYkr1nO9nzmPEBTN2htqv2UDW4fhheQlpiym01GYjYgRchDlU2ZQppews WKTIb3zWOQ3cnWDsCZvy7wFRw/B9mzllAnc+6l6xVLFphj/9jEuy9pgiED1OCyojEP+o xRIFPiI0v1eaurio0LYH+VMjQh81taX914E5aJHrkBg6okucpjL16wEyGuhPGYnxjdaB SHWw== X-Gm-Message-State: ANoB5pkvp1JDFruQqmuHI4+SHcYOyMhHz+iTriOr1Hno9HAj14KBxQC8 /RJ40RZSUjTJLlMeBWUVWkRuHDysDQg= X-Google-Smtp-Source: AA0mqf73+c9FkVjH0UZsnEYwwG9uGoJu/+R3/PQEp2r8aAlec1TKvHnygo2tyR3cIYGM1mJBQZWmWg== X-Received: by 2002:adf:f011:0:b0:241:c78c:3671 with SMTP id j17-20020adff011000000b00241c78c3671mr36148944wro.129.1669930877766; Thu, 01 Dec 2022 13:41:17 -0800 (PST) Received: from localhost.localdomain ([2a04:241e:502:a080:d550:2713:91f3:c113]) by smtp.gmail.com with ESMTPSA id i2-20020adff302000000b002421a8f4fa6sm5294662wro.92.2022.12.01.13.41.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 13:41:17 -0800 (PST) From: Leonard Crestez To: Stephen Hemminger , David Ahern Cc: netdev@vger.kernel.org Subject: [PATCH iproute2 1/2] ip neigh: Support --json on ip neigh get Date: Thu, 1 Dec 2022 23:41:05 +0200 Message-Id: <63b6585719b0307d81191bbcf5228b94f81c112f.1669930736.git.cdleonard@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com The ip neigh command supports --json for "list" but not for "get". Add json support for the "get" command so that it's possible to fetch information about specific neighbors without regular expressions. Fixes: aac7f725fa46 ("ipneigh: add color and json support") Signed-off-by: Leonard Crestez --- ip/ipneigh.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ip/ipneigh.c b/ip/ipneigh.c index 61b0a4a22cbf..0cf7bb60553a 100644 --- a/ip/ipneigh.c +++ b/ip/ipneigh.c @@ -727,16 +727,19 @@ static int ipneigh_get(int argc, char **argv) if (rtnl_talk(&rth, &req.n, &answer) < 0) return -2; ipneigh_reset_filter(0); + new_json_obj(json); if (print_neigh(answer, stdout) < 0) { fprintf(stderr, "An error :-)\n"); free(answer); + delete_json_obj(); return -1; } free(answer); + delete_json_obj(); return 0; } int do_ipneigh(int argc, char **argv) From patchwork Thu Dec 1 21:41:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonard Crestez X-Patchwork-Id: 13061842 X-Patchwork-Delegate: dsahern@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CC3AC4321E for ; Thu, 1 Dec 2022 21:41:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230385AbiLAVl0 (ORCPT ); Thu, 1 Dec 2022 16:41:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229755AbiLAVlX (ORCPT ); Thu, 1 Dec 2022 16:41:23 -0500 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37345B0DCA for ; Thu, 1 Dec 2022 13:41:20 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id w15so4940670wrl.9 for ; Thu, 01 Dec 2022 13:41:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iQz5pBpkO8xYdbER52V8d8Wv1i3SDO8OvdHRuU1DAh4=; b=f79us2JwmwXIFRK9MEOMvleB1WwzxrgappbJLjb+AGEfgJ0P38UXpTsZJ1Ci9xr69Z f0B6i41LnKXX7XYsnYhRtiQ44guT/F3am5mw6r03TbJvFsCSoAlUojzTwjpl6IcDd2JT j/KZw6tMeTV2l0rjLSSjYD6wvQszkzXp1T2JIQgVVFYwxNsQ2f8tOyaANpptddaQ9iM6 s4H5CFXpjJ4FvD0ko9xzTECLKxURmn0MmNuTwj8jFEjOkru2PzLpTIbeSvC5bmqxnu5h pc/qZtXUHEx0q2K46BlbvKbZQsjy/N7Llw5/VQv+OOqI1FUZXym1YniRnzs1oIRMC+TA bekw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iQz5pBpkO8xYdbER52V8d8Wv1i3SDO8OvdHRuU1DAh4=; b=1hJjjPmiomM/Sz2+cGXedFdmu7zexydRKF8UScXtFwBMAjAaTLYrtIEZdKus8MUTRx FM/0Tqo9OObrTill+KBopRjsSVkJfl2HEtJSebhHOPiVAdsLhRHOdms7Zphr1IFJi/P9 n01luIQktaCbOHrqUDv21Ta8nGVfUBAHlKoVt0yt+dogdyGDIptXCNvHpm2PBRYV4gEf lLFfFdYh0w1dw+8KGU6YWmzBQHmQuO5uP6Dioy54N/OuwhH8KlImyA085QbOzvx639gh hDWdaKra+Mh2A7y5mgT7WO9t613w9DxcNbi/8D+TxBkXh2vFimLHmcRDq7nXji8hNXmf 7xIw== X-Gm-Message-State: ANoB5pmfYM2rOqDnAOrQs9zzaKipv94O/njS9+5cukHMF27G47kOM3IH 0ydZwDPav2o5IO2ja19EKHgj3qVC6Qo= X-Google-Smtp-Source: AA0mqf7vjVWZvwCbKLxqi1qBrpYZ5oAuCC5KkK39EZwxz2r5YWoIppOVItJo/mHm3+UsG++bSW0NwA== X-Received: by 2002:a5d:56c9:0:b0:236:5d8b:dd9c with SMTP id m9-20020a5d56c9000000b002365d8bdd9cmr32850647wrw.283.1669930878840; Thu, 01 Dec 2022 13:41:18 -0800 (PST) Received: from localhost.localdomain ([2a04:241e:502:a080:d550:2713:91f3:c113]) by smtp.gmail.com with ESMTPSA id i2-20020adff302000000b002421a8f4fa6sm5294662wro.92.2022.12.01.13.41.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 13:41:18 -0800 (PST) From: Leonard Crestez To: Stephen Hemminger , David Ahern Cc: netdev@vger.kernel.org Subject: [PATCH iproute2 2/2] testsuite: Add test for ip --json neigh get Date: Thu, 1 Dec 2022 23:41:06 +0200 Message-Id: <9b167a5bf910676cdae24edeb47aa77c2f312476.1669930736.git.cdleonard@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <63b6585719b0307d81191bbcf5228b94f81c112f.1669930736.git.cdleonard@gmail.com> References: <63b6585719b0307d81191bbcf5228b94f81c112f.1669930736.git.cdleonard@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com Signed-off-by: Leonard Crestez --- testsuite/tests/ip/neigh/basic.t | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100755 testsuite/tests/ip/neigh/basic.t diff --git a/testsuite/tests/ip/neigh/basic.t b/testsuite/tests/ip/neigh/basic.t new file mode 100755 index 000000000000..9c13c8ef4b25 --- /dev/null +++ b/testsuite/tests/ip/neigh/basic.t @@ -0,0 +1,13 @@ +#!/bin/sh + +. lib/generic.sh + +ts_log "[Testing add/get neigh]" + +NEW_DEV="$(rand_dev)" +ts_ip "$0" "Add $NEW_DEV dummy interface" link add dev $NEW_DEV type dummy +ts_ip "$0" "Add $NEW_DEV neighbor 192.0.2.2 " neigh add 192.0.2.2 lladdr 02:00:00:00:00:01 dev $NEW_DEV +ts_ip "$0" "List neighbors " neigh list +test_on '02:00:00:00:00:01' +ts_ip "$0" "Get $NEW_DEV neighbor 192.0.2.2 " --json neigh get 192.0.2.2 dev $NEW_DEV +test_on '"lladdr":"02:00:00:00:00:01"'