1 diff --git a/build.sh b/build.sh
2 index cd21ba8..bc60d91 100755
5 @@ -19,7 +19,7 @@ export GOPATH=${PWD}/gopath
8 echo "Building plugins"
9 -PLUGINS="plugins/meta/* plugins/main/* plugins/ipam/* plugins/sample"
10 +PLUGINS="plugins/main/ovsdpdk plugins/main/bridge plugins/ipam/host-local"
13 plugin="$(basename "$d")"
14 diff --git a/plugins/main/ovsdpdk/ovsdpdk.go b/plugins/main/ovsdpdk/ovsdpdk.go
16 index 0000000..1b931d4
18 +++ b/plugins/main/ovsdpdk/ovsdpdk.go
20 +// Copyright 2014 CNI authors
22 +// Licensed under the Apache License, Version 2.0 (the "License");
23 +// you may not use this file except in compliance with the License.
24 +// You may obtain a copy of the License at
26 +// http://www.apache.org/licenses/LICENSE-2.0
28 +// Unless required by applicable law or agreed to in writing, software
29 +// distributed under the License is distributed on an "AS IS" BASIS,
30 +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 +// See the License for the specific language governing permissions and
32 +// limitations under the License.
46 + "github.com/containernetworking/cni/pkg/skel"
47 + "github.com/containernetworking/cni/pkg/types"
48 + "github.com/containernetworking/cni/pkg/types/current"
49 + "github.com/containernetworking/cni/pkg/version"
50 + //"github.com/containernetworking/plugins/pkg/ip"
51 + "github.com/containernetworking/plugins/pkg/ipam"
52 + //"github.com/containernetworking/plugins/pkg/ns"
53 + //"github.com/containernetworking/plugins/pkg/utils"
54 + //"github.com/vishvananda/netlink"
57 +const defaultBrName = "cni0"
59 +type NetConf struct {
61 + BrName string `json:"bridge"`
65 + // this ensures that main runs only on main thread (thread group leader).
66 + // since namespace ops (unshare, setns) are done for a single thread, we
67 + // must ensure that the goroutine does not jump from OS thread to thread
68 + runtime.LockOSThread()
71 +func loadNetConf(bytes []byte) (*NetConf, string, error) {
73 + BrName: defaultBrName,
75 + if err := json.Unmarshal(bytes, n); err != nil {
76 + return nil, "", fmt.Errorf("failed to load netconf: %v", err)
78 + return n, n.CNIVersion, nil
81 +func setupVhostUser(args *skel.CmdArgs, types string) error {
82 + exec.Command("/bin/bash", "/opt/cni/bin/setup_ovsdpdk.sh", args.Netns, args.ContainerID, types).Output()
87 +func cmdAdd(args *skel.CmdArgs) error {
88 + n, cniVersion, err := loadNetConf(args.StdinData)
93 + // run the IPAM plugin and get back the config to apply
94 + r, err := ipam.ExecAdd(n.IPAM.Type, args.StdinData)
99 + // Convert whatever the IPAM result was into the current Result type
100 + result, err := current.NewResultFromResult(r)
105 + if len(result.IPs) == 0 {
106 + return errors.New("IPAM plugin returned missing IP config")
109 + setupVhostUser(args, result.String())
111 + return types.PrintResult(result, cniVersion)
114 +func tearDownVhostUser(args *skel.CmdArgs) error {
115 + exec.Command("/bin/bash", "/opt/cni/bin/teardown_ovsdpdk.sh", args.Netns, args.ContainerID).Output()
119 +func cmdDel(args *skel.CmdArgs) error {
120 + n, _, err := loadNetConf(args.StdinData)
125 + if err := ipam.ExecDel(n.IPAM.Type, args.StdinData); err != nil {
129 + tearDownVhostUser(args)
135 + skel.PluginMain(cmdAdd, cmdDel, version.All)