Skip to content

Commit

Permalink
Merge branch 'master' into bridge-port-mac-learn
Browse files Browse the repository at this point in the history
  • Loading branch information
shine4chen authored and shine.chen committed Oct 4, 2019
2 parents c757ece + 953474a commit 53a3f1e
Show file tree
Hide file tree
Showing 39 changed files with 696 additions and 429 deletions.
22 changes: 11 additions & 11 deletions cfgmgr/buffermgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ namespace swss {
#define LOSSLESS_PGS "3-4"

typedef struct{
string size;
string xon;
string xon_offset;
string xoff;
string threshold;
std::string size;
std::string xon;
std::string xon_offset;
std::string xoff;
std::string threshold;
} pg_profile_t;

typedef map<string, pg_profile_t> speed_map_t;
typedef map<string, speed_map_t> pg_profile_lookup_t;
typedef std::map<std::string, pg_profile_t> speed_map_t;
typedef std::map<std::string, speed_map_t> pg_profile_lookup_t;

typedef map<string, string> port_cable_length_t;
typedef std::map<std::string, std::string> port_cable_length_t;

class BufferMgr : public Orch
{
public:
BufferMgr(DBConnector *cfgDb, DBConnector *stateDb, string pg_lookup_file, const vector<string> &tableNames);
BufferMgr(DBConnector *cfgDb, DBConnector *stateDb, std::string pg_lookup_file, const std::vector<std::string> &tableNames);
using Orch::doTask;

private:
Expand All @@ -44,8 +44,8 @@ class BufferMgr : public Orch
port_cable_length_t m_cableLenLookup;
std::string getPgPoolMode();
void readPgProfileLookupFile(std::string);
task_process_status doCableTask(string port, string cable_length);
task_process_status doSpeedUpdateTask(string port, string speed);
task_process_status doCableTask(std::string port, std::string cable_length);
task_process_status doSpeedUpdateTask(std::string port, std::string speed);

void doTask(Consumer &consumer);
};
Expand Down
12 changes: 6 additions & 6 deletions cfgmgr/intfmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ namespace swss {
class IntfMgr : public Orch
{
public:
IntfMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const vector<string> &tableNames);
IntfMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const std::vector<std::string> &tableNames);
using Orch::doTask;

private:
ProducerStateTable m_appIntfTableProducer;
Table m_cfgIntfTable, m_cfgVlanIntfTable;
Table m_statePortTable, m_stateLagTable, m_stateVlanTable, m_stateVrfTable, m_stateIntfTable;

void setIntfIp(const string &alias, const string &opCmd, const IpPrefix &ipPrefix);
void setIntfVrf(const string &alias, const string vrfName);
bool doIntfGeneralTask(const vector<string>& keys, const vector<FieldValueTuple>& data, const string& op);
bool doIntfAddrTask(const vector<string>& keys, const vector<FieldValueTuple>& data, const string& op);
void setIntfIp(const std::string &alias, const std::string &opCmd, const IpPrefix &ipPrefix);
void setIntfVrf(const std::string &alias, const std::string vrfName);
bool doIntfGeneralTask(const std::vector<std::string>& keys, const std::vector<FieldValueTuple>& data, const std::string& op);
bool doIntfAddrTask(const std::vector<std::string>& keys, const std::vector<FieldValueTuple>& data, const std::string& op);
void doTask(Consumer &consumer);
bool isIntfStateOk(const string &alias);
bool isIntfStateOk(const std::string &alias);
};

}
Expand Down
6 changes: 3 additions & 3 deletions cfgmgr/nbrmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ namespace swss {
class NbrMgr : public Orch
{
public:
NbrMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const vector<string> &tableNames);
NbrMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const std::vector<std::string> &tableNames);
using Orch::doTask;

bool isNeighRestoreDone();

