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 a new wrapper for point2point IPAM that filters invalid addresses and routes #1647

Closed

Conversation

NikitaSkrynnik
Copy link
Contributor

@NikitaSkrynnik NikitaSkrynnik commented Jul 17, 2024

Description

If point2point IPAM receives a request with filled ip_context it doesn't check if some of ip_context's addresses are already allocated for other connections. The PR adds a new wrapper for point2point IPAM that filters already allocated addresses.

Issue link

networkservicemesh/deployments-k8s#11787

How Has This Been Tested?

  • Added unit testing to cover
  • Tested manually
  • Tested by integration testing
  • Have not tested

Types of changes

  • Bug fix
  • New functionality
  • Documentation
  • Refactoring
  • CI

@NikitaSkrynnik NikitaSkrynnik marked this pull request as draft July 17, 2024 13:47
Signed-off-by: NikitaSkrynnik <nikita.skrynnik@xored.com>
Signed-off-by: NikitaSkrynnik <nikita.skrynnik@xored.com>
Signed-off-by: NikitaSkrynnik <nikita.skrynnik@xored.com>
Signed-off-by: NikitaSkrynnik <nikita.skrynnik@xored.com>
@NikitaSkrynnik NikitaSkrynnik changed the title add a unit test for ipam issue fix ipam doesn't check if addresses are already allocated Jul 22, 2024
@NikitaSkrynnik NikitaSkrynnik changed the title fix ipam doesn't check if addresses are already allocated fix point2point IPAM doesn't check if addresses are already allocated Jul 22, 2024
Signed-off-by: NikitaSkrynnik <nikita.skrynnik@xored.com>
Signed-off-by: NikitaSkrynnik <nikita.skrynnik@xored.com>
Signed-off-by: NikitaSkrynnik <nikita.skrynnik@xored.com>
Copy link

codecov bot commented Jul 23, 2024

Codecov Report

Attention: Patch coverage is 77.90698% with 19 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@c0bcf88). Learn more about missing BASE report.

Files Patch % Lines
pkg/networkservice/ipam/filteripam/server.go 79.76% 11 Missing and 6 partials ⚠️
pkg/tools/ippool/ippool.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1647   +/-   ##
=======================================
  Coverage        ?   67.94%           
=======================================
  Files           ?      265           
  Lines           ?    12677           
  Branches        ?        0           
=======================================
  Hits            ?     8614           
  Misses          ?     3531           
  Partials        ?      532           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: NikitaSkrynnik <nikita.skrynnik@xored.com>
@NikitaSkrynnik NikitaSkrynnik marked this pull request as ready for review July 23, 2024 06:07
Signed-off-by: NikitaSkrynnik <nikita.skrynnik@xored.com>
@NikitaSkrynnik NikitaSkrynnik changed the title fix point2point IPAM doesn't check if addresses are already allocated [fix] point2point IPAM doesn't check if addresses are already allocated Aug 13, 2024
Signed-off-by: NikitaSkrynnik <nikita.skrynnik@xored.com>
Signed-off-by: NikitaSkrynnik <nikita.skrynnik@xored.com>
@NikitaSkrynnik NikitaSkrynnik changed the title [fix] point2point IPAM doesn't check if addresses are already allocated Add a new wrapper for point2point IPAM that filters invalid addresses and routes Aug 16, 2024
Signed-off-by: NikitaSkrynnik <nikita.skrynnik@xored.com>
Signed-off-by: NikitaSkrynnik <nikita.skrynnik@xored.com>
Signed-off-by: NikitaSkrynnik <nikita.skrynnik@xored.com>
Signed-off-by: NikitaSkrynnik <nikita.skrynnik@xored.com>
Signed-off-by: NikitaSkrynnik <nikita.skrynnik@xored.com>
if newIPAMServer == nil {
panic("newIPAMServer should not be nil")
}
ipPool := ippool.New(net.IPv6len)
Copy link
Member

Choose a reason for hiding this comment

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

TODO: consider using dualstack ippool

"github.com/networkservicemesh/sdk/pkg/tools/ippool"
)

type filterIPAMServer struct {
Copy link
Member

@denis-tingaikin denis-tingaikin Aug 16, 2024

Choose a reason for hiding this comment

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

Consider better naming. For example primaryipam .

}

func (s *filterIPAMServer) getInvalidAddrs(addrs []string) []string {
invalidAddrs := make([]string, 0)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
invalidAddrs := make([]string, 0)
invalidAddrs := []string(nil)

for _, addr := range ipContext.SrcIpAddrs {
_, ipNet, err := net.ParseCIDR(addr)
if err != nil {
return
Copy link
Contributor

@ljkiraly ljkiraly Oct 15, 2024

Choose a reason for hiding this comment

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

We don't expect any error here, but don't we want to free the rest?

@NikitaSkrynnik
Copy link
Contributor Author

The same functionality has been implemented in this PR: #1679

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.

3 participants