-
Notifications
You must be signed in to change notification settings - Fork 260
[NPM Lite] Bypassing IPSets for IP CIDR Block Based Network Policies #4107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
3179b1f
c32653b
0f96f04
af8d266
48168b1
ce8cb5a
351d8fb
55ec65e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -362,6 +362,55 @@ | |||||||
| return nil | ||||||||
| } | ||||||||
|
|
||||||||
| func directPeerAndPortRule(npmNetPol *policies.NPMNetworkPolicy, direction policies.Direction, ports []networkingv1.NetworkPolicyPort, cidr string, npmLiteToggle bool) error { | ||||||||
| if len(ports) == 0 { | ||||||||
| acl := policies.NewACLPolicy(policies.Allowed, direction) | ||||||||
| // bypasses ipset creation for /32 cidrs and directly creates an acl with the cidr | ||||||||
| if direction == policies.Ingress { | ||||||||
| acl.SrcDirectIPs = []string{cidr} | ||||||||
| } else { | ||||||||
| acl.DstDirectIPs = []string{cidr} | ||||||||
| } | ||||||||
| npmNetPol.ACLs = append(npmNetPol.ACLs, acl) | ||||||||
| return nil | ||||||||
| } else { | ||||||||
|
Check failure on line 376 in npm/pkg/controlplane/translation/translatePolicy.go
|
||||||||
| // handle each port separately | ||||||||
| for i := range ports { | ||||||||
| portKind, err := portType(ports[i]) | ||||||||
| if err != nil { | ||||||||
| return err | ||||||||
| } | ||||||||
|
|
||||||||
| err = checkForNamedPortType(portKind, npmLiteToggle) | ||||||||
| if err != nil { | ||||||||
| return err | ||||||||
| } | ||||||||
|
|
||||||||
| acl := policies.NewACLPolicy(policies.Allowed, direction) | ||||||||
|
|
||||||||
| // Set direct IP based on direction | ||||||||
| if direction == policies.Ingress { | ||||||||
| acl.SrcDirectIPs = []string{cidr} | ||||||||
| } else { | ||||||||
| acl.DstDirectIPs = []string{cidr} | ||||||||
| } | ||||||||
|
|
||||||||
| // Handle ports | ||||||||
| if portKind == namedPortType { | ||||||||
| return ErrUnsupportedNamedPort | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would also wrap this with some additional context from the |
||||||||
| } | ||||||||
|
Comment on lines
+399
to
+401
|
||||||||
| if portKind == namedPortType { | |
| return ErrUnsupportedNamedPort | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+ error wrapping here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably include
Allowsomewhere in this func to be extra explicit