Skip to content

Commit 9955bf3

Browse files
author
Rodny Molina
committed
Integrating directed-bcast-route code within LI's overlapping-prevention logic.
See before/after scenarios below: <-- Setup: admin@lnos-x1-a-asw02:~$ ip a show Vlan100 | grep inet inet 9.1.1.2/24 scope global Vlan100 inet6 fc00:9:2::2/64 scope global inet6 fe80::2e0:ecff:fe3c:a16/64 scope link admin@lnos-x1-a-asw02:~$ ip a show Vlan777 | grep inet inet 8.1.1.2/24 scope global Vlan777 inet6 fc00:8:2::2/64 scope global inet6 fe80::2e0:ecff:fe3c:a16/64 scope link Before ====== <-- Adding 9.1.1.3/24 over Vlan100 with existing 9.1.1.2/24. Notice that we attempt to add an overlapping direct-bcast route, but this one isn't successful, so no data-plane changes are pushed down. Apr 27 05:09:35.550861 lnos-x1-a-asw02 WARNING orchagent: :- trackIntfRouteOverlap: New subnet route 9.1.1.0/24 for interface Vlan100 overlaps with existing route 9.1.1.0/24 for interface Vlan100. Skipping... Apr 27 05:09:35.550861 lnos-x1-a-asw02 NOTICE orchagent: :- addIp2MeRoute: Create IP2me route ip:9.1.1.3 Apr 27 05:09:35.550861 lnos-x1-a-asw02 ERR orchagent: :- meta_sai_validate_neighbor_entry: object key SAI_OBJECT_TYPE_NEIGHBOR_ENTRY:{"ip":"9.1.1.255","rif":"oid:0x60000000012ae","switch_id":"oid:0x21000000000000"} already exists Apr 27 05:09:35.550861 lnos-x1-a-asw02 ERR orchagent: :- addDirectedBroadcast: Failed to create broadcast entry 9.1.1.255 rv:-6 admin@lnos-x1-a-asw02:~$ sudo ip -4 addr add dev Vlan100 9.1.1.2/24 admin@lnos-x1-a-asw02:~$ bcmcmd "l3 egress show" l3 egress show Entry Mac Vlan INTF PORT MOD MPLS_LABEL ToCpu Drop RefCount L3MC 100002 00:e0:ec:3c:0a:16 1 0 0 0 -1 no yes 2 no 100003 00:e0:ec:3c:0a:16 1 0 0 0 -1 no no 31 no 100004 ff:ff:ff:ff:ff:ff 100 6 34 0 -1 no no 0 yes 100005 ff:ff:ff:ff:ff:ff 100 6 35 0 -1 no no 0 yes 100006 ff:ff:ff:ff:ff:ff 777 7 34 0 -1 no no 0 yes 100007 ff:ff:ff:ff:ff:ff 777 7 35 0 -1 no no 0 yes 100008 00:e0:ec:3b:da:41 4093 2 122 0 -1 no no 3 no 100009 00:e0:ec:3b:da:41 4093 2 122 0 -1 no no 0 no 100010 00:e0:ec:3b:d9:be 4092 3 126 0 -1 no no 0 no 100011 00:e0:ec:3b:d9:be 4092 3 126 0 -1 no no 0 no 100012 00:e0:ec:3b:d9:be 4092 3 126 0 -1 no no 0 no 100013 00:e0:ec:3b:da:41 4093 2 122 0 -1 no no 2 no <-- Deleting previously-added overlapped subnet. Notice that bcast-route is erroneously being deleted. admin@lnos-x1-a-asw02:~$ sudo ip -4 addr del dev Vlan100 9.1.1.3/24 Apr 27 05:11:39.177899 lnos-x1-a-asw02 NOTICE orchagent: :- deleteIntfRoute: Eliminating active subnet route 9.1.1.0/24 from interface Vlan100 Apr 27 05:11:39.178925 lnos-x1-a-asw02 NOTICE orchagent: :- removeSubnetRoute: Remove subnet route to 9.1.1.0/24 from Vlan100 Apr 27 05:11:39.178991 lnos-x1-a-asw02 NOTICE orchagent: :- resurrectIntfRoute: Resurrecting overlapped subnet route 9.1.1.0/24 from interface Vlan100 Apr 27 05:11:39.179487 lnos-x1-a-asw02 NOTICE orchagent: :- addSubnetRoute: Create subnet route to 9.1.1.0/24 from Vlan100 Apr 27 05:11:39.179548 lnos-x1-a-asw02 NOTICE orchagent: :- deleteIntfRoute: Eliminating active ip2me route 9.1.1.3/32 from interface Vlan100 Apr 27 05:11:39.179756 lnos-x1-a-asw02 NOTICE orchagent: :- removeIp2MeRoute: Remove packet action trap route ip:9.1.1.3 Apr 27 05:11:39.180314 lnos-x1-a-asw02 NOTICE orchagent: :- removeDirectedBroadcast: Remove broadcast route ip:9.1.1.255 admin@lnos-x1-a-asw02:~$ bcmcmd "l3 egress show" l3 egress show Entry Mac Vlan INTF PORT MOD MPLS_LABEL ToCpu Drop RefCount L3MC 100002 00:e0:ec:3c:0a:16 1 0 0 0 -1 no yes 2 no 100003 00:e0:ec:3c:0a:16 1 0 0 0 -1 no no 31 no 100006 ff:ff:ff:ff:ff:ff 777 7 34 0 -1 no no 0 yes 100007 ff:ff:ff:ff:ff:ff 777 7 35 0 -1 no no 0 yes 100008 00:e0:ec:3b:da:41 4093 2 122 0 -1 no no 3 no 100009 00:e0:ec:3b:da:41 4093 2 122 0 -1 no no 0 no 100010 00:e0:ec:3b:d9:be 4092 3 126 0 -1 no no 0 no 100011 00:e0:ec:3b:d9:be 4092 3 126 0 -1 no no 0 no 100012 00:e0:ec:3b:d9:be 4092 3 126 0 -1 no no 0 no 100013 00:e0:ec:3b:da:41 4093 2 122 0 -1 no no 2 no After ===== <-- Adding 9.1.1.3/24 over Vlan100 with existing 9.1.1.2/24. Notice that no changes observed in data-plane for bcast-routes: admin@lnos-x1-a-asw02:~$ sudo ip -4 addr add dev Vlan100 9.1.1.3/24 Apr 27 06:08:09.524770 lnos-x1-a-asw02 WARNING orchagent: :- trackIntfRouteOverlap: New subnet route 9.1.1.0/24 for interface Vlan100 overlaps with existing route 9.1.1.0/24 for interface Vlan100. Skipping... Apr 27 06:08:09.525716 lnos-x1-a-asw02 NOTICE orchagent: :- addIp2MeRoute: Create IP2me route ip:9.1.1.3 Apr 27 06:08:09.525716 lnos-x1-a-asw02 WARNING orchagent: :- trackIntfRouteOverlap: New bcast route 9.1.1.255/32 for interface Vlan100 overlaps with existing route 9.1.1.255/32 for interface Vlan100. Skipping... admin@lnos-x1-a-asw02:~$ bcmcmd "l3 egress show" l3 egress show Entry Mac Vlan INTF PORT MOD MPLS_LABEL ToCpu Drop RefCount L3MC 100002 00:e0:ec:3c:0a:16 1 0 0 0 -1 no yes 2 no 100003 00:e0:ec:3c:0a:16 1 0 0 0 -1 no no 34 no 100004 ff:ff:ff:ff:ff:ff 100 6 34 0 -1 no no 0 yes 100005 ff:ff:ff:ff:ff:ff 100 6 35 0 -1 no no 0 yes 100006 ff:ff:ff:ff:ff:ff 777 7 34 0 -1 no no 0 yes 100007 ff:ff:ff:ff:ff:ff 777 7 35 0 -1 no no 0 yes 100008 00:e0:ec:3b:d9:be 4092 3 126 0 -1 no no 0 no 100009 00:e0:ec:3b:da:41 4093 2 122 0 -1 no no 3 no 100010 00:e0:ec:3b:da:41 4093 2 122 0 -1 no no 2 no 100011 00:e0:ec:3b:da:41 4093 2 122 0 -1 no no 0 no 100012 00:e0:ec:3b:d9:be 4092 3 126 0 -1 no no 0 no 100013 00:e0:ec:3b:d9:be 4092 3 126 0 -1 no no 0 no <-- Deleting previously-added overlapped subnet: admin@lnos-x1-a-asw02:~$ sudo ip -4 addr del dev Vlan100 9.1.1.3/24 Apr 27 06:09:46.330285 lnos-x1-a-asw02 NOTICE orchagent: :- deleteIntfRoute: Eliminating active subnet route 9.1.1.0/24 from interface Vlan100 Apr 27 06:09:46.331069 lnos-x1-a-asw02 NOTICE orchagent: :- removeSubnetRoute: Remove subnet route to 9.1.1.0/24 from Vlan100 Apr 27 06:09:46.331069 lnos-x1-a-asw02 NOTICE orchagent: :- resurrectIntfRoute: Resurrecting overlapped subnet route 9.1.1.0/24 from interface Vlan100 Apr 27 06:09:46.332871 lnos-x1-a-asw02 NOTICE orchagent: :- addSubnetRoute: Create subnet route to 9.1.1.0/24 from Vlan100 Apr 27 06:09:46.332871 lnos-x1-a-asw02 NOTICE orchagent: :- deleteIntfRoute: Eliminating active ip2me route 9.1.1.3/32 from interface Vlan100 Apr 27 06:09:46.333511 lnos-x1-a-asw02 NOTICE orchagent: :- removeIp2MeRoute: Remove packet action trap route ip:9.1.1.3 Apr 27 06:09:46.333511 lnos-x1-a-asw02 NOTICE orchagent: :- deleteIntfRoute: Eliminating active bcast route 9.1.1.255/32 from interface Vlan100 Apr 27 06:09:46.334017 lnos-x1-a-asw02 NOTICE orchagent: :- removeDirectedBroadcast: Remove broadcast route ip:9.1.1.255 Apr 27 06:09:46.334017 lnos-x1-a-asw02 NOTICE orchagent: :- resurrectIntfRoute: Resurrecting overlapped bcast route 9.1.1.255/32 from interface Vlan100 Apr 27 06:09:46.335139 lnos-x1-a-asw02 NOTICE orchagent: :- addDirectedBroadcast: Add broadcast route for ip:9.1.1.255 admin@lnos-x1-a-asw02:~$ bcmcmd "l3 egress show" l3 egress show Entry Mac Vlan INTF PORT MOD MPLS_LABEL ToCpu Drop RefCount L3MC 100002 00:e0:ec:3c:0a:16 1 0 0 0 -1 no yes 2 no 100003 00:e0:ec:3c:0a:16 1 0 0 0 -1 no no 33 no 100004 ff:ff:ff:ff:ff:ff 100 6 34 0 -1 no no 0 yes 100005 ff:ff:ff:ff:ff:ff 100 6 35 0 -1 no no 0 yes 100006 ff:ff:ff:ff:ff:ff 777 7 34 0 -1 no no 0 yes 100007 ff:ff:ff:ff:ff:ff 777 7 35 0 -1 no no 0 yes 100008 00:e0:ec:3b:d9:be 4092 3 126 0 -1 no no 0 no 100009 00:e0:ec:3b:da:41 4093 2 122 0 -1 no no 3 no 100010 00:e0:ec:3b:da:41 4093 2 122 0 -1 no no 2 no 100011 00:e0:ec:3b:da:41 4093 2 122 0 -1 no no 0 no 100012 00:e0:ec:3b:d9:be 4092 3 126 0 -1 no no 0 no 100013 00:e0:ec:3b:d9:be 4092 3 126 0 -1 no no 0 no RB=1294335 G=lnos-reviewers R=ntrianta,pmao,rmolina,sfardeen,zxu A=
1 parent 2a9b422 commit 9955bf3

File tree

2 files changed

+51
-11
lines changed

2 files changed

+51
-11
lines changed

orchagent/intfsorch.cpp

+48-10
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,6 @@ void IntfsOrch::doTask(Consumer &consumer)
140140

141141
/* Creating intfRoutes associated to this interface being added */
142142
createIntfRoutes(IntfRouteEntry(ip_prefix, alias), port);
143-
if(port.m_type == Port::VLAN && ip_prefix.isV4())
144-
{
145-
addDirectedBroadcast(port, ip_prefix.getBroadcastIp());
146-
}
147143

148144
m_syncdIntfses[alias].ip_addresses.insert(ip_prefix);
149145
it = consumer.m_toSync.erase(it);
@@ -179,11 +175,7 @@ void IntfsOrch::doTask(Consumer &consumer)
179175
{
180176
if (iter->second.ip_addresses.count(ip_prefix))
181177
{
182-
if(port.m_type == Port::VLAN && ip_prefix.isV4())
183-
{
184-
removeDirectedBroadcast(port, ip_prefix.getBroadcastIp());
185-
}
186-
iter->second.ip_addresses.erase(ip_prefix);
178+
iter->second.ip_addresses.erase(ip_prefix);
187179
}
188180

189181
/* Remove router interface if there's no ip-address left. */
@@ -566,6 +558,24 @@ void IntfsOrch::createIntfRoutes(const IntfRouteEntry &ifRoute,
566558
}
567559
}
568560
}
561+
562+
/*
563+
* A directed-broadcast route is expected in vlan-ipv4 scenarios. Proceed to
564+
* push the route down if no overlap is detected.
565+
*/
566+
if(port.m_type == Port::VLAN && ifRoute.prefix.isV4())
567+
{
568+
IntfRouteEntry ifBcastRoute(getBcastPrefix(ifRoute.prefix),
569+
ifRoute.ifName,
570+
"bcast");
571+
572+
bool bcastOverlap = trackIntfRouteOverlap(ifBcastRoute);
573+
574+
if (!bcastOverlap)
575+
{
576+
addDirectedBroadcast(port, ifBcastRoute.prefix.getIp());
577+
}
578+
}
569579
}
570580

