mirror_iproute2/tc
Jamal Hadi Salim 35f2a7639d tc/actions: introduce support for jump action
Sample use case:

... add ingress qdisc
sudo $TC qdisc add dev $ETH ingress

 ... if we exceed rate of 1kbps (burst of 90K), do an absolute jump of 2 actions
sudo $TC actions add action police rate 1kbit burst 90k conform-exceed jump 2 / pipe

sudo $TC -s actions ls action police
 action order 0:  police 0x4 rate 1Kbit burst 23440b mtu 2Kb action jump 2/pipe overhead 0b
 ref 1 bind 0 installed 41 sec used 41 sec
 Action statistics:
  Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
  backlog 0b 0p requeues 0

... lets add a couple of marks so we can use them to mark exceed/not exceed
sudo $TC actions add action skbedit mark 11 ok index 11
sudo $TC actions add action skbedit mark 12 ok index 12

... if we dont exceed our rate we get a mark of 11, else mark of 12
sudo $TC filter add dev $ETH parent ffff: protocol ip prio 8 u32 \
match ip dst 127.0.0.8/32 flowid 1:10 \
action police index 4 \
action skbedit index 11 \
action skbedit index 12

Ok, lets keep this thing a little busy..
sudo ping -f -c 10000 127.0.0.8

... now lets see the filters..
sudo $TC -s filter ls dev $ETH parent ffff: protocol ip
filter pref 8 u32 chain 0
filter pref 8 u32 chain 0 fh 800: ht divisor 1
filter pref 8 u32 chain 0 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:10 not_in_hw  (rule hit 20000 success 10000)
  match 7f000008/ffffffff at 16 (success 10000 )
	action order 1:  police 0x4 rate 1Kbit burst 23440b mtu 2Kb action jump 2/pipe overhead 0b
	ref 2 bind 1 installed 198 sec used 2 sec
	Action statistics:
	Sent 840000 bytes 10000 pkt (dropped 0, overlimits 9721 requeues 0)
	backlog 0b 0p requeues 0

	action order 2:  skbedit mark 11 pass
	 index 11 ref 2 bind 1 installed 127 sec used 2 sec
 	Action statistics:
	Sent 23436 bytes 279 pkt (dropped 0, overlimits 0 requeues 0)
	backlog 0b 0p requeues 0

	action order 3:  skbedit mark 12 pass
	 index 12 ref 2 bind 1 installed 127 sec used 2 sec
 	Action statistics:
	Sent 816564 bytes 9721 pkt (dropped 0, overlimits 0 requeues 0)
	backlog 0b 0p requeues 0

As can be seen 97.21% of the packets were marked as exceeding the allocated
rate; you could do something clever with the skb mark after this.

Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-10-25 12:33:46 +02:00
..
.gitignore Add ignore files to make using git easier 2006-08-08 12:04:38 -07:00
e_bpf.c bpf: make tc's bpf loader generic and move into lib 2016-11-29 12:35:32 -08:00
em_canid.c Replace malloc && memset by calloc 2016-07-20 12:05:24 -07:00
em_cmp.c Use C99 style initializers everywhere 2016-07-20 12:05:24 -07:00
em_ipset.c Convert the obvious cases to strlcpy() 2017-09-01 12:10:54 -07:00
em_meta.c tc: ematch: Ignore all-zero mask value when printing filters 2016-07-20 12:20:13 -07:00
em_nbyte.c Use C99 style initializers everywhere 2016-07-20 12:05:24 -07:00
em_u32.c Use C99 style initializers everywhere 2016-07-20 12:05:24 -07:00
emp_ematch.l fix build issues with flex ver 2.5 2010-04-22 15:27:42 -07:00
emp_ematch.y tc: remove extra whitespace 2015-10-23 15:43:28 -07:00
f_basic.c tc actions: Improved batching and time filtered dumping 2017-08-04 13:16:51 -07:00
f_bpf.c Merge branch 'master' into net-next 2017-09-05 09:33:29 -07:00
f_cgroup.c tc actions: Improved batching and time filtered dumping 2017-08-04 13:16:51 -07:00
f_flow.c tc actions: Improved batching and time filtered dumping 2017-08-04 13:16:51 -07:00
f_flower.c Check user supplied interface name lengths 2017-10-02 08:01:21 -07:00
f_fw.c tc actions: Improved batching and time filtered dumping 2017-08-04 13:16:51 -07:00
f_matchall.c tc actions: Improved batching and time filtered dumping 2017-08-04 13:16:51 -07:00
f_route.c tc actions: Improved batching and time filtered dumping 2017-08-04 13:16:51 -07:00
f_rsvp.c tc actions: Improved batching and time filtered dumping 2017-08-04 13:16:51 -07:00
f_tcindex.c tc actions: Improved batching and time filtered dumping 2017-08-04 13:16:51 -07:00
f_u32.c tc: fix ipv6 filter selector attribute for some prefix lengths 2017-10-01 13:41:29 -07:00
m_action.c Merge branch 'master' into net-next 2017-09-05 09:33:29 -07:00
m_bpf.c bpf: consolidate dumps to use bpf_dump_prog_info 2017-09-05 09:26:34 -07:00
m_connmark.c tc/actions: introduce support for goto chain action 2017-05-22 13:31:51 -07:00
m_csum.c tc: actions: add helpers to parse and print control actions 2017-05-22 13:31:51 -07:00
m_ematch.c Use C99 style initializers everywhere 2016-07-20 12:05:24 -07:00
m_ematch.h include needed files 2012-12-23 11:49:06 -08:00
m_estimator.c tc: code cleanup 2016-03-21 11:48:36 -07:00
m_gact.c tc/actions: introduce support for jump action 2017-10-25 12:33:46 +02:00
m_ife.c tc: m_ife: report about kernels default type 2017-08-30 08:26:46 -07:00
m_ipt.c tc: pass correct conversion specifier to print 'unsigned int' action index. 2016-12-14 19:00:36 -08:00
m_mirred.c tc: actions: add helpers to parse and print control actions 2017-05-22 13:31:51 -07:00
m_nat.c tc: actions: add helpers to parse and print control actions 2017-05-22 13:31:51 -07:00
m_pedit.c tc/actions: introduce support for goto chain action 2017-05-22 13:31:51 -07:00
m_pedit.h pedit: fix whitespace 2017-05-01 09:25:22 -07:00
m_police.c tc/actions: introduce support for goto chain action 2017-05-22 13:31:51 -07:00
m_sample.c tc: actions: add helpers to parse and print control actions 2017-05-22 13:31:51 -07:00
m_simple.c tc: fix m_simple usage 2017-08-03 16:10:18 -07:00
m_skbedit.c tc: actions: add helpers to parse and print control actions 2017-05-22 13:31:51 -07:00
m_skbmod.c tc/actions: introduce support for goto chain action 2017-05-22 13:31:51 -07:00
m_tunnel_key.c tc: m_tunnel_key: add csum/nocsum option 2017-06-16 09:11:42 -07:00
m_vlan.c tc/actions: introduce support for goto chain action 2017-05-22 13:31:51 -07:00
m_xt_old.c tc: pass correct conversion specifier to print 'unsigned int' action index. 2016-12-14 19:00:36 -08:00
m_xt.c tc/m_xt: Fix for potential string buffer overflows 2017-08-24 14:53:14 -07:00
Makefile config: put CFLAGS/LDLIBS in config.mk 2017-08-23 10:03:09 -07:00
p_eth.c pedit: Check for extended capability in protocol parser 2017-05-15 15:05:20 -07:00
p_icmp.c tc/pedit: Extend pedit to specify offset relative to mac/transport headers 2017-05-01 09:22:16 -07:00
p_ip6.c pedit: Introduce ipv6 support 2017-05-15 15:05:20 -07:00
p_ip.c pedit: Introduce ipv6 support 2017-05-15 15:05:20 -07:00
p_tcp.c tc/pedit: p_tcp: introduce pedit tcp support 2017-05-01 09:22:16 -07:00
p_udp.c pedit: Check for extended capability in protocol parser 2017-05-15 15:05:20 -07:00
q_atm.c tc: use rta_getattr_u32 2017-02-24 15:24:34 -08:00
q_cbq.c Use C99 style initializers everywhere 2016-07-20 12:05:24 -07:00
q_choke.c Use C99 style initializers everywhere 2016-07-20 12:05:24 -07:00
q_clsact.c ingress, clsact: don't add TCA_OPTIONS to nl msg 2016-05-16 11:20:50 -07:00
q_codel.c Use C99 style initializers everywhere 2016-07-20 12:05:24 -07:00
q_drr.c tc: code cleanup 2016-03-21 11:48:36 -07:00
q_dsmark.c Use C99 style initializers everywhere 2016-07-20 12:05:24 -07:00
q_fifo.c Use C99 style initializers everywhere 2016-07-20 12:05:24 -07:00
q_fq_codel.c Use C99 style initializers everywhere 2016-07-20 12:05:24 -07:00
q_fq.c tc: fq: support low_rate_threshold attribute 2017-09-12 21:33:31 -07:00
q_gred.c tc: code cleanup 2016-03-21 11:48:36 -07:00
q_hfsc.c Use C99 style initializers everywhere 2016-07-20 12:05:24 -07:00
q_hhf.c tc: code cleanup 2016-03-21 11:48:36 -07:00
q_htb.c Use C99 style initializers everywhere 2016-07-20 12:05:24 -07:00
q_ingress.c ingress, clsact: don't add TCA_OPTIONS to nl msg 2016-05-16 11:20:50 -07:00
q_mqprio.c tc: use named initializer for default mqprio options 2017-08-24 15:28:15 -07:00
q_multiq.c tc/q_multiq: Don't pass garbage in TCA_OPTIONS 2017-08-21 17:17:00 -07:00
q_netem.c netem: fix code indentation 2017-10-11 18:08:15 -07:00
q_pie.c pie: remove always false condition 2017-03-10 08:58:01 -08:00
q_prio.c tc: code cleanup 2016-03-21 11:48:36 -07:00
q_qfq.c qfq: fix parse_opt dead code 2015-10-27 15:46:20 +09:00
q_red.c Use C99 style initializers everywhere 2016-07-20 12:05:24 -07:00
q_rr.c tc: code cleanup 2016-03-21 11:48:36 -07:00
q_sfb.c Use C99 style initializers everywhere 2016-07-20 12:05:24 -07:00
q_sfq.c Use C99 style initializers everywhere 2016-07-20 12:05:24 -07:00
q_tbf.c Use C99 style initializers everywhere 2016-07-20 12:05:24 -07:00
README.last tc: remove extra whitespace 2015-10-23 15:43:28 -07:00
static-syms.c Fix build when shared libraries are disabled 2013-03-13 08:29:59 -07:00
tc_cbq.c tc: code cleanup 2016-03-21 11:48:36 -07:00
tc_cbq.h (Logical change 1.3) 2004-04-15 20:56:59 +00:00
tc_class.c remove useless return statement 2016-09-01 08:44:20 -07:00
tc_common.h tc: built-in eBPF exec proxy 2015-04-27 16:39:23 -07:00
tc_core.c tc: include stdint.h explicitly for UINT16_MAX 2017-05-22 11:41:53 -07:00
tc_core.h htb: support 64bit rates 2013-11-22 17:36:18 -08:00
tc_estimator.c tc: code cleanup 2016-03-21 11:48:36 -07:00
tc_exec.c Replace malloc && memset by calloc 2016-07-20 12:05:24 -07:00
tc_filter.c tc/tc_filter: Make sure filter name is not empty 2017-08-24 14:49:44 -07:00
tc_monitor.c tc: code cleanup 2016-03-21 11:48:36 -07:00
tc_qdisc.c iproute2: add support for invisible qdisc dumping 2017-03-14 16:37:08 -07:00
tc_red.c tc: code cleanup 2016-03-21 11:48:36 -07:00
tc_red.h (Logical change 1.3) 2004-04-15 20:56:59 +00:00
tc_stab.c remove useless return statement 2016-09-01 08:44:20 -07:00
tc_util.c tc/actions: introduce support for jump action 2017-10-25 12:33:46 +02:00
tc_util.h tc actions: Improved batching and time filtered dumping 2017-08-04 13:16:51 -07:00
tc.c Replace malloc && memset by calloc 2016-07-20 12:05:24 -07:00

