summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2013-12-10 19:04:22 +0100
committerThomas Haller <thaller@redhat.com>2014-01-30 19:51:45 +0100
commit0535aa44db419eae77c77a07012644e732690ac1 (patch)
tree6be330fbfe2f1debecae5ed9b2fe9281c3d57c7b
parentfca51f37176916859066164a1e09fce9d522282e (diff)
core: use nm_utils_get_monotonic_timestamp_s for timestamp of NMPlatformIP[46]Address
https://bugzilla.gnome.org/show_bug.cgi?id=720833 Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--src/dhcp-manager/nm-dhcp-client.c15
-rw-r--r--src/platform/nm-fake-platform.c15
-rw-r--r--src/platform/nm-linux-platform.c15
-rw-r--r--src/platform/nm-platform.c15
-rw-r--r--src/platform/nm-platform.h8
-rw-r--r--src/rdisc/nm-lndp-rdisc.c15
-rw-r--r--src/rdisc/tests/Makefile.am22
7 files changed, 38 insertions, 67 deletions
diff --git a/src/dhcp-manager/nm-dhcp-client.c b/src/dhcp-manager/nm-dhcp-client.c
index c2a760ea36..5b3b3f8ea6 100644
--- a/src/dhcp-manager/nm-dhcp-client.c
+++ b/src/dhcp-manager/nm-dhcp-client.c
@@ -28,6 +28,7 @@
#include <stdlib.h>
#include <uuid/uuid.h>
+#include "NetworkManagerUtils.h"
#include "nm-utils.h"
#include "nm-logging.h"
#include "nm-dbus-glib-types.h"
@@ -802,16 +803,6 @@ nm_dhcp_client_foreach_option (NMDHCPClient *self,
return TRUE;
}
-static guint32
-get_time (void)
-{
- struct timespec tp;
-
- clock_gettime (CLOCK_MONOTONIC, &tp);
-
- return tp.tv_sec;
-}
-
/********************************************/
static gboolean
@@ -1163,7 +1154,7 @@ ip4_options_to_config (NMDHCPClient *self)
ip4_config = nm_ip4_config_new ();
memset (&address, 0, sizeof (address));
- address.timestamp = get_time ();
+ address.timestamp = nm_utils_get_monotonic_timestamp_s ();
str = g_hash_table_lookup (priv->options, "new_ip_address");
if (str && (inet_pton (AF_INET, str, &tmp_addr) > 0)) {
@@ -1395,7 +1386,7 @@ ip6_options_to_config (NMDHCPClient *self)
memset (&address, 0, sizeof (address));
address.plen = 128;
- address.timestamp = get_time ();
+ address.timestamp = nm_utils_get_monotonic_timestamp_s ();
priv = NM_DHCP_CLIENT_GET_PRIVATE (self);
g_return_val_if_fail (priv->options != NULL, NULL);
diff --git a/src/platform/nm-fake-platform.c b/src/platform/nm-fake-platform.c
index 9fa4077fdf..43944721cd 100644
--- a/src/platform/nm-fake-platform.c
+++ b/src/platform/nm-fake-platform.c
@@ -23,6 +23,7 @@
#include <netinet/icmp6.h>
#include <netinet/in.h>
+#include "NetworkManagerUtils.h"
#include "nm-fake-platform.h"
#include "nm-logging.h"
@@ -728,16 +729,6 @@ ip6_address_get_all (NMPlatform *platform, int ifindex)
return addresses;
}
-static guint32
-get_time (void)
-{
- struct timespec tp;
-
- clock_gettime (CLOCK_MONOTONIC, &tp);
-
- return tp.tv_sec;
-}
-
static gboolean
ip4_address_add (NMPlatform *platform, int ifindex,
in_addr_t addr, in_addr_t peer_addr,
@@ -752,7 +743,7 @@ ip4_address_add (NMPlatform *platform, int ifindex,
address.address = addr;
address.peer_address = peer_addr;
address.plen = plen;
- address.timestamp = get_time ();
+ address.timestamp = nm_utils_get_monotonic_timestamp_s ();
address.lifetime = lifetime;
address.preferred = preferred;
@@ -791,7 +782,7 @@ ip6_address_add (NMPlatform *platform, int ifindex,
address.address = addr;
address.peer_address = peer_addr;
address.plen = plen;
- address.timestamp = get_time ();
+ address.timestamp = nm_utils_get_monotonic_timestamp_s ();
address.lifetime = lifetime;
address.preferred = preferred;
address.flags = flags;
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index d99cb1d580..9fc264aeb6 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -43,6 +43,7 @@
#include <netlink/route/route.h>
#include <gudev/gudev.h>
+#include "NetworkManagerUtils.h"
#include "nm-linux-platform.h"
#include "NetworkManagerUtils.h"
#include "nm-utils.h"
@@ -814,16 +815,6 @@ hack_empty_master_iff_lower_up (NMPlatform *platform, struct nl_object *object)
rtnl_link_unset_flags (rtnllink, IFF_LOWER_UP);
}
-static guint32
-get_time (void)
-{
- struct timespec tp;
-
- clock_gettime (CLOCK_MONOTONIC, &tp);
-
- return tp.tv_sec;
-}
-
static void
init_ip4_address (NMPlatformIP4Address *address, struct rtnl_addr *rtnladdr)
{
@@ -836,7 +827,7 @@ init_ip4_address (NMPlatformIP4Address *address, struct rtnl_addr *rtnladdr)
address->ifindex = rtnl_addr_get_ifindex (rtnladdr);
address->plen = rtnl_addr_get_prefixlen (rtnladdr);
- address->timestamp = get_time ();
+ address->timestamp = nm_utils_get_monotonic_timestamp_s ();
address->lifetime = rtnl_addr_get_valid_lifetime (rtnladdr);
address->preferred = rtnl_addr_get_preferred_lifetime (rtnladdr);
g_assert (nl_addr_get_len (nladdr) == sizeof (address->address));
@@ -857,7 +848,7 @@ init_ip6_address (NMPlatformIP6Address *address, struct rtnl_addr *rtnladdr)
address->ifindex = rtnl_addr_get_ifindex (rtnladdr);
address->plen = rtnl_addr_get_prefixlen (rtnladdr);
- address->timestamp = get_time ();
+ address->timestamp = nm_utils_get_monotonic_timestamp_s ();
address->lifetime = rtnl_addr_get_valid_lifetime (rtnladdr);
address->preferred = rtnl_addr_get_preferred_lifetime (rtnladdr);
address->flags = rtnl_addr_get_flags (rtnladdr);
diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c
index 79eb06523a..5d6257fd85 100644
--- a/src/platform/nm-platform.c
+++ b/src/platform/nm-platform.c
@@ -26,6 +26,7 @@
#include <string.h>
#include <netlink/route/addr.h>
+#include "NetworkManagerUtils.h"
#include "nm-platform.h"
#include "NetworkManagerUtils.h"
#include "nm-logging.h"
@@ -1339,16 +1340,6 @@ array_contains_ip6_address (const GArray *addresses, const NMPlatformIP6Address
return FALSE;
}
-static guint32
-get_time (void)
-{
- struct timespec tp;
-
- clock_gettime (CLOCK_MONOTONIC, &tp);
-
- return tp.tv_sec;
-}
-
/* Compute (a - b) in an overflow-safe manner. */
static guint32
subtract_guint32 (guint32 a, guint32 b)
@@ -1375,7 +1366,7 @@ nm_platform_ip4_address_sync (int ifindex, const GArray *known_addresses)
{
GArray *addresses;
NMPlatformIP4Address *address;
- guint32 now = get_time ();
+ guint32 now = nm_utils_get_monotonic_timestamp_s ();
int i;
/* Delete unknown addresses */
@@ -1428,7 +1419,7 @@ nm_platform_ip6_address_sync (int ifindex, const GArray *known_addresses)
{
GArray *addresses;
NMPlatformIP6Address *address;
- guint32 now = get_time ();
+ guint32 now = nm_utils_get_monotonic_timestamp_s ();
int i;
/* Delete unknown addresses */
diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h
index a219a3794c..4ae64dbc13 100644
--- a/src/platform/nm-platform.h
+++ b/src/platform/nm-platform.h
@@ -133,6 +133,10 @@ typedef enum {
NM_PLATFORM_SOURCE_USER,
} NMPlatformSource;
+/**
+ * NMPlatformIP4Address:
+ * @timestamp: timestamp as returned by nm_utils_get_monotonic_timestamp_s()
+ **/
typedef struct {
int ifindex;
NMPlatformSource source;
@@ -144,6 +148,10 @@ typedef struct {
guint32 preferred; /* seconds */
} NMPlatformIP4Address;
+/**
+ * NMPlatformIP6Address:
+ * @timestamp: timestamp as returned by nm_utils_get_monotonic_timestamp_s()
+ **/
typedef struct {
int ifindex;
NMPlatformSource source;
diff --git a/src/rdisc/nm-lndp-rdisc.c b/src/rdisc/nm-lndp-rdisc.c
index e7124f1b7a..5fb28778fc 100644
--- a/src/rdisc/nm-lndp-rdisc.c
+++ b/src/rdisc/nm-lndp-rdisc.c
@@ -26,6 +26,7 @@
#include "nm-lndp-rdisc.h"
+#include "NetworkManagerUtils.h"
#include "nm-logging.h"
#define debug(...) nm_log_dbg (LOGD_IP6, __VA_ARGS__)
@@ -384,20 +385,10 @@ check_timestamps (NMRDisc *rdisc, guint32 now, NMRDiscConfigMap changed)
}
}
-static guint32
-get_time (void)
-{
- struct timespec tp;
-
- clock_gettime (CLOCK_MONOTONIC, &tp);
-
- return tp.tv_sec;
-}
-
static gboolean
timeout_cb (gpointer user_data)
{
- check_timestamps (user_data, get_time (), 0);
+ check_timestamps (user_data, nm_utils_get_monotonic_timestamp_s (), 0);
return TRUE;
}
@@ -470,7 +461,7 @@ receive_ra (struct ndp *ndp, struct ndp_msg *msg, gpointer user_data)
const char *lladdr = NULL;
struct ndp_msgra *msgra = ndp_msgra (msg);
NMRDiscGateway gateway;
- guint32 now = get_time ();
+ guint32 now = nm_utils_get_monotonic_timestamp_s ();
int offset;
if (rdisc->lladdr)
diff --git a/src/rdisc/tests/Makefile.am b/src/rdisc/tests/Makefile.am
index 7308cfe973..9d21284c70 100644
--- a/src/rdisc/tests/Makefile.am
+++ b/src/rdisc/tests/Makefile.am
@@ -1,15 +1,24 @@
AM_CPPFLAGS = \
-I${top_srcdir} \
+ -I$(top_srcdir)/include \
-I${top_srcdir}/src \
+ -I${top_srcdir}/src/devices \
-I${top_srcdir}/src/logging \
+ -I${top_srcdir}/src/platform \
+ -I${top_srcdir}/src/posix-signals \
-I${top_srcdir}/libnm-util \
-I${srcdir}/.. \
$(GLIB_CFLAGS) \
+ $(DBUS_CFLAGS) \
+ $(POLKIT_CFLAGS) \
$(LIBNL_CFLAGS) \
$(LIBNDP_CFLAGS)
AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
-AM_LDFLAGS = $(GLIB_LIBS) $(CODE_COVERAGE_LDFLAGS)
+AM_LDFLAGS = \
+ $(GLIB_LIBS) \
+ $(DBUS_LIBS) \
+ $(CODE_COVERAGE_LDFLAGS)
@GNOME_CODE_COVERAGE_RULES@
@@ -17,9 +26,8 @@ noinst_PROGRAMS = \
rdisc
rdisc_SOURCES = \
- rdisc.c \
- ../nm-rdisc.c \
- ../nm-fake-rdisc.c \
- ../nm-lndp-rdisc.c \
- ../../logging/nm-logging.c
-rdisc_LDADD = $(LIBNDP_LIBS)
+ rdisc.c
+rdisc_LDADD = \
+ $(top_builddir)/src/libNetworkManager.la \
+ $(LIBNDP_LIBS)
+