@@ -59,6 +59,8 @@ class ControlPlaneAclManager(daemon_base.DaemonBase):
59
59
60
60
ACL_TABLE_TYPE_CTRLPLANE = "CTRLPLANE"
61
61
62
+ BFD_SESSION_TABLE = "BFD_SESSION_TABLE"
63
+
62
64
# To specify a port range instead of a single port, use iptables format:
63
65
# separate start and end ports with a colon, e.g., "1000:2000"
64
66
ACL_SERVICES = {
@@ -87,6 +89,7 @@ class ControlPlaneAclManager(daemon_base.DaemonBase):
87
89
UPDATE_DELAY_SECS = 0.5
88
90
89
91
DualToR = False
92
+ bfdAllowed = False
90
93
91
94
def __init__ (self , log_identifier ):
92
95
super (ControlPlaneAclManager , self ).__init__ (log_identifier )
@@ -170,6 +173,7 @@ class ControlPlaneAclManager(daemon_base.DaemonBase):
170
173
self .log_error ("Error running command '{}'" .format (cmd ))
171
174
elif stdout :
172
175
return stdout .rstrip ('\n ' )
176
+ return ""
173
177
174
178
def parse_int_to_tcp_flags (self , hex_value ):
175
179
tcp_flags_str = ""
@@ -705,6 +709,13 @@ class ControlPlaneAclManager(daemon_base.DaemonBase):
705
709
self .update_thread [namespace ] = None
706
710
return
707
711
712
+ def allow_bfd_protocol (self , namespace ):
713
+ iptables_cmds = []
714
+ # Add iptables/ip6tables commands to allow all BFD singlehop and multihop sessions
715
+ iptables_cmds .append (self .iptables_cmd_ns_prefix [namespace ] + "iptables -I INPUT 2 -p udp -m multiport --dports 3784,4784 -j ACCEPT" )
716
+ iptables_cmds .append (self .iptables_cmd_ns_prefix [namespace ] + "ip6tables -I INPUT 2 -p udp -m multiport --dports 3784,4784 -j ACCEPT" )
717
+ self .run_commands (iptables_cmds )
718
+
708
719
def run (self ):
709
720
# Set select timeout to 1 second
710
721
SELECT_TIMEOUT_MS = 1000
@@ -730,12 +741,12 @@ class ControlPlaneAclManager(daemon_base.DaemonBase):
730
741
state_db_id = swsscommon .SonicDBConfig .getDbId ("STATE_DB" )
731
742
dhcp_packet_mark_tbl = {}
732
743
744
+ # set up state_db connector
745
+ state_db_connector = swsscommon .DBConnector ("STATE_DB" , 0 )
746
+
733
747
if self .DualToR :
734
748
self .log_info ("Dual ToR mode" )
735
749
736
- # set up state_db connector
737
- state_db_connector = swsscommon .DBConnector ("STATE_DB" , 0 )
738
-
739
750
subscribe_mux_cable = swsscommon .SubscriberStateTable (state_db_connector , self .MUX_CABLE_TABLE )
740
751
sel .addSelectable (subscribe_mux_cable )
741
752
@@ -746,6 +757,10 @@ class ControlPlaneAclManager(daemon_base.DaemonBase):
746
757
for namespace in list (self .config_db_map .keys ()):
747
758
self .setup_dhcp_chain (namespace )
748
759
760
+ # This should be migrated from state_db BFD session table to feature_table in the future when feature table support gets added for BFD
761
+ subscribe_bfd_session = swsscommon .SubscriberStateTable (state_db_connector , self .BFD_SESSION_TABLE )
762
+ sel .addSelectable (subscribe_bfd_session )
763
+
749
764
# Map of Namespace <--> susbcriber table's object
750
765
config_db_subscriber_table_map = {}
751
766
@@ -785,6 +800,17 @@ class ControlPlaneAclManager(daemon_base.DaemonBase):
785
800
db_id = redisSelectObj .getDbConnector ().getDbId ()
786
801
787
802
if db_id == state_db_id :
803
+ while True :
804
+ key , op , fvs = subscribe_bfd_session .pop ()
805
+ if not key :
806
+ break
807
+
808
+ print (key )
809
+ if op == 'SET' and not self .bfdAllowed :
810
+ self .allow_bfd_protocol (namespace )
811
+ self .bfdAllowed = True
812
+ sel .removeSelectable (subscribe_bfd_session )
813
+
788
814
if self .DualToR :
789
815
'''dhcp packet mark update'''
790
816
while True :
0 commit comments