From 687e6f0b0798f8ddb32ad9f036b9c01761e106a4 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Tue, 18 Aug 2015 14:06:35 -0700 Subject: [PATCH] add link ifb and fix macvtap --- link.go | 13 +++++++++++++ link_linux.go | 11 ++++++++++- link_test.go | 7 +++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/link.go b/link.go index 664895f..18fd175 100644 --- a/link.go +++ b/link.go @@ -62,6 +62,19 @@ func (dummy *Dummy) Type() string { return "dummy" } +// Ifb links are advanced dummy devices for packet filtering +type Ifb struct { + LinkAttrs +} + +func (ifb *Ifb) Attrs() *LinkAttrs { + return &ifb.LinkAttrs +} + +func (ifb *Ifb) Type() string { + return "ifb" +} + // Bridge links are simple linux bridges type Bridge struct { LinkAttrs diff --git a/link_linux.go b/link_linux.go index d3d467a..6851150 100644 --- a/link_linux.go +++ b/link_linux.go @@ -493,6 +493,8 @@ func linkDeserialize(m []byte) (Link, error) { switch linkType { case "dummy": link = &Dummy{} + case "ifb": + link = &Ifb{} case "bridge": link = &Bridge{} case "vlan": @@ -522,8 +524,10 @@ func linkDeserialize(m []byte) (Link, error) { parseVxlanData(link, data) case "ipvlan": parseIPVlanData(link, data) - case "macvlan", "macvtap": + case "macvlan": parseMacvlanData(link, data) + case "macvtap": + parseMacvtapData(link, data) } } } @@ -698,6 +702,11 @@ func parseIPVlanData(link Link, data []syscall.NetlinkRouteAttr) { } } +func parseMacvtapData(link Link, data []syscall.NetlinkRouteAttr) { + macv := link.(*Macvtap) + parseMacvlanData(&macv.Macvlan, data) +} + func parseMacvlanData(link Link, data []syscall.NetlinkRouteAttr) { macv := link.(*Macvlan) for _, datum := range data { diff --git a/link_test.go b/link_test.go index bb994ad..9ceca11 100644 --- a/link_test.go +++ b/link_test.go @@ -183,6 +183,13 @@ func TestLinkAddDelDummy(t *testing.T) { testLinkAddDel(t, &Dummy{LinkAttrs{Name: "foo"}}) } +func TestLinkAddDelIfb(t *testing.T) { + tearDown := setUpNetlinkTest(t) + defer tearDown() + + testLinkAddDel(t, &Ifb{LinkAttrs{Name: "foo"}}) +} + func TestLinkAddDelBridge(t *testing.T) { tearDown := setUpNetlinkTest(t) defer tearDown()