@@ -132,27 +132,27 @@ def __init__(self):
132
132
# Global namespace will be used for Control plane ACL which are via IPTables.
133
133
# Per ASIC namespace will be used for Data and Everflow ACL's.
134
134
# Global Configdb will have all ACL information for both Ctrl and Data/Evereflow ACL's
135
- # and will be used as souurce of truth for ACL modification to config DB which will be done to both Global DB and
135
+ # and will be used as souurce of truth for ACL modification to config DB which will be done to both Global DB and
136
136
# front asic namespace
137
-
137
+
138
138
self .per_npu_configdb = {}
139
139
140
140
# State DB are used for to get mirror Session monitor port.
141
141
# For multi-npu platforms each asic namespace can have different monitor port
142
142
# dependinding on which route to session destination ip. So for multi-npu
143
- # platforms we get state db for all front asic namespace in addition to
144
-
143
+ # platforms we get state db for all front asic namespace in addition to
144
+
145
145
self .per_npu_statedb = {}
146
146
147
147
# Getting all front asic namespace and correspding config and state DB connector
148
-
148
+
149
149
namespaces = device_info .get_all_namespaces ()
150
150
for front_asic_namespaces in namespaces ['front_ns' ]:
151
151
self .per_npu_configdb [front_asic_namespaces ] = ConfigDBConnector (use_unix_socket_path = True , namespace = front_asic_namespaces )
152
152
self .per_npu_configdb [front_asic_namespaces ].connect ()
153
153
self .per_npu_statedb [front_asic_namespaces ] = SonicV2Connector (use_unix_socket_path = True , namespace = front_asic_namespaces )
154
154
self .per_npu_statedb [front_asic_namespaces ].connect (self .per_npu_statedb [front_asic_namespaces ].STATE_DB )
155
-
155
+
156
156
self .read_tables_info ()
157
157
self .read_rules_info ()
158
158
self .read_sessions_info ()
@@ -183,8 +183,8 @@ def read_policers_info(self):
183
183
Read POLICER table from configuration database
184
184
:return:
185
185
"""
186
-
187
- # For multi-npu platforms we will read from any one of front asic namespace
186
+
187
+ # For multi-npu platforms we will read from any one of front asic namespace
188
188
# config db as the information should be same across all config db
189
189
if self .per_npu_configdb :
190
190
namespace_configdb = list (self .per_npu_configdb .values ())[0 ]
@@ -201,7 +201,7 @@ def read_sessions_info(self):
201
201
:return:
202
202
"""
203
203
204
- # For multi-npu platforms we will read from any one of front asic namespace
204
+ # For multi-npu platforms we will read from any one of front asic namespace
205
205
# config db as the information should be same across all config db
206
206
if self .per_npu_configdb :
207
207
namespace_configdb = list (self .per_npu_configdb .values ())[0 ]
@@ -210,8 +210,8 @@ def read_sessions_info(self):
210
210
self .sessions_db_info = self .configdb .get_table (self .CFG_MIRROR_SESSION_TABLE )
211
211
for key in self .sessions_db_info :
212
212
if self .per_npu_statedb :
213
- # For multi-npu platforms we will read from all front asic name space
214
- # statedb as the monitor port will be differnt for each asic
213
+ # For multi-npu platforms we will read from all front asic name space
214
+ # statedb as the monitor port will be differnt for each asic
215
215
# and it's status also might be different (ideally should not happen)
216
216
# We will store them as dict of 'asic' : value
217
217
self .sessions_db_info [key ]["status" ] = {}
@@ -283,6 +283,14 @@ def set_max_priority(self, priority):
283
283
def is_table_valid (self , tname ):
284
284
return self .tables_db_info .get (tname )
285
285
286
+ def is_table_egress (self , tname ):
287
+ """
288
+ Check if ACL table stage is egress
289
+ :param tname: ACL table name
290
+ :return: True if table type is Egress
291
+ """
292
+ return self .tables_db_info [tname ].get ("stage" , Stage .INGRESS ).upper () == Stage .EGRESS
293
+
286
294
def is_table_mirror (self , tname ):
287
295
"""
288
296
Check if ACL table type is ACL_TABLE_TYPE_MIRROR or ACL_TABLE_TYPE_MIRRORV6
@@ -377,12 +385,12 @@ def validate_actions(self, table_name, action_props):
377
385
# check if per npu state db is there then read using first state db
378
386
# else read from global statedb
379
387
if self .per_npu_statedb :
380
- # For multi-npu we will read using anyone statedb connector for front asic namespace.
381
- # Same information should be there in all state DB's
388
+ # For multi-npu we will read using anyone statedb connector for front asic namespace.
389
+ # Same information should be there in all state DB's
382
390
# as it is static information about switch capability
383
391
namespace_statedb = list (self .per_npu_statedb .values ())[0 ]
384
392
capability = namespace_statedb .get_all (self .statedb .STATE_DB , "{}|switch" .format (self .SWITCH_CAPABILITY_TABLE ))
385
- else :
393
+ else :
386
394
capability = self .statedb .get_all (self .statedb .STATE_DB , "{}|switch" .format (self .SWITCH_CAPABILITY_TABLE ))
387
395
for action_key in dict (action_props ):
388
396
key = "{}|{}" .format (self .ACL_ACTIONS_CAPABILITY_FIELD , stage .upper ())
@@ -636,7 +644,7 @@ def convert_rules(self):
636
644
except AclLoaderException as ex :
637
645
error ("Error processing rule %s: %s. Skipped." % (acl_entry_name , ex ))
638
646
639
- if not self .is_table_mirror (table_name ):
647
+ if not self .is_table_mirror (table_name ) and not self . is_table_egress ( table_name ) :
640
648
deep_update (self .rules_info , self .deny_rule (table_name ))
641
649
642
650
def full_update (self ):
@@ -705,7 +713,7 @@ def incremental_update(self):
705
713
# Add all new dataplane rules
706
714
for key in new_dataplane_rules :
707
715
self .configdb .mod_entry (self .ACL_RULE , key , self .rules_info [key ])
708
- # Program for per-asic namespace corresponding to front asic also if present.
716
+ # Program for per-asic namespace corresponding to front asic also if present.
709
717
for namespace_configdb in self .per_npu_configdb .values ():
710
718
namespace_configdb .mod_entry (self .ACL_RULE , key , self .rules_info [key ])
711
719
@@ -715,22 +723,22 @@ def incremental_update(self):
715
723
716
724
for key in added_controlplane_rules :
717
725
self .configdb .mod_entry (self .ACL_RULE , key , self .rules_info [key ])
718
- # Program for per-asic namespace corresponding to front asic also if present.
726
+ # Program for per-asic namespace corresponding to front asic also if present.
719
727
# For control plane ACL it's not needed but to keep all db in sync program everywhere
720
728
for namespace_configdb in self .per_npu_configdb .values ():
721
729
namespace_configdb .mod_entry (self .ACL_RULE , key , self .rules_info [key ])
722
730
723
731
for key in removed_controlplane_rules :
724
732
self .configdb .mod_entry (self .ACL_RULE , key , None )
725
- # Program for per-asic namespace corresponding to front asic also if present.
733
+ # Program for per-asic namespace corresponding to front asic also if present.
726
734
# For control plane ACL it's not needed but to keep all db in sync program everywhere
727
735
for namespace_configdb in self .per_npu_configdb .values ():
728
736
namespace_configdb .mod_entry (self .ACL_RULE , key , None )
729
737
730
738
for key in existing_controlplane_rules :
731
739
if cmp (self .rules_info [key ], self .rules_db_info [key ]) != 0 :
732
740
self .configdb .set_entry (self .ACL_RULE , key , self .rules_info [key ])
733
- # Program for per-asic namespace corresponding to front asic also if present.
741
+ # Program for per-asic namespace corresponding to front asic also if present.
734
742
# For control plane ACL it's not needed but to keep all db in sync program everywhere
735
743
for namespace_configdb in self .per_npu_configdb .values ():
736
744
namespace_configdb .set_entry (self .ACL_RULE , key , self .rules_info [key ])
@@ -745,10 +753,10 @@ def delete(self, table=None, rule=None):
745
753
if not table or table == key [0 ]:
746
754
if not rule or rule == key [1 ]:
747
755
self .configdb .set_entry (self .ACL_RULE , key , None )
748
- # Program for per-asic namespace corresponding to front asic also if present.
756
+ # Program for per-asic namespace corresponding to front asic also if present.
749
757
for namespace_configdb in self .per_npu_configdb .values ():
750
758
namespace_configdb .set_entry (self .ACL_RULE , key , None )
751
-
759
+
752
760
def show_table (self , table_name ):
753
761
"""
754
762
Show ACL table configuration.
0 commit comments