Skip to content

Commit

Permalink
add prefix length from mtpnc to podipinfo & gatewayip
Browse files Browse the repository at this point in the history
  • Loading branch information
kmurudi committed Jul 3, 2024
1 parent 368193c commit 70e9f8c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion cns/middlewares/k8sSwiftV2.go
Original file line number Diff line number Diff line change
@@ -182,6 +182,11 @@ func (k *K8sSWIFTv2Middleware) getIPConfig(ctx context.Context, podInfo cns.PodI
if prefixSize != prefixLength {
return nil, errors.Wrapf(errInvalidMTPNCPrefixLength, "mtpnc primaryIP prefix length is %d", prefixSize)
}
// Parse MTPNC SubnetAddressSpace to get the subnet prefix length
subnet, subnetPrefix, err := utils.ParseIPAndPrefix(interfaceInfo.PrimaryIP)
if err != nil {
return nil, errors.Wrap(err, "failed to parse mtpnc subnetAddressSpace prefix")
}

var nicType cns.NICType
switch {
@@ -204,7 +209,16 @@ func (k *K8sSWIFTv2Middleware) getIPConfig(ctx context.Context, podInfo cns.PodI
NICType: nicType,
SkipDefaultRoutes: false,
HostPrimaryIPInfo: cns.HostIPInfo{
Gateway: interfaceInfo.GatewayIP,
Gateway: interfaceInfo.GatewayIP,
PrimaryIP: ip,
Subnet: interfaceInfo.SubnetAddressSpace,
},
NetworkContainerPrimaryIPConfig: cns.IPConfiguration{
IPSubnet: cns.IPSubnet{
IPAddress: subnet,
PrefixLength: uint8(subnetPrefix),
},
GatewayIPAddress: interfaceInfo.GatewayIP,
},
}
}

0 comments on commit 70e9f8c

Please sign in to comment.