]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Do not register Xsk sockets on configuration check or client mode 15362/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 25 Mar 2025 09:55:10 +0000 (10:55 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 27 Mar 2025 09:32:44 +0000 (10:32 +0100)
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.

pdns/dnsdistdist/dnsdist-configuration-yaml.cc
pdns/dnsdistdist/dnsdist-lua.cc

index 00d2c5aa1d120c829e3529f7b87c43357f3f1a1d..c2816a98d680f9a5e57a39a08cdd26961b50e01e 100644 (file)
@@ -486,8 +486,8 @@ static std::shared_ptr<DownstreamState> createBackendFromConfiguration(const dns
     if (!xskMap) {
       throw std::runtime_error("XSK map " + std::string(config.xsk) + " attached to backend " + std::string(config.address) + " not found");
     }
-    downstream->registerXsk(*xskMap);
     if (!configCheck) {
+      downstream->registerXsk(*xskMap);
       infolog("Added downstream server %s via XSK in %s mode", std::string(config.address), xskMap->at(0)->getXDPMode());
     }
   }
index 0f8b0a2d53e55f8be7c39e831710935ddee6d653..4ad34ccfb50039a946d0e2c8719df2a65b9cb721 100644 (file)
@@ -611,7 +611,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 (dnsdist::configuration::isImmutableConfigurationDone()) {
                              throw std::runtime_error("Adding a server with xsk at runtime is not supported");
                            }
@@ -638,6 +638,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());