@@ -118,7 +118,7 @@ class InterfaceMonitorImpl : public InterfaceMonitor {
118118 sys_string name (req.lifr_name );
119119
120120 auto interfaceFlags = ioctlSocket<GetLInterfaceFlags>(m_socket, name).value ();
121- if ((interfaceFlags & IFF_LOOPBACK) || !(interfaceFlags & IFF_MULTICAST ))
121+ if (isUnusableInterface (interfaceFlags))
122122 continue ;
123123 auto index = ioctlSocket<GetLInterfaceIndex>(m_socket, name).value ();
124124 m_handler->addAddress (NetworkInterface (index, name), addr);
@@ -204,7 +204,7 @@ class InterfaceMonitorImpl : public InterfaceMonitor {
204204 }
205205
206206 if (header->rtm_type == RTM_IFINFO) {
207- knownIfaces[result.iface ->index ] = (interfaceFlags & IFF_LOOPBACK) || !(interfaceFlags & IFF_MULTICAST );
207+ knownIfaces[result.iface ->index ] = isUnusableInterface (interfaceFlags);
208208 } else {
209209 if (auto it = knownIfaces.find (result.iface ->index ); it == knownIfaces.end ()) {
210210 #if HAVE_SIOCGLIFCONF
@@ -214,7 +214,7 @@ class InterfaceMonitorImpl : public InterfaceMonitor {
214214 #endif
215215 if (auto flagsRes = ioctlSocket<GetInterfaceFlagsType>(m_socket, result.iface ->name )) {
216216 interfaceFlags = flagsRes.assume_value ();
217- bool ignore = (interfaceFlags & IFF_LOOPBACK) || !(interfaceFlags & IFF_MULTICAST );
217+ bool ignore = isUnusableInterface (interfaceFlags);
218218 knownIfaces.emplace (result.iface ->index , ignore);
219219 }
220220 }
@@ -288,17 +288,29 @@ class InterfaceMonitorImpl : public InterfaceMonitor {
288288 ignore = it->second ;
289289 }
290290
291- if (!ignore)
291+ if (!ignore) {
292292 m_handler->addAddress (iface, addr);
293- else
293+ } else if (m_config->enableLoopback ()) {
294+ WSDLOG_DEBUG (" Interface {} doesn't support multicast - ignoring" , iface);
295+ } else {
294296 WSDLOG_DEBUG (" Interface {} is loopback or doesn't support multicast - ignoring" , iface);
297+ }
295298
296299 } else {
297300
298301 m_handler->removeAddress (iface, addr);
299302 }
300303 }
301304
305+ template <class T >
306+ bool isUnusableInterface (T interfaceFlags) {
307+ bool res = !(interfaceFlags & IFF_MULTICAST);
308+ if (!res && !m_config->enableLoopback ()) {
309+ res = (interfaceFlags & IFF_LOOPBACK);
310+ }
311+ return res;
312+ }
313+
302314private:
303315 const refcnt_ptr<Config> m_config;
304316 Handler * m_handler = nullptr ;
0 commit comments