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 all commits
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
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,49 @@ && 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.getInterfaceType() != InterfaceType.LOOPBACK
&& iface.getOspfEnabled()
&& !iface.getOspfPassive()
&& iface.getOspfSettings().getNetworkType() == OspfNetworkType.POINT_TO_POINT
&& !iface.getOspfSettings().getOspfAddresses().getAddresses().isEmpty()
&& iface.getAllLinkLocalAddresses().isEmpty()) {
if (iface.getAddress() == null) {
iface.setAddress(LINK_LOCAL_ADDRESS);
}
iface.setAllAddresses(
ImmutableSet.<InterfaceAddress>builderWithExpectedSize(
iface.getAllAddresses().size() + 1)
.addAll(iface.getAllAddresses())
.add(LINK_LOCAL_ADDRESS)
.build());
}
});
}

private void populatePortsInterfaceProperties(Configuration c) {
_portsConfiguration
.getPortSettings()
Expand Down
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 @@ -62,6 +63,7 @@
import org.batfish.datamodel.Interface;
import org.batfish.datamodel.InterfaceType;
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 @@ -941,6 +943,51 @@ public void testOspfAddresses() throws IOException {
}
}

@Test
public void testOspfUnnumberedLLAs() throws IOException {
Configuration c = parseConfig("ospf_link_local");
assertThat(c.getAllInterfaces(), hasKeys("swp1", "swp2", "swp3", "swp4", "swp5", "swp6", "lo"));
{
Interface iface = c.getAllInterfaces().get("swp1");
assertThat(iface.getAddress(), equalTo(ConcreteInterfaceAddress.parse("10.0.0.1/32")));
assertThat(
iface.getAllAddresses(),
containsInAnyOrder(
equalTo(ConcreteInterfaceAddress.parse("10.0.0.1/32")),
instanceOf(LinkLocalAddress.class)));
}
{
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());
}
{
Interface iface = c.getAllInterfaces().get("swp6");
assertNull(iface.getAddress());
assertThat(iface.getAllAddresses(), empty());
}
{
Interface iface = c.getAllInterfaces().get("lo");
assertNull(iface.getAddress());
assertThat(iface.getAllAddresses(), empty());
}
}

@Test
public void testLoopbackInterfaceType() throws IOException {
Configuration c = parseConfig("loopback");
Expand Down
@@ -0,0 +1,95 @@
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.
address 10.0.0.1/32

auto swp2
iface swp2
# Should not own 10.0.0.1/32.
address 10.0.0.1/32

auto swp3
iface swp3

auto swp4
iface swp4
# Should not own 10.0.0.1/32.
address 10.0.0.1/32

auto swp5
iface swp5
# Should not own 10.0.0.1/32.
address 10.0.0.1/32

auto swp6
iface swp6
# Should not own 10.0.0.1/32.
address 10.0.0.1/32

auto lo
iface lo
# Should not own 10.0.0.1/32.
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 ospf_link_local
username cumulus nopassword
!
service integrated-vtysh-config
!
log syslog informational
!
interface swp1
! Should receive LLA, since OSPF is enabled on this interface and the network type is point-to-point.
! Even though it already has an address, it needs an LLA to ensure L3 edge can come up.
ip ospf area 0
ip ospf network point-to-point
!
interface swp2
! Should receive LLA, since OSPF is enabled on this interface and the network type is point-to-point.
ip ospf area 0
ip ospf network point-to-point
!
interface swp3
! Even though OSPF is enabled on this interface and the network type is point-to-point, should
! not receive LLA since it was never assigned any addresses.
ip ospf area 0
ip ospf network point-to-point
!
interface swp4
! Since OSPF is passive on this interface, should not receive LLA.
ip ospf area 0
ip ospf network point-to-point
!
interface swp5
! Since the OSPF network type is not point-to-point on this interface, should not receive LLA.
ip ospf area 0
!
interface swp6
! Since OSPF is not enabled on this interface, should not receive LLA.
!
interface lo
! Should not receive LLA since this is a loopback, even though OSPF is enabled on this interface
! and the network type is point-to-point.
ip ospf area 0
ip ospf network point-to-point
!
router ospf
ospf router-id 1.1.1.1
passive-interface swp4
!
line vty
!