diff --git a/link.go b/link.go index 30167cd..ec3df82 100644 --- a/link.go +++ b/link.go @@ -114,6 +114,15 @@ func (macvlan *Macvlan) Type() string { return "macvlan" } +// Macvtap - macvtap is a virtual interfaces based on macvlan +type Macvtap struct { + Macvlan +} + +func (macvtap Macvtap) Type() string { + return "macvtap" +} + // Veth devices must specify PeerName on create type Veth struct { LinkAttrs diff --git a/link_test.go b/link_test.go index 9e44f0d..bb994ad 100644 --- a/link_test.go +++ b/link_test.go @@ -225,6 +225,27 @@ func TestLinkAddDelMacvlan(t *testing.T) { } } +func TestLinkAddDelMacvtap(t *testing.T) { + tearDown := setUpNetlinkTest(t) + defer tearDown() + + parent := &Dummy{LinkAttrs{Name: "foo"}} + if err := LinkAdd(parent); err != nil { + t.Fatal(err) + } + + testLinkAddDel(t, &Macvtap{ + Macvlan: Macvlan{ + LinkAttrs: LinkAttrs{Name: "bar", ParentIndex: parent.Attrs().Index}, + Mode: MACVLAN_MODE_PRIVATE, + }, + }) + + if err := LinkDel(parent); err != nil { + t.Fatal(err) + } +} + func TestLinkAddDelVeth(t *testing.T) { tearDown := setUpNetlinkTest(t) defer tearDown()