Skip to content

Commit a80d5cd

Browse files
authored
Merge pull request #232 from stackhpc/upstream/2025.1-2025-10-06
Synchronise 2025.1 with upstream
2 parents 2d3bf68 + b3db08f commit a80d5cd

File tree

7 files changed

+429
-198
lines changed

7 files changed

+429
-198
lines changed

neutron/conf/policies/l3_conntrack_helper.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
name='create_router_conntrack_helper',
3333
check_str=neutron_policy.policy_or(
3434
base.ADMIN_OR_PROJECT_MEMBER,
35-
base.RULE_PARENT_OWNER),
35+
base.PARENT_OWNER_MEMBER),
3636
scope_types=['project'],
3737
description='Create a router conntrack helper',
3838
operations=[
@@ -51,7 +51,7 @@
5151
name='get_router_conntrack_helper',
5252
check_str=neutron_policy.policy_or(
5353
base.ADMIN_OR_PROJECT_READER,
54-
base.RULE_PARENT_OWNER),
54+
base.PARENT_OWNER_READER),
5555
scope_types=['project'],
5656
description='Get a router conntrack helper',
5757
operations=[
@@ -74,7 +74,7 @@
7474
name='update_router_conntrack_helper',
7575
check_str=neutron_policy.policy_or(
7676
base.ADMIN_OR_PROJECT_MEMBER,
77-
base.RULE_PARENT_OWNER),
77+
base.PARENT_OWNER_MEMBER),
7878
scope_types=['project'],
7979
description='Update a router conntrack helper',
8080
operations=[
@@ -93,7 +93,7 @@
9393
name='delete_router_conntrack_helper',
9494
check_str=neutron_policy.policy_or(
9595
base.ADMIN_OR_PROJECT_MEMBER,
96-
base.RULE_PARENT_OWNER),
96+
base.PARENT_OWNER_MEMBER),
9797
scope_types=['project'],
9898
description='Delete a router conntrack helper',
9999
operations=[

neutron/conf/policies/local_ip_association.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
name='create_local_ip_port_association',
3030
check_str=neutron_policy.policy_or(
3131
base.ADMIN_OR_PROJECT_MEMBER,
32-
base.RULE_PARENT_OWNER),
32+
base.PARENT_OWNER_MEMBER),
3333
scope_types=['project'],
3434
description='Create a Local IP port association',
3535
operations=[
@@ -48,7 +48,7 @@
4848
name='get_local_ip_port_association',
4949
check_str=neutron_policy.policy_or(
5050
base.ADMIN_OR_PROJECT_READER,
51-
base.RULE_PARENT_OWNER),
51+
base.PARENT_OWNER_READER),
5252
scope_types=['project'],
5353
description='Get a Local IP port association',
5454
operations=[
@@ -71,7 +71,7 @@
7171
name='delete_local_ip_port_association',
7272
check_str=neutron_policy.policy_or(
7373
base.ADMIN_OR_PROJECT_MEMBER,
74-
base.RULE_PARENT_OWNER),
74+
base.PARENT_OWNER_MEMBER),
7575
scope_types=['project'],
7676
description='Delete a Local IP port association',
7777
operations=[

neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/br_tun.py

Lines changed: 60 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515
# License for the specific language governing permissions and limitations
1616
# under the License.
1717

18+
from neutron_lib import constants as lib_constants
1819
from neutron_lib.plugins.ml2 import ovs_constants as constants
1920
from os_ken.lib.packet import ether_types
21+
from os_ken.lib.packet import icmpv6
22+
from os_ken.lib.packet import in_proto
2023

2124
from neutron.plugins.ml2.drivers.openvswitch.agent.openflow.native \
2225
import br_dvr_process
@@ -33,6 +36,62 @@ class OVSTunnelBridge(ovs_bridge.OVSAgentBridge,
3336
dvr_process_next_table_id = constants.PATCH_LV_TO_TUN
3437
of_tables = constants.TUN_BR_ALL_TABLES
3538

39+
def _setup_learn_flows(self, ofpp, patch_int_ofport):
40+
flow_specs = [
41+
ofpp.NXFlowSpecMatch(src=('vlan_tci', 0),
42+
dst=('vlan_tci', 0),
43+
n_bits=12),
44+
ofpp.NXFlowSpecMatch(src=('eth_src', 0),
45+
dst=('eth_dst', 0),
46+
n_bits=48),
47+
ofpp.NXFlowSpecLoad(src=0,
48+
dst=('vlan_tci', 0),
49+
n_bits=16),
50+
ofpp.NXFlowSpecLoad(src=('tunnel_id', 0),
51+
dst=('tunnel_id', 0),
52+
n_bits=64),
53+
ofpp.NXFlowSpecOutput(src=('in_port', 0),
54+
dst='',
55+
n_bits=32),
56+
]
57+
actions = [
58+
ofpp.NXActionLearn(table_id=constants.UCAST_TO_TUN,
59+
cookie=self.default_cookie,
60+
priority=1,
61+
hard_timeout=300,
62+
specs=flow_specs),
63+
ofpp.OFPActionOutput(patch_int_ofport, 0),
64+
]
65+
66+
arp_match = ofpp.OFPMatch(
67+
eth_type=ether_types.ETH_TYPE_ARP,
68+
arp_tha=lib_constants.BROADCAST_MAC
69+
)
70+
ipv6_ra_match = ofpp.OFPMatch(
71+
eth_type=ether_types.ETH_TYPE_IPV6,
72+
ip_proto=in_proto.IPPROTO_ICMPV6,
73+
icmpv6_type=icmpv6.ND_ROUTER_ADVERT) # icmp_type=134
74+
ipv6_na_match = ofpp.OFPMatch(
75+
eth_type=ether_types.ETH_TYPE_IPV6,
76+
ip_proto=in_proto.IPPROTO_ICMPV6,
77+
icmpv6_type=icmpv6.ND_NEIGHBOR_ADVERT) # icmp_type=136
78+
79+
self.install_apply_actions(table_id=constants.LEARN_FROM_TUN,
80+
priority=2,
81+
match=arp_match,
82+
actions=actions)
83+
self.install_apply_actions(table_id=constants.LEARN_FROM_TUN,
84+
priority=2,
85+
match=ipv6_ra_match,
86+
actions=actions)
87+
self.install_apply_actions(table_id=constants.LEARN_FROM_TUN,
88+
priority=2,
89+
match=ipv6_na_match,
90+
actions=actions)
91+
self.install_apply_actions(table_id=constants.LEARN_FROM_TUN,
92+
priority=1,
93+
actions=actions)
94+
3695
def setup_default_table(
3796
self, patch_int_ofport, arp_responder_enabled, dvr_enabled):
3897
(dp, ofp, ofpp) = self._get_dp()
@@ -81,34 +140,7 @@ def setup_default_table(
81140
# dynamically set-up flows in UCAST_TO_TUN corresponding to remote mac
82141
# addresses (assumes that lvid has already been set by a previous flow)
83142
# Once remote mac addresses are learnt, output packet to patch_int
84-
flow_specs = [
85-
ofpp.NXFlowSpecMatch(src=('vlan_tci', 0),
86-
dst=('vlan_tci', 0),
87-
n_bits=12),
88-
ofpp.NXFlowSpecMatch(src=('eth_src', 0),
89-
dst=('eth_dst', 0),
90-
n_bits=48),
91-
ofpp.NXFlowSpecLoad(src=0,
92-
dst=('vlan_tci', 0),
93-
n_bits=16),
94-
ofpp.NXFlowSpecLoad(src=('tunnel_id', 0),
95-
dst=('tunnel_id', 0),
96-
n_bits=64),
97-
ofpp.NXFlowSpecOutput(src=('in_port', 0),
98-
dst='',
99-
n_bits=32),
100-
]
101-
actions = [
102-
ofpp.NXActionLearn(table_id=constants.UCAST_TO_TUN,
103-
cookie=self.default_cookie,
104-
priority=1,
105-
hard_timeout=300,
106-
specs=flow_specs),
107-
ofpp.OFPActionOutput(patch_int_ofport, 0),
108-
]
109-
self.install_apply_actions(table_id=constants.LEARN_FROM_TUN,
110-
priority=1,
111-
actions=actions)
143+
self._setup_learn_flows(ofpp, patch_int_ofport)
112144

113145
# Egress unicast will be handled in table UCAST_TO_TUN, where remote
114146
# mac addresses will be learned. For now, just add a default flow that

neutron/tests/unit/conf/policies/test_l3_conntrack_helper.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,29 @@ def setUp(self):
2929
self.router = {
3030
'id': uuidutils.generate_uuid(),
3131
'project_id': self.project_id}
32+
self.alt_router = {
33+
'id': uuidutils.generate_uuid(),
34+
'project_id': self.alt_project_id}
35+
3236
self.target = {
3337
'project_id': self.project_id,
3438
'router_id': self.router['id'],
3539
'ext_parent_router_id': self.router['id']}
36-
3740
self.alt_target = {
3841
'project_id': self.alt_project_id,
39-
'router_id': self.router['id'],
40-
'ext_parent_router_id': self.router['id']}
42+
'router_id': self.alt_router['id'],
43+
'ext_parent_router_id': self.alt_router['id']}
44+
45+
routers = {
46+
self.router['id']: self.router,
47+
self.alt_router['id']: self.alt_router,
48+
}
49+
50+
def get_router(context, router_id, fields=None):
51+
return routers[router_id]
4152

4253
self.plugin_mock = mock.Mock()
43-
self.plugin_mock.get_router.return_value = self.router
54+
self.plugin_mock.get_router.side_effect = get_router
4455
mock.patch(
4556
'neutron_lib.plugins.directory.get_plugin',
4657
return_value=self.plugin_mock).start()

neutron/tests/unit/conf/policies/test_local_ip_association.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,29 @@ def setUp(self):
2929
self.local_ip = {
3030
'id': uuidutils.generate_uuid(),
3131
'project_id': self.project_id}
32+
self.alt_local_ip = {
33+
'id': uuidutils.generate_uuid(),
34+
'project_id': self.alt_project_id}
3235

3336
self.target = {
3437
'project_id': self.project_id,
3538
'local_ip_id': self.local_ip['id'],
3639
'ext_parent_local_ip_id': self.local_ip['id']}
3740
self.alt_target = {
3841
'project_id': self.alt_project_id,
39-
'local_ip_id': self.local_ip['id'],
40-
'ext_parent_local_ip_id': self.local_ip['id']}
42+
'local_ip_id': self.alt_local_ip['id'],
43+
'ext_parent_local_ip_id': self.alt_local_ip['id']}
44+
45+
local_ips = {
46+
self.local_ip['id']: self.local_ip,
47+
self.alt_local_ip['id']: self.alt_local_ip,
48+
}
49+
50+
def get_local_ip(context, lip_id, fields=None):
51+
return local_ips[lip_id]
4152

4253
self.plugin_mock = mock.Mock()
43-
self.plugin_mock.get_local_ip.return_value = self.local_ip
54+
self.plugin_mock.get_local_ip.side_effect = get_local_ip
4455
mock.patch(
4556
'neutron_lib.plugins.directory.get_plugin',
4657
return_value=self.plugin_mock).start()

0 commit comments

Comments
 (0)