@@ -75,7 +75,7 @@ def extract_cmd_daemons(cmd_str):
75
75
class BgpdClientMgr (threading .Thread ):
76
76
VTYSH_MARK = 'vtysh '
77
77
PROXY_SERVER_ADDR = '/etc/frr/bgpd_client_sock'
78
- ALL_DAEMONS = ['bgpd' , 'zebra' , 'staticd' , 'bfdd' , 'ospfd' , 'pimd' ]
78
+ ALL_DAEMONS = ['bgpd' , 'zebra' , 'staticd' , 'bfdd' , 'ospfd' , 'pimd' , 'mgmtd' ]
79
79
TABLE_DAEMON = {
80
80
'DEVICE_METADATA' : ['bgpd' ],
81
81
'BGP_GLOBALS' : ['bgpd' ],
@@ -118,7 +118,9 @@ class BgpdClientMgr(threading.Thread):
118
118
'PIM_INTERFACE' : ['pimd' ],
119
119
'IGMP_INTERFACE' : ['pimd' ],
120
120
'IGMP_INTERFACE_QUERY' : ['pimd' ],
121
- 'SRV6_LOCATOR' : ['zebra' ]
121
+ 'SRV6_MY_LOCATORS' : ['zebra' ],
122
+ 'SRV6_MY_SIDS' : ['mgmtd' ]
123
+
122
124
}
123
125
VTYSH_CMD_DAEMON = [(r'show (ip|ipv6) route($|\s+\S+)' , ['zebra' ]),
124
126
(r'show ip mroute($|\s+\S+)' , ['pimd' ]),
@@ -402,46 +404,6 @@ def get_command_cmn(daemon, cmd_str, op, st_idx, vals, bool_values):
402
404
cmd_args .append (CommandArgument (daemon , cmd_enable , vals [idx ]))
403
405
return [cmd_str .format (* cmd_args , no = CommandArgument (daemon , cmd_enable ))]
404
406
405
- def hdl_srv6_locator (daemon , cmd_str , op , st_idx , vals , bool_values ):
406
- chk_val = None
407
- if op == CachedDataWithOp .OP_DELETE :
408
- if bool_values is not None and len (bool_values ) >= 3 :
409
- # set to default if given
410
- cmd_enable = bool_values [2 ]
411
- else :
412
- cmd_enable = False
413
- else :
414
- cmd_enable = True
415
- if bool_values is not None :
416
- if len (vals ) <= st_idx :
417
- return None
418
- chk_val = vals [st_idx ]
419
- if type (chk_val ) is dict :
420
- cmd_enable = False
421
- for _ , v in chk_val .items ():
422
- if not v [1 ]:
423
- continue
424
- if v [0 ] == bool_values [0 ]:
425
- cmd_enable = True
426
- break
427
- else :
428
- if chk_val == bool_values [0 ]:
429
- cmd_enable = True
430
- elif chk_val == bool_values [1 ]:
431
- cmd_enable = False
432
- else :
433
- return None
434
- else :
435
- cmd_enable = True
436
- cmd_list = []
437
- for num in range (len (vals [0 ])):
438
- cmd_args = []
439
- for idx in range (len (vals )):
440
- if bool_values is not None and idx == st_idx :
441
- continue
442
- cmd_args .append (CommandArgument (daemon , cmd_enable , vals [idx ][num ]))
443
- cmd_list .append (cmd_str .format (* cmd_args , no = CommandArgument (daemon , cmd_enable )))
444
- return cmd_list
445
407
446
408
def hdl_set_extcomm (daemon , cmd_str , op , st_idx , args , is_inline ):
447
409
if is_inline :
@@ -2128,7 +2090,6 @@ class BGPConfigDaemon:
2128
2090
('icmo_ttl' , 'ttl {}' , handle_ip_sla_common ),
2129
2091
('icmp_tos' , 'tos {}' , handle_ip_sla_common ),
2130
2092
]
2131
- srv6_locator_key_map = [(['opcode_prefix' , 'opcode_act' , 'opcode_data' ], '{no:no-prefix}opcode {} {} {}' , hdl_srv6_locator )]
2132
2093
2133
2094
2134
2095
tbl_to_key_map = {'BGP_GLOBALS' : global_key_map ,
@@ -2159,7 +2120,6 @@ class BGPConfigDaemon:
2159
2120
'PIM_INTERFACE' : pim_interface_key_map ,
2160
2121
'IGMP_INTERFACE' : igmp_mcast_grp_key_map ,
2161
2122
'IGMP_INTERFACE_QUERY' : igmp_interface_config_key_map ,
2162
- 'SRV6_LOCATOR' : srv6_locator_key_map ,
2163
2123
}
2164
2124
2165
2125
vrf_tables = {'BGP_GLOBALS' , 'BGP_GLOBALS_AF' ,
@@ -2357,7 +2317,8 @@ def __init__(self):
2357
2317
('PIM_INTERFACE' , self .bgp_table_handler_common ),
2358
2318
('IGMP_INTERFACE' , self .bgp_table_handler_common ),
2359
2319
('IGMP_INTERFACE_QUERY' , self .bgp_table_handler_common ),
2360
- ('SRV6_LOCATOR' , self .bgp_table_handler_common ),
2320
+ ('SRV6_MY_LOCATORS' , self .bgp_table_handler_common ),
2321
+ ('SRV6_MY_SIDS' , self .bgp_table_handler_common ),
2361
2322
]
2362
2323
self .bgp_message = queue .Queue (0 )
2363
2324
self .table_data_cache = self .config_db .get_table_data ([tbl for tbl , _ in self .table_handler_list ])
@@ -2753,17 +2714,38 @@ def __update_bgp(self, data_list):
2753
2714
self .bgp_confed_peers [vrf ] = copy .copy (self .upd_confed_peers )
2754
2715
else :
2755
2716
self .__delete_vrf_asn (vrf , table , data )
2756
- elif table == 'SRV6_LOCATOR' :
2757
- key = prefix
2758
- prefix = data ['prefix' ]
2759
- cmd_prefix = ['configure terminal' , 'segment-routing' , 'srv6' , 'locators' ,
2760
- 'locator {}' .format (key ),
2761
- 'prefix {} block-len {} node-len {} func-bits {}' .format (prefix .data , data ['block_len' ].data , data ['node_len' ].data , data ['func_len' ].data )]
2762
-
2763
- if not key_map .run_command (self , table , data , cmd_prefix ):
2764
- syslog .syslog (syslog .LOG_ERR , 'failed running SRV6 LOCATOR config command' )
2717
+ elif table == 'SRV6_MY_LOCATORS' :
2718
+ if key is None :
2719
+ syslog .syslog (syslog .LOG_ERR , 'invalid key for SRV6_MY_LOCATORS table' )
2720
+ continue
2721
+ if not del_table :
2722
+ key = prefix
2723
+ prefix = data ['prefix' ]
2724
+ cmd = "vtysh -c 'configure terminal' -c 'segment-routing' -c 'srv6' -c 'locators' "
2725
+ cmd += " -c 'locator {}' " .format (key )
2726
+ cmd += " -c 'prefix {} block-len {} node-len {} func-bits {}' " .format (prefix .data , data ['block_len' ].data , data ['node_len' ].data , data ['func_len' ].data )
2727
+ if not self .__run_command (table , cmd ):
2728
+ syslog .syslog (syslog .LOG_ERR , 'failed running SRV6 POLICY config command' )
2729
+ continue
2730
+ elif table == 'SRV6_MY_SIDS' :
2731
+ if key is None :
2732
+ syslog .syslog (syslog .LOG_ERR , 'invalid key for SRV6_MY_SIDS table' )
2765
2733
continue
2766
-
2734
+ if not del_table :
2735
+ cmd = "vtysh -c 'configure terminal' -c 'segment-routing' -c 'srv6' "
2736
+ cmd += "-c 'static-sids' "
2737
+ uDTAction = ["uDT46" , "uDT4" , "uDT6" ]
2738
+ if data ['action' ].data in uDTAction :
2739
+ cmd += "-c 'sid {} locator {} behavior {} vrf {}' " .format (key , prefix , data ['action' ].data , data ['decap_vrf' ].data )
2740
+ elif data ['action' ].data == 'uN' :
2741
+ cmd += "-c 'sid {} locator {} behavior {} ' " .format (key , prefix , data ['action' ].data )
2742
+ else :
2743
+ syslog .syslog (syslog .LOG_ERR , 'failed running SRV6 POLICY config command, not support action %s' .format (data ['action' ].data ))
2744
+ continue
2745
+ if not self .__run_command (table , cmd ):
2746
+ syslog .syslog (syslog .LOG_ERR , 'failed running SRV6 SRV6_MY_SIDS config command' )
2747
+ continue
2748
+
2767
2749
elif table == 'BGP_GLOBALS_AF' :
2768
2750
af , ip_type = key .lower ().split ('_' )
2769
2751
#this is to temporarily make table cache key accessible to key_map handler function
0 commit comments