netlink: move func AddRoute/DelRoute

This commit is contained in:
rkonfj
2024-07-20 09:37:53 +08:00
parent 7f6c78b763
commit 948522a2bb
8 changed files with 57 additions and 56 deletions

View File

@@ -3,6 +3,7 @@ package netlink
import (
"context"
"log/slog"
"net"
"slices"
"github.com/vishvananda/netlink"
@@ -43,3 +44,17 @@ func RouteSubscribe(ctx context.Context, ch chan<- RouteUpdate) error {
}()
return nil
}
func AddRoute(_ string, to *net.IPNet, via net.IP) error {
return netlink.RouteAdd(&netlink.Route{
Dst: to,
Gw: via,
})
}
func DelRoute(_ string, to *net.IPNet, via net.IP) error {
return netlink.RouteDel(&netlink.Route{
Dst: to,
Gw: via,
})
}