Explorar el Código

Merge pull request #2456 from suwang48404/master

Resolve "bridge fdb show" hang issue
Euan Harris hace 5 años
padre
commit
6b13c00a79
Se han modificado 2 ficheros con 13 adiciones y 1 borrados
  1. 1 0
      libnetwork/support/Dockerfile
  2. 12 1
      libnetwork/support/support.sh

+ 1 - 0
libnetwork/support/Dockerfile

@@ -11,6 +11,7 @@ RUN apk add --no-cache \
     iproute2 \
     ipvsadm \
     conntrack-tools \
+    jq \
     bash
 
 WORKDIR /bin

+ 12 - 1
libnetwork/support/support.sh

@@ -18,6 +18,7 @@ IPTABLES="${IPTABLES:-iptables}"
 IPVSADM="${IPVSADM:-ipvsadm}"
 IP="${IP:-ip}"
 SSDBIN="${SSDBIN:-ssd}"
+JQ="${JQ:-jq}"
 
 networks=0
 containers=0
@@ -53,6 +54,7 @@ type -P ${BRIDGE} > /dev/null || echo "This tool requires bridge"
 type -P ${IPTABLES} > /dev/null || echo "This tool requires iptables"
 type -P ${IPVSADM} > /dev/null || echo "This tool requires ipvsadm"
 type -P ${IP} > /dev/null || echo "This tool requires ip"
+type -P ${JQ} > /dev/null || echo "This tool requires jq"
 
 if ${DOCKER} network inspect --help | grep -q -- --verbose; then
     NETINSPECT_VERBOSE_SUPPORT="--verbose"
@@ -89,7 +91,16 @@ for networkID in $(${DOCKER} network ls --no-trunc --filter driver=overlay -q) "
       echo_and_run ${NSENTER} --net=${i} ${IP} -o -4 address show
       echo_and_run ${NSENTER} --net=${i} ${IP} -4 route show
       echo_and_run ${NSENTER} --net=${i} ${IP} -4 neigh show
-      echo_and_run ${NSENTER} --net=${i} ${BRIDGE} fdb show
+      bridges=$(${NSENTER} --net=${i} ${IP} -j link show type bridge | ${JQ} -r '.[].ifname')
+      # break string to array
+      bridges=(${bridges})
+      for b in "${bridges[@]}"
+      do
+        if [ -z ${b} ] || [ ${b} == "null" ]; then
+          continue
+        fi
+        echo_and_run ${NSENTER} --net=${i} ${BRIDGE} fdb show br ${b}
+      done
       echo_and_run ${NSENTER} --net=${i} ${IPTABLES} -w1 -n -v -L -t filter | grep -v '^$'
       echo_and_run ${NSENTER} --net=${i} ${IPTABLES} -w1 -n -v -L -t nat | grep -v '^$'
       echo_and_run ${NSENTER} --net=${i} ${IPTABLES} -w1 -n -v -L -t mangle | grep -v '^$'