the control path of 'sample' action does not validate the value of 'rate'
provided by the user, but then it uses it as divisor in the traffic path.
Validate it in tcf_sample_init(), and return -EINVAL with a proper extack
message in case that value is zero, to fix a splat with the script below:
# tc f a dev test0 egress matchall action sample rate 0 group 1 index 2
# tc -s a s action sample
total acts 1
action order 0: sample rate 1/0 group 1 pipe
index 2 ref 1 bind 1 installed 19 sec used 19 sec
Action statistics:
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
# ping 192.0.2.1 -I test0 -c1 -q
divide error: 0000 [#1] SMP PTI
CPU: 1 PID: 6192 Comm: ping Not tainted 5.1.0-rc2.diag2+ #591
Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
RIP: 0010:tcf_sample_act+0x9e/0x1e0 [act_sample]
Code: 6a f1 85 c0 74 0d 80 3d 83 1a 00 00 00 0f 84 9c 00 00 00 4d 85 e4 0f 84 85 00 00 00 e8 9b d7 9c f1 44 8b 8b e0 00 00 00 31 d2 <41> f7 f1 85 d2 75 70 f6 85 83 00 00 00 10 48 8b 45 10 8b 88 08 01
RSP: 0018:ffffae320190ba30 EFLAGS: 00010246
RAX: 00000000b0677d21 RBX: ffff8af1ed9ec000 RCX: 0000000059a9fe49
RDX: 0000000000000000 RSI: 000000000c7e33b7 RDI: ffff8af23daa0af0
RBP: ffff8af1ee11b200 R08: 0000000074fcaf7e R09: 0000000000000000
R10: 0000000000000050 R11: ffffffffb3088680 R12: ffff8af232307f80
R13: 0000000000000003 R14: ffff8af1ed9ec000 R15: 0000000000000000
FS: 00007fe9c6d2f740(0000) GS:ffff8af23da80000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fff6772f000 CR3: 00000000746a2004 CR4: 00000000001606e0
Call Trace:
tcf_action_exec+0x7c/0x1c0
tcf_classify+0x57/0x160
__dev_queue_xmit+0x3dc/0xd10
ip_finish_output2+0x257/0x6d0
ip_output+0x75/0x280
ip_send_skb+0x15/0x40
raw_sendmsg+0xae3/0x1410
sock_sendmsg+0x36/0x40
__sys_sendto+0x10e/0x140
__x64_sys_sendto+0x24/0x30
do_syscall_64+0x60/0x210
entry_SYSCALL_64_after_hwframe+0x49/0xbe
[...]
Kernel panic - not syncing: Fatal exception in interrupt
Add a TDC selftest to document that 'rate' is now being validated.
Reported-by: Matteo Croce <mcroce@redhat.com>
Fixes: 5c5670fae4 ("net/sched: Introduce sample tc action")
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Acked-by: Yotam Gigi <yotam.gi@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
638 lines
19 KiB
JSON
638 lines
19 KiB
JSON
[
|
|
{
|
|
"id": "9784",
|
|
"name": "Add valid sample action with mandatory arguments",
|
|
"category": [
|
|
"actions",
|
|
"sample"
|
|
],
|
|
"setup": [
|
|
[
|
|
"$TC actions flush action sample",
|
|
0,
|
|
1,
|
|
255
|
|
]
|
|
],
|
|
"cmdUnderTest": "$TC actions add action sample rate 10 group 1 index 2",
|
|
"expExitCode": "0",
|
|
"verifyCmd": "$TC actions get action sample index 2",
|
|
"matchPattern": "action order [0-9]+: sample rate 1/10 group 1.*index 2 ref",
|
|
"matchCount": "1",
|
|
"teardown": [
|
|
"$TC actions flush action sample"
|
|
]
|
|
},
|
|
{
|
|
"id": "5c91",
|
|
"name": "Add valid sample action with mandatory arguments and continue control action",
|
|
"category": [
|
|
"actions",
|
|
"sample"
|
|
],
|
|
"setup": [
|
|
[
|
|
"$TC actions flush action sample",
|
|
0,
|
|
1,
|
|
255
|
|
]
|
|
],
|
|
"cmdUnderTest": "$TC actions add action sample rate 700 group 2 continue index 2",
|
|
"expExitCode": "0",
|
|
"verifyCmd": "$TC actions get action sample index 2",
|
|
"matchPattern": "action order [0-9]+: sample rate 1/700 group 2 continue.*index 2 ref",
|
|
"matchCount": "1",
|
|
"teardown": [
|
|
"$TC actions flush action sample"
|
|
]
|
|
},
|
|
{
|
|
"id": "334b",
|
|
"name": "Add valid sample action with mandatory arguments and drop control action",
|
|
"category": [
|
|
"actions",
|
|
"sample"
|
|
],
|
|
"setup": [
|
|
[
|
|
"$TC actions flush action sample",
|
|
0,
|
|
1,
|
|
255
|
|
]
|
|
],
|
|
"cmdUnderTest": "$TC actions add action sample rate 10000 group 11 drop index 22",
|
|
"expExitCode": "0",
|
|
"verifyCmd": "$TC actions list action sample",
|
|
"matchPattern": "action order [0-9]+: sample rate 1/10000 group 11 drop.*index 22 ref",
|
|
"matchCount": "1",
|
|
"teardown": [
|
|
"$TC actions flush action sample"
|
|
]
|
|
},
|
|
{
|
|
"id": "da69",
|
|
"name": "Add valid sample action with mandatory arguments and reclassify control action",
|
|
"category": [
|
|
"actions",
|
|
"sample"
|
|
],
|
|
"setup": [
|
|
[
|
|
"$TC actions flush action sample",
|
|
0,
|
|
1,
|
|
255
|
|
]
|
|
],
|
|
"cmdUnderTest": "$TC actions add action sample rate 20000 group 72 reclassify index 100",
|
|
"expExitCode": "0",
|
|
"verifyCmd": "$TC actions list action sample",
|
|
"matchPattern": "action order [0-9]+: sample rate 1/20000 group 72 reclassify.*index 100 ref",
|
|
"matchCount": "1",
|
|
"teardown": [
|
|
"$TC actions flush action sample"
|
|
]
|
|
},
|
|
{
|
|
"id": "13ce",
|
|
"name": "Add valid sample action with mandatory arguments and pipe control action",
|
|
"category": [
|
|
"actions",
|
|
"sample"
|
|
],
|
|
"setup": [
|
|
[
|
|
"$TC actions flush action sample",
|
|
0,
|
|
1,
|
|
255
|
|
]
|
|
],
|
|
"cmdUnderTest": "$TC actions add action sample rate 20 group 2 pipe index 100",
|
|
"expExitCode": "0",
|
|
"verifyCmd": "$TC actions list action sample",
|
|
"matchPattern": "action order [0-9]+: sample rate 1/20 group 2 pipe.*index 100 ref",
|
|
"matchCount": "1",
|
|
"teardown": [
|
|
"$TC actions flush action sample"
|
|
]
|
|
},
|
|
{
|
|
"id": "1886",
|
|
"name": "Add valid sample action with mandatory arguments and jump control action",
|
|
"category": [
|
|
"actions",
|
|
"sample"
|
|
],
|
|
"setup": [
|
|
[
|
|
"$TC actions flush action sample",
|
|
0,
|
|
1,
|
|
255
|
|
]
|
|
],
|
|
"cmdUnderTest": "$TC actions add action sample rate 700 group 25 jump 4 index 200",
|
|
"expExitCode": "0",
|
|
"verifyCmd": "$TC actions get action sample index 200",
|
|
"matchPattern": "action order [0-9]+: sample rate 1/700 group 25 jump 4.*index 200 ref",
|
|
"matchCount": "1",
|
|
"teardown": [
|
|
"$TC actions flush action sample"
|
|
]
|
|
},
|
|
{
|
|
"id": "7571",
|
|
"name": "Add sample action with invalid rate",
|
|
"category": [
|
|
"actions",
|
|
"sample"
|
|
],
|
|
"setup": [
|
|
[
|
|
"$TC actions flush action sample",
|
|
0,
|
|
1,
|
|
255
|
|
]
|
|
],
|
|
"cmdUnderTest": "$TC actions add action sample rate 0 group 1 index 2",
|
|
"expExitCode": "255",
|
|
"verifyCmd": "$TC actions get action sample index 2",
|
|
"matchPattern": "action order [0-9]+: sample rate 1/0 group 1.*index 2 ref",
|
|
"matchCount": "0",
|
|
"teardown": [
|
|
"$TC actions flush action sample"
|
|
]
|
|
},
|
|
{
|
|
"id": "b6d4",
|
|
"name": "Add sample action with mandatory arguments and invalid control action",
|
|
"category": [
|
|
"actions",
|
|
"sample"
|
|
],
|
|
"setup": [
|
|
[
|
|
"$TC actions flush action sample",
|
|
0,
|
|
1,
|
|
255
|
|
]
|
|
],
|
|
"cmdUnderTest": "$TC actions add action sample rate 200000 group 52 foo index 1",
|
|
"expExitCode": "255",
|
|
"verifyCmd": "$TC actions list action sample",
|
|
"matchPattern": "action order [0-9]+: sample rate 1/200000 group 52 foo.*index 1 ref",
|
|
"matchCount": "0",
|
|
"teardown": []
|
|
},
|
|
{
|
|
"id": "a874",
|
|
"name": "Add invalid sample action without mandatory arguments",
|
|
"category": [
|
|
"actions",
|
|
"sample"
|
|
],
|
|
"setup": [
|
|
[
|
|
"$TC actions flush action sample",
|
|
0,
|
|
1,
|
|
255
|
|
]
|
|
],
|
|
"cmdUnderTest": "$TC actions add action sample index 1",
|
|
"expExitCode": "255",
|
|
"verifyCmd": "$TC actions list action sample",
|
|
"matchPattern": "action order [0-9]+: sample.*index 1 ref",
|
|
"matchCount": "0",
|
|
"teardown": []
|
|
},
|
|
{
|
|
"id": "ac01",
|
|
"name": "Add invalid sample action without mandatory argument rate",
|
|
"category": [
|
|
"actions",
|
|
"sample"
|
|
],
|
|
"setup": [
|
|
[
|
|
"$TC actions flush action sample",
|
|
0,
|
|
1,
|
|
255
|
|
]
|
|
],
|
|
"cmdUnderTest": "$TC actions add action sample group 10 index 1",
|
|
"expExitCode": "255",
|
|
"verifyCmd": "$TC actions list action sample",
|
|
"matchPattern": "action order [0-9]+: sample.*group 10.*index 1 ref",
|
|
"matchCount": "0",
|
|
"teardown": []
|
|
},
|
|
{
|
|
"id": "4203",
|
|
"name": "Add invalid sample action without mandatory argument group",
|
|
"category": [
|
|
"actions",
|
|
"sample"
|
|
],
|
|
"setup": [
|
|
[
|
|
"$TC actions flush action sample",
|
|
0,
|
|
1,
|
|
255
|
|
]
|
|
],
|
|
"cmdUnderTest": "$TC actions add action sample rate 100 index 10",
|
|
"expExitCode": "255",
|
|
"verifyCmd": "$TC actions get action sample index 10",
|
|
"matchPattern": "action order [0-9]+: sample rate 1/100.*index 10 ref",
|
|
"matchCount": "0",
|
|
"teardown": []
|
|
},
|
|
{
|
|
"id": "14a7",
|
|
"name": "Add invalid sample action without mandatory argument group",
|
|
"category": [
|
|
"actions",
|
|
"sample"
|
|
],
|
|
"setup": [
|
|
[
|
|
"$TC actions flush action sample",
|
|
0,
|
|
1,
|
|
255
|
|
]
|
|
],
|
|
"cmdUnderTest": "$TC actions add action sample rate 100 index 10",
|
|
"expExitCode": "255",
|
|
"verifyCmd": "$TC actions get action sample index 10",
|
|
"matchPattern": "action order [0-9]+: sample rate 1/100.*index 10 ref",
|
|
"matchCount": "0",
|
|
"teardown": []
|
|
},
|
|
{
|
|
"id": "8f2e",
|
|
"name": "Add valid sample action with trunc argument",
|
|
"category": [
|
|
"actions",
|
|
"sample"
|
|
],
|
|
"setup": [
|
|
[
|
|
"$TC actions flush action sample",
|
|
0,
|
|
1,
|
|
255
|
|
]
|
|
],
|
|
"cmdUnderTest": "$TC actions add action sample rate 1024 group 4 trunc 1024 index 10",
|
|
"expExitCode": "0",
|
|
"verifyCmd": "$TC actions get action sample index 10",
|
|
"matchPattern": "action order [0-9]+: sample rate 1/1024 group 4 trunc_size 1024 pipe.*index 10 ref",
|
|
"matchCount": "1",
|
|
"teardown": [
|
|
"$TC actions flush action sample"
|
|
]
|
|
},
|
|
{
|
|
"id": "45f8",
|
|
"name": "Add sample action with maximum rate argument",
|
|
"category": [
|
|
"actions",
|
|
"sample"
|
|
],
|
|
"setup": [
|
|
[
|
|
"$TC actions flush action sample",
|
|
0,
|
|
1,
|
|
255
|
|
]
|
|
],
|
|
"cmdUnderTest": "$TC actions add action sample rate 4294967295 group 4 index 10",
|
|
"expExitCode": "0",
|
|
"verifyCmd": "$TC actions get action sample index 10",
|
|
"matchPattern": "action order [0-9]+: sample rate 1/4294967295 group 4 pipe.*index 10 ref",
|
|
"matchCount": "1",
|
|
"teardown": [
|
|
"$TC actions flush action sample"
|
|
]
|
|
},
|
|
{
|
|
"id": "ad0c",
|
|
"name": "Add sample action with maximum trunc argument",
|
|
"category": [
|
|
"actions",
|
|
"sample"
|
|
],
|
|
"setup": [
|
|
[
|
|
"$TC actions flush action sample",
|
|
0,
|
|
1,
|
|
255
|
|
]
|
|
],
|
|
"cmdUnderTest": "$TC actions add action sample rate 16000 group 4 trunc 4294967295 index 10",
|
|
"expExitCode": "0",
|
|
"verifyCmd": "$TC actions get action sample index 10",
|
|
"matchPattern": "action order [0-9]+: sample rate 1/16000 group 4 trunc_size 4294967295 pipe.*index 10 ref",
|
|
"matchCount": "1",
|
|
"teardown": [
|
|
"$TC actions flush action sample"
|
|
]
|
|
},
|
|
{
|
|
"id": "83a9",
|
|
"name": "Add sample action with maximum group argument",
|
|
"category": [
|
|
"actions",
|
|
"sample"
|
|
],
|
|
"setup": [
|
|
[
|
|
"$TC actions flush action sample",
|
|
0,
|
|
1,
|
|
255
|
|
]
|
|
],
|
|
"cmdUnderTest": "$TC actions add action sample rate 4294 group 4294967295 index 1",
|
|
"expExitCode": "0",
|
|
"verifyCmd": "$TC actions get action sample index 1",
|
|
"matchPattern": "action order [0-9]+: sample rate 1/4294 group 4294967295 pipe.*index 1 ref",
|
|
"matchCount": "1",
|
|
"teardown": [
|
|
"$TC actions flush action sample"
|
|
]
|
|
},
|
|
{
|
|
"id": "ed27",
|
|
"name": "Add sample action with invalid rate argument",
|
|
"category": [
|
|
"actions",
|
|
"sample"
|
|
],
|
|
"setup": [
|
|
[
|
|
"$TC actions flush action sample",
|
|
0,
|
|
1,
|
|
255
|
|
]
|
|
],
|
|
"cmdUnderTest": "$TC actions add action sample rate 4294967296 group 4 index 10",
|
|
"expExitCode": "255",
|
|
"verifyCmd": "$TC actions get action sample index 10",
|
|
"matchPattern": "action order [0-9]+: sample rate 1/4294967296 group 4 pipe.*index 10 ref",
|
|
"matchCount": "0",
|
|
"teardown": []
|
|
},
|
|
{
|
|
"id": "2eae",
|
|
"name": "Add sample action with invalid group argument",
|
|
"category": [
|
|
"actions",
|
|
"sample"
|
|
],
|
|
"setup": [
|
|
[
|
|
"$TC actions flush action sample",
|
|
0,
|
|
1,
|
|
255
|
|
]
|
|
],
|
|
"cmdUnderTest": "$TC actions add action sample rate 4098 group 5294967299 continue index 1",
|
|
"expExitCode": "255",
|
|
"verifyCmd": "$TC actions get action sample index 1",
|
|
"matchPattern": "action order [0-9]+: sample rate 1/4098 group 5294967299 continue.*index 1 ref",
|
|
"matchCount": "0",
|
|
"teardown": []
|
|
},
|
|
{
|
|
"id": "6ff3",
|
|
"name": "Add sample action with invalid trunc size",
|
|
"category": [
|
|
"actions",
|
|
"sample"
|
|
],
|
|
"setup": [
|
|
[
|
|
"$TC actions flush action sample",
|
|
0,
|
|
1,
|
|
255
|
|
]
|
|
],
|
|
"cmdUnderTest": "$TC actions add action sample rate 1024 group 4 trunc 112233445566 index 11",
|
|
"expExitCode": "255",
|
|
"verifyCmd": "$TC actions get action sample index 11",
|
|
"matchPattern": "action order [0-9]+: sample rate 1/1024 group 4 trunc_size 112233445566.*index 11 ref",
|
|
"matchCount": "0",
|
|
"teardown": []
|
|
},
|
|
{
|
|
"id": "2b2a",
|
|
"name": "Add sample action with invalid index",
|
|
"category": [
|
|
"actions",
|
|
"sample"
|
|
],
|
|
"setup": [
|
|
[
|
|
"$TC actions flush action sample",
|
|
0,
|
|
1,
|
|
255
|
|
]
|
|
],
|
|
"cmdUnderTest": "$TC actions add action sample rate 1024 group 4 index 5294967299",
|
|
"expExitCode": "255",
|
|
"verifyCmd": "$TC actions get action sample index 5294967299",
|
|
"matchPattern": "action order [0-9]+: sample rate 1/1024 group 4 pipe.*index 5294967299 ref",
|
|
"matchCount": "0",
|
|
"teardown": []
|
|
},
|
|
{
|
|
"id": "dee2",
|
|
"name": "Add sample action with maximum allowed index",
|
|
"category": [
|
|
"actions",
|
|
"sample"
|
|
],
|
|
"setup": [
|
|
[
|
|
"$TC actions flush action sample",
|
|
0,
|
|
1,
|
|
255
|
|
]
|
|
],
|
|
"cmdUnderTest": "$TC actions add action sample rate 1024 group 4 index 4294967295",
|
|
"expExitCode": "0",
|
|
"verifyCmd": "$TC actions get action sample index 4294967295",
|
|
"matchPattern": "action order [0-9]+: sample rate 1/1024 group 4 pipe.*index 4294967295 ref",
|
|
"matchCount": "1",
|
|
"teardown": [
|
|
"$TC actions flush action sample"
|
|
]
|
|
},
|
|
{
|
|
"id": "560e",
|
|
"name": "Add sample action with cookie",
|
|
"category": [
|
|
"actions",
|
|
"sample"
|
|
],
|
|
"setup": [
|
|
[
|
|
"$TC actions flush action sample",
|
|
0,
|
|
1,
|
|
255
|
|
]
|
|
],
|
|
"cmdUnderTest": "$TC actions add action sample rate 1024 group 4 index 45 cookie aabbccdd",
|
|
"expExitCode": "0",
|
|
"verifyCmd": "$TC actions get action sample index 45",
|
|
"matchPattern": "action order [0-9]+: sample rate 1/1024 group 4 pipe.*index 45.*cookie aabbccdd",
|
|
"matchCount": "1",
|
|
"teardown": [
|
|
"$TC actions flush action sample"
|
|
]
|
|
},
|
|
{
|
|
"id": "704a",
|
|
"name": "Replace existing sample action with new rate argument",
|
|
"category": [
|
|
"actions",
|
|
"sample"
|
|
],
|
|
"setup": [
|
|
[
|
|
"$TC actions flush action sample",
|
|
0,
|
|
1,
|
|
255
|
|
],
|
|
"$TC actions add action sample rate 1024 group 4 index 4"
|
|
],
|
|
"cmdUnderTest": "$TC actions replace action sample rate 2048 group 4 index 4",
|
|
"expExitCode": "0",
|
|
"verifyCmd": "$TC actions list action sample",
|
|
"matchPattern": "action order [0-9]+: sample rate 1/2048 group 4 pipe.*index 4",
|
|
"matchCount": "1",
|
|
"teardown": [
|
|
"$TC actions flush action sample"
|
|
]
|
|
},
|
|
{
|
|
"id": "60eb",
|
|
"name": "Replace existing sample action with new group argument",
|
|
"category": [
|
|
"actions",
|
|
"sample"
|
|
],
|
|
"setup": [
|
|
[
|
|
"$TC actions flush action sample",
|
|
0,
|
|
1,
|
|
255
|
|
],
|
|
"$TC actions add action sample rate 1024 group 4 index 4"
|
|
],
|
|
"cmdUnderTest": "$TC actions replace action sample rate 1024 group 7 index 4",
|
|
"expExitCode": "0",
|
|
"verifyCmd": "$TC actions list action sample",
|
|
"matchPattern": "action order [0-9]+: sample rate 1/1024 group 7 pipe.*index 4",
|
|
"matchCount": "1",
|
|
"teardown": [
|
|
"$TC actions flush action sample"
|
|
]
|
|
},
|
|
{
|
|
"id": "2cce",
|
|
"name": "Replace existing sample action with new trunc argument",
|
|
"category": [
|
|
"actions",
|
|
"sample"
|
|
],
|
|
"setup": [
|
|
[
|
|
"$TC actions flush action sample",
|
|
0,
|
|
1,
|
|
255
|
|
],
|
|
"$TC actions add action sample rate 1024 group 4 trunc 48 index 4"
|
|
],
|
|
"cmdUnderTest": "$TC actions replace action sample rate 1024 group 7 trunc 64 index 4",
|
|
"expExitCode": "0",
|
|
"verifyCmd": "$TC actions list action sample",
|
|
"matchPattern": "action order [0-9]+: sample rate 1/1024 group 7 trunc_size 64 pipe.*index 4",
|
|
"matchCount": "1",
|
|
"teardown": [
|
|
"$TC actions flush action sample"
|
|
]
|
|
},
|
|
{
|
|
"id": "59d1",
|
|
"name": "Replace existing sample action with new control argument",
|
|
"category": [
|
|
"actions",
|
|
"sample"
|
|
],
|
|
"setup": [
|
|
[
|
|
"$TC actions flush action sample",
|
|
0,
|
|
1,
|
|
255
|
|
],
|
|
"$TC actions add action sample rate 1024 group 4 reclassify index 4"
|
|
],
|
|
"cmdUnderTest": "$TC actions replace action sample rate 1024 group 7 pipe index 4",
|
|
"expExitCode": "0",
|
|
"verifyCmd": "$TC actions list action sample",
|
|
"matchPattern": "action order [0-9]+: sample rate 1/1024 group 7 pipe.*index 4",
|
|
"matchCount": "1",
|
|
"teardown": [
|
|
"$TC actions flush action sample"
|
|
]
|
|
},
|
|
{
|
|
"id": "0a6e",
|
|
"name": "Replace sample action with invalid goto chain control",
|
|
"category": [
|
|
"actions",
|
|
"sample"
|
|
],
|
|
"setup": [
|
|
[
|
|
"$TC actions flush action sample",
|
|
0,
|
|
1,
|
|
255
|
|
],
|
|
"$TC actions add action sample rate 1024 group 4 pass index 90"
|
|
],
|
|
"cmdUnderTest": "$TC actions replace action sample rate 1024 group 7 goto chain 42 index 90 cookie c1a0c1a0",
|
|
"expExitCode": "255",
|
|
"verifyCmd": "$TC actions list action sample",
|
|
"matchPattern": "action order [0-9]+: sample rate 1/1024 group 4 pass.*index 90",
|
|
"matchCount": "1",
|
|
"teardown": [
|
|
"$TC actions flush action sample"
|
|
]
|
|
}
|
|
]
|