Commit Graph

1268 Commits

Author SHA1 Message Date
Stephen Hemminger
95f4021b48 netem: swap transposed calloc args
Gcc with -Wextra complains about transposed args to calloc
in netem.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-10-07 09:37:24 -07:00
Davide Caratti
0941975dc8 tc: f_flower: add support for matching on tunnel metadata
extend TC flower for matching on tunnel metadata.

Changes since v2:
 - split uAPI changes and TC code in separate patches, as per David's request [2]

Changes since v1:
 - fix incostintent naming in explain() and in tc-flower.8 (Asbjørn)

Changes since RFC:
 - update uAPI bits to Asbjørn's most recent code [1]
 - add 'tun' prefix to all flag names (Asbjørn)
 - allow parsing 'enc_flags' multiple times, without clearing the match
   mask every time, like happens for 'ip_flags' (Asbjørn)
 - don't use "matches()" for parsing argv[]  (Stephen)
 - (hopefully) improve usage() printout (Asbjørn)
 - update man page

[1] https://lore.kernel.org/netdev/20240709163825.1210046-1-ast@fiberby.net/
[2] https://lore.kernel.org/netdev/cc73004c-9aa8-9cd3-b46e-443c0727c34d@kernel.org/

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
2024-08-04 15:20:32 +00:00
Maks Mishin
b06341a252 f_flower: Remove always zero checks
Expression 'ttl & ~(255 >> 0)' is always zero, because right operand
has 8 trailing zero bits, which is greater or equal than the size
of the left operand == 8 bits.

Found by RASU JSC.

Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
Reviewed-by: Guillaume Nault <gnault@redhat.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-07-17 16:47:57 -07:00
David Ahern
977d51cfec Merge remote-tracking branch 'main/main' into next
Signed-off-by: David Ahern <dsahern@kernel.org>
2024-05-03 15:40:02 +00:00
Stephen Hemminger
911c62bf9d use missing argument helper
There is a helper in utilities to handle missing argument,
but it was not being used consistently.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-04-23 09:01:46 -07:00
Michal Swiatkowski
976dca372e f_flower: implement pfcp opts
Allow adding tc filter for PFCP header.

Add support for parsing TCA_FLOWER_KEY_ENC_OPTS_PFCP.
Options are as follows: TYPE:SEID.

TYPE is a 8-bit value represented in hex and can be  1
for session header and 0 for node header. In PFCP packet
this is S flag in header.

SEID is a 64-bit session id value represented in hex.

This patch enables adding hardware filters using PFCP fields, see [1].

[1] https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=d823265dd45bbf14bd67aa476057108feb4143ce

Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Signed-off-by: Wojciech Drewek <wojciech.drewek@intel.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
2024-04-23 15:34:19 +00:00
Stephen Hemminger
95c886b8e8 tc/util: remove unused argument from print_tcstats2_attr
The function doesn't use the FILE handle.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: David Ahern <dsahern@kernel.org>
2024-04-21 01:45:48 +00:00
Stephen Hemminger
6879d2046b tc/police: remove unused argument to tc_print_police
FILE handle no longer used.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: David Ahern <dsahern@kernel.org>
2024-04-21 01:45:38 +00:00
Stephen Hemminger
2c42df8689 tc/util: remove unused argument from print_action_control
The FILE handle is no longer used.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: David Ahern <dsahern@kernel.org>
2024-04-21 01:43:52 +00:00
Stephen Hemminger
bf4022ebe6 tc/util: remove unused argument from print_tm
File argument no longer used.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: David Ahern <dsahern@kernel.org>
2024-04-21 01:41:56 +00:00
Stephen Hemminger
98b7262c12 tc/u32: remove FILE argument
The pretty printing routines no longer use the file handle.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: David Ahern <dsahern@kernel.org>
2024-04-21 01:12:51 +00:00
Stephen Hemminger
69d55c213d simple: support json output
Last action that never got JSON support.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-03-13 10:07:33 -07:00
Stephen Hemminger
af0ddbfa51 skbmod: support json in print
This tc action never got jsonized.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-03-13 10:07:33 -07:00
Stephen Hemminger
ba52b3d4dd pedit: log errors to stderr
The errors should bo to stderr, not to stdout.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-03-13 10:07:33 -07:00
Stephen Hemminger
fc4226d247 tc: support JSON for legacy stats
The extended stats already supported JSON output, add to the
legacy stats as well.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-03-13 10:07:33 -07:00
Stephen Hemminger
38656eeb35 tc: remove no longer used helpers
The removal of tick usage in netem, means that some of the
helper functions in tc are no longer used and can be safely removed.
Other functions can be made static.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-03-13 09:56:29 -07:00
Stephen Hemminger
9a6b231ea1 netem: use 64 bit value for latency and jitter
The current version of netem in iproute2 has a maximum of 4.3 seconds
because of scaled 32 bit clock values. Some users would like to be
able to use larger delays to emulate things like storage delays.

