[PATCH 1/1] route/addr: mitigation for sending extended 32bit IFA_FLAGS to older kernels

Thomas Haller thaller at redhat.com
Thu Apr 3 09:17:52 PDT 2014


Some older kernels seem to have problems when receiving
RTM_NEWADDR/RTM_DELADDR messages with the netlink attribute IFA_FLAGS.

As a mitigation, don't set this attribute, unless we have actually
extended 32bit flags at hand.

The problem seems to be a kernel bug (that should still be
investigated). This is not a proper workaround, because applications
that want to use extended flags will still be broken.

https://github.com/thom311/libnl/issues/56
https://bugzilla.redhat.com/show_bug.cgi?id=1063885

Signed-off-by: Thomas Haller <thaller at redhat.com>
---
 lib/route/addr.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/route/addr.c b/lib/route/addr.c
index 7726fb0..918ffda 100644
--- a/lib/route/addr.c
+++ b/lib/route/addr.c
@@ -600,7 +600,15 @@ static int build_addr_msg(struct rtnl_addr *tmpl, int cmd, int flags,
 		NLA_PUT(msg, IFA_CACHEINFO, sizeof(ca), &ca);
 	}
 
-	NLA_PUT_U32(msg, IFA_FLAGS, tmpl->a_flags);
+	if (tmpl->a_flags & ~0xFF) {
+		/* only set the IFA_FLAGS attribute, if we have extended attributes.
+		 * Apparently, older kernels have problems with the additional netlink
+		 * attribute, so as a mitigation only add it when it is needed.
+		 *
+		 * A proper workaround would be to detect that we are talking to such an old
+		 * kernel. */
+		NLA_PUT_U32(msg, IFA_FLAGS, tmpl->a_flags);
+	}
 
 	*result = msg;
 	return 0;
-- 
1.9.0




More information about the libnl mailing list