Make the MTU configurable
This commit is contained in:
parent
00bd0820f5
commit
fd8b63c291
|
@ -19,6 +19,7 @@ type config struct {
|
|||
BindIface string `id:"bind-iface" desc:"Interface to bind to for cluster membership traffic (cannot be used with --bind-addr)"`
|
||||
ClusterPort int `id:"cluster-port" desc:"port used for membership gossip traffic (both TCP and UDP); must be the same across cluster" default:"7946"`
|
||||
WireguardPort int `id:"wireguard-port" desc:"port used for wireguard traffic (UDP); must be the same across cluster" default:"51820"`
|
||||
BaseMtu int `id:"mtu" desc:"MTU of the underlying network, taking intermediary hops into account" default:"1500"`
|
||||
OverlayNet *network `id:"overlay-net" desc:"the network in which to allocate addresses for the overlay mesh network (CIDR format); smaller networks increase the chance of IP collision" default:"10.0.0.0/8"`
|
||||
RoutedNet *network `id:"routed-net" desc:"network used to filter routes that nodes are allowed to announce (CIDR format)" default:"0.0.0.0/32"`
|
||||
Interface string `desc:"name of the wireguard interface to create and manage" default:"wgoverlay"`
|
||||
|
|
2
main.go
2
main.go
|
@ -39,7 +39,7 @@ func main() {
|
|||
if err != nil {
|
||||
logrus.WithError(err).Fatal("could not create cluster")
|
||||
}
|
||||
wgstate, localNode, err := wg.New(config.Interface, config.WireguardPort, (*net.IPNet)(config.OverlayNet), cluster.LocalName)
|
||||
wgstate, localNode, err := wg.New(config.Interface, config.WireguardPort, config.BaseMtu, (*net.IPNet)(config.OverlayNet), cluster.LocalName)
|
||||
if err != nil {
|
||||
logrus.WithError(err).Fatal("could not instantiate wireguard controller")
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ type State struct {
|
|||
client *wgctrl.Client
|
||||
OverlayAddr net.IPNet
|
||||
Port int
|
||||
Mtu int
|
||||
PrivKey wgtypes.Key
|
||||
PubKey wgtypes.Key
|
||||
}
|
||||
|
@ -25,7 +26,7 @@ type State struct {
|
|||
// New creates a new Wesher Wireguard state
|
||||
// The Wireguard keys are generated for every new interface
|
||||
// The interface must later be setup using SetUpInterface
|
||||
func New(iface string, port int, ipnet *net.IPNet, name string) (*State, *common.Node, error) {
|
||||
func New(iface string, port int, mtu int, ipnet *net.IPNet, name string) (*State, *common.Node, error) {
|
||||
client, err := wgctrl.New()
|
||||
if err != nil {
|
||||
return nil, nil, errors.Wrap(err, "could not instantiate wireguard client")
|
||||
|
@ -41,6 +42,7 @@ func New(iface string, port int, ipnet *net.IPNet, name string) (*State, *common
|
|||
iface: iface,
|
||||
client: client,
|
||||
Port: port,
|
||||
Mtu: mtu,
|
||||
PrivKey: privKey,
|
||||
PubKey: pubKey,
|
||||
}
|
||||
|
@ -123,8 +125,7 @@ func (s *State) SetUpInterface(nodes []common.Node, routedNet *net.IPNet) error
|
|||
}); err != nil {
|
||||
return errors.Wrapf(err, "could not set address for %s", s.iface)
|
||||
}
|
||||
// TODO: make MTU configurable?
|
||||
if err := netlink.LinkSetMTU(link, 1420); err != nil {
|
||||
if err := netlink.LinkSetMTU(link, s.Mtu-80); err != nil {
|
||||
return errors.Wrapf(err, "could not set MTU for %s", s.iface)
|
||||
}
|
||||
if err := netlink.LinkSetUp(link); err != nil {
|
||||
|
|
Loading…
Reference in New Issue