Skip to content

Commit

Permalink
Merge branch 'master' into v6erspan
Browse files Browse the repository at this point in the history
  • Loading branch information
prsunny authored Oct 24, 2024
2 parents aafae7b + 064f2e3 commit 5301600
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 38 deletions.
2 changes: 0 additions & 2 deletions orchagent/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ INCLUDES = -I $(top_srcdir)/lib \
-I pbh \
-I nhg

if GCOV_ENABLED
SUBDIRS = p4orch/tests
endif

CFLAGS_SAI = -I /usr/include/sai

Expand Down
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;
}
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());
}
else
{
Expand Down
33 changes: 5 additions & 28 deletions orchagent/p4orch/tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ INCLUDES = -I $(top_srcdir) -I $(ORCHAGENT_DIR) -I $(P4ORCH_DIR) -I $(top_srcdir

CFLAGS_SAI = -I /usr/include/sai

TESTS = p4orch_tests p4orch_tests_asan p4orch_tests_tsan p4orch_tests_usan
TESTS = p4orch_tests

noinst_PROGRAMS = p4orch_tests p4orch_tests_asan p4orch_tests_tsan p4orch_tests_usan
noinst_PROGRAMS = p4orch_tests

if DEBUG
DBGFLAGS = -ggdb -DDEBUG
Expand All @@ -16,11 +16,6 @@ endif

CFLAGS_GTEST =
LDADD_GTEST = -lgtest -lgtest_main -lgmock -lgmock_main
CFLAGS_COVERAGE = --coverage -fprofile-arcs -ftest-coverage
LDADD_COVERAGE = -lgcov
CFLAGS_ASAN = -fsanitize=address
CFLAGS_TSAN = -fsanitize=thread
CFLAGS_USAN = -fsanitize=undefined

p4orch_tests_SOURCES = $(ORCHAGENT_DIR)/orch.cpp \
$(ORCHAGENT_DIR)/vrforch.cpp \
Expand Down Expand Up @@ -83,24 +78,6 @@ p4orch_tests_SOURCES = $(ORCHAGENT_DIR)/orch.cpp \
mock_sai_switch.cpp \
mock_sai_udf.cpp

p4orch_tests_CFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) $(CFLAGS_COVERAGE) $(CFLAGS_SAI)
p4orch_tests_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) $(CFLAGS_COVERAGE) $(CFLAGS_SAI)
p4orch_tests_LDADD = $(LDADD_GTEST) $(LDADD_COVERAGE) -lpthread -lsairedis -lswsscommon -lsaimeta -lsaimetadata -lzmq

p4orch_tests_asan_SOURCES = $(p4orch_tests_SOURCES)
p4orch_tests_asan_CFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) $(CFLAGS_ASAN) $(CFLAGS_SAI)
p4orch_tests_asan_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) $(CFLAGS_ASAN) $(CFLAGS_SAI)
p4orch_tests_asan_LDFLAGS = $(CFLAGS_ASAN)
p4orch_tests_asan_LDADD = $(LDADD_GTEST) -lpthread -lsairedis -lswsscommon -lsaimeta -lsaimetadata -lzmq

p4orch_tests_tsan_SOURCES = $(p4orch_tests_SOURCES)
p4orch_tests_tsan_CFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) $(CFLAGS_TSAN) $(CFLAGS_SAI)
p4orch_tests_tsan_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) $(CFLAGS_TSAN) $(CFLAGS_SAI)
p4orch_tests_tsan_LDFLAGS = $(CFLAGS_TSAN)
p4orch_tests_tsan_LDADD = $(LDADD_GTEST) -lpthread -lsairedis -lswsscommon -lsaimeta -lsaimetadata -lzmq

p4orch_tests_usan_SOURCES = $(p4orch_tests_SOURCES)
p4orch_tests_usan_CFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) $(CFLAGS_USAN) $(CFLAGS_SAI)
p4orch_tests_usan_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) $(CFLAGS_USAN) $(CFLAGS_SAI)
p4orch_tests_usan_LDFLAGS = $(CFLAGS_USAN)
p4orch_tests_usan_LDADD = $(LDADD_GTEST) -lpthread -lsairedis -lswsscommon -lsaimeta -lsaimetadata -lzmq
p4orch_tests_CFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) $(CFLAGS_SAI) $(CFLAGS_ASAN)
p4orch_tests_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) $(CFLAGS_SAI) $(CFLAGS_ASAN)
p4orch_tests_LDADD = $(LDADD_GTEST) $(LDFLAGS_ASAN) -lpthread -lsairedis -lswsscommon -lsaimeta -lsaimetadata -lzmq
8 changes: 8 additions & 0 deletions orchagent/p4orch/tests/acl_manager_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2849,6 +2849,8 @@ TEST_F(AclManagerTest, AclRuleWithColorPacketActionsButNoRateLimit)
acl_rule->action_fvs[SAI_ACL_ENTRY_ATTR_ACTION_SET_USER_TRAP_ID].aclaction.parameter.oid);
}

#pragma GCC diagnostic warning "-Wdisabled-optimization"

TEST_F(AclManagerTest, AclRuleWithValidAction)
{
ASSERT_NO_FATAL_FAILURE(AddDefaultIngressTable());
Expand Down Expand Up @@ -3201,6 +3203,8 @@ TEST_F(AclManagerTest, AclRuleWithValidAction)
EXPECT_EQ(nullptr, GetAclRule(kAclIngressTableName, acl_rule_key));
}

#pragma GCC diagnostic pop

TEST_F(AclManagerTest, AclRuleWithVrfAction)
{
ASSERT_NO_FATAL_FAILURE(AddDefaultIngressTable());
Expand Down Expand Up @@ -3410,6 +3414,8 @@ TEST_F(AclManagerTest, AclRuleWithIpTypeBitEncoding)
ASSERT_EQ(nullptr, acl_rule);
}

#pragma GCC diagnostic warning "-Wdisabled-optimization"

TEST_F(AclManagerTest, UpdateAclRuleWithActionMeterChange)
{
ASSERT_NO_FATAL_FAILURE(AddDefaultIngressTable());
Expand Down Expand Up @@ -3834,6 +3840,8 @@ TEST_F(AclManagerTest, UpdateAclRuleWithActionMeterChange)
acl_rule->action_fvs[SAI_ACL_ENTRY_ATTR_ACTION_SET_USER_TRAP_ID].aclaction.parameter.oid);
}

#pragma GCC diagnostic pop

TEST_F(AclManagerTest, UpdateAclRuleWithVrfActionChange)
{
ASSERT_NO_FATAL_FAILURE(AddDefaultIngressTable());
Expand Down
6 changes: 3 additions & 3 deletions orchagent/p4orch/tests/wcmp_manager_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2291,7 +2291,7 @@ TEST_F(WcmpManagerTest, WatchportStateChangetoOperDownSucceeds)
// Verify that the next hop member associated with the port is pruned.
std::string op = "port_state_change";
std::string data = "[{\"port_id\":\"oid:0x56789abcdff\",\"port_state\":\"SAI_PORT_OPER_"
"STATUS_DOWN\"}]";
"STATUS_DOWN\",\"port_error_status\":\"0\"}]";
EXPECT_CALL(mock_sai_next_hop_group_, remove_next_hop_group_member(Eq(kWcmpGroupMemberOid1)))
.WillOnce(Return(SAI_STATUS_SUCCESS));
HandlePortStatusChangeNotification(op, data);
Expand All @@ -2314,7 +2314,7 @@ TEST_F(WcmpManagerTest, WatchportStateChangeToOperUpSucceeds)
// restored.
std::string op = "port_state_change";
std::string data = "[{\"port_id\":\"oid:0x112233\",\"port_state\":\"SAI_PORT_OPER_"
"STATUS_UP\"}]";
"STATUS_UP\",\"port_error_status\":\"0\"}]";
EXPECT_CALL(mock_sai_next_hop_group_,
create_next_hop_group_member(_, Eq(gSwitchId), Eq(3),
Truly(std::bind(MatchSaiNextHopGroupMemberAttribute, kNexthopOid1, 2,
Expand All @@ -2339,7 +2339,7 @@ TEST_F(WcmpManagerTest, WatchportStateChangeFromOperUnknownToDownPrunesMemberOnl
// Verify that the pruned next hop member is not pruned again.
std::string op = "port_state_change";
std::string data = "[{\"port_id\":\"oid:0x56789abcfff\",\"port_state\":\"SAI_PORT_OPER_"
"STATUS_DOWN\"}]";
"STATUS_DOWN\",\"port_error_status\":\"0\"}]";
HandlePortStatusChangeNotification(op, data);
EXPECT_TRUE(VerifyWcmpGroupMemberInPortMap(app_db_entry.wcmp_group_members[0], true, 1));
EXPECT_TRUE(app_db_entry.wcmp_group_members[0]->pruned);
Expand Down
17 changes: 17 additions & 0 deletions tests/test_zmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,20 @@ def test_appliance(self, dvs):
for fv in fvs.items():
if fv[0] == "SAI_VIP_ENTRY_ATTR_ACTION":
assert fv[1] == "SAI_VIP_ENTRY_ACTION_ACCEPT"

def test_vrf(self, dvs):
# Improve test code coverage, change orchagent to use VRF
dvs.runcmd("cp /usr/bin/orchagent.sh /usr/bin/orchagent.sh_vrf_ut_backup")
dvs.runcmd("sed -i.bak 's/\/usr\/bin\/orchagent /\/usr\/bin\/orchagent -v mgmt /g' /usr/bin/orchagent.sh")
dvs.stop_swss()
dvs.start_swss()

# wait orchagent start
time.sleep(3)
process_statue = dvs.runcmd("ps -ef")
zmq_logger.debug("Process status: {}".format(process_statue))

# revert change
dvs.runcmd("cp /usr/bin/orchagent.sh_vrf_ut_backup /usr/bin/orchagent.sh")
dvs.stop_swss()
dvs.start_swss()
8 changes: 7 additions & 1 deletion tlm_teamd/values_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,13 @@ void ValuesStore::update(const std::vector<StringPair> & dumps)
{
const auto & storage = from_json(dumps);
const auto & old_keys = get_old_keys(storage);
remove_keys_db(old_keys);
// Do not delete te key from State Db. State DB LAB_TABLE entry is created/deleted
// from teamsyncd on detecting netlink of teamd dev as up/down. For some reason
// if we do not get state dump from teamdctl it might be transient issue. If it is
// persistent issue then teamsyncd might be able to catch it and delete state db entry
// or we can keep entry in it's current state as best effort. Similar to try_add_lag which is best effort
// to connect to teamdctl and if it fails we do not delete State Db entry.
//remove_keys_db(old_keys);
remove_keys_storage(old_keys);
const auto & keys_to_refresh = update_storage(storage);
update_db(storage, keys_to_refresh);
Expand Down

0 comments on commit 5301600

Please sign in to comment.