mirror of
https://github.com/vishvananda/netlink
synced 2025-04-01 22:58:37 +00:00
Change route to hold pointers to structs
This commit is contained in:
parent
ec452b3aa1
commit
9f98335fb3
4
route.go
4
route.go
@ -10,8 +10,8 @@ import (
|
||||
// gateway. Advanced route parameters and non-main routing tables are
|
||||
// currently not supported.
|
||||
type Route struct {
|
||||
Link Link
|
||||
Dst net.IPNet
|
||||
Link *Link
|
||||
Dst *net.IPNet
|
||||
Src net.IP
|
||||
Gw net.IP
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ func RouteList(link *Link, family int) ([]Route, error) {
|
||||
case syscall.RTA_PREFSRC:
|
||||
route.Src = net.IP(attr.Value)
|
||||
case syscall.RTA_DST:
|
||||
route.Dst = net.IPNet{
|
||||
route.Dst = &net.IPNet{
|
||||
IP: attr.Value,
|
||||
Mask: net.CIDRMask(int(msg.Dst_len), 8*len(attr.Value)),
|
||||
}
|
||||
@ -175,7 +175,7 @@ func RouteList(link *Link, family int) ([]Route, error) {
|
||||
continue
|
||||
}
|
||||
resLink, _ := LinkByIndex(index)
|
||||
route.Link = *resLink
|
||||
route.Link = resLink
|
||||
}
|
||||
}
|
||||
res = append(res, route)
|
||||
|
@ -24,7 +24,7 @@ func TestRouteAddDel(t *testing.T) {
|
||||
_, dst, err := net.ParseCIDR("192.168.0.0/24")
|
||||
|
||||
ip := net.ParseIP("127.1.1.1")
|
||||
route := Route{Link: *link, Dst: *dst, Src: ip}
|
||||
route := Route{Link: link, Dst: dst, Src: ip}
|
||||
err = RouteAdd(&route)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
Loading…
Reference in New Issue
Block a user