Commit ec93726159 ("Adds strings translation methods") broke non-Linux
builds by relying on unix constants that are only declared on the linux
platform in the upstream x/sys/unix package.
Other platforms report undefined variables, such as the following:
$ GOOS=darwin go build .
# github.com/vishvananda/netlink
./route.go:17:7: undefined: SCOPE_UNIVERSE
./route.go:19:7: undefined: SCOPE_SITE
./route.go:21:7: undefined: SCOPE_LINK
./route.go:23:7: undefined: SCOPE_HOST
./route.go:25:7: undefined: SCOPE_NOWHERE
./route.go:55:7: undefined: unix.RTPROT_BABEL
./route.go:57:7: undefined: unix.RTPROT_BGP
./route.go:59:7: undefined: unix.RTPROT_BIRD
./route.go:61:7: undefined: unix.RTPROT_BOOT
./route.go:63:7: undefined: unix.RTPROT_DHCP
./route.go:63:7: too many errors
Move the platform-specific implementations to platform-specific files
and add stubs to satisfy other platforms.
Fixes: ec93726159 ("Adds strings translation methods")
Signed-off-by: Joe Stringer <joe@cilium.io>
There are lots of route metrics to be added, such as rto_min,
quick_ack and so on, and these metrics are useful for users to
tune network performance, so we add all these metrics.
Signed-off-by: bianze <bianze1993@gmail.com>
This is a `net.IP` and therefore, we should use `%s`. Using `%d` gives
something like this:
Gw: [0 0 0 0 0 0 0 0 0 0 255 255 192 168 24 2]
After this fix, we get:
Gw: 192.168.24.2
$ ip -M route add 100 dev eth0
$ ip -M route add 100 as to 200/300 dev eth0
$ ip -M route add 100 nexthop dev eth0 as to 200 \
nexthop dev eth1 as to 300
$ ip route add 10.10.0.0/24 encap mpls 200/300 dev eth0
$ ip route add 10.0.0.0/24 nexthop encap mpls 200 dev eth0 \
nexthop encap mpls 300 dev eth1
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Having object composition causes both client and library to
do potentially unecessary work to retrieve Link attributes
when only index is often sufficient.