All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: lartc@vger.kernel.org
Subject: Re: [LARTC] Adding dsmark qdisc fails
Date: Sun, 20 Mar 2005 15:15:36 +0000	[thread overview]
Message-ID: <423D9398.8050907@trash.net> (raw)
In-Reply-To: <BAY24-F131BDFCA526884F5089F76C54C0@phx.gbl>

[-- Attachment #1: Type: text/plain, Size: 1661 bytes --]

Tero Saarni wrote:
> I'm trying to configure dsmark qdisc on 2.6.11.4 user mode linux and
> tc from iproute2-2.6.11-050314.
> 
> I think I have some mismatch in my setup since adding dsmark qdisc
> fails *unless* I specify "set_tc_index" argument which I believe should
> be optional:
> 
> # tc qdisc add dev eth1 handle 1:0 root dsmark indices 8
> RTNETLINK answers: Invalid argument
> Mar 20 13:00:50 user user.debug kernel: dsmark_init(sch a0bb3ae0,[qdisc 
> a0bb3b60],opt 00000000)
> 
> here the log shows that opt is null, sch_dsmark checks for that and
> bails out.  However running tc with "set_tc_index" goes ok:
> 
> # tc qdisc add dev eth1 handle 1:0 root dsmark indices 8 set_tc_index
> Mar 20 13:01:12 user user.debug kernel: dsmark_init(sch a0bb3060,[qdisc 
> a0bb30e0],opt a038e9d0)
> Mar 20 13:01:12 user user.debug kernel: dsmark_init: qdisc a0bb30e0
> 
> # tc qdisc show dev eth1
> qdisc dsmark 1: indices 0x0008 set_tc_index
> 
> 
> but then changing the class fails:
> 
> # tc class change dev eth1 classid 1:1 dsmark mask 0x0 value 0xb8
> RTNETLINK answers: Invalid argument
> Mar 20 13:02:28 user user.debug kernel: dsmark_get(sch a0bb3060,[qdisc 
> a0bb30e0],classid 10001)
> Mar 20 13:02:28 user user.debug kernel: dsmark_change(sch 
> a0bb3060,[qdisc a0bb30e0],classid 10001,parent 0),arg 0x2
> 
> 
> Any ideas where I've gone wrong?

It is caused by this patch, the transformation to use NLMSG_TAIL is
not equivalent (it calculates the size of the aligned message). This
makes parsing the attributes in rtnetlink_rcv_msg() fail. I haven't 
checked what the exact problem is, Thomas, can you have a look at this
please?

Regards
Patrick

[-- Attachment #2: x --]
[-- Type: text/plain, Size: 19715 bytes --]

# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2005/01/18 02:24:18+01:00 tgraf@suug.ch 
#   Transform rta_len calculations for nested TLVs to use NLMSG_TAIL
#   macro to simply code a lot.
# 
# tc/q_tbf.c
#   2005/01/18 02:24:18+01:00 tgraf@suug.ch +2 -2
#   Use NLMSG_TAIL
# 
# tc/q_red.c
#   2005/01/18 02:24:18+01:00 tgraf@suug.ch +2 -3
#   Use NLMSG_TAIL
# 
# tc/q_netem.c
#   2005/01/18 02:24:18+01:00 tgraf@suug.ch +2 -2
#   Use NLMSG_TAIL
# 
# tc/q_htb.c
#   2005/01/18 02:24:18+01:00 tgraf@suug.ch +4 -4
#   Use NLMSG_TAIL
# 
# tc/q_hfsc.c
#   2005/01/18 02:24:18+01:00 tgraf@suug.ch +2 -2
#   Use NLMSG_TAIL
# 
# tc/q_gred.c
#   2005/01/18 02:24:18+01:00 tgraf@suug.ch +4 -6
#   Use NLMSG_TAIL
# 
# tc/q_dsmark.c
#   2005/01/18 02:24:18+01:00 tgraf@suug.ch +4 -4
#   Use NLMSG_TAIL
# 
# tc/q_cbq.c
#   2005/01/18 02:24:18+01:00 tgraf@suug.ch +4 -4
#   Use NLMSG_TAIL
# 
# tc/q_atm.c
#   2005/01/18 02:24:18+01:00 tgraf@suug.ch +2 -2
#   Use NLMSG_TAIL
# 
# tc/m_police.c
#   2005/01/18 02:24:18+01:00 tgraf@suug.ch +2 -2
#   Use NLMSG_TAIL
# 
# tc/m_pedit.c
#   2005/01/18 02:24:18+01:00 tgraf@suug.ch +2 -3
#   Use NLMSG_TAIL
# 
# tc/m_mirred.c
#   2005/01/18 02:24:18+01:00 tgraf@suug.ch +2 -3
#   Use NLMSG_TAIL
# 
# tc/m_ipt.c
#   2005/01/18 02:24:18+01:00 tgraf@suug.ch +2 -3
#   Use NLMSG_TAIL
# 
# tc/m_gact.c
#   2005/01/18 02:24:18+01:00 tgraf@suug.ch +2 -3
#   Use NLMSG_TAIL
# 
# tc/m_action.c
#   2005/01/18 02:24:18+01:00 tgraf@suug.ch +17 -30
#   Use NLMSG_TAIL
# 
# tc/f_u32.c
#   2005/01/18 02:24:18+01:00 tgraf@suug.ch +2 -2
#   Use NLMSG_TAIL
# 
# tc/f_tcindex.c
#   2005/01/18 02:24:18+01:00 tgraf@suug.ch +2 -2
#   Use NLMSG_TAIL
# 
# tc/f_rsvp.c
#   2005/01/18 02:24:18+01:00 tgraf@suug.ch +2 -2
#   Use NLMSG_TAIL
# 
# tc/f_route.c
#   2005/01/18 02:24:18+01:00 tgraf@suug.ch +2 -2
#   Use NLMSG_TAIL
# 
# tc/f_fw.c
#   2005/01/18 02:24:18+01:00 tgraf@suug.ch +2 -2
#   Use NLMSG_TAIL
# 
# include/libnetlink.h
#   2005/01/18 02:24:18+01:00 tgraf@suug.ch +3 -0
#   Add NLMSG_TAIL macro pointing to the tail of a netlink message
# 
diff -Nru a/include/libnetlink.h b/include/libnetlink.h
--- a/include/libnetlink.h	2005-03-20 15:54:37 +01:00
+++ b/include/libnetlink.h	2005-03-20 15:54:37 +01:00
@@ -46,5 +46,8 @@
 extern int rtnl_from_file(FILE *, rtnl_filter_t handler,
 		       void *jarg);
 
+#define NLMSG_TAIL(nmsg) \
+	((struct rtattr *) (((void *) (nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len)))
+
 #endif /* __LIBNETLINK_H__ */
 
diff -Nru a/tc/f_fw.c b/tc/f_fw.c
--- a/tc/f_fw.c	2005-03-20 15:54:37 +01:00
+++ b/tc/f_fw.c	2005-03-20 15:54:37 +01:00
@@ -50,7 +50,7 @@
 	if (argc == 0)
 		return 0;
 
-	tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
+	tail = NLMSG_TAIL(n);
 	addattr_l(n, 4096, TCA_OPTIONS, NULL, 0);
 
 	while (argc > 0) {
@@ -98,7 +98,7 @@
 		}
 		argc--; argv++;
 	}
-	tail->rta_len = (((void*)n)+n->nlmsg_len) - (void*)tail;
+	tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
 	return 0;
 }
 
diff -Nru a/tc/f_route.c b/tc/f_route.c
--- a/tc/f_route.c	2005-03-20 15:54:37 +01:00
+++ b/tc/f_route.c	2005-03-20 15:54:37 +01:00
@@ -54,7 +54,7 @@
 	if (argc == 0)
 		return 0;
 
-	tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
+	tail = NLMSG_TAIL(n);
 	addattr_l(n, 4096, TCA_OPTIONS, NULL, 0);
 
 	while (argc > 0) {
@@ -125,7 +125,7 @@
 		}
 		argc--; argv++;
 	}
