Skip to content

Commit 61896f1

Browse files
Fix breakage for smartswitch usecase
Refer to sonic-net/sonic-buildimage#19638 The previous PR (#3979) inadvertantly caused the above issue. This commit fixes that by connecting to zmq from fpmsyncd using the vrf as well (if one is configured)
1 parent 0adab60 commit 61896f1

File tree

6 files changed

+40
-14
lines changed

6 files changed

+40
-14
lines changed

fpmsyncd/fpmsyncd.cpp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,31 @@ static bool eoiuFlagsSet(Table &bgpStateTable)
6969
return true;
7070
}
7171

72+
std::string get_zmq_vrf(DBConnector &cfgDb) {
73+
std::shared_ptr<std::string> mgmt_vrf_enabled = nullptr;
74+
75+
try
76+
{
77+
swss::DBConnector config_db("CONFIG_DB", 0);
78+
mgmt_vrf_enabled = config_db.hget("MGMT_VRF_CONFIG|vrf_global",
79+
"mgmtVrfEnabled");
80+
}
81+
catch (const std::runtime_error &e)
82+
{
83+
return std::string();
84+
}
85+
86+
if (!mgmt_vrf_enabled)
87+
{
88+
return std::string();
89+
}
90+
91+
if( *mgmt_vrf_enabled != "true") {
92+
return std::string();
93+
}
94+
return std::string("mgmt");
95+
}
96+
7297
int main(int argc, char **argv)
7398
{
7499
swss::Logger::linkToDbNative("fpmsyncd");
@@ -83,7 +108,8 @@ int main(int argc, char **argv)
83108
std::unique_ptr<NotificationConsumer> routeResponseChannel;
84109

85110
RedisPipeline pipeline(&db, ROUTE_SYNC_PPL_SIZE);
86-
RouteSync sync(&pipeline);
111+
auto zmqVrf = get_zmq_vrf(cfgDb);
112+
RouteSync sync(&pipeline, zmqVrf);
87113

88114
DBConnector stateDb("STATE_DB", 0);
89115
Table bgpStateTable(&stateDb, STATE_BGP_TABLE_NAME);

fpmsyncd/routesync.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ static decltype(auto) makeNlAddr(const T& ip)
145145
}
146146

147147

148-
RouteSync::RouteSync(RedisPipeline *pipeline) :
148+
RouteSync::RouteSync(RedisPipeline *pipeline, const std::string& zmqVrf) :
149149
// When the feature ORCH_NORTHBOND_ROUTE_ZMQ_ENABLED is enabled, route events must be sent to orchagent via the ZMQ channel.
150-
m_zmqClient(create_local_zmq_client(ORCH_NORTHBOND_ROUTE_ZMQ_ENABLED, false)),
150+
m_zmqClient(create_local_zmq_client(ORCH_NORTHBOND_ROUTE_ZMQ_ENABLED, false, zmqVrf)),
151151
m_routeTable(createProducerStateTable(pipeline, APP_ROUTE_TABLE_NAME, true, m_zmqClient)),
152152
m_nexthop_groupTable(pipeline, APP_NEXTHOP_GROUP_TABLE_NAME, true),
153153
m_label_routeTable(createProducerStateTable(pipeline, APP_LABEL_ROUTE_TABLE_NAME, true, m_zmqClient)),

fpmsyncd/routesync.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ class RouteSync : public NetMsg
178178
public:
179179
enum { MAX_ADDR_SIZE = 64 };
180180

181-
RouteSync(RedisPipeline *pipeline);
181+
RouteSync(RedisPipeline *pipeline, const std::string& zmqVrf = "");
182182

183183
virtual void onMsg(int nlmsg_type, struct nl_object *obj);
184184

lib/orch_zmq_config.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ bool swss::get_feature_status(std::string feature, bool default_value)
103103
return *enabled == "true";
104104
}
105105

