-
Notifications
You must be signed in to change notification settings - Fork 321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discuss ways to improve Virtual Wifi #791
Comments
Maybe try creating a docker network and then assigning it to the container and then try that way |
Here is my redroid WiFi solution, which relies on the mac80211_hwsim kernel module. I have currently abandoned creating a router namespace, and the WiFi is running correctly. I think replacing it with the virt_wifi module should also work properly. |
good job! I investigated the https://github.com/torvalds/linux/blob/master/drivers/net/wireless/virtual/virt_wifi.c#L139 |
I'm trying to replace the rmmod mac80211_hwsim
modprobe virt_wifi Then I modified diff --git a/network/init.redroid.net.sh b/network/init.redroid.net.sh
index 37e273d..d39882f 100755
--- a/network/init.redroid.net.sh
+++ b/network/init.redroid.net.sh
@@ -95,7 +54,9 @@ if [ "$redroid_wifi" -eq "1" -o "$redroid_radio" -eq "1" ]; then
/system/bin/ip route add default via ${eth0_gw} dev veth0
if [ "$redroid_wifi" -eq "1" ]; then
- init_wlan
+ #init_wlan
+ /system/bin/ip link add link veth0 name wlan0 type virt_wifi
+ /system/bin/ip link set wlan0 up
fi After that I started the redroid container and indeed I could access the android interface via scrcpy. But when I try to start the wifi it doesn't start successfully. This is the logcat log.
Then I checked the NIC device information in the shell :/ # ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: veth0@if7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether bc:24:11:f6:b9:e5 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 192.168.1.100/24 brd 192.168.1.255 scope global veth0
valid_lft forever preferred_lft forever
inet6 fe80::be24:11ff:fef6:b9e5/64 scope link tentative
valid_lft forever preferred_lft forever
3: wlan0@veth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
link/ether bc:24:11:f6:b9:e5 brd ff:ff:ff:ff:ff:ff
inet6 fe80::be24:11ff:fef6:b9e5/64 scope link tentative
valid_lft forever preferred_lft forever
:/ # ifconfig -a
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope: Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:2 errors:0 dropped:0 overruns:0 frame:0
TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:80 TX bytes:80
veth0 Link encap:Ethernet HWaddr bc:24:11:f6:b9:e5
inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::be24:11ff:fef6:b9e5/64 Scope: Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:70 errors:0 dropped:3 overruns:0 frame:0
TX packets:41 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:18123 TX bytes:7035
wlan0 Link encap:Ethernet HWaddr bc:24:11:f6:b9:e5
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 TX bytes:0 Tried to manually start the wlan0 device, but it didn't work :/ # /system/bin/ip link set wlan0 up
:/ # /system/bin/ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: veth0@if7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
link/ether bc:24:11:f6:b9:e5 brd ff:ff:ff:ff:ff:ff link-netnsid 0
3: wlan0@veth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000
link/ether bc:24:11:f6:b9:e5 brd ff:ff:ff:ff:ff:ff
:/ # ifconfig wlan0 up
:/ # /system/bin/ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: veth0@if7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
link/ether bc:24:11:f6:b9:e5 brd ff:ff:ff:ff:ff:ff link-netnsid 0
3: wlan0@veth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000
link/ether bc:24:11:f6:b9:e5 brd ff:ff:ff:ff:ff:ff Maybe I'm missing something? |
Regarding the Virtual Wifi implementation, it's all based on the
mac80211_hwsim
kernel module.By creating two virtual wifi devices,
wlan0
andwlan1
, and adding namespace divisions to differentiate betweenmain
androuter
, so you can simulate a wireless AP and a wifi receiver.Here's the structure.
But this method has been abandoned at AOSP13
There is actually a better solution now, using the
virt_wifi
kernel module.Masquerade a wired network card as a wireless network card
I tried it in Ubuntu 22.04, it does work.
But I don't know the Android source code well enough to figure out how to implement it, although I've looked at the code for blissOS
https://github.com/BlissRoms-x86/device_generic_common/blob/6017b7d8071e148623efca41531fc1c5ff2a6092/init.sh#L49
https://github.com/BlissRoms-x86/device_generic_common/blob/6017b7d8071e148623efca41531fc1c5ff2a6092/init.x86.rc#L92
I tried to run these commands in redroid, and it does create wlan0, but this causes adb to be inaccessible, so there's no way to tell if the wifi is working properly
I think I also need to fix the wifi autoconnect to keep adb accessible, because by running these commands, the only network eth0 in the container is changed to wifi_eth, which in turn Android assumes there is no network connection.
The text was updated successfully, but these errors were encountered: