refactor: further simplify fastdp initialisation
This commit is contained in:
1 parent
13f37edb64
commit
0ee22af32d
2 files changed
+6
-17
No files matched your search
+1
-5
@@ -169,11 +169,7 @@ func main() {
|
|||||||
// options can override that below. Even if both
|
// options can override that below. Even if both
|
||||||
// things are overridden, we might need bridging on
|
// things are overridden, we might need bridging on
|
||||||
// the datapath.
|
// the datapath.
|
||||||
fastdp, err := weave.NewFastDatapath(weave.FastDatapathConfig{
|
fastdp, err := weave.NewFastDatapath(datapathName, config.Port)
|
||||||
DatapathName: datapathName,
|
|
||||||
Port: config.Port,
|
|
||||||
})
|
|
||||||
|
|
||||||
checkFatal(err)
|
checkFatal(err)
|
||||||
networkConfig.Bridge = fastdp.Bridge()
|
networkConfig.Bridge = fastdp.Bridge()
|
||||||
overlays.Add("fastdp", fastdp.Overlay())
|
overlays.Add("fastdp", fastdp.Overlay())
|
||||||
|
|||||||
+5
-12
@@ -68,14 +68,7 @@ type FastDatapath struct {
|
|||||||
forwarders map[mesh.PeerName]*fastDatapathForwarder
|
forwarders map[mesh.PeerName]*fastDatapathForwarder
|
||||||
}
|
}
|
||||||
|
|
||||||
type FastDatapathConfig struct {
|
func NewFastDatapath(dpName string, port int) (*FastDatapath, error) {
|
||||||
DatapathName string
|
|
||||||
Port int
|
|
||||||
ExpireFlowsInterval time.Duration
|
|
||||||
ExpireMACsInterval time.Duration
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewFastDatapath(config FastDatapathConfig) (*FastDatapath, error) {
|
|
||||||
dpif, err := odp.NewDpif()
|
dpif, err := odp.NewDpif()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -88,18 +81,18 @@ func NewFastDatapath(config FastDatapathConfig) (*FastDatapath, error) {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
dp, err := dpif.LookupDatapath(config.DatapathName)
|
dp, err := dpif.LookupDatapath(dpName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
iface, err := net.InterfaceByName(config.DatapathName)
|
iface, err := net.InterfaceByName(dpName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
fastdp := &FastDatapath{
|
fastdp := &FastDatapath{
|
||||||
dpname: config.DatapathName,
|
dpname: dpName,
|
||||||
mtu: iface.MTU,
|
mtu: iface.MTU,
|
||||||
dpif: dpif,
|
dpif: dpif,
|
||||||
dp: dp,
|
dp: dp,
|
||||||
@@ -131,7 +124,7 @@ func NewFastDatapath(config FastDatapathConfig) (*FastDatapath, error) {
|
|||||||
// numbers to be independent, but working out how to specify
|
// numbers to be independent, but working out how to specify
|
||||||
// them on the connecting side. So we can wait to find out if
|
// them on the connecting side. So we can wait to find out if
|
||||||
// anyone wants that.
|
// anyone wants that.
|
||||||
fastdp.mainVxlanVportID, err = fastdp.getVxlanVportIDHarder(config.Port+1, 5, time.Millisecond*10)
|
fastdp.mainVxlanVportID, err = fastdp.getVxlanVportIDHarder(port+1, 5, time.Millisecond*10)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user