private:
bool isIntfStateOk(const string &alias);
bool setNeighbor(const string& alias, const IpAddress& ip, const MacAddress& mac);
bool isIntfStateOk(const std::string &alias);
bool setNeighbor(const std::string& alias, const IpAddress& ip, const MacAddress& mac);

void doTask(Consumer &consumer);

Expand Down
12 changes: 6 additions & 6 deletions cfgmgr/portmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace swss {
class PortMgr : public Orch
{
public:
PortMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const vector<string> &tableNames);
PortMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const std::vector<std::string> &tableNames);

using Orch::doTask;
private:
Expand All @@ -26,13 +26,13 @@ class PortMgr : public Orch
Table m_statePortTable;
ProducerStateTable m_appPortTable;

set<string> m_portList;
std::set<std::string> m_portList;

void doTask(Consumer &consumer);
bool setPortMtu(const string &alias, const string &mtu);
bool setPortAdminStatus(const string &alias, const bool up);
bool setPortLearnMode(const string &alias, const string &learn_mode);
bool isPortStateOk(const string &alias);
bool setPortMtu(const std::string &alias, const std::string &mtu);
bool setPortAdminStatus(const std::string &alias, const bool up);
bool setPortLearnMode(const std::string &alias, const std::string &learn_mode);
bool isPortStateOk(const std::string &alias);
};

}
28 changes: 14 additions & 14 deletions cfgmgr/teammgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class TeamMgr : public Orch
{
public:
TeamMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *staDb,
const vector<TableConnector> &tables);
const std::vector<TableConnector> &tables);

using Orch::doTask;
private:
Expand All @@ -28,7 +28,7 @@ class TeamMgr : public Orch
ProducerStateTable m_appPortTable;
ProducerStateTable m_appLagTable;

set<string> m_lagList;
std::set<std::string> m_lagList;

MacAddress m_mac;

Expand All @@ -37,20 +37,20 @@ class TeamMgr : public Orch
void doLagMemberTask(Consumer &consumer);
void doPortUpdateTask(Consumer &consumer);

task_process_status addLag(const string &alias, int min_links, bool fall_back);
bool removeLag(const string &alias);
task_process_status addLagMember(const string &lag, const string &member);
bool removeLagMember(const string &lag, const string &member);
task_process_status addLag(const std::string &alias, int min_links, bool fall_back);
bool removeLag(const std::string &alias);
task_process_status addLagMember(const std::string &lag, const std::string &member);
bool removeLagMember(const std::string &lag, const std::string &member);

bool setLagAdminStatus(const string &alias, const string &admin_status);
bool setLagMtu(const string &alias, const string &mtu);
bool setLagLearnMode(const string &alias, const string &learn_mode);
bool setLagAdminStatus(const std::string &alias, const std::string &admin_status);
bool setLagMtu(const std::string &alias, const std::string &mtu);
bool setLagLearnMode(const std::tring &alias, const std::string &learn_mode);

bool isPortEnslaved(const string &);
bool findPortMaster(string &, const string &);
bool checkPortIffUp(const string &);
bool isPortStateOk(const string&);
bool isLagStateOk(const string&);
bool isPortEnslaved(const std::string &);
bool findPortMaster(std::string &, const std::string &);
bool checkPortIffUp(const std::string &);
bool isPortStateOk(const std::string&);
bool isLagStateOk(const std::string&);
};

}
16 changes: 8 additions & 8 deletions cfgmgr/vlanmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace swss {
class VlanMgr : public Orch
{
public:
VlanMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const vector<string> &tableNames);
VlanMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const std::vector<std::string> &tableNames);
using Orch::doTask;

private:
Expand All @@ -27,18 +27,18 @@ class VlanMgr : public Orch
void doTask(Consumer &consumer);
void doVlanTask(Consumer &consumer);
void doVlanMemberTask(Consumer &consumer);
void processUntaggedVlanMembers(string vlan, const string &members);
void processUntaggedVlanMembers(std::string vlan, const std::string &members);

