mirror of
https://github.com/vishvananda/netlink
synced 2025-02-16 12:06:49 +00:00
Add scope parameter to route
This commit is contained in:
parent
0e7e6d493a
commit
950b852cad
13
route.go
13
route.go
@ -3,6 +3,18 @@ package netlink
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// Scope is an enum representing a route scope.
|
||||
type Scope uint8
|
||||
|
||||
const (
|
||||
SCOPE_UNIVERSE Scope = syscall.RT_SCOPE_UNIVERSE
|
||||
SCOPE_SITE Scope = syscall.RT_SCOPE_SITE
|
||||
SCOPE_LINK Scope = syscall.RT_SCOPE_LINK
|
||||
SCOPE_HOST Scope = syscall.RT_SCOPE_HOST
|
||||
SCOPE_NOWHERE Scope = syscall.RT_SCOPE_NOWHERE
|
||||
)
|
||||
|
||||
// Route represents a netlink route. A route is associated with a link,
|
||||
@ -11,6 +23,7 @@ import (
|
||||
// currently not supported.
|
||||
type Route struct {
|
||||
Link *Link
|
||||
Scope Scope
|
||||
Dst *net.IPNet
|
||||
Src net.IP
|
||||
Gw net.IP
|
||||
|
@ -56,6 +56,7 @@ func routeHandle(route *Route, req *NetlinkRequest) error {
|
||||
}
|
||||
|
||||
msg := newRtMsg()
|
||||
msg.Scope = uint8(route.Scope)
|
||||
family := -1
|
||||
var rtAttrs []*RtAttr
|
||||
|
||||
@ -156,7 +157,7 @@ func RouteList(link *Link, family int) ([]Route, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var route Route
|
||||
route := Route{Scope: Scope(msg.Scope)}
|
||||
for _, attr := range attrs {
|
||||
switch attr.Attr.Type {
|
||||
case syscall.RTA_GATEWAY:
|
||||
|
Loading…
Reference in New Issue
Block a user