]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
DNS: trigger logging for toserver dir when previous reply is lost.
authorVictor Julien <victor@inliniac.net>
Mon, 11 Nov 2013 16:27:56 +0000 (17:27 +0100)
committerVictor Julien <victor@inliniac.net>
Fri, 15 Nov 2013 14:41:24 +0000 (15:41 +0100)
src/log-dnslog.c

index 5ef4b1fab7f7e3fb1bd4a2eef31c57d3795d4acd..9fc82ca842d96f752a71bd2007cd9e6ffeaf9d60 100644 (file)
@@ -295,36 +295,39 @@ static TmEcode LogDnsLogIPWrapper(ThreadVars *tv, Packet *p, void *data, PacketQ
         }
     } else
 #endif
-    if ((PKT_IS_TOCLIENT(p))) {
-        DNSTransaction *tx = NULL;
-        for (; tx_id < total_txs; tx_id++)
-        {
-            tx = AppLayerGetTx(proto, dns_state, tx_id);
-            if (tx == NULL)
-                continue;
-
-            DNSQueryEntry *query = NULL;
-            TAILQ_FOREACH(query, &tx->query_list, next) {
-                LogQuery(aft, timebuf, dstip, srcip, dp, sp, tx, query);
-            }
 
-            if (tx->no_such_name) {
-                LogAnswer(aft, timebuf, srcip, dstip, sp, dp, tx, NULL);
-            }
+    DNSTransaction *tx = NULL;
+    for (; tx_id < total_txs; tx_id++)
+    {
+        tx = AppLayerGetTx(proto, dns_state, tx_id);
+        if (tx == NULL)
+            continue;
 
-            DNSAnswerEntry *entry = NULL;
-            TAILQ_FOREACH(entry, &tx->answer_list, next) {
-                LogAnswer(aft, timebuf, srcip, dstip, sp, dp, tx, entry);
-            }
+        /* only consider toserver logging if tx has reply lost set */
+        if (PKT_IS_TOSERVER(p) && tx->reply_lost == 0)
+            continue;
 
-            entry = NULL;
-            TAILQ_FOREACH(entry, &tx->authority_list, next) {
-                LogAnswer(aft, timebuf, srcip, dstip, sp, dp, tx, entry);
-            }
+        DNSQueryEntry *query = NULL;
+        TAILQ_FOREACH(query, &tx->query_list, next) {
+            LogQuery(aft, timebuf, dstip, srcip, dp, sp, tx, query);
+        }
+
+        if (tx->no_such_name) {
+            LogAnswer(aft, timebuf, srcip, dstip, sp, dp, tx, NULL);
+        }
 
-            SCLogDebug("calling AppLayerTransactionUpdateLoggedId");
-            AppLayerTransactionUpdateLogId(p->flow);
+        DNSAnswerEntry *entry = NULL;
+        TAILQ_FOREACH(entry, &tx->answer_list, next) {
+            LogAnswer(aft, timebuf, srcip, dstip, sp, dp, tx, entry);
         }
+
+        entry = NULL;
+        TAILQ_FOREACH(entry, &tx->authority_list, next) {
+            LogAnswer(aft, timebuf, srcip, dstip, sp, dp, tx, entry);
+        }
+
+        SCLogDebug("calling AppLayerTransactionUpdateLoggedId");
+        AppLayerTransactionUpdateLogId(p->flow);
     }
 
 end: