[PATCH] IPROUTE: correct nla nested message generated by netem_parse_opt

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jeff Kirsher
Date: Thursday, August 21, 2008 - 5:50 pm

From: Alexander Duyck <alexander.h.duyck@intel.com>

netem_parse_opt was generating a malformed nested compat message.  This patch
corrects it so that the nested arguments are contained within a nested nla
header.

Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---

 tc/q_netem.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/tc/q_netem.c b/tc/q_netem.c
index d06932e..a3365c1 100644
--- a/tc/q_netem.c
+++ b/tc/q_netem.c
@@ -128,7 +128,7 @@ static int netem_parse_opt(struct qdisc_util *qu, int argc, char **argv,
 			   struct nlmsghdr *n)
 {
 	size_t dist_size = 0;
-	struct rtattr *tail;
+	struct rtattr *nest;
 	struct tc_netem_qopt opt;
 	struct tc_netem_corr cor;
 	struct tc_netem_reorder reorder;
@@ -257,8 +257,6 @@ static int netem_parse_opt(struct qdisc_util *qu, int argc, char **argv,
 		argc--; argv++;
 	}
 
-	tail = NLMSG_TAIL(n);
-
 	if (reorder.probability) {
 		if (opt.latency == 0) {
 			fprintf(stderr, "reordering not possible without specifying some delay\n");
@@ -277,8 +275,7 @@ static int netem_parse_opt(struct qdisc_util *qu, int argc, char **argv,
 		return -1;
 	}
 
-	if (addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt)) < 0)
-		return -1;
+	nest = addattr_nest_compat(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
 
 	if (present[TCA_NETEM_CORR] &&
 	    addattr_l(n, 1024, TCA_NETEM_CORR, &cor, sizeof(cor)) < 0)
@@ -299,7 +296,7 @@ static int netem_parse_opt(struct qdisc_util *qu, int argc, char **argv,
 			return -1;
 		free(dist_data);
 	}
-	tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
+	addattr_nest_compat_end(n, nest);
 	return 0;
 }
 

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] IPROUTE: correct nla nested message generated by n ..., Jeff Kirsher, (Thu Aug 21, 5:50 pm)
Re: [PATCH] IPROUTE: correct nla nested message generated ..., Stephen Hemminger, (Thu Aug 21, 6:19 pm)
RE: [PATCH] IPROUTE: correct nla nested message generated ..., Duyck, Alexander H, (Wed Aug 27, 9:30 am)
Re: [PATCH] IPROUTE: correct nla nested message generated ..., Stephen Hemminger, (Wed Aug 27, 2:10 pm)