func()

in plugins/eni/engine/engine.go [225:248]


func (engine *engine) getIPV6GatewayIPFromRoutesOnce(link netlink.Link, deviceName string) (string, bool, error) {
	routes, err := engine.netLink.RouteList(link, netlink.FAMILY_V6)
	if err != nil {
		return "", false, errors.Wrapf(err,
			"getIPV6Gateway engine: unable to get ipv6 routes for device '%s'", deviceName)
	}

	for _, route := range routes {
		// Search for "default" route. A "default" route has no source and
		// destination ip addresses, but has the gateway set to a non-emtpty string
		if route.Dst != nil {
			continue
		}

		if (route.Dst == nil || route.Dst.String() == zeroLengthIPString) && // Dst is not set
			route.Src.String() == zeroLengthIPString && // Src is not set
			route.Gw.String() != zeroLengthIPString { // Gw is set
			log.Debugf("Found ipv6 gateway (device=%s): %s", deviceName, route.Gw.String())
			return route.Gw.String(), true, nil
		}
	}

	return "", false, nil
}