Skip to content

Commit

Permalink
Simplify network interface matching
Browse files Browse the repository at this point in the history
systemd-networkd can match wired interfaces based on Type=ether; let's
switch to that to simplify the interface matching.

Signed-off-by: Christopher Obbard <[email protected]>
  • Loading branch information
obbardc authored and sjoerdsimons committed Dec 29, 2023
1 parent bb815e6 commit f678bc3
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 13 deletions.
3 changes: 0 additions & 3 deletions backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ type backend interface {
// A list of udev rules
UdevRules() []string

// The match expression used for the networkd configuration
NetworkdMatch() string

// The tty used for the job output
JobOutputTTY() string

Expand Down
4 changes: 0 additions & 4 deletions backend_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,6 @@ func (b qemuBackend) UdevRules() []string {
return udevRules
}

func (b qemuBackend) NetworkdMatch() string {
return "e*"
}

func (b qemuBackend) JobOutputTTY() string {
// By default we send job output to the second virtio console,
// reserving /dev/ttyS0 for boot messages (which we ignore)
Expand Down
4 changes: 0 additions & 4 deletions backend_uml.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ func (b umlBackend) UdevRules() []string {
return udevRules
}

func (b umlBackend) NetworkdMatch() string {
return "vec*"
}

func (b umlBackend) JobOutputTTY() string {
// Send the fakemachine job output to the right console
if b.machine.showBoot {
Expand Down
4 changes: 2 additions & 2 deletions machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ exec /lib/systemd/systemd
`
const networkdTemplate = `
[Match]
Name=%[1]s
Type=ether
[Network]
DHCP=ipv4
Expand Down Expand Up @@ -808,7 +808,7 @@ func (m *Machine) startup(command string, extracontent [][2]string) (int, error)
}

err = w.WriteFile("/etc/systemd/network/ethernet.network",
fmt.Sprintf(networkdTemplate, backend.NetworkdMatch()), 0444)
networkdTemplate, 0444)
if err != nil {
return -1, err
}
Expand Down

0 comments on commit f678bc3

Please sign in to comment.