Bug 301577

Summary: Broken link state awareness on FreeBSD
Product: [Applications] knemo Reporter: Alberto Villa <avilla>
Component: generalAssignee: John Stamp <jstamp>
Status: RESOLVED UNMAINTAINED    
Severity: major    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: FreeBSD Ports   
OS: FreeBSD   
Latest Commit: Version Fixed In:
Attachments: Fix to the bug.

Description Alberto Villa 2012-06-10 13:56:19 UTC
Connection state of interfaces is detected in two ways on FreeBSD.

AF_LINK interfaces:
stats->ifi_link_state == LINK_STATE_UP

AF_INET ones:
ifa->ifa_flags & IFF_RUNNING && addrVal.scope != RT_SCOPE_LINK && addrVal.scope != RT_SCOPE_NOWHERE

While the first one is correct (even if I don't think we should check for the link-layer connection, as we need the network one - anyway, it's being overwritten, so it's fine), the AF_INET interface uses IFF_RUNNING which on FreeBSD is a driver reserved value (and is mostly set when the driver is loaded).

The consequence of this is that the interface, if it has an IP set, is detected as connected. Instead, ioctl() should be used to get a reliable state.

Reproducible: Always
Comment 1 Alberto Villa 2012-06-10 13:58:29 UTC
Created attachment 71701 [details]
Fix to the bug.

I'm attaching a patch which fixes the issue checking for the IFM_ACTIVE flag (just like ifconfig and dhclient do).
Comment 2 John Stamp 2012-06-12 02:18:12 UTC
SVN commit 1299926 by jstamp:

Fix link state awareness on FreeBSD

Thanks to Alberto Villa for the report and patch.


 M  +6 -1      bsdbackend.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1299926
Comment 3 Andrew Crouthamel 2018-10-29 22:10:13 UTC
Hello! Sorry to be the bearer of bad news, but this project has been unmaintained for many years so I will be closing this bug.