Compare commits

...
12 Commits
Author SHA1 Message Date
Bryan Boreham e0348233af Add release v2.6.5 2020-06-10 13:41:13 +00:00
Bryan Boreham 495bea8890 Merge pull request #3808 from weaveworks/stop-switch-fwd
router: tell goroutine to exit when forwarder is stopped
2020-06-10 14:07:41 +01:00
Bryan Boreham 3d79b07dba Merge pull request #3815 from weaveworks/ignore-ipv6-not-found
Don't exit if machine has no ipv6 installed
2020-06-04 18:47:28 +01:00
Bryan Boreham 27f8f9092f router: tell goroutine to exit when forwarder is stopped
Otherwise a goroutine is leaked each time a connection is closed.
2020-06-04 17:46:18 +00:00
Bryan Boreham 7174738d9d Don't exit if machine has no ipv6 installed
We are trying to turn off `accept_ra`, so if we get an error that the
option doesn't exist we can just ignore it.
2020-06-04 16:12:38 +00:00
Bryan Boreham 9be65b466b Merge pull request #3812 from weaveworks/improve-test-840
Kubernetes smoke-test improvements
2020-05-30 13:13:28 +01:00
Bryan Boreham c7a235a54a Add release v2.6.4 2020-05-30 10:11:08 +00:00
Bryan Boreham bef50d3730 Merge pull request #3811 from weaveworks/allow-dnat-127
Only drop traffic to the Weave Net port on 127.0.0.1
2020-05-30 11:07:13 +01:00
Bryan Boreham d45579bf82 Allow time for network policy changes to take effect
Also change from waiting longer to polling until connections are
established after restarting Weave Net.
2020-05-29 19:59:13 +00:00
Bryan Boreham a46d18da0c Use a more targeted iptables rule to block access to control port
Only block the specific port Weave Net is listening on.
Add a comment so users know what the rule is for.

Remove the rule added in v2.6.3 because it was too coarse.
2020-05-29 19:58:41 +00:00
Bryan Boreham 95c020fbe0 Merge pull request #3809 from weaveworks/move-ansible-install
Move ansible install out from every CI run
2020-05-29 20:58:05 +01:00
Bryan Boreham 7c2084b9af Move ansible install out from every CI run
to only where we create images.
2020-05-29 13:33:30 +00:00
10 changed files with 69 additions and 18 deletions

No files matched your search

+13
View File
@@ -1,3 +1,16 @@
## Release 2.6.5
Fixes a bug that would leak memory every time a fast-datapath connection
was stopped. #3808
Also avoid a crash when the machine has ipv6 disabled. #3815
## Release 2.6.4
Improves the iptables rule added in 2.6.3 to block just the Weave Net
control port and avoid blocking other uses of 127.0.0.1. #3811
## Release 2.6.3 ## Release 2.6.3
This release has a couple of security improvements, and some other fixes. This release has a couple of security improvements, and some other fixes.
-8
View File
@@ -13,13 +13,6 @@ function install_terraform() {
curl -fsS https://releases.hashicorp.com/terraform/0.11.14/terraform_0.11.14_linux_amd64.zip | gunzip >terraform && chmod +x terraform && sudo mv terraform /usr/bin curl -fsS https://releases.hashicorp.com/terraform/0.11.14/terraform_0.11.14_linux_amd64.zip | gunzip >terraform && chmod +x terraform && sudo mv terraform /usr/bin
} }
function install_ansible() {
sudo apt-get update || true
sudo apt-get install -qq -y python-pip python-dev libffi-dev libssl-dev \
&& pip install --user -U setuptools cffi \
&& pip install --user ansible
}
[ -n "$SECRET_KEY" ] || { [ -n "$SECRET_KEY" ] || {
echo "Cannot run smoke tests: no secret key" echo "Cannot run smoke tests: no secret key"
exit 1 exit 1
@@ -28,7 +21,6 @@ function install_ansible() {
source "$SRCDIR/bin/circle-env" source "$SRCDIR/bin/circle-env"
install_terraform install_terraform
install_ansible
# Only attempt to create GCP image in first container, wait for it to be created otherwise: # Only attempt to create GCP image in first container, wait for it to be created otherwise:
[ "$CIRCLE_NODE_INDEX" != "0" ] && export CREATE_IMAGE=0 [ "$CIRCLE_NODE_INDEX" != "0" ] && export CREATE_IMAGE=0
+8
View File
@@ -41,3 +41,11 @@ func sysctl(procPath, variable, value string) error {
return nil return nil
} }
func sysctlIfExists(procPath, variable, value string) error {
err := sysctl(procPath, variable, value)
if err != nil && os.IsNotExist(err) {
err = nil // ignore 'not found' errors
}
return err
}
+12 -4
View File
@@ -221,6 +221,7 @@ type BridgeConfig struct {
MTU int MTU int
Mac string Mac string
Port int Port int
ControlPort string
NoMasqLocal bool NoMasqLocal bool
} }
@@ -280,7 +281,7 @@ func EnsureBridge(procPath string, config *BridgeConfig, log *logrus.Logger, ips
} }
} }
// No ipv6 router advertisments please // No ipv6 router advertisments please
if err := sysctl(procPath, "net/ipv6/conf/"+config.WeaveBridgeName+"/accept_ra", "0"); err != nil { if err := sysctlIfExists(procPath, "net/ipv6/conf/"+config.WeaveBridgeName+"/accept_ra", "0"); err != nil {
return bridgeType, errors.Wrap(err, "setting accept_ra to 0") return bridgeType, errors.Wrap(err, "setting accept_ra to 0")
} }
@@ -469,10 +470,17 @@ func configureIPTables(config *BridgeConfig, ips ipset.Interface) error {
} }
} }
// Block non-local traffic to the Weave control port if config.ControlPort != "" {
if err = ipt.AppendUnique("filter", "INPUT", "-p", "tcp", "--dst", "127.0.0.1", "-m", "addrtype", "!", "--src-type", "LOCAL", "-m", "conntrack", "!", "--ctstate", "RELATED,ESTABLISHED", "-j", "DROP"); err != nil { if err = ipt.AppendUnique("filter", "INPUT", "-p", "tcp", "--dst", "127.0.0.1", "--dport", config.ControlPort,
return err "-m", "addrtype", "!", "--src-type", "LOCAL",
"-m", "conntrack", "!", "--ctstate", "RELATED,ESTABLISHED",
"-m", "comment", "--comment", "Block non-local access to Weave Net control port",
"-j", "DROP"); err != nil {
return err
}
} }
// Remove the rule from Weave Net 2.6.3 which dropped too much.
_ = ipt.Delete("filter", "INPUT", "-p", "tcp", "--dst", "127.0.0.1", "-m", "addrtype", "!", "--src-type", "LOCAL", "-m", "conntrack", "!", "--ctstate", "RELATED,ESTABLISHED", "-j", "DROP")
if config.NPC { if config.NPC {
// Steer traffic via the NPC. // Steer traffic via the NPC.
+2 -2
View File
@@ -50,10 +50,10 @@ func CreateAndAttachVeth(procPath, name, peerName, bridgeName string, mtu int, k
return cleanup("attaching veth %q to %q: %s", name, bridgeName, err) return cleanup("attaching veth %q to %q: %s", name, bridgeName, err)
} }
// No ipv6 router advertisments please // No ipv6 router advertisments please
if err := sysctl(procPath, "net/ipv6/conf/"+name+"/accept_ra", "0"); err != nil { if err := sysctlIfExists(procPath, "net/ipv6/conf/"+name+"/accept_ra", "0"); err != nil {
return cleanup("setting accept_ra to 0: %s", err) return cleanup("setting accept_ra to 0: %s", err)
} }
if err := sysctl(procPath, "net/ipv6/conf/"+peerName+"/accept_ra", "0"); err != nil { if err := sysctlIfExists(procPath, "net/ipv6/conf/"+peerName+"/accept_ra", "0"); err != nil {
return cleanup("setting accept_ra to 0: %s", err) return cleanup("setting accept_ra to 0: %s", err)
} }
if !bridgeType.IsFastdp() && !keepTXOn { if !bridgeType.IsFastdp() && !keepTXOn {
+5
View File
@@ -307,6 +307,11 @@ func main() {
bridgeConfig.Mac = name.String() bridgeConfig.Mac = name.String()
bridgeConfig.Port = config.Port bridgeConfig.Port = config.Port
if httpAddr != "" {
if _, port, err := net.SplitHostPort(httpAddr); err == nil {
bridgeConfig.ControlPort = port
}
}
ips := ipset.New(common.LogLogger(), 0) ips := ipset.New(common.LogLogger(), 0)
bridgeType, err := weavenet.EnsureBridge(procPath, &bridgeConfig, Log, ips) bridgeType, err := weavenet.EnsureBridge(procPath, &bridgeConfig, Log, ips)
checkFatal(err) checkFatal(err)
+1
View File
@@ -452,6 +452,7 @@ func (fwd *overlaySwitchForwarder) Stop() {
fwd.lock.Lock() fwd.lock.Lock()
defer fwd.lock.Unlock() defer fwd.lock.Unlock()
fwd.stopFrom(0) fwd.stopFrom(0)
close(fwd.stopChan)
} }
func (fwd *overlaySwitchForwarder) ControlMessage(tag byte, msg []byte) { func (fwd *overlaySwitchForwarder) ControlMessage(tag byte, msg []byte) {
+17 -2
View File
@@ -54,7 +54,7 @@ sed -e "s%imagePullPolicy: Always%imagePullPolicy: Never%" \
-e "s%env:%$WEAVE_ENV_VARS%" \ -e "s%env:%$WEAVE_ENV_VARS%" \
"$(dirname "$0")/../prog/weave-kube/weave-daemonset-k8s-1.9.yaml" | run_on "$HOST1" "$KUBECTL apply -n kube-system -f -" "$(dirname "$0")/../prog/weave-kube/weave-daemonset-k8s-1.9.yaml" | run_on "$HOST1" "$KUBECTL apply -n kube-system -f -"
sleep 5 sleep 2
check_connections() { check_connections() {
run_on $HOST1 "curl -sS http://127.0.0.1:6784/status | grep \"$SUCCESS\"" run_on $HOST1 "curl -sS http://127.0.0.1:6784/status | grep \"$SUCCESS\""
@@ -247,6 +247,9 @@ spec:
- namespaceSelector: {} - namespaceSelector: {}
EOF EOF
# Allow some time for the policy change to take effect
sleep 2
# Should be able to access from the "deny" pod now # Should be able to access from the "deny" pod now
assert_raises "$SSH $HOST1 $KUBECTL exec $denyPodName -- curl -s -S -f -m 2 http://$DOMAIN:8080/status >/dev/null" assert_raises "$SSH $HOST1 $KUBECTL exec $denyPodName -- curl -s -S -f -m 2 http://$DOMAIN:8080/status >/dev/null"
@@ -270,6 +273,7 @@ spec:
cidr: $HOST1EXPIP/32 cidr: $HOST1EXPIP/32
EOF EOF
# Allow some time for the policy change to take effect
sleep 2 sleep 2
assert_raises "$SSH $HOST1 curl -s -S -f -m 2 http://$VIRTUAL_IP/status >/dev/null" assert_raises "$SSH $HOST1 curl -s -S -f -m 2 http://$VIRTUAL_IP/status >/dev/null"
@@ -289,6 +293,9 @@ spec:
- {} - {}
EOF EOF
# Allow some time for the policy change to take effect
sleep 2
# Virtual IP and NodePort should now work # Virtual IP and NodePort should now work
assert_raises "$SSH $HOST1 curl -s -S -f -m 2 http://$VIRTUAL_IP/status >/dev/null" assert_raises "$SSH $HOST1 curl -s -S -f -m 2 http://$VIRTUAL_IP/status >/dev/null"
assert_raises "$SSH $HOST1 curl -s -S -f -m 2 http://$HOST2:31138/status >/dev/null" assert_raises "$SSH $HOST1 curl -s -S -f -m 2 http://$HOST2:31138/status >/dev/null"
@@ -314,6 +321,9 @@ spec:
- 8.8.8.4/32 - 8.8.8.4/32
EOF EOF
# Allow some time for the policy change to take effect
sleep 2
assert_raises "! $SSH $HOST1 $KUBECTL exec $denyPodName -- curl -s -S -f -m 2 http://$DOMAIN:8080/status >/dev/null" assert_raises "! $SSH $HOST1 $KUBECTL exec $denyPodName -- curl -s -S -f -m 2 http://$DOMAIN:8080/status >/dev/null"
assert_raises "! $SSH $HOST1 $KUBECTL exec $denyPodName -- dig @8.8.8.4 google.com >/dev/null" assert_raises "! $SSH $HOST1 $KUBECTL exec $denyPodName -- dig @8.8.8.4 google.com >/dev/null"
assert_raises "$SSH $HOST1 $KUBECTL exec $denyPodName -- dig @8.8.8.8 google.com >/dev/null" assert_raises "$SSH $HOST1 $KUBECTL exec $denyPodName -- dig @8.8.8.8 google.com >/dev/null"
@@ -346,6 +356,9 @@ spec:
name: kube-system name: kube-system
EOF EOF
# Allow some time for the policy change to take effect
sleep 2
assert_raises "$SSH $HOST1 $KUBECTL exec $denyPodName -- curl -s -S -f -m 2 http://$DOMAIN:8080/status >/dev/null" assert_raises "$SSH $HOST1 $KUBECTL exec $denyPodName -- curl -s -S -f -m 2 http://$DOMAIN:8080/status >/dev/null"
# Passing --no-masq-local and setting externalTrafficPolicy to Local must preserve # Passing --no-masq-local and setting externalTrafficPolicy to Local must preserve
@@ -359,10 +372,12 @@ sed -e "s%imagePullPolicy: Always%imagePullPolicy: Never%" \
-e "s%env:%$WEAVE_ENV_VARS%" \ -e "s%env:%$WEAVE_ENV_VARS%" \
"$(dirname "$0")/../prog/weave-kube/weave-daemonset-k8s-1.9.yaml" | run_on "$HOST1" "$KUBECTL apply -n kube-system -f -" "$(dirname "$0")/../prog/weave-kube/weave-daemonset-k8s-1.9.yaml" | run_on "$HOST1" "$KUBECTL apply -n kube-system -f -"
sleep 5 sleep 2
assert_raises 'wait_for_x check_connections "connections to establish"'
run_on $HOST1 "$KUBECTL patch svc netvirt -p '{\"spec\":{\"externalTrafficPolicy\":\"Local\"}}'" run_on $HOST1 "$KUBECTL patch svc netvirt -p '{\"spec\":{\"externalTrafficPolicy\":\"Local\"}}'"
sleep 2
CLIENT_IP_NO_MASQ="$($SSH $HOST1 curl -sS http://$HOST2:31138/client_ip)" CLIENT_IP_NO_MASQ="$($SSH $HOST1 curl -sS http://$HOST2:31138/client_ip)"
assert_raises "[ $CLIENT_IP_NO_MASQ != $CLIENT_IP_MASQ ]" assert_raises "[ $CLIENT_IP_NO_MASQ != $CLIENT_IP_MASQ ]"
+10 -1
View File
@@ -66,7 +66,7 @@ function print_vars() {
} }
function verify_dependencies() { function verify_dependencies() {
local deps=(python terraform ansible-playbook gcloud) local deps=(python terraform gcloud)
for dep in "${deps[@]}"; do for dep in "${deps[@]}"; do
if [ ! "$(which "$dep")" ]; then if [ ! "$(which "$dep")" ]; then
echo >&2 "$dep is not installed or not in PATH." echo >&2 "$dep is not installed or not in PATH."
@@ -141,9 +141,18 @@ function wait_for_image() {
exit 1 exit 1
} }
function install_ansible() {
sudo apt-get update || true
sudo apt-get install -qq -y python-pip python-dev libffi-dev libssl-dev \
&& pip install --user -U setuptools cffi \
&& pip install --user ansible
}
# shellcheck disable=SC2155 # shellcheck disable=SC2155
function create_image() { function create_image() {
if [[ "$CREATE_IMAGE" == 1 ]]; then if [[ "$CREATE_IMAGE" == 1 ]]; then
install_ansible
greenly echo "> Creating GCP image $IMAGE_NAME..." greenly echo "> Creating GCP image $IMAGE_NAME..."
local begin_img=$(date +%s) local begin_img=$(date +%s)
local num_hosts=1 local num_hosts=1
+1 -1
View File
@@ -483,7 +483,7 @@ destroy_bridge() {
[ -n "$DOCKER_BRIDGE_IP" ] || DOCKER_BRIDGE_IP=$(util_op bridge-ip $DOCKER_BRIDGE) [ -n "$DOCKER_BRIDGE_IP" ] || DOCKER_BRIDGE_IP=$(util_op bridge-ip $DOCKER_BRIDGE)
run_iptables -t filter -D INPUT -d 127.0.0.1/32 -p tcp -m addrtype ! --src-type LOCAL -m conntrack ! --ctstate RELATED,ESTABLISHED -j DROP >/dev/null 2>&1 || true run_iptables -t filter -D INPUT -d 127.0.0.1/32 -p tcp --dport 6784 -m addrtype ! --src-type LOCAL -m conntrack ! --ctstate RELATED,ESTABLISHED -m comment --comment "Block non-local access to Weave Net control port" -j DROP >/dev/null 2>&1 || true
run_iptables -t filter -D INPUT -i $DOCKER_BRIDGE -p udp --dport 53 -j ACCEPT >/dev/null 2>&1 || true run_iptables -t filter -D INPUT -i $DOCKER_BRIDGE -p udp --dport 53 -j ACCEPT >/dev/null 2>&1 || true
run_iptables -t filter -D INPUT -i $DOCKER_BRIDGE -p tcp --dport 53 -j ACCEPT >/dev/null 2>&1 || true run_iptables -t filter -D INPUT -i $DOCKER_BRIDGE -p tcp --dport 53 -j ACCEPT >/dev/null 2>&1 || true