1 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2 : Copyright (c) 2019 Mirantis Inc., Enea AB and others.
4 : All rights reserved. This program and the accompanying materials
5 : are made available under the terms of the Apache License, Version 2.0
6 : which accompanies this distribution, and is available at
7 : http://www.apache.org/licenses/LICENSE-2.0
8 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
9 From: Michael Polenchuk <mpolenchuk@mirantis.com>
10 Date: Wed, 28 Feb 2018 17:54:28 +0400
11 Subject: [PATCH] Set ovs bridges as L3 interfaces
13 diff --git a/linux/files/ovs_bridge b/linux/files/ovs_bridge
15 index 0000000..d33864c
17 +++ b/linux/files/ovs_bridge
19 +auto {{ bridge_name }}
20 +allow-ovs {{ bridge_name }}
21 +iface {{ bridge_name }} inet static
23 + address {{ bridge.address }}
24 + netmask {{ bridge.netmask }}
25 + {%- if bridge.use_interfaces is defined %}
26 + ovs_ports {{ bridge.use_interfaces|join(' ') }}
28 + {%- if bridge.datapath_type is defined %}
29 + ovs_extra set Bridge ${IFACE} datapath_type={{ bridge.datapath_type }}
31 + {%- if bridge.gateway is defined %}
32 + gateway {{ bridge.gateway }}
34 + {%- if bridge.name_servers is defined %}
35 + dns-nameservers {{ bridge.name_servers | join(' ') }}
37 diff --git a/linux/files/ovs_port b/linux/files/ovs_port
38 index 222ca8e..03072cd 100644
39 --- a/linux/files/ovs_port
40 +++ b/linux/files/ovs_port
43 +# With systemd, adding OVS bridges as 'auto' can cause race conditions
44 +# https://github.com/openvswitch/ovs/blob/master/debian/openvswitch-switch.README.Debian
45 +# auto {{ port_name }}
46 allow-{{ port.bridge }} {{ port_name }}
47 iface {{ port_name }} inet {{ port.get('proto', 'manual') }}
48 +{%- if '.' in port_name %}
49 +vlan-raw-device {{ port_name.split('.')[0] }}
51 ovs_type {{ port.get('ovs_port_type', 'OVSIntPort') }}
52 mtu {{ port.get('mtu', '1500') }}
53 ovs_bridge {{ port.bridge }}
54 diff --git a/linux/network/interface.sls b/linux/network/interface.sls
55 index a39fc37..c4a94a3 100644
56 --- a/linux/network/interface.sls
57 +++ b/linux/network/interface.sls
58 @@ -92,6 +92,37 @@ add_int_{{ int_name }}_to_ovs_dpdk_bridge_{{ interface_name }}:
59 ovs_bridge_{{ interface_name }}:
60 openvswitch_bridge.present:
61 - name: {{ interface_name }}
62 +{%- if interface.get('proto', 'manual') == 'static' %}
64 + - name: /etc/network/interfaces.u/ifcfg-{{ interface_name }}
66 + - source: salt://linux/files/ovs_bridge
68 + bridge: {{ interface|yaml }}
69 + bridge_name: {{ interface_name }}
72 +linux_interfaces_include_{{ interface_name }}:
74 + - name: /etc/network/interfaces
76 + source /etc/network/interfaces.d/*
77 + # Workaround for Upstream-Bug: https://github.com/saltstack/salt/issues/40262
78 + source /etc/network/interfaces.u/*
80 +ovs_bridge_up_{{ interface_name }}:
82 + - name: ifup --ignore-errors {{ interface_name }}
84 + - file: ovs_bridge_{{ interface_name }}
85 + - openvswitch_bridge: ovs_bridge_{{ interface_name }}
86 + - file: linux_interfaces_final_include
87 + {%- if network.noifupdown|d(false) or interface.noifupdown|d(false) %}
88 + - onlyif: /bin/false
90 + - unless: ip link show {{ interface_name }} | grep -q '\<UP\>'
94 {# add linux network interface into OVS bridge #}
95 {%- for int_name, int in network.interface.items() %}
96 @@ -176,6 +207,9 @@ ovs_port_{{ interface_name }}_line2:
97 ovs_port_up_{{ interface_name }}:
99 - name: ifup {{ interface_name }}
100 + {%- if network.noifupdown|d(false) or interface.noifupdown|d(false) %}
101 + - onlyif: /bin/false
104 - file: ovs_port_{{ interface_name }}
105 - file: ovs_port_{{ interface_name }}_line1