From dwinship at redhat.com  Thu Aug 20 09:43:42 2009
From: dwinship at redhat.com (Dan Winship)
Date: Thu, 20 Aug 2009 09:43:42 -0400
Subject: rtnl_addr caching broken
Message-ID: <4A8D530E.4020902@redhat.com>

It seems like rtnl_addr caches are currently broken; addresses go in but
they don't come out, because addr_obj_ops is set up to require
ADDR_ATTR_PEER to be set, but that's not set for most addresses, and so
non-point-to-point addresses compare as not equal to themselves and so
they can never be removed from the cache. Or am I doing something wrong?

-- Dan

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 0001-Fix-rtnl_addr-caching.patch
URL: <http://bombadil.infradead.org/pipermail/libnl/attachments/20090820/77e134a4/attachment.el>

From danw at redhat.com  Thu Aug 20 09:29:26 2009
From: danw at redhat.com (Dan Winship)
Date: Thu, 20 Aug 2009 09:29:26 -0400
Subject: [PATCH] Fix rtnl_addr caching
Message-ID: <mailman.2.1251117929.2309.libnl@lists.infradead.org>

addr_obj.ops.oo_id_attrs included ADDR_ATTR_PEER, so any address that
didn't have a peer address set would compare as unequal to itself,
meaning it could never be removed from a cache after it was added, etc.
---
 lib/route/addr.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/lib/route/addr.c b/lib/route/addr.c
index fa9d0f4..d14c481 100644
--- a/lib/route/addr.c
+++ b/lib/route/addr.c
@@ -907,8 +907,7 @@ static struct nl_object_ops addr_obj_ops = {
 	.oo_compare		= addr_compare,
 	.oo_attrs2str		= addr_attrs2str,
 	.oo_id_attrs		= (ADDR_ATTR_FAMILY | ADDR_ATTR_IFINDEX |
-				   ADDR_ATTR_LOCAL | ADDR_ATTR_PREFIXLEN |
-				   ADDR_ATTR_PEER),
+				   ADDR_ATTR_LOCAL | ADDR_ATTR_PREFIXLEN),
 };
 
 static struct nl_af_group addr_groups[] = {
-- 
1.6.2.5



--------------080701050804010708060701--


From mdekruijf at gmail.com  Wed Aug 26 17:28:01 2009
From: mdekruijf at gmail.com (Marc de Kruijf)
Date: Wed, 26 Aug 2009 16:28:01 -0500
Subject: Patch for unexpectedly aligned messages
Message-ID: <c338c7960908261428t1c689e9dt340d03741316fa2@mail.gmail.com>

Hi,

I have been using the libnl's generic netlink support for my user
application.  I found the following bug, where nlmsg_ok() in lib/msg.c would
incorrectly return 'true' when the input argument 'remaining' was a negative
number.  This happens when the message is not aligned the way that libnl
expects (although it is still legal).

In the comparison of the signed and unsigned numbers on line 284, the signed
number gets converted to an unsigned number, which is unexpected and
naturally produces a bug.  My patch is below.  The cast is ugly, but it
fixes the problem.

Marc

---------------

diff --git a/lib/msg.c b/lib/msg.c
index 22761a0..01779b1 100644
--- a/lib/msg.c
+++ b/lib/msg.c

@@ -284,7 +284,7 @@ int nlmsg_valid_hdr(const struct nlmsghdr *nlh, int
hdrlen)
  */
 int nlmsg_ok(const struct nlmsghdr *nlh, int remaining)
 {
-       return (remaining >= sizeof(struct nlmsghdr) &&
+       return (remaining >= (int)sizeof(struct nlmsghdr) &&
                nlh->nlmsg_len >= sizeof(struct nlmsghdr) &&
                nlh->nlmsg_len <= remaining);
 }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://bombadil.infradead.org/pipermail/libnl/attachments/20090826/87e9c5fb/attachment.htm>

