// setupTapDevice creates persistent tap devices // and returns a newly created netlink.Link structure func setupTapDevice() (netlink.Link, error) { ifName, err := tuntap.CreatePersistentIface(tuntap.Tap) if err != nil { return nil, fmt.Errorf("tuntap persist %v", err) } link, err := netlink.LinkByName(ifName) if err != nil { return nil, fmt.Errorf("cannot find link %q: %v", ifName, err) } err = netlink.LinkSetUp(link) if err != nil { return nil, fmt.Errorf("cannot set link up %q: %v", ifName, err) } return link, nil }
// setupTapDevice creates persistent tap devices // and returns a newly created netlink.Link structure func setupTapDevice(podID types.UUID) (netlink.Link, error) { // network device names are limited to 16 characters // the suffix %d will be replaced by the kernel with a suitable number nameTemplate := fmt.Sprintf("rkt-%s-tap%%d", podID.String()[0:4]) ifName, err := tuntap.CreatePersistentIface(nameTemplate, tuntap.Tap) if err != nil { return nil, fmt.Errorf("tuntap persist %v", err) } link, err := netlink.LinkByName(ifName) if err != nil { return nil, fmt.Errorf("cannot find link %q: %v", ifName, err) } err = netlink.LinkSetUp(link) if err != nil { return nil, fmt.Errorf("cannot set link up %q: %v", ifName, err) } return link, nil }