Change route to hold pointers to structs

This commit is contained in:
Vishvananda Ishaya 2014-09-07 11:19:59 -07:00
parent ec452b3aa1
commit 9f98335fb3
3 changed files with 5 additions and 5 deletions

View File

@ -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
}

View File

@ -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)

View File

@ -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)