Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
paulyufan2 committed Jan 22, 2025
1 parent 8e94fc6 commit 91847f5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
6 changes: 3 additions & 3 deletions cni/network/invoker_cns.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,9 @@ func getRoutes(cnsRoutes []cns.Route, skipDefaultRoutes bool) ([]network.RouteIn
}

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

routes = append(routes,
network.RouteInfo{
Expand Down
7 changes: 6 additions & 1 deletion cns/middlewares/k8sSwiftV2_windows.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package middlewares

import (
"net"
"net/netip"

"github.com/Azure/azure-container-networking/cns"
Expand Down Expand Up @@ -71,9 +72,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 nil
}
routes[i] = cns.Route{
IPAddress: cidr,
GatewayIPAddress: "", // gateway IP is not required for infraNIC
GatewayIPAddress: ip.String(),
}
}
return routes
Expand Down
9 changes: 8 additions & 1 deletion network/endpoint_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,15 @@ func (nw *network) configureHcnEndpoint(epInfo *EndpointInfo) (*hcn.HostComputeE
}

for _, route := range epInfo.Routes {
nextHop := route.Gw.String()
// If the route is for the frontend NIC, the next hop should be empty.
// This is because the containerd does not require next hop to configure route and the expected route entry on lcow should be like:
// 10.224.0.0/12 dev eth0
if epInfo.NICType == cns.NodeNetworkInterfaceFrontendNIC {
nextHop = ""
}
hcnRoute := hcn.Route{
NextHop: route.Gw.String(),
NextHop: nextHop,
DestinationPrefix: route.Dst.String(),
}

Expand Down

0 comments on commit 91847f5

Please sign in to comment.