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

Implementation of System ports initialization, Interface & Neighbor Synchronization... #1431

Merged
merged 30 commits into from
Jan 17, 2021
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
30c8a0c
[voq] Redis instance for global app db
Sep 10, 2020
bfb6f2f
[voq] System port init and orchestration
Sep 10, 2020
ee967d9
[voq] Router interface for system ports, global app db sync
Sep 10, 2020
45942e7
[voq] Inband interface config
Sep 10, 2020
10771a8
[voq] System port neighbors
Sep 10, 2020
2ca2a00
[swss] Review comments fixes
Sep 29, 2020
8e235e6
[swss]Code review comments fix 2
Oct 1, 2020
52fe3e1
Merge branch 'master' into chassis-voq-pr1
vganesan-nokia Oct 1, 2020
1b6d62f
Merge branch 'master' into chassis-voq-pr1
vganesan-nokia Oct 11, 2020
8704004
[swss] voq code review comment fix 3
Oct 12, 2020
8b68af4
[swss] voq code review comments fixes 4
Oct 13, 2020
52972b6
[swss] Voq code review comments fixes 5
Oct 22, 2020
b6fe4e6
Merge branch 'master' into chassis-voq-pr1
vganesan-nokia Nov 3, 2020
34e9f68
[swss]VS tests for VOQ system ports
Nov 9, 2020
a42d3f5
[vstest]Voq switch test - removed chassis_db.json
Nov 20, 2020
8922f46
[vstest]VOQ switch system ports test
Nov 21, 2020
d9df781
[swss]VOQ Code review comments fix 6
Nov 21, 2020
39b1858
Merge branch 'master' into chassis-voq-pr1
vganesan-nokia Nov 30, 2020
21b7cd6
Merge branch 'master' into chassis-voq-pr1
vganesan-nokia Dec 2, 2020
233a1be
[swss]vs test for voq neighbor
Dec 3, 2020
e9fc950
[swss]vs test for voq nbr review comments fix 1
Dec 8, 2020
ae86130
[swss]vs test for voq nbr review comments fix 2
Dec 9, 2020
2d090d5
Merge branch 'master' into chassis-voq-pr1
vganesan-nokia Dec 18, 2020
d93ea79
[systemport]VOQ system port code review comments fix - 7
Dec 22, 2020
40fb3fc
[systemport] VS test chgs in code review comments fix - 7 reverted
Dec 22, 2020
a5c2533
Merge branch 'master' into chassis-voq-pr1
vganesan-nokia Dec 23, 2020
96d5a71
[systemport] Rebase to master, neighorch conflict fix
Dec 23, 2020
5878628
Merge remote-tracking branch 'vganesan-nokia/master' into chassis-voq…
Jan 12, 2021
0ab5d95
Merge remote-tracking branch 'origin/master' into chassis-voq-pr1
Jan 15, 2021
08b256b
[voq] azure-pipeline armhf build error fix
Jan 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cfgmgr/intfmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,8 @@ void IntfMgr::doTask(Consumer &consumer)
{
SWSS_LOG_ENTER();

string table_name = consumer.getTableName();

auto it = consumer.m_toSync.begin();
while (it != consumer.m_toSync.end())
{
Expand All @@ -688,6 +690,16 @@ void IntfMgr::doTask(Consumer &consumer)

if (keys.size() == 1)
{
if((table_name == CFG_VOQ_INBAND_INTERFACE_TABLE_NAME) &&
(op == SET_COMMAND))
{
//No further processing needed. Just relay to orchagent
m_appIntfTableProducer.set(keys[0], data);
m_stateIntfTable.hset(keys[0], "vrf", "");

it = consumer.m_toSync.erase(it);
continue;
}
if (!doIntfGeneralTask(keys, data, op))
{
it++;
Expand Down
1 change: 1 addition & 0 deletions cfgmgr/intfmgrd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ int main(int argc, char **argv)
CFG_VLAN_INTF_TABLE_NAME,
CFG_LOOPBACK_INTERFACE_TABLE_NAME,
CFG_VLAN_SUB_INTF_TABLE_NAME,
CFG_VOQ_INBAND_INTERFACE_TABLE_NAME,
};

DBConnector cfgDb("CONFIG_DB", 0);
Expand Down
262 changes: 261 additions & 1 deletion cfgmgr/nbrmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "nbrmgr.h"
#include "exec.h"
#include "shellcmd.h"
#include "subscriberstatetable.h"

using namespace swss;

Expand Down Expand Up @@ -64,6 +65,20 @@ NbrMgr::NbrMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, con
TableConsumable::DEFAULT_POP_BATCH_SIZE, default_orch_pri);
auto consumer = new Consumer(consumerStateTable, this, APP_NEIGH_RESOLVE_TABLE_NAME);
Orch::addExecutor(consumer);

string swtype;
Table cfgDeviceMetaDataTable(cfgDb, CFG_DEVICE_METADATA_TABLE_NAME);
if(cfgDeviceMetaDataTable.hget("localhost", "switch_type", swtype))
{
//If this is voq system, let the neighbor manager subscribe to state of SYSTEM_NEIGH
//entries. This is used to program static neigh and static route in kernel for remote neighbors.
if(swtype == "voq")
{
string tableName = STATE_SYSTEM_NEIGH_TABLE_NAME;
minionatwork marked this conversation as resolved.
Show resolved Hide resolved
Orch::addExecutor(new Consumer(new SubscriberStateTable(stateDb, tableName, TableConsumable::DEFAULT_POP_BATCH_SIZE, 0), this, tableName));
minionatwork marked this conversation as resolved.
Show resolved Hide resolved
m_cfgVoqInbandInterfaceTable = unique_ptr<Table>(new Table(cfgDb, CFG_VOQ_INBAND_INTERFACE_TABLE_NAME));
}
}
}

bool NbrMgr::isIntfStateOk(const string &alias)
Expand Down Expand Up @@ -294,8 +309,253 @@ void NbrMgr::doTask(Consumer &consumer)
} else if (table_name == APP_NEIGH_RESOLVE_TABLE_NAME)
{
doResolveNeighTask(consumer);
} else
} else if(table_name == STATE_SYSTEM_NEIGH_TABLE_NAME)
{
doStateSystemNeighTask(consumer);
}
else
{
SWSS_LOG_ERROR("Unknown REDIS table %s ", table_name.c_str());
}
}

