From 27aadd67e05632afb86e97a39f775c0a1cc5f81f Mon Sep 17 00:00:00 2001 From: Hyunsun Moon Date: Wed, 25 Oct 2017 09:42:27 +0900 Subject: [PATCH] openvswitch: Move IP address from physical device to bridge A physical ethernet device that is part of an Open vSwitch bridge should not have an IP address. This patch restores the IP address by moving it to the bridge itself. Change-Id: I9100a65ecfbb0433a55449178d06879509d01987 --- .../templates/bin/_openvswitch-vswitchd.sh.tpl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/openvswitch/templates/bin/_openvswitch-vswitchd.sh.tpl b/openvswitch/templates/bin/_openvswitch-vswitchd.sh.tpl index 61364aa1a6..5d4e15c42e 100644 --- a/openvswitch/templates/bin/_openvswitch-vswitchd.sh.tpl +++ b/openvswitch/templates/bin/_openvswitch-vswitchd.sh.tpl @@ -47,6 +47,12 @@ if [ -n "${external_bridge}" ] ; then # add external interface to the bridge ovs-vsctl --no-wait --may-exist add-port $external_bridge $external_interface ip link set dev $external_interface up + ip link set dev $external_bridge up + # move ip address from physical interface to the bridge + for IP in $(ip addr show dev $external_interface | grep ' inet ' | awk '{print $2}'); do + ip addr add $IP dev $external_bridge + ip addr del $IP dev $external_interface + done fi fi @@ -58,6 +64,12 @@ if [ -n "{{- $br -}}" ] ; then if [ -n "{{- $phys -}}" ] ; then ovs-vsctl --no-wait --may-exist add-port "{{ $br }}" "{{ $phys }}" ip link set dev "{{ $phys }}" up + ip link set dev "{{ $br }}" up + # move ip address from physical interface to the bridge + for IP in $(ip addr show dev "{{ $phys }}" | grep ' inet ' | awk '{print $2}'); do + ip addr add $IP dev "{{ $br }}" + ip addr del $IP dev "{{ $phys }}" + done fi fi {{- end }}