diff options
author | Peter Wu <peter@lekensteyn.nl> | 2014-04-20 16:54:59 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-04-27 15:32:07 +0200 |
commit | a2eb4789ac2fe8a6389aabb83285bc667b86d941 (patch) | |
tree | 88cbaede2e657ed04f7c2685283f07a27d7894d4 | |
parent | c0254336ce99737115d7b6a598e5e46215201aea (diff) | |
download | NetworkManager-a2eb4789ac2fe8a6389aabb83285bc667b86d941.tar.gz |
platform: set link scope for IP4LL addresses
https://bugzilla.gnome.org/show_bug.cgi?id=728595
[thaller@redhat.com: minor change in coding style]
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r-- | src/platform/nm-linux-platform.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 7ec3da66a3..46430d6cbd 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -2989,6 +2989,15 @@ addr4_to_broadcast (struct in_addr *dst, const struct in_addr *src, guint8 plen) } } +#define IPV4LL_NETWORK (htonl (0xA9FE0000L)) +#define IPV4LL_NETMASK (htonl (0xFFFF0000L)) + +static gboolean +ip4_is_link_local (const struct in_addr *src) +{ + return (src->s_addr & IPV4LL_NETMASK) == IPV4LL_NETWORK; +} + static struct nl_object * build_rtnl_addr (int family, int ifindex, @@ -3012,6 +3021,10 @@ build_rtnl_addr (int family, nle = rtnl_addr_set_local (rtnladdr, nladdr); g_assert (!nle); + /* Tighten scope (IPv4 only) */ + if (family == AF_INET && ip4_is_link_local (addr)) + rtnl_addr_set_scope (rtnladdr, rtnl_str2scope ("link")); + /* IPv4 Broadcast address */ if (family == AF_INET) { struct in_addr bcast; |