Skip to content
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

Move Network Manager bits into extensions #6756

Merged
merged 15 commits into from
Jun 20, 2024
Merged

Move Network Manager bits into extensions #6756

merged 15 commits into from
Jun 20, 2024

Conversation

igorpecovnik
Copy link
Member

@igorpecovnik igorpecovnik commented Jun 17, 2024

Description

This will allow dynamic selection and we could make even leaner NetworkManager-free minimal images. Which will be defaulted to systemd networking.

  • Standard (fat) image: use Netplan, NetworkManager, resolved and Chrony
  • Minimal image: use Netplan, systemd-networkd, resolved and timesyncd
  • Improve first login methods. Replace nmtui-connect with lightweight variant
  • added extensions: net-networkd, net-network-manager, net-timesyncd, net-chrony
  • remove all legacy ifupdown stuff (ifupdown2 is incompatible with Netplan)
  • move all network-manager related stuff into the extension

Jira reference number AR-2373

How Has This Been Tested?

  • systemd-networkd trixe and bookworm
  • systemd-networkd oracular and jammy and noble
  • Tested setting fixed IP on wired and wireless network
  • test firstlogin IP address retrieval function
  • test wireless connect in case we start without fixed network

Documentation changes

https://github.com/igorpecovnik/documentation/blob/master/docs/User-Guide_Networking.md

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

@igorpecovnik igorpecovnik added the Work in progress Unfinished / work in progress label Jun 17, 2024
@github-actions github-actions bot added size/medium PR with more then 50 and less then 250 lines Hardware Hardware related like kernel, U-Boot, ... Framework Framework components labels Jun 17, 2024
@igorpecovnik igorpecovnik force-pushed the AR-2373 branch 2 times, most recently from aae3bf4 to 0a66b50 Compare June 17, 2024 16:47
@github-actions github-actions bot added size/large PR with 250 lines or more and removed size/medium PR with more then 50 and less then 250 lines labels Jun 17, 2024
extensions/network-manager.sh Outdated Show resolved Hide resolved
extensions/network-manager.sh Outdated Show resolved Hide resolved
extensions/network-manager.sh Outdated Show resolved Hide resolved
extensions/systemd-neworkd.sh Outdated Show resolved Hide resolved
extensions/systemd-neworkd.sh Outdated Show resolved Hide resolved
lib/functions/configuration/main-config.sh Outdated Show resolved Hide resolved
@ColorfulRhino
Copy link
Collaborator

Overall I think this is a great idea 👍 Having stuff in a modular fashion definitely has its advantages.

lib/functions/configuration/main-config.sh Outdated Show resolved Hide resolved
extensions/systemd-neworkd.sh Outdated Show resolved Hide resolved
@igorpecovnik igorpecovnik force-pushed the AR-2373 branch 2 times, most recently from 00a6c0c to ea11602 Compare June 17, 2024 21:03
@ColorfulRhino
Copy link
Collaborator

I just tested with networkd, it won't even detect the ethernet, like no connection is up without manual config.

Any manual config won't work since the ethernet interfaces have different names (sometimes lan, wan, eth0, enps***, ...). We need auto detection.

@igorpecovnik
Copy link
Member Author

igorpecovnik commented Jun 17, 2024

I just tested with networkd, it won't even detect the ethernet, like no connection is up without manual config.

It works now.

We need auto detection.

Yes, it only works when its eth0 ...

@igorpecovnik igorpecovnik force-pushed the AR-2373 branch 2 times, most recently from d60374f to cd60f67 Compare June 17, 2024 21:23
@ColorfulRhino
Copy link
Collaborator

ColorfulRhino commented Jun 17, 2024

Okay I got it!

In /etc/systemd/network/20-dhcp-all-interfaces.network put:

[Match]
Name=*

[Network]
DHCP=yes

This will match all network interfaces and stuff will work automatically with DHCP enabled, like expected.

@igorpecovnik igorpecovnik force-pushed the AR-2373 branch 2 times, most recently from 5787057 to 12b18f5 Compare June 18, 2024 11:08
@ColorfulRhino
Copy link
Collaborator

Oh no, I was just working on a common Netplan config 😂

@ColorfulRhino
Copy link
Collaborator

ColorfulRhino commented Jun 18, 2024

https://github.com/armbian/build/blob/main/packages/bsp/common/usr/lib/armbian/armbian-firstlogin#L50-L118 will get messy when not using Netplan or another common way of config unfortunately.

