netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Add documentation of ss filter to man page
@ 2021-01-28  8:10 Thayne McCombs
  2021-01-31  6:16 ` Thayne McCombs
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Thayne McCombs @ 2021-01-28  8:10 UTC (permalink / raw)
  To: netdev; +Cc: Thayne McCombs

This adds some documentation of the syntax for the FILTER argument to
the ss command to the ss (8) man page.

Signed-off-by: Thayne McCombs <astrothayne@gmail.com>
---
 man/man8/ss.8 | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 105 insertions(+)

diff --git a/man/man8/ss.8 b/man/man8/ss.8
index e4b9cdc..3da279f 100644
--- a/man/man8/ss.8
+++ b/man/man8/ss.8
@@ -440,6 +440,111 @@ states except for
 - opposite to
 .B bucket
 
+.SH EXPRESSION
+
+.B EXPRESSION
+allows filtering based on specific criteria.
+.B EXPRESSION
+consists of a series of predicates combined by boolean operators. The possible operators in increasing
+order of precedence are
+.B or
+(or | or ||),
+.B and
+(or & or &&), and
+.B not
+(or !). If no operator is between consecutive predicates, an implicit
+.B and
+operator is assumed. Subexpressions can be grouped with "(" and ")".
+.P
+The following predicates are supported:
+
+.TP
+.B {dst|src} [=] HOST
+Test if the destination or source matches HOST. See HOST SYNTAX for details.
+.TP
+.B {dport|sport} [OP] [FAMILY:]:PORT
+Compare the destination or source port to PORT. OP can be any of "<", "<=", "=", "!=",
+">=" and ">". Following normal arithmetic rules. FAMILY and PORT are as described in
+HOST SYNTAX below.
+.TP
+.B dev [=|!=] DEVICE
+Match based on the device the connection uses. DEVICE can either be a device name or the
+index of the interface.
+.TP
+.B fwmark [=|!=] MASK
+Matches based on the fwmark value for the connection. This can either be a specific mark value
+or a mark value followed by a "/" and a bitmask of which bits to use in the comparison. For example
+"fwmark = 0x01/0x03" would match if the two least significant bits of the fwmark were 0x01.
+.TP
+.B cgroup [=|!=] PATH
+Match if the connection is part of a cgroup at the given path.
+.TP
+.B autobound
+Match if the port or path of the source address was automatically allocated
+(rather than explicitly specified).
+.P
+Most operators have aliases. If no operator is supplied "=" is assumed.
+Each of the following groups of operators are all equivalent:
+.RS
+.IP \(bu 2
+= == eq
+.IP \(bu
+!= ne neq
+.IP \(bu
+> gt
+.IP \(bu
+< lt
+.IP \(bu
+>= ge geq
+.IP \(bu
+<= le leq
+.IP \(bu
+! not
+.IP \(bu
+| || or
+.IP \(bu
+& && and
+.RE
+.SH HOST SYNTAX
+.P
+The general host syntax is [FAMILY:]ADDRESS[:PORT].
+.P
+FAMILY must be one of the families supported by the -f option. If not given
+it defaults to the family given with the -f option, and if that is also
+missing, will assume either inet or inet6.
+.P
+The form of ADDRESS and PORT depends on the family used. "*" can be used as
+a wildcord for either the address or port. The details for each family are as
+follows:
+.TP
+.B unix
+ADDRESS is a glob pattern (see
+.BR fnmatch (3))
+that will be matched case-insensitively against the unix socket's address. Both path and abstract
+names are supported. Unix addresses do not support a port, and "*" cannot be used as a wildcard.
+.TP
+.B link
+ADDRESS is the case-insensitive name of an ethernet protocol to match. PORT
+is either a device name or a device index for the desired link device, as seen
+in the output of ip link.
+.TP
+.B netlink
+ADDRESS is a descriptor of the netlink family. Possible values come from
+/etc/iproute2/nl_protos. PORT is the port id of the socket, which is usually
+the same as the owning process id. The value "kernel" can be used to represent
+the kernel (port id of 0).
+.TP
+.B vsock
+ADDRESS is an integer representing the CID address, and PORT is the port.
+.TP
+.BR inet \ and\  inet6
+ADDRESS is an ip address (either v4 or v6 depending on the family) or a DNS
+hostname that resolves to an ip address of the required version. An ipv6
+address must be enclosed in "[" and "]" to disambiguate the port seperator. The
+address may addtionally have a prefix length given in CIDR notation (a slash
+followed by the prefix length in bits). PORT is either the numerical
+socket port, or the service name for the port to match.
+
 .SH USAGE EXAMPLES
 .TP
 .B ss -t -a
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Add documentation of ss filter to man page
  2021-01-28  8:10 [PATCH] Add documentation of ss filter to man page Thayne McCombs
@ 2021-01-31  6:16 ` Thayne McCombs
  2021-02-01  9:14 ` [PATCH iproute2-next] ss: Add clarification about host conditions with multiple familes to man Thayne McCombs
  2021-02-02 22:25 ` [PATCH] Add documentation of ss filter to man page Stephen Hemminger
  2 siblings, 0 replies; 5+ messages in thread
