xref: /linux/tools/testing/selftests/tc-testing/creating-testcases/scapy-example.json (revision ae22a94997b8a03dcb3c922857c203246711f9d4)
1[
2    {
3        "id": "b1e9",
4        "name": "Test matching of source IP",
5        "category": [
6            "actions",
7            "scapy"
8        ],
9        "plugins": {
10            "requires": [
11                "nsPlugin",
12                "scapyPlugin"
13            ]
14        },
15        "setup": [
16            [
17                "$TC qdisc del dev $DEV1 ingress",
18                0,
19                1,
20                2,
21                255
22            ],
23            "$TC qdisc add dev $DEV1 ingress"
24        ],
25        "cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: prio 3 protocol ip flower src_ip 16.61.16.61 flowid 1:1 action ok",
26        "scapy": {
27            "iface": "$DEV0",
28            "count": 1,
29            "packet": "Ether(type=0x800)/IP(src='16.61.16.61')/ICMP()"
30        },
31        "expExitCode": "0",
32        "verifyCmd": "$TC -s -j filter ls dev $DEV1 ingress prio 3",
33        "matchJSON": [
34            {
35                "path": [
36                    1,
37                    "options",
38                    "actions",
39                    0,
40                    "stats",
41                    "packets"
42                ],
43                "value": 1
44            }
45        ],
46        "teardown": [
47            "$TC qdisc del dev $DEV1 ingress"
48        ]
49    },
50    {
51        "id": "e9c4",
52        "name": "Test matching of source IP with wrong count",
53        "category": [
54            "actions",
55            "scapy"
56        ],
57        "plugins": {
58            "requires": [
59                "nsPlugin",
60                "scapyPlugin"
61            ]
62        },
63        "setup": [
64            [
65                "$TC qdisc del dev $DEV1 ingress",
66                0,
67                1,
68                2,
69                255
70            ],
71            "$TC qdisc add dev $DEV1 ingress"
72        ],
73        "cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: prio 3 protocol ip flower src_ip 16.61.16.61 flowid 1:1 action ok",
74        "scapy": {
75            "iface": "$DEV0",
76            "count": 3,
77            "packet": "Ether(type=0x800)/IP(src='16.61.16.61')/ICMP()"
78        },
79        "expExitCode": "0",
80        "verifyCmd": "$TC -s -j filter ls dev $DEV1 parent ffff:",
81        "matchJSON": [
82            {
83                "path": [
84                    1,
85                    "options",
86                    "actions",
87                    0,
88                    "stats",
89                    "packets"
90                ],
91                "value": 1
92            }
93        ],
94        "teardown": [
95            "$TC qdisc del dev $DEV1 ingress"
96        ]
97    }
98]
99