mirror of
https://git.proxmox.com/git/mirror_iproute2
synced 2025-10-19 12:35:00 +00:00
Allow default DP of zero in gred
To emulate WRED behaviour, allow default DP of zero.
This commit is contained in:
parent
d13cee6d59
commit
ebde878097
49
tc/q_gred.c
49
tc/q_gred.c
@ -48,39 +48,40 @@ static void explain(void)
|
|||||||
|
|
||||||
#define usage() return(-1)
|
#define usage() return(-1)
|
||||||
|
|
||||||
static int init_gred(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
|
static int init_gred(struct qdisc_util *qu, int argc, char **argv,
|
||||||
|
struct nlmsghdr *n)
|
||||||
{
|
{
|
||||||
|
|
||||||
struct rtattr *tail;
|
struct rtattr *tail;
|
||||||
struct tc_gred_sopt opt;
|
struct tc_gred_sopt opt;
|
||||||
memset(&opt, 0, sizeof(struct tc_gred_sopt));
|
int dps = 0;
|
||||||
|
int def_dp = -1;
|
||||||
|
|
||||||
while (argc > 0) {
|
while (argc > 0) {
|
||||||
DPRINTF(stderr,"init_gred: invoked with %s\n",*argv);
|
DPRINTF(stderr,"init_gred: invoked with %s\n",*argv);
|
||||||
if (strcmp(*argv, "DPs") == 0) {
|
if (strcmp(*argv, "DPs") == 0) {
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
DPRINTF(stderr,"init_gred: next_arg with %s\n",*argv);
|
DPRINTF(stderr,"init_gred: next_arg with %s\n",*argv);
|
||||||
opt.DPs=strtol(*argv, (char **)NULL, 10);
|
dps = strtol(*argv, (char **)NULL, 10);
|
||||||
if (opt.DPs >MAX_DPs) { /* need a better error check */
|
if (dps < 0 || dps >MAX_DPs) {
|
||||||
fprintf(stderr, "DPs =%u \n",opt.DPs);
|
fprintf(stderr, "DPs =%d\n", dps);
|
||||||
fprintf(stderr, "Illegal \"DPs\"\n");
|
fprintf(stderr, "Illegal \"DPs\"\n");
|
||||||
fprintf(stderr, "GRED: only %d DPs are "
|
fprintf(stderr, "GRED: only %d DPs are "
|
||||||
"currently supported\n",MAX_DPs);
|
"currently supported\n",MAX_DPs);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else if (strcmp(*argv, "default") == 0) {
|
} else if (strcmp(*argv, "default") == 0) {
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
opt.def_DP=strtol(*argv, (char **)NULL, 10);
|
def_dp = strtol(*argv, (char **)NULL, 10);
|
||||||
if (!opt.DPs) {
|
if (dps) {
|
||||||
fprintf(stderr, "\"default DP\" must be "
|
fprintf(stderr, "\"default DP\" must be "
|
||||||
"defined after DPs\n");
|
"defined after DPs\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (opt.def_DP>opt.DPs) {
|
if (def_dp < 0 || def_dp > dps) {
|
||||||
/*
|
fprintf(stderr,
|
||||||
fprintf(stderr, "\"default DP\" must be less than %d\nNote: DP runs from 0 to %d for %d DPs\n",opt.DPs,opt.DPs-1,opt.DPs);
|
"\"default DP\" must be less than %d\n",
|
||||||
*/
|
opt.DPs);
|
||||||
fprintf(stderr, "\"default DP\" must be less than %d\n",opt.DPs);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else if (strcmp(*argv, "grio") == 0) {
|
} else if (strcmp(*argv, "grio") == 0) {
|
||||||
@ -94,20 +95,24 @@ static int init_gred(struct qdisc_util *qu, int argc, char **argv, struct nlmsgh
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
argc--; argv++;
|
argc--; argv++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!opt.DPs) || (!opt.def_DP))
|
if (!dps || def_dp == -1) {
|
||||||
{
|
fprintf(stderr, "Illegal gred setup parameters \n");
|
||||||
fprintf(stderr, "Illegal gred setup parameters \n");
|
return -1;
|
||||||
return -1;
|
}
|
||||||
}
|
|
||||||
DPRINTF("TC_GRED: sending DPs=%d default=%d\n",opt.DPs,opt.def_DP);
|
memset(&opt, 0, sizeof(struct tc_gred_sopt));
|
||||||
|
opt.DPs = dps;
|
||||||
|
opt.def_DP = def_dp;
|
||||||
|
|
||||||
|
DPRINTF("TC_GRED: sending DPs=%d default=%d\n",opt.DPs,opt.def_DP);
|
||||||
n->nlmsg_flags|=NLM_F_CREATE;
|
n->nlmsg_flags|=NLM_F_CREATE;
|
||||||
tail = NLMSG_TAIL(n);
|
tail = NLMSG_TAIL(n);
|
||||||
addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
|
addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
|
||||||
addattr_l(n, 1024, TCA_GRED_DPS, &opt, sizeof(struct tc_gred_sopt));
|
addattr_l(n, 1024, TCA_GRED_DPS, &opt, sizeof(struct tc_gred_sopt));
|
||||||
tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
|
tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
Loading…
Reference in New Issue
Block a user