-
Notifications
You must be signed in to change notification settings - Fork 104
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
udev rules to prioritize network interfaces #167
Conversation
We will manage USB dongle priority over built-in wifi with udev rule. Just keep wifistart.sh for power save off which may help many wifi chips
Setting udev rules to give USB network adapters priority over Built-in interfaces if connected: - If USB adapters are connected they take precedence for wlan0 or eth0 over built-in interfaces. - If no external adapter are connected, built-in interfaces get wlan0 or eth0 names. This method applies equally to all devices and does not need specific logic to blacklist/force-load modules. It may work on other HW platforms, although more tests would be needed due to potential HW diversity: so we keep it for Pi at teh moment.
That's clever. Has it been tested extensively? (trying to avoid regressions) |
Thanks. Extensively, not really as I do not own sufficient HW derivatives. I made many unitary (positive and negative) tests for base search on my PiZero with my USB dongles (wifi 8188eu, ethernet asix), and noted no issue. If you experience issues, please send me udevadm info /sys/class/net/YOUR_INTERFACE so that I can eventually fine-tune the filters. |
I have a Pi3 with several USB wifi adapters. Exactly what do you need testing? Simply udev rule inclusion and look at interfaces brought up? |
Sure, that would be great, thanks! Indeed, you just have to restart with/without USB adapter plugged, and check which interface is actually used by Volumio. Besides adding the udev rules file, you'll also want to (make copies elsewhere first):
This will replicate the complete PR Looking forward your feedback. |
RTL8188cus: works as wanted, USB dongle wlan0, RPi internal wlan1 Edit: used second udev rule |
ok, thanks. For few (rename4 in particular) it may be because of existing ralink rule installed by mrEngman drivers: could you I guess Volumio does not have drivers for Atheros (AR9170+AR9101), so the fact they won't work is probably not related to this. Should we install drivers, they would probably be taken care of. (Would be nice to try though) |
Well, on second time of asking RTL8192cu comes up as wlan0 (RPi internal wlan1). Strange?? RT5370:
Removing the ralink rule made no difference. |
let me look... |
Can you please make sure
With that, are RTL8192cu and RT5370 still "faulty" in their names? |
before removing power, make sure you type: |
yes remove power after proper shutdown indeed! |
Ok, sorry for delay ... dog walking and making dinner got in the way ;). Right, repeated for 4 dongles, ralink rule renamed, 70-persistent-net.rules as per your post above, sync & cold reboots between each. RT8188cus: wlan0 and RPi internal on wlan1 Don't know if it's useful but udevadm info /sys/class/net/rename4 for Atheros is: volumio@volumiokitchen:~$ udevadm info /sys/class/net/rename4 |
renamed what? (names do matter for rules as they are executed in sequence): removed from that directory (or altogether) would be much safer. |
Ah sorry, I was under the impression that it was anything named *.rules. I'll move it & try again. Edit: Nope, exactly the same behaviour for RT5370 with the ralink rule totally absent from directory. |
Thanks for your kind help. ...and |
one other thing...can you comment (or remove) the second line (the one related to eth0) of the rule for now? |
I've not truncated the output from dmesg: http://pastebin.com/JzbazcyQ Removing the eth0 line from the rule made no apparent diffference. udevadm info -a /sys/class/net/rename4: http://pastebin.com/x4bqQjy5 |
Thanks. Can you replace the rule content by this and tell if it helps?
|
Dongle still named 'rename4' |
|
http://pastebin.com/rfFKqgxg .....journalctl -b up to Volumio system starting. Noticeably much longer to reach accepting ssh connections with these dongles that have name as rename4. Built-in wifi still wlan0. Just checking other dongles now. Sorry, no ethernet-USB dongles Edit: RTL* work fine |
Did you cut&paste the rule, can you eventually delete and retype? I'm wondering if there is nothing wrong with those dongle drivers. |
ok, seems like RT5370/TL-WN727N v3/Tenda_W311M might need extra config for proper udev support... do you have anything in there |
I did cut&paste..now deleted and typed in ... no difference to naming behaviour. Yes, the dongle drivers are working fine; I can connect to my home AP without problems (after disabling internal wifi). However, neither Atheros or Ralink successfully created Volumio hotspot (indicated as 'on' in UI, but can't see network on my phone or a wifi analyser). Drivers present in rt2800usb:
So to conclude: the Atheros and Ralink dongles work fine with Volumio in RPi3 with internal wifi disabled, but they do not 'behave' with your prioritising udev rule, and nor do they produce hotspots with Volumio's current scripting. As an aside, I bought the Atheros dongle specifically, quite some time ago, to investigate generating a hotspot for Volumio for a portable device ... at the time, it was one of a few dongles with an appropriate chipset that could simultaneously act as hotspot and normal wifi. |
ok, thanks. Maybe @earlchew can bring expertise on overall |
Good luck. Udev is very powerful, but a bit of a pig to fine-tune to achieve exactly what you want/expect. |
RT5370: wlan1 (internal wlan0) |
Ok. I'm going to try to remotely access a friend's Pi3 to directly test some base stuff on that HW next week (several things at play it seems). If you accept, I'll get back to you when I have something more reliable to test across dongles, not to abuse your time and patience. Thanks again! |
Not needed as already taken care of for all platforms and wlan chipsets by: https://github.com/volumio/Build/blob/master/volumio/etc/network/if-pre-up.d/powersavedisable Currently file is empty: did not remove as is used in https://github.com/volumio/Build/blob/master/volumio/lib/systemd/system/wireless.service (ExecStartPre=-/bin/wifistart.sh), and may be a placehoder for other stuff? If removed in the end, reference should also be removed in here https://github.com/volumio/Build/blob/master/scripts/configure.sh#L86-L88
Still WIP? |
Yes...planning a remote session with @chsims1 to figure-out specif issues with his dongles/setup. BTW, to you want me to keep empty |
Udev rule to prioritize USB network interfaces over built-in ones. Rule relies on a script to actually change name, as renaming to base kernel interface names may fail with some drivers.
This script, called by Volumio udev rules change network interface name.
move rename_netiface0.sh at right place during Build and set execution permissions
Now available (and working) in all platforms
Let's keep it as an empty placeholder please (but I think we still need it to set power save off) |
/etc/network/if-pre-up.d/powersavedisable does it already! |
Sometimes this does not work, for example for network devices turned on by wireless.js |
@volumio said
For my education, I'm curious which action in wireless.js does not relate to
I'll restore the line in As for the udev stuff: seems to work great on wlan side on @chsims1 setup: will let him confirm. |
Exclude internal eth interface (smsc95xx driver) from interface priority renaming rule
Yep, all seems to be playing together nicely here. Well done. |
handles situation where script may be called for eth and wlan before first one is terminated. use one _temp_name per interface type to avoid potential collisions.
reversed 2ca705f
Glad it works! @volumio still giving a bit of thought & re-reading: will change PR title when ready for merge on my side. |
@volumio I think it can be merged now. |
Ok, let me do last checks and then I'll merge |
Please hold a bit pending a last test from @chsims1 with that rules:
Simpler if no rename4 issues reported with that one (would not depend on extra code for naming). |
Ok, so the whole current PR is needed to circumvent some potential race conditions in renaming interfaces with kernel's default names. Longer term, it might be wise to consider naming Volumio network interfaces by some specific (and predictable) names, outside of kernel's default namespace (like volumio_wlan, volumio_lan or any other better names). |
Reported working by @chsims1 with that addition on Pi (Home wifi AP only, not Volumio Hotspot at this point) volumio#167 (comment)
udev rules to prioritize network interfaces
This PR replaces Pi3-specific driver blacklist-based filter by udev rule.
It brings several benefits:
This fix has been tested with several devices and dongles.