summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2015-03-24 12:46:18 -0500
committerDan Williams <dcbw@redhat.com>2015-03-24 12:47:49 -0500
commit36fb74a494d871e43992cbc0a9dae02eddcd871b (patch)
tree2eed8b1a4a327d3c2513d8bb9d65ad22adced19a
parent0ded8191b7d60115919b8dab7e0590fe76b9d00e (diff)
downloadNetworkManager-dcbw/dev-id-rh1101809.tar.gz
core: use dev_id when calculating the interface IPv6 IID (rh #1101809)dcbw/dev-id-rh1101809
Some device types (s390 OSA and ipvlan) can use the same link-layer address for multiple virtual interfaces, and the kernel used the dev_id property to differentiate these devices when constructing the IID. NM should do this too to prevent IID clashes. https://bugzilla.redhat.com/show_bug.cgi?id=1101809
-rw-r--r--src/NetworkManagerUtils.c17
-rw-r--r--src/NetworkManagerUtils.h1
-rw-r--r--src/devices/nm-device.c4
3 files changed, 18 insertions, 4 deletions
diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c
index 57f817649e..f28b783e58 100644
--- a/src/NetworkManagerUtils.c
+++ b/src/NetworkManagerUtils.c
@@ -2351,6 +2351,7 @@ get_gre_eui64_u_bit (guint32 addr)
* @link_type: the hardware link type
* @hwaddr: the hardware address of the interface
* @hwaddr_len: the length (in bytes) of @hwaddr
+ * @dev_id: the device identifier, if any
* @out_iid: on success, filled with the interface identifier; on failure
* zeroed out
*
@@ -2365,6 +2366,7 @@ gboolean
nm_utils_get_ipv6_interface_identifier (NMLinkType link_type,
const guint8 *hwaddr,
guint hwaddr_len,
+ guint dev_id,
NMUtilsIPv6IfaceId *out_iid)
{
guint32 addr;
@@ -2399,13 +2401,20 @@ nm_utils_get_ipv6_interface_identifier (NMLinkType link_type,
default:
if (hwaddr_len == ETH_ALEN) {
/* Translate 48-bit MAC address to a 64-bit Modified EUI-64. See
- * http://tools.ietf.org/html/rfc4291#appendix-A
+ * http://tools.ietf.org/html/rfc4291#appendix-A and the Linux
+ * kernel's net/ipv6/addrconf.c::ipv6_generate_eui64() function.
*/
- out_iid->id_u8[0] = hwaddr[0] ^ 0x02;
+ out_iid->id_u8[0] = hwaddr[0];
out_iid->id_u8[1] = hwaddr[1];
out_iid->id_u8[2] = hwaddr[2];
- out_iid->id_u8[3] = 0xff;
- out_iid->id_u8[4] = 0xfe;
+ if (dev_id) {
+ out_iid->id_u8[3] = (dev_id >> 8) & 0xff;
+ out_iid->id_u8[4] = dev_id & 0xff;
+ } else {
+ out_iid->id_u8[0] ^= 0x02;
+ out_iid->id_u8[3] = 0xff;
+ out_iid->id_u8[4] = 0xfe;
+ }
out_iid->id_u8[5] = hwaddr[3];
out_iid->id_u8[6] = hwaddr[4];
out_iid->id_u8[7] = hwaddr[5];
diff --git a/src/NetworkManagerUtils.h b/src/NetworkManagerUtils.h
index 23d8330a34..11dc496b4f 100644
--- a/src/NetworkManagerUtils.h
+++ b/src/NetworkManagerUtils.h
@@ -198,6 +198,7 @@ struct _NMUtilsIPv6IfaceId {
gboolean nm_utils_get_ipv6_interface_identifier (NMLinkType link_type,
const guint8 *hwaddr,
guint len,
+ guint dev_id,
NMUtilsIPv6IfaceId *out_iid);
void nm_utils_ipv6_addr_set_interface_identfier (struct in6_addr *addr,
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index ddc213c0a4..bf10abe6c5 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -201,6 +201,7 @@ typedef struct {
char * hw_addr;
guint hw_addr_len;
char * physical_port_id;
+ guint dev_id;
NMUnmanagedFlags unmanaged_flags;
gboolean is_nm_owned; /* whether the device is a device owned and created by NM */
@@ -600,6 +601,7 @@ nm_device_set_ip_iface (NMDevice *self, const char *iface)
static gboolean
get_ip_iface_identifier (NMDevice *self, NMUtilsIPv6IfaceId *out_iid)
{
+ NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
NMLinkType link_type;
const guint8 *hwaddr = NULL;
size_t hwaddr_len = 0;
@@ -620,6 +622,7 @@ get_ip_iface_identifier (NMDevice *self, NMUtilsIPv6IfaceId *out_iid)
success = nm_utils_get_ipv6_interface_identifier (link_type,
hwaddr,
hwaddr_len,
+ priv->dev_id,
out_iid);
if (!success) {
_LOGW (LOGD_HW, "failed to generate interface identifier "
@@ -8472,6 +8475,7 @@ constructed (GObject *object)
if (priv->ifindex > 0) {
priv->is_software = nm_platform_link_is_software (priv->ifindex);
priv->physical_port_id = nm_platform_link_get_physical_port_id (priv->ifindex);
+ priv->dev_id = nm_platform_link_get_dev_id (priv->ifindex);
priv->mtu = nm_platform_link_get_mtu (priv->ifindex);
}
/* Indicate software device in capabilities. */