diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2015-03-23 12:58:02 +0100 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2015-03-23 12:59:18 +0100 |
commit | c2103ff30f64ec40f06b433ab9fde1e216e4d428 (patch) | |
tree | b970ba55f09fcf794acdaca515e5a4b1479a405f | |
parent | aea829eb7e73a8c48fffa93e316f964234b3ba19 (diff) | |
download | NetworkManager-lr/vf-names-rh1155226.tar.gz |
ethernet: use virtual function & port for connection descriptionlr/vf-names-rh1155226
https://bugzilla.redhat.com/show_bug.cgi?id=1155226
-rw-r--r-- | src/devices/nm-device-ethernet-utils.c | 11 | ||||
-rw-r--r-- | src/devices/nm-device-ethernet-utils.h | 3 | ||||
-rw-r--r-- | src/devices/nm-device-ethernet.c | 2 | ||||
-rw-r--r-- | src/tests/test-wired-defname.c | 8 |
4 files changed, 16 insertions, 8 deletions
diff --git a/src/devices/nm-device-ethernet-utils.c b/src/devices/nm-device-ethernet-utils.c index 585f6a0e0e..afe661b188 100644 --- a/src/devices/nm-device-ethernet-utils.c +++ b/src/devices/nm-device-ethernet-utils.c @@ -26,18 +26,25 @@ #include "nm-device-ethernet-utils.h" char * -nm_device_ethernet_utils_get_default_wired_name (const GSList *connections) +nm_device_ethernet_utils_get_default_wired_name (NMDevice *device, const GSList *connections) { const GSList *iter; char *cname = NULL; int i = 0; + int port = device ? nm_device_get_port (device) : -1; + int vf = device ? nm_device_get_vf (device) : -1; /* Find the next available unique connection name */ while (!cname && (i++ < 10000)) { char *temp; gboolean found = FALSE; - temp = g_strdup_printf (_("Wired connection %d"), i); + if (port >= 0 && vf >= 0) { + temp = g_strdup_printf (_("Wired port %d, function %d"), port, vf); + port = vf = -1; + } else { + temp = g_strdup_printf (_("Wired connection %d"), i); + } for (iter = connections; iter; iter = iter->next) { if (g_strcmp0 (nm_connection_get_id (NM_CONNECTION (iter->data)), temp) == 0) { found = TRUE; diff --git a/src/devices/nm-device-ethernet-utils.h b/src/devices/nm-device-ethernet-utils.h index 5848f7e604..f768cf67cd 100644 --- a/src/devices/nm-device-ethernet-utils.h +++ b/src/devices/nm-device-ethernet-utils.h @@ -20,7 +20,8 @@ #define __NETWORKMANAGER_DEVICE_ETHERNET_UTILS_H__ #include <glib.h> +#include "nm-device.h" -char *nm_device_ethernet_utils_get_default_wired_name (const GSList *connections); +char *nm_device_ethernet_utils_get_default_wired_name (NMDevice *device, const GSList *connections); #endif /* NETWORKMANAGER_DEVICE_ETHERNET_UTILS_H */ diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index 24aa8967d6..1fc518606d 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -1475,7 +1475,7 @@ new_default_connection (NMDevice *self) nm_connection_add_setting (connection, setting); connections = nm_connection_provider_get_connections (nm_connection_provider_get ()); - defname = nm_device_ethernet_utils_get_default_wired_name (connections); + defname = nm_device_ethernet_utils_get_default_wired_name (self, connections); uuid = nm_utils_uuid_generate (); g_object_set (setting, NM_SETTING_CONNECTION_ID, defname, diff --git a/src/tests/test-wired-defname.c b/src/tests/test-wired-defname.c index b2933de0e3..cf2cb4bb08 100644 --- a/src/tests/test-wired-defname.c +++ b/src/tests/test-wired-defname.c @@ -48,7 +48,7 @@ test_defname_no_connections (void) { gs_free char *name = NULL; - name = nm_device_ethernet_utils_get_default_wired_name (NULL); + name = nm_device_ethernet_utils_get_default_wired_name (NULL, NULL); g_assert_cmpstr (name, ==, "Wired connection 1"); } @@ -64,7 +64,7 @@ test_defname_no_conflict (void) list = g_slist_append (list, _new_connection ("work wifi")); list = g_slist_append (list, _new_connection ("random gsm connection")); - name = nm_device_ethernet_utils_get_default_wired_name (list); + name = nm_device_ethernet_utils_get_default_wired_name (NULL, list); g_assert_cmpstr (name, ==, "Wired connection 1"); g_slist_free_full (list, g_object_unref); @@ -82,7 +82,7 @@ test_defname_conflict (void) list = g_slist_append (list, _new_connection ("Wired connection 1")); list = g_slist_append (list, _new_connection ("random gsm connection")); - name = nm_device_ethernet_utils_get_default_wired_name (list); + name = nm_device_ethernet_utils_get_default_wired_name (NULL, list); g_assert_cmpstr (name, ==, "Wired connection 2"); g_slist_free_full (list, g_object_unref); @@ -104,7 +104,7 @@ test_defname_multiple_conflicts (void) list = g_slist_append (list, _new_connection ("work wifi")); list = g_slist_append (list, _new_connection ("a vpn")); - name = nm_device_ethernet_utils_get_default_wired_name (list); + name = nm_device_ethernet_utils_get_default_wired_name (NULL, list); g_assert_cmpstr (name, ==, "Wired connection 4"); g_slist_free_full (list, g_object_unref); |