On 02/12/2016 08:12 PM, Darrell Ball wrote:
> Signed-off-by: Darrell Ball <db...@vmware.com>
> ---
>  vtep/ovs-vtep | 20 ++++++++++++++++++--
>  1 file changed, 18 insertions(+), 2 deletions(-)
> 
> diff --git a/vtep/ovs-vtep b/vtep/ovs-vtep
> index 46a5692..54bf0db 100755
> --- a/vtep/ovs-vtep
> +++ b/vtep/ovs-vtep
> @@ -135,15 +135,31 @@ class Logical_Switch(object):
>              ovs_ofctl("add-flow %s table=1,priority=1,in_port=%s,action=%s"
>                          % (self.short_name, port_no, ",".join(flood_ports)))
>  
> +        existing_flow = 0
> +        appended_flood_tunnel_port = 0

I would use the boolean type, instead.  Instead of 0, set these both to
False.

> +        flows = ovs_ofctl("dump-flows %s table=1,cookie=0x4848/-1"
> +                  % self.short_name).splitlines()
> +        for f in flows:
> +            if ("table" in f):

These parenthesis can be removed.

> +               existing_flow = 1

    existing_flow = True

> +               break
> +

If you're just looking for "table" somewhere in the output, there's no
need to split it up into lines first.  This should be sufficient.

Remove .splitlines() and you can replace the for loop with:

    existing_flow = flows.find('table') > -1

>          # Traffic coming from a VTEP physical port should only be flooded to
>          # one 'unknown-dst' and to all other physical ports that belong to 
> that
>          # VTEP device and this logical switch.
>          for tunnel in self.unknown_dsts:
>              port_no = self.tunnels[tunnel][0]
>              flood_ports.append(port_no)
> +            appended_flood_tunnel_port = 1

    appended_flood_tunnel_port = True

>              break
> -
> -        ovs_ofctl("add-flow %s table=1,priority=0,action=%s"
> +        # Handle remote tunnel port set changes
> +        if ((existing_flow == 1) and (appended_flood_tunnel_port == 1)):

    if existing_flow and appended_flood_tunnel_port:

> +            ovs_ofctl(
> +                  "mod-flows %s 
> table=1,priority=0,cookie=0x4848/-1,action=%s"
> +                  % (self.short_name, ",".join(flood_ports)))
> +        elif (existing_flow == 0):

    elif not existing_flow:

> +            ovs_ofctl(
> +                  "add-flow %s table=1,priority=0,cookie=0x4848,action=%s"
>                    % (self.short_name, ",".join(flood_ports)))
>  
>      def add_lbinding(self, lbinding):
> 


-- 
Russell Bryant
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to