Bug 1953680

Summary: ipBlock ignoring all other cidr's apart from the last one specified
Product: OpenShift Container Platform Reporter: Andy Bartlett <andbartl>
Component: NetworkingAssignee: Dan Winship <danw>
Networking sub component: ovn-kubernetes QA Contact: huirwang
Status: CLOSED ERRATA Docs Contact:
Severity: high    
Priority: urgent CC: aconstan, astoycos, bbennett, bjarolim, christoph.obexer, danw, huirwang, openshift-bugs-escalate, zzhao
Version: 4.6   
Target Milestone: ---   
Target Release: 4.8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: ovn-kubernetes handled some NetworkPolicies with multiple ipBlocks incorrectly Consequence: The ipBlocks after the first one would be ignored, resulting in pods not being able to reach all of the IPs they were supposed to be able to reach. Fix: Fixed the code for generating OVN ACLs from kubernetes NetworkPolicies Result: Policies with multiple ipBlocks work correctly
Story Points: ---
Clone Of:
: 1967132 (view as bug list) Environment:
Last Closed: 2021-07-27 23:04:01 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1967132    

Description Andy Bartlett 2021-04-26 16:08:20 UTC
Description of problem:

Hi,
 Created from BZ: 1950283

 Speaking to the customer today, they have observed that if you use:

# Source: networkpolicies-config-values/charts/networkpolicies-config/templates/networkpolicies.yaml
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
  name: stex-rd-networkpolicies-config-allow-from-ic
  labels:
    helm.sh/chart: networkpolicies-config-0.1.0
    app.kubernetes.io/name: networkpolicies-config
    app.kubernetes.io/instance: stex-rd
    app.kubernetes.io/version: "1.16.0"
    app.kubernetes.io/managed-by: Helm
spec:
  podSelector:
    matchLabels:
      "nl.duo.networkpolicy.allow-ingress": 'true'
  ingress:
  - from:
    - ipBlock:
        cidr: 10.0.4.2/23
    - ipBlock:
        cidr: 10.1.2.2/23
    - ipBlock:
        cidr: 10.3.2.2/23
  policyTypes:
    - Ingress

In this case the ipBlock only uses the last cidr specified (cidr: 10.3.2.2/23) , so to get round this:

# Source: networkpolicies-config-values/charts/networkpolicies-config/templates/networkpolicies.yaml
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
  name: stex-rd-networkpolicies-config-allow-from-ic
  labels:
    helm.sh/chart: networkpolicies-config-0.1.0
    app.kubernetes.io/name: networkpolicies-config
    app.kubernetes.io/instance: stex-rd
    app.kubernetes.io/version: "1.16.0"
    app.kubernetes.io/managed-by: Helm
spec:
  podSelector:
    matchLabels:
      "nl.duo.networkpolicy.allow-ingress": 'true'
  ingress:
  - from:
    - ipBlock:
        cidr: 10.0.4.2/23
  - from:
    - ipBlock:
        cidr: 10.1.2.2/23
  - from:
    - ipBlock:
        cidr: 10.3.2.2/23
  policyTypes:
    - Ingress


Version-Release number of selected component (if applicable):


How reproducible:

100%

Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 Ben Bennett 2021-04-26 16:14:10 UTC
This will need to be backported to 4.6.

Comment 9 errata-xmlrpc 2021-07-27 23:04:01 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: OpenShift Container Platform 4.8.2 bug fix and security update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2021:2438