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

Regenerate network and system UCI configs on every reconfigure, switch to role-based interface configuration #2372

Merged
merged 8 commits into from
Mar 20, 2022

Conversation

neocturne
Copy link
Member

@neocturne neocturne commented Jan 9, 2022

This PR is now based on #2382 (therefore blocked)

  • lan_ifname, wan_ifname and setup_ifname are reset on every reconfigure
    • This makes it impossible to change these manually; instead, the roles of these logical interfaces can be modified on a higher level (see below). Changing the config mode interface (setup_ifname) is not possible.
    • When only one interface exists, it is called single_ifname, and lan_ifname/wan_ifname are unset to allow separate configuration via site.conf for this case
  • Generate fresh network config
    • Settings that are configurable in the Web UI are preserved, + minor additions
  • Generate fresh system config
    • Only the "system" section (hostname, remote syslog), NTP servers and GPIO (PoE passthrough) settings are preserved
  • Interface configuration is now role-based. A list of roles ("client", "uplink", "mesh") can be assigned to each of the logical interfaces (LAN/WAN or single). See the individual commit messages, in particular "gluon-core: initialize interfaces role configuration" and "treewide: use interface roles as basis for network configuration", for details
  • Modifying port assignment on swconfig-based devices is not possible at the moment (preserve flag only allows adding new custom sections, not modifying existing ones)

TODO:

To test:

  • Migrations from 2021.1.x
    • Correct migration of Mesh-on-LAN/WAN to mesh role on 2-interface devices
    • Correct migration of Mesh-on-WAN on 1-interface devices
    • Correct migration of Mesh-on-LAN on 1-interface devices that were originally set up with single_as_lan = true
  • Network config works for DSA-based devices
  • Network config works for swconfig-based devices
  • Other things?

@github-actions github-actions bot added 3. topic: babel Topic: Babel Layer 3 Routing 3. topic: batman-adv 3. topic: fastd 3. topic: package Topic: Gluon Packages 3. topic: tunneldigger This is about tunneldigger, a L2TP brokering solution 3. topic: wireguard This is about wireguard, an in-kernel layer 3 VPN labels Jan 9, 2022
@mkg20001
Copy link
Member

This kills the loopback interfacce

@neocturne
Copy link
Member Author

This kills the loopback interfacce

Oops, fixed.

@neocturne
Copy link
Member Author

Proposal for new site.conf settings for default interface assignment, superseding mesh_on_wan, mesh_on_lan and single_as_wan:

	interfaces = {
		lan = {
			default_roles = { 'client' },
		},
		wan = {
			default_roles = { 'uplink', 'mesh' },
		},
		single = {
			default_roles = { 'uplink', 'mesh' },
		},
	},

single will default to the same setting used for wan, but can be configured independently.

@neocturne
Copy link
Member Author

neocturne commented Jan 23, 2022

Migration of Mesh-on-WAN/LAN setting from the old configuration is implemented now.

I've also added a simple migration for single -> WAN and vice-versa to account for added and removed interfaces. This is currently not fully working without an upgrade, as /etc/board.json is not regenerated by default. We could account for this unusual case by regenerating board.json on every reconfigure. Edit: Resetting board.json on reconfigure is implemented now.

@neocturne neocturne force-pushed the uci-regen branch 3 times, most recently from 096478e to afe399f Compare January 23, 2022 22:34
@neocturne neocturne marked this pull request as ready for review January 23, 2022 23:19
@neocturne neocturne added 2. status: blocked Marked as blocked because it's waiting on something 2. status: waiting-on-review Awaiting review from the assignee but also interested parties. 5. needs: testing Testing of the changes is necessary 9. meta: release notes Significant change that should be mentioned in the release notes labels Jan 23, 2022
@neocturne neocturne changed the title [WIP] Regenerate network and system UCI configs on every reconfigure Regenerate network and system UCI configs on every reconfigure, switch to role-based interface configuration Jan 23, 2022
@AiyionPrime
Copy link
Member

AiyionPrime commented Jan 26, 2022

http://lilienstra-e.n.ffh.zone/ runs the current version of the PR.
mesh-on-wan does apparently still work, gluon-reconfigure does not break the device and dmesg does not throw obvious errors.

Wireless mesh is disabled as it has been before the update.

https://hannover.freifunk.net/karte/#/en/map/b44bd6202778

This appears not to break a device that has nothing to migrate, which is nice.
What else should be tested?

@neocturne
Copy link
Member Author

The PR description now contains a list of things to test. I have two devices for tests that actually need migration of interface names (a TP-LINK CPE510 v1 and a D-Link DIR-860L), but I don't think I have a single-interface device like that. Might be sufficient to test with x86 VMs, as /etc/config/network is reset anyways, so device-specific migration issues are unlikely (and if there are device-specific issues, they should also happen without migration).

I have also pushed a small change that should handle migration of the Mesh-on-LAN/WAN flag more correctly for single-interface devices.

@belzebub40k
Copy link
Contributor

Should be fixed now.

The problem with the selection of the mesh interfaces is fixed but the "Bad Gateway" message still shows up when clicking save & reboot.

Fixed as well now. And now I'm confused why this worked at all in Gluon 2021.1.x...

Strange but I can confirm it is fixed now.

@belzebub40k
Copy link
Contributor

belzebub40k commented Feb 14, 2022

I noticed a new problem. When using this branch I'm not able to change the hostname via the config-mode but pretty-hostname on the shell works. I did not notice any other options which are not saved. I tried to reproduce the problem with the master branch but there it is working fine.

EDIT: Never mind! I just noticed the conversation on IRC regarding the same problem. Can confirm it is fixed.

@AiyionPrime
Copy link
Member

Starting a build for the CPE210 now, @belzebub40k sorry I effectively put the hostname-discussion in the wrong PR.

@neocturne neocturne added the 2. status: blocked Marked as blocked because it's waiting on something label Feb 15, 2022
Do not write files when the content is unchanged.

Avoids a few unnecessary filesystem writes when resetting ifname
sysconfigs on each upgrade.
The new configuration generates sections iface_single/lan/wan in
/etc/config/gluon. These sections usually refer to a sysconfig-controlled
interface list, but adding custom sections with verbatim interfaces names
is also possible.

Each interface section contains a list of roles. The supported roles are
'client', 'uplink' and 'mesh'. Multiple roles can be configured on the
same interface (for example the old 'mesh_on_wan' setting would become
'uplink'+'mesh').

'client' is subsumed by any other role configured on the same interface
('client'+'mesh' is equivalent to 'mesh'). This property is important, as
it allows the Wired Mesh settings in gluon-web-network to simply add and
remove the mesh role without having to care what other roles are set -
so in the default setup, this would switch between 'client' and
'client'+'mesh' for the LAN interface.

By default, the WAN interface has role 'uplink' and the LAN interface
'client'; if only a single interface exists, the roles from the WAN
interface are used by default. The default for each of the three
interfaces (WAN/LAN/single) can be changed separated in site.conf,
superseding the old mesh_on_wan, mesh_on_lan and single_as_lan settings.
With the new role-based interface configuration, it would be better to
rename the wan/wan6 interfaces to uplink/uplink6, but that would cause
unnecessary churn for the firewall configuration, so it is left for a
later update.

As all interfaces with the 'uplink' role are in the br-wan bridge, it is
not possible to assign these to the 'mesh' role independently - instead,
br-wan is added as a mesh interface as soon as a single interface has
both the 'uplink' and 'mesh' roles. The UCI section for this
configuration is now called 'mesh_uplink' instead of 'mesh_wan'.

For all interfaces that have the 'mesh', but not the 'uplink' role a
second configuration 'mesh_other' is created. If there is more than one
such interface, all these interfaces are bridged as well (creating a
bridge 'br-mesh_other'). This replaces the 'mesh_lan' section with its
optional 'br-mesh_lan' bridge, but can also include interfaces that were
not considered "LAN" when interfaces roles are modified (via site.conf
or manually).
… introduce single_ifname

Allow interface names to change on updates to handle hwconfig -> DSA and
similar migrations.

On devices with only a single interface, a sysconfig single_ifname is
created instead of wan_ifname or lan_ifname to allow separate
configuration in site.conf.
A section can be marked as preseved by setting the gluon_preserve option
to 1. In addition the following conditions must hold:

- The preserved section must not already exist after OpenWrt's and
  Gluons setup scripts run. Modifying existing sections is currently
  unsupported.
- Preserved sections must be named, so it can be detected whether a
  section conflicts with a preexisting one.
@neocturne neocturne removed the 2. status: blocked Marked as blocked because it's waiting on something label Feb 22, 2022
@neocturne
Copy link
Member Author

Rebased and unblocked again.

@lemoer
Copy link
Member

lemoer commented Mar 17, 2022

What is the current state here? How are we going to proceed?

@neocturne
Copy link
Member Author

From my side this is ready to merge.

@blocktrron blocktrron merged commit a3203b2 into master Mar 20, 2022
@blocktrron blocktrron deleted the uci-regen branch March 20, 2022 16:54
@AiyionPrime
Copy link
Member

Thanks!

@rotanid rotanid removed the 2. status: waiting-on-review Awaiting review from the assignee but also interested parties. label Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. topic: babel Topic: Babel Layer 3 Routing 3. topic: batman-adv 3. topic: config-mode This is about the configuration mode 3. topic: docs Topic: Documentation 3. topic: multidomain 3. topic: package Topic: Gluon Packages 3. topic: wireguard This is about wireguard, an in-kernel layer 3 VPN 9. meta: release notes Significant change that should be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants