Skip to content
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

Add methods in pkg/agent/route for NodeNetworkPolicy #5692

Conversation

hongliangl
Copy link
Contributor

@hongliangl hongliangl commented Nov 10, 2023

Add the following methods for NodeNetworkPolicy to sync iptables and ipsets:

  • AddOrUpdateNodeNetworkPolicyIPSet
  • DeleteNodeNetworkPolicyIPSet
  • AddOrUpdateNodeNetworkPolicyIPTables
  • DeleteNodeNetworkPolicyIPTables

Signed-off-by: Hongliang Liu [email protected]

@hongliangl hongliangl force-pushed the 20231110_interfaces_for_nnp_in_pkg_agent_route branch from eeeb30f to 1d39a4e Compare November 10, 2023 07:44
@hongliangl hongliangl force-pushed the 20231110_interfaces_for_nnp_in_pkg_agent_route branch 2 times, most recently from a84569a to f89cec0 Compare November 10, 2023 08:42
Add the following methods for NodeNetworkPolicy to
sync iptables and ipsets:

- AddOrUpdateNodeNetworkPolicyIPSet
- DeleteNodeNetworkPolicyIPSet
- AddOrUpdateNodeNetworkPolicyIPTables
- DeleteNodeNetworkPolicyIPTables

Signed-off-by: Hongliang Liu <[email protected]>
@hongliangl hongliangl force-pushed the 20231110_interfaces_for_nnp_in_pkg_agent_route branch from f89cec0 to 55cad45 Compare November 13, 2023 01:57
@@ -90,4 +92,16 @@ type Interface interface {

// ClearConntrackEntryForService deletes a conntrack entry for a Service connection.
ClearConntrackEntryForService(svcIP net.IP, svcPort uint16, endpointIP net.IP, protocol binding.Protocol) error

// AddOrUpdateNodeNetworkPolicyIPSet adds or updates ipset created for NodeNetworkPolicy.
AddOrUpdateNodeNetworkPolicyIPSet(ipsetName string, prevIPSetEntries, curIPSetEntries sets.Set[string], isIPv6 bool) error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need "NodeNetworkPolicy" in the methods' name? I feel it's better to name it as a general one if the function has not to be bound with NodeNetworkPolicy.

Comment on lines +1804 to +1808
if tt.isIPv6 {
_, exists = c.nodeNetworkPolicyIPSetsIPv6.Load(tt.ipsetName)
} else {
_, exists = c.nodeNetworkPolicyIPSetsIPv4.Load(tt.ipsetName)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add an internal function to reduce the code duplication.

Comment on lines +1893 to +1897
if tt.isIPv6 {
_, exists = c.nodeNetworkPolicyIPTablesIPv6.Load(chain)
} else {
_, exists = c.nodeNetworkPolicyIPTablesIPv4.Load(chain)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@hongliangl hongliangl closed this Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants