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)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
svc.DHCPd(ctx, DefaultInterface)
|
svc.DHCPd(ctx, defaultInterface())
|
||||||
}()
|
}()
|
||||||
} else {
|
} else {
|
||||||
for _, netconf := range data.Networking.OS.Devices {
|
for _, netconf := range data.Networking.OS.Devices {
|
||||||
|
@ -10,6 +10,8 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"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/talos-systems/talos/pkg/userdata"
|
||||||
"github.com/vishvananda/netlink"
|
"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 {
|
if err = StaticAddress(userdata.Device{Interface: "lo", CIDR: "127.0.0.1/8"}); err != nil && err != syscall.EEXIST {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err = ifup(DefaultInterface); err != nil {
|
|
||||||
|
if err = ifup(defaultInterface()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this calls out to 'networkd' inline
|
// 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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,3 +111,12 @@ func ifup(ifname string) (err error) {
|
|||||||
|
|
||||||
return nil
|
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.
|
// hostname.
|
||||||
KernelParamHostname = "talos.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
|
// KernelCurrentRoot is the kernel parameter name for specifying the
|
||||||
// current root partition.
|
// current root partition.
|
||||||
KernelCurrentRoot = "talos.root"
|
KernelCurrentRoot = "talos.root"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user