-	tail->rta_len = (((void*)n)+n->nlmsg_len) - (void*)tail;
+	tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
 	if (order) {
 		fh &= ~0x7F00;
 		fh |= (order<<8)&0x7F00;
diff -Nru a/tc/f_rsvp.c b/tc/f_rsvp.c
--- a/tc/f_rsvp.c	2005-03-20 15:54:37 +01:00
+++ b/tc/f_rsvp.c	2005-03-20 15:54:37 +01:00
@@ -189,7 +189,7 @@
 	if (argc == 0)
 		return 0;
 
-	tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
+	tail = NLMSG_TAIL(n);
 	addattr_l(n, 4096, TCA_OPTIONS, NULL, 0);
 
 	while (argc > 0) {
@@ -282,7 +282,7 @@
 
 	if (pinfo_ok)
 		addattr_l(n, 4096, TCA_RSVP_PINFO, &pinfo, sizeof(pinfo));
-	tail->rta_len = (((void*)n)+n->nlmsg_len) - (void*)tail;
+	tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
 	return 0;
 }
 
diff -Nru a/tc/f_tcindex.c b/tc/f_tcindex.c
--- a/tc/f_tcindex.c	2005-03-20 15:54:37 +01:00
+++ b/tc/f_tcindex.c	2005-03-20 15:54:37 +01:00
@@ -43,7 +43,7 @@
 		}
 	}
 	if (!argc) return 0;
