]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Reject BPFFilter::attachToAllBinds() at configuration time
authorY7n05h <Y7n05h@protonmail.com>
Mon, 11 Apr 2022 15:44:46 +0000 (23:44 +0800)
committerY7n05h <Y7n05h@protonmail.com>
Mon, 11 Apr 2022 15:44:46 +0000 (23:44 +0800)
Signed-off-by: Y7n05h <Y7n05h@protonmail.com>
pdns/dnsdist-lua-bindings.cc
pdns/dnsdistdist/docs/advanced/ebpf.rst
pdns/dnsdistdist/docs/reference/ebpf.rst

index 30eff5d39d607aad388faa22e95a54da218f6b31..0ea0250a2fab0078f06db3752ecc7c253e9d1fc6 100644 (file)
@@ -547,6 +547,10 @@ void setupLuaBindings(LuaContext& luaCtx, bool client)
 
   luaCtx.registerFunction<void(std::shared_ptr<BPFFilter>::*)()>("attachToAllBinds", [](std::shared_ptr<BPFFilter> bpf) {
       std::string res;
+      if (!g_configurationDone) {
+        throw std::runtime_error("attachToAllBinds() cannot be used at configuration time!");
+        return;
+      }
       if (bpf) {
         for (const auto& frontend : g_frontends) {
           frontend->attachFilter(bpf);
index 488480406ebef17f97f690862c22d100d03aeb4e..6ce847bff892645b30f987b1c4a5dba505432f95 100644 (file)
@@ -30,7 +30,9 @@ Contrary to source address filtering, qname filtering only works over UDP. TCP q
 
   addAction(AndRule({TCPRule(true), makeRule("evildomain.com")}), DropAction())
 
-The :meth:`BPFFilter:attachToAllBinds` method attaches the filter to every existing bind at runtime, but it's also possible to define a default BPF filter at configuration time, so it's automatically attached to every bind::
+The :meth:`BPFFilter:attachToAllBinds` method attaches the filter to every existing bind at runtime. It cannot use at configuration time. The :func:`setDefaultBPFFilter()` should be used at configuration time.
+
+The :meth:`BPFFilter:attachToAllBinds` automatically attached to every bind::
 
   bpf = newBPFFilter(1024, 1024, 1024)
   setDefaultBPFFilter(bpf)
index 5fc3da9f0e4ae348ef59b82fc8c772c86e07dfc0..6899bffd34d1688cbaee7eb76c4bbe9011386d14 100644 (file)
@@ -66,7 +66,9 @@ These are all the functions, objects and methods related to the :doc:`../advance
   .. method:: BPFFilter:attachToAllBinds()
 
     Attach this filter to every bind already defined.
-    This is the run-time equivalent of :func:`setDefaultBPFFilter`
+    This is the run-time equivalent of :func:`setDefaultBPFFilter`.
+    This only can be use at run-time.
+
 
   .. method:: BPFFilter:block(address)