From 69b6bceec76caea07f95ba5cc372205c16e0e11b Mon Sep 17 00:00:00 2001 From: Kuralamudhan Ramakrishnan Date: Sun, 9 Aug 2020 21:38:57 -0700 Subject: adding gwipaddress features in network annotation - check defautgateway is true only for one network - first network with defautgateway is only configured, rest is ignored - add node network and ovn4nfv0-* route info for eth0 interface Signed-off-by: Kuralamudhan Ramakrishnan Change-Id: I078dee22627b2fa92e34b6cc4fa2ec7c8cd58220 --- internal/pkg/network/iface.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'internal/pkg/network') diff --git a/internal/pkg/network/iface.go b/internal/pkg/network/iface.go index b2a57bd..d49566d 100644 --- a/internal/pkg/network/iface.go +++ b/internal/pkg/network/iface.go @@ -27,6 +27,24 @@ func GetDefaultGateway() (string, error) { return "", errors.New("Unable to find default route") } +//CheckRoute return bool isPresent +func CheckRoute(dst, gw string) (bool, error) { + var isPresent bool + routes, err := netlink.RouteList(nil, syscall.AF_INET) + if err != nil { + return isPresent, err + } + + for _, route := range routes { + if route.Dst.String() == dst && route.Gw.To4().String() == gw { + isPresent = true + } + } + + return isPresent, nil + +} + // GetDefaultGatewayInterface return default gateway interface link func GetDefaultGatewayInterface() (*net.Interface, error) { routes, err := netlink.RouteList(nil, syscall.AF_INET) -- cgit 1.2.3-korg