-	tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
+	tail = NLMSG_TAIL(n);
 	addattr_l(n,4096,TCA_OPTIONS,NULL,0);
 	while (argc) {
 		if (!strcmp(*argv,"hash")) {
@@ -117,7 +117,7 @@
 		argc--;
 		argv++;
 	}
-	tail->rta_len = (((void*)n)+n->nlmsg_len) - (void*)tail;
+	tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
 	return 0;
 }
 
diff -Nru a/tc/f_u32.c b/tc/f_u32.c
--- a/tc/f_u32.c	2005-03-20 15:54:37 +01:00
+++ b/tc/f_u32.c	2005-03-20 15:54:37 +01:00
@@ -794,7 +794,7 @@
 	if (argc == 0)
 		return 0;
 
-	tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
+	tail = NLMSG_TAIL(n);
 	addattr_l(n, MAX_MSG, TCA_OPTIONS, NULL, 0);
 
 	while (argc > 0) {
@@ -943,7 +943,7 @@
 		addattr_l(n, MAX_MSG, TCA_U32_HASH, &htid, 4);
 	if (sel_ok)
 		addattr_l(n, MAX_MSG, TCA_U32_SEL, &sel, sizeof(sel.sel)+sel.sel.nkeys*sizeof(struct tc_u32_key));
-	tail->rta_len = (((void*)n)+n->nlmsg_len) - (void*)tail;
+	tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
 	return 0;
 }
 
diff -Nru a/tc/m_action.c b/tc/m_action.c
--- a/tc/m_action.c	2005-03-20 15:54:37 +01:00
+++ b/tc/m_action.c	2005-03-20 15:54:37 +01:00
@@ -144,8 +144,7 @@
 	if (argc <= 0)
 		return -1;
 
-	tail = tail2 =
-	    (struct rtattr *) (((void *) n) + NLMSG_ALIGN(n->nlmsg_len));
+	tail = tail2 = NLMSG_TAIL(n);
 
 	addattr_l(n, MAX_MSG, tca_id, NULL, 0);
 
@@ -185,9 +184,7 @@
 				goto bad_val;
 			}
 
-			tail =
-			    (struct rtattr *) (((void *) n) +
-				       NLMSG_ALIGN(n->nlmsg_len));
+			tail = NLMSG_TAIL(n);
 			addattr_l(n, MAX_MSG, ++prio, NULL, 0);
 			addattr_l(n, MAX_MSG, TCA_ACT_KIND, k, strlen(k) + 1);
 
@@ -197,9 +194,7 @@
 				fprintf(stderr,"bad action parsing\n");
 				goto bad_val;
 			}
