Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Set up static route for multicast, with option to turn off
Browse files Browse the repository at this point in the history
  • Loading branch information
bboreham committed Dec 16, 2015
1 parent 85c9cf4 commit 4600355
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
25 changes: 17 additions & 8 deletions plugin/net/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down
22 changes: 12 additions & 10 deletions prog/plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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()

Expand All @@ -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)
}
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion weave
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4600355

Please sign in to comment.