From 0f89f8562f9cb53af30b0378dbae16ff41318d26 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Wed, 30 Mar 2016 14:07:33 +0100 Subject: [PATCH] refactor(ish): parameterise dp creation by iface, not name --- prog/weaver/main.go | 4 ++-- router/fastdp.go | 11 +++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/prog/weaver/main.go b/prog/weaver/main.go index a406b543..cb297117 100644 --- a/prog/weaver/main.go +++ b/prog/weaver/main.go @@ -348,9 +348,9 @@ func createOverlay(datapathName string, ifaceName string, host string, port int, case datapathName != "" && ifaceName != "": Log.Fatal("At most one of --datapath and --iface must be specified.") case datapathName != "": - _, err := weavenet.EnsureInterface(datapathName) + iface, err := weavenet.EnsureInterface(datapathName) checkFatal(err) - fastdp, err := weave.NewFastDatapath(datapathName, port) + fastdp, err := weave.NewFastDatapath(iface, port) checkFatal(err) bridge = fastdp.Bridge() overlay.Add("fastdp", fastdp.Overlay()) diff --git a/router/fastdp.go b/router/fastdp.go index 3c1efa7d..c4d8c775 100644 --- a/router/fastdp.go +++ b/router/fastdp.go @@ -61,7 +61,7 @@ type FastDatapath struct { forwarders map[mesh.PeerName]*fastDatapathForwarder } -func NewFastDatapath(dpName string, port int) (*FastDatapath, error) { +func NewFastDatapath(iface *net.Interface, port int) (*FastDatapath, error) { dpif, err := odp.NewDpif() if err != nil { return nil, err @@ -74,18 +74,13 @@ func NewFastDatapath(dpName string, port int) (*FastDatapath, error) { } }() - dp, err := dpif.LookupDatapath(dpName) - if err != nil { - return nil, err - } - - iface, err := net.InterfaceByName(dpName) + dp, err := dpif.LookupDatapath(iface.Name) if err != nil { return nil, err } fastdp := &FastDatapath{ - dpname: dpName, + dpname: iface.Name, dpif: dpif, dp: dp, iface: iface,