Since kernel version 4.15, netem qdisc had netlink parameters
to express wider range of delays in nanoseconds. But the iproute2
side was never updated to use them.

This does break compatibility with older kernels (4.14 and earlier).
With these out of support kernels, the latency/delay parameter
will end up being ignored.

Reported-by: Marc Blanchet <marc.blanchet@viagenie.ca>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-03-13 09:54:44 -07:00
Stephen Hemminger
9fb634deec tc: make exec_util arg const
The callbacks in exec_util should not be modifying underlying
qdisc operations structure.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-03-12 15:11:43 -07:00
Stephen Hemminger
38b0e6c120 tc: make action_util arg const
The callbacks in action_util should not be modifying underlying
qdisc operations structure.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-03-12 15:11:43 -07:00
Stephen Hemminger
fa740c21b4 tc: make filter_util args const
The callbacks in filter_util should not be modifying underlying
qdisc operations structure.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-03-12 15:11:43 -07:00
Stephen Hemminger
8576afbb89 tc: make qdisc_util arg const
The callbacks in qdisc_util should not be modifying underlying
qdisc operations structure.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-03-12 15:11:43 -07:00
Stephen Hemminger
ade05d59c3 Merge branch 'main' of git://git.kernel.org/pub/scm/network/iproute2/iproute2-next 2024-03-11 16:39:39 -07:00
Stephen Hemminger
88f0b157e9 tc/action: remove trailing whitespace
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-03-11 10:32:05 -07:00
Takanori Hirano
b8daf861a4 tc: Fix json output for f_u32
Signed-off-by: Takanori Hirano <me@hrntknr.net>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-03-04 08:20:46 -08:00
David Ahern
4306b28650 Merge remote-tracking branch 'main/main' into next
Signed-off-by: David Ahern <dsahern@kernel.org>
2024-02-27 04:09:35 +00:00
Takanori Hirano
4b6e97b5f3 tc: Support json option in tc-cgroup, tc-flow and tc-route
Fix json corruption when using the "-json" option in some cases

Signed-off-by: Takanori Hirano <me@hrntknr.net>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-02-19 10:08:56 -08:00
Takanori Hirano
bc5468c5eb tc: Change of json format in tc-fw
In the case of a process such as mapping a json to a structure,
it can be difficult if the keys have the same name but different types.
Since handle is used in hex string, change it to fw.

Signed-off-by: Takanori Hirano <me@hrntknr.net>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-02-19 10:08:49 -08:00
David Ahern
f900302f32 Merge remote-tracking branch 'main/main' into next
Signed-off-by: David Ahern <dsahern@kernel.org>
2024-02-18 17:41:39 +00:00
Stephen Hemminger
d06f6a3d17 tc: u32: check return value from snprintf
Add assertion to check for case of snprintf failing (bad format?)
or buffer getting full.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-02-10 16:47:25 -08:00
Stephen Hemminger
e91dfaaaea tc: drop no longer used prototype from tc_util.h
Part of the ipt removal missed this.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-02-10 09:48:55 -08:00
Stephen Hemminger
b958d3c25d tc: print unknown action on stderr
This is an error, and should not go to stdout.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-02-10 09:48:55 -08:00
Stephen Hemminger
46031294e3 tc: bpf: fix extra newline in JSON output
Don't print newline at end of bpf if in JSON mode.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-02-10 09:48:55 -08:00
Takanori Hirano
49a8b895ad tc: Support json option in tc-fw.
Fix json corruption when using the "-json" option in cases where tc-fw is set.

Signed-off-by: Takanori Hirano <me@hrntknr.net>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-02-10 09:48:55 -08:00
Stephen Hemminger
e449400508 tc: u32: errors should be printed on stderr
Don't corrupt stdout with error messages, matters if JSON is used.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-02-10 09:48:49 -08:00
Andrea Claudi
9cf6493cab treewide: fix typos in various comments
Fix various typos and spelling errors in some iproute2 comments.

Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-02-09 08:45:10 -08:00
Victor Nogueira
cf0eae9a9f tc: Add NLM_F_ECHO support for filters
If the user specifies this flag for a filter command the kernel will
return the command's result back to user space.
For example:

  tc -echo filter add dev lo parent ffff: protocol ip matchall action ok

  added filter dev lo parent ffff: protocol ip pref 49152 matchall chain 0

As illustrated above, the kernel will give us a pref of 491252

The same can be done for other filter commands (replace, delete, and
change). For example:

  tc -echo filter del dev lo parent ffff: pref 49152 protocol ip matchall

  deleted filter dev lo parent ffff: protocol ip pref 49152 matchall chain 0

Signed-off-by: Victor Nogueira <victor@mojatatu.com>
Reviewed-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
2024-01-30 15:49:13 +00:00
Victor Nogueira
071144c0bb tc: add NLM_F_ECHO support for actions
This patch adds the -echo flag to tc command line and support for it in
tc actions. If the user specifies this flag for an action command, the
kernel will return the command's result back to user space.
For example:

  tc -echo actions add action mirred egress mirror dev lo

  total acts 0
  Added action
        action order 1: mirred (Egress Mirror to device lo) pipe
        index 10 ref 1 bind 0
        not_in_hw

