Skip to content

Commit d4b2c5d

Browse files
committed
ddress comment
1 parent 261b16c commit d4b2c5d

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

cns/hnsclient/hnsclient_windows.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/pkg/errors"
1818
)
1919

20+
// TODO redesign hnsclient on windows
2021
const (
2122
// Name of the external hns network
2223
ExtHnsNetworkName = "ext"
@@ -53,9 +54,9 @@ const (
5354
// Name of the loopback adapter needed to create Host NC apipa network
5455
hostNCLoopbackAdapterName = "LoopbackAdapterHostNCConnectivity"
5556

57+
// HNS rehydration issue requires this GW to be different than the loopback adapter ip, so we set it to .2
5658
defaultHnsGwIPAddress = "169.254.128.2"
5759
hnsLoopbackAdapterIPAddress = "169.254.128.1"
58-
apipaRemoteIPAddress = "169.254.128.1"
5960
// protocolTCP indicates the TCP protocol identifier in HCN
6061
protocolTCP = "6"
6162

@@ -513,7 +514,7 @@ func configureHostNCApipaEndpoint(
513514
endpointPolicies, err := configureAclSettingHostNCApipaEndpoint(
514515
protocolList,
515516
networkContainerApipaIP,
516-
apipaRemoteIPAddress,
517+
hnsLoopbackAdapterIPAddress,
517518
allowNCToHostCommunication,
518519
allowHostToNCCommunication,
519520
ncPolicies)
@@ -576,7 +577,7 @@ func CreateHostNCApipaEndpoint(
576577
return endpoint.Id, nil
577578
}
578579

579-
adjustIPConfig(&localIPConfiguration)
580+
updateGwForLocalIPConfiguration(&localIPConfiguration)
580581
if network, err = createHostNCApipaNetwork(localIPConfiguration); err != nil {
581582
logger.Errorf("[Azure CNS] Failed to create HostNCApipaNetwork. Error: %v", err)
582583
return "", err
@@ -608,10 +609,10 @@ func CreateHostNCApipaEndpoint(
608609
return endpoint.Id, nil
609610
}
610611

611-
// adjustIPConfig applies change on gw IP address.
612+
// updateGwForLocalIPConfiguration applies change on APIPA NW gw IP address.
612613
// Currently, cns using the same ip address "169.254.128.1" for both apipa gw and loopback adapter. This cause conflict issue when hns get restarted and not able to rehydrate the apipa endpoints.
613614
// This func is to overwrite the address to 169.254.128.2 when the gateway address is 169.254.128.1
614-
func adjustIPConfig(localIPConfiguration *cns.IPConfiguration) {
615+
func updateGwForLocalIPConfiguration(localIPConfiguration *cns.IPConfiguration) {
615616
// When gw address is 169.254.128.1, should use .2 instead. If gw address is not .1, that mean this value is
616617
// configured from dnc, we should keep it
617618
if localIPConfiguration.GatewayIPAddress == "169.254.128.1" {

cns/hnsclient/hnsclient_windows_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestAdhocAdjustIPConfig(t *testing.T) {
2828
for _, tt := range tests {
2929
tt := tt
3030
t.Run(tt.name, func(t *testing.T) {
31-
adjustIPConfig(&tt.ipConfig)
31+
updateGwForLocalIPConfiguration(&tt.ipConfig)
3232
assert.Equal(t, tt.expected.GatewayIPAddress, tt.ipConfig.GatewayIPAddress)
3333
})
3434
}

0 commit comments

Comments
 (0)