void NbrMgr::doStateSystemNeighTask(Consumer &consumer)
{
SWSS_LOG_ENTER();

//Get the name of the device on which the neigh and route are
//going to be programmed.
string nbr_odev;
if(!getVoqInbandInterfaceName(nbr_odev))
{
//The inband interface is not available yet
return;
}

auto it = consumer.m_toSync.begin();
while (it != consumer.m_toSync.end())
{
KeyOpFieldsValuesTuple t = it->second;
string key = kfvKey(t);
string op = kfvOp(t);

size_t found = key.find_last_of(state_db_key_delimiter);
if (found == string::npos)
{
SWSS_LOG_ERROR("Failed to parse key %s", key.c_str());
it = consumer.m_toSync.erase(it);
continue;
}

IpAddress ip_address(key.substr(found+1));
if (op == SET_COMMAND)
{
MacAddress mac_address;
for (auto i = kfvFieldsValues(t).begin();
i != kfvFieldsValues(t).end(); i++)
{
if (fvField(*i) == "neigh")
mac_address = MacAddress(fvValue(*i));
}

if (!isIntfStateOk(nbr_odev))
{
SWSS_LOG_DEBUG("Interface %s is not ready, skipping system neigh %s'", nbr_odev.c_str(), kfvKey(t).c_str());
it++;
continue;
}

if (!addKernelNeigh(nbr_odev, ip_address, mac_address))
{
SWSS_LOG_ERROR("Neigh entry add on dev %s failed for '%s'", nbr_odev.c_str(), kfvKey(t).c_str());
it++;
continue;
}
else
{
SWSS_LOG_NOTICE("Neigh entry added on dev %s for '%s'", nbr_odev.c_str(), kfvKey(t).c_str());
}

if (!addKernelRoute(nbr_odev, ip_address))
{
SWSS_LOG_ERROR("Route entry add on dev %s failed for '%s'", nbr_odev.c_str(), kfvKey(t).c_str());
delKernelNeigh(nbr_odev, ip_address);
it++;
continue;
}
else
{
SWSS_LOG_NOTICE("Route entry added on dev %s for '%s'", nbr_odev.c_str(), kfvKey(t).c_str());
}
SWSS_LOG_NOTICE("Added voq neighbor %s to kernel", kfvKey(t).c_str());
}
else if (op == DEL_COMMAND)
{
if (!delKernelRoute(ip_address))
{
SWSS_LOG_ERROR("Route entry on dev %s delete failed for '%s'", nbr_odev.c_str(), kfvKey(t).c_str());
}
else
{
SWSS_LOG_NOTICE("Route entry on dev %s deleted for '%s'", nbr_odev.c_str(), kfvKey(t).c_str());
}

if (!delKernelNeigh(nbr_odev, ip_address))
{
SWSS_LOG_ERROR("Neigh entry on dev %s delete failed for '%s'", nbr_odev.c_str(), kfvKey(t).c_str());
}
else
{
SWSS_LOG_NOTICE("Neigh entry on dev %s deleted for '%s'", nbr_odev.c_str(), kfvKey(t).c_str());
}
SWSS_LOG_DEBUG("Deleted voq neighbor %s from kernel", kfvKey(t).c_str());
}

it = consumer.m_toSync.erase(it);
}
}

bool NbrMgr::getVoqInbandInterfaceName(string &ibif)
{

vector<string> keys;
m_cfgVoqInbandInterfaceTable->getKeys(keys);

if (keys.empty())
{
SWSS_LOG_NOTICE("Voq Inband interface is not configured!");
return false;
}
//key:"alias" = inband interface name
vector<string> if_keys = tokenize(keys[0], config_db_key_delimiter);
ibif = if_keys[0];
return true;
}

bool NbrMgr::addKernelRoute(string odev, IpAddress ip_addr)
{
string cmd, res;

SWSS_LOG_ENTER();

string ip_str = ip_addr.to_string();

if(ip_addr.isV4())
{
cmd = string("") + IP_CMD + " route add " + ip_str + "/32 dev " + odev;
SWSS_LOG_NOTICE("IPv4 Route Add cmd: %s",cmd.c_str());
}
else
{
cmd = string("") + IP_CMD + " -6 route add " + ip_str + "/128 dev " + odev;
SWSS_LOG_NOTICE("IPv6 Route Add cmd: %s",cmd.c_str());
}

int32_t ret = swss::exec(cmd, res);

if(ret)
{
/* Just log error and return */
SWSS_LOG_ERROR("Failed to add route for %s, error: %d", ip_str.c_str(), ret);
return false;
}

SWSS_LOG_INFO("Added route for %s on device %s", ip_str.c_str(), odev.c_str());
return true;
}

bool NbrMgr::delKernelRoute(IpAddress ip_addr)
{
string cmd, res;

SWSS_LOG_ENTER();

string ip_str = ip_addr.to_string();

if(ip_addr.isV4())
{
cmd = string("") + IP_CMD + " route del " + ip_str + "/32";
SWSS_LOG_NOTICE("IPv4 Route Del cmd: %s",cmd.c_str());
}
else
{
cmd = string("") + IP_CMD + " -6 route del " + ip_str + "/128";
SWSS_LOG_NOTICE("IPv6 Route Del cmd: %s",cmd.c_str());
}

int32_t ret = swss::exec(cmd, res);

if(ret)
{
/* Just log error and return */
SWSS_LOG_ERROR("Failed to delete route for %s, error: %d", ip_str.c_str(), ret);
return false;
}

SWSS_LOG_INFO("Deleted route for %s", ip_str.c_str());
return true;
}

bool NbrMgr::addKernelNeigh(string odev, IpAddress ip_addr, MacAddress mac_addr)
minionatwork marked this conversation as resolved.
Show resolved Hide resolved
{
SWSS_LOG_ENTER();

string cmd, res;
string ip_str = ip_addr.to_string();
string mac_str = mac_addr.to_string();

if(ip_addr.isV4())
{
cmd = string("") + IP_CMD + " neigh add " + ip_str + " lladdr " + mac_str + " dev " + odev;
SWSS_LOG_NOTICE("IPv4 Nbr Add cmd: %s",cmd.c_str());
}
else
{
cmd = string("") + IP_CMD + " -6 neigh add " + ip_str + " lladdr " + mac_str + " dev " + odev;
SWSS_LOG_NOTICE("IPv6 Nbr Add cmd: %s",cmd.c_str());
}

int32_t ret = swss::exec(cmd, res);

if(ret)
{
/* Just log error and return */
SWSS_LOG_ERROR("Failed to add Nbr for %s, error: %d", ip_str.c_str(), ret);
return false;
}

SWSS_LOG_INFO("Added Nbr for %s on interface %s", ip_str.c_str(), odev.c_str());
return true;
}

bool NbrMgr::delKernelNeigh(string odev, IpAddress ip_addr)
{
string cmd, res;

SWSS_LOG_ENTER();

string ip_str = ip_addr.to_string();

if(ip_addr.isV4())
{
cmd = string("") + IP_CMD + " neigh del " + ip_str + " dev " + odev;
SWSS_LOG_NOTICE("IPv4 Nbr Del cmd: %s",cmd.c_str());
}
else
{
cmd = string("") + IP_CMD + " -6 neigh del " + ip_str + " dev " + odev;
SWSS_LOG_NOTICE("IPv6 Nbr Del cmd: %s",cmd.c_str());
}

int32_t ret = swss::exec(cmd, res);

if(ret)
{
/* Just log error and return */
SWSS_LOG_ERROR("Failed to delete Nbr for %s, error: %d", ip_str.c_str(), ret);
return false;
}

SWSS_LOG_INFO("Deleted Nbr for %s on interface %s", ip_str.c_str(), odev.c_str());
return true;
}
7 changes: 7 additions & 0 deletions cfgmgr/nbrmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ class NbrMgr : public Orch
void doResolveNeighTask(Consumer &consumer);
void doSetNeighTask(Consumer &consumer);
void doTask(Consumer &consumer);
void doStateSystemNeighTask(Consumer &consumer);
bool getVoqInbandInterfaceName(string &nbr_odev);
bool addKernelRoute(string odev, IpAddress ip_addr);
bool delKernelRoute(IpAddress ip_addr);
bool addKernelNeigh(string odev, IpAddress ip_addr, MacAddress mac_addr);
bool delKernelNeigh(string odev, IpAddress ip_addr);
unique_ptr<Table> m_cfgVoqInbandInterfaceTable;

Table m_statePortTable, m_stateLagTable, m_stateVlanTable, m_stateIntfTable, m_stateNeighRestoreTable;
struct nl_sock *m_nl_sock;
Expand Down
Loading