From afcb84d42c8c1deb907ff9d2de33d7bede2bfd77 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Wed, 2 Dec 2015 17:47:19 +0000 Subject: [PATCH] Set up static route for multicast, with option to turn off --- plugin/net/driver.go | 25 +++++++++++++++++-------- prog/plugin/main.go | 22 ++++++++++++---------- site/plugin.md | 2 ++ weave | 2 +- 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/plugin/net/driver.go b/plugin/net/driver.go index 34c5c306..12b4a62f 100644 --- a/plugin/net/driver.go +++ b/plugin/net/driver.go @@ -21,19 +21,21 @@ const ( ) type driver struct { - version string - nameserver string - scope string + version string + nameserver string + scope string + noMulticastRoute bool sync.RWMutex endpoints map[string]struct{} } -func New(client *docker.Client, version string, nameserver string, scope string) (skel.Driver, error) { +func New(client *docker.Client, version string, nameserver string, scope string, noMulticastRoute bool) (skel.Driver, error) { driver := &driver{ - nameserver: nameserver, - version: version, - scope: scope, - endpoints: make(map[string]struct{}), + nameserver: nameserver, + noMulticastRoute: noMulticastRoute, + version: version, + scope: scope, + endpoints: make(map[string]struct{}), } _, err := NewWatcher(client, driver) @@ -162,6 +164,13 @@ func (driver *driver) JoinEndpoint(j *api.JoinRequest) (*api.JoinResponse, error } response.StaticRoutes = []api.StaticRoute{routeToDNS} } + if !driver.noMulticastRoute { + multicastRoute := api.StaticRoute{ + Destination: "224.0.0.0/4", + RouteType: types.CONNECTED, + } + response.StaticRoutes = append(response.StaticRoutes, multicastRoute) + } Log.Infof("Join endpoint %s:%s to %s", j.NetworkID, j.EndpointID, j.SandboxKey) return response, nil } diff --git a/prog/plugin/main.go b/prog/plugin/main.go index b9a5a581..d1ffb928 100644 --- a/prog/plugin/main.go +++ b/prog/plugin/main.go @@ -22,12 +22,13 @@ var version = "(unreleased version)" func main() { var ( - justVersion bool - address string - nameserver string - meshAddress string - logLevel string - meshNetworkName string + justVersion bool + address string + nameserver string + meshAddress string + logLevel string + meshNetworkName string + noMulticastRoute bool ) flag.BoolVar(&justVersion, "version", false, "print version and exit") @@ -36,6 +37,7 @@ func main() { flag.StringVar(&nameserver, "nameserver", "", "nameserver to provide to containers") flag.StringVar(&meshAddress, "meshsocket", "/run/docker/plugins/weavemesh.sock", "socket on which to listen in mesh mode") flag.StringVar(&meshNetworkName, "mesh-network-name", "weave", "network name to create in mesh mode") + flag.BoolVar(&noMulticastRoute, "no-multicast-route", false, "do not add a multicast route to network endpoints") flag.Parse() @@ -57,14 +59,14 @@ func main() { var globalListener, meshListener net.Listener endChan := make(chan error, 1) if address != "" { - globalListener, err := listenAndServe(dockerClient, address, nameserver, endChan, "global", false) + globalListener, err := listenAndServe(dockerClient, address, nameserver, noMulticastRoute, endChan, "global", false) if err != nil { Log.Fatalf("unable to create driver: %s", err) } defer globalListener.Close() } if meshAddress != "" { - meshListener, err := listenAndServe(dockerClient, meshAddress, nameserver, endChan, "local", true) + meshListener, err := listenAndServe(dockerClient, meshAddress, nameserver, noMulticastRoute, endChan, "local", true) if err != nil { Log.Fatalf("unable to create driver: %s", err) } @@ -94,8 +96,8 @@ func main() { } } -func listenAndServe(dockerClient *docker.Client, address, nameserver string, endChan chan<- error, scope string, withIpam bool) (net.Listener, error) { - d, err := netplugin.New(dockerClient, version, nameserver, scope) +func listenAndServe(dockerClient *docker.Client, address, nameserver string, noMulticastRoute bool, endChan chan<- error, scope string, withIpam bool) (net.Listener, error) { + d, err := netplugin.New(dockerClient, version, nameserver, scope, noMulticastRoute) if err != nil { return nil, err } diff --git a/site/plugin.md b/site/plugin.md index eb4489b1..f6497dac 100644 --- a/site/plugin.md +++ b/site/plugin.md @@ -68,6 +68,8 @@ The plugin command-line arguments are: how much information to emit for debugging. * `--mesh-network-name=`: set it to blank to disable creation of a default network, or a name of your own choice. + * `--no-multicast-route`: stop weave adding a static IP route for + multicast traffic on its interface ## Restarting diff --git a/weave b/weave index 16d15feb..e2267789 100755 --- a/weave +++ b/weave @@ -54,7 +54,7 @@ weave launch-proxy [-H ] [--with-dns | --without-dns] [--hostname-match ] [--hostname-replacement ] [--rewrite-inspect] -weave launch-plugin +weave launch-plugin [--no-multicast-route] weave env [--restore] weave config weave dns-args