Skip to content

Commit f84974e

Browse files
committed
Merge branch 'tc-testing-dnat-tuple-collision'
Marcelo Ricardo Leitner says: ==================== tc-testing: add test for ct DNAT tuple collision That was fixed in 13c62f5 ("net/sched: act_ct: handle DNAT tuple collision"). For that, it requires that tdc is able to send diverse packets with scapy, which is then done on the 2nd patch of this series. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 1b134d8 + e469056 commit f84974e

File tree

2 files changed

+68
-19
lines changed

2 files changed

+68
-19
lines changed

tools/testing/selftests/tc-testing/plugin-lib/scapyPlugin.py

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,26 @@ def post_execute(self):
2929
return
3030

3131
# Check for required fields
32-
scapyinfo = self.args.caseinfo['scapy']
33-
scapy_keys = ['iface', 'count', 'packet']
34-
missing_keys = []
35-
keyfail = False
36-
for k in scapy_keys:
37-
if k not in scapyinfo:
38-
keyfail = True
39-
missing_keys.add(k)
40-
if keyfail:
41-
print('{}: Scapy block present in the test, but is missing info:'
42-
.format(self.sub_class))
43-
print('{}'.format(missing_keys))
44-
45-
pkt = eval(scapyinfo['packet'])
46-
if '$' in scapyinfo['iface']:
47-
tpl = Template(scapyinfo['iface'])
48-
scapyinfo['iface'] = tpl.safe_substitute(NAMES)
49-
for count in range(scapyinfo['count']):
50-
sendp(pkt, iface=scapyinfo['iface'])
32+
lscapyinfo = self.args.caseinfo['scapy']
33+
if type(lscapyinfo) != list:
34+
lscapyinfo = [ lscapyinfo, ]
35+
36+
for scapyinfo in lscapyinfo:
37+
scapy_keys = ['iface', 'count', 'packet']
38+
missing_keys = []
39+
keyfail = False
40+
for k in scapy_keys:
41+
if k not in scapyinfo:
42+
keyfail = True
43+
missing_keys.append(k)
44+
if keyfail:
45+
print('{}: Scapy block present in the test, but is missing info:'
46+
.format(self.sub_class))
47+
print('{}'.format(missing_keys))
48+
49+
pkt = eval(scapyinfo['packet'])
50+
if '$' in scapyinfo['iface']:
51+
tpl = Template(scapyinfo['iface'])
52+
scapyinfo['iface'] = tpl.safe_substitute(NAMES)
53+
for count in range(scapyinfo['count']):
54+
sendp(pkt, iface=scapyinfo['iface'])

tools/testing/selftests/tc-testing/tc-tests/actions/ct.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,5 +406,50 @@
406406
"teardown": [
407407
"$TC actions flush action ct"
408408
]
409+
},
410+
{
411+
"id": "3992",
412+
"name": "Add ct action triggering DNAT tuple conflict",
413+
"category": [
414+
"actions",
415+
"ct",
416+
"scapy"
417+
],
418+
"plugins": {
419+
"requires": [
420+
"nsPlugin",
421+
"scapyPlugin"
422+
]
423+
},
424+
"setup": [
425+
[
426+
"$TC qdisc del dev $DEV1 ingress",
427+
0,
428+
1,
429+
2,
430+
255
431+
],
432+
"$TC qdisc add dev $DEV1 ingress"
433+
],
434+
"cmdUnderTest": "$TC filter add dev $DEV1 ingress protocol ip prio 1 flower ct_state -trk action ct commit nat dst addr 20.0.0.1 port 10 pipe action drop",
435+
"scapy": [
436+
{
437+
"iface": "$DEV0",
438+
"count": 1,
439+
"packet": "Ether(type=0x800)/IP(src='10.0.0.10',dst='10.0.0.10')/TCP(sport=5000,dport=10)"
440+
},
441+
{
442+
"iface": "$DEV0",
443+
"count": 1,
444+
"packet": "Ether(type=0x800)/IP(src='10.0.0.10',dst='10.0.0.20')/TCP(sport=5000,dport=10)"
445+
}
446+
],
447+
"expExitCode": "0",
448+
"verifyCmd": "cat /proc/net/nf_conntrack",
449+
"matchPattern": "dst=10.0.0.20",
450+
"matchCount": "1",
451+
"teardown": [
452+
"$TC qdisc del dev $DEV1 ingress"
453+
]
409454
}
410455
]

0 commit comments

Comments
 (0)