From: Anton Danilov <littlesmilingcloud@gmail.com>
To: netdev@vger.kernel.org
Cc: stephen@networkplumber.org, Anton Danilov <littlesmilingcloud@gmail.com>
Subject: [PATCH v2 iproute2] misc: make the pattern matching case-insensitive
Date: Thu, 9 Jul 2020 18:03:43 +0300 [thread overview]
Message-ID: <20200709150341.30892-1-littlesmilingcloud@gmail.com> (raw)
In-Reply-To: <20200708082819.155f7bb7@hermes.lan>
To improve the usability better use case-insensitive pattern-matching
in ifstat, nstat and ss tools.
Signed-off-by: Anton Danilov <littlesmilingcloud@gmail.com>
---
man/man8/rtacct.8 | 7 +++++++
misc/ifstat.c | 2 +-
misc/nstat.c | 2 +-
misc/ss.c | 2 +-
4 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/man/man8/rtacct.8 b/man/man8/rtacct.8
index ccdbf6ca..988a6d1b 100644
--- a/man/man8/rtacct.8
+++ b/man/man8/rtacct.8
@@ -14,6 +14,13 @@ and
.B rtacct
are simple tools to monitor kernel snmp counters and network interface statistics.
+.B nstat
+can filter kernel snmp counters by name with one or several specified wildcards. Wildcards are case-insensitive and can include special symbols
+.B ?
+and
+.B *
+.
+
.SH OPTIONS
.B \-h, \-\-help
Print help
diff --git a/misc/ifstat.c b/misc/ifstat.c
index 60efe6cb..03327af8 100644
--- a/misc/ifstat.c
+++ b/misc/ifstat.c
@@ -104,7 +104,7 @@ static int match(const char *id)
return 1;
for (i = 0; i < npatterns; i++) {
- if (!fnmatch(patterns[i], id, 0))
+ if (!fnmatch(patterns[i], id, FNM_CASEFOLD))
return 1;
}
return 0;
diff --git a/misc/nstat.c b/misc/nstat.c
index 425e75ef..88f52eaf 100644
--- a/misc/nstat.c
+++ b/misc/nstat.c
@@ -114,7 +114,7 @@ static int match(const char *id)
return 1;
for (i = 0; i < npatterns; i++) {
- if (!fnmatch(patterns[i], id, 0))
+ if (!fnmatch(patterns[i], id, FNM_CASEFOLD))
return 1;
}
return 0;
diff --git a/misc/ss.c b/misc/ss.c
index f3d01812..5aa10e4a 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -1670,7 +1670,7 @@ static int unix_match(const inet_prefix *a, const inet_prefix *p)
return 1;
if (addr == NULL)
addr = "";
- return !fnmatch(pattern, addr, 0);
+ return !fnmatch(pattern, addr, FNM_CASEFOLD);
}
static int run_ssfilter(struct ssfilter *f, struct sockstat *s)
--
2.26.2
next prev parent reply other threads:[~2020-07-09 15:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-08 12:38 [PATCH iproute2] nstat: case-insensitive pattern matching Anton Danilov
2020-07-08 15:28 ` Stephen Hemminger
2020-07-09 15:03 ` Anton Danilov [this message]
2020-07-20 20:30 ` [PATCH v2 iproute2] misc: make the pattern matching case-insensitive Stephen Hemminger
2020-07-08 15:40 ` [PATCH iproute2] nstat: case-insensitive pattern matching Stephen Hemminger
2020-07-08 21:48 ` Anton Danilov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200709150341.30892-1-littlesmilingcloud@gmail.com \
--to=littlesmilingcloud@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).