This repository was archived by the owner on Jun 20, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed
Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -39,13 +39,18 @@ func (i *Ipam) Allocate(args *skel.CmdArgs) (types.Result, error) {
3939 var ipnet * net.IPNet
4040
4141 if len (conf .IPs ) == 1 {
42- ip := conf .IPs [0 ]
43- if ip .Version == "4" {
44- ipnet = & ip .Address
45- err = i .weave .ClaimIP (containerID , ipnet , false )
46- } else {
42+ ip := net .ParseIP (conf .IPs [0 ]).To4 ()
43+
44+ if ip == nil {
4745 return nil , errors .New ("allocation of ipv6 addresses is not implemented" )
4846 }
47+
48+ ipnet := & net.IPNet {
49+ IP : ip ,
50+ Mask : ip .DefaultMask (),
51+ }
52+
53+ err = i .weave .ClaimIP (containerID , ipnet , false )
4954 } else if conf .Subnet == "" {
5055 ipnet , err = i .weave .AllocateIP (containerID , false )
5156 } else {
@@ -80,10 +85,10 @@ func (i *Ipam) Release(args *skel.CmdArgs) error {
8085}
8186
8287type ipamConf struct {
83- Subnet string `json:"subnet,omitempty"`
84- Gateway net.IP `json:"gateway,omitempty"`
85- Routes []* types.Route `json:"routes"`
86- IPs []* current. IPConfig `json:"ips,omitempty"`
88+ Subnet string `json:"subnet,omitempty"`
89+ Gateway net.IP `json:"gateway,omitempty"`
90+ Routes []* types.Route `json:"routes"`
91+ IPs []string `json:"ips,omitempty"`
8792}
8893
8994type netConf struct {
You can’t perform that action at this time.
0 commit comments