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

Cumulus FRR assign LLAs to point-to-point OSPF interfaces without addresses #7038

Merged
merged 4 commits into from
Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import org.batfish.datamodel.MacAddress;
import org.batfish.datamodel.Prefix;
import org.batfish.datamodel.SwitchportMode;
import org.batfish.datamodel.ospf.OspfNetworkType;
import org.batfish.datamodel.vendor_family.cumulus.CumulusFamily;
import org.batfish.representation.cumulus.CumulusPortsConfiguration.PortSettings;
import org.batfish.vendor.VendorConfiguration;
Expand Down Expand Up @@ -142,17 +143,7 @@ Configuration toVendorIndependentConfiguration() {
populatePortsInterfaceProperties(c);
populateFrrInterfaceProperties(c);

// for interfaces that didn't get an address via either interfaces or FRR, give them a link
// local address if they are being used for BGP unnumbered
c.getAllInterfaces()
.forEach(
(iname, iface) -> {
if (iface.getAllAddresses().size() == 0
&& isUsedForBgpUnnumbered(iface.getName(), _frrConfiguration.getBgpProcess())) {
iface.setAddress(LINK_LOCAL_ADDRESS);
iface.setAllAddresses(ImmutableSet.of(LINK_LOCAL_ADDRESS));
}
});
addBgpUnnumberedLLAs(c);

// FRR does not generate local routes for connected routes.
c.getAllInterfaces()
Expand Down Expand Up @@ -198,6 +189,7 @@ && isUsedForBgpUnnumbered(iface.getName(), _frrConfiguration.getBgpProcess())) {
convertVxlans(c, this, vniToVrf, loopbackClagVxlanAnycastIp, loopbackVxlanLocalTunnelIp, _w);

convertOspfProcess(c, this, _w);
addOspfUnnumberedLLAs(c);
convertBgpProcess(c, this, _w);

initVendorFamily(c);
Expand All @@ -207,6 +199,40 @@ && isUsedForBgpUnnumbered(iface.getName(), _frrConfiguration.getBgpProcess())) {
return c;
}

/**
* For interfaces that didn't get an address via either interfaces or FRR, give them a link-local
* address if they are being used for BGP unnumbered.
*/
private void addBgpUnnumberedLLAs(Configuration c) {
c.getAllInterfaces()
.forEach(
(iname, iface) -> {
if (iface.getAllAddresses().size() == 0
&& isUsedForBgpUnnumbered(iface.getName(), _frrConfiguration.getBgpProcess())) {
iface.setAddress(LINK_LOCAL_ADDRESS);
iface.setAllAddresses(ImmutableSet.of(LINK_LOCAL_ADDRESS));
}
});
}

/**
* For interfaces that didn't get an address via either interfaces or FRR, give them a link-local
* address if they are being used for OSPF unnumbered.
*/
private void addOspfUnnumberedLLAs(Configuration c) {
c.getAllInterfaces()
.forEach(
(iname, iface) -> {
if (iface.getAllAddresses().size() == 0
&& iface.getOspfEnabled()
&& !iface.getOspfPassive()
&& iface.getOspfSettings().getNetworkType() == OspfNetworkType.POINT_TO_POINT) {
iface.setAddress(LINK_LOCAL_ADDRESS);
iface.setAllAddresses(ImmutableSet.of(LINK_LOCAL_ADDRESS));
}
});
}

private void populatePortsInterfaceProperties(Configuration c) {
_portsConfiguration
.getPortSettings()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static org.hamcrest.Matchers.hasEntry;
import static org.hamcrest.Matchers.hasKey;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
Expand Down Expand Up @@ -61,6 +62,7 @@
import org.batfish.datamodel.GeneratedRoute;
import org.batfish.datamodel.Interface;
import org.batfish.datamodel.Ip;
import org.batfish.datamodel.LinkLocalAddress;
import org.batfish.datamodel.OriginType;
import org.batfish.datamodel.OspfExternalType2Route;
import org.batfish.datamodel.Prefix;
Expand Down Expand Up @@ -939,4 +941,35 @@ public void testOspfAddresses() throws IOException {
assertNull(iface.getOspfSettings());
}
}

@Test
public void testOspfUnnumberedLLAs() throws IOException {
Configuration c = parseConfig("ospf_link_local");
assertThat(c.getAllInterfaces(), hasKeys("swp1", "swp2", "swp3", "swp4", "swp5", "lo"));
{
Interface iface = c.getAllInterfaces().get("swp1");
assertThat(iface.getAddress(), equalTo(ConcreteInterfaceAddress.parse("10.0.0.1/32")));
assertThat(iface.getAllAddresses(), contains(ConcreteInterfaceAddress.parse("10.0.0.1/32")));
}
{
Interface iface = c.getAllInterfaces().get("swp2");
assertThat(iface.getAddress(), instanceOf(LinkLocalAddress.class));
assertThat(iface.getAllAddresses(), contains(instanceOf(LinkLocalAddress.class)));
}
{
Interface iface = c.getAllInterfaces().get("swp3");
assertNull(iface.getAddress());
assertThat(iface.getAllAddresses(), empty());
}
{
Interface iface = c.getAllInterfaces().get("swp4");
assertNull(iface.getAddress());
assertThat(iface.getAllAddresses(), empty());
}
{
Interface iface = c.getAllInterfaces().get("swp5");
assertNull(iface.getAddress());
assertThat(iface.getAllAddresses(), empty());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
ospf_link_local
# This file describes the network interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

auto swp1
iface swp1
# Should own 10.0.0.1/32, since this is the earliest declared interface that assigns it.
# Should not receive an LLA, since it already has an address.
address 10.0.0.1/32

auto swp2
iface swp2
# Should not own 10.0.0.1/32.
# Instead should receive LLA, since OSPF is enabled on this interface and the network type is point-to-point.
address 10.0.0.1/32

auto swp3
iface swp3
# Should not own 10.0.0.1/32.
# Since OSPF is passive on this interface, should not receive LLA.
address 10.0.0.1/32

auto swp4
iface swp4
# Should not own 10.0.0.1/32.
# Since the OSPF network type is not point-to-point on this interface, should not receive LLA.
address 10.0.0.1/32

auto swp5
iface swp5
# Should not own 10.0.0.1/32.
# Since OSPF is not enabled on this interface, should not receive LLA.
address 10.0.0.1/32

# ports.conf --
# ports.conf --
#
# configure port speed, aggregation, and subdivision.
#
# The ports in Cumulus VX are not configurable from here.
#frr version
frr version 4.0+cl3u8
frr defaults datacenter
hostname ip_reuse
username cumulus nopassword
!
service integrated-vtysh-config
!
log syslog informational
!
interface swp1
ip ospf area 0
ip ospf network point-to-point
!
interface swp2
ip ospf area 0
ip ospf network point-to-point
!
interface swp3
ip ospf area 0
ip ospf network point-to-point
!
interface swp4
ip ospf area 0
!
interface swp5
!
router ospf
ospf router-id 1.1.1.1
passive-interface swp3
!
line vty
!