History

net: sched: Allow extending set of supported RED flags

The qdiscs RED, GRED, SFQ and CHOKE use different subsets of the same pool of global RED flags. These are passed in tc_red_qopt.flags. However none of these qdiscs validate the flag field, and just copy it over wholesale to internal structures, and later dump it back. (An exception is GRED, which does validate for VQs -- however not for the main setup.) A broken userspace can therefore configure a qdisc with arbitrary unsupported flags, and later expect to see the flags on qdisc dump. The current ABI therefore allows storage of several bits of custom data to qdisc instances of the types mentioned above. How many bits, depends on which flags are meaningful for the qdisc in question. E.g. SFQ recognizes flags ECN and HARDDROP, and the rest is not interpreted. If SFQ ever needs to support ADAPTATIVE, it needs another way of doing it, and at the same time it needs to retain the possibility to store 6 bits of uninterpreted data. Likewise RED, which adds a new flag later in this patchset. To that end, this patch adds a new function, red_get_flags(), to split the passed flags of RED-like qdiscs to flags and user bits, and red_validate_flags() to validate the resulting configuration. It further adds a new attribute, TCA_RED_FLAGS, to pass arbitrary flags.

Petr Machata committed 6 years ago

Commit 14bc1751 parent 10ef49b3 files · +89 −3Browse files

Showing the changes to include/uapi/linux (1 of 3 files). Show all

Unified · Split

include/uapi/linux/pkt_sched.h+16−0
@@ -256,6 +256,7 @@ enum { · 255 unmodified lines
256 TCA_RED_PARMS,256 TCA_RED_PARMS,
257 TCA_RED_STAB,257 TCA_RED_STAB,
258 TCA_RED_MAX_P,258 TCA_RED_MAX_P,
259 TCA_RED_FLAGS, /* bitfield32 */
259 __TCA_RED_MAX,260 __TCA_RED_MAX,
260};261};
261 262
@@ -268,12 +269,27 @@ struct tc_red_qopt { · 6 unmodified lines
268 unsigned char Wlog; /* log(W) */269 unsigned char Wlog; /* log(W) */
269 unsigned char Plog; /* log(P_max/(qth_max-qth_min)) */270 unsigned char Plog; /* log(P_max/(qth_max-qth_min)) */
270 unsigned char Scell_log; /* cell size for idle damping */271 unsigned char Scell_log; /* cell size for idle damping */
272
273 /* This field can be used for flags that a RED-like qdisc has
274 * historically supported. E.g. when configuring RED, it can be used for
275 * ECN, HARDDROP and ADAPTATIVE. For SFQ it can be used for ECN,
276 * HARDDROP. Etc. Because this field has not been validated, and is
277 * copied back on dump, any bits besides those to which a given qdisc
278 * has assigned a historical meaning need to be considered for free use
279 * by userspace tools.
280 *
281 * Any further flags need to be passed differently, e.g. through an
282 * attribute (such as TCA_RED_FLAGS above). Such attribute should allow
283 * passing both recent and historic flags in one value.
284 */
271 unsigned char flags;285 unsigned char flags;
272#define TC_RED_ECN 1286#define TC_RED_ECN 1
273#define TC_RED_HARDDROP 2287#define TC_RED_HARDDROP 2
274#define TC_RED_ADAPTATIVE 4288#define TC_RED_ADAPTATIVE 4
275};289};
276 290
291#define TC_RED_HISTORIC_FLAGS (TC_RED_ECN | TC_RED_HARDDROP | TC_RED_ADAPTATIVE)
292
277struct tc_red_xstats {293struct tc_red_xstats {
278 __u32 early; /* Early drops */294 __u32 early; /* Early drops */
279 __u32 pdrop; /* Drops due to queue limits */295 __u32 pdrop; /* Drops due to queue limits */