Skip to content

Commit 9410398

Browse files
committed
Added more comments on logic.
1 parent fbfc4a7 commit 9410398

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

files/image_config/caclmgrd/caclmgrd

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ try:
1616
import subprocess
1717
import sys
1818
import syslog
19+
1920
import sonic_device_util
2021
from swsscommon import swsscommon
2122
from swsssdk import SonicDBConfig, ConfigDBConnector
@@ -448,28 +449,41 @@ class ControlPlaneAclManager(object):
448449
def run(self):
449450
# Select Time-out for 10 Seconds
450451
SELECT_TIMEOUT_MS = 1000 * 10
452+
# Initlaize Global config that loads all database*.json
451453
swsscommon.SonicDBConfig.initializeGlobalConfig()
454+
# Create the Select object
452455
sel = swsscommon.Select()
456+
# Map of Namespace <--> susbcriber table's object
453457
config_db_subscriber_table_map = {}
458+
# Loop through all asic namespaces (if present) and host (namespace='')
454459
for namespace in self.config_db_map.keys():
455-
# Unconditionally update control plane ACLs once at start
460+
# Unconditionally update control plane ACLs once at start on given namespace
456461
self.update_control_plane_acls(namespace)
457-
462+
# Connect to Config DB of given namespace
458463
acl_db_connector = swsscommon.DBConnector("CONFIG_DB", 0, False, namespace)
464+
# Subscribe to notifications when ACL tables changes
459465
subscribe_acl_table = swsscommon.SubscriberStateTable(acl_db_connector, swsscommon.CFG_ACL_TABLE_TABLE_NAME)
466+
# Subscribe to notifications when ACL rule tables changes
460467
subscribe_acl_rule_table = swsscommon.SubscriberStateTable(acl_db_connector, swsscommon.CFG_ACL_RULE_TABLE_NAME)
468+
# Add both tables to the selectable object
461469
sel.addSelectable(subscribe_acl_table)
462470
sel.addSelectable(subscribe_acl_rule_table)
471+
# Update the map
463472
config_db_subscriber_table_map[namespace] = []
464473
config_db_subscriber_table_map[namespace].append(subscribe_acl_table)
465474
config_db_subscriber_table_map[namespace].append(subscribe_acl_rule_table)
475+
#Loop on select to see if any event happen on config db of any namespace
466476
while True:
467477
(state, c) = sel.select(SELECT_TIMEOUT_MS)
478+
# Continue if select is timeout or selectable object is not return
468479
if state != swsscommon.Select.OBJECT:
469480
continue
481+
# Get the corresponding namespace from selectable object
470482
namespace = c.getDbNamespace()
483+
# Pop data of both Subscriber Table object of namespace that got config db acl table event
471484
for table in config_db_subscriber_table_map[namespace]:
472485
table.pop()
486+
# Update the Control Plane ACL of the namespace that got config db acl table event
473487
self.update_control_plane_acls(namespace)
474488

475489
# ============================= Functions =============================

0 commit comments

Comments
 (0)