Skip to content

Commit

Permalink
Fix review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Junchao-Mellanox committed Apr 6, 2022
1 parent e40c736 commit ef23e3f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 14 deletions.
4 changes: 2 additions & 2 deletions orchagent/flex_counter/flowcounterrouteorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ void FlowCounterRouteOrch::onAddMiscRouteEntry(sai_object_id_t vrf_id, const sai
return;
}

IpPrefix ip_prefix = copy(ip_pfx);
IpPrefix ip_prefix = convert(ip_pfx);
onAddMiscRouteEntry(vrf_id, ip_prefix, add_to_cache);
}

Expand Down Expand Up @@ -350,7 +350,7 @@ void FlowCounterRouteOrch::onRemoveMiscRouteEntry(sai_object_id_t vrf_id, const
return;
}

IpPrefix ip_prefix = copy(ip_pfx);
IpPrefix ip_prefix = convert(ip_pfx);
onRemoveMiscRouteEntry(vrf_id, ip_prefix, remove_from_cache);
}

Expand Down
2 changes: 2 additions & 0 deletions orchagent/flex_counter/flowcounterrouteorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <string>
#include <vector>

#define ROUTE_FLOW_COUNTER_FLEX_COUNTER_GROUP "ROUTE_FLOW_COUNTER"

struct RoutePattern
{
RoutePattern(const std::string& input_vrf_name, sai_object_id_t vrf, IpPrefix prefix, size_t max_match_count)
Expand Down
5 changes: 0 additions & 5 deletions orchagent/routeorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,13 @@
#include "bulker.h"
#include "fgnhgorch.h"
#include <map>
#include <memory>
#include <set>
#include <sstream>

/* Maximum next hop group number */
#define NHGRP_MAX_SIZE 128
/* Length of the Interface Id value in EUI64 format */
#define EUI64_INTF_ID_LEN 8

#define LOOPBACK_PREFIX "Loopback"
#define ROUTE_FLOW_COUNTER_FLEX_COUNTER_GROUP "ROUTE_FLOW_COUNTER"

struct NextHopGroupMemberEntry
{
Expand Down Expand Up @@ -219,7 +215,6 @@ class RouteOrch : public Orch, public Subject

unsigned int getNhgCount() { return m_nextHopGroupCount; }
unsigned int getMaxNhgCount() { return m_maxNextHopGroupCount; }

void increaseNextHopGroupCount();
void decreaseNextHopGroupCount();
bool checkNextHopGroupCount();
Expand Down
2 changes: 1 addition & 1 deletion orchagent/swssnet.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static int getPrefixLenFromAddr(const uint8_t *addr, int len)

}

inline static IpPrefix copy(const sai_ip_prefix_t& src)
inline static IpPrefix convert(const sai_ip_prefix_t& src)
{
ip_addr_t ip;
switch(src.addr_family)
Expand Down
12 changes: 6 additions & 6 deletions tests/mock_tests/swssnet_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,32 @@ namespace swssnet_test
SwssNetTest() {}
};

TEST_F(SwssNetTest, CopySAIPrefixToSONiCPrefix)
TEST_F(SwssNetTest, CovertSAIPrefixToSONiCPrefix)
{
IpPrefix ip_prefix("1.2.3.4/24");
sai_ip_prefix_t sai_prefix;
swss::copy(sai_prefix, ip_prefix);
IpPrefix ip_prefix_copied = swss::copy(sai_prefix);
IpPrefix ip_prefix_copied = swss::convert(sai_prefix);
ASSERT_EQ("1.2.3.4/24", ip_prefix_copied.to_string());

IpPrefix ip_prefix1("1.2.3.4/32");
swss::copy(sai_prefix, ip_prefix1);
ip_prefix_copied = swss::copy(sai_prefix);
ip_prefix_copied = swss::convert(sai_prefix);
ASSERT_EQ("1.2.3.4/32", ip_prefix_copied.to_string());

IpPrefix ip_prefix2("0.0.0.0/0");
swss::copy(sai_prefix, ip_prefix2);
ip_prefix_copied = swss::copy(sai_prefix);
ip_prefix_copied = swss::convert(sai_prefix);
ASSERT_EQ("0.0.0.0/0", ip_prefix_copied.to_string());

IpPrefix ip_prefix3("2000::1/128");
swss::copy(sai_prefix, ip_prefix3);
ip_prefix_copied = swss::copy(sai_prefix);
ip_prefix_copied = swss::convert(sai_prefix);
ASSERT_EQ("2000::1/128", ip_prefix_copied.to_string());

IpPrefix ip_prefix4("::/0");
swss::copy(sai_prefix, ip_prefix4);
ip_prefix_copied = swss::copy(sai_prefix);
ip_prefix_copied = swss::convert(sai_prefix);
ASSERT_EQ("::/0", ip_prefix_copied.to_string());
}
}

0 comments on commit ef23e3f

Please sign in to comment.