From patchwork Tue Mar 12 22:53:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 13590752 X-Patchwork-Delegate: stephen@networkplumber.org Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5D7D2B2D7 for ; Tue, 12 Mar 2024 22:55:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710284109; cv=none; b=EbJjpq9eoXPkxVKTyjcUXK4519/GZqKOUEPWeKyX0pNvdXYGNnHP6KrhqTeQUXbCzaW+QTXsWaL2XsAv9ZAw1F8SgGbHEQfBgEkJRolOWJ7Ktil/FuEzqQGwYRarj4uzFrMzZwqOmWYVVh/4jIEZYD8639L8fPhV6/0vyUGL4X4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710284109; c=relaxed/simple; bh=D17CfyLCkdZYZDTyILrmsyr0JuPNALsjc5fjrsMLRX8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YBomzX6s0kBuUKykTmo7rQ3+AWmtMWBvahMXf2urBPfZVj1iVhmwZY5aeEaN/y7NPs5oxbitk41d+6Kw2JHZ26ebnXeQI9zpttDUJzfldJ6T0iGk4Y0GoEWRjJuWLlkSegtDIkYIw1EeznzXwfaOmi7cYjPxhhpqRGL5MM92kPk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=networkplumber.org; spf=pass smtp.mailfrom=networkplumber.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20230601.gappssmtp.com header.i=@networkplumber-org.20230601.gappssmtp.com header.b=IXu/nBnr; arc=none smtp.client-ip=209.85.210.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20230601.gappssmtp.com header.i=@networkplumber-org.20230601.gappssmtp.com header.b="IXu/nBnr" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-6e5eaf5bb3eso4835351b3a.3 for ; Tue, 12 Mar 2024 15:55:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1710284107; x=1710888907; darn=vger.kernel.org; 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=VW6qWmOMedufGlnAxm3HMyqlGBbwwKJdDG+kzVaEuHA=; b=IXu/nBnrOMlwLR75FodGPLr6uIIOu0YrRuM0OhhVHw7vhkl35D9WSb9rgsIt8dzJrG Zk3AyKOT/bdjlwnsMYavAlZjYPt5CJDcP2yJkwG4+SS1w0WamiA+PMT9sn6C/aq1VRbu NbdpmwEN8BgEeUG6PhMLU1k2VqXuzrmsBkifusl3xOic4cPifOc0uG3ZYp09gvDdXsuH no8+7yT//FBT3EHx6jZn0ltlB2bsi9HfOrnqp3YHfAYcLNhRM58w9mMEE1Mr4Zu5VqNH yUMSj/kdniLdNnarEgTl6GvNv0QT4hFZhpTK98aw/S3u60w362BS9kSETCVpKeeQ8Nl6 DSsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710284107; x=1710888907; 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=VW6qWmOMedufGlnAxm3HMyqlGBbwwKJdDG+kzVaEuHA=; b=j5+sVQqfKucAeYPSR/rJSvqaKnunu0Nh4xgwaT6ICLt1+UcRuJrOnWgubBAvbp6QN0 uZROroBvzQr2nLuwqYJ3gusU47jfQeDtkWmSkunTuClYzgQxcIZRRXrLxR+qLJCkfbqx g9uWF5hHpzkciFY/Zd9fBZjOAfW0ZSGaJoFjY1Ck30fJt3gx8Qee5SLgcheAo5m7AVeX H3Qv1ERB/fu4nKvmtN6szEWKAnN2LSEEusnQEZ2ISFquKQ12J1mmIb23vmPpyHKfDoP+ XuVczXQGGSpHY6/oMmbnLthPySxXfpUh8KphRdGlNKNRLLQQXWki5NXzAs0qVzuZWqiN cqhg== X-Gm-Message-State: AOJu0Yy9z1vB4loFklMPODwqLK9TvzthPxt0Q0V6/JEvFEqHhM2AXDSk IiKxsXwZIlRxIjYsj1p1/BZm8GWMbxkFWZ0MeMuiyDxspSEj/hoOuoL2jvNVwe0iVKPOm+sDbIQ b X-Google-Smtp-Source: AGHT+IFPmg+qYMe3b0ngt2qfACkX16cIMDV8IKatl5m1ItbFPlwXb5W7LgDzYxh10iTpvMcv7Ls5pg== X-Received: by 2002:a05:6a20:daa0:b0:1a1:7257:6302 with SMTP id iy32-20020a056a20daa000b001a172576302mr3537513pzb.4.1710284107012; Tue, 12 Mar 2024 15:55:07 -0700 (PDT) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id y8-20020a17090a8b0800b0029bb8ebdc23sm98947pjn.37.2024.03.12.15.55.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 15:55:06 -0700 (PDT) From: Stephen Hemminger To: netdev@vger.kernel.org Cc: Stephen Hemminger Subject: [PATCH iproute2 1/5] tc: support JSON for legacy stats Date: Tue, 12 Mar 2024 15:53:28 -0700 Message-ID: <20240312225456.87937-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240312225456.87937-1-stephen@networkplumber.org> References: <20240312225456.87937-1-stephen@networkplumber.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: dsahern@gmail.com The extended stats already supported JSON output, add to the legacy stats as well. Signed-off-by: Stephen Hemminger --- tc/tc_util.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/tc/tc_util.c b/tc/tc_util.c index aa7cf60faa6d..615e3e9cc377 100644 --- a/tc/tc_util.c +++ b/tc/tc_util.c @@ -804,28 +804,30 @@ void print_tcstats_attr(FILE *fp, struct rtattr *tb[], const char *prefix, memcpy(&st, RTA_DATA(tb[TCA_STATS]), MIN(RTA_PAYLOAD(tb[TCA_STATS]), sizeof(st))); - fprintf(fp, - "%sSent %llu bytes %u pkts (dropped %u, overlimits %u) ", - prefix, (unsigned long long)st.bytes, - st.packets, st.drops, st.overlimits); + print_string(PRINT_FP, NULL, "%s", prefix); + print_lluint(PRINT_ANY, "bytes", "Sent %llu bytes", + (unsigned long long)st.bytes); + print_uint(PRINT_ANY, "packets", " %u pkts", st.packets); + print_uint(PRINT_ANY, "dropped", " (dropped %u,", st.drops); + print_uint(PRINT_ANY, "overlimits", " overlimits %u) ", st.overlimits); if (st.bps || st.pps || st.qlen || st.backlog) { - fprintf(fp, "\n%s", prefix); + print_nl(); + print_string(PRINT_FP, NULL, "%s", prefix); + if (st.bps || st.pps) { - fprintf(fp, "rate "); + print_string(PRINT_FP, NULL, "rate ", NULL); if (st.bps) - tc_print_rate(PRINT_FP, NULL, "%s ", - st.bps); + tc_print_rate(PRINT_ANY, "rate", "%s ", st.bps); if (st.pps) - fprintf(fp, "%upps ", st.pps); + print_uint(PRINT_ANY, "pps", "%upps ", st.pps); } if (st.qlen || st.backlog) { - fprintf(fp, "backlog "); + print_string(PRINT_FP, NULL, "backlog ", NULL); if (st.backlog) - print_size(PRINT_FP, NULL, "%s ", - st.backlog); + print_size(PRINT_ANY, "backlog", "%s ", st.backlog); if (st.qlen) - fprintf(fp, "%up ", st.qlen); + print_uint(PRINT_ANY, "qlen", "%up ", st.qlen); } } } From patchwork Tue Mar 12 22:53:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 13590753 X-Patchwork-Delegate: stephen@networkplumber.org Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 571602E41A for ; Tue, 12 Mar 2024 22:55:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710284110; cv=none; b=AZ3t6clchcFg2iR+XkNCShMpyGEPra7Kk/dMidDPcoTo569cogQCQIC7GIBQR9i/wTuAHZIyH77TTdAIOmpX/sxKn1lIsYqZfI+LRZ95lwpvXiRbkehQl1mge5xzUq9/dliaGvfhpNkhIaMHpayshk9gD19RhxURHtLjc/fh2fM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710284110; c=relaxed/simple; bh=39RRfqgMLeZYg0ZW+kNWd5tYfFckssYC0rGgnCr6lsY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Mur2ljJbk5wfQIHwo0o2vZ8mKnzLrMHSqQpA4FSn0wXsvwGf8IoZAHUp1/uHujYVXFYLHhuJ29WhEtSHjPiqvSErZTsoLWhixQ//FPX1yI1skmrFnEpZ+Xzu9vguoiCbJ+bBZH2/BOxDg/+RK5mnJnThjMUy+hneDdeh9q2DFG4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=networkplumber.org; spf=pass smtp.mailfrom=networkplumber.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20230601.gappssmtp.com header.i=@networkplumber-org.20230601.gappssmtp.com header.b=ZpAaUSoX; arc=none smtp.client-ip=209.85.215.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20230601.gappssmtp.com header.i=@networkplumber-org.20230601.gappssmtp.com header.b="ZpAaUSoX" Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-5ce6b5e3c4eso3100005a12.2 for ; Tue, 12 Mar 2024 15:55:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1710284107; x=1710888907; darn=vger.kernel.org; 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=loW8beBfYpw+JBNitxFB4W2XmqM5hYVgSxYhpCG5shA=; b=ZpAaUSoXXB7XJ/6WflswmZTw4gjv5xGuZZcnTi66kW0Dh8dMI8xwJI/gS4jaT0GrNG b2zxGx9YWIUB+loLTVVNStUInbH/HawtdrMVO601v7W7kRXd5S/+K2ESLv6P2XchFX5j cEpOG/F08XZJPiYJThUofqGGcnXRzaCGw6C0TnEIO+WOsiHMLvUfl4UfL5KfbXvleuGA jb29/26S8reMmS3IvMmYg7Yu+ER/poyB5XE0xgL05a+Aisw/lpJNBw1Dgc5FCrM4HTNH fDndKhCjCkc8E/X/rMcwSAKxUZLgrNYZVo8B1Uzkbi+zNl91tfJ4G7sUs6UiYt1alzib 4jSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710284107; x=1710888907; 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=loW8beBfYpw+JBNitxFB4W2XmqM5hYVgSxYhpCG5shA=; b=hjzGO1ryEB59h2KD4grnEeL028U8VSj5rM2wOnuRpw7z53AY2NnJ1ANRm6oSoG01Ig Ba3N/cw3/BdxDgqCppCcp3f20rzYqxjd0fIlqg/i9leCFEe2q2W6XehbcS87r/0Y3p08 c6okm5xqS4Ppuks2e7raPkUodQqZzPl9deLJZ4T/neQbzhCM7UNmsqMltxfZbtn6L9rV 9zEDiPab/eDuhk+wrFY3/Ml/Zdrw3+xP7vGQnvEXWxLACLdPgZy5ggA3ROk+pR+WAhKV rkWNbzU5PMh68pnGPNc7Mb+TyKTO/rOHS3mTfzYxIaTTWPMwvuiul5ehTm8Cm4dW9BQt bT9A== X-Gm-Message-State: AOJu0YzZ8a8OAFsA8EEsbrGaT1d1Tr5oNdHd93L8LL2rfWc8Kx+K8259 KeGnrdBtms5BqdlazYJOGU5FUybT9WjWO3HCJNBdI6uYU7rgAmujtnA33H6EcxcTAjJPvKlsKoh Z X-Google-Smtp-Source: AGHT+IFZryQu9zdnC3myVX8W3DxCksm+844PkPplNuPc+cZpckGH0f0nHE2WFTZv3/yd1u8P/bK0nA== X-Received: by 2002:a17:90a:b392:b0:29b:22f9:c8e6 with SMTP id e18-20020a17090ab39200b0029b22f9c8e6mr7642778pjr.19.1710284107703; Tue, 12 Mar 2024 15:55:07 -0700 (PDT) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id y8-20020a17090a8b0800b0029bb8ebdc23sm98947pjn.37.2024.03.12.15.55.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 15:55:07 -0700 (PDT) From: Stephen Hemminger To: netdev@vger.kernel.org Cc: Stephen Hemminger Subject: [PATCH iproute2 2/5] pedit: log errors to stderr Date: Tue, 12 Mar 2024 15:53:29 -0700 Message-ID: <20240312225456.87937-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240312225456.87937-1-stephen@networkplumber.org> References: <20240312225456.87937-1-stephen@networkplumber.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: dsahern@gmail.com The errors should bo to stderr, not to stdout. Signed-off-by: Stephen Hemminger --- tc/m_pedit.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tc/m_pedit.c b/tc/m_pedit.c index 32f03415d61c..f954221da393 100644 --- a/tc/m_pedit.c +++ b/tc/m_pedit.c @@ -771,20 +771,20 @@ static int print_pedit(struct action_util *au, FILE *f, struct rtattr *arg) sel = RTA_DATA(tb[TCA_PEDIT_PARMS_EX]); if (!tb[TCA_PEDIT_KEYS_EX]) { - fprintf(f, "Netlink error\n"); + fprintf(stderr, "Netlink error\n"); return -1; } keys_ex = calloc(sel->nkeys, sizeof(*keys_ex)); if (!keys_ex) { - fprintf(f, "Out of memory\n"); + fprintf(stderr, "Out of memory\n"); return -1; } err = pedit_keys_ex_getattr(tb[TCA_PEDIT_KEYS_EX], keys_ex, sel->nkeys); if (err) { - fprintf(f, "Netlink error\n"); + fprintf(stderr, "Netlink error\n"); free(keys_ex); return -1; From patchwork Tue Mar 12 22:53:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 13590754 X-Patchwork-Delegate: stephen@networkplumber.org Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 37FFD2EAF7 for ; Tue, 12 Mar 2024 22:55:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710284110; cv=none; b=K300+nP5LDkwdBNjipnAdOHSPpUhLsi3PnD6MFzJQrOAMTMsrASAyW6qRXPt0vnPOXkKTukVcRqDMubLMWhbdHXOoBVF5PbkTYavgIsXfbJCh9f77lreCt0gGkOMfxOv3rtjlstACkO7YA3mONv4Wss1gy8VVbnm94Syz7+Y31s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710284110; c=relaxed/simple; bh=svRJEBM+C3QE064pQ/pEML8YbGL/qqMDURCpWAG8Mz4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dDD8gt2z+d4NLTqg7HrFaLOlK0FA7m17ZTh0aER77LDYDK8O6TDZcUa5TwvuNJ4qSR1QACx9HdEIYaUAYUJN4ZYS8ELoU4TBC5B7ErmGEXQpGVbTZxqoLQDEER4r5jyfCrY7ljER7vcektGp1m0AxhfgZLxJRgL6sbabWi7ybS0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=networkplumber.org; spf=pass smtp.mailfrom=networkplumber.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20230601.gappssmtp.com header.i=@networkplumber-org.20230601.gappssmtp.com header.b=gLZL5uqb; arc=none smtp.client-ip=209.85.216.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20230601.gappssmtp.com header.i=@networkplumber-org.20230601.gappssmtp.com header.b="gLZL5uqb" Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-29c09ee1bceso2036875a91.2 for ; Tue, 12 Mar 2024 15:55:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1710284108; x=1710888908; darn=vger.kernel.org; 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=/Ib/pb+kLOd5ocoVhOz3+USGBF+/XkIcYOjmle2ItM4=; b=gLZL5uqbxtOYm+eQxnqUzQG7w7gvwiPIw9xYmQww2PSMKGvyoOrMuF9eZQhHh1Jp/K jREAEf+Kro5gRL9nW2IgP6LA/6u15WmepjYnkjeK3fVW+60xk6ROEtR1QH46PISaDyww mi3DaZjymviouq7+E601aJqeNYebPORhcnzIxHiYPK3Q9nvVzndGU74hbl9FTuwxGoVs 4XX1FdNJpc31wG5ONg/Jdh5kSPkXvkbeu6ucioqj/YQ7wJNPOK6tLGU2LtWt2nLFCvvr ORps+q5dGCbFwkEYU1U92OJFf5fC2JHuvuljuTDlEfyMbrBajBfGO0al9DjmPA09SlO7 L3WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710284108; x=1710888908; 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=/Ib/pb+kLOd5ocoVhOz3+USGBF+/XkIcYOjmle2ItM4=; b=aelo9Zb6KRMopSEg9+2LzOYXt/cMi4FqAKWKePXtmDM1KaR7D4K9GcZYMGkqlfoMEM v2E/KlR/OCrUF1XsHS7CqaASJBUbqKIRtNKgNhxc6crwrdaRHrJlFOAVHX+pgfYGBKuu UQd2k9P/4+z4yJLs1ZOnUcoaRLqD898KBMZepW5eKp3vYjWdyPzRfX9mNy7vMAm+0g1q 6dt1vvALYIy0trvwWZsInmSIGZc6voiKOOTbbR9LbiKapFFPs7BHiGFQR8R2GSYQ8fpq UAEVD+Si2HSqjx71paEIod3XzBPWTml5pN8yp00zEim/3atL7jBtgmHeGv6oVYkKnEVg B8NA== X-Gm-Message-State: AOJu0YyDfETlsxeixgfBHcK65ZWb83h+3j0VIBqa5MI+NWj/yllNeKVj 0onJqdMEOmyB1ypGWPHRlUVNEDOgMy1fdEfyh//QG10OMna4iFMx7o39JTg+ThXB6uoYZbMGSp/ v X-Google-Smtp-Source: AGHT+IGeOTf6zq8oES+yQxInSoGIoS7cLEMqBTBkHF+luuaklFfFm3Oe4AZblVJUknzT5toGmlmsTQ== X-Received: by 2002:a17:90b:4d90:b0:29c:3af5:e274 with SMTP id oj16-20020a17090b4d9000b0029c3af5e274mr2710931pjb.28.1710284108490; Tue, 12 Mar 2024 15:55:08 -0700 (PDT) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id y8-20020a17090a8b0800b0029bb8ebdc23sm98947pjn.37.2024.03.12.15.55.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 15:55:08 -0700 (PDT) From: Stephen Hemminger To: netdev@vger.kernel.org Cc: Stephen Hemminger Subject: [PATCH iproute2 3/5] skbmod: support json in print Date: Tue, 12 Mar 2024 15:53:30 -0700 Message-ID: <20240312225456.87937-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240312225456.87937-1-stephen@networkplumber.org> References: <20240312225456.87937-1-stephen@networkplumber.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: dsahern@gmail.com This tc action never got jsonized. Signed-off-by: Stephen Hemminger --- tc/m_skbmod.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/tc/m_skbmod.c b/tc/m_skbmod.c index b1c8d00dfe47..87de59cf60bb 100644 --- a/tc/m_skbmod.c +++ b/tc/m_skbmod.c @@ -177,43 +177,48 @@ static int print_skbmod(struct action_util *au, FILE *f, struct rtattr *arg) p = RTA_DATA(tb[TCA_SKBMOD_PARMS]); - fprintf(f, "skbmod "); + print_string(PRINT_FP, NULL, "skbmod ", NULL); print_action_control(f, "", p->action, " "); if (tb[TCA_SKBMOD_ETYPE]) { skbmod_etype = rta_getattr_u16(tb[TCA_SKBMOD_ETYPE]); has_optional = 1; - fprintf(f, "set etype 0x%X ", skbmod_etype); + print_0xhex(PRINT_ANY, "etype", "set etype 0x%X ", skbmod_etype); } if (has_optional) - fprintf(f, "\n\t "); + print_string(PRINT_FP, NULL, "%s\t ", _SL_); if (tb[TCA_SKBMOD_DMAC]) { has_optional = 1; - fprintf(f, "set dmac %s ", - ll_addr_n2a(RTA_DATA(tb[TCA_SKBMOD_DMAC]), - RTA_PAYLOAD(tb[TCA_SKBMOD_DMAC]), 0, b1, - sizeof(b1))); + print_color_string(PRINT_ANY, COLOR_MAC, "dmac", + "set dmac %s ", + ll_addr_n2a(RTA_DATA(tb[TCA_SKBMOD_DMAC]), + RTA_PAYLOAD(tb[TCA_SKBMOD_DMAC]), 0, b1, + sizeof(b1))); } if (tb[TCA_SKBMOD_SMAC]) { has_optional = 1; - fprintf(f, "set smac %s ", - ll_addr_n2a(RTA_DATA(tb[TCA_SKBMOD_SMAC]), - RTA_PAYLOAD(tb[TCA_SKBMOD_SMAC]), 0, b2, - sizeof(b2))); + print_color_string(PRINT_ANY, COLOR_MAC, "smac", + "set smac %s ", + ll_addr_n2a(RTA_DATA(tb[TCA_SKBMOD_SMAC]), + RTA_PAYLOAD(tb[TCA_SKBMOD_SMAC]), 0, b2, + sizeof(b2))); } if (p->flags & SKBMOD_F_SWAPMAC) - fprintf(f, "swap mac "); + print_null(PRINT_ANY, "swapmac", "swap mac ", NULL); if (p->flags & SKBMOD_F_ECN) - fprintf(f, "ecn "); + print_null(PRINT_ANY, "ecn", "ecn ", NULL); + + print_nl(); + print_uint(PRINT_ANY, "index", "\t index %u ", p->index); + print_int(PRINT_ANY, "ref", "ref %d ", p->refcnt); + print_int(PRINT_ANY, "bind", "bind %d", p->bindcnt); - fprintf(f, "\n\t index %u ref %d bind %d", p->index, p->refcnt, - p->bindcnt); if (show_stats) { if (tb[TCA_SKBMOD_TM]) { struct tcf_t *tm = RTA_DATA(tb[TCA_SKBMOD_TM]); @@ -222,7 +227,7 @@ static int print_skbmod(struct action_util *au, FILE *f, struct rtattr *arg) } } - fprintf(f, "\n"); + print_string(PRINT_FP, NULL, "\n", NULL); return 0; } From patchwork Tue Mar 12 22:53:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 13590755 X-Patchwork-Delegate: stephen@networkplumber.org Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF3603FE46 for ; Tue, 12 Mar 2024 22:55:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710284111; cv=none; b=kZHXXEogkEOgSwDl58qDac7sZ3Kt2JUM2gUf9xBrUQRfOLT+EZCwPy39+KgWcLaAhvqp7DNzXFjqCVoiREzk8ApWtl4k2DSP/DDhZmbw6rkhnj019xIWFoQNK1+pCQNuknQ+DYVTpSLUwWdff1pTPl2PmoRwqDRwFozDG0kMpKw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710284111; c=relaxed/simple; bh=mab3TgW/hRTopZU2/0VsNLwuHEF/5We932m7lu+Uiac=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Lyr+fGafTTEVgcnIYCdKvtUvU+0PRpal7eEhvIymoHLJrgvdhjCICz9ZO3MxU+H2HNv4piUByUSkiI6kMULKs1Rf83JC++myHj1nkXBXT7+irL2/R7YDOeVMCG08Pt3hgGnYuLZwlkMhXanxYZX3oDFWRo4DH1DU2aWDawmgCKA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=networkplumber.org; spf=pass smtp.mailfrom=networkplumber.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20230601.gappssmtp.com header.i=@networkplumber-org.20230601.gappssmtp.com header.b=zGXkfY7w; arc=none smtp.client-ip=209.85.216.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20230601.gappssmtp.com header.i=@networkplumber-org.20230601.gappssmtp.com header.b="zGXkfY7w" Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-29c16b324ecso1810235a91.3 for ; Tue, 12 Mar 2024 15:55:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1710284109; x=1710888909; darn=vger.kernel.org; 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=pMQfhWOplgYjPLGoDX87ljiu23hmeS533ddimQcO6Po=; b=zGXkfY7wE+AmqKYB7PU5Eu5Ogzgru71/UJKujgXD/DfE6wQqGFswMNOYDZiqtQKOhd e+DqLl4xih70NNh6/mIsZoGDRkyhlQZ8XY7RGW1JGsjLRIadasRwBLAEE9XnWshGZ++7 2GHGw//MXUgh/Hr5gg9BCjSEhS6Tziqfnfd8GGVuC13yvxRTtNknBg+aQgYr33JaTJ8j QZaTg0QhHnbuP5WV1NKNPuPEQGgnQPGosUSgzP3EM3S6wfGlmS7XfaDrbSRMlpPpaVSU GfH/9DJJpZIZ/hZXvmDRn91P7dN1fzRMK9oZdO77Jpf0IvekDkmZa2eui1j/YN33uc0y ogmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710284109; x=1710888909; 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=pMQfhWOplgYjPLGoDX87ljiu23hmeS533ddimQcO6Po=; b=IxMFd+RZ9IhG1K6l8cM2nxDAxlBGt6M3up3Zw4jzJbOrR4JOKFcSWhCjbUzsVlSmxe 5X+xVSvn2kummALrp1A+J8Op2CjtJO2yulbS9C1NGpuoSLFBK4Kx4NDQKwfVthH9bNfu 2XseVcoOTVrkDxVj/0BDSTCNnIFhI9iQ/fOL/rBuhduedvNFRb7sW4nWGVhQXfzyIvzq wSkfgUSMblGeT4D6aJGotxM3s+V247Sawmlubm0awuSKdnjQMr06CCdR96+CT0gBS3kC pCH1/l3ulDiJVK4veDTV5vfRSDB1f7Be7YcX0pJsoxyGtzb+Nf5P6+260o8RUJJ7KK1k c/SQ== X-Gm-Message-State: AOJu0YyR7vBEou4WtnGVs9FTRDjSdBMNiSur6QaRUrNFe5mapP2ygysr egpwbXpi/Z+B+Jy1ru73zn7k88IfGqwckgTdVbOKUBkZoV3zeyYltP9TaSlEm9VSXAiq5gORoHo + X-Google-Smtp-Source: AGHT+IEj5b54g9Jef50ylNe5CagmnL4WcXXK4+cLnt5wRWAIbfrYvcMCD17m46GVPHD3vV2wRN0onw== X-Received: by 2002:a17:90b:4d90:b0:29c:3af5:e274 with SMTP id oj16-20020a17090b4d9000b0029c3af5e274mr2710948pjb.28.1710284109139; Tue, 12 Mar 2024 15:55:09 -0700 (PDT) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id y8-20020a17090a8b0800b0029bb8ebdc23sm98947pjn.37.2024.03.12.15.55.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 15:55:08 -0700 (PDT) From: Stephen Hemminger To: netdev@vger.kernel.org Cc: Stephen Hemminger Subject: [PATCH iproute2 4/5] simple: support json output Date: Tue, 12 Mar 2024 15:53:31 -0700 Message-ID: <20240312225456.87937-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240312225456.87937-1-stephen@networkplumber.org> References: <20240312225456.87937-1-stephen@networkplumber.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: dsahern@gmail.com Last action that never got JSON support. Signed-off-by: Stephen Hemminger --- tc/m_simple.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tc/m_simple.c b/tc/m_simple.c index fe2bca21ae46..6eb60bd8a924 100644 --- a/tc/m_simple.c +++ b/tc/m_simple.c @@ -179,9 +179,11 @@ static int print_simple(struct action_util *au, FILE *f, struct rtattr *arg) simpdata = RTA_DATA(tb[TCA_DEF_DATA]); - fprintf(f, "Simple <%s>\n", simpdata); - fprintf(f, "\t index %u ref %d bind %d", sel->index, - sel->refcnt, sel->bindcnt); + print_string(PRINT_ANY, "simple", "Simple <%s>", simpdata); + print_nl(); + print_uint(PRINT_ANY, "index", "\t index %u ", sel->index); + print_int(PRINT_ANY, "ref", "ref %d ", sel->refcnt); + print_int(PRINT_ANY, "bind","bind %d", sel->bindcnt); if (show_stats) { if (tb[TCA_DEF_TM]) { From patchwork Tue Mar 12 22:53:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 13590756 X-Patchwork-Delegate: stephen@networkplumber.org Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E1E641744 for ; Tue, 12 Mar 2024 22:55:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710284111; cv=none; b=PeZK4tzYz47Qt7mLku/5PIIK3t4z62Lg6Hi+5qQrIkqHaO/yI1lnkC1aNM8l572j1b3JskfWSNOA0MgsnIc8Ei2BCHES7fyvKKX2jt7iHZlQSfx5bKh2390VlyEqhn3TMvx+9azyYs7ducKLwlC97vmGjgk0qhsElb+R+PJQbBs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710284111; c=relaxed/simple; bh=f+1keHxGrhlOVOzqi+hzOYufflwoOaXGi0GBxMo5RHQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AT2E+e0MPk2U6k9pkXDOj45mTi12O60165rh3B+xeXw3irc7tQhNLVHhfjRhJsR3o5QXhJjl1dnYY+dOT7KAYHztZPFW1Tt2tRfWRk3yqY/YWGOpviXCoQVakd4cXJVfGTCxxoA50PBom5oSdt35Fw2V+EfznOVoDYZdtmzkfEQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=networkplumber.org; spf=pass smtp.mailfrom=networkplumber.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20230601.gappssmtp.com header.i=@networkplumber-org.20230601.gappssmtp.com header.b=YTQg5fR4; arc=none smtp.client-ip=209.85.210.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20230601.gappssmtp.com header.i=@networkplumber-org.20230601.gappssmtp.com header.b="YTQg5fR4" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-6e6b54a28ebso329657b3a.2 for ; Tue, 12 Mar 2024 15:55:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1710284110; x=1710888910; darn=vger.kernel.org; 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=cAWHcTxAB1nLta9qPuToaMmMW1t9lT6u/KzReuDs/+0=; b=YTQg5fR4ea27RB06Ue2R6++x9mKQ1rjBuC0IU1U2J1GKECb/+brHtUymnogmnwgTLG Llf3O08tU1p2G+kcT5K6hcn6WKG2CuLXDmy0e6KpSbp5lTNpAIcloyHZTYpMhTvmg2O5 HLJRXxBWyb2hQI6GpuuUaBGQiupzY8ihGQc4dlSnCqDAe8NDNQNVI+fBGH3+aFgjEcG2 xVHGTxPPqh29amUVP9KoNtyNJVPlITXoVO3PAhvj6A3ew7nFU/XpePiuwCeQ3GQ3XqEv a9bEsx2VEHLIFv+3rK2yNuzcrQ8lWr22gXjlBI+d1BkpoDKJL3ukjN2ozbqK/Bigz0jS kq9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710284110; x=1710888910; 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=cAWHcTxAB1nLta9qPuToaMmMW1t9lT6u/KzReuDs/+0=; b=XskR3cjVlkfqrjFV6jJDCc+2v2wbDNJt1Czy2hQWgvUD9UpJrilfgiEjyrlRUgEXpl Hvr5iRM+2l0kDen1++SINUTM22sWhdeQPpYkvWiZvy6iKZAoMV+tS1peCt2L7s5cAlXZ E9vUfvtMZL2Av9n5KfeYtVjED/HWu9skTMDLmMoiGEuCGRASd2OGrRk+5f8hXAcHuSCo kOgWEi4s587nqTKm+kWyBGR3ZUBZe9qgq2DccdV7K6x8TJ2a6EjoOZQp/uE1uEcLxyTq MbjPo/ccmjMHC+ESkTUhFHqjuFDpbgt6lTjLPAJb/Duq16yAjF0HXA9f87bXcldB64Ql Q77A== X-Gm-Message-State: AOJu0Yzb2oLqZBFwNnYH5tdp8oADAljHE/NdRggYTG1MniZg0WiTvu68 ZsReQb3AtS+A11xP1kuX+baP8cdT2VNJcZ6Ncv3jPbbM5U1/1k3ADptc4zTLa2JOcskGyluKyvf G X-Google-Smtp-Source: AGHT+IGUGSzFeT0a2jMSOMH7dinRVLrBvqpRLiLNdG/dGKvGg9G6ojMRNaFbJ1sYRuT2YcbMDVC7ng== X-Received: by 2002:a05:6a20:938a:b0:1a3:2f74:e374 with SMTP id x10-20020a056a20938a00b001a32f74e374mr1743421pzh.43.1710284109765; Tue, 12 Mar 2024 15:55:09 -0700 (PDT) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id y8-20020a17090a8b0800b0029bb8ebdc23sm98947pjn.37.2024.03.12.15.55.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 15:55:09 -0700 (PDT) From: Stephen Hemminger To: netdev@vger.kernel.org Cc: Stephen Hemminger Subject: [PATCH iproute2 5/5] tc-simple.8: take Jamal's prompt off examples Date: Tue, 12 Mar 2024 15:53:32 -0700 Message-ID: <20240312225456.87937-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240312225456.87937-1-stephen@networkplumber.org> References: <20240312225456.87937-1-stephen@networkplumber.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: dsahern@gmail.com The examples on tc-simple man page had extra stuff in the prompt which is not necessary. Signed-off-by: Stephen Hemminger --- man/man8/tc-simple.8 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/man/man8/tc-simple.8 b/man/man8/tc-simple.8 index f565755e5e11..ae1aec31d099 100644 --- a/man/man8/tc-simple.8 +++ b/man/man8/tc-simple.8 @@ -55,11 +55,11 @@ grep the logs to see the logged message display stats again and observe increment by 1 .EX - hadi@noma1:$ tc qdisc add dev eth0 ingress - hadi@noma1:$tc filter add dev eth0 parent ffff: protocol ip prio 5 \\ + $ tc qdisc add dev eth0 ingress + $ tc filter add dev eth0 parent ffff: protocol ip prio 5 \\ u32 match ip protocol 1 0xff flowid 1:1 action simple sdata "Incoming ICMP" - hadi@noma1:$ sudo tc -s filter ls dev eth0 parent ffff: + $ sudo tc -s filter ls dev eth0 parent ffff: filter protocol ip pref 5 u32 filter protocol ip pref 5 u32 fh 800: ht divisor 1 filter protocol ip pref 5 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:1 @@ -71,7 +71,7 @@ display stats again and observe increment by 1 backlog 0b 0p requeues 0 - hadi@noma1$ ping -c 1 www.google.ca + $ ping -c 1 www.google.ca PING www.google.ca (74.125.225.120) 56(84) bytes of data. 64 bytes from ord08s08-in-f24.1e100.net (74.125.225.120): icmp_req=1 ttl=53 time=31.3 ms @@ -79,10 +79,10 @@ display stats again and observe increment by 1 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 31.316/31.316/31.316/0.000 ms - hadi@noma1$ dmesg | grep simple + $ dmesg | grep simple [135354.473951] simple: Incoming ICMP_1 - hadi@noma1$ sudo tc/tc -s filter ls dev eth0 parent ffff: + $ sudo tc/tc -s filter ls dev eth0 parent ffff: filter protocol ip pref 5 u32 filter protocol ip pref 5 u32 fh 800: ht divisor 1 filter protocol ip pref 5 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:1