summaryrefslogtreecommitdiff
path: root/src/nm-dcb.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-04-18 12:36:09 +0200
committerThomas Haller <thaller@redhat.com>2015-04-21 17:51:34 +0200
commitc6529a9d748ad3c8ee37431d020a7b9223992a23 (patch)
treeadd34e4c0dd7718b1d514de717777d663e2e14b6 /src/nm-dcb.c
parentccba1b1e2d1fb2a23dd9e86d8ba44f7a3287cafb (diff)
downloadNetworkManager-c6529a9d748ad3c8ee37431d020a7b9223992a23.tar.gz
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform singleton nm_platform_get(). That made sense because the NMPlatform instance was mainly to hook fake platform for testing. While the implicit argument saved some typing, I think explicit is better. Especially, because NMPlatform could become a more usable object then just a hook for testing. With this change, NMPlatform instances can be used individually, not only as a singleton instance. Before this change, the constructor of NMLinuxPlatform could not call any nm_platform_*() functions because the singleton was not yet initialized. We could only instantiate an incomplete instance, register it via nm_platform_setup(), and then complete initialization via singleton->setup(). With this change, we can create and fully initialize NMPlatform instances before/without setting them up them as singleton. Also, currently there is no clear distinction between functions that operate on the NMPlatform instance, and functions that can be used stand-alone (e.g. nm_platform_ip4_address_to_string()). The latter can not be mocked for testing. With this change, the distinction becomes obvious. That is also useful because it becomes clearer which functions make use of the platform cache and which not. Inside nm-linux-platform.c, continue the pattern that the self instance is named @platform. That makes sense because its type is NMPlatform, and not NMLinuxPlatform what we would expect from a paramter named @self. This is a major diff that causes some pain when rebasing. Try to rebase to the parent commit of this commit as a first step. Then rebase on top of this commit using merge-strategy "ours".
Diffstat (limited to 'src/nm-dcb.c')
-rw-r--r--src/nm-dcb.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/nm-dcb.c b/src/nm-dcb.c
index 0b18ca7f2b..8bf3858a3d 100644
--- a/src/nm-dcb.c
+++ b/src/nm-dcb.c
@@ -354,7 +354,7 @@ carrier_wait (const char *iface, guint secs, gboolean up)
g_return_if_fail (iface != NULL);
- ifindex = nm_platform_link_get_ifindex (iface);
+ ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, iface);
if (ifindex > 0) {
/* To work around driver quirks and lldpad handling of carrier status,
* we must wait a short period of time to see if the carrier goes
@@ -365,9 +365,9 @@ carrier_wait (const char *iface, guint secs, gboolean up)
nm_log_dbg (LOGD_DCB, "(%s): cleanup waiting for carrier %s",
iface, up ? "up" : "down");
g_usleep (G_USEC_PER_SEC / 4);
- while (nm_platform_link_is_connected (ifindex) != up && count-- > 0) {
+ while (nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex) != up && count-- > 0) {
g_usleep (G_USEC_PER_SEC / 10);
- nm_platform_link_refresh (ifindex);
+ nm_platform_link_refresh (NM_PLATFORM_GET, ifindex);
}
}
}