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

Code changes to support IPv6 Link local enhancements #1463

Merged
merged 31 commits into from
Aug 5, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a5f21ff
Code changes to support IPv6 Link local enchancements
AkhileshSamineni Oct 10, 2020
b0257fc
Updated pytest for ipv6 link-local.
AkhileshSamineni Oct 21, 2020
c8fabd8
Few fixes for docker-vs pytest.
AkhileshSamineni Oct 22, 2020
0b9e8d1
Corrected the changes as per design change.
AkhileshSamineni Apr 5, 2021
54c974b
Added the removed file.
AkhileshSamineni Apr 5, 2021
a6ed450
Removed hasIp2MeAddr function.
AkhileshSamineni Apr 14, 2021
e85122e
Added vs testcase for interface.
AkhileshSamineni Jun 7, 2021
2642fa2
Fixed LGTM issue.
AkhileshSamineni Jun 7, 2021
37afab4
Added vs testcase for LAG and Vlan interfaces.
AkhileshSamineni Jun 7, 2021
a167064
Addressed review comments
AkhileshSamineni Jun 25, 2021
2b7d62c
Validation check added in remove_vlan()
AkhileshSamineni Jul 1, 2021
373cc3e
Added vlan verification using dvs_vlan
AkhileshSamineni Jul 1, 2021
e2d14b0
Corrected vlan verification
AkhileshSamineni Jul 1, 2021
dda4999
Correction in Vlan create function
AkhileshSamineni Jul 1, 2021
0e1cb06
Modified in Vlan create
AkhileshSamineni Jul 2, 2021
7574a3a
Few more corrections
AkhileshSamineni Jul 2, 2021
bf6336a
Added validation checks in remove_vrf
AkhileshSamineni Jul 2, 2021
ae7a169
Added different VRs in the testcase
AkhileshSamineni Jul 2, 2021
1e03523
Few correction in create_vrf
AkhileshSamineni Jul 3, 2021
f99203e
Cleanup in remove_vrf
AkhileshSamineni Jul 3, 2021
c9fa5ea
Added few more cleanup
AkhileshSamineni Jul 3, 2021
5d36b60
Added few more cleanup in create_vrf
AkhileshSamineni Jul 3, 2021
122afaa
Reverted the changes tried for l3 vxlan test case
AkhileshSamineni Jul 4, 2021
cb780ed
Added few prints to debug further
AkhileshSamineni Jul 6, 2021
2c62ef6
Added few more changes in test case
AkhileshSamineni Jul 6, 2021
47faa87
Added few more changes in test case2
AkhileshSamineni Jul 6, 2021
adfb5d5
Reverted/Removed few changes to verify the l3 vxlan test case
AkhileshSamineni Jul 22, 2021
e2448d6
Removed the VRF changes
AkhileshSamineni Jul 26, 2021
37ed2cf
Removed the extra line in file
AkhileshSamineni Jul 26, 2021
d774cea
Addressed minor comment
AkhileshSamineni Aug 2, 2021
3e615e2
Added changes to skip the link-local neighbors based on ipv6_link_loc…
AkhileshSamineni Aug 4, 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
67 changes: 65 additions & 2 deletions neighsyncd/neighsync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@

#include "neighsync.h"
#include "warm_restart.h"
#include <algorithm>

using namespace std;
using namespace swss;

NeighSync::NeighSync(RedisPipeline *pipelineAppDB, DBConnector *stateDb) :
NeighSync::NeighSync(RedisPipeline *pipelineAppDB, DBConnector *stateDb, DBConnector *cfgDb) :
m_neighTable(pipelineAppDB, APP_NEIGH_TABLE_NAME),
m_stateNeighRestoreTable(stateDb, STATE_NEIGH_RESTORE_TABLE_NAME)
m_stateNeighRestoreTable(stateDb, STATE_NEIGH_RESTORE_TABLE_NAME),
m_cfgInterfaceTable(cfgDb, CFG_INTF_TABLE_NAME),
m_cfgLagInterfaceTable(cfgDb, CFG_LAG_INTF_TABLE_NAME),
m_cfgVlanInterfaceTable(cfgDb, CFG_VLAN_INTF_TABLE_NAME)
{
m_AppRestartAssist = new AppRestartAssist(pipelineAppDB, "neighsyncd", "swss", DEFAULT_NEIGHSYNC_WARMSTART_TIMER);
if (m_AppRestartAssist)
Expand Down Expand Up @@ -57,6 +61,7 @@ void NeighSync::onMsg(int nlmsg_type, struct nl_object *obj)
struct rtnl_neigh *neigh = (struct rtnl_neigh *)obj;
string key;
string family;
string intfName;

if ((nlmsg_type != RTM_NEWNEIGH) && (nlmsg_type != RTM_GETNEIGH) &&
(nlmsg_type != RTM_DELNEIGH))
Expand All @@ -70,9 +75,18 @@ void NeighSync::onMsg(int nlmsg_type, struct nl_object *obj)
return;

key+= LinkCache::getInstance().ifindexToName(rtnl_neigh_get_ifindex(neigh));
intfName = key;
key+= ":";

nl_addr2str(rtnl_neigh_get_dst(neigh), ipStr, MAX_ADDR_SIZE);
/* Ignore IPv6 link-local addresses as neighbors, if ipv6 link local mode is disabled */
if (family == IPV6_NAME && IN6_IS_ADDR_LINKLOCAL(nl_addr_get_binary_addr(rtnl_neigh_get_dst(neigh))))
{
if (isLinkLocalEnabled(intfName) == false)
prsunny marked this conversation as resolved.
Show resolved Hide resolved
{
return;
}
}
/* Ignore IPv6 multicast link-local addresses as neighbors */
if (family == IPV6_NAME && IN6_IS_ADDR_MC_LINKLOCAL(nl_addr_get_binary_addr(rtnl_neigh_get_dst(neigh))))
return;
Expand Down Expand Up @@ -121,3 +135,52 @@ void NeighSync::onMsg(int nlmsg_type, struct nl_object *obj)
m_neighTable.set(key, fvVector);
}
}

/* To check the ipv6 link local is enabled on a given port */
bool NeighSync::isLinkLocalEnabled(const string &port)
{
vector<FieldValueTuple> values;

if (!port.compare(0, strlen("Vlan"), "Vlan"))
{
if (!m_cfgVlanInterfaceTable.get(port, values))
{
SWSS_LOG_INFO("IPv6 Link local is not enabled on %s", port.c_str());
return false;
}
}
else if (!port.compare(0, strlen("PortChannel"), "PortChannel"))
{
if (!m_cfgLagInterfaceTable.get(port, values))
{
SWSS_LOG_INFO("IPv6 Link local is not enabled on %s", port.c_str());
return false;
}
}
else if (!port.compare(0, strlen("Ethernet"), "Ethernet"))
{
if (!m_cfgInterfaceTable.get(port, values))
{
SWSS_LOG_INFO("IPv6 Link local is not enabled on %s", port.c_str());
return false;
}
}
else
{
SWSS_LOG_INFO("IPv6 Link local is not supported for %s ", port.c_str());
return false;
}

auto it = std::find_if(values.begin(), values.end(), [](const FieldValueTuple& t){ return t.first == "ipv6_use_link_local_only";});
if (it != values.end())
{
if (it->second == "enable")
{
SWSS_LOG_INFO("IPv6 Link local is enabled on %s", port.c_str());
return true;
}
}

SWSS_LOG_INFO("IPv6 Link local is not enabled on %s", port.c_str());
return false;
}
5 changes: 4 additions & 1 deletion neighsyncd/neighsync.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class NeighSync : public NetMsg
public:
enum { MAX_ADDR_SIZE = 64 };

NeighSync(RedisPipeline *pipelineAppDB, DBConnector *stateDb);
NeighSync(RedisPipeline *pipelineAppDB, DBConnector *stateDb, DBConnector *cfgDb);
~NeighSync();

virtual void onMsg(int nlmsg_type, struct nl_object *obj);
Expand All @@ -39,6 +39,9 @@ class NeighSync : public NetMsg
Table m_stateNeighRestoreTable;
ProducerStateTable m_neighTable;
AppRestartAssist *m_AppRestartAssist;
Table m_cfgVlanInterfaceTable, m_cfgLagInterfaceTable, m_cfgInterfaceTable;

bool isLinkLocalEnabled(const std::string &port);
};

}
Expand Down
3 changes: 2 additions & 1 deletion neighsyncd/neighsyncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ int main(int argc, char **argv)
DBConnector appDb("APPL_DB", 0);
RedisPipeline pipelineAppDB(&appDb);
DBConnector stateDb("STATE_DB", 0);
DBConnector cfgDb("CONFIG_DB", 0);

NeighSync sync(&pipelineAppDB, &stateDb);
NeighSync sync(&pipelineAppDB, &stateDb, &cfgDb);

NetDispatcher::getInstance().registerMessageHandler(RTM_NEWNEIGH, &sync);
NetDispatcher::getInstance().registerMessageHandler(RTM_DELNEIGH, &sync);
Expand Down