But good news, I have tested a minimal system with networkd and alos with networkd+Netplan. There is not difference in RAM or CPU usage since Netplan only generates a config for the managing service (networkd or network-manager). So it should be fine to include in the minmal image 👍

Sorry by the way for spamming this PR, it's probably not the best idea to have more than one person work on the same topic 😅. I just enjoy networking stuff 😄

@igorpecovnik
Copy link
Member Author

So it should be fine to include in the minmal image

OK, lets go back then ;) I have no problem with that. I haven't done anything in the messy areas yet.

Sorry by the way for spamming this PR, it's probably not the best idea to have more than one person work on the same topic

I appreciate your input. Doing this together is better!

I just enjoy networking stuff

Networking is my passion too. Sorry for taking away something enjoyable 😄

@ColorfulRhino
Copy link
Collaborator

I appreciate your input. Doing this together is better!

Thanks! I did some substantial changes which are currently working pretty well I think. I can push them later. But maybe it's better if I open a new PR for this instead of pushing to this PR?

@igorpecovnik
Copy link
Member Author

I did some substantial changes which are currently working pretty well I think. I can push them later. But maybe it's better if I open a new PR for this instead of pushing to this PR?

In which area? I am not done yet with 1st config - setting up netplan config from external input and I haven't test network manager much yet.

- use Chrony with Network Manager
- use timesync with systemd-networkd
- use NetPlan with Network manager only
- move command-not-found to CLI image only
- improve firstlogin ip detection
@ColorfulRhino
Copy link
Collaborator

ColorfulRhino commented Jun 18, 2024

In which area? I am not done yet with 1st config - setting up netplan config from external input and I haven't test network manager much yet.

  • Refactoring
  • Extensions: net-networkd, net-network-manager, net-timesyncd, net-chrony (about to test network-manager)
  • Remove all legacy ifupdown stuff (ifupdown2 is incompatible with Netplan)
  • Move all network-manager related stuff into the extension

Maybe I'll put the config documents for the extensions in their own folder instead of doing cat <<- EOF >

I can't build at the moment because packages.debian.org is always down when trying to download base-files.

Also remove `$BRANCH == dev` line since dev branch does not exist anymore
@ColorfulRhino
Copy link
Collaborator

Done with the set_fixed_mac function. Haven't tested it, but it's more simplified and easier to understand than before I think :)

- Use resolved no matter what manages the network (networkd or NetworkManager)
- Use resolved.conf.d/ directory to set DNS as recommended by resolved itself
- In armbian-firstrun, remove config specific to mvebu64|mt7623 since this is now done by default
This should also include the case if zero retries are left, but the IP address has been found on this last retry.
@ColorfulRhino
Copy link
Collaborator

The IP address function should now work pretty stable. And it doesn't need to ping anything :)

…ve defined AP for wifi. Which we don't have yet.
If we have more ethernet devices, we want to list them one after another

Before:
IP address: 1.1.1.1
2.2.2.2

After
IP address: 1.1.1.1,2.2.2.2
@igorpecovnik igorpecovnik added Ready to merge Reviewed, tested and ready for merge and removed Needs review Seeking for review labels Jun 20, 2024
@igorpecovnik
Copy link
Member Author

igorpecovnik commented Jun 20, 2024

I am pleased with our common achievement and I think we are ready to go. Functionality is added, documentation is ready and there are in general less bugs then before.

@igorpecovnik igorpecovnik merged commit 6925745 into main Jun 20, 2024
10 checks passed
@igorpecovnik igorpecovnik deleted the AR-2373 branch June 20, 2024 17:59
@ColorfulRhino
Copy link
Collaborator

I agree, nice one! It was a lot of work, but network stuff should be pretty good now and likely easier to maintain in the future 👍

Although I don't quite understand this commit yet: 8d94b9e

if ($1 == "link/ether") was specifically looking for ethernet devices, I think wifi devices have another category when doing ip link show, don't they?

@igorpecovnik
Copy link
Member Author

I agree, nice one! It was a lot of work, but network stuff should be pretty good now and likely easier to maintain in the future

Yep. Wish for refactoring networking was year(s) old :) Now finally ✔️

if ($1 == "link/ether") was specifically looking for ethernet devices

My test wireless device represented itself as Ethernet ... otherwise this would be unnoticed.

@ColorfulRhino
Copy link
Collaborator