bool addHostVlan(int vlan_id);
bool removeHostVlan(int vlan_id);
bool setHostVlanAdminState(int vlan_id, const string &admin_status);
bool setHostVlanAdminState(int vlan_id, const std::string &admin_status);
bool setHostVlanMtu(int vlan_id, uint32_t mtu);
bool addHostVlanMember(int vlan_id, const string &port_alias, const string& tagging_mode);
bool removeHostVlanMember(int vlan_id, const string &port_alias);
bool isMemberStateOk(const string &alias);
bool isVlanStateOk(const string &alias);
bool addHostVlanMember(int vlan_id, const std::string &port_alias, const std::string& tagging_mode);
bool removeHostVlanMember(int vlan_id, const std::string &port_alias);
bool isMemberStateOk(const std::string &alias);
bool isVlanStateOk(const std::string &alias);
bool isVlanMacOk();
bool isVlanMemberStateOk(const string &vlanMemberKey);
bool isVlanMemberStateOk(const std::string &vlanMemberKey);
};

}
Expand Down
8 changes: 4 additions & 4 deletions cfgmgr/vrfmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ namespace swss {
class VrfMgr : public Orch
{
public:
VrfMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const vector<string> &tableNames);
VrfMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const std::vector<std::string> &tableNames);
using Orch::doTask;

private:
bool delLink(const string& vrfName);
bool setLink(const string& vrfName);
bool delLink(const std::string& vrfName);
bool setLink(const std::string& vrfName);
void recycleTable(uint32_t table);
uint32_t getFreeTable(void);
void handleVnetConfigSet(KeyOpFieldsValuesTuple &t);
void doTask(Consumer &consumer);

map<string, uint32_t> m_vrfTableMap;
std::map<std::string, uint32_t> m_vrfTableMap;
set<uint32_t> m_freeTables;

Table m_stateVrfTable;
Expand Down
2 changes: 1 addition & 1 deletion cfgmgr/vxlanmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace swss {
class VxlanMgr : public Orch
{
public:
VxlanMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const vector<std::string> &tableNames);
VxlanMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const std::vector<std::string> &tableNames);
using Orch::doTask;

typedef struct VxlanInfo
Expand Down
4 changes: 4 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
sonic (1.0.0) stable; urgency=medium

* next-hop key add ifname

-- Tyler Li <tyler.li@mediatek.com> Thu, 19 Sep 2019 04:00:00 -0700

* Initial release.

-- Shuotian Cheng <shuche@microsoft.com> Wed, 09 Mar 2016 12:00:00 -0800
Expand Down
6 changes: 4 additions & 2 deletions doc/swss-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,10 @@ Stores rules associated with a specific ACL table on the switch.
; it could be:
: name of physical port. Example: "Ethernet10"
: name of LAG port Example: "PortChannel5"
: next-hop ip address Example: "10.0.0.1"
: next-hop group set of addresses Example: "10.0.0.1,10.0.0.3"
: next-hop ip address (in global) Example: "10.0.0.1"
: next-hop ip address and vrf Example: "10.0.0.2@Vrf2"
: next-hop ip address and ifname Example: "10.0.0.3@Ethernet1"
: next-hop group set of next-hop Example: "10.0.0.1,10.0.0.3@Ethernet1"

redirect_action = 1*255CHAR ; redirect parameter
; This parameter defines a destination for redirected packets
Expand Down
11 changes: 11 additions & 0 deletions fpmsyncd/routesync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,17 @@ string RouteSync::getNextHopGw(struct rtnl_route *route_obj)
nl_addr2str(addr, gw_ip, MAX_ADDR_SIZE);
result += gw_ip;
}
else
{
if (rtnl_route_get_family(route_obj) == AF_INET)
{
result += "0.0.0.0";
}
else
{
result += "::";
}
}

if (i + 1 < rtnl_route_get_nnexthops(route_obj))
{
Expand Down
34 changes: 17 additions & 17 deletions orchagent/aclorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,12 +546,12 @@ void AclRule::decreaseNextHopRefCount()
{
if (!m_redirect_target_next_hop.empty())
{
m_pAclOrch->m_neighOrch->decreaseNextHopRefCount(IpAddress(m_redirect_target_next_hop));
m_pAclOrch->m_neighOrch->decreaseNextHopRefCount(NextHopKey(m_redirect_target_next_hop));
m_redirect_target_next_hop.clear();
}
if (!m_redirect_target_next_hop_group.empty())
{
IpAddresses target = IpAddresses(m_redirect_target_next_hop_group);
NextHopGroupKey target = NextHopGroupKey(m_redirect_target_next_hop_group);
m_pAclOrch->m_routeOrch->decreaseNextHopRefCount(target);
// remove next hop group in case it's not used by anything else
if (m_pAclOrch->m_routeOrch->isRefCounterZero(target))
Expand Down Expand Up @@ -880,44 +880,44 @@ sai_object_id_t AclRuleL3::getRedirectObjectId(const string& redirect_value)
}
}

// Try to parse nexthop ip address
// Try to parse nexthop ip address and interface name
try
{
IpAddress ip(target);
if (!m_pAclOrch->m_neighOrch->hasNextHop(ip))
NextHopKey nh(target);
if (!m_pAclOrch->m_neighOrch->hasNextHop(nh))
{
SWSS_LOG_ERROR("ACL Redirect action target next hop ip: '%s' doesn't exist on the switch", ip.to_string().c_str());
SWSS_LOG_ERROR("ACL Redirect action target next hop ip: '%s' doesn't exist on the switch", nh.to_string().c_str());
return SAI_NULL_OBJECT_ID;
}

m_redirect_target_next_hop = target;
m_pAclOrch->m_neighOrch->increaseNextHopRefCount(ip);
return m_pAclOrch->m_neighOrch->getNextHopId(ip);
m_pAclOrch->m_neighOrch->increaseNextHopRefCount(nh);
return m_pAclOrch->m_neighOrch->getNextHopId(nh);
}
catch (...)
{
// no error, just try next variant
}

// try to parse nh group ip addresses
// try to parse nh group the set of <ip address, interface name>
try
{
IpAddresses ips(target);
if (!m_pAclOrch->m_routeOrch->hasNextHopGroup(ips))
NextHopGroupKey nhg(target);
if (!m_pAclOrch->m_routeOrch->hasNextHopGroup(nhg))
{
SWSS_LOG_INFO("ACL Redirect action target next hop group: '%s' doesn't exist on the switch. Creating it.", ips.to_string().c_str());
SWSS_LOG_INFO("ACL Redirect action target next hop group: '%s' doesn't exist on the switch. Creating it.", nhg.to_string().c_str());

if (!m_pAclOrch->m_routeOrch->addNextHopGroup(ips))
if (!m_pAclOrch->m_routeOrch->addNextHopGroup(nhg))
{
SWSS_LOG_ERROR("Can't create required target next hop group '%s'", ips.to_string().c_str());
SWSS_LOG_ERROR("Can't create required target next hop group '%s'", nhg.to_string().c_str());
return SAI_NULL_OBJECT_ID;
}
SWSS_LOG_DEBUG("Created acl redirect target next hop group '%s'", ips.to_string().c_str());
SWSS_LOG_DEBUG("Created acl redirect target next hop group '%s'", nhg.to_string().c_str());
}

m_redirect_target_next_hop_group = target;
m_pAclOrch->m_routeOrch->increaseNextHopRefCount(ips);
return m_pAclOrch->m_routeOrch->getNextHopGroupId(ips);
m_pAclOrch->m_routeOrch->increaseNextHopRefCount(nhg);
return m_pAclOrch->m_routeOrch->getNextHopGroupId(nhg);
}
catch (...)
{
Expand Down
Loading

0 comments on commit 53a3f1e

Please sign in to comment.