Skip to content

Comments

Support EndPort field#75

Merged
zeeke merged 5 commits intok8snetworkplumbingwg:masterfrom
zeeke:us/end-port
Apr 28, 2025
Merged

Support EndPort field#75
zeeke merged 5 commits intok8snetworkplumbingwg:masterfrom
zeeke:us/end-port

Conversation

@zeeke
Copy link
Member

@zeeke zeeke commented Apr 18, 2025

MultiNetworkPolicy API v1.0.1 supports EndPort fields in rules.

This PR elaborates on @nkinkade's work

To support such fields in the iptables implementation

cc @nkinkade, @dougbtv , @s1061123

zeeke and others added 5 commits April 18, 2025 15:15
Bumped dependency with commands:
```
$ go get github.com/k8snetworkplumbingwg/multi-networkpolicy@v1.0.1
go: downloading github.com/k8snetworkplumbingwg/multi-networkpolicy v1.0.1
go: downloading k8s.io/code-generator v0.28.8
go: downloading k8s.io/gengo v0.0.0-20220902162205-c0856e24416d
go: downloading k8s.io/klog v1.0.0
go: downloading golang.org/x/tools v0.16.1
go: downloading golang.org/x/mod v0.14.0
go: upgraded github.com/k8snetworkplumbingwg/multi-networkpolicy v0.0.0-20200903074708-7b3ce95ae804 => v1.0.1
$ go mod tidy
$ go mod vendor
```

Signed-off-by: Andrea Panattoni <apanatto@redhat.com>
This commit simply adds a small conditional checking whether port.EndPort is
not nil, in which case it writes the iptable rule with flag `--dport N:N`, else
it write the same iptables rule as before.
Verfies that a port specification which includes endPort writes the expected
iptables rule with `--dport N:N`, and that one that doesn't include endPort
writes the normal iptables rule with `--dport N`.
This was an oversight on my part, as our use case only requires ingress rules,
but the functionality needs to be available for both ingress and egress rules.

Additionally, I reformated the logic, per PR reviewer suggestions, to eliminate
some redudnacy and make the code cleaner and more readable.
@coveralls
Copy link

Pull Request Test Coverage Report for Build 14535937923

Details

  • 7 of 7 (100.0%) changed or added relevant lines in 1 file are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.004%) to 58.208%

Files with Coverage Reduction New Missed Lines %
pkg/server/server.go 2 26.54%
Totals Coverage Status
Change from base Build 13654733914: 0.004%
Covered Lines: 1124
Relevant Lines: 1931

💛 - Coveralls

Copy link
Member

@dougbtv dougbtv left a comment

Choose a reason for hiding this comment

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

LGTM!

@zeeke zeeke merged commit 42bf16c into k8snetworkplumbingwg:master Apr 28, 2025
10 checks passed
zeeke added a commit to zeeke/multi-networkpolicy-iptables that referenced this pull request Apr 28, 2025
Add end2end test cases for
- k8snetworkplumbingwg#75

Signed-off-by: Andrea Panattoni <apanatto@redhat.com>
@zeeke zeeke mentioned this pull request Apr 28, 2025
Cellebyte pushed a commit to telekom/multi-networkpolicy-nftables that referenced this pull request Sep 15, 2025
Cellebyte pushed a commit to telekom/multi-networkpolicy-nftables that referenced this pull request Sep 15, 2025
Add end2end test cases for
- k8snetworkplumbingwg#75

Signed-off-by: Andrea Panattoni <apanatto@redhat.com>
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.

4 participants