-			tail->rta_len =
-			    (((void *) n) + NLMSG_ALIGN(n->nlmsg_len)) -
-			    (void *) tail;
+			tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
 			ok++;
 		}
 
@@ -210,8 +205,7 @@
 		goto bad_val;
 	}
 
-	tail2->rta_len =
-	    (((void *) n) + NLMSG_ALIGN(n->nlmsg_len)) - (void *) tail2;
+	tail2->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail2;
 
 done:
 	*argc_p = argc;
@@ -376,8 +370,7 @@
 	argv +=1;
 
 
-	tail = (struct rtattr*)(((void*)&req.n)+NLMSG_ALIGN(req.n.nlmsg_len));
-
+	tail = NLMSG_TAIL(&req.n);
 	addattr_l(&req.n, MAX_MSG, TCA_ACT_TAB, NULL, 0);
 
 	while (argc > 0) {
@@ -425,17 +418,15 @@
 			goto bad_val;
 		}
 
-	tail2 =
-	   (struct rtattr *) (((void *) &req.n) + NLMSG_ALIGN(req.n.nlmsg_len));
-	addattr_l(&req.n, MAX_MSG, ++prio, NULL, 0);
-	addattr_l(&req.n, MAX_MSG, TCA_ACT_KIND, k, strlen(k) + 1);
-	addattr32(&req.n, MAX_MSG, TCA_ACT_INDEX, i);
-	tail2->rta_len =
-	    (((void *) &req.n) + NLMSG_ALIGN(req.n.nlmsg_len)) - (void *) tail2;
+		tail2 = NLMSG_TAIL(&req.n);
+		addattr_l(&req.n, MAX_MSG, ++prio, NULL, 0);
+		addattr_l(&req.n, MAX_MSG, TCA_ACT_KIND, k, strlen(k) + 1);
+		addattr32(&req.n, MAX_MSG, TCA_ACT_INDEX, i);
+		tail2->rta_len = (void *) NLMSG_TAIL(&req.n) - (void *) tail2;
 
 	}
 
-	tail->rta_len = (((void*)&req.n)+ NLMSG_ALIGN(req.n.nlmsg_len)) - (void*)tail;
+	tail->rta_len = (void *) NLMSG_TAIL(&req.n) - (void *) tail;
 
 	if (rtnl_open(&rth, 0) < 0) {
 		fprintf(stderr, "Cannot open rtnetlink\n");
@@ -485,14 +476,14 @@
 	req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcamsg));
 	req.n.nlmsg_flags = NLM_F_REQUEST|flags;
 	req.n.nlmsg_type = cmd;
-	tail = (struct rtattr*)(((void*)&req.n)+NLMSG_ALIGN(req.n.nlmsg_len));
+	tail = NLMSG_TAIL(&req.n);
 	argc -=1;
 	argv +=1;
 	if (parse_action(&argc, &argv, TCA_ACT_TAB, &req.n)) {
 		fprintf(stderr, "Illegal \"action\"\n");
 		return -1;
 	}
-	tail->rta_len = (((void*)&req.n)+req.n.nlmsg_len) - (void*)tail;
+	tail->rta_len = (void *) NLMSG_TAIL(&req.n) - (void *) tail;
 
 	if (rtnl_open(&rth, 0) < 0) {
 		fprintf(stderr, "Cannot open rtnetlink\n");
@@ -530,11 +521,9 @@
 
 	req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcamsg));
 
-	tail = (struct rtattr*)(((void*)&req.n)+NLMSG_ALIGN(req.n.nlmsg_len));
-
+	tail = NLMSG_TAIL(&req.n);
 	addattr_l(&req.n, MAX_MSG, TCA_ACT_TAB, NULL, 0);
-	tail2 =
-	   (struct rtattr *) (((void *) &req.n) + NLMSG_ALIGN(req.n.nlmsg_len));
+	tail2 = NLMSG_TAIL(&req.n);
 
 	strncpy(k, *argv, sizeof (k) - 1);
 #ifdef CONFIG_GACT
@@ -555,10 +544,8 @@
 
 	addattr_l(&req.n, MAX_MSG, ++prio, NULL, 0);
 	addattr_l(&req.n, MAX_MSG, TCA_ACT_KIND, k, strlen(k) + 1);
-	tail2->rta_len =
-	    (((void *) &req.n) + NLMSG_ALIGN(req.n.nlmsg_len)) - (void *) tail2;
-	tail->rta_len = (((void*)&req.n)+NLMSG_ALIGN(req.n.nlmsg_len)) - (void*)tail;
-
+	tail2->rta_len = (void *) NLMSG_TAIL(&req.n) - (void *) tail2;
+	tail->rta_len = (void *) NLMSG_TAIL(&req.n) - (void *) tail;
 
 	if (rtnl_open(&rth, 0) < 0) {
 		fprintf(stderr, "Cannot open rtnetlink\n");
diff -Nru a/tc/m_gact.c b/tc/m_gact.c
--- a/tc/m_gact.c	2005-03-20 15:54:37 +01:00
+++ b/tc/m_gact.c	2005-03-20 15:54:37 +01:00
@@ -177,7 +177,7 @@
 	if (!ok)
 		return -1;
 
-	tail = (struct rtattr *) (((void *) n) + NLMSG_ALIGN(n->nlmsg_len));
+	tail = NLMSG_TAIL(n);
 	addattr_l(n, MAX_MSG, tca_id, NULL, 0);
 	addattr_l(n, MAX_MSG, TCA_GACT_PARMS, &p, sizeof (p));
 #ifdef CONFIG_GACT_PROB
@@ -185,8 +185,7 @@
 		addattr_l(n, MAX_MSG, TCA_GACT_PROB, &pp, sizeof (pp));
 	}
 #endif
-	tail->rta_len =
-	    (((void *) n) + NLMSG_ALIGN(n->nlmsg_len)) - (void *) tail;
+	tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
 
 	*argc_p = argc;
 	*argv_p = argv;
diff -Nru a/tc/m_ipt.c b/tc/m_ipt.c
--- a/tc/m_ipt.c	2005-03-20 15:54:37 +01:00
+++ b/tc/m_ipt.c	2005-03-20 15:54:37 +01:00
@@ -547,7 +547,7 @@
 		}
 	}
 
-	tail = (struct rtattr *) (((void *) n) + NLMSG_ALIGN(n->nlmsg_len));
+	tail = NLMSG_TAIL(n);
 	addattr_l(n, MAX_MSG, tca_id, NULL, 0);
 	fprintf(stdout, "tablename: %s hook: %s\n ", tname, ipthooks[hook]);
 	fprintf(stdout, "\ttarget: ");
@@ -569,8 +569,7 @@
 	addattr_l(n, MAX_MSG, TCA_IPT_INDEX, &index, 4);
 	if (m)
 		addattr_l(n, MAX_MSG, TCA_IPT_TARG, m->t, m->t->u.target_size);
-	tail->rta_len =
-	    (((void *) n) + NLMSG_ALIGN(n->nlmsg_len)) - (void *) tail;
+	tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
 
 	argc -= optind;
 	argv += optind;
diff -Nru a/tc/m_mirred.c b/tc/m_mirred.c
--- a/tc/m_mirred.c	2005-03-20 15:54:37 +01:00
+++ b/tc/m_mirred.c	2005-03-20 15:54:37 +01:00
@@ -201,11 +201,10 @@
 	if (mirred_d)
 		fprintf(stdout, "Action %d device %s ifindex %d\n",p.action, d,p.ifindex);
 
-	tail = (struct rtattr *) (((void *) n) + NLMSG_ALIGN(n->nlmsg_len));
+	tail = NLMSG_TAIL(n);
 	addattr_l(n, MAX_MSG, tca_id, NULL, 0);
 	addattr_l(n, MAX_MSG, TCA_MIRRED_PARMS, &p, sizeof (p));
-	tail->rta_len =
-	    (((void *) n) + NLMSG_ALIGN(n->nlmsg_len)) - (void *) tail;
+	tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
 
 	*argc_p = argc;
 	*argv_p = argv;
