+ovs_vsctl () {
+ ovs-vsctl --no-wait --timeout=5 "$@"
+}
+
+save_datapaths () {
+ if missing_program ovs-dpctl; then
+ echo "$0: ovs-dpctl not found in $PATH" >&2
+ exit 1
+ fi
+ if missing_program ovs-vsctl; then
+ echo "$0: ovs-vsctl not found in $PATH" >&2
+ exit 1
+ fi
+
+ for dp in "$@"; do
+ echo "ovs-dpctl add-dp ${dp}"
+ ovs-dpctl show $dp | while read line; do
+ # An example 'ovs-dpctl show' output looks like this:
+ # system@br1:
+ # lookups: hit:0 missed:0 lost:0
+ # flows: 0
+ # port 0: br1 (internal)
+ # port 2: gre2886795521 (ipsec_gre: key=flow, remote_ip=172.17.1.1, tos=inherit)
+ # port 3: gre1 (ipsec_gre: remote_ip=192.168.113.1)
+ # port 14: gre2 (gre: remote_ip=192.168.115.1)
+ # port 15: gre3 (gre64: remote_ip=192.168.116.1)
+ # port 16: eth0
+ # port 17: br1- (patch: peer=br1+)
+
+ # Skip lines which do not have 'port'
+ if port_no=`expr "${line}" : '.*port \([0-9]\+\):'`; then :; else
+ continue
+ fi
+
+ netdev=`echo ${line} | awk '{print $3}'`
+
+ # Do not add port that has the same name as the datapath. It gets
+ # added by default.
+ [ "${dp#system@}" = "${netdev}" ] && continue
+
+ type=`echo ${line} | awk '{print $4}' | sed 's/[:)(]//g'`
+ [ ! -n "${type}" ] && type="system"
+
+ command="ovs-dpctl add-if ${dp}\
+ ${netdev},type=${type},port_no=${port_no}"
+
+ options=`echo ${line} | awk -F: '{print $3}' | sed 's/[) ]//g'`
+ [ -n "${options}" ] && command="${command},${options}"