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

fix: sometimes allocate IPv6 address failed but there is available IP in V6FreeIPList #2132

Merged
merged 1 commit into from
Dec 7, 2022

Conversation

changluyi
Copy link
Collaborator

@changluyi changluyi commented Dec 6, 2022

sometimes ipam.GetStaticAddress return NoAvailableAddress but there is available IP in V6FreeIPList

when use ipam.GetStaticAddress with param ipv6 address without clean Zero such as "fd00::00e9:0ed1", and exactly subnet.V6FreeIPList has a range with start fd00::e9:ed1 and end with any v6 address, or start with an any v6 address and end with fd00::e9:ed1, it will cause ipr.Start.Equal(ip) or ipr.End.Equal(ip) failed, Because equal only check the string match .

What type of this PR

Examples of user facing changes:

  • Features
  • Bug fixes
  • Docs
  • Tests

Which issue(s) this PR fixes:

Fixes #(issue-number)

@changluyi changluyi added bug Something isn't working need backport labels Dec 6, 2022
pkg/ipam/ip.go Outdated
@@ -15,7 +16,7 @@ type IPRange struct {
}

func (a IP) Equal(b IP) bool {
return a == b
return net.ParseIP(string(a)).Equal(net.ParseIP(string(b)))
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
return net.ParseIP(string(a)).Equal(net.ParseIP(string(b)))
return a == b || net.ParseIP(string(a)).Equal(net.ParseIP(string(b)))

Copy link
Member

Choose a reason for hiding this comment

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

Where is Equal() used? Is there any chance that net.ParseIP(string(a)) may return nil?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

image

Copy link
Collaborator Author

@changluyi changluyi Dec 6, 2022

Choose a reason for hiding this comment

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

in splitIPRangeList, the equal function will return false

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

for example, ipr.End = "fd00::e9:ed1" and ip ="fd00::00e9:0ed1"

…ress return NoAvailableAddress

 when use ipam.GetStaticAddress with param ipv6 address without clean Zero
 such as "fd00::00e9:0ed1", and exactly subnet.V6FreeIPList has a range
 with start fd00::e9:ed1 and end with any v6 address,or start with an any v6
 address and end with fd00::e9:ed1, it will cause ipr.Start.Equal(ip)
 or ipr.End.Equal(ip) failed, and no v6 address allocated
@changluyi changluyi force-pushed the fix_alloc_ipv6_address_NoAvailableAddress branch from 09dbd4f to 7f3a9ea Compare December 7, 2022 01:35
@changluyi changluyi merged commit f58c88f into master Dec 7, 2022
@changluyi changluyi deleted the fix_alloc_ipv6_address_NoAvailableAddress branch December 7, 2022 02:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working need backport
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants