From 828e2240d3988391f9989a32d4f474c670866cfa Mon Sep 17 00:00:00 2001 From: Pawel Palucki Date: Mon, 27 Jul 2015 15:48:26 +0200 Subject: [PATCH] macvtap support --- link.go | 9 +++++++++ link_test.go | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/link.go b/link.go index af51e3f..c4a3605 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 2edfcbe..b167057 100644 --- a/link_test.go +++ b/link_test.go @@ -222,6 +222,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()