diff -Nru a/tc/m_pedit.c b/tc/m_pedit.c
--- a/tc/m_pedit.c	2005-03-20 15:54:37 +01:00
+++ b/tc/m_pedit.c	2005-03-20 15:54:37 +01:00
@@ -534,11 +534,10 @@
 		}
 	}
 
-	tail = (struct rtattr *) (((void *) n) + NLMSG_ALIGN(n->nlmsg_len));
+	tail = NLMSG_TAIL(n);
 	addattr_l(n, MAX_MSG, tca_id, NULL, 0);
 	addattr_l(n, MAX_MSG, TCA_PEDIT_PARMS,&sel, sizeof(sel.sel)+sel.sel.nkeys*sizeof(struct tc_pedit_key));
-	tail->rta_len =
-	    (((void *) n) + NLMSG_ALIGN(n->nlmsg_len)) - (void *) tail;
+	tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
 
 	*argc_p = argc;
 	*argv_p = argv;
diff -Nru a/tc/m_police.c b/tc/m_police.c
--- a/tc/m_police.c	2005-03-20 15:54:37 +01:00
+++ b/tc/m_police.c	2005-03-20 15:54:37 +01:00
@@ -282,7 +282,7 @@
 		p.peakrate.mpu = mpu;
 	}
 
-	tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
+	tail = NLMSG_TAIL(n);
 	addattr_l(n, MAX_MSG, tca_id, NULL, 0);
 	addattr_l(n, MAX_MSG, TCA_POLICE_TBF, &p, sizeof(p));
 	if (p.rate.rate)
@@ -294,7 +294,7 @@
 	if (presult)
 		addattr32(n, MAX_MSG, TCA_POLICE_RESULT, presult);
 
-	tail->rta_len = (((void*)n)+NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail;
+	tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
 	res = 0;
 
 	*argc_p = argc;
diff -Nru a/tc/q_atm.c b/tc/q_atm.c
--- a/tc/q_atm.c	2005-03-20 15:54:37 +01:00
+++ b/tc/q_atm.c	2005-03-20 15:54:37 +01:00
@@ -179,12 +179,12 @@
 			perror("ioctl ATMARP_MKIP");
 			return -1;
 		}
-	tail = (struct rtattr *) (((void *) n)+NLMSG_ALIGN(n->nlmsg_len));
+	tail = NLMSG_TAIL(n);
 	addattr_l(n,1024,TCA_OPTIONS,NULL,0);
 	addattr_l(n,1024,TCA_ATM_FD,&s,sizeof(s));
 	if (excess) addattr_l(n,1024,TCA_ATM_EXCESS,&excess,sizeof(excess));
 	if (hdr_len != -1) addattr_l(n,1024,TCA_ATM_HDR,hdr,hdr_len);
-	tail->rta_len = (((void *) n)+NLMSG_ALIGN(n->nlmsg_len))-(void *) tail;
+	tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
 	return 0;
 }
 
diff -Nru a/tc/q_cbq.c b/tc/q_cbq.c
--- a/tc/q_cbq.c	2005-03-20 15:54:37 +01:00
+++ b/tc/q_cbq.c	2005-03-20 15:54:37 +01:00
@@ -151,7 +151,7 @@
 	lss.change = TCF_CBQ_LSS_MAXIDLE|TCF_CBQ_LSS_EWMA|TCF_CBQ_LSS_AVPKT;
 	lss.avpkt = avpkt;
 
-	tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
+	tail = NLMSG_TAIL(n);
 	addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
 	addattr_l(n, 1024, TCA_CBQ_RATE, &r, sizeof(r));
 	addattr_l(n, 1024, TCA_CBQ_LSSOPT, &lss, sizeof(lss));
@@ -162,7 +162,7 @@
 			printf("%u ", rtab[i]);
 		printf("\n");
 	}
-	tail->rta_len = (((void*)n)+NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail;
+	tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
 	return 0;
 }
 
@@ -385,7 +385,7 @@
 		lss.change |= TCF_CBQ_LSS_EWMA;
 	}
 
-	tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
+	tail = NLMSG_TAIL(n);
 	addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
 	if (lss.change) {
 		lss.change |= TCF_CBQ_LSS_FLAGS;
@@ -405,7 +405,7 @@
 			printf("\n");
 		}
 	}
-	tail->rta_len = (((void*)n)+NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail;
+	tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
 	return 0;
 }
 
diff -Nru a/tc/q_dsmark.c b/tc/q_dsmark.c
--- a/tc/q_dsmark.c	2005-03-20 15:54:37 +01:00
+++ b/tc/q_dsmark.c	2005-03-20 15:54:37 +01:00
@@ -71,7 +71,7 @@
 		explain();
 		return -1;
 	}
-	tail = (struct rtattr *) (((void *) n)+NLMSG_ALIGN(n->nlmsg_len));
+	tail = NLMSG_TAIL(n);
 	addattr_l(n,1024,TCA_OPTIONS,NULL,0);
 	addattr_l(n,1024,TCA_DSMARK_INDICES,&ind,sizeof(ind));
 	if (dflt != -1) {
@@ -80,7 +80,7 @@
 	    addattr_l(n,1024,TCA_DSMARK_DEFAULT_INDEX,&tmp,sizeof(tmp));
 	}
 	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;
+	tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
 	return 0;
 }
 
@@ -98,7 +98,7 @@
 	__u8 tmp;
 	char *end;
 
-	tail = (struct rtattr *) (((void *) n)+NLMSG_ALIGN(n->nlmsg_len));
+	tail = NLMSG_TAIL(n);
 	addattr_l(n,1024,TCA_OPTIONS,NULL,0);
 	while (argc > 0) {
 		if (!strcmp(*argv,"mask")) {
@@ -126,7 +126,7 @@
 		argc--;
 		argv++;
 	}
-	tail->rta_len = (((void *) n)+n->nlmsg_len)-(void *) tail;
+	tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
 	return 0;
 }
 
diff -Nru a/tc/q_gred.c b/tc/q_gred.c
--- a/tc/q_gred.c	2005-03-20 15:54:37 +01:00
+++ b/tc/q_gred.c	2005-03-20 15:54:37 +01:00
@@ -106,11 +106,10 @@
 }
 DPRINTF("TC_GRED: sending DPs=%d default=%d\n",opt.DPs,opt.def_DP);
 	n->nlmsg_flags|=NLM_F_CREATE;
-	tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
-
+	tail = NLMSG_TAIL(n);
 	addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
 	addattr_l(n, 1024, TCA_GRED_DPS, &opt, sizeof(struct tc_gred_sopt));
