diff --git a/pkg/agent/openflow/network_policy.go b/pkg/agent/openflow/network_policy.go index 9128f19b7be..c2bb9e29d14 100644 --- a/pkg/agent/openflow/network_policy.go +++ b/pkg/agent/openflow/network_policy.go @@ -841,12 +841,12 @@ func (c *clause) addAddrFlows(featureNetworkPolicy *featureNetworkPolicy, addrTy return conjMatchFlowContextChanges } -// addServiceFlows translates the specified NetworkPolicyPorts to conjunctiveMatchFlow, and returns corresponding -// conjMatchFlowContextChange. -func (c *clause) addServiceFlows(featureNetworkPolicy *featureNetworkPolicy, ports []v1beta2.Service, priority *uint16, matchSrc bool) []*conjMatchFlowContextChange { +// addServiceFlows translates the specified Antrea Service to conjunctiveMatchFlow, +// and returns corresponding conjMatchFlowContextChange. +func (c *clause) addServiceFlows(featureNetworkPolicy *featureNetworkPolicy, services []v1beta2.Service, priority *uint16, matchSrc bool) []*conjMatchFlowContextChange { var conjMatchFlowContextChanges []*conjMatchFlowContextChange - for _, port := range ports { - matches := generateServiceConjMatches(c.ruleTable.GetID(), port, priority, featureNetworkPolicy.ipProtocols, matchSrc) + for _, service := range services { + matches := generateServiceConjMatches(c.ruleTable.GetID(), service, priority, featureNetworkPolicy.ipProtocols, matchSrc) for _, match := range matches { ctxChange := c.addConjunctiveMatchFlow(featureNetworkPolicy, match) conjMatchFlowContextChanges = append(conjMatchFlowContextChanges, ctxChange) diff --git a/pkg/controller/networkpolicy/crd_utils.go b/pkg/controller/networkpolicy/crd_utils.go index 09282240c37..5a775708d71 100644 --- a/pkg/controller/networkpolicy/crd_utils.go +++ b/pkg/controller/networkpolicy/crd_utils.go @@ -35,9 +35,10 @@ var ( } ) -// toAntreaServicesForCRD converts a slice of v1alpha1.NetworkPolicyPort -// objects to a slice of Antrea Service objects. A bool is returned along with -// the Service objects to indicate whether any named port exists. +// toAntreaServicesForCRD converts a slice of v1alpha1.NetworkPolicyPort objects +// and a slice of v1alpha1.NetworkPolicyProtocol objects to a slice of Antrea +// Service objects. A bool is returned along with the Service objects to indicate +// whether any named port exists. func toAntreaServicesForCRD(npPorts []v1alpha1.NetworkPolicyPort, npProtocols []v1alpha1.NetworkPolicyProtocol) ([]controlplane.Service, bool) { var antreaServices []controlplane.Service var namedPortExists bool