From: Thomas Graf <tgraf@suug.ch>
To: lartc@vger.kernel.org
Subject: Re: [LARTC] Adding dsmark qdisc fails
Date: Sun, 20 Mar 2005 16:25:53 +0000 [thread overview]
Message-ID: <20050320162553.GT3086@postel.suug.ch> (raw)
In-Reply-To: <BAY24-F131BDFCA526884F5089F76C54C0@phx.gbl>
* Patrick McHardy <423D9398.8050907@trash.net> 2005-03-20 16:15
> ># 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)
> >
> 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?
My patch is right but discovered a quite more serious bug in the
generic routing attribute handling. nlmsg_len is not aligned to
RTA_ALIGNTO if the data length of the attribute did not have
this alignment itself. The fact that the addition of the next attribute
fixed this bug automatically by issueing NLMSG_ALIGN(nlmsg_len) + len
put a good shadow around it and made it only a problem when the last
attribute added was not properly aligned. Patch attached, alternatively
one can clone bk://kernel.bkbits.net/tgraf/iproute2-tgr and als get
the new fancy multipath bits installed. ;->
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
# 2005/03/20 17:19:39+01:00 tgraf@suug.ch
# Fix netlink message alignment when the last routing attribute added
# has a data length not aligned to RTA_ALIGNTO.
#
# lib/libnetlink.c
# 2005/03/20 17:19:38+01:00 tgraf@suug.ch +4 -4
# Fix netlink message alignment when the last routing attribute added
# has a data length not aligned to RTA_ALIGNTO.
#
diff -Nru a/lib/libnetlink.c b/lib/libnetlink.c
--- a/lib/libnetlink.c 2005-03-20 17:19:53 +01:00
+++ b/lib/libnetlink.c 2005-03-20 17:19:53 +01:00
@@ -491,7 +491,7 @@
int len = RTA_LENGTH(alen);
struct rtattr *rta;
- if (NLMSG_ALIGN(n->nlmsg_len) + len > maxlen) {
+ if (NLMSG_ALIGN(n->nlmsg_len) + RTA_ALIGN(len) > maxlen) {
fprintf(stderr, "addattr_l ERROR: message exceeded bound of %d\n",maxlen);
return -1;
}
@@ -499,7 +499,7 @@
rta->rta_type = type;
rta->rta_len = len;
memcpy(RTA_DATA(rta), data, alen);
- n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + len;
+ n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + RTA_ALIGN(len);
return 0;
}
@@ -539,7 +539,7 @@
struct rtattr *subrta;
int len = RTA_LENGTH(alen);
- if (RTA_ALIGN(rta->rta_len) + len > maxlen) {
+ if (RTA_ALIGN(rta->rta_len) + RTA_ALIGN(len) > maxlen) {
fprintf(stderr,"rta_addattr_l: Error! max allowed bound %d exceeded\n",maxlen);
return -1;
}
@@ -547,7 +547,7 @@
subrta->rta_type = type;
subrta->rta_len = len;
memcpy(RTA_DATA(subrta), data, alen);
- rta->rta_len = NLMSG_ALIGN(rta->rta_len) + len;
+ rta->rta_len = NLMSG_ALIGN(rta->rta_len) + RTA_ALIGN(len);
return 0;
}
_______________________________________________
LARTC mailing list
LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc
next prev parent reply other threads:[~2005-03-20 16:25 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
2005-03-20 16:25 ` Thomas Graf [this message]
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=20050320162553.GT3086@postel.suug.ch \
--to=tgraf@suug.ch \
--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.