mirror of
https://github.com/garywill/linux-router.git
synced 2025-12-30 18:58:28 +01:00
Compare commits
4 Commits
workaround
...
dev-12
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
200b6d4451 | ||
|
|
2ea1dfd5b7 | ||
|
|
204756cffb | ||
|
|
e1ccfac40c |
90
lnxrouter
90
lnxrouter
@@ -1119,6 +1119,10 @@ backup_interface_status() {
|
||||
# nm managing status is saved when nm_set_unmanaged()
|
||||
}
|
||||
restore_interface_status() {
|
||||
# virtual wifi interface will be destroyed, so no need to restore status
|
||||
# don't use [[ $VWIFI_IFACE ]] to judge, if creating virtual wifi failed, VWIFI_IFACE is empty
|
||||
[[ "$WIFI_IFACE" && "$NO_VIRT" -eq 0 ]] && return
|
||||
|
||||
restore_ipv6_bits
|
||||
|
||||
if [[ -n "$OLD_MACADDR" && "$(get_interface_mac $SUBNET_IFACE)" != "$OLD_MACADDR" ]] ; then
|
||||
@@ -1128,6 +1132,7 @@ restore_interface_status() {
|
||||
|
||||
nm_restore_manage
|
||||
|
||||
[[ $SUBNET_IFACE_ORIGINAL_UP_STATUS -eq 1 ]] && ip link set up dev ${SUBNET_IFACE} && echo "Restore ${SUBNET_IFACE} to link up"
|
||||
}
|
||||
#---------------------------------------
|
||||
|
||||
@@ -1150,7 +1155,12 @@ kill_processes() { # for this instance
|
||||
_cleanup() {
|
||||
local x
|
||||
|
||||
ip addr flush ${SUBNET_IFACE}
|
||||
|
||||
rm -rf $CONFDIR
|
||||
|
||||
ip link set down dev ${SUBNET_IFACE}
|
||||
|
||||
if [[ $VWIFI_IFACE ]]; then # the subnet interface (virtual wifi interface) will be removed
|
||||
iw dev ${VWIFI_IFACE} del
|
||||
dealloc_vface_name $VWIFI_IFACE
|
||||
@@ -1586,13 +1596,15 @@ decide_target_interface() {
|
||||
|
||||
decide_ip_addresses() {
|
||||
if [[ ! -n $GATEWAY ]]; then
|
||||
echo
|
||||
GATEWAY="$(generate_random_ip4)"
|
||||
echo "Use random LAN IPv4 address $GATEWAY"
|
||||
elif [[ ! "$GATEWAY" =~ "." ]]; then
|
||||
GATEWAY="192.168.${GATEWAY}.1"
|
||||
fi
|
||||
|
||||
if [[ $IPV6 -eq 1 && ! -n $PREFIX6 ]]; then
|
||||
echo
|
||||
PREFIX6="$(generate_random_lan_ip6_prefix)"
|
||||
echo "Use random LAN IPv6 address ${PREFIX6}${IID6}"
|
||||
elif [[ ! "$PREFIX6" =~ ":" ]]; then
|
||||
PREFIX6="fd00:0:0:${PREFIX6}::"
|
||||
fi
|
||||
@@ -1602,6 +1614,10 @@ decide_ip_addresses() {
|
||||
}
|
||||
|
||||
prepare_wifi_interface() {
|
||||
|
||||
sleep 1
|
||||
echo; echo; echo;
|
||||
echo "Trying to set power_save off ..."
|
||||
if [[ $USE_IWCONFIG -eq 0 ]]; then
|
||||
iw dev ${WIFI_IFACE} set power_save off
|
||||
fi
|
||||
@@ -1625,6 +1641,8 @@ prepare_wifi_interface() {
|
||||
fi
|
||||
fi
|
||||
|
||||
sleep 6
|
||||
echo; echo; echo;
|
||||
echo "Creating a virtual WiFi interface... "
|
||||
VWIFI_IFACE=$(alloc_new_vface_name)
|
||||
if iw dev ${WIFI_IFACE} interface add ${VWIFI_IFACE} type __ap; then
|
||||
@@ -1939,9 +1957,7 @@ phead
|
||||
phead2
|
||||
echo
|
||||
|
||||
echo
|
||||
echo "This is workaround for #31. Must use with '-g' and for wired interface !"
|
||||
echo
|
||||
echo " ============ In dev branch for issue #12 ==========="
|
||||
|
||||
echo "PID: $$"
|
||||
|
||||
@@ -1966,10 +1982,33 @@ init_trap
|
||||
|
||||
init_conf_dirs # CONFDIR , COMMON_CONFDIR . make dir
|
||||
|
||||
echo -e "\nDistro:"
|
||||
cat /etc/os-release
|
||||
|
||||
echo -e "\nKernel:"
|
||||
uname -a
|
||||
echo
|
||||
|
||||
echo "setting NM log level: nmcli general logging level TRACE domains ALL"
|
||||
nmcli general logging level TRACE domains ALL
|
||||
|
||||
echo "Logging journalctl -f"
|
||||
journalctl -f &
|
||||
echo $! > $CONFDIR/journalctl.pid
|
||||
|
||||
echo "Logging dmesg -W"
|
||||
dmesg -W &
|
||||
echo $! > $CONFDIR/dmesg.pid
|
||||
|
||||
echo "Logging wpa_supplicant.log"
|
||||
tail -f /var/log/wpa_supplicant.log &
|
||||
echo $! > $CONFDIR/wpa_supplicant_log.pid
|
||||
|
||||
[[ $WIFI_IFACE ]] && prepare_wifi_interface # this will create virtual ap interface (if needed) and set VWIFI_IFACE and AP_IFACE (if success)
|
||||
|
||||
SUBNET_IFACE="$(decide_subnet_interface)" # SUBNET_IFACE can be TARGET_IFACE (wired) or AP_IFACE (ap) .this is after prepare_wifi_interface()
|
||||
echo "$SUBNET_IFACE" > "$CONFDIR/subn_iface"
|
||||
ip addr show dev ${SUBNET_IFACE}
|
||||
|
||||
# if virtual wifi interface, will be destroyed, so only need to save status when not
|
||||
[[ -z $VWIFI_IFACE ]] && backup_interface_status
|
||||
@@ -1989,6 +2028,10 @@ fi
|
||||
#===================================================
|
||||
#===================================================
|
||||
|
||||
sleep 1
|
||||
echo; echo; echo;
|
||||
ip addr show dev ${SUBNET_IFACE}
|
||||
echo "Trying to set NM unmanage ..."
|
||||
# set interface unmanaged by networkManager
|
||||
if [[ $NM_RUNNING -eq 1 ]] && nm_knows $TARGET_IFACE; then # if nm knows target iface, should know subnet iface too. but need to wait until nm finds subnet iface (waiting code is in nm_set_unmanaged()
|
||||
nm_set_unmanaged ${SUBNET_IFACE} # will write NM_UNM_LIST
|
||||
@@ -1998,14 +2041,51 @@ fi
|
||||
#===========================
|
||||
|
||||
|
||||
sleep 1
|
||||
echo; echo; echo;
|
||||
ip addr show dev ${SUBNET_IFACE}
|
||||
echo "Trying to set ${SUBNET_IFACE} down ..."
|
||||
# initialize subnet interface
|
||||
# take subnet interface down first
|
||||
ip link set down dev ${SUBNET_IFACE} || die "Failed setting ${SUBNET_IFACE} down"
|
||||
|
||||
sleep 1
|
||||
echo; echo; echo;
|
||||
ip addr show dev ${SUBNET_IFACE}
|
||||
echo "Trying to flush ${SUBNET_IFACE} ..."
|
||||
# flush old IPs of subnet interface
|
||||
ip addr flush ${SUBNET_IFACE} || die "Failed flush ${SUBNET_IFACE} IP"
|
||||
|
||||
sleep 1
|
||||
echo; echo; echo;
|
||||
ip addr show dev ${SUBNET_IFACE}
|
||||
dealwith_mac # setting MAC should be after setting NM unmanaged
|
||||
|
||||
sleep 1
|
||||
echo; echo; echo;
|
||||
ip addr show dev ${SUBNET_IFACE}
|
||||
echo "Trying to check and do rfkill unblock ..."
|
||||
[[ $WIFI_IFACE ]] && check_rfkill_unblock_wifi
|
||||
|
||||
sleep 1
|
||||
echo; echo; echo;
|
||||
ip addr show dev ${SUBNET_IFACE}
|
||||
echo "Trying to bring interface ${SUBNET_IFACE} up ..."
|
||||
# bring subnet interface up
|
||||
ip link set up dev ${SUBNET_IFACE} || die "Failed bringing ${SUBNET_IFACE} up"
|
||||
|
||||
sleep 1
|
||||
echo; echo; echo;
|
||||
echo "Finished test. Exiting ..."
|
||||
clean_exit
|
||||
exit
|
||||
|
||||
|
||||
# hostapd , haveged
|
||||
[[ $WIFI_IFACE ]] && run_wifi_ap_processes
|
||||
|
||||
# add ipv4 address to subnet interface
|
||||
ip -4 addr add ${GATEWAY}/24 broadcast ${GATEWAY%.*}.255 dev ${SUBNET_IFACE} || die "Failed setting ${SUBNET_IFACE} IPv4 address"
|
||||
|
||||
set_ipv6_bits
|
||||
|
||||
|
||||
Reference in New Issue
Block a user