@@ -7,16 +7,16 @@ import (
77
88 "github.com/genuinetools/netns/bridge"
99 "github.com/genuinetools/netns/netutils"
10- "github.com/opencontainers/runc/libcontainer/configs "
10+ "github.com/opencontainers/runtime-spec/specs-go "
1111 "github.com/sirupsen/logrus"
1212 "github.com/vishvananda/netlink"
1313 "github.com/vishvananda/netns"
1414 bolt "go.etcd.io/bbolt"
1515)
1616
1717// Create returns a container IP that was created with the given bridge name,
18- // the settings from the HookState passed, and the bridge options.
19- func (c * Client ) Create (hook configs. HookState , brOpt bridge.Opt , staticip string ) (net.IP , error ) {
18+ // the settings from the spec.State passed, and the bridge options.
19+ func (c * Client ) Create (s * specs. State , brOpt bridge.Opt , staticip string ) (net.IP , error ) {
2020 var nsip net.IP
2121 // Open the database.
2222 if err := c .openDB (false ); err != nil {
@@ -32,9 +32,9 @@ func (c *Client) Create(hook configs.HookState, brOpt bridge.Opt, staticip strin
3232 }
3333
3434 // Create and attach local name to the bridge.
35- localVethPair , err := c .vethPair (hook .Pid , c .opt .BridgeName )
35+ localVethPair , err := c .vethPair (s .Pid , c .opt .BridgeName )
3636 if err != nil {
37- return nil , fmt .Errorf ("getting vethpair for pid %d failed: %v" , hook .Pid , err )
37+ return nil , fmt .Errorf ("getting vethpair for pid %d failed: %v" , s .Pid , err )
3838 }
3939 if err := netlink .LinkAdd (localVethPair ); err != nil {
4040 return nil , fmt .Errorf ("create veth pair named [ %#v ] failed: %v" , localVethPair , err )
@@ -47,8 +47,8 @@ func (c *Client) Create(hook configs.HookState, brOpt bridge.Opt, staticip strin
4747 }
4848
4949 // Put peer interface into the network namespace of specified PID.
50- if err := netlink .LinkSetNsPid (peer , hook .Pid ); err != nil {
51- return nil , fmt .Errorf ("adding peer interface to network namespace of pid %d failed: %v" , hook .Pid , err )
50+ if err := netlink .LinkSetNsPid (peer , s .Pid ); err != nil {
51+ return nil , fmt .Errorf ("adding peer interface to network namespace of pid %d failed: %v" , s .Pid , err )
5252 }
5353
5454 // Bring the veth pair up.
@@ -83,7 +83,7 @@ func (c *Client) Create(hook configs.HookState, brOpt bridge.Opt, staticip strin
8383 if staticip != "" {
8484 nsip = net .ParseIP (staticip )
8585 } else {
86- nsip , err = c .AllocateIP (hook .Pid )
86+ nsip , err = c .AllocateIP (s .Pid )
8787 }
8888
8989 if err != nil {
@@ -96,7 +96,7 @@ func (c *Client) Create(hook configs.HookState, brOpt bridge.Opt, staticip strin
9696 }
9797
9898 // Configure the interface in the network namespace.
99- if err := c .configureInterface (localVethPair .PeerName , hook .Pid , newIP , ip .String ()); err != nil {
99+ if err := c .configureInterface (localVethPair .PeerName , s .Pid , newIP , ip .String ()); err != nil {
100100 return nil , err
101101 }
102102
0 commit comments