diff --git a/meta/gensairpc.pl b/meta/gensairpc.pl index 13b1f6a8b..6a05e182a 100755 --- a/meta/gensairpc.pl +++ b/meta/gensairpc.pl @@ -281,7 +281,7 @@ sub generate_server_template_from_skeleton { # Define global variable before "class" print {$server_template} -"\nextern sai_object_id_t switch_id;\nsai_object_id_t switch_id;\n\n\n"; +"\nextern sai_object_id_t switch_id;\nsai_object_id_t switch_id;\nextern sai_object_id_t gSwitchId;\n\n\n"; # Define helper functions print {$server_template} "[% PROCESS helper_functions %]\n\n\n"; diff --git a/meta/templates/sai_rpc_server_functions.tt b/meta/templates/sai_rpc_server_functions.tt index 6763e8001..de154d7de 100644 --- a/meta/templates/sai_rpc_server_functions.tt +++ b/meta/templates/sai_rpc_server_functions.tt @@ -54,6 +54,12 @@ if (switch_id != NULL) { return switch_id; } + + //check if the switch created in syncd + if (gSwitchId != NULL) { + switch_id = gSwitchId; + return switch_id; + } [%- END -%]