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

[neighsync] Modification for ignoring neighbor entries #3330

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
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
72 changes: 68 additions & 4 deletions neighsyncd/neighsync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
using namespace std;
using namespace swss;

#define VLAN_SUB_INTERFACE_SEPARATOR "."
#define RESERVED_IPV4_LL "169.254.0.1"

NeighSync::NeighSync(RedisPipeline *pipelineAppDB, DBConnector *stateDb, DBConnector *cfgDb) :
m_neighTable(pipelineAppDB, APP_NEIGH_TABLE_NAME),
m_stateNeighRestoreTable(stateDb, STATE_NEIGH_RESTORE_TABLE_NAME),
Expand Down Expand Up @@ -55,11 +58,50 @@ bool NeighSync::isNeighRestoreDone()
return false;
}

Table *NeighSync::getInterfaceTable(const std::string &intfName)
{
if (intfName.find(FRONT_PANEL_PORT_PREFIX) != string::npos)
{
if (intfName.find(VLAN_SUB_INTERFACE_SEPARATOR) != string::npos)
return &m_cfgSubInterfaceTable;
return &m_cfgInterfaceTable;
}
else if (intfName.find(PORTCHANNEL_PREFIX) != string::npos)
{
if (intfName.find(VLAN_SUB_INTERFACE_SEPARATOR) != string::npos)
return &m_cfgSubInterfaceTable;
return &m_cfgLagInterfaceTable;
}
else if (intfName.find(VLAN_PREFIX) != string::npos)
{
return &m_cfgVlanInterfaceTable;
}
else if (intfName.find(VLAN_SUB_INTERFACE_SEPARATOR) != string::npos)
{
if ((intfName.find(FRONT_PANEL_PORT_PREFIX) != string::npos) || (intfName.find(PORTCHANNEL_PREFIX) != string::npos))
return &m_cfgSubInterfaceTable;
}
return nullptr;
}

bool NeighSync::isRouterInterface(const std::string &intfName)
{
vector<FieldValueTuple> values;
Table *intfTable_p = nullptr;
intfTable_p = getInterfaceTable(intfName);
if ((intfTable_p != nullptr) && intfTable_p->get(intfName, values))
{
return true;
}
return false;
}

void NeighSync::onMsg(int nlmsg_type, struct nl_object *obj)
{
char ipStr[MAX_ADDR_SIZE + 1] = {0};
char macStr[MAX_ADDR_SIZE + 1] = {0};
struct rtnl_neigh *neigh = (struct rtnl_neigh *)obj;
struct nl_addr *lladdr = NULL;
string key;
string family;
string intfName;
Expand Down Expand Up @@ -133,14 +175,34 @@ void NeighSync::onMsg(int nlmsg_type, struct nl_object *obj)
delete_key = true;
}

/* Ignore the following neighbor entries
* - learned on non-router interface
* - learned on SAG disabled interface
* For reserved IPv4 link-local address (169.254.0.1) used as next hop for BGP unnumber,
* this entry shouldn't be ignored even if it satisfy the above condition
* */
//if (!delete_key && !isRouterInterface(intfName) && !isSagEnabled(intfName) && strcmp(ipStr, RESERVED_IPV4_LL)) ///FIXME, isSagEnabled
if (!delete_key && !isRouterInterface(intfName) && strcmp(ipStr, RESERVED_IPV4_LL))
{
SWSS_LOG_INFO("Ignore neighbor %s on non-router-interface %s", ipStr, intfName.c_str());
return;
}

if (use_zero_mac)
{
std::string zero_mac = "00:00:00:00:00:00";
strncpy(macStr, zero_mac.c_str(), zero_mac.length());
}
else
{
nl_addr2str(rtnl_neigh_get_lladdr(neigh), macStr, MAX_ADDR_SIZE);
/* Get the link-layer address */
lladdr = rtnl_neigh_get_lladdr(neigh);

/* Check if the link-layer address is NULL */
if (lladdr != NULL)
{
nl_addr2str(lladdr, macStr, MAX_ADDR_SIZE);
}
}

if (!delete_key && !strncmp(macStr, "none", MAX_ADDR_SIZE))
Expand All @@ -149,10 +211,12 @@ void NeighSync::onMsg(int nlmsg_type, struct nl_object *obj)
return;
}

/* Ignore neighbor entries with Broadcast Mac - Trigger for directed broadcast */
if (!delete_key && (MacAddress(macStr) == MacAddress("ff:ff:ff:ff:ff:ff")))
/* Ignore neighbor entries with Broadcast/Null Mac */
if (!delete_key
&& ((lladdr == NULL)
|| (MacAddress(macStr) == MacAddress("ff:ff:ff:ff:ff:ff"))))
{
SWSS_LOG_INFO("Broadcast Mac received, ignoring for %s", ipStr);
SWSS_LOG_INFO("Broadcast/Null Mac received, ignoring for %s", ipStr);
return;
}

Expand Down
Loading