Skip to content

Commit

Permalink
On a routing vlan, the neighbor entry in the /31 subnet is not added …
Browse files Browse the repository at this point in the history
…to hardware (sonic-net#771)

* In a routing vlan, the neighbor entry in the /31 subnet is not getting added to hardware.
Fix:
   Don't add the net broadcast neighbor entry on the /31 subnet routin vlan as there is
   no net broadcast address in /31 subnets.
Signed-off-by: kiran.kella@broadcom.com
  • Loading branch information
kirankella authored and prsunny committed Jan 28, 2019
1 parent 882ccc6 commit 36e85eb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
32 changes: 26 additions & 6 deletions orchagent/intfsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ bool IntfsOrch::setIntf(const string& alias, sai_object_id_t vrf_id, const IpPre
addSubnetRoute(port, *ip_prefix);
addIp2MeRoute(vrf_id, *ip_prefix);

if (port.m_type == Port::VLAN && ip_prefix->isV4())
if (port.m_type == Port::VLAN)
{
addDirectedBroadcast(port, ip_prefix->getBroadcastIp());
addDirectedBroadcast(port, *ip_prefix);
}

m_syncdIntfses[alias].ip_addresses.insert(*ip_prefix);
Expand Down Expand Up @@ -344,9 +344,10 @@ void IntfsOrch::doTask(Consumer &consumer)
{
removeSubnetRoute(port, ip_prefix);
removeIp2MeRoute(vrf_id, ip_prefix);
if(port.m_type == Port::VLAN && ip_prefix.isV4())

if(port.m_type == Port::VLAN)
{
removeDirectedBroadcast(port, ip_prefix.getBroadcastIp());
removeDirectedBroadcast(port, ip_prefix);
}

m_syncdIntfses[alias].ip_addresses.erase(ip_prefix);
Expand Down Expand Up @@ -623,10 +624,20 @@ void IntfsOrch::removeIp2MeRoute(sai_object_id_t vrf_id, const IpPrefix &ip_pref
}
}

void IntfsOrch::addDirectedBroadcast(const Port &port, const IpAddress &ip_addr)
void IntfsOrch::addDirectedBroadcast(const Port &port, const IpPrefix &ip_prefix)
{
sai_status_t status;
sai_neighbor_entry_t neighbor_entry;
IpAddress ip_addr;

/* If not IPv4 subnet or if /31 or /32 subnet, there is no broadcast address, hence don't
* add a broadcast route. */
if (!(ip_prefix.isV4()) || (ip_prefix.getMaskLength() > 30))
{
return;
}
ip_addr = ip_prefix.getBroadcastIp();

neighbor_entry.rif_id = port.m_rif_id;
neighbor_entry.switch_id = gSwitchId;
copy(neighbor_entry.ip_address, ip_addr);
Expand All @@ -646,10 +657,19 @@ void IntfsOrch::addDirectedBroadcast(const Port &port, const IpAddress &ip_addr)
SWSS_LOG_NOTICE("Add broadcast route for ip:%s", ip_addr.to_string().c_str());
}

void IntfsOrch::removeDirectedBroadcast(const Port &port, const IpAddress &ip_addr)
void IntfsOrch::removeDirectedBroadcast(const Port &port, const IpPrefix &ip_prefix)
{
sai_status_t status;
sai_neighbor_entry_t neighbor_entry;
IpAddress ip_addr;

/* If not IPv4 subnet or if /31 or /32 subnet, there is no broadcast address */
if (!(ip_prefix.isV4()) || (ip_prefix.getMaskLength() > 30))
{
return;
}
ip_addr = ip_prefix.getBroadcastIp();

neighbor_entry.rif_id = port.m_rif_id;
neighbor_entry.switch_id = gSwitchId;
copy(neighbor_entry.ip_address, ip_addr);
Expand Down
4 changes: 2 additions & 2 deletions orchagent/intfsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class IntfsOrch : public Orch
void addIp2MeRoute(sai_object_id_t vrf_id, const IpPrefix &ip_prefix);
void removeIp2MeRoute(sai_object_id_t vrf_id, const IpPrefix &ip_prefix);

void addDirectedBroadcast(const Port &port, const IpAddress &ip_addr);
void removeDirectedBroadcast(const Port &port, const IpAddress &ip_addr);
void addDirectedBroadcast(const Port &port, const IpPrefix &ip_prefix);
void removeDirectedBroadcast(const Port &port, const IpPrefix &ip_prefix);
};

#endif /* SWSS_INTFSORCH_H */

0 comments on commit 36e85eb

Please sign in to comment.