Kernel code and interface.
--------------------------

* Compile time switches

There is only one, but very important, compile time switch.
It is not settable by "make config", but should be selected
manually and after a bit of thinking in <include/net/pkt_sched.h>

PSCHED_CLOCK_SOURCE can take three values:

	PSCHED_GETTIMEOFDAY
	PSCHED_JIFFIES
	PSCHED_CPU


 PSCHED_GETTIMEOFDAY

Default setting is the most conservative PSCHED_GETTIMEOFDAY.
It is very slow both because of weird slowness of do_gettimeofday()
and because it forces code to use unnatural "timeval" format,
where microseconds and seconds fields are separate.
Besides that, it will misbehave, when delays exceed 2 seconds
(f.e. very slow links or classes bounded to small slice of bandwidth)
To resume: as only you will get it working, select correct clock
source and forget about PSCHED_GETTIMEOFDAY forever.


 PSCHED_JIFFIES

Clock is derived from jiffies. On architectures with HZ=100
granularity of this clock is not enough to make reasonable
bindings to real time. However, taking into account Linux
architecture problems, which force us to use artificial
integrated clock in any case, this switch is not so bad
for schduling even on high speed networks, though policing
is not reliable.


 PSCHED_CPU

It is available only for alpha and pentiums with correct
CPU timestamp. It is the fastest way, use it when it is available,
but remember: not all pentiums have this facility, and
a lot of them have clock, broken by APM etc. etc.