-
-
Notifications
You must be signed in to change notification settings - Fork 343
Closed
Milestone
Description
We are currently calling the ip
command for configuring addresses, routes and neighbour objects.
This is unnecessary additional overhead and requires parsing the output in some cases, like here:
incus/internal/server/ip/neigh.go
Lines 61 to 87 in faa4880
for _, line := range util.SplitNTrimSpace(out, "\n", -1, true) { | |
// Split fields and early validation. | |
fields := strings.Fields(line) | |
if len(fields) != 4 { | |
continue | |
} | |
addr := net.ParseIP(fields[0]) | |
if addr == nil { | |
continue | |
} | |
mac, _ := net.ParseMAC(fields[2]) | |
// Check neighbour matches desired MAC address if specified. | |
if n.MAC != nil { | |
if !bytes.Equal(n.MAC, mac) { | |
continue | |
} | |
} | |
neighbours = append(neighbours, Neigh{ | |
Addr: addr, | |
MAC: mac, | |
State: NeighbourIPState(fields[3]), | |
}) | |
} |
By using netlink directly we can avoid that.
We already have a dependency on github.com/vishvananda/netlink, so we could use that without adding any extra dependencies.
If there is interest in this I will make a PR.
Metadata
Metadata
Assignees
Labels
No labels