As illustrated above, the kernel will give us an index of 10

The same can be done for other action commands (replace, change, and
delete). For example:

  tc -echo actions delete action mirred index 10

  total acts 0
  Deleted action
        action order 1: mirred (Egress Mirror to device lo) pipe
        index 10 ref 0 bind 0
        not_in_hw

Signed-off-by: Victor Nogueira <victor@mojatatu.com>
Reviewed-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
2024-01-30 15:49:12 +00:00
Stephen Hemminger
0c3400cc8f spelling fixes
Use codespell and ispell to fix some spelling errors
in comments and README's.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-01-25 16:49:10 -08:00
Victor Nogueira
139a74134c m_mirred: Allow mirred to block
So far the mirred action has dealt with syntax that handles
mirror/redirection for netdev. A matching packet is redirected or mirrored
to a target netdev.

In this patch we enable mirred to mirror to a tc block as well.
IOW, the new syntax looks as follows:
... mirred <ingress | egress> <mirror | redirect> [index INDEX] < <blockid BLOCKID> | <dev <devname>> >

Examples of mirroring or redirecting to a tc block:
$ tc filter add block 22 protocol ip pref 25 \
  flower dst_ip 192.168.0.0/16 action mirred egress mirror blockid 22

$ tc filter add block 22 protocol ip pref 25 \
  flower dst_ip 10.10.10.10/32 action mirred egress redirect blockid 22

Co-developed-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Co-developed-by: Pedro Tammela <pctammela@mojatatu.com>
Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
Signed-off-by: Victor Nogueira <victor@mojatatu.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
2024-01-25 18:15:50 +00:00
Stephen Hemminger
3062aaf770 tc: better clockid handling
All clockid values not available on some older glibc versions.
Also, add some comments.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-01-21 09:19:19 -08:00
Stephen Hemminger
91cca2aee7 tc: unify clockid handling
There are three places in tc which all have same code for
handling clockid (copy/paste). Move it into tc_util.c.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-01-19 08:38:58 -08:00
Stephen Hemminger
45dc10463d remove support for iptables action
There is an open upstream kernel patch to remove ipt action from
kernel. This is corresponding iproute2 change.

 - Remove support fot ipt and xt in tc.
 - Remove no longer used header files.
 - Update man pages.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
2024-01-08 01:44:50 +00:00
Eric Dumazet
3086a339f6 tc: fq: reports stats added in linux-6.7
Report new fields added in linux-6.7:

- fastpath        : Number of packets that have used the fast path.
- band[012]_pkts  : Number of packets currently queued per band.
- band[012]_drops : Counters of dropped packets, per band
                    (only printed if not zero)

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
2023-12-06 16:51:48 +00:00
Eric Dumazet
567eb4e410 tc: fq: add TCA_FQ_WEIGHTS handling
Linux-6.7 FQ got WRR scheduling.

TCA_FQ_WEIGHTS attribute can report/change per-band weights.

tc qdisc show dev eth1
...
qdisc fq ... weights 589824 196608 65536 quantum 8364b ...

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
2023-12-06 16:51:43 +00:00
Eric Dumazet
73a31c9454 tc: fq: add TCA_FQ_PRIOMAP handling
linux-6.7 FQ packet scheduler gets 3-bands, and the ability
to report or program the associated priomap.

$ tc qdisc show dev eth0
...
qdisc fq ... bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1

$ tc qdisc change dev eth0 ... qdisc fq ... bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
2023-12-06 16:51:41 +00:00
Stephen Hemminger
cb0709b74f Merge branch 'main' of git://git.kernel.org/pub/scm/network/iproute2/iproute2-next 2023-11-06 12:40:38 -08:00
Stephen Hemminger
8a20feb638 tc: drop support for ATM qdisc
The upstream kernel dropped support for ATM qdisc in
fb38306ceb9e (net/sched: Retire ATM qdisc, 2023-02-14)

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2023-10-30 14:16:29 -07:00
Stephen Hemminger
11e6e783b6 tc: remove dsmark qdisc
The kernel has removed support for dsmark qdisc in commit
bbe77c14ee61 (net/sched: Retire dsmark qdisc, 2023-02-14)

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2023-10-30 11:35:32 -07:00
Stephen Hemminger
bc0c1661eb tc: remove tcindex classifier
Support for tcindex classifier was removed by upstream commit
8c710f75256b (net/sched: Retire tcindex classifier, 2023-02-14)

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2023-10-30 11:30:53 -07:00
Stephen Hemminger
aeb7be3843 tc: remove support for RSVP classifier
The RSVP classifier was removed in 6.3 kernel by upstream commit
265b4da82dbf (net/sched: Retire rsvp classifier, 2023-02-14)

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2023-10-30 11:24:26 -07:00