diff --git a/hcn/hcn.go b/hcn/hcn.go index eefd88d856..a59202409d 100644 --- a/hcn/hcn.go +++ b/hcn/hcn.go @@ -264,6 +264,18 @@ func SetPolicySupported() error { return platformDoesNotSupportError("SetPolicy") } +// ModifyLoadbalancerSupported returns an error if the HCN version does not support ModifyLoadbalancer. +func ModifyLoadbalancerSupported() error { + supported, err := GetCachedSupportedFeatures() + if err != nil { + return err + } + if supported.ModifyLoadbalancer { + return nil + } + return platformDoesNotSupportError("ModifyLoadbalancer") +} + // VxlanPortSupported returns an error if the HCN version does not support configuring the VXLAN TCP port. func VxlanPortSupported() error { supported, err := GetCachedSupportedFeatures() diff --git a/hcn/hcnerrors.go b/hcn/hcnerrors.go index ad30d320d9..3306a82366 100644 --- a/hcn/hcnerrors.go +++ b/hcn/hcnerrors.go @@ -10,6 +10,7 @@ import ( "github.com/Microsoft/hcsshim/internal/hcserror" "github.com/Microsoft/hcsshim/internal/interop" "github.com/sirupsen/logrus" + "golang.org/x/sys/windows" ) var ( @@ -48,8 +49,9 @@ type ErrorCode uint32 // For common errors, define the error as it is in windows, so we can quickly determine it later const ( - ERROR_NOT_FOUND = 0x490 - HCN_E_PORT_ALREADY_EXISTS ErrorCode = 0x803b0013 + ERROR_NOT_FOUND = ErrorCode(windows.ERROR_NOT_FOUND) + HCN_E_PORT_ALREADY_EXISTS ErrorCode = ErrorCode(windows.HCN_E_PORT_ALREADY_EXISTS) + HCN_E_NOTIMPL ErrorCode = ErrorCode(windows.E_NOTIMPL) ) type HcnError struct { @@ -77,6 +79,10 @@ func IsPortAlreadyExistsError(err error) bool { return CheckErrorWithCode(err, HCN_E_PORT_ALREADY_EXISTS) } +func IsNotImplemented(err error) bool { + return CheckErrorWithCode(err, HCN_E_NOTIMPL) +} + func new(hr error, title string, rest string) error { err := &HcnError{} hcsError := hcserror.New(hr, title, rest) diff --git a/hcn/hcnglobals.go b/hcn/hcnglobals.go index d03c48736d..ac9f6ad68e 100644 --- a/hcn/hcnglobals.go +++ b/hcn/hcnglobals.go @@ -76,6 +76,17 @@ var ( //HNS 14.0 allows for TierAcl Policy support TierAclPolicyVersion = VersionRanges{VersionRange{MinVersion: Version{Major: 14, Minor: 0}, MaxVersion: Version{Major: math.MaxInt32, Minor: math.MaxInt32}}} + + //HNS 15.0 allows for NetworkACL Policy support + NetworkACLPolicyVersion = VersionRanges{VersionRange{MinVersion: Version{Major: 15, Minor: 0}, MaxVersion: Version{Major: math.MaxInt32, Minor: math.MaxInt32}}} + + //HNS 15.0 allows for NestedIpSet support + NestedIpSetVersion = VersionRanges{VersionRange{MinVersion: Version{Major: 15, Minor: 0}, MaxVersion: Version{Major: math.MaxInt32, Minor: math.MaxInt32}}} + + //HNS 15.1 allows support for DisableHostPort flag. + DisableHostPortVersion = VersionRanges{VersionRange{MinVersion: Version{Major: 15, Minor: 1}, MaxVersion: Version{Major: math.MaxInt32, Minor: math.MaxInt32}}} + // HNS 15.4 allows for Modify Loadbalancer support + ModifyLoadbalancerVersion = VersionRanges{VersionRange{MinVersion: Version{Major: 15, Minor: 4}, MaxVersion: Version{Major: math.MaxInt32, Minor: math.MaxInt32}}} ) // GetGlobals returns the global properties of the HCN Service. diff --git a/hcn/hcnsupport.go b/hcn/hcnsupport.go index 64f9e3728b..c34d89dbec 100644 --- a/hcn/hcnsupport.go +++ b/hcn/hcnsupport.go @@ -32,6 +32,10 @@ type SupportedFeatures struct { L4Proxy bool `json:"L4Proxy"` // network policy that applies VFP rules to all endpoints on the network to redirect traffic L4WfpProxy bool `json:"L4WfpProxy"` // endpoint policy that applies WFP filters to redirect traffic to/from that endpoint TierAcl bool `json:"TierAcl"` + NetworkACL bool `json:"NetworkACL"` + NestedIpSet bool `json:"NestedIpSet"` + DisableHostPort bool `json:"DisableHostPort"` + ModifyLoadbalancer bool `json:"ModifyLoadbalancer"` } // AclFeatures are the supported ACL possibilities. @@ -107,6 +111,10 @@ func getSupportedFeatures() (SupportedFeatures, error) { features.L4Proxy = isFeatureSupported(globals.Version, L4ProxyPolicyVersion) features.L4WfpProxy = isFeatureSupported(globals.Version, L4WfpProxyPolicyVersion) features.TierAcl = isFeatureSupported(globals.Version, TierAclPolicyVersion) + features.NetworkACL = isFeatureSupported(globals.Version, NetworkACLPolicyVersion) + features.NestedIpSet = isFeatureSupported(globals.Version, NestedIpSetVersion) + features.DisableHostPort = isFeatureSupported(globals.Version, DisableHostPortVersion) + features.ModifyLoadbalancer = isFeatureSupported(globals.Version, ModifyLoadbalancerVersion) logrus.WithFields(logrus.Fields{ "version": fmt.Sprintf("%+v", globals.Version),