Skip to content

Commit a3053a8

Browse files
committed
use default gw ip
1 parent 91847f5 commit a3053a8

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

cns/middlewares/k8sSwiftV2_windows.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import (
1010
"github.com/pkg/errors"
1111
)
1212

13+
const (
14+
defaultGateway = "0.0.0.0"
15+
)
16+
1317
// for AKS L1VH, do not set default route on infraNIC to avoid customer pod reaching all infra vnet services
1418
// default route is set for secondary interface NIC(i.e,delegatedNIC)
1519
func (k *K8sSWIFTv2Middleware) setRoutes(podIPInfo *cns.PodIpInfo) error {
@@ -19,7 +23,7 @@ func (k *K8sSWIFTv2Middleware) setRoutes(podIPInfo *cns.PodIpInfo) error {
1923
// TODO: Remove this once HNS fix is ready
2024
route := cns.Route{
2125
IPAddress: "0.0.0.0/0",
22-
GatewayIPAddress: "0.0.0.0",
26+
GatewayIPAddress: defaultGateway,
2327
}
2428
podIPInfo.Routes = append(podIPInfo.Routes, route)
2529

@@ -69,16 +73,15 @@ func (k *K8sSWIFTv2Middleware) addDefaultRoute(podIPInfo *cns.PodIpInfo, gateway
6973
podIPInfo.Routes = append(podIPInfo.Routes, route)
7074
}
7175

76+
// add routes to podIPInfo for the given CIDRs and gateway IP
77+
// always use default gateway IP for containerd to configure routes;
78+
// containerd will set route with default gateway ip like 10.0.0.0/16 via 0.0.0.0 dev eth0
7279
func (k *K8sSWIFTv2Middleware) addRoutes(cidrs []string) []cns.Route {
7380
routes := make([]cns.Route, len(cidrs))
7481
for i, cidr := range cidrs {
75-
ip, _, err := net.ParseCIDR(cidr)
76-
if err != nil {
77-
return nil
78-
}
7982
routes[i] = cns.Route{
8083
IPAddress: cidr,
81-
GatewayIPAddress: ip.String(),
84+
GatewayIPAddress: defaultGateway,
8285
}
8386
}
8487
return routes

network/endpoint_windows.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -333,18 +333,10 @@ func (nw *network) configureHcnEndpoint(epInfo *EndpointInfo) (*hcn.HostComputeE
333333
}
334334

335335
for _, route := range epInfo.Routes {
336-
nextHop := route.Gw.String()
337-
// If the route is for the frontend NIC, the next hop should be empty.
338-
// This is because the containerd does not require next hop to configure route and the expected route entry on lcow should be like:
339-
// 10.224.0.0/12 dev eth0
340-
if epInfo.NICType == cns.NodeNetworkInterfaceFrontendNIC {
341-
nextHop = ""
342-
}
343336
hcnRoute := hcn.Route{
344-
NextHop: nextHop,
337+
NextHop: route.Gw.String(),
345338
DestinationPrefix: route.Dst.String(),
346339
}
347-
348340
hcnEndpoint.Routes = append(hcnEndpoint.Routes, hcnRoute)
349341
}
350342

0 commit comments

Comments
 (0)