Set up static route for multicast, with option to turn off
This commit is contained in:
1 parent
c46febd7df
commit
afcb84d42c
4 files changed
+32
-19
No files matched your search
+17
-8
@@ -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
|
||||
}
|
||||
|
||||
+12
-10
@@ -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
|
||||
}
|
||||
|
||||
@@ -68,6 +68,8 @@ The plugin command-line arguments are:
|
||||
how much information to emit for debugging.
|
||||
* `--mesh-network-name=<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
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ weave launch-proxy [-H <endpoint>] [--with-dns | --without-dns]
|
||||
[--hostname-match <regexp>]
|
||||
[--hostname-replacement <replacement>]
|
||||
[--rewrite-inspect]
|
||||
weave launch-plugin
|
||||
weave launch-plugin [--no-multicast-route]
|
||||
weave env [--restore]
|
||||
weave config
|
||||
weave dns-args
|
||||
|
||||
Reference in new issue
Block a user