Skip to content

Commit a8cf50e

Browse files
authored
Merge pull request #151 from stackhpc/upstream/zed-2024-06-17
Synchronise zed with upstream
2 parents c1f7693 + c32eb56 commit a8cf50e

File tree

6 files changed

+50
-4
lines changed

6 files changed

+50
-4
lines changed

doc/source/contributor/internals/openvswitch_firewall.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,19 @@ will be:
525525
table=94, priority=10,reg6=0x284,dl_src=fa:16:3e:24:57:c7,dl_dst=00:00:00:00:00:00/01:00:00:00:00:00 actions=push_vlan:0x8100,set_field:0x1->vlan_vid,output:3
526526
table=94, priority=1 actions=NORMAL
527527

528+
The OVS firewall will initialize a default goto table 94 flow
529+
on TRANSIENT_TABLE |table_60|, if ``explicitly_egress_direct``
530+
is set to True, which is mainly for ports without security groups
531+
and disabled port_security. For instance:
532+
533+
::
534+
table=60, priority=2 actions=resubmit(,94)
535+
536+
Then for packets from the outside to VM without security functionalities
537+
(--disable-port-security --no-security-group)
538+
will go to table 94 and do the same direct actions.
539+
540+
528541
OVS firewall integration points
529542
-------------------------------
530543

neutron/agent/linux/openvswitch_firewall/firewall.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,14 @@ def _initialize_common_flows(self):
644644
'resubmit(,%d)' % ovs_consts.BASE_EGRESS_TABLE,
645645
)
646646

647+
if cfg.CONF.AGENT.explicitly_egress_direct:
648+
self._add_flow(
649+
table=ovs_consts.TRANSIENT_TABLE,
650+
priority=2,
651+
actions='resubmit(,%d)' % (
652+
ovs_consts.ACCEPTED_EGRESS_TRAFFIC_NORMAL_TABLE)
653+
)
654+
647655
def _initialize_third_party_tables(self):
648656
self.int_br.br.add_flow(
649657
table=ovs_consts.ACCEPTED_EGRESS_TRAFFIC_NORMAL_TABLE,
@@ -1253,6 +1261,7 @@ def install_accepted_egress_direct_flow(self, mac, vlan_tag, dst_port,
12531261
return
12541262

12551263
# Prevent flood for accepted egress traffic
1264+
# For packets from internal ports or VM ports.
12561265
self._add_flow(
12571266
flow_group_id=dst_port,
12581267
table=ovs_consts.ACCEPTED_EGRESS_TRAFFIC_NORMAL_TABLE,
@@ -1261,6 +1270,15 @@ def install_accepted_egress_direct_flow(self, mac, vlan_tag, dst_port,
12611270
reg_net=vlan_tag,
12621271
actions='output:{:d}'.format(dst_port)
12631272
)
1273+
# For packets from patch ports.
1274+
self._add_flow(
1275+
flow_group_id=dst_port,
1276+
table=ovs_consts.ACCEPTED_EGRESS_TRAFFIC_NORMAL_TABLE,
1277+
priority=12,
1278+
dl_dst=mac,
1279+
dl_vlan=vlan_tag,
1280+
actions='strip_vlan,output:{:d}'.format(dst_port)
1281+
)
12641282

12651283
# The former flow may not match, that means the destination port is
12661284
# not in this host. So, we direct the packet to mapped bridge(s).
@@ -1309,6 +1327,12 @@ def delete_accepted_egress_direct_flow(self, mac, vlan_tag):
13091327
dl_src=mac,
13101328
reg_net=vlan_tag)
13111329

1330+
self._delete_flows(
1331+
table=ovs_consts.ACCEPTED_EGRESS_TRAFFIC_NORMAL_TABLE,
1332+
dl_dst=mac,
1333+
dl_vlan=vlan_tag
1334+
)
1335+
13121336
def _initialize_tracked_egress(self, port):
13131337
# Drop invalid packets
13141338
self._add_flow(

neutron/conf/plugins/ml2/drivers/ovs_conf.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,16 @@
228228
"outgoing IP packet carrying GRE/VXLAN tunnel.")),
229229
cfg.BoolOpt('baremetal_smartnic', default=False,
230230
help=_("Enable the agent to process Smart NIC ports.")),
231+
# TODO(liuyulong): consider adding a new configuration
232+
# item to control ingress behavior.
231233
cfg.BoolOpt('explicitly_egress_direct', default=False,
232234
help=_("When set to True, the accepted egress unicast "
233235
"traffic will not use action NORMAL. The accepted "
234236
"egress packets will be taken care of in the final "
235237
"egress tables direct output flows for unicast "
236-
"traffic.")),
238+
"traffic. This will aslo change the pipleline for "
239+
"ingress traffic to ports without security, the final "
240+
"output action will be hit in table 94. ")),
237241
]
238242

239243
dhcp_opts = [

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def setup_default_table(self, enable_openflow_dhcp=False,
5757
self.install_goto(dest_table_id=constants.PACKET_RATE_LIMIT)
5858
self.install_goto(dest_table_id=constants.TRANSIENT_TABLE,
5959
table_id=constants.PACKET_RATE_LIMIT)
60-
self.install_normal(table_id=constants.TRANSIENT_TABLE, priority=3)
60+
self.install_normal(table_id=constants.TRANSIENT_TABLE, priority=1)
6161
self.init_dhcp(enable_openflow_dhcp=enable_openflow_dhcp,
6262
enable_dhcpv6=enable_dhcpv6)
6363
self.install_drop(table_id=constants.ARP_SPOOF_TABLE)

neutron/tests/unit/agent/linux/openvswitch_firewall/test_firewall.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,8 +909,13 @@ def test_delete_all_port_flows(self):
909909
"reg6": port.vlan_tag}
910910
flow7 = mock.call(**call_args7)
911911

912+
call_args8 = {"table": ovs_consts.ACCEPTED_EGRESS_TRAFFIC_NORMAL_TABLE,
913+
"dl_dst": port.mac,
914+
"dl_vlan": port.vlan_tag}
915+
flow8 = mock.call(**call_args8)
916+
912917
self.mock_bridge.br.delete_flows.assert_has_calls(
913-
[flow1, flow2, flow3, flow6, flow7, flow4, flow5])
918+
[flow1, flow2, flow3, flow6, flow7, flow8, flow4, flow5])
914919

915920
def test_prepare_port_filter_initialized_port(self):
916921
port_dict = {'device': 'port-id',

neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/openflow/native/test_br_int.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def test_setup_default_table(self):
7171
]),
7272
],
7373
match=ofpp.OFPMatch(),
74-
priority=3,
74+
priority=1,
7575
table_id=60),
7676
active_bundle=None),
7777
call._send_msg(ofpp.OFPFlowMod(dp,

0 commit comments

Comments
 (0)