[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
proposed patch to iproute2-2.2.4-now-ss001007
This patch changes the use of the default_index option of "tc qdisc dsmark"
as follows:
- "default_index 0" is no longer treated like an absent default_index
option, but tc tries to set the default index to 0 instead. If the
kernel contains the patch I've sent this morning, this works.
Otherwise (i.e. with an older kernel), we get EINVAL.
- defaut_index arguments larger than 0xffff are no longer silently
truncated, but you get an error instead
I don't think the second change is much of a problem. The first change
would break scripts that use "default_index 0" to explicitly request
that no default index be used. I think such usage is pretty uncommon,
and I'd take this small risk for the benefit of a consistent syntax.
Comments ?
- Werner
---------------------------------- cut here -----------------------------------
--- iproute2.orig/tc/q_dsmark.c Sun Apr 16 19:42:54 2000
+++ iproute2/tc/q_dsmark.c Thu Jan 4 14:51:53 2001
@@ -33,11 +33,12 @@
struct nlmsghdr *n)
{
struct rtattr *tail;
- __u16 ind,dflt;
+ __u16 ind;
char *end;
- int set_tc_index;
+ int set_tc_index,default_index;
- ind = dflt = set_tc_index = 0;
+ ind = set_tc_index = 0;
+ default_index = -1;
while (argc > 0) {
if (!strcmp(*argv,"indices")) {
NEXT_ARG();
@@ -50,8 +51,9 @@
else if (!strcmp(*argv,"default_index") || !strcmp(*argv,
"default")) {
NEXT_ARG();
- dflt = strtoul(*argv,&end,0);
- if (*end) {
+ default_index = strtol(*argv,&end,0);
+ if (*end || default_index < 0 ||
+ default_index > 0xffff) {
explain();
return -1;
}
@@ -73,7 +75,11 @@
tail = (struct rtattr *) (((void *) n)+NLMSG_ALIGN(n->nlmsg_len));
addattr_l(n,1024,TCA_OPTIONS,NULL,0);
addattr_l(n,1024,TCA_DSMARK_INDICES,&ind,sizeof(ind));
- if (dflt) addattr_l(n,1024,TCA_DSMARK_DEFAULT_INDEX,&dflt,sizeof(dflt));
+ if (default_index != -1) {
+ __u16 dflt = default_index;
+
+ addattr_l(n,1024,TCA_DSMARK_DEFAULT_INDEX,&dflt,sizeof(dflt));
+ }
if (set_tc_index) addattr_l(n,1024,TCA_DSMARK_SET_TC_INDEX,NULL,0);
tail->rta_len = (((void *) n)+n->nlmsg_len)-(void *) tail;
return 0;
--
_________________________________________________________________________
/ Werner Almesberger, ICA, EPFL, CH Werner.Almesberger@epfl.ch /
/_IN_N_032__Tel_+41_21_693_6621__Fax_+41_21_693_6610_____________________/