Create a plugin for up'ing a lo device

- Believe we need sudo to create netns
- Use syscall instead of relying on ip netns
- Add sudo to .travis.yml
- Needs more -E
- Revert Godeps GoVersion to 1.4.2
- in travis, test command is run with all necessary env vars
- Loopback plugin only works on 'lo' interface
- Update README, add loopback plugin config
- note script dependency on jq

Signed-off-by: Gabe Rosenhouse <grosenhouse@pivotal.io>
This commit is contained in:
Zachary Gershman
2016-02-12 09:30:10 -08:00
committed by zachgersh
parent ebd5be8475
commit 2708bdf2f5
7 changed files with 182 additions and 4 deletions

View File

@ -0,0 +1,40 @@
package main
import (
"os"
"github.com/appc/cni/pkg/ns"
"github.com/appc/cni/pkg/skel"
"github.com/vishvananda/netlink"
)
func cmdAdd(args *skel.CmdArgs) error {
args.IfName = "lo" // ignore config, this only works for loopback
err := ns.WithNetNSPath(args.Netns, false, func(hostNS *os.File) error {
link, err := netlink.LinkByName(args.IfName)
if err != nil {
return err // not tested
}
err = netlink.LinkSetUp(link)
if err != nil {
return err // not tested
}
return nil
})
if err != nil {
return err // not tested
}
return nil
}
func cmdDel(args *skel.CmdArgs) error {
// del does nothing, we're going to destroy the device anyway
return nil
}
func main() {
skel.PluginMain(cmdAdd, cmdDel)
}