ColorfulRhino commented Jun 20, 2024

Yep. Wish for refactoring networking was year(s) old :) Now finally ✔️

Ah yes! It feels great when some long wish is finally fulfilled 😄

My test wireless device represented itself as Ethernet ... otherwise this would be unnoticed.

I see, that's a problem. On the other hand, only checking if it's not lo|vir|wl will not account for nertworks which have bridges, tunnels and so on, maybe for VPN and stuff.

What's your output for the wifi device when you do cat /sys/class/net/[interface_name]/type?

For ethernet it is 1.

Maybe

for dev in `ls /sys/class/net`; do
    [ -d "/sys/class/net/$dev/wireless" ] && echo "$dev"
done

can find your wireless device and filter it out?

Or maybe lshw -class network -short?

@igorpecovnik
Copy link
Member Author

will not account for nertworks which have bridges, tunnels and so on, maybe for VPN and stuff.

Yes, I think this is just fine as for 1st run we don't expect to have that. For automated scenarios this also doesn't apply as configuration is pushed to the system.

What's your output for the wifi device when you do cat /sys/class/net/[interface_name]/type?
For ethernet it is 1.

Classification is clearly wrong,

6: wlx44334c47dec3: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 44:33:4c:47:de:c3 brd ff:ff:ff:ff:ff:ff

cat /sys/class/net/wlx44334c47dec3/type 
1

Bus 003 Device 002: ID 148f:3070 Ralink Technology, Corp. RT2870/RT3070 Wireless Adapter

I am pretty sure this is not the only one ... (cheap) wireless networking is IMO quite a mess.

@ColorfulRhino
Copy link
Collaborator

Yes, I think this is just fine as for 1st run we don't expect to have that.

Sure but I think it may be forgotten if we don't fix it soon 😅 Maybe I have too high expectations regarding quality though, lol

For automated scenarios this also doesn't apply as configuration is pushed to the system.

What do you mean?

I am pretty sure this is not the only one ... (cheap) wireless networking is IMO quite a mess.

Oh no :(
Does this adapter have at least the file /sys/class/net/wlx44334c47dec3/wireless ?

@igorpecovnik
Copy link
Member Author

Maybe I have too high expectations regarding quality though, lol

This is perfectly fine. I am just trying not to go overkill ;)

What do you mean?

I mean if we preset network configuration, wizards does not run.

For wireless. I would propose not getting further as we are opening Pandora box LOL

Comment on lines +479 to +486
else
# Search for the extension file in any subdirectory
extension_file=$(find "${extension_base_path}" -type f -name "${extension_name}.sh" | head -n 1) # Example format: extensions/network/net-network-manager.sh
if [[ -n "${extension_file}" ]]; then
# Extract extension dir from file, e.g. from "extensions/network/net-network-manager.sh" the dir "extensions/network/" gets extracted
extension_dir="${extension_file%/*}"
break
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty late to this party, but I think this opens up too many possibilities for confusion. eg if someone has a/a/b.sh and a/a/a/b.sh which is loaded? I appreciate being able to group extensions in sub-directories, but really we should be explicit about them. @ColorfulRhino

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I agree this is not solved pretty, I wish I had found a prettier solution.
The reason for this was to be able to group multiple extensions (in this case networking stuff) in one folder as to not let the extensions folder become a massive clutter-dump.
The ultimate goal is to move more stuff into extensions as to make things more modular and replacable in general. If stuff is baked hard into the system, it's difficult and time-consuming to change stuff.

Comment on lines +51 to +58
cat <<- EOF > "${SDCARD}"/etc/systemd/resolved.conf.d/00-armbian-default-dns.conf
# Added by Armbian
#
# See resolved.conf(5) for details

[Resolve]
DNS=${NAMESERVER}
EOF
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the necro @ColorfulRhino but I've been badly bit by this. This seems to force resolved to use $NAMESERVER (which is always in practice set to 1.0.0.1) despite anything obtained through DHCP. I don't think we should have this in at all -- $NAMESERVER is required during image building but should be left to DHCP or manual user configuration at runtime. Why did you introduce this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
08 Milestone: Third quarter release Desktop Graphical user interface Framework Framework components Hardware Hardware related like kernel, U-Boot, ... Ready to merge Reviewed, tested and ready for merge size/large PR with 250 lines or more
Development

Successfully merging this pull request may close these issues.

3 participants