The output of "bridge fdb show" command invoked under a network
namespace is unpredicable. Sometime it returns empty, and sometime
non-stop rolling output. This perhaps is a bug in kernel
and/or iproute2 implementation. To work around, display fdb for
each bridge.
Signed-off-by: Su Wang <su.wang@docker.com>
| ... | ... |
@@ -18,6 +18,7 @@ IPTABLES="${IPTABLES:-iptables}"
|
| 18 | 18 |
IPVSADM="${IPVSADM:-ipvsadm}"
|
| 19 | 19 |
IP="${IP:-ip}"
|
| 20 | 20 |
SSDBIN="${SSDBIN:-ssd}"
|
| 21 |
+JQ="${JQ:-jq}"
|
|
| 21 | 22 |
|
| 22 | 23 |
networks=0 |
| 23 | 24 |
containers=0 |
| ... | ... |
@@ -53,6 +54,7 @@ type -P ${BRIDGE} > /dev/null || echo "This tool requires bridge"
|
| 53 | 53 |
type -P ${IPTABLES} > /dev/null || echo "This tool requires iptables"
|
| 54 | 54 |
type -P ${IPVSADM} > /dev/null || echo "This tool requires ipvsadm"
|
| 55 | 55 |
type -P ${IP} > /dev/null || echo "This tool requires ip"
|
| 56 |
+type -P ${JQ} > /dev/null || echo "This tool requires jq"
|
|
| 56 | 57 |
|
| 57 | 58 |
if ${DOCKER} network inspect --help | grep -q -- --verbose; then
|
| 58 | 59 |
NETINSPECT_VERBOSE_SUPPORT="--verbose" |
| ... | ... |
@@ -89,7 +91,16 @@ for networkID in $(${DOCKER} network ls --no-trunc --filter driver=overlay -q) "
|
| 89 | 89 |
echo_and_run ${NSENTER} --net=${i} ${IP} -o -4 address show
|
| 90 | 90 |
echo_and_run ${NSENTER} --net=${i} ${IP} -4 route show
|
| 91 | 91 |
echo_and_run ${NSENTER} --net=${i} ${IP} -4 neigh show
|
| 92 |
- echo_and_run ${NSENTER} --net=${i} ${BRIDGE} fdb show
|
|
| 92 |
+ bridges=$(${NSENTER} --net=${i} ${IP} -j link show type bridge | ${JQ} -r '.[].ifname')
|
|
| 93 |
+ # break string to array |
|
| 94 |
+ bridges=(${bridges})
|
|
| 95 |
+ for b in "${bridges[@]}"
|
|
| 96 |
+ do |
|
| 97 |
+ if [ -z ${b} ] || [ ${b} == "null" ]; then
|
|
| 98 |
+ continue |
|
| 99 |
+ fi |
|
| 100 |
+ echo_and_run ${NSENTER} --net=${i} ${BRIDGE} fdb show br ${b}
|
|
| 101 |
+ done |
|
| 93 | 102 |
echo_and_run ${NSENTER} --net=${i} ${IPTABLES} -w1 -n -v -L -t filter | grep -v '^$'
|
| 94 | 103 |
echo_and_run ${NSENTER} --net=${i} ${IPTABLES} -w1 -n -v -L -t nat | grep -v '^$'
|
| 95 | 104 |
echo_and_run ${NSENTER} --net=${i} ${IPTABLES} -w1 -n -v -L -t mangle | grep -v '^$'
|