From: Thayne McCombs @ 2021-01-31  6:16 UTC (permalink / raw)
  To: netdev


Oh. I think I should have added "[PATCH iproute2-next] ss:" to my 
subject line.

Sorry, this was my first post to this list.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH iproute2-next] ss: Add clarification about host conditions with multiple familes to man
  2021-01-28  8:10 [PATCH] Add documentation of ss filter to man page Thayne McCombs
  2021-01-31  6:16 ` Thayne McCombs
@ 2021-02-01  9:14 ` Thayne McCombs
  2021-02-02 22:25 ` [PATCH] Add documentation of ss filter to man page Stephen Hemminger
  2 siblings, 0 replies; 5+ messages in thread
From: Thayne McCombs @ 2021-02-01  9:14 UTC (permalink / raw)
  To: netdev, stephen, vadim4j; +Cc: Thayne McCombs

In creating documentation for expressions I ran into an interesting case
where if you use two different familie types in the expression, such as
in `ss 'sport inet:ssh or src unix:/run/*'`, then you would only get the
results for one address family (in this case unix sockets).

The reason is that in parse_hostcond if the family is specified we
remove any previously added families from filter->families, and
preserve the "states" if any states are set. I tried changing this to
not reset the families, but ran into some issues with Invalid Argument
errors in inet_show_netlink, I think related to the state.

I can dig into that more if supporting this is useful, but I'm not sure
if these types of expressions would actually be useful in practice. Or
perhaps an error should be given if an expression contains conditions
with multiple families (besides inet and inet6)?

Anyway, for now, this patch just notes the limitation in the man page.

Signed-off-by: Thayne McCombs <astrothayne@gmail.com>
---
 man/man8/ss.8 | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/man/man8/ss.8 b/man/man8/ss.8
index 3da279f9..3c4beede 100644
--- a/man/man8/ss.8
+++ b/man/man8/ss.8
@@ -511,7 +511,9 @@ The general host syntax is [FAMILY:]ADDRESS[:PORT].
 .P
 FAMILY must be one of the families supported by the -f option. If not given
 it defaults to the family given with the -f option, and if that is also
-missing, will assume either inet or inet6.
+missing, will assume either inet or inet6. Note that all host conditions in the
+expression should either all be the same family or be only inet and inet6. If there
+is some other mixture of families, the results will probably be unexpected.
 .P
 The form of ADDRESS and PORT depends on the family used. "*" can be used as
 a wildcord for either the address or port. The details for each family are as
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Add documentation of ss filter to man page
  2021-01-28  8:10 [PATCH] Add documentation of ss filter to man page Thayne McCombs
  2021-01-31  6:16 ` Thayne McCombs
  2021-02-01  9:14 ` [PATCH iproute2-next] ss: Add clarification about host conditions with multiple familes to man Thayne McCombs
@ 2021-02-02 22:25 ` Stephen Hemminger
  2021-02-03  5:40   ` Thayne McCombs
  2 siblings, 1 reply; 5+ messages in thread
From: Stephen Hemminger @ 2021-02-02 22:25 UTC (permalink / raw)
  To: Thayne McCombs; +Cc: netdev

On Thu, 28 Jan 2021 01:10:18 -0700
Thayne McCombs <astrothayne@gmail.com> wrote:

> This adds some documentation of the syntax for the FILTER argument to
> the ss command to the ss (8) man page.
> 
> Signed-off-by: Thayne McCombs <astrothayne@gmail.com>

Applied, but I had to fix several spelling errors.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Add documentation of ss filter to man page
  2021-02-02 22:25 ` [PATCH] Add documentation of ss filter to man page Stephen Hemminger
@ 2021-02-03  5:40   ` Thayne McCombs
  0 siblings, 0 replies; 5+ messages in thread
From: Thayne McCombs @ 2021-02-03  5:40 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev

Awesome! Thank you very much! Sorry about the spelling errors.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-02-03  5:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-28  8:10 [PATCH] Add documentation of ss filter to man page Thayne McCombs
2021-01-31  6:16 ` Thayne McCombs
2021-02-01  9:14 ` [PATCH iproute2-next] ss: Add clarification about host conditions with multiple familes to man Thayne McCombs
2021-02-02 22:25 ` [PATCH] Add documentation of ss filter to man page Stephen Hemminger
2021-02-03  5:40   ` Thayne McCombs

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).