mirror of
https://github.com/siderolabs/talos.git
synced 2025-08-22 07:01:12 +02:00
feat(initramfs): Add kernel arg for default interface
Should allow us to handle edge cases where eth0 is not the primary interface Signed-off-by: Brad Beam <brad.beam@talos-systems.com>
This commit is contained in:
parent
8d9dde97fa
commit
c194621e56
@ -39,7 +39,7 @@ func (svc *Service) Main(ctx context.Context, data *userdata.UserData, logWriter
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
svc.DHCPd(ctx, DefaultInterface)
|
||||
svc.DHCPd(ctx, defaultInterface())
|
||||
}()
|
||||
} else {
|
||||
for _, netconf := range data.Networking.OS.Devices {
|
||||
|
@ -10,6 +10,8 @@ import (
|
||||
"syscall"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/talos-systems/talos/internal/pkg/constants"
|
||||
"github.com/talos-systems/talos/internal/pkg/kernel"
|
||||
"github.com/talos-systems/talos/pkg/userdata"
|
||||
"github.com/vishvananda/netlink"
|
||||
)
|
||||
@ -75,12 +77,12 @@ func defaultNetworkSetup() (err error) {
|
||||
if err = StaticAddress(userdata.Device{Interface: "lo", CIDR: "127.0.0.1/8"}); err != nil && err != syscall.EEXIST {
|
||||
return err
|
||||
}
|
||||
if err = ifup(DefaultInterface); err != nil {
|
||||
|
||||
if err = ifup(defaultInterface()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO: this calls out to 'networkd' inline
|
||||
if _, err = NewService().Dhclient(context.Background(), DefaultInterface); err != nil {
|
||||
if _, err = NewService().Dhclient(context.Background(), defaultInterface()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -109,3 +111,12 @@ func ifup(ifname string) (err error) {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func defaultInterface() string {
|
||||
netif := DefaultInterface
|
||||
if option := kernel.Cmdline().Get(constants.KernelParamDefaultInterface).First(); option != nil {
|
||||
netif = *option
|
||||
}
|
||||
|
||||
return netif
|
||||
}
|
||||
|
@ -26,6 +26,10 @@ const (
|
||||
// hostname.
|
||||
KernelParamHostname = "talos.hostname"
|
||||
|
||||
// KernelParamDefaultInterface is the kernel parameter for specifying the
|
||||
// initial interface used to bootstrap the node
|
||||
KernelParamDefaultInterface = "talos.interface"
|
||||
|
||||
// KernelCurrentRoot is the kernel parameter name for specifying the
|
||||
// current root partition.
|
||||
KernelCurrentRoot = "talos.root"
|
||||
|
Loading…
x
Reference in New Issue
Block a user