gbproxy: Use monotonic system time instead of time-of-day

Currently time() is used for age calculations. This time source
may jump either forwards or backwards in time (NTP update, leap
seconds).

This patch replaces the use of time() by using
clock_gettime(CLOCK_MONOTONIC) instead.

Sponsored-by: On-Waves ehf
diff --git a/openbsc/src/gprs/gb_proxy.c b/openbsc/src/gprs/gb_proxy.c
index 130ab4e..9aeb010 100644
--- a/openbsc/src/gprs/gb_proxy.c
+++ b/openbsc/src/gprs/gb_proxy.c
@@ -518,6 +518,7 @@
 	int rc;
 	int len_change = 0;
 	time_t now;
+	struct timespec ts = {0,};
 	struct gbproxy_link_info *link_info = NULL;
 	uint32_t sgsn_nsei = cfg->nsip_sgsn_nsei;
 
@@ -549,7 +550,9 @@
 	if (!peer)
 		return 0;
 
-	now = time(NULL);
+
+	clock_gettime(CLOCK_MONOTONIC, &ts);
+	now = ts.tv_sec;
 
 	gbprox_update_current_raid(parse_ctx.bssgp_raid_enc, peer,
 				   parse_ctx.llc_msg_name);
@@ -611,6 +614,7 @@
 	int rc;
 	int len_change = 0;
 	time_t now;
+	struct timespec ts = {0,};
 	struct gbproxy_link_info *link_info = NULL;
 
 	if (!cfg->core_mcc && !cfg->core_mnc && !cfg->core_apn &&
@@ -640,7 +644,8 @@
 	if (!peer)
 		return;
 
-	now = time(NULL);
+	clock_gettime(CLOCK_MONOTONIC, &ts);
+	now = ts.tv_sec;
 
 	if (parse_ctx.g48_hdr) {
 		switch (parse_ctx.g48_hdr->msg_type) {