refactor(ish): parameterise dp creation by iface, not name
This commit is contained in:
1 parent
8eb52538de
commit
0f89f8562f
2 files changed
+5
-10
No files matched your search
+2
-2
@@ -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())
|
||||
|
||||
+3
-8
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user