1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/libnetwork/support.sh
Trapier Marshall 1b49b17ef5 wait for iptables lock in support script
Addresses failure to collect iptables information if lock is held during
data capture. Follows the reccomendation of iptables stderr in this
scenario:

```
Another app is currently holding the xtables lock. Perhaps you want to
use the -w option?
```

Signed-off-by: Trapier Marshall <trapier.marshall@docker.com>
2017-10-24 12:35:26 -04:00

37 lines
1.1 KiB
Bash
Executable file

#!/usr/bin/env bash
# Required tools
DOCKER="${DOCKER:-docker}"
NSENTER="${NSENTER:-nsenter}"
BRIDGE="${BRIDGE:-bridge}"
BRCTL="${BRCTL:-brctl}"
IPTABLES="${IPTABLES:-iptables}"
NSDIR=/var/run/docker/netns
BRIDGEIF=br0
function die {
echo $*
exit 1
}
type -P ${DOCKER} > /dev/null || die "This tool requires the docker binary"
type -P ${NSENTER} > /dev/null || die "This tool requires nsenter"
type -P ${BRIDGE} > /dev/null || die "This tool requires bridge"
type -P ${BRCTL} > /dev/null || die "This tool requires brctl"
type -P ${IPTABLES} > /dev/null || die "This tool requires iptables"
echo "iptables configuration"
${IPTABLES} -w1 -n -v -L -t filter
${IPTABLES} -w1 -n -v -L -t nat
echo ""
echo "Overlay network configuration"
for networkID in $(${DOCKER} network ls --filter driver=overlay -q) ; do
echo "Network ${networkID}"
nspath=(${NSDIR}/*-$(echo ${networkID}| cut -c1-10))
${DOCKER} network inspect -v ${networkID}
${NSENTER} --net=${nspath[0]} ${BRIDGE} fdb show ${BRIDGEIF}
${NSENTER} --net=${nspath[0]} ${BRCTL} showmacs ${BRIDGEIF}
echo ""
done