106-
std::shared_ptr<swss::ZmqClient> swss::create_local_zmq_client(std::string feature, bool default_value)
106+
std::shared_ptr<swss::ZmqClient> swss::create_local_zmq_client(std::string feature, bool default_value, std::string vrf)
107107
{
108108
auto enable = get_feature_status(feature, default_value);
109109
if (enable) {
110-
SWSS_LOG_NOTICE("Feature %s enabled, Create ZMQ client : %s", feature.c_str(), ZMQ_LOCAL_ADDRESS);
111-
return create_zmq_client(ZMQ_LOCAL_ADDRESS);
110+
SWSS_LOG_NOTICE("Feature %s enabled, Create ZMQ client : %s, vrf: %s", feature.c_str(), ZMQ_LOCAL_ADDRESS, vrf.c_str());
111+
return create_zmq_client(ZMQ_LOCAL_ADDRESS, vrf);
112112
}
113113

114114
return nullptr;

lib/orch_zmq_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ std::shared_ptr<ZmqServer> create_zmq_server(std::string zmq_address, std::strin
3737

3838
bool get_feature_status(std::string feature, bool default_value);
3939

40-
std::shared_ptr<swss::ZmqClient> create_local_zmq_client(std::string feature, bool default_value);
40+
std::shared_ptr<swss::ZmqClient> create_local_zmq_client(std::string feature, bool default_value, std::string vrf="");
4141

4242
std::shared_ptr<swss::ProducerStateTable> createProducerStateTable(DBConnector *db, const std::string &tableName, std::shared_ptr<swss::ZmqClient> zmqClient);
4343

orchagent/main.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ uint32_t create_switch_timeout = 0;
8080

8181
void usage()
8282
{
83-
cout << "usage: orchagent [-h] [-r record_type] [-d record_location] [-f swss_rec_filename] [-j sairedis_rec_filename] [-b batch_size] [-m MAC] [-i INST_ID] [-s] [-z mode] [-k bulk_size] [-q zmq_server_address] [-c mode] [-t create_switch_timeout] [-v VRF] [-I heart_beat_interval] [-R] [-M]" << endl;
83+
cout << "usage: orchagent [-h] [-r record_type] [-d record_location] [-f swss_rec_filename] [-j sairedis_rec_filename] [-b batch_size] [-m MAC] [-i INST_ID] [-s] [-z mode] [-k bulk_size] [-q zmq_server_address] [-c mode] [-t create_switch_timeout] [-v ZMQVRF] [-I heart_beat_interval] [-R] [-M]" << endl;
8484
cout << " -h: display this message" << endl;
8585
cout << " -r record_type: record orchagent logs with type (default 3)" << endl;
8686
cout << " Bit 0: sairedis.rec, Bit 1: swss.rec, Bit 2: responsepublisher.rec. For example:" << endl;
@@ -101,7 +101,7 @@ void usage()
101101
cout << " -q zmq_server_address: ZMQ server address (default disable ZMQ)" << endl;
102102
cout << " -c counter mode (traditional|asic_db), default: asic_db" << endl;
103103
cout << " -t Override create switch timeout, in sec" << endl;
104-
cout << " -v vrf: VRF name (default empty)" << endl;
104+
cout << " -v zmqvrf: ZMQVRF name (default empty)" << endl;
105105
cout << " -I heart_beat_interval: Heart beat interval in millisecond (default 10)" << endl;
106106
cout << " -R enable the ring thread feature" << endl;
107107
cout << " -M enable SAI MACSec POST" << endl;
@@ -367,7 +367,7 @@ int main(int argc, char **argv)
367367
string swss_rec_filename = Recorder::SWSS_FNAME;
368368
string sairedis_rec_filename = Recorder::SAIREDIS_FNAME;
369369
string zmq_server_address = "";
370-
string vrf;
370+
string zmq_vrf;
371371
string responsepublisher_rec_filename = Recorder::RESPPUB_FNAME;
372372
int record_type = 3; // Only swss and sairedis recordings enabled by default.
373373
long heartBeatInterval = HEART_BEAT_INTERVAL_MSECS_DEFAULT;
@@ -471,7 +471,7 @@ int main(int argc, char **argv)
471471
case 'v':
472472
if (optarg)
473473
{
474-
vrf = optarg;
474+
zmq_vrf = optarg;
475475
}
476476
break;
477477
case 'I':
@@ -545,8 +545,8 @@ int main(int argc, char **argv)
545545
}
546546
else
547547
{
548-
SWSS_LOG_NOTICE("The ZMQ channel on the northbound side of orchagent has been initialized: %s, %s", zmq_server_address.c_str(), vrf.c_str());
549-
zmq_server = create_zmq_server(zmq_server_address);
548+
SWSS_LOG_NOTICE("The ZMQ channel on the northbound side of orchagent has been initialized: %s, %s", zmq_server_address.c_str(), zmq_vrf.c_str());
549+
zmq_server = create_zmq_server(zmq_server_address, zmq_vrf);
550550
}
551551

552552
// Get switch_type

0 commit comments

Comments
 (0)