Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mgmt VRF support. #3299

Merged
merged 15 commits into from
Oct 24, 2024
16 changes: 12 additions & 4 deletions orchagent/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ uint32_t create_switch_timeout = 0;

void usage()
{
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]" << endl;
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]" << endl;
cout << " -h: display this message" << endl;
cout << " -r record_type: record orchagent logs with type (default 3)" << endl;
cout << " Bit 0: sairedis.rec, Bit 1: swss.rec, Bit 2: responsepublisher.rec. For example:" << endl;
Expand All @@ -94,6 +94,7 @@ void usage()
cout << " -q zmq_server_address: ZMQ server address (default disable ZMQ)" << endl;
cout << " -c counter mode (traditional|asic_db), default: asic_db" << endl;
cout << " -t Override create switch timeout, in sec" << endl;
cout << " -v vrf: VRF name (default empty)" << endl;
}

void sighup_handler(int signo)
Expand Down Expand Up @@ -344,11 +345,12 @@ int main(int argc, char **argv)
string swss_rec_filename = Recorder::SWSS_FNAME;
string sairedis_rec_filename = Recorder::SAIREDIS_FNAME;
string zmq_server_address = "tcp://127.0.0.1:" + to_string(ORCH_ZMQ_PORT);
string vrf;
bool enable_zmq = false;
string responsepublisher_rec_filename = Recorder::RESPPUB_FNAME;
int record_type = 3; // Only swss and sairedis recordings enabled by default.

while ((opt = getopt(argc, argv, "b:m:r:f:j:d:i:hsz:k:q:c:t:")) != -1)
while ((opt = getopt(argc, argv, "b:m:r:f:j:d:i:hsz:k:q:c:t:v:")) != -1)
{
switch (opt)
{
Expand Down Expand Up @@ -442,6 +444,12 @@ int main(int argc, char **argv)
case 't':
create_switch_timeout = atoi(optarg);
break;
case 'v':
if (optarg)
{
vrf = optarg;
Copy link
Contributor

@qiluo-msft qiluo-msft Oct 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is it used? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When mgmt VRF feature enabled, orchagent need start with "-v mgmt" parameter. "mgmt" is the VRF name.

Here is the code change:
sonic-net/sonic-buildimage#20345

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part of code can't cover by VS test because VS test does not enable VRF.
There already VRF test case failed in sonic-mgmt, and will fix by this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will add a test case for code coverage

}
break;
default: /* '?' */
exit(EXIT_FAILURE);
}
Expand Down Expand Up @@ -486,8 +494,8 @@ int main(int argc, char **argv)
shared_ptr<ZmqServer> zmq_server = nullptr;
if (enable_zmq)
{
SWSS_LOG_NOTICE("Instantiate ZMQ server : %s", zmq_server_address.c_str());
zmq_server = make_shared<ZmqServer>(zmq_server_address.c_str());
SWSS_LOG_NOTICE("Instantiate ZMQ server : %s, %s", zmq_server_address.c_str(), vrf.c_str());
zmq_server = make_shared<ZmqServer>(zmq_server_address.c_str(), vrf.c_str());
liuh-80 marked this conversation as resolved.
Show resolved Hide resolved
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions tests/dash/dash_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ def __setitem__(self, key: str, pairs: typing.Union[dict, list, tuple]):
for k, v in pairs:
pairs_str.append((to_string(k), to_string(v)))
self.set(key, pairs_str)
time.sleep(1)
time.sleep(3)

def __delitem__(self, key: str):
self.delete(str(key))
time.sleep(1)
time.sleep(3)


class Table(swsscommon.Table):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_zmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def enable_orchagent_zmq(self, dvs):
# change orchagent to use ZMQ
# change orchagent to use custom create_switch_timeout
dvs.runcmd("cp /usr/bin/orchagent.sh /usr/bin/orchagent.sh_zmq_ut_backup")
dvs.runcmd("sed -i.bak 's/\/usr\/bin\/orchagent /\/usr\/bin\/orchagent -q tcp:\/\/127.0.0.1:8100 -t 60 /g' /usr/bin/orchagent.sh")
dvs.runcmd("sed -i.bak 's/\/usr\/bin\/orchagent /\/usr\/bin\/orchagent -q tcp:\/\/127.0.0.1:8100 -t 60 -v \'\'/g' /usr/bin/orchagent.sh")
dvs.stop_swss()
dvs.start_swss()

Expand Down
Loading