[fix] NDK pthread_np support
This commit is contained in:
+20
-3
@@ -28,6 +28,25 @@ with open(config_toml_path, 'w') as f:
|
|||||||
|
|
||||||
# -------------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Patch ZeroTierOne/osdep/LinuxEthernetTap.cpp
|
||||||
|
|
||||||
|
linux_tap_path = 'ZeroTierOne/osdep/LinuxEthernetTap.cpp'
|
||||||
|
|
||||||
|
linux_tap_match1 = 'int rc = pthread_setaffinity_np(self, sizeof(cpu_set_t), &cpuset);'
|
||||||
|
linux_tap_replace1 = 'int rc = sched_setaffinity(pthread_gettid_np(self), sizeof(cpu_set_t), &cpuset);'
|
||||||
|
|
||||||
|
linxu_tap_match2 = '#include <sys/utsname.h>'
|
||||||
|
linux_tap_replace2 = '#include <sys/utsname.h>\n#include <sched.h>'
|
||||||
|
|
||||||
|
with open(linux_tap_path, 'r') as file:
|
||||||
|
data = file.read()
|
||||||
|
patch_NDK = data.replace(linux_tap_match1, linux_tap_replace1).replace(linux_tap_match2, linux_tap_replace2)
|
||||||
|
|
||||||
|
with open(linux_tap_path, 'w') as file:
|
||||||
|
file.write(patch_NDK)
|
||||||
|
|
||||||
|
# -------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
# Patch make-linux.mk
|
# Patch make-linux.mk
|
||||||
|
|
||||||
make_linux_path = 'ZeroTierOne/make-linux.mk'
|
make_linux_path = 'ZeroTierOne/make-linux.mk'
|
||||||
@@ -68,8 +87,6 @@ with open(make_linux_path, 'r') as file:
|
|||||||
|
|
||||||
osutil_path = 'ZeroTierOne/osdep/OSUtils.cpp'
|
osutil_path = 'ZeroTierOne/osdep/OSUtils.cpp'
|
||||||
with open(osutil_path, 'r') as file:
|
with open(osutil_path, 'r') as file:
|
||||||
data = file.read().replace(
|
data = file.read().replace('/var/lib/zerotier-one', '/data/adb/zerotier/home')
|
||||||
'/var/lib/zerotier-one', '/data/adb/zerotier/home'
|
|
||||||
)
|
|
||||||
with open(osutil_path, 'w') as file:
|
with open(osutil_path, 'w') as file:
|
||||||
file.write(data)
|
file.write(data)
|
||||||
@@ -21,6 +21,11 @@ _stop() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
kill -9 $pid
|
kill -9 $pid
|
||||||
|
|
||||||
|
# delete from ip rules
|
||||||
|
ip rule del from all lookup main pref 1
|
||||||
|
ip -6 rule del from all lookup main pref 1
|
||||||
|
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
log "kill zerotier-one failed"
|
log "kill zerotier-one failed"
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -13,5 +13,10 @@ PIPE_APP=$APPROOT/run/pipe
|
|||||||
export LD_LIBRARY_PATH=/system/lib64:/data/adb/zerotier/lib
|
export LD_LIBRARY_PATH=/system/lib64:/data/adb/zerotier/lib
|
||||||
|
|
||||||
__start() {
|
__start() {
|
||||||
|
# add main route table to lookup rules
|
||||||
|
ip rule add from all lookup main pref 1
|
||||||
|
ip -6 rule add from all lookup main pref 1
|
||||||
|
|
||||||
|
# start zerotier daemon
|
||||||
nohup $ZTROOT/zerotier-one -d >> $ZT_LOG 2>&1 &
|
nohup $ZTROOT/zerotier-one -d >> $ZT_LOG 2>&1 &
|
||||||
}
|
}
|
||||||
@@ -33,11 +33,6 @@ mkdir -p $ZTROOT/run
|
|||||||
# start zerotier
|
# start zerotier
|
||||||
# ----------------------------------------------
|
# ----------------------------------------------
|
||||||
|
|
||||||
# add main route table to lookup rules
|
|
||||||
ip rule add from all lookup main pref 1
|
|
||||||
ip -6 rule add from all lookup main pref 1
|
|
||||||
|
|
||||||
# start zerotier
|
|
||||||
__start
|
__start
|
||||||
|
|
||||||
# ----------------------------------------------
|
# ----------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user