Skip to content

Conversation

@huntergregory
Copy link
Contributor

iptables comments will allow us to debug/understand which policies and what ACL rules are which within iptables. For an overview of what the comments will look like, see the description in iptables-comments_linux.go.

This PR also updates the validation check for port/protocol constraints in policy.go so that ACLs with a namedport are required to have UnspecifiedProtocol

@huntergregory huntergregory added the npm Related to NPM. label Dec 8, 2021
*/

func (networkPolicy *NPMNetworkPolicy) commentForJumpToIngress() string {
return networkPolicy.commentForJump(true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you change true/false to constant types for ingressJump or egressJump, that was it will be easier to read ?

return fmt.Sprintf("-ON-%s", string(proto))
}

func (portRange *Ports) comment() string {
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of having these .comment() functions for all in this file, can we place these near their type declarations? that will be cleaner in my opinion ? No strong opinion though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should leave as is since comments are only used in Linux, and we don't have a policies_linux.go file

Copy link
Collaborator

Choose a reason for hiding this comment

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

@vakalapa is correct, methods should be defined next to their receivers
the farther a declaration is from the usage, the harder it is to grok

Copy link
Contributor Author

Choose a reason for hiding this comment

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

edit: we do have a policies_linux.go file. Might make sense to compile iptables code into one file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as discussed offline, moving these Linux-specific codes to policy_linux.go

vakalapa
vakalapa previously approved these changes Dec 13, 2021
@huntergregory huntergregory merged commit bbfdef3 into master Dec 15, 2021
@huntergregory huntergregory deleted the iptables-comments branch December 15, 2021 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

npm Related to NPM.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants