Merge pull request #1758 from weaveworks/issues/82-optional-encryption

Make encryption optional; fixes #82, #1788. LGTM.
This commit is contained in:
Bryan Boreham committed 2015-12-15 15:23:58 +00:00
commit c973808b20
12 files changed
+214 -118

No files matched your search

+35 -12
View File
@@ -40,17 +40,19 @@ type RemoteConnection struct {
type LocalConnection struct { type LocalConnection struct {
sync.RWMutex sync.RWMutex
RemoteConnection RemoteConnection
TCPConn *net.TCPConn TCPConn *net.TCPConn
version byte TrustRemote bool // is remote on a trusted subnet?
tcpSender TCPSender TrustedByRemote bool // does remote trust us?
SessionKey *[32]byte version byte
heartbeatTCP *time.Ticker tcpSender TCPSender
Router *Router SessionKey *[32]byte
uid uint64 heartbeatTCP *time.Ticker
actionChan chan<- ConnectionAction Router *Router
errorChan chan<- error uid uint64
finished <-chan struct{} // closed to signal that actorLoop has finished actionChan chan<- ConnectionAction
OverlayConn OverlayConnection errorChan chan<- error
finished <-chan struct{} // closed to signal that actorLoop has finished
OverlayConn OverlayConnection
} }
type ConnectionAction func() error type ConnectionAction func() error
@@ -94,6 +96,7 @@ func StartLocalConnection(connRemote *RemoteConnection, tcpConn *net.TCPConn, ro
RemoteConnection: *connRemote, // NB, we're taking a copy of connRemote here. RemoteConnection: *connRemote, // NB, we're taking a copy of connRemote here.
Router: router, Router: router,
TCPConn: tcpConn, TCPConn: tcpConn,
TrustRemote: router.Trusts(connRemote),
uid: randUint64(), uid: randUint64(),
actionChan: actionChan, actionChan: actionChan,
errorChan: errorChan, errorChan: errorChan,
@@ -189,13 +192,19 @@ func (conn *LocalConnection) run(actionChan <-chan ConnectionAction, errorChan <
conn.Log("connection ready; using protocol version", conn.version) conn.Log("connection ready; using protocol version", conn.version)
// only use negotiated session key for untrusted connections
var sessionKey *[32]byte
if conn.Untrusted() {
sessionKey = conn.SessionKey
}
params := OverlayConnectionParams{ params := OverlayConnectionParams{
RemotePeer: conn.remote, RemotePeer: conn.remote,
LocalAddr: conn.TCPConn.LocalAddr().(*net.TCPAddr), LocalAddr: conn.TCPConn.LocalAddr().(*net.TCPAddr),
RemoteAddr: conn.TCPConn.RemoteAddr().(*net.TCPAddr), RemoteAddr: conn.TCPConn.RemoteAddr().(*net.TCPAddr),
Outbound: conn.outbound, Outbound: conn.outbound,
ConnUID: conn.uid, ConnUID: conn.uid,
SessionKey: conn.SessionKey, SessionKey: sessionKey,
SendControlMessage: conn.sendOverlayControlMessage, SendControlMessage: conn.sendOverlayControlMessage,
Features: intro.Features, Features: intro.Features,
} }
@@ -253,6 +262,7 @@ func (conn *LocalConnection) makeFeatures() map[string]string {
"ShortID": fmt.Sprint(conn.local.ShortID), "ShortID": fmt.Sprint(conn.local.ShortID),
"UID": fmt.Sprint(conn.local.UID), "UID": fmt.Sprint(conn.local.UID),
"ConnID": fmt.Sprint(conn.uid), "ConnID": fmt.Sprint(conn.uid),
"Trusted": fmt.Sprint(conn.TrustRemote),
} }
conn.Router.Overlay.AddFeaturesTo(features) conn.Router.Overlay.AddFeaturesTo(features)
return features return features
@@ -300,6 +310,15 @@ func (conn *LocalConnection) parseFeatures(features features) (*Peer, error) {
} }
} }
var trusted bool
if trustedStr, present := features["Trusted"]; present {
trusted, err = strconv.ParseBool(trustedStr)
if err != nil {
return nil, err
}
}
conn.TrustedByRemote = trusted
uid, err := ParsePeerUID(features.Get("UID")) uid, err := ParsePeerUID(features.Get("UID"))
if err != nil { if err != nil {
return nil, err return nil, err
@@ -435,3 +454,7 @@ func (conn *LocalConnection) handleProtocolMsg(tag ProtocolTag, payload []byte)
func (conn *LocalConnection) extendReadDeadline() { func (conn *LocalConnection) extendReadDeadline() {
conn.TCPConn.SetReadDeadline(time.Now().Add(TCPHeartbeat * 2)) conn.TCPConn.SetReadDeadline(time.Now().Add(TCPHeartbeat * 2))
} }
func (conn *LocalConnection) Untrusted() bool {
return !conn.TrustRemote || !conn.TrustedByRemote
}
+15
View File
@@ -37,6 +37,7 @@ type Config struct {
Password []byte Password []byte
ConnLimit int ConnLimit int
PeerDiscovery bool PeerDiscovery bool
TrustedSubnets []*net.IPNet
} }
type Router struct { type Router struct {
@@ -181,3 +182,17 @@ func (router *Router) applyTopologyUpdate(update []byte) (PeerNameSet, PeerNameS
} }
return origUpdate, newUpdate, nil return origUpdate, newUpdate, nil
} }
func (router *Router) Trusts(remote *RemoteConnection) bool {
if tcpAddr, err := net.ResolveTCPAddr("tcp4", remote.remoteTCPAddr); err == nil {
for _, trustedSubnet := range router.TrustedSubnets {
if trustedSubnet.Contains(tcpAddr.IP) {
return true
}
}
} else {
// Should not happen as remoteTCPAddr was obtained from TCPConn
log.Errorf("Unable to parse remote TCP addr: %s", err)
}
return false
}
+19 -1
View File
@@ -2,6 +2,7 @@ package mesh
import ( import (
"fmt" "fmt"
"net"
) )
type Status struct { type Status struct {
@@ -19,6 +20,7 @@ type Status struct {
Connections []LocalConnectionStatus Connections []LocalConnectionStatus
Targets []string Targets []string
OverlayDiagnostics interface{} OverlayDiagnostics interface{}
TrustedSubnets []string
} }
type PeerStatus struct { type PeerStatus struct {
@@ -69,7 +71,8 @@ func NewStatus(router *Router) *Status {
NewBroadcastRouteStatusSlice(router.Routes), NewBroadcastRouteStatusSlice(router.Routes),
NewLocalConnectionStatusSlice(router.ConnectionMaker), NewLocalConnectionStatusSlice(router.ConnectionMaker),
NewTargetSlice(router.ConnectionMaker), NewTargetSlice(router.ConnectionMaker),
router.Overlay.Diagnostics()} router.Overlay.Diagnostics(),
NewTrustedSubnetsSlice(router.TrustedSubnets)}
} }
func NewPeerStatusSlice(peers *Peers) []PeerStatus { func NewPeerStatusSlice(peers *Peers) []PeerStatus {
@@ -147,6 +150,13 @@ func NewLocalConnectionStatusSlice(cm *ConnectionMaker) []LocalConnectionStatus
} }
lc, _ := conn.(*LocalConnection) lc, _ := conn.(*LocalConnection)
info := fmt.Sprintf("%-6v %v", lc.OverlayConn.DisplayName(), conn.Remote()) info := fmt.Sprintf("%-6v %v", lc.OverlayConn.DisplayName(), conn.Remote())
if lc.Router.UsingPassword() {
if lc.Untrusted() {
info = fmt.Sprintf("%-11v %v", "encrypted", info)
} else {
info = fmt.Sprintf("%-11v %v", "unencrypted", info)
}
}
slice = append(slice, LocalConnectionStatus{conn.RemoteTCPAddr(), conn.Outbound(), state, info}) slice = append(slice, LocalConnectionStatus{conn.RemoteTCPAddr(), conn.Outbound(), state, info})
} }
for address, target := range cm.targets { for address, target := range cm.targets {
@@ -191,3 +201,11 @@ func NewTargetSlice(cm *ConnectionMaker) []string {
} }
return <-resultChan return <-resultChan
} }
func NewTrustedSubnetsSlice(trustedSubnets []*net.IPNet) []string {
trustedSubnetStrs := []string{}
for _, trustedSubnet := range trustedSubnets {
trustedSubnetStrs = append(trustedSubnetStrs, trustedSubnet.String())
}
return trustedSubnetStrs
}
+26 -25
View File
@@ -27,11 +27,11 @@ var rootTemplate = template.New("root").Funcs(map[string]interface{}{
} }
return count return count
}, },
"upstreamServers": func(servers []string) string { "printList": func(list []string) string {
if len(servers) == 0 { if len(list) == 0 {
return "none" return "none"
} }
return strings.Join(servers, ", ") return strings.Join(list, ", ")
}, },
"printIPAMRanges": func(router weave.NetworkRouterStatus, status ipam.Status) string { "printIPAMRanges": func(router weave.NetworkRouterStatus, status ipam.Status) string {
var buffer bytes.Buffer var buffer bytes.Buffer
@@ -138,47 +138,48 @@ func defTemplate(name string, text string) *template.Template {
} }
var statusTemplate = defTemplate("status", `\ var statusTemplate = defTemplate("status", `\
Version: {{.Version}} Version: {{.Version}}
Service: router Service: router
Protocol: {{.Router.Protocol}} \ Protocol: {{.Router.Protocol}} \
{{if eq .Router.ProtocolMinVersion .Router.ProtocolMaxVersion}}\ {{if eq .Router.ProtocolMinVersion .Router.ProtocolMaxVersion}}\
{{.Router.ProtocolMaxVersion}}\ {{.Router.ProtocolMaxVersion}}\
{{else}}\ {{else}}\
{{.Router.ProtocolMinVersion}}..{{.Router.ProtocolMaxVersion}}\ {{.Router.ProtocolMinVersion}}..{{.Router.ProtocolMaxVersion}}\
{{end}} {{end}}
Name: {{.Router.Name}}({{.Router.NickName}}) Name: {{.Router.Name}}({{.Router.NickName}})
Encryption: {{printState .Router.Encryption}} Encryption: {{printState .Router.Encryption}}
PeerDiscovery: {{printState .Router.PeerDiscovery}} PeerDiscovery: {{printState .Router.PeerDiscovery}}
Targets: {{len .Router.Targets}} Targets: {{len .Router.Targets}}
Connections: {{len .Router.Connections}}{{with printConnectionCounts .Router.Connections}} ({{.}}){{end}} Connections: {{len .Router.Connections}}{{with printConnectionCounts .Router.Connections}} ({{.}}){{end}}
Peers: {{len .Router.Peers}}{{with printPeerConnectionCounts .Router.Peers}} (with {{.}} connections){{end}} Peers: {{len .Router.Peers}}{{with printPeerConnectionCounts .Router.Peers}} (with {{.}} connections){{end}}
TrustedSubnets: {{printList .Router.TrustedSubnets}}
{{if .IPAM}}\ {{if .IPAM}}\
Service: ipam Service: ipam
{{if .IPAM.Entries}}\ {{if .IPAM.Entries}}\
{{if allIPAMOwnersUnreachable .IPAM}}\ {{if allIPAMOwnersUnreachable .IPAM}}\
Status: all IP ranges owned by unreachable peers - use 'rmpeer' if they are dead Status: all IP ranges owned by unreachable peers - use 'rmpeer' if they are dead
{{else if len .IPAM.PendingAllocates}}\ {{else if len .IPAM.PendingAllocates}}\
Status: waiting for IP range grant from peers Status: waiting for IP range grant from peers
{{else}}\ {{else}}\
Status: ready Status: ready
{{end}}\ {{end}}\
{{else if .IPAM.Paxos}}\ {{else if .IPAM.Paxos}}\
Status: awaiting consensus (quorum: {{.IPAM.Paxos.Quorum}}, known: {{.IPAM.Paxos.KnownNodes}}) Status: awaiting consensus (quorum: {{.IPAM.Paxos.Quorum}}, known: {{.IPAM.Paxos.KnownNodes}})
{{else}}\ {{else}}\
Status: idle Status: idle
{{end}}\ {{end}}\
Range: {{.IPAM.Range}} Range: {{.IPAM.Range}}
DefaultSubnet: {{.IPAM.DefaultSubnet}} DefaultSubnet: {{.IPAM.DefaultSubnet}}
{{end}}\ {{end}}\
{{if .DNS}}\ {{if .DNS}}\
Service: dns Service: dns
Domain: {{.DNS.Domain}} Domain: {{.DNS.Domain}}
Upstream: {{upstreamServers .DNS.Upstream}} Upstream: {{printList .DNS.Upstream}}
TTL: {{.DNS.TTL}} TTL: {{.DNS.TTL}}
Entries: {{countDNSEntries .DNS.Entries}} Entries: {{countDNSEntries .DNS.Entries}}
{{end}}\ {{end}}\
`) `)
+26 -4
View File
@@ -69,6 +69,7 @@ func main() {
dnsEffectiveListenAddress string dnsEffectiveListenAddress string
iface *net.Interface iface *net.Interface
datapathName string datapathName string
trustedSubnetStr string
) )
mflag.BoolVar(&justVersion, []string{"#version", "-version"}, false, "print version and exit") mflag.BoolVar(&justVersion, []string{"#version", "-version"}, false, "print version and exit")
@@ -101,6 +102,8 @@ func main() {
mflag.StringVar(&dnsEffectiveListenAddress, []string{"-dns-effective-listen-address"}, "", "address DNS will actually be listening, after Docker port mapping") mflag.StringVar(&dnsEffectiveListenAddress, []string{"-dns-effective-listen-address"}, "", "address DNS will actually be listening, after Docker port mapping")
mflag.StringVar(&datapathName, []string{"-datapath"}, "", "ODP datapath name") mflag.StringVar(&datapathName, []string{"-datapath"}, "", "ODP datapath name")
mflag.StringVar(&trustedSubnetStr, []string{"-trusted-subnets"}, "", "Command separated list of trusted subnets in CIDR notation")
// crude way of detecting that we probably have been started in a // crude way of detecting that we probably have been started in a
// container, with `weave launch` --> suppress misleading paths in // container, with `weave launch` --> suppress misleading paths in
// mflags error messages. // mflags error messages.
@@ -193,10 +196,7 @@ func main() {
Log.Println("Communication between peers is unencrypted.") Log.Println("Communication between peers is unencrypted.")
} else { } else {
config.Password = []byte(password) config.Password = []byte(password)
Log.Println("Communication between peers is encrypted.") Log.Println("Communication between peers via untrusted networks is encrypted.")
// fastdp doesn't support encryption
fastDPOverlay = nil
} }
overlays := weave.NewOverlaySwitch() overlays := weave.NewOverlaySwitch()
@@ -237,6 +237,10 @@ func main() {
networkConfig.PacketLogging = nopPacketLogging{} networkConfig.PacketLogging = nopPacketLogging{}
} }
if config.TrustedSubnets, err = parseTrustedSubnets(trustedSubnetStr); err != nil {
Log.Fatal("Unable to parse trusted subnets: ", err)
}
router := weave.NewNetworkRouter(config, networkConfig, name, nickName, overlays) router := weave.NewNetworkRouter(config, networkConfig, name, nickName, overlays)
Log.Println("Our name is", router.Ourself) Log.Println("Our name is", router.Ourself)
@@ -405,6 +409,24 @@ func determineQuorum(initPeerCountFlag int, peers []string) uint {
return quorum return quorum
} }
func parseTrustedSubnets(trustedSubnetStr string) ([]*net.IPNet, error) {
trustedSubnets := []*net.IPNet{}
if trustedSubnetStr == "" {
return trustedSubnets, nil
}
for _, subnetStr := range strings.Split(trustedSubnetStr, ",") {
_, subnet, err := net.ParseCIDR(subnetStr)
if err != nil {
return nil, err
}
trustedSubnets = append(trustedSubnets, subnet)
}
return trustedSubnets, nil
}
func listenAndServeHTTP(httpAddr string, muxRouter *mux.Router) { func listenAndServeHTTP(httpAddr string, muxRouter *mux.Router) {
protocol := "tcp" protocol := "tcp"
if strings.HasPrefix(httpAddr, "/") { if strings.HasPrefix(httpAddr, "/") {
+2 -3
View File
@@ -515,9 +515,8 @@ type fastDatapathForwarder struct {
func (fastdp fastDatapathOverlay) PrepareConnection(params mesh.OverlayConnectionParams) (mesh.OverlayConnection, error) { func (fastdp fastDatapathOverlay) PrepareConnection(params mesh.OverlayConnectionParams) (mesh.OverlayConnection, error) {
if params.SessionKey != nil { if params.SessionKey != nil {
// No encryption suport in fastdp. The weaver main.go // No encryption support in fastdp
// is responsible for ensuring this doesn't happen. return nil, fmt.Errorf("encryption not supported")
log.Fatal("Attempt to use FastDatapath with encryption")
} }
vxlanVportID := fastdp.mainVxlanVportID vxlanVportID := fastdp.mainVxlanVportID
+10 -2
View File
@@ -204,8 +204,16 @@ func (osw *OverlaySwitch) PrepareConnection(params mesh.OverlayConnectionParams)
subConn, err := overlay.PrepareConnection(params) subConn, err := overlay.PrepareConnection(params)
if err != nil { if err != nil {
fwd.stopFrom(0) log.Infof("Unable to use %s for connection to %s(%s): %s",
return nil, err overlay.name,
params.RemotePeer.Name,
params.RemotePeer.NickName,
err)
// failed to start subforwarder - record overlay name and continue
fwd.forwarders[i] = subForwarder{
overlayName: overlay.name,
}
continue
} }
subFwd := subConn.(OverlayForwarder) subFwd := subConn.(OverlayForwarder)
+13 -5
View File
@@ -63,7 +63,9 @@ Weave automatically chooses the fastest available method to transport
data between peers. The most performant of these ('fastdp') offers data between peers. The most performant of these ('fastdp') offers
near-native throughput and latency but does not support encryption; near-native throughput and latency but does not support encryption;
consequently supplying a password will cause the router to fall back consequently supplying a password will cause the router to fall back
to a slower mode ('sleeve') that does. to a slower mode ('sleeve') that does, for connections that traverse
untrusted networks (see the [security](#security) section for more
details).
Even when encryption is not in use, certain adverse network conditions Even when encryption is not in use, certain adverse network conditions
will cause this fallback to occur dynamically; in these circumstances, will cause this fallback to occur dynamically; in these circumstances,
@@ -321,10 +323,16 @@ way to generate a random password which satsifies this requirement is
< /dev/urandom tr -dc A-Za-z0-9 | head -c9 ; echo < /dev/urandom tr -dc A-Za-z0-9 | head -c9 ; echo
The same password must be specified for all weave peers. Note that The same password must be specified for all weave peers; by default
supplying a password will [cause weave to fall back to a slower both control and data plane traffic will then use authenticated
method](#fast-data-path) for transporting data between encryption. If some of your peers are colocated in a trusted network
peers. (for example within the boundary of your own datacentre) you can use
the `--trusted-subnets` argument to `weave launch` to selectively
disable data plane encryption as an optimisation. Both peers must
consider the other to be in a trusted subnet for this to take place -
if they do not, weave will [fall back to a slower
method](#fast-data-path) for transporting data between peers as fast
datapath does not support encryption.
Be aware that: Be aware that:
+27 -23
View File
@@ -68,29 +68,30 @@ A status summary can be obtained with `weave status`:
```` ````
$ weave status $ weave status
Version: 1.1.0 Version: 1.1.0
Service: router Service: router
Protocol: weave 1..2 Protocol: weave 1..2
Name: 4a:0f:f6:ec:1c:93(host1) Name: 4a:0f:f6:ec:1c:93(host1)
Encryption: disabled Encryption: disabled
PeerDiscovery: enabled PeerDiscovery: enabled
Targets: [192.168.48.14 192.168.48.15] Targets: [192.168.48.14 192.168.48.15]
Connections: 5 (1 established, 1 pending, 1 retrying, 1 failed, 1 connecting) Connections: 5 (1 established, 1 pending, 1 retrying, 1 failed, 1 connecting)
Peers: 3 (with 5 established, 1 pending connections) Peers: 3 (with 5 established, 1 pending connections)
TrustedSubnets: none
Service: ipam Service: ipam
Consensus: achieved Consensus: achieved
Range: 10.32.0.0-10.47.255.255 Range: 10.32.0.0-10.47.255.255
DefaultSubnet: 10.32.0.0/12 DefaultSubnet: 10.32.0.0/12
Service: dns Service: dns
Domain: weave.local. Domain: weave.local.
TTL: 1 TTL: 1
Entries: 9 Entries: 9
Service: proxy Service: proxy
Address: tcp://127.0.0.1:12375 Address: tcp://127.0.0.1:12375
```` ````
@@ -129,6 +130,9 @@ state. Further details are available with
number of connections peers have to other peers. Further details are number of connections peers have to other peers. Further details are
available with [`weave status peers`](#weave-status-peers). available with [`weave status peers`](#weave-status-peers).
'TrustedSubnets' shows subnets which the router trusts as specified by
the `--trusted-subnets` option to `weave launch`.
There are further sections for the [IP address There are further sections for the [IP address
allocator](ipam.html#troubleshooting), allocator](ipam.html#troubleshooting),
[weaveDNS](weavedns.html#troubleshooting), and [Weave Docker API [weaveDNS](weavedns.html#troubleshooting), and [Weave Docker API
@@ -141,8 +145,8 @@ obtained with `weave status connections`:
```` ````
$ weave status connections $ weave status connections
<- 192.168.48.12:33866 established fastdp 7e:21:4a:70:2f:45(host2) <- 192.168.48.12:33866 established unencrypted fastdp 7e:21:4a:70:2f:45(host2)
<- 192.168.48.13:60773 pending fastdp 7e:ae:cd:d5:23:8d(host3) <- 192.168.48.13:60773 pending encrypted fastdp 7e:ae:cd:d5:23:8d(host3)
-> 192.168.48.14:6783 retrying dial tcp4 192.168.48.14:6783: no route to host -> 192.168.48.14:6783 retrying dial tcp4 192.168.48.14:6783: no route to host
-> 192.168.48.15:6783 failed dial tcp4 192.168.48.15:6783: no route to host, retry: 2015-08-06 18:55:38.246910357 +0000 UTC -> 192.168.48.15:6783 failed dial tcp4 192.168.48.15:6783: no route to host, retry: 2015-08-06 18:55:38.246910357 +0000 UTC
-> 192.168.48.16:6783 connecting -> 192.168.48.16:6783 connecting
@@ -162,8 +166,8 @@ The columns are as follows:
heartbeat heartbeat
* `established` - TCP connection and corresponding UDP path are up * `established` - TCP connection and corresponding UDP path are up
* Info - the failure reason for failed and retrying connections, or * Info - the failure reason for failed and retrying connections, or
the data transport method, remote peer name and nickname for the encryption mode, data transport method, remote peer name and
pending and established connections nickname for pending and established connections
### <a name="weave-status-peers"></a>List peers ### <a name="weave-status-peers"></a>List peers
+3
View File
@@ -14,4 +14,7 @@ start_container $HOST1 $C1/24 --name=c1
start_container $HOST2 $C2/24 --name=c2 start_container $HOST2 $C2/24 --name=c2
assert_raises "exec_on $HOST1 c1 $PING $C2" assert_raises "exec_on $HOST1 c1 $PING $C2"
assert_raises "weave_on $HOST1 status connections | grep encrypted"
assert_raises "weave_on $HOST2 status connections | grep encrypted"
end_suite end_suite
+30
View File
@@ -0,0 +1,30 @@
#!/bin/bash
. ./config.sh
start_suite "Optional encryption via trusted subnets"
# Determine subnet for hosts given either an IP or name. We need to resolve
# these entries on the remote hosts to make sure we get the private
# IP addresses in the Circle/GCE context
HOST1_IP=$($SSH $HOST1 "getent hosts $HOST1" | grep $HOST1 | cut -d ' ' -f 1)
HOST2_IP=$($SSH $HOST2 "getent hosts $HOST2" | grep $HOST2 | cut -d ' ' -f 1)
HOST1_CIDR=$($SSH $HOST1 "ip addr show" | grep -oP $HOST1_IP/[0-9]+)
HOST2_CIDR=$($SSH $HOST2 "ip addr show" | grep -oP $HOST2_IP/[0-9]+)
# Check asymmetric trust - connections should be encrypted
weave_on $HOST1 launch --password wfvAwt7sj --trusted-subnets $HOST2_CIDR
weave_on $HOST2 launch --password wfvAwt7sj $HOST1
assert_raises "weave_on $HOST1 status connections | grep encrypted"
assert_raises "weave_on $HOST2 status connections | grep encrypted"
weave_on $HOST1 stop
weave_on $HOST2 stop
# Check symmetric trust - overlay in plaintext
weave_on $HOST1 launch --password wfvAwt7sj --trusted-subnets $HOST2_CIDR
weave_on $HOST2 launch --password wfvAwt7sj --trusted-subnets $HOST1_CIDR $HOST1
assert_raises "weave_on $HOST1 status connections | grep unencrypted"
assert_raises "weave_on $HOST2 status connections | grep unencrypted"
end_suite
+8 -43
View File
@@ -42,7 +42,8 @@ weave setup
weave version weave version
weave launch [--password <password>] [--nickname <nickname>] weave launch [--password <password>] [--nickname <nickname>]
[--ipalloc-range <cidr> [--ipalloc-default-subnet <cidr>]] [--ipalloc-range <cidr> [--ipalloc-default-subnet <cidr>]]
[--no-discovery] [--init-peer-count <count>] <peer> ... [--no-discovery] [--init-peer-count <count>]
[--trusted-subnets <cidr>,...] <peer> ...
weave launch-router [--password <password>] [--nickname <nickname>] weave launch-router [--password <password>] [--nickname <nickname>]
[--ipalloc-range <cidr> [--ipalloc-default-subnet <cidr>]] [--ipalloc-range <cidr> [--ipalloc-default-subnet <cidr>]]
[--no-discovery] [--init-peer-count <count>] <peer> ... [--no-discovery] [--init-peer-count <count>] <peer> ...
@@ -321,8 +322,6 @@ DATAPATH=datapath
BRIDGE_IFNAME=link-${BRIDGE} BRIDGE_IFNAME=link-${BRIDGE}
DATAPATH_IFNAME=${DATAPATH}-link DATAPATH_IFNAME=${DATAPATH}-link
CONTAINER_IFNAME=ethwe CONTAINER_IFNAME=ethwe
# ROUTER_HOSTNETNS_IFNAME is only used for fastdp with encryption
ROUTER_HOSTNETNS_IFNAME=veth-weave
PORT=${WEAVE_PORT:-6783} PORT=${WEAVE_PORT:-6783}
HTTP_PORT=6784 HTTP_PORT=6784
PROXY_PORT=12375 PROXY_PORT=12375
@@ -765,27 +764,7 @@ ask_version() {
} }
router_opts_fastdp() { router_opts_fastdp() {
if [ -z "$WEAVE_PASSWORD" ] ; then echo "--datapath $DATAPATH"
echo "--datapath $DATAPATH"
else
# When using encryption, we still do bridging on the ODP
# datapath, because you can 'weave launch' without encryption
# and then later restart the router with encryption, or vice
# versa. Encryption disables the use of the fastdp Overlay,
# but the router could still use the fastdp Bridge to receive
# packets. However, pcap has better performance when sniffing
# every packet. So we pass --iface to use the pcap Bridge.
#
# Why don't we simply pass "--iface $BRIDGE". We could,
# except for the fact that NetworkManager likes to down the
# odp $BRIDGE netdev (at least under ubuntu), and you can only
# use pcap on an interface that is up. We avoid that by use
# pcap via a veth pair (NetworkManager leaves them alone).
# Having a netdev in the host netns called "ethwe" might
# surprise people, so it is called $ROUTER_HOSTNETNS_IFNAME
# instead.
echo "--datapath $DATAPATH --iface $ROUTER_HOSTNETNS_IFNAME"
fi
} }
router_opts_bridge() { router_opts_bridge() {
@@ -801,15 +780,7 @@ router_opts_bridged_fastdp() {
###################################################################### ######################################################################
setup_router_iface_fastdp() { setup_router_iface_fastdp() {
if [ -n "$WEAVE_PASSWORD" ] ; then true
# See router_opts_fastdp
# No-op if already attached
if ip link show $LOCAL_IFNAME >/dev/null 2>&1 ; then
return 0
fi
connect_container_to_bridge $ROUTER_HOSTNETNS_IFNAME &&
ip link set $ROUTER_HOSTNETNS_IFNAME up
fi
} }
setup_router_iface_bridge() { setup_router_iface_bridge() {
@@ -1606,8 +1577,6 @@ launch_router() {
if [ "$BRIDGE_TYPE" != bridge ] ; then if [ "$BRIDGE_TYPE" != bridge ] ; then
NETHOST_OPT="--net=host" NETHOST_OPT="--net=host"
HTTP_IP=127.0.0.1 HTTP_IP=127.0.0.1
# In case there is a lingering veth-weave netdev
ip link del $ROUTER_HOSTNETNS_IFNAME >/dev/null 2>&1 || true
fi fi
# Set WEAVE_DOCKER_ARGS in the environment in order to supply # Set WEAVE_DOCKER_ARGS in the environment in order to supply
@@ -1660,10 +1629,6 @@ attach_router() {
stop_router() { stop_router() {
stop $CONTAINER_NAME "Weave" stop $CONTAINER_NAME "Weave"
conntrack -D -p udp --dport $PORT >/dev/null 2>&1 || true conntrack -D -p udp --dport $PORT >/dev/null 2>&1 || true
# Remove the veth-weave netdev in a fastdp context
if detect_bridge_type && [ "$BRIDGE_TYPE" != bridge ] ; then
ip link del $ROUTER_HOSTNETNS_IFNAME >/dev/null 2>&1 || true
fi
} }
launch_proxy() { launch_proxy() {
@@ -1917,13 +1882,13 @@ EOF
fi fi
if [ -z "$SUB_STATUS" ] && check_running $PROXY_CONTAINER_NAME 2>/dev/null && PROXY_ADDRS=$(proxy_addrs) ; then if [ -z "$SUB_STATUS" ] && check_running $PROXY_CONTAINER_NAME 2>/dev/null && PROXY_ADDRS=$(proxy_addrs) ; then
echo echo
echo " Service: proxy" echo " Service: proxy"
echo " Address: $PROXY_ADDRS" echo " Address: $PROXY_ADDRS"
fi fi
if [ -z "$SUB_STATUS" ] && check_running $PLUGIN_CONTAINER_NAME 2>/dev/null ; then if [ -z "$SUB_STATUS" ] && check_running $PLUGIN_CONTAINER_NAME 2>/dev/null ; then
echo echo
echo " Service: plugin" echo " Service: plugin"
echo " DriverName: weave" echo " DriverName: weave"
fi fi
[ -n "$SUB_STATUS" ] || echo [ -n "$SUB_STATUS" ] || echo
[ $res -eq 0 ] [ $res -eq 0 ]