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

vSphere provider ipv6 support #3957

Closed
chrislovecnm opened this issue Nov 18, 2015 · 7 comments · Fixed by #4035
Closed

vSphere provider ipv6 support #3957

chrislovecnm opened this issue Nov 18, 2015 · 7 comments · Fixed by #4035

Comments

@chrislovecnm
Copy link
Contributor

Two things need to be done.

@tkak if you can point me in the right direction I have an environment up that can test it. I am a bit lost in ipv6 and golang land :)

Outlined my lack of knowledge here: http://stackoverflow.com/questions/33769800/getting-ipv6-subnet-mask-from-net-cidrmask

@jen20 might you add 'bug' 'enhancement' and correct provider labels? This is a bug because the provider assumes ipv4, and it goes boom with ipv6 addresses.

@chrislovecnm
Copy link
Contributor Author

#3959 submitted to update docs, till ip addressing is enhanced.

@chrislovecnm
Copy link
Contributor Author

@jen20 thanks

Docs are updated, at a min we need to test for ipv6 ip address and fail.

@chrislovecnm
Copy link
Contributor Author

Here is design for the fix:

Current code:


    // string of ip address
    networkInterface["ip_address"] = v.IpAddress[0]
    m := net.CIDRMask(v.IpConfig.IpAddress[0].PrefixLength, 32)
    subnetMask := net.IPv4(m[0], m[1], m[2], m[3])
    networkInterface["subnet_mask"] = subnetMask.String()

design code:


    if v.IpAddress[0] != nil {
        networkInterface["ip_address"] = v.IpAddress[0]
        testip := net.ParseIP(v.IpAddress[0])
        subnetMask := nil
        if testInput.To4() != nil {
          if v.IpConfig.IpAddress[0].PrefixLength != nil {
              mask := net.CIDRMask(v.IpConfig.IpAddress[0].PrefixLength, 32)
              subnetMask := net.IPv4(m[0], m[1], m[2], m[3])
              networkInterface["subnet_mask"] = subnetMask.String()
          }
        } else if testInput.To16() != nil {
          if v.IpConfig.IpAddress[0].PrefixLength != nil {
              mask := net.CIDRMask(v.IpConfig.IpAddress[0].PrefixLength, 128)
              // TODO figure this out
              // net.mask?? func (ip IP) Mask(mask IPMask) IP
              // subnetMask := net.IP()
              networkInterface["subnet_mask"] = subnetMask.String()
          } 
       }
}

This is what is comming back from the api:

$ govc vm.info -json vcsa | jq .VirtualMachines[0].Guest.Net[0].IpConfig.IpAddress [ {
"IpAddress": "10.20.128.218",
"PrefixLength": 22,
"Origin": "",
"State": "preferred",
"Lifetime": null } ]

@tkak
Copy link
Contributor

tkak commented Nov 22, 2015

@chrislovecnm Thank you for investigation. That design code looks good to me.

Anyway, I'm thinking about that we sould change subnet_mask parameter to prefix_length in order to meet the specification of VMware vSphere API. Because subnet_mask paremeter is long to input in case of IPv6. What do you think of this idea?

@chrislovecnm
Copy link
Contributor Author

@tkak that makes more sense to me frankly, and is less code. Less code is always better 😀

Do we ever need to send the subnet mask, or do we need ever need the subnet_mask for the api?

@tkak
Copy link
Contributor

tkak commented Nov 24, 2015

@chrislovecnm I tried to make a proposal PR to support ipv6 address. Can you check that?

@ghost
Copy link

ghost commented Apr 29, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants