]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
dns: only register a single logger
authorJason Ish <jason.ish@oisf.net>
Tue, 16 Mar 2021 21:28:01 +0000 (15:28 -0600)
committerVictor Julien <victor@inliniac.net>
Thu, 1 Apr 2021 13:44:14 +0000 (15:44 +0200)
DNS no longer requires a logger to be registered for to-client and
to-server directions. This has not been required with the stateless
design of the Rust DNS parser.

rust/src/dns/dns.rs
src/output-json-dns.c
src/suricata-common.h
src/util-profiling.c

index 4f2d9a38b6f01c9699ccc87826fa7012045e4b50..50f1458ed9faa01991ec79f3c49be6f99a637d3c 100644 (file)
@@ -875,6 +875,16 @@ pub extern "C" fn rs_dns_state_get_tx(state: *mut std::os::raw::c_void,
     }
 }
 
+#[no_mangle]
+pub extern "C" fn rs_dns_tx_is_request(tx: &mut DNSTransaction) -> bool {
+    tx.request.is_some()
+}
+
+#[no_mangle]
+pub extern "C" fn rs_dns_tx_is_response(tx: &mut DNSTransaction) -> bool {
+    tx.response.is_some()
+}
+
 #[no_mangle]
 pub extern "C" fn rs_dns_state_set_tx_detect_state(
     tx: *mut std::os::raw::c_void,
index 42d2bcd8d3d11293a3624338b11a70f3d4544cec..e62c3f1f5d622c2931063864b2647fcc56418134 100644 (file)
@@ -410,6 +410,17 @@ static int JsonDnsLoggerToClient(ThreadVars *tv, void *thread_data,
     SCReturnInt(TM_ECODE_OK);
 }
 
+static int JsonDnsLogger(ThreadVars *tv, void *thread_data, const Packet *p, Flow *f, void *alstate,
+        void *txptr, uint64_t tx_id)
+{
+    if (rs_dns_tx_is_request(txptr)) {
+        return JsonDnsLoggerToServer(tv, thread_data, p, f, alstate, txptr, tx_id);
+    } else if (rs_dns_tx_is_response(txptr)) {
+        return JsonDnsLoggerToClient(tv, thread_data, p, f, alstate, txptr, tx_id);
+    }
+    return TM_ECODE_OK;
+}
+
 static TmEcode LogDnsLogThreadInit(ThreadVars *t, const void *initdata, void **data)
 {
     LogDnsLogThread *aft = SCCalloc(1, sizeof(LogDnsLogThread));
@@ -649,15 +660,7 @@ static OutputInitResult JsonDnsLogInitCtxSub(ConfNode *conf, OutputCtx *parent_c
 #define MODULE_NAME "JsonDnsLog"
 void JsonDnsLogRegister (void)
 {
-    /* Sub-logger for requests. */
-    OutputRegisterTxSubModuleWithProgress(LOGGER_JSON_DNS_TS, "eve-log",
-        MODULE_NAME, "eve-log.dns", JsonDnsLogInitCtxSub, ALPROTO_DNS,
-        JsonDnsLoggerToServer, 0, 1, LogDnsLogThreadInit,
-        LogDnsLogThreadDeinit, NULL);
-
-    /* Sub-logger for replies. */
-    OutputRegisterTxSubModuleWithProgress(LOGGER_JSON_DNS_TC, "eve-log",
-        MODULE_NAME, "eve-log.dns", JsonDnsLogInitCtxSub, ALPROTO_DNS,
-        JsonDnsLoggerToClient, 1, 1, LogDnsLogThreadInit, LogDnsLogThreadDeinit,
-        NULL);
+    OutputRegisterTxSubModule(LOGGER_JSON_DNS, "eve-log", MODULE_NAME, "eve-log.dns",
+            JsonDnsLogInitCtxSub, ALPROTO_DNS, JsonDnsLogger, LogDnsLogThreadInit,
+            LogDnsLogThreadDeinit, NULL);
 }
index 6dbcb3d0f5c211f0577444c51aff837e3f5b5574..6e24a9fd76e0051fc378b3afee26c26869295336 100644 (file)
@@ -442,8 +442,7 @@ typedef enum {
     LOGGER_HTTP,
     LOGGER_TLS_STORE,
     LOGGER_TLS,
-    LOGGER_JSON_DNS_TS,
-    LOGGER_JSON_DNS_TC,
+    LOGGER_JSON_DNS,
     LOGGER_JSON_HTTP,
     LOGGER_JSON_SMTP,
     LOGGER_JSON_TLS,
index 7967e98d7531b6724d476ac7ed8a26412b461db4..9e7dd7cfdd05ec5373987facd51ef6c2ca2b6d86 100644 (file)
@@ -1302,8 +1302,7 @@ const char * PacketProfileLoggertIdToString(LoggerId id)
         CASE_CODE (LOGGER_JSON_SMB);
         CASE_CODE (LOGGER_JSON_NFS);
         CASE_CODE (LOGGER_HTTP);
-        CASE_CODE (LOGGER_JSON_DNS_TS);
-        CASE_CODE (LOGGER_JSON_DNS_TC);
+        CASE_CODE(LOGGER_JSON_DNS);
         CASE_CODE (LOGGER_JSON_DNP3_TS);
         CASE_CODE (LOGGER_JSON_DNP3_TC);
         CASE_CODE (LOGGER_JSON_HTTP);