From: Marcin Siodelski Date: Thu, 21 Aug 2014 06:37:05 +0000 (+0200) Subject: [3512] Loopback interface should not be selected for DHCP traffic reception. X-Git-Tag: trac3482_base~11^2~2^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dc6da560054a29a2f1b5d0c823bd0206d010e6ba;p=thirdparty%2Fkea.git [3512] Loopback interface should not be selected for DHCP traffic reception. Also, fixed selection of the unicast addresses for receiving DHCP packets. --- diff --git a/src/lib/dhcpsrv/iface_cfg.cc b/src/lib/dhcpsrv/iface_cfg.cc index 68c639559f..725de2d028 100644 --- a/src/lib/dhcpsrv/iface_cfg.cc +++ b/src/lib/dhcpsrv/iface_cfg.cc @@ -40,8 +40,9 @@ IfaceCfg::openSockets(const uint16_t port, const bool use_bcast) { // If wildcard interface '*' was not specified, set all interfaces to // inactive state. We will later enable them selectively using the // interface names specified by the user. If wildcard interface was - // specified, mark all interfaces active. - setState(!wildcard_used_); + // specified, mark all interfaces active. In all cases, mark loopback + // inactive. + setState(!wildcard_used_, true); // Remove selection of unicast addresses from all interfaces. IfaceMgr::instance().clearUnicasts(); // If there is no wildcard interface specified, we will have to iterate @@ -81,6 +82,7 @@ IfaceCfg::openSockets(const uint16_t port, const bool use_bcast) { " exist"); } iface->addUnicast(unicast->second); + iface->inactive6_ = false; } } @@ -115,15 +117,17 @@ IfaceCfg::reset() { } void -IfaceCfg::setState(const bool inactive) { +IfaceCfg::setState(const bool inactive, const bool loopback_inactive) { IfaceMgr::IfaceCollection ifaces = IfaceMgr::instance().getIfaces(); for (IfaceMgr::IfaceCollection::iterator iface = ifaces.begin(); iface != ifaces.end(); ++iface) { Iface* iface_ptr = IfaceMgr::instance().getIface(iface->getName()); if (getFamily() == V4) { - iface_ptr->inactive4_ = inactive; + iface_ptr->inactive4_ = iface_ptr->flag_loopback_ ? + loopback_inactive : inactive; } else { - iface_ptr->inactive6_ = inactive; + iface_ptr->inactive6_ = iface_ptr->flag_loopback_ ? + loopback_inactive : inactive; } } } diff --git a/src/lib/dhcpsrv/iface_cfg.h b/src/lib/dhcpsrv/iface_cfg.h index 6edc32e221..9c6311a4e1 100644 --- a/src/lib/dhcpsrv/iface_cfg.h +++ b/src/lib/dhcpsrv/iface_cfg.h @@ -152,14 +152,17 @@ public: private: - /// @brief Selects or deselects all interfaces. + /// @brief Selects or deselects interfaces. /// /// This function selects all interfaces to receive DHCP traffic or /// deselects all interfaces so as none of them receives a DHCP traffic. /// /// @param inactive A boolean value which indicates if all interfaces + /// (except loopback) should be selected or deselected. + /// @param loopback_inactive A boolean value which indicates if loopback + /// interface should be selected or deselected. /// should be deselected/inactive (true) or selected/active (false). - void setState(const bool inactive); + void setState(const bool inactive, const bool loopback_inactive); /// @brief Error handler for executed when opening a socket fail. ///