8 Commits

Author SHA1 Message Date
Andrey Smirnov
205a8d6dc4
chore: make nethelpers build on all OSes
Related to #4420

This removes `linux` build tags to make sure all `nethelpers` build on
any OS, as it's part of Talos API (via resources). Constants were
replaced with literal values. Code generated by `stringer` serves as
proof of the change: constant values haven't changed.

Remove build tags from `pkgs/resources/network` now, marking only a part
of single file `_linux` (which converts link spec to low-level netlink
messages).

Theere should be no functional changes.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
2021-10-26 22:45:10 +03:00
Andrey Smirnov
b450b7cef0
chore: deprecate Interfaces and Routes APIs
Fixes #4094

Deprecate old networkd APIs, `talosctl interfaces` and `talosctl routes`
now suggest different commands to be used to achieve same task.

TUI installer was updated to stop using Interfaces API.

Those APIs will be completely removed in 0.14.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
2021-09-27 15:21:02 +03:00
Andrey Smirnov
5ca1fb8221
fix: multiple fixes for KubeSpan and Wireguard implementation
* calculate covering IPPrefixes for the KubeSpan peer `AllowedIPs`,
check for overlap
* don't use KubeSpan IP as potential node endpoint (inception!)
* allow Wireguard config to be applied which doesn't change peer
endpoint
* support for pre-shared Wireguard peer keys

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
Signed-off-by: Seán C McCord <ulexus@gmail.com>
Co-authored-by: Seán C McCord <ulexus@gmail.com>
2021-09-10 16:23:27 +03:00
Andrey Smirnov
0b8681b4b4 fix: resolve several issues with Wireguard link specs
* correctly merge wireguard specs across multiple configuration layers
(partially stolen from #3577)

* fix erroneous wireguard reconfig when listen port in the config is
zero

* add tests for link merging (once again, partially stolen from #3577)

* fix ugly bug with LinkSpec Type merging (I believe it's a major source
of pain for you, Seán, in your PR).

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2021-08-03 13:25:19 -07:00
Andrey Smirnov
b609f33cde fix: update networking stack after Equnix Metal testing
This PR contains multiple fixes to the networking controllers and
logging improvements for easier debugging:

* `LinkConfigController` now correctly merges duplicate link definitions
in the machine configuration
* `LinkConfigController` correctly enslaves bond interfaces even if
they're not mentioned explicitly in the config
* bond slaves are no longer brought down forcefully, but they're brought
down before being enslaved (and brought up once they're enslaved)
* route sync code ignores flags which are not managed by Talos

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2021-06-16 15:33:19 -07:00
Andrey Smirnov
8b8de11d9f feat: implement new controllers for hostname, resolvers and time servers
This is next part of networkd rewrite.

This implements three new resource types coupled with controllers which
process the default configuration, merges and applying changes.

TimeSync was set up to watch the time servers resource. This is a no-op
for now, but once DHCP is implemented, this would enable time server
configuration coming from DHCP.

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2021-06-05 12:41:14 -07:00
Andrey Smirnov
6e77536392 refactor: rename *.Status() to *.TypedSpec() in the resources
It was a bad choice to name the method which returns resource spec
typecasted to the proper Go type as `Status()`, as certainly `Status`
has a different meaning for resources. So rename the method accordingly
to be `TypedSpec()`.

No functional or user-visbile changes, just renames.

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2021-06-01 12:30:13 -07:00
Andrey Smirnov
5811f4dda1 feat: implement link (interface) controllers
The structure of the controllers is really similar to addresses and
routes:

* `LinkSpec` resource describes desired link state
* `LinkConfig` controller generates `LinkSpecs` based on machine
configuration and kernel cmdline
* `LinkMerge` controller merges multiple configuration sources into a
single `LinkSpec` paying attention to the config layer priority
* `LinkSpec` controller applies the specs to the kernel state

Controller `LinkStatus` (which was implemented before) watches the
kernel state and publishes current link status.

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2021-06-01 09:36:25 -07:00