@@ -7,16 +7,16 @@ import (
7
7
8
8
"github.com/genuinetools/netns/bridge"
9
9
"github.com/genuinetools/netns/netutils"
10
- "github.com/opencontainers/runc/libcontainer/configs "
10
+ "github.com/opencontainers/runtime-spec/specs-go "
11
11
"github.com/sirupsen/logrus"
12
12
"github.com/vishvananda/netlink"
13
13
"github.com/vishvananda/netns"
14
14
bolt "go.etcd.io/bbolt"
15
15
)
16
16
17
17
// 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 ) {
20
20
var nsip net.IP
21
21
// Open the database.
22
22
if err := c .openDB (false ); err != nil {
@@ -32,9 +32,9 @@ func (c *Client) Create(hook configs.HookState, brOpt bridge.Opt, staticip strin
32
32
}
33
33
34
34
// 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 )
36
36
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 )
38
38
}
39
39
if err := netlink .LinkAdd (localVethPair ); err != nil {
40
40
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
47
47
}
48
48
49
49
// 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 )
52
52
}
53
53
54
54
// Bring the veth pair up.
@@ -83,7 +83,7 @@ func (c *Client) Create(hook configs.HookState, brOpt bridge.Opt, staticip strin
83
83
if staticip != "" {
84
84
nsip = net .ParseIP (staticip )
85
85
} else {
86
- nsip , err = c .AllocateIP (hook .Pid )
86
+ nsip , err = c .AllocateIP (s .Pid )
87
87
}
88
88
89
89
if err != nil {
@@ -96,7 +96,7 @@ func (c *Client) Create(hook configs.HookState, brOpt bridge.Opt, staticip strin
96
96
}
97
97
98
98
// 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 {
100
100
return nil , err
101
101
}
102
102
0 commit comments