mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-22 23:17:41 -04:00
selftests: tc: act_pedit: require matching IPv4 L4 protocol
Add a tdc test that checks the act_pedit extended L4 header mode does not edit a packet whose IPv4 protocol does not match the selected transport header. The test installs an ingress pedit rule that sets the UDP destination port, then injects a TCP packet with dport 2222. The UDP and TCP destination ports sit at the same L4 offset, so a buggy kernel rewrites the TCP dport. A second flower filter matches TCP dport 2222 and drops the packet through an indexed gact action; the test then verifies via JSON that this action saw exactly one packet, i.e. the dport was left untouched and still matched 2222. Signed-off-by: Victor Nogueira <victor@mojatatu.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
d504a97857
commit
f7d109f176
@@ -1920,5 +1920,54 @@
|
||||
"teardown": [
|
||||
"$TC actions flush action pedit"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "1a4f",
|
||||
"name": "Pedit udp dport should not mangle TCP packet dport",
|
||||
"category": [
|
||||
"actions",
|
||||
"pedit"
|
||||
],
|
||||
"plugins": {
|
||||
"requires": [
|
||||
"nsPlugin",
|
||||
"scapyPlugin"
|
||||
]
|
||||
},
|
||||
"setup": [
|
||||
"$TC qdisc add dev $DEV1 clsact",
|
||||
"$TC filter add dev $DEV1 ingress protocol ip pref 1 matchall action pedit ex munge udp dport set 18053 continue"
|
||||
],
|
||||
"cmdUnderTest": "$TC filter add dev $DEV1 ingress protocol ip pref 2 flower ip_proto tcp dst_port 2222 action drop index 1",
|
||||
"scapy": {
|
||||
"iface": "$DEV0",
|
||||
"count": 1,
|
||||
"packet": "Ether()/IP(dst='10.10.10.1')/TCP(dport=2222)"
|
||||
},
|
||||
"expExitCode": "0",
|
||||
"verifyCmd": "$TC -j -s actions get action gact index 1",
|
||||
"matchJSON": [
|
||||
{
|
||||
"total acts": 0
|
||||
},
|
||||
{
|
||||
"actions": [
|
||||
{
|
||||
"order": 1,
|
||||
"kind": "gact",
|
||||
"control_action": {
|
||||
"type": "drop"
|
||||
},
|
||||
"index": 1,
|
||||
"stats": {
|
||||
"packets": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"teardown": [
|
||||
"$TC qdisc del dev $DEV1 clsact"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user