Skip to content

Commit 7992ca9

Browse files
gotostackrubasov
authored andcommitted
Add a default goto table=94 for openvswitch fw
If enable explicitly_egress_direct=True and set port as no security group and port_security=False, the ingress flood will reappear. The pipleline is: Ingress table_0 -> table_60 -> NORMAL -> VM Egress table_0 -> ... -> table_94 -> output Because ingress final action is normal, the br-int will learn the source MAC, but egress final action is output. So VM's mac will never be learnt by the br-int. Then ingress flood comes again. This patch adds a default direct flow to table 94 during the openflow security group init and explicitly_egress_direct=True, then the pipleline will be: Ingress table_0 -> table_60 -> table_94 -> output VM Egress table_0 -> ... -> table_94 -> output And this patch adds the flows coming from patch port which will match local vlan then go to table 94 do the same direct actions. Above flood issue will be addressed by these flows. Closes-Bug: #2051351 Change-Id: Ia61784174ee610b338f26660b2954330abc131a1 (cherry picked from commit d6f56c5) (cherry picked from commit f94f8b6) (cherry picked from commit fc7fa9c) Conflict with 02b12b0 in neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/br_int.py (cherry picked from commit 1045985) Conflict with 5b64ac9 in neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/openflow/native/test_br_int.py (cherry picked from commit c32eb56)
1 parent 2d6c161 commit 7992ca9

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
@@ -634,6 +634,14 @@ def _initialize_common_flows(self):
634634
'resubmit(,%d)' % ovs_consts.BASE_EGRESS_TABLE,
635635
)
636636

637+
if cfg.CONF.AGENT.explicitly_egress_direct:
638+
self._add_flow(
639+
table=ovs_consts.TRANSIENT_TABLE,
640+
priority=2,
641+
actions='resubmit(,%d)' % (
642+
ovs_consts.ACCEPTED_EGRESS_TRAFFIC_NORMAL_TABLE)
643+
)
644+
637645
def _initialize_third_party_tables(self):
638646
self.int_br.br.add_flow(
639647
table=ovs_consts.ACCEPTED_EGRESS_TRAFFIC_NORMAL_TABLE,
@@ -1239,13 +1247,23 @@ def install_accepted_egress_direct_flow(self, mac, vlan_tag, dst_port,
12391247
return
12401248

12411249
# Prevent flood for accepted egress traffic
1250+
# For packets from internal ports or VM ports.
12421251
self._add_flow(
12431252
table=ovs_consts.ACCEPTED_EGRESS_TRAFFIC_NORMAL_TABLE,
12441253
priority=12,
12451254
dl_dst=mac,
12461255
reg_net=vlan_tag,
12471256
actions='output:{:d}'.format(dst_port)
12481257
)
1258+
# For packets from patch ports.
1259+
self._add_flow(
1260+
flow_group_id=dst_port,
1261+
table=ovs_consts.ACCEPTED_EGRESS_TRAFFIC_NORMAL_TABLE,
1262+
priority=12,
1263+
dl_dst=mac,
1264+
dl_vlan=vlan_tag,
1265+
actions='strip_vlan,output:{:d}'.format(dst_port)
1266+
)
12491267

12501268
# The former flow may not match, that means the destination port is
12511269
# not in this host. So, we direct the packet to mapped bridge(s).
@@ -1293,6 +1311,12 @@ def delete_accepted_egress_direct_flow(self, mac, vlan_tag):
12931311
dl_src=mac,
12941312
reg_net=vlan_tag)
12951313

1314+
self._delete_flows(
1315+
table=ovs_consts.ACCEPTED_EGRESS_TRAFFIC_NORMAL_TABLE,
1316+
dl_dst=mac,
1317+
dl_vlan=vlan_tag
1318+
)
1319+
12961320
def _initialize_tracked_egress(self, port):
12971321
# Drop invalid packets
12981322
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
@@ -219,12 +219,16 @@
219219
"outgoing IP packet carrying GRE/VXLAN tunnel.")),
220220
cfg.BoolOpt('baremetal_smartnic', default=False,
221221
help=_("Enable the agent to process Smart NIC ports.")),
222+
# TODO(liuyulong): consider adding a new configuration
223+
# item to control ingress behavior.
222224
cfg.BoolOpt('explicitly_egress_direct', default=False,
223225
help=_("When set to True, the accepted egress unicast "
224226
"traffic will not use action NORMAL. The accepted "
225227
"egress packets will be taken care of in the final "
226228
"egress tables direct output flows for unicast "
227-
"traffic.")),
229+
"traffic. This will aslo change the pipleline for "
230+
"ingress traffic to ports without security, the final "
231+
"output action will be hit in table 94. ")),
228232
]
229233

230234
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
@@ -56,7 +56,7 @@ def setup_default_table(self, enable_openflow_dhcp=False,
5656
self.install_goto(dest_table_id=constants.PACKET_RATE_LIMIT)
5757
self.install_goto(dest_table_id=constants.TRANSIENT_TABLE,
5858
table_id=constants.PACKET_RATE_LIMIT)
59-
self.install_normal(table_id=constants.TRANSIENT_TABLE, priority=3)
59+
self.install_normal(table_id=constants.TRANSIENT_TABLE, priority=1)
6060
self.init_dhcp(enable_openflow_dhcp=enable_openflow_dhcp,
6161
enable_dhcpv6=enable_dhcpv6)
6262
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
@@ -905,8 +905,13 @@ def test_delete_all_port_flows(self):
905905
"reg6": port.vlan_tag}
906906
flow7 = mock.call(**call_args7)
907907

908+
call_args8 = {"table": ovs_consts.ACCEPTED_EGRESS_TRAFFIC_NORMAL_TABLE,
909+
"dl_dst": port.mac,
910+
"dl_vlan": port.vlan_tag}
911+
flow8 = mock.call(**call_args8)
912+
908913
self.mock_bridge.br.delete_flows.assert_has_calls(
909-
[flow1, flow2, flow3, flow6, flow7, flow4, flow5])
914+
[flow1, flow2, flow3, flow6, flow7, flow8, flow4, flow5])
910915

911916
def test_prepare_port_filter_initialized_port(self):
912917
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)