Skip to content

Commit

Permalink
Initialize meta
Browse files Browse the repository at this point in the history
Uninitialized meta fields caused some failed tests.

Signed-off-by: Kiran Shastri <shastrinator@gmail.com>
  • Loading branch information
shastrinator committed Oct 27, 2020
1 parent bf30e36 commit 8267122
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
11 changes: 6 additions & 5 deletions agent-ovs/ovs/PacketLogHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,12 @@ void PacketLogHandler::getDropReason(ParseInfo &p, std::string &dropReason) {
break;
}
}

boost::optional<std::string> ruleUri = idGen.getStringForId((IntFlowManager::getIdNamespace(L24Classifier::CLASS_ID)), p.meta[3]);

if (ruleUri) {
dropReason += " "+ruleUri.get();
if((p.meta[2] == 1) || (p.meta[2]==2)) {
boost::optional<std::string> ruleUri = idGen.getStringForId((IntFlowManager::getIdNamespace(L24Classifier::CLASS_ID)), p.meta[3]);

if (ruleUri) {
dropReason += " "+ruleUri.get();
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion agent-ovs/ovs/include/PacketDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ struct ParseInfo {
nextKey(0), optionLayerTypeId(0), parsedLength(0), parsedString(),
formattedFields(), layerFormatterString(), hasOptBytes(false),
pendingOptionLength(0), inferredLength(0), inferredDataLength(0),
scratchpad{0,0,0,0}, packetTuple(), pruneLog(false) {
scratchpad{0,0,0,0}, packetTuple(), meta{0,0,0,0}, pruneLog(false) {
time_t rawtime = std::time(nullptr);
char currTime[256];
struct tm tp;
Expand Down
8 changes: 4 additions & 4 deletions agent-ovs/ovs/test/PacketDecoder_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ BOOST_FIXTURE_TEST_CASE(tcp_test, PacketDecoderFixture) {
BOOST_FIXTURE_TEST_CASE(udp_test, PacketDecoderFixture) {
auto pktDecoder = pktLogger.getDecoder();
ParseInfo p(&pktDecoder);
PacketTuple expectedTuple("", "Acc-SEC_GROUP_OUT_TABLE", "9e:72:a6:94:18:af", "5a:08:66:ce:0b:49", "IPv4", "14.0.0.2", "100.0.0.1" ,"UDP", "60376", "161");
PacketTuple expectedTuple("", "Acc-SEC_GROUP_OUT_TABLE MISS", "9e:72:a6:94:18:af", "5a:08:66:ce:0b:49", "IPv4", "14.0.0.2", "100.0.0.1" ,"UDP", "60376", "161");
std::string expected(" MAC=5a:08:66:ce:0b:49:9e:72:a6:94:18:af:IPv4 SRC=14.0.0.2 DST=100.0.0.1 LEN=28 DSCP=0 TTL=255 ID=0 FLAGS=0 FRAG=0 PROTO=UDP SPT=60376 DPT=161 LEN=74");
int ret = pktDecoder.decode(udp_buf, 66, p);
BOOST_CHECK(ret == 0);
Expand All @@ -207,7 +207,7 @@ BOOST_FIXTURE_TEST_CASE(udp_test, PacketDecoderFixture) {
BOOST_FIXTURE_TEST_CASE(udp_over_v6_test, PacketDecoderFixture) {
auto pktDecoder = pktLogger.getDecoder();
ParseInfo p(&pktDecoder);
PacketTuple expectedTuple("", "Int-SERVICE_REV_TABLE", "9e:72:a6:94:18:af", "5a:08:66:ce:0b:49", "IPv6", "fe80::a00:27ff:fefe:8f95", "ff02::1:2" ,"UDP", "546", "547");
PacketTuple expectedTuple("", "Int-SERVICE_REV_TABLE MISS", "9e:72:a6:94:18:af", "5a:08:66:ce:0b:49", "IPv6", "fe80::a00:27ff:fefe:8f95", "ff02::1:2" ,"UDP", "546", "547");
std::string expected(" MAC=5a:08:66:ce:0b:49:9e:72:a6:94:18:af:IPv6 SRC=fe80::a00:27ff:fefe:8f95 DST=ff02::1:2 LEN=60 TC=0 HL=1 FL=0 PROTO=UDP SPT=546 DPT=547 LEN=60");
int ret = pktDecoder.decode(udpv6_buf, 86, p);
BOOST_CHECK(ret == 0);
Expand All @@ -221,7 +221,7 @@ BOOST_FIXTURE_TEST_CASE(udp_over_v6_test, PacketDecoderFixture) {
BOOST_FIXTURE_TEST_CASE(tcp_over_v6_test, PacketDecoderFixture) {
auto pktDecoder = pktLogger.getDecoder();
ParseInfo p(&pktDecoder);
PacketTuple expectedTuple("", "Int-BRIDGE_TABLE", "9e:72:a6:94:18:af", "5a:08:66:ce:0b:49", "IPv6", "fe80::a00:27ff:fefe:8f95", "ff02::1:2" ,"TCP", "41634", "179");
PacketTuple expectedTuple("", "Int-BRIDGE_TABLE MISS", "9e:72:a6:94:18:af", "5a:08:66:ce:0b:49", "IPv6", "fe80::a00:27ff:fefe:8f95", "ff02::1:2" ,"TCP", "41634", "179");
std::string expected(" MAC=5a:08:66:ce:0b:49:9e:72:a6:94:18:af:IPv6 SRC=fe80::a00:27ff:fefe:8f95 DST=ff02::1:2 LEN=60 TC=0 HL=1 FL=0 PROTO=TCP SPT=41634 DPT=179 SEQ=2939917199 ACK=0 LEN=10 WINDOWS=29200 SYN URGP=0");
int ret = pktDecoder.decode(tcpv6_buf, 118, p);
BOOST_CHECK(ret == 0);
Expand All @@ -235,7 +235,7 @@ BOOST_FIXTURE_TEST_CASE(tcp_over_v6_test, PacketDecoderFixture) {
BOOST_FIXTURE_TEST_CASE(ip_options_unrecognized_test, PacketDecoderFixture) {
auto pktDecoder = pktLogger.getDecoder();
ParseInfo p(&pktDecoder);
PacketTuple expectedTuple("", "Int-PORT_SECURITY_TABLE", "fa:16:3e:d3:f3:0b", "01:00:5e:00:00:16", "IPv4", "192.168.210.8", "224.0.0.22" ,"2_unrecognized", "", "");
PacketTuple expectedTuple("", "Int-PORT_SECURITY_TABLE MISS", "fa:16:3e:d3:f3:0b", "01:00:5e:00:00:16", "IPv4", "192.168.210.8", "224.0.0.22" ,"2_unrecognized", "", "");
std::string expected(" MAC=01:00:5e:00:00:16:fa:16:3e:d3:f3:0b:Qtag QTAG=4094 IPv4 SRC=192.168.210.8 DST=224.0.0.22 LEN=40 DSCP=48 TTL=1 ID=0 FLAGS=2 FRAG=0 PROTO=2_unrecognized");
int ret = pktDecoder.decode(igmp_buf, 178, p);
BOOST_CHECK(ret == 0);
Expand Down

0 comments on commit 8267122

Please sign in to comment.