Skip to content

Commit

Permalink
add unchanged gw
Browse files Browse the repository at this point in the history
  • Loading branch information
paulyufan2 committed Jan 22, 2025
1 parent d1c2ae3 commit 500698f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cni/network/invoker_cns.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ func getRoutes(cnsRoutes []cns.Route, skipDefaultRoutes bool) ([]network.RouteIn
}

gw := net.ParseIP(route.GatewayIPAddress)
if skipDefaultRoutes {
if gw == nil && skipDefaultRoutes {
return nil, errors.Wrap(errInvalidGatewayIP, route.GatewayIPAddress)
}

Expand Down
6 changes: 5 additions & 1 deletion cns/middlewares/k8sSwiftV2_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,13 @@ func (k *K8sSWIFTv2Middleware) addDefaultRoute(podIPInfo *cns.PodIpInfo, gateway
func (k *K8sSWIFTv2Middleware) addRoutes(cidrs []string) []cns.Route {
routes := make([]cns.Route, len(cidrs))
for i, cidr := range cidrs {
ip, _, err := net.ParseCIDR(cidr)
if err != nil {
return "", errors.Wrap(err, "failed to parse cidr")
}
routes[i] = cns.Route{
IPAddress: cidr,
GatewayIPAddress: "", // gateway IP is not required for infraNIC routes
GatewayIPAddress: ip.String(),
}
}
return routes
Expand Down

0 comments on commit 500698f

Please sign in to comment.