[ovs-dev] [PATCH] ovs-docker : add fake bridges support.
Gurucharan Shetty
shettyg at nicira.com
Wed Dec 17 21:18:49 UTC 2014
On Wed, Dec 17, 2014 at 12:56 PM, Paul-Emmanuel Raoul
<skyper205 at gmail.com> wrote:
> From 7b693f8f8b5028e445c116531d9d960603222e06 Mon Sep 17 00:00:00 2001
> From: Paul-Emmanuel Raoul <skyper at skyplabs.net>
> Date: Wed, 17 Dec 2014 02:25:30 +0100
> Subject: [PATCH] ovs-docker : add fake bridges support.
>
> Also updates ovs-docker README documentation.
>
> Signed-off-by: Paul-Emmanuel Raoul <skyper at skyplabs.net>
Can you please tell me the usecase for a 'fake bridge' and why you
feel that we need it inside the 'ovs-docker' script? I imagine that a
'fake bridge' can be created asynchronously by simply using ovs-vsctl,
no? The only reason a bridge is created right now inside the
ovs-docker script is to prevent an error if someone executes this
script without previously having created any bridge. I would like to
avoid overloading the 'add-port' command.
> ---
> INSTALL.Docker.md | 9 +++++++++
> utilities/ovs-docker | 51
> ++++++++++++++++++++++++++++++++++++++-------------
> 2 files changed, 47 insertions(+), 13 deletions(-)
>
> diff --git a/INSTALL.Docker.md b/INSTALL.Docker.md
> index ddbef99..29b3a70 100644
> --- a/INSTALL.Docker.md
> +++ b/INSTALL.Docker.md
> @@ -56,10 +56,19 @@ and then attaches it to the Open vSwitch bridge
> 'br-int'. This is done by
> creating a veth pair. One end of the interface becomes 'eth1' inside
> the
> container and the other end attaches to 'br-int'.
>
> +If an Open vSwitch fake bridge should be used, you have to specify its
> +parent and VLAN. e.g.:
> +
> +`% ovs-docker add-port br-int br-parent 10 eth1 $CONTAINER_ID`
> +
> The script also lets one to add an IP address to the interface. e.g.:
>
> `% ovs-docker add-port br-int eth1 $CONTAINER_ID 192.168.1.1/24`
>
> +The previous two options can be combined :
> +
> +`% ovs-docker add-port br-int br-parent 10 eth1 $CONTAINER_ID
> 192.168.1.1/24`
> +
> * A previously added network interface can be deleted. e.g.:
>
> `% ovs-docker del-port br-int eth1 $CONTAINER_ID`
> diff --git a/utilities/ovs-docker b/utilities/ovs-docker
> index 4a43a15..e2c306d 100755
> --- a/utilities/ovs-docker
> +++ b/utilities/ovs-docker
> @@ -43,20 +43,44 @@ delete_netns_link () {
> }
>
> add_port () {
> - BRIDGE="$1"
> - INTERFACE="$2"
> - CONTAINER="$3"
> - ADDRESS="$4"
> -
> if [ "$#" -lt 3 ]; then
> usage
> exit 1
> + elif [ "$#" -eq 3 ]; then
> + BRIDGE="$1"
> + INTERFACE="$2"
> + CONTAINER="$3"
> + elif [ "$#" -eq 4 ]; then
> + BRIDGE="$1"
> + INTERFACE="$2"
> + CONTAINER="$3"
> + ADDRESS="$4"
> + elif [ "$#" -eq 5 ]; then
> + BRIDGE="$1"
> + PARENT="$2"
> + VLAN="$3"
> + INTERFACE="$4"
> + CONTAINER="$5"
> + elif [ "$#" -eq 6 ]; then
> + BRIDGE="$1"
> + PARENT="$2"
> + VLAN="$3"
> + INTERFACE="$4"
> + CONTAINER="$5"
> + ADDRESS="$6"
> fi
>
> - if ovs_vsctl --may-exist add-br "$BRIDGE"; then :; else
> - echo >&2 "$UTIL: Failed to create bridge $BRIDGE"
> - exit 1
> - fi
> + if [ -n "$PARENT" ]; then
> + if ovs_vsctl --may-exist add-br "$BRIDGE" "$PARENT" "$VLAN"; then :;
> else
> + echo >&2 "$UTIL: Failed to create fake bridge $BRIDGE"
> + exit 1
> + fi
> + else
> + if ovs_vsctl --may-exist add-br "$BRIDGE"; then :; else
> + echo >&2 "$UTIL: Failed to create bridge $BRIDGE"
> + exit 1
> + fi
> + fi
>
> if PID=`docker inspect -f '{{.State.Pid}}' "$CONTAINER"`; then :;
> else
> echo >&2 "$UTIL: Failed to get the PID of the container"
> @@ -142,11 +166,12 @@ ${UTIL}: Performs integration of Open vSwitch with
> Docker.
> usage: ${UTIL} COMMAND
>
> Commands:
> - add-port BRIDGE INTERFACE CONTAINER [ADDRESS]
> + add-port BRIDGE [PARENT] [VLAN] INTERFACE CONTAINER [ADDRESS]
> Adds INTERFACE inside CONTAINER and connects it as
> a port
> - in Open vSwitch BRIDGE. Optionally, sets ADDRESS on
> - INTERFACE. ADDRESS can include a '/' to represent
> network
> - prefix length. e.g.:
> + in Open vSwitch BRIDGE. If BRIDGE is a fake bridge,
> you
> + have to specify its PARENT and VLAN. Optionally,
> sets
> + ADDRESS on INTERFACE. ADDRESS can include a '/' to
> + represent network prefix length. e.g.:
> ${UTIL} add-port br-int eth1 c474a0e2830e
> 192.168.1.2/24
> del-port BRIDGE INTERFACE CONTAINER
> Deletes INTERFACE inside CONTAINER and removes its
> --
> 1.9.3
>
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
More information about the dev
mailing list