diff options
author | Kuralamudhan Ramakrishnan <kuralamudhan.ramakrishnan@intel.com> | 2020-08-09 21:38:57 -0700 |
---|---|---|
committer | Kuralamudhan Ramakrishnan <kuralamudhan.ramakrishnan@intel.com> | 2020-09-17 17:10:02 -0700 |
commit | 69b6bceec76caea07f95ba5cc372205c16e0e11b (patch) | |
tree | 06cbf79c6b62e934e68ddd62b07c727313ed4c39 /internal/pkg/network/iface.go | |
parent | c99d1522d6a52765cb8bb664149c705e33911f7d (diff) |
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 <kuralamudhan.ramakrishnan@intel.com>
Change-Id: I078dee22627b2fa92e34b6cc4fa2ec7c8cd58220
Diffstat (limited to 'internal/pkg/network/iface.go')
-rw-r--r-- | internal/pkg/network/iface.go | 18 |
1 files changed, 18 insertions, 0 deletions
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) |