--- iproute2-5.10.0/include/uapi/linux/pkt_sched.h.orig 2021-02-24 19:32:20.974075535 +0100 +++ iproute2-5.10.0/include/uapi/linux/pkt_sched.h 2021-02-24 19:33:12.273391823 +0100 @@ -279,6 +279,14 @@ unsigned hash_kind; /* Hash function to use for flow identification */ }; +/* SRR section */ +struct tc_srr_qopt { + __u32 slots; + __u32 used_slots; + __u32 slot_limit; + __u32 slot_classify; +}; + /* RED section */ enum { diff -ruN iproute-20041019/tc/q_srr.c iproute-20041019.srr.patched.v0.4/tc/q_srr.c --- iproute-20041019/tc/q_srr.c 1970-01-01 03:00:00.000000000 +0300 +++ iproute-20041019.srr.patched.v0.4/tc/q_srr.c 2006-07-27 12:59:27.000000000 +0300 @@ -0,0 +1,118 @@ +#include +#include +#include +#include +#include +#include +#include + +#include "utils.h" +#include "tc_util.h" + +#define SRR_CL_SRC 0 +#define SRR_CL_DST 1 +#define SRR_CL_FWM 2 + +static void explain(void) +{ + fprintf(stderr, "Usage: ... srr [ slots NUMBER ] [ limit NUMBER ] [ classify src/dst/fw ]\n"); +} + +#define usage() return(-1) + +static int srr_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n) +{ + int ok=0; + struct tc_srr_qopt opt; + + memset(&opt, 0, sizeof(opt)); + + while ( argc > 0 ) { + if ( strcmp(*argv, "slots") == 0 ) { + NEXT_ARG(); + if ( get_u32(&opt.slots, *argv, 0) ) { + fprintf(stderr, "Illegal \"slot\"\n"); + return -1; + } + ok++; + } + else if ( strcmp(*argv, "limit") == 0 ) { + NEXT_ARG(); + if ( get_u32(&opt.slot_limit, *argv, 0) ) { + fprintf(stderr, "Illegal \"limit\"\n"); + } + ok++; + } + else if ( strcmp(*argv, "classify") == 0 ) { + NEXT_ARG(); + if ( strcmp(*argv, "src") == 0 ) { + opt.slot_classify = SRR_CL_SRC; + goto cl_ok; + } + if ( strcmp(*argv, "dst") == 0 ) { + opt.slot_classify = SRR_CL_DST; + goto cl_ok; + } + if ( strcmp(*argv, "fw") == 0 ) { + opt.slot_classify = SRR_CL_FWM; + goto cl_ok; + } + fprintf(stderr, "Illegal \"classify\"\n"); + return -1; + + cl_ok: ok++; + } + else if ( strcmp(*argv, "help") == 0 ) { + explain(); + return -1; + } + else { + fprintf(stderr, "What is \"%s\"?\n", *argv); + explain(); + return -1; + } + argc--; argv++; + } + + if ( ok ) + addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt)); + return 0; +} + +static int srr_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) +{ + struct tc_srr_qopt *qopt; + + if ( opt == NULL ) + return 0; + + if (RTA_PAYLOAD(opt) < sizeof(*qopt)) + return -1; + + qopt = RTA_DATA(opt); + fprintf(f, "slots %u ", qopt->slots); + fprintf(f, "used %u/%u ", qopt->used_slots, qopt->slots); + fprintf(f, "qlimit %u ", qopt->slot_limit); + switch (qopt->slot_classify) { + case SRR_CL_SRC: + fprintf(f, "classify IP_SRC"); + break; + case SRR_CL_DST: + fprintf(f, "classify IP_DST"); + break; + case SRR_CL_FWM: + fprintf(f, "classify FW"); + break; + default: + fprintf(f, "classify UNKNOW!!!"); + } + + return 0; +} + + +struct qdisc_util srr_qdisc_util = { + .id = "srr", + .parse_qopt = srr_parse_opt, + .print_qopt = srr_print_opt, +}; --- iproute2-5.10.0/tc/Makefile.orig 2021-02-24 19:32:21.377429702 +0100 +++ iproute2-5.10.0/tc/Makefile 2021-02-24 19:33:44.238376154 +0100 @@ -21,6 +21,7 @@ TCMODULES += q_netem.o TCMODULES += q_choke.o TCMODULES += q_sfb.o +TCMODULES += q_srr.o TCMODULES += q_wrr.o TCMODULES += f_rsvp.o TCMODULES += f_u32.o