]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3144] addressed review comments
authorRazvan Becheriu <razvan@isc.org>
Thu, 14 May 2026 08:30:39 +0000 (11:30 +0300)
committerRazvan Becheriu <razvan@isc.org>
Mon, 18 May 2026 11:22:02 +0000 (14:22 +0300)
src/lib/dhcpsrv/cfg_iface.cc
src/lib/dhcpsrv/cfg_iface.h

index b7ff6277b2aa5a88880c8a43535096c5f351bfa4..35258cfdce826959a4638c909a254ee8ef088da1 100644 (file)
@@ -86,7 +86,7 @@ CfgIface::openSockets(const uint16_t family, const uint16_t port,
     const bool can_use_bcast = use_bcast && (socket_type_ == SOCKET_RAW);
 
     reconnect_ctl_ = makeReconnectCtl();
-    auto sopen = openSocketsWithRetry(reconnect_ctl_, family, port, can_use_bcast);
+    auto sopen = openSocketsWithRetry(reconnect_ctl_, family, port, can_use_bcast, false);
 
     if (!sopen) {
         // If no socket were opened, log a warning because the server will
@@ -104,7 +104,7 @@ CfgIface::triggerOpenSocketsWithRetry(const uint16_t family, const uint16_t port
 
     reconnect_ctl_->resetRetries();
 
-    openSocketsWithRetry(reconnect_ctl_, family, port, can_use_bcast);
+    openSocketsWithRetry(reconnect_ctl_, family, port, can_use_bcast, true);
 }
 
 std::pair<bool, bool>
@@ -153,7 +153,7 @@ ReconnectCtlPtr CfgIface::makeReconnectCtl() const {
 bool
 CfgIface::openSocketsWithRetry(ReconnectCtlPtr reconnect_ctl,
                                const uint16_t family, const uint16_t port,
-                               const bool can_use_bcast) const {
+                               const bool can_use_bcast, bool skip_opened) const {
     MultiThreadingCriticalSection cs;
 
     // The detection must be done before resetting and setting the
@@ -250,7 +250,10 @@ CfgIface::openSocketsWithRetry(ReconnectCtlPtr reconnect_ctl,
     }
 
     // Skip opened sockets in the retry calls.
-    bool is_initial_call = (reconnect_ctl->retriesLeft() == reconnect_ctl->maxRetries());
+    bool is_initial_call = false;
+    if (!skip_opened) {
+        is_initial_call = (reconnect_ctl->retriesLeft() == reconnect_ctl->maxRetries());
+    }
     auto result_pair = CfgIface::openSocketsForFamily(family, port, can_use_bcast, !is_initial_call);
     bool sopen = result_pair.first;
     bool has_errors = !result_pair.second;
@@ -272,7 +275,7 @@ CfgIface::openSocketsWithRetry(ReconnectCtlPtr reconnect_ctl,
                                                 std::bind(&CfgIface::openSocketsWithRetry,
                                                           this,
                                                           reconnect_ctl, family,
-                                                          port, can_use_bcast),
+                                                          port, can_use_bcast, false),
                                                 reconnect_ctl->retryInterval(),
                                                 asiolink::IntervalTimer::ONE_SHOT);
         }
index 0b342c1aeb1da35bfa95a6d9ffc7c7aa92b9f4ef..75cbc239e105ad9f3bf82086e33614506c6a2cb5 100644 (file)
@@ -470,11 +470,13 @@ private:
     /// traffic should be received through the socket and the raw sockets are
     /// used. For the UDP sockets, we only handle the relayed (unicast)
     /// traffic. This parameter is ignored for IPv6.
+    /// @param skip_opened Omits the already opened sockets (doesn't try to
+    /// re-bind).
     ///
     /// @return True if at least one socket opened successfully.
     bool openSocketsWithRetry(util::ReconnectCtlPtr reconnect_ctl,
                               const uint16_t family, const uint16_t port,
-                              const bool can_use_bcast) const;
+                              const bool can_use_bcast, bool skip_opened) const;
 
     /// @brief Represents a set of interface names.
     typedef std::set<std::string> IfaceSet;