571581
/*
@@ -656,6 +666,16 @@ void IntfsOrch::deleteIntfRoutes(const IntfRouteEntry &ifRoute,
656666
deleteIntfRoute(ifSubnetRoute, port);
657667
}
658668
deleteIntfRoute(ifIp2meRoute, port);
669+
670+
/* Also remove the directed-bcast route if applicable. */
671+
if(port.m_type == Port::VLAN && ifRoute.prefix.isV4())
672+
{
673+
IntfRouteEntry ifBcastRoute(getBcastPrefix(ifRoute.prefix),
674+
ifRoute.ifName,
675+
"bcast");
676+
677+
deleteIntfRoute(ifBcastRoute, port);
678+
}
659679
}
660680

661681
void IntfsOrch::deleteIntfRoute(const IntfRouteEntry &ifRoute, const Port &port)
@@ -706,6 +726,10 @@ void IntfsOrch::deleteIntfRoute(const IntfRouteEntry &ifRoute, const Port &port)
706726
{
707727
removeIp2MeRoute(ifRoute.prefix);
708728
}
729+
else if (it->type == "bcast")
730+
{
731+
removeDirectedBroadcast(port, ifRoute.prefix.getIp());
732+
}
709733

710734
/*
711735
* Notice that the resurrection-order is vital here. We must
@@ -774,10 +798,15 @@ void IntfsOrch::resurrectIntfRoute(const IntfRouteEntry &ifRoute)
774798
{
775799
addIp2MeRoute(ifRoute.prefix);
776800
}
801+
else if (ifRoute.type == "bcast")
802+
{
803+
addDirectedBroadcast(port, ifRoute.prefix.getIp());
804+
}
777805
}
778806

779807
/*
780-
* Perhaps to be moved to a more appropriate location (e.g. IpPrefix class).
808+
* Helper functions. Perhaps to be moved to a more appropriate location (e.g.
809+
* IpPrefix class).
781810
*/
782811
IpPrefix IntfsOrch::getIp2mePrefix(const IpPrefix &ip_prefix)
783812
{
@@ -787,3 +816,12 @@ IpPrefix IntfsOrch::getIp2mePrefix(const IpPrefix &ip_prefix)
787816

788817
return (IpPrefix(newRoutePrefixStr));
789818
}
819+
820+
IpPrefix IntfsOrch::getBcastPrefix(const IpPrefix &ip_prefix)
821+
{
822+
string newRoutePrefixStr = ip_prefix.isV4() ?
823+
ip_prefix.getBroadcastIp().to_string() + "/32" :
824+
ip_prefix.getBroadcastIp().to_string() + "/128";
825+
826+
return (IpPrefix(newRoutePrefixStr));
827+
}

