Skip to content

Commit 83d2fe6

Browse files
committed
Merge branch 'net_sched-prevent-creation-of-classes-with-tc_h_root'
Cong Wang says: ==================== net_sched: Prevent creation of classes with TC_H_ROOT This patchset contains a bug fix and its TDC test case. ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 081b575 + bb7737d commit 83d2fe6

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

net/sched/sch_api.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2254,6 +2254,12 @@ static int tc_ctl_tclass(struct sk_buff *skb, struct nlmsghdr *n,
22542254
return -EOPNOTSUPP;
22552255
}
22562256

2257+
/* Prevent creation of traffic classes with classid TC_H_ROOT */
2258+
if (clid == TC_H_ROOT) {
2259+
NL_SET_ERR_MSG(extack, "Cannot create traffic class with classid TC_H_ROOT");
2260+
return -EINVAL;
2261+
}
2262+
22572263
new_cl = cl;
22582264
err = -EOPNOTSUPP;
22592265
if (cops->change)

tools/testing/selftests/tc-testing/tc-tests/qdiscs/drr.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,30 @@
6161
"teardown": [
6262
"$TC qdisc del dev $DUMMY handle 1: root"
6363
]
64+
},
65+
{
66+
"id": "4009",
67+
"name": "Reject creation of DRR class with classid TC_H_ROOT",
68+
"category": [
69+
"qdisc",
70+
"drr"
71+
],
72+
"plugins": {
73+
"requires": "nsPlugin"
74+
},
75+
"setup": [
76+
"$TC qdisc add dev $DUMMY root handle ffff: drr",
77+
"$TC filter add dev $DUMMY parent ffff: basic classid ffff:1",
78+
"$TC class add dev $DUMMY parent ffff: classid ffff:1 drr",
79+
"$TC filter add dev $DUMMY parent ffff: prio 1 u32 match u16 0x0000 0xfe00 at 2 flowid ffff:ffff"
80+
],
81+
"cmdUnderTest": "$TC class add dev $DUMMY parent ffff: classid ffff:ffff drr",
82+
"expExitCode": "2",
83+
"verifyCmd": "$TC class show dev $DUMMY",
84+
"matchPattern": "class drr ffff:ffff",
85+
"matchCount": "0",
86+
"teardown": [
87+
"$TC qdisc del dev $DUMMY root"
88+
]
6489
}
6590
]

0 commit comments

Comments
 (0)