-	tail->rta_len = (((void*)n)+NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail;
+	tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
 return 0;
 }
 /*
@@ -252,12 +251,11 @@
 	}
 	opt.Scell_log = wlog;
 
-	tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
-
+	tail = NLMSG_TAIL(n);
 	addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
 	addattr_l(n, 1024, TCA_GRED_PARMS, &opt, sizeof(opt));
 	addattr_l(n, 1024, TCA_GRED_STAB, sbuf, 256);
-	tail->rta_len = (((void*)n)+NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail;
+	tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
 	return 0;
 }
 
diff -Nru a/tc/q_hfsc.c b/tc/q_hfsc.c
--- a/tc/q_hfsc.c	2005-03-20 15:54:37 +01:00
+++ b/tc/q_hfsc.c	2005-03-20 15:54:37 +01:00
@@ -205,7 +205,7 @@
 		return -1;
 	}
 
-	tail = (struct rtattr*)(((void*)n) + NLMSG_ALIGN(n->nlmsg_len));
+	tail = NLMSG_TAIL(n);
 
 	addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
 	if (rsc_ok)
@@ -215,7 +215,7 @@
 	if (usc_ok)
 		addattr_l(n, 1024, TCA_HFSC_USC, &usc, sizeof(usc));
 
-	tail->rta_len = (((void*)n) + NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail;
+	tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
 	return 0;
 }
 
diff -Nru a/tc/q_htb.c b/tc/q_htb.c
--- a/tc/q_htb.c	2005-03-20 15:54:37 +01:00
+++ b/tc/q_htb.c	2005-03-20 15:54:37 +01:00
@@ -93,10 +93,10 @@
 		}
 		argc--; argv++;
 	}
-	tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
+	tail = NLMSG_TAIL(n);
 	addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
 	addattr_l(n, 2024, TCA_HTB_INIT, &opt, NLMSG_ALIGN(sizeof(opt)));
-	tail->rta_len = (((void*)n)+NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail;
+	tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
 	return 0;
 }
 
@@ -224,12 +224,12 @@
 	opt.cbuffer = tc_calc_xmittime(opt.ceil.rate, cbuffer);
 	opt.ceil.cell_log = ccell_log;
 
-	tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
+	tail = NLMSG_TAIL(n);
 	addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
 	addattr_l(n, 2024, TCA_HTB_PARMS, &opt, sizeof(opt));
 	addattr_l(n, 3024, TCA_HTB_RTAB, rtab, 1024);
 	addattr_l(n, 4024, TCA_HTB_CTAB, ctab, 1024);
-	tail->rta_len = (((void*)n)+NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail;
+	tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
 	return 0;
 }
 
diff -Nru a/tc/q_netem.c b/tc/q_netem.c
--- a/tc/q_netem.c	2005-03-20 15:54:37 +01:00
+++ b/tc/q_netem.c	2005-03-20 15:54:37 +01:00
@@ -213,7 +213,7 @@
 		argc--; argv++;
 	}
 
-	tail = (struct rtattr*)(((void*)n) + NLMSG_ALIGN(n->nlmsg_len));
+	tail = NLMSG_TAIL(n);
 
 	addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
 	addattr_l(n, 1024, TCA_NETEM_CORR, &cor, sizeof(cor));
@@ -222,7 +222,7 @@
 		addattr_l(n, 32768, TCA_NETEM_DELAY_DIST,
 			  dist_data, dist_size*sizeof(dist_data[0]));
 	}
-	tail->rta_len = (((void*)n)+NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail;
+	tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
 	return 0;
 }
 
diff -Nru a/tc/q_red.c b/tc/q_red.c
--- a/tc/q_red.c	2005-03-20 15:54:37 +01:00
+++ b/tc/q_red.c	2005-03-20 15:54:37 +01:00
@@ -149,12 +149,11 @@
 #endif
 	}
 
-	tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
-
+	tail = NLMSG_TAIL(n);
 	addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
 	addattr_l(n, 1024, TCA_RED_PARMS, &opt, sizeof(opt));
 	addattr_l(n, 1024, TCA_RED_STAB, sbuf, 256);
-	tail->rta_len = (((void*)n)+NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail;
+	tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
 	return 0;
 }
 
diff -Nru a/tc/q_tbf.c b/tc/q_tbf.c
--- a/tc/q_tbf.c	2005-03-20 15:54:37 +01:00
+++ b/tc/q_tbf.c	2005-03-20 15:54:37 +01:00
@@ -187,13 +187,13 @@
 		opt.peakrate.mpu = mpu;
 	}
 
-	tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
+	tail = NLMSG_TAIL(n);
 	addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
 	addattr_l(n, 2024, TCA_TBF_PARMS, &opt, sizeof(opt));
 	addattr_l(n, 3024, TCA_TBF_RTAB, rtab, 1024);
 	if (opt.peakrate.rate)
 		addattr_l(n, 4096, TCA_TBF_PTAB, ptab, 1024);
-	tail->rta_len = (((void*)n)+NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail;
+	tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
 	return 0;
 }
 

[-- Attachment #3: Type: text/plain, Size: 143 bytes --]

_______________________________________________
LARTC mailing list
LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc

  reply	other threads:[~2005-03-20 15:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-20 13:06 [LARTC] Adding dsmark qdisc fails Tero Saarni
2005-03-20 15:15 ` Patrick McHardy [this message]
2005-03-20 16:25 ` Thomas Graf
2005-03-20 17:00 ` Tero Saarni
2006-01-05 21:34 ` Keith Mitchell
2006-01-06  0:38 ` Keith Mitchell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=423D9398.8050907@trash.net \
    --to=kaber@trash.net \
    --cc=lartc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.