orchagent/intfsorch.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ struct IntfRouteEntry
5353
* ---------- -------------------------------------------------------
5454
* 10.1.1.0/24 (subnet) 10.1.1.0/24 eth1, 10.1.1.0/24 eth2, 10.1.1.0/24 eth3
5555
* 10.1.1.1/32 (ip2me) 10.1.1.1/32 eth1, 10.1.1.10/32 eth2, 10.1.1.255/32 eth3
56+
* 10.1.1.255/32 (bcast) 10.1.1.255/32 eth1, 10.1.1.255/32 eth2
5657
* ...
5758
* fe80:1:1/64 (subnet) fe80:1:1/64 eth1, fe80:1:1/64 eth2
5859
* fe80:1::1/128 (ip2me) fe80:1:1::1/128 eth2, fe80:1:1::1/128 eth1
@@ -94,7 +95,8 @@ class IntfsOrch : public Orch
9495
bool trackIntfRouteOverlap(const IntfRouteEntry &ifRoute);
9596

9697
IpPrefix getIp2mePrefix(const IpPrefix &ip_prefix);
97-
98+
IpPrefix getBcastPrefix(const IpPrefix &ip_prefix);
99+
98100
void addDirectedBroadcast(const Port &port, const IpAddress &ip_addr);
99101
void removeDirectedBroadcast(const Port &port, const IpAddress &ip_addr);
100102
};

0 commit comments

Comments
 (0)