]> git.proxmox.com Git - pve-firewall.git/blobdiff - src/pvefw-logger.c
Fix #1492: logger: print timestamps only if we have one
[pve-firewall.git] / src / pvefw-logger.c
index 54145a9f261fb1e13f5382d6ceb0ad5cf518ca62..12ada772c3e51db5fe20b1798d8b21ee67c39922 100644 (file)
@@ -411,7 +411,6 @@ print_routing(struct log_entry *le, struct ip6_rthdr *rthdr, int payload_len)
         /* Route via waypoints (deprecated), this contains a list of waypoints
          * to visit. (RFC2460 (4.4))
          */
-        unsigned i;
         struct ip6_rthdr0 *h = (struct ip6_rthdr0*)rthdr;
         if (rthdr->ip6r_len*8 < sizeof(*h) + rthdr->ip6r_segleft * sizeof(struct in6_addr)) {
             LEPRINTF("INVALID=SEGMENTS ");
@@ -754,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);
@@ -983,7 +984,7 @@ main(int argc, char *argv[])
         exit(-1);
     }
 
-    if (!nflog_bind_pf(logh, AF_INET) <= 0) {
+    if (nflog_bind_pf(logh, AF_INET) < 0) {
         fprintf(stderr, "nflog_bind_pf AF_INET failed\n");
         exit(-1);
     }
@@ -995,7 +996,7 @@ main(int argc, char *argv[])
     }
 #endif
 
-    if (!nflog_bind_pf(logh, AF_BRIDGE) <= 0) {
+    if (nflog_bind_pf(logh, AF_BRIDGE) < 0) {
         fprintf(stderr, "nflog_bind_pf AF_BRIDGE failed\n");
         exit(-1);
     }