Fix #1492: logger: print timestamps only if we have one
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 4 Sep 2017 08:56:59 +0000 (10:56 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 4 Sep 2017 10:39:27 +0000 (12:39 +0200)
There's no guarantee that there's a timestamp in an skb, so
nflog_get_timestamp can fail.

src/pvefw-logger.c

index 3dc40eb..12ada77 100644 (file)
@@ -753,9 +753,11 @@ static int print_pkt(struct log_entry *le, struct nflog_data *ldata, u_int8_t fa
     LEPRINTF("%s ", chain_name);
 
     struct timeval ts;
-    nflog_get_timestamp(ldata, &ts);
-
-    LEPRINTTIME(ts.tv_sec);
+    if (nflog_get_timestamp(ldata, &ts) == 0) {
+        LEPRINTTIME(ts.tv_sec);
+    } else {
+        LEPRINTTIME(time(NULL));
+    }
 
     if (prefix != NULL) {
         LEPRINTF("%s", prefix);