Skip to content

Commit 500698f

Browse files
committed
add unchanged gw
1 parent d1c2ae3 commit 500698f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

cni/network/invoker_cns.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ func getRoutes(cnsRoutes []cns.Route, skipDefaultRoutes bool) ([]network.RouteIn
362362
}
363363

364364
gw := net.ParseIP(route.GatewayIPAddress)
365-
if skipDefaultRoutes {
365+
if gw == nil && skipDefaultRoutes {
366366
return nil, errors.Wrap(errInvalidGatewayIP, route.GatewayIPAddress)
367367
}
368368

cns/middlewares/k8sSwiftV2_windows.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,13 @@ func (k *K8sSWIFTv2Middleware) addDefaultRoute(podIPInfo *cns.PodIpInfo, gateway
7171
func (k *K8sSWIFTv2Middleware) addRoutes(cidrs []string) []cns.Route {
7272
routes := make([]cns.Route, len(cidrs))
7373
for i, cidr := range cidrs {
74+
ip, _, err := net.ParseCIDR(cidr)
75+
if err != nil {
76+
return "", errors.Wrap(err, "failed to parse cidr")
77+
}
7478
routes[i] = cns.Route{
7579
IPAddress: cidr,
76-
GatewayIPAddress: "", // gateway IP is not required for infraNIC routes
80+
GatewayIPAddress: ip.String(),
7781
}
7882
}
7983
return routes

0 commit comments

Comments
 (0)