patch-2.4.1 linux/net/sched/sch_dsmark.c

Next file: linux/net/sched/sch_gred.c
Previous file: linux/net/sched/cls_u32.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0/linux/net/sched/sch_dsmark.c linux/net/sched/sch_dsmark.c
@@ -39,16 +39,22 @@
  *   x:y y>0	 y+1		use entry [y]
  *   ...	 ...		...
  * x:indices-1	indices		use entry [indices-1]
+ *   ...	 ...		...
+ *   x:y	 y+1		use entry [y & (indices-1)]
+ *   ...	 ...		...
+ * 0xffff	0x10000		use entry [indices-1]
  */
 
 
+#define NO_DEFAULT_INDEX	(1 << 16)
+
 struct dsmark_qdisc_data {
 	struct Qdisc		*q;
 	struct tcf_proto	*filter_list;
 	__u8			*mask;	/* "owns" the array */
 	__u8			*value;
 	__u16			indices;
-	__u16			default_index;
+	__u32			default_index;	/* index range is 0...0xffff */
 	int			set_tc_index;
 };
 
@@ -217,7 +223,7 @@
 			case TC_POLICE_UNSPEC:
 				/* fall through */
 			default:
-				if (p->default_index)
+				if (p->default_index != NO_DEFAULT_INDEX)
 					skb->tc_index = p->default_index;
 				break;
 		};
@@ -325,14 +331,12 @@
 		if (tmp & 1)
 			return -EINVAL;
 	}
-	p->default_index = 0;
+	p->default_index = NO_DEFAULT_INDEX;
 	if (tb[TCA_DSMARK_DEFAULT_INDEX-1]) {
 		if (RTA_PAYLOAD(tb[TCA_DSMARK_DEFAULT_INDEX-1]) < sizeof(__u16))
 			return -EINVAL;
 		p->default_index =
 		    *(__u16 *) RTA_DATA(tb[TCA_DSMARK_DEFAULT_INDEX-1]);
-		if (!p->default_index || p->default_index >= p->indices)
-			return -EINVAL;
 	}
 	p->set_tc_index = !!tb[TCA_DSMARK_SET_TC_INDEX-1];
 	p->mask = kmalloc(p->indices*2,GFP_KERNEL);
@@ -411,9 +415,11 @@
 	rta = (struct rtattr *) b;
 	RTA_PUT(skb,TCA_OPTIONS,0,NULL);
 	RTA_PUT(skb,TCA_DSMARK_INDICES,sizeof(__u16),&p->indices);
-	if (p->default_index)
-		RTA_PUT(skb,TCA_DSMARK_DEFAULT_INDEX, sizeof(__u16),
-			&p->default_index);
+	if (p->default_index != NO_DEFAULT_INDEX) {
+		__u16 tmp = p->default_index;
+
+		RTA_PUT(skb,TCA_DSMARK_DEFAULT_INDEX, sizeof(__u16), &tmp);
+	}
 	if (p->set_tc_index)
 		RTA_PUT(skb, TCA_DSMARK_SET_TC_INDEX, 0, NULL);
 	rta->rta_len = skb->tail-b;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)