From 24950b3894039d8f42ebaa6a6696d6a2e3d91b95 Mon Sep 17 00:00:00 2001
From: wuchunyang <wuchunyang@yovole.com>
Date: Mon, 26 Apr 2021 21:00:58 +0800
Subject: [PATCH] Fix incorrect config of linuxbridge multiple external
 networks

multiple external networks are supported by linuxbridge and OVS.
Currently the config template only works for OVS

Closes-Bug: #1863935
Change-Id: I9da331e007c25c4a760839c566831769a68507a9
---
 ansible/roles/neutron/templates/linuxbridge_agent.ini.j2    | 4 +++-
 ansible/roles/neutron/templates/ml2_conf.ini.j2             | 2 +-
 releasenotes/notes/linux-bridge-multi-fe8576616fb7d373.yaml | 6 ++++++
 3 files changed, 10 insertions(+), 2 deletions(-)
 create mode 100644 releasenotes/notes/linux-bridge-multi-fe8576616fb7d373.yaml

diff --git a/ansible/roles/neutron/templates/linuxbridge_agent.ini.j2 b/ansible/roles/neutron/templates/linuxbridge_agent.ini.j2
index f33a133b08..1dbaae0ede 100644
--- a/ansible/roles/neutron/templates/linuxbridge_agent.ini.j2
+++ b/ansible/roles/neutron/templates/linuxbridge_agent.ini.j2
@@ -4,7 +4,9 @@ extensions = {{ neutron_agent_extensions|map(attribute='name')|join(',') }}
 {% endif %}
 
 [linux_bridge]
-physical_interface_mappings = physnet1:{{ neutron_external_interface }}
+{% if inventory_hostname in groups["network"] or (inventory_hostname in groups["compute"] and computes_need_external_bridge | bool ) %}
+physical_interface_mappings = {% for interface in neutron_external_interface.split(',') %}physnet{{ loop.index0 + 1 }}:{{ interface }}{% if not loop.last %},{% endif %}{% endfor %}
+{% endif %}
 
 [securitygroup]
 firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
diff --git a/ansible/roles/neutron/templates/ml2_conf.ini.j2 b/ansible/roles/neutron/templates/ml2_conf.ini.j2
index 2e1cb8096a..e55423e33c 100644
--- a/ansible/roles/neutron/templates/ml2_conf.ini.j2
+++ b/ansible/roles/neutron/templates/ml2_conf.ini.j2
@@ -24,7 +24,7 @@ network_vlan_ranges =
 {% if enable_ironic | bool %}
 flat_networks = *
 {% else %}
-flat_networks = {% for bridge in neutron_bridge_name.split(',') %}physnet{{ loop.index0 + 1 }}{% if not loop.last %},{% endif %}{% endfor %}
+flat_networks = {% for interface in neutron_external_interface.split(',') %}physnet{{ loop.index0 + 1 }}{% if not loop.last %},{% endif %}{% endfor %}
 {% endif %}
 
 [ml2_type_vxlan]
diff --git a/releasenotes/notes/linux-bridge-multi-fe8576616fb7d373.yaml b/releasenotes/notes/linux-bridge-multi-fe8576616fb7d373.yaml
new file mode 100644
index 0000000000..91626720d6
--- /dev/null
+++ b/releasenotes/notes/linux-bridge-multi-fe8576616fb7d373.yaml
@@ -0,0 +1,6 @@
+---
+fixes:
+  - |
+    Fixes an issue with Neutron ``linuxbridge`` ML2 agent when
+    ``neutron_external_interface`` includes multiple interfaces. `LP#1863935
+    <https://launchpad.net/bugs/1863935>`__