]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Do not register Xsk sockets on configuration check or client mode 15510/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 25 Mar 2025 09:55:10 +0000 (10:55 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 30 Apr 2025 11:12:10 +0000 (13:12 +0200)
It does not make sense, and in some cases might lead to a crash
because the Xsk socket is actually an empty shared pointer in client
mode.

(cherry picked from commit bbd1a19e0194aabdd745c5196e1eaeb196d7e196)

pdns/dnsdist-lua.cc

index f9b972acb1076e51ec52fb4d810923b45a9bb2a1..92fe2be56e98a7661ef1e7435904322a5db187ab 100644 (file)
@@ -642,7 +642,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
                          auto ret = std::make_shared<DownstreamState>(std::move(config), std::move(tlsCtx), !(client || configCheck));
 #ifdef HAVE_XSK
                          LuaArray<std::shared_ptr<XskSocket>> luaXskSockets;
-                         if (getOptionalValue<LuaArray<std::shared_ptr<XskSocket>>>(vars, "xskSockets", luaXskSockets) > 0 && !luaXskSockets.empty()) {
+                         if (!client && !configCheck && getOptionalValue<LuaArray<std::shared_ptr<XskSocket>>>(vars, "xskSockets", luaXskSockets) > 0 && !luaXskSockets.empty()) {
                            if (g_configurationDone) {
                              throw std::runtime_error("Adding a server with xsk at runtime is not supported");
                            }
@@ -668,6 +668,13 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
                          else if (!(client || configCheck)) {
                            infolog("Added downstream server %s", ret->d_config.remote.toStringWithPort());
                          }
+
+                         if (client || configCheck) {
+                           /* consume these in client or configuration check mode, to prevent warnings */
+                           std::string mac;
+                           getOptionalValue<std::string>(vars, "MACAddr", mac);
+                           getOptionalValue<LuaArray<std::shared_ptr<XskSocket>>>(vars, "xskSockets", luaXskSockets);
+                         }
 #else /* HAVE_XSK */
       if (!(client || configCheck)) {
         infolog("Added downstream server %s", ret->d_config.remote.toStringWithPort());