Skip to content

Commit 36e85eb

Browse files
kirankellaprsunny
authored andcommitted
On a routing vlan, the neighbor entry in the /31 subnet is not added 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
1 parent 882ccc6 commit 36e85eb

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

orchagent/intfsorch.cpp

+26-6
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ bool IntfsOrch::setIntf(const string& alias, sai_object_id_t vrf_id, const IpPre
158158
addSubnetRoute(port, *ip_prefix);
159159
addIp2MeRoute(vrf_id, *ip_prefix);
160160

161-
if (port.m_type == Port::VLAN && ip_prefix->isV4())
161+
if (port.m_type == Port::VLAN)
162162
{
163-
addDirectedBroadcast(port, ip_prefix->getBroadcastIp());
163+
addDirectedBroadcast(port, *ip_prefix);
164164
}
165165

166166
m_syncdIntfses[alias].ip_addresses.insert(*ip_prefix);
@@ -344,9 +344,10 @@ void IntfsOrch::doTask(Consumer &consumer)
344344
{
345345
removeSubnetRoute(port, ip_prefix);
346346
removeIp2MeRoute(vrf_id, ip_prefix);
347-
if(port.m_type == Port::VLAN && ip_prefix.isV4())
347+
348+
if(port.m_type == Port::VLAN)
348349
{
349-
removeDirectedBroadcast(port, ip_prefix.getBroadcastIp());
350+
removeDirectedBroadcast(port, ip_prefix);
350351
}
351352

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

626-
void IntfsOrch::addDirectedBroadcast(const Port &port, const IpAddress &ip_addr)
627+
void IntfsOrch::addDirectedBroadcast(const Port &port, const IpPrefix &ip_prefix)
627628
{
628629
sai_status_t status;
629630
sai_neighbor_entry_t neighbor_entry;
631+
IpAddress ip_addr;
632+
633+
/* If not IPv4 subnet or if /31 or /32 subnet, there is no broadcast address, hence don't
634+
* add a broadcast route. */
635+
if (!(ip_prefix.isV4()) || (ip_prefix.getMaskLength() > 30))
636+
{
637+
return;
638+
}
639+
ip_addr = ip_prefix.getBroadcastIp();
640+
630641
neighbor_entry.rif_id = port.m_rif_id;
631642
neighbor_entry.switch_id = gSwitchId;
632643
copy(neighbor_entry.ip_address, ip_addr);
@@ -646,10 +657,19 @@ void IntfsOrch::addDirectedBroadcast(const Port &port, const IpAddress &ip_addr)
646657
SWSS_LOG_NOTICE("Add broadcast route for ip:%s", ip_addr.to_string().c_str());
647658
}
648659

649-
void IntfsOrch::removeDirectedBroadcast(const Port &port, const IpAddress &ip_addr)
660+
void IntfsOrch::removeDirectedBroadcast(const Port &port, const IpPrefix &ip_prefix)
650661
{
651662
sai_status_t status;
652663
sai_neighbor_entry_t neighbor_entry;
664+
IpAddress ip_addr;
665+
666+
/* If not IPv4 subnet or if /31 or /32 subnet, there is no broadcast address */
667+
if (!(ip_prefix.isV4()) || (ip_prefix.getMaskLength() > 30))
668+
{
669+
return;
670+
}
671+
ip_addr = ip_prefix.getBroadcastIp();
672+
653673
neighbor_entry.rif_id = port.m_rif_id;
654674
neighbor_entry.switch_id = gSwitchId;
655675
copy(neighbor_entry.ip_address, ip_addr);

orchagent/intfsorch.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ class IntfsOrch : public Orch
5252
void addIp2MeRoute(sai_object_id_t vrf_id, const IpPrefix &ip_prefix);
5353
void removeIp2MeRoute(sai_object_id_t vrf_id, const IpPrefix &ip_prefix);
5454

55-
void addDirectedBroadcast(const Port &port, const IpAddress &ip_addr);
56-
void removeDirectedBroadcast(const Port &port, const IpAddress &ip_addr);
55+
void addDirectedBroadcast(const Port &port, const IpPrefix &ip_prefix);
56+
void removeDirectedBroadcast(const Port &port, const IpPrefix &ip_prefix);
5757
};
5858

5959
#endif /* SWSS_INTFSORCH_H */

0 commit comments

Comments
 (0)