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:

committed by
zachgersh

parent
ebd5be8475
commit
2708bdf2f5
40
plugins/main/loopback/loopback.go
Normal file
40
plugins/main/loopback/loopback.go
Normal 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)
|
||||
}
|
Reference in New Issue
Block a user