Static build support + RTM_NEWLINK race fix
1. CMakeLists.txt: BUILD_STATIC cmake option. When ON, links against static libnl-3 archives and sets -static linker flag. Required for deploying vwifi-client to OpenWrt DUT (no libnl-3 shared library). 2. cmonwirelessdevice.cc: RTM_NEWLINK race fix. new_net_interface() called get_winterface_infos() which does an nl80211 roundtrip on wifi.nls — same socket used by winet_update_loop's 1s poll. When both hit the socket concurrently, responses get crossed and the new interface is permanently lost from _list_winterfaces. Fix: call _newinet_cb(inetdevice) directly since RTM_NEWLINK already has all needed info (name, ifindex, MAC). No shared socket access. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
4d144cd2f4
commit
fee9a651ba
@@ -91,7 +91,13 @@ set(COMMON_SOURCES
|
|||||||
|
|
||||||
add_library(vwifi_common STATIC ${COMMON_SOURCES})
|
add_library(vwifi_common STATIC ${COMMON_SOURCES})
|
||||||
# Link common library dependencies once
|
# Link common library dependencies once
|
||||||
|
option(BUILD_STATIC "Build static binaries" OFF)
|
||||||
|
if(BUILD_STATIC)
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "-static")
|
||||||
|
target_link_libraries(vwifi_common PUBLIC Threads::Threads /usr/lib/x86_64-linux-gnu/libnl-genl-3.a /usr/lib/x86_64-linux-gnu/libnl-3.a)
|
||||||
|
else()
|
||||||
target_link_libraries(vwifi_common PUBLIC Threads::Threads PkgConfig::LIBNL3)
|
target_link_libraries(vwifi_common PUBLIC Threads::Threads PkgConfig::LIBNL3)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
# --- Executables ---
|
# --- Executables ---
|
||||||
|
|||||||
@@ -323,7 +323,7 @@ void MonitorWirelessDevice::new_net_interface(struct nlmsghdr *h)
|
|||||||
|
|
||||||
if(inetdevice.checkif_wireless_device()){
|
if(inetdevice.checkif_wireless_device()){
|
||||||
|
|
||||||
get_winterface_infos(ifi->ifi_index); // we can call a callback here, instead calling it in recv_winterface_infos, to reduce cpu
|
_newinet_cb(inetdevice); // Fix: call directly, skip nl80211 roundtrip (races with winet_update_loop)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user