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

FRR: Adding max-metric router-lsa administrative support #6577

Merged
merged 1 commit into from
Jan 20, 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
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,11 @@ MAX_MED
'max-med'
;

MAX_METRIC
:
'max-metric'
;

MESSAGE_DIGEST
:
'message-digest'
Expand Down Expand Up @@ -734,6 +739,11 @@ ROUTE_REFLECTOR_CLIENT
'route-reflector-client'
;

ROUTER_LSA
:
'router-lsa'
;

SUBNET_MASK
:
F_SubnetMask
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ s_router_ospf
ROUTER OSPF NEWLINE
(
ro_log_adj_changes
| ro_max_metric_router_lsa_administrative
| ro_no
| ro_passive_interface
| ro_router_id
Expand All @@ -23,6 +24,11 @@ ro_log_adj_changes
LOG_ADJACENCY_CHANGES DETAIL? NEWLINE
;

ro_max_metric_router_lsa_administrative
:
MAX_METRIC ROUTER_LSA ADMINISTRATIVE NEWLINE
;

ro_no
:
NO
Expand All @@ -40,6 +46,8 @@ rono_passive_interface
)
;



ro_redistribute
:
REDISTRIBUTE ospf_redist_type (ROUTE_MAP route_map_name)? NEWLINE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
import org.batfish.grammar.cumulus_frr.CumulusFrrParser.Rms_tagContext;
import org.batfish.grammar.cumulus_frr.CumulusFrrParser.Rms_weightContext;
import org.batfish.grammar.cumulus_frr.CumulusFrrParser.Rmsipnh_literalContext;
import org.batfish.grammar.cumulus_frr.CumulusFrrParser.Ro_max_metric_router_lsa_administrativeContext;
import org.batfish.grammar.cumulus_frr.CumulusFrrParser.Ro_redistributeContext;
import org.batfish.grammar.cumulus_frr.CumulusFrrParser.Ro_router_idContext;
import org.batfish.grammar.cumulus_frr.CumulusFrrParser.Ronopi_defaultContext;
Expand Down Expand Up @@ -677,6 +678,12 @@ public void enterS_router_ospf(S_router_ospfContext ctx) {
}
}

@Override
public void exitRo_max_metric_router_lsa_administrative(
Ro_max_metric_router_lsa_administrativeContext ctx) {
_frr.getOspfProcess().setMaxMetricRouterLsa(true);
}

@Override
public void exitRo_router_id(Ro_router_idContext ctx) {
if (_frr.getOspfProcess() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public final class CumulusConversions {
public static final Ip CLAG_LINK_LOCAL_IP = Ip.parse("169.254.40.94");

public static final long DEFAULT_MAX_MED = 4294967294L;
public static final long DEFAULT_OSPF_MAX_METRIC = 0xFFFF;

@VisibleForTesting
static GeneratedRoute GENERATED_DEFAULT_ROUTE =
Expand Down Expand Up @@ -1245,6 +1246,11 @@ static org.batfish.datamodel.ospf.OspfProcess toOspfProcess(
addOspfInterfaces(vsConfig, vrfInterfaces, proc.getProcessId(), w);
proc.setAreas(computeOspfAreas(vsConfig, vrfInterfaces.keySet()));

// Handle Max Metric Router LSA
if (firstNonNull(vsConfig.getOspfProcess().getMaxMetricRouterLsa(), Boolean.FALSE)) {
proc.setMaxMetricTransitLinks(DEFAULT_OSPF_MAX_METRIC);
}

// Handle Redistribution
String ospfExportPolicyName = computeOspfExportPolicyName(ospfVrf.getVrfName());
RoutingPolicy ospfExportPolicy = new RoutingPolicy(ospfExportPolicyName, c);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.batfish.datamodel.Configuration;

/** Class for ospf process */
Expand All @@ -18,6 +19,7 @@ public class OspfProcess implements Serializable {
public static String DEFAULT_OSPF_PROCESS_NAME = "default";

private Map<CumulusRoutingProtocol, RedistributionPolicy> _redistributionPolicies;
private @Nullable Boolean _maxMetricRouterLsa;

public OspfProcess() {
_defaultVrf = new OspfVrf(Configuration.DEFAULT_VRF_NAME);
Expand Down Expand Up @@ -46,4 +48,12 @@ public void setDefaultPassiveInterface(boolean defaultPassiveInterface) {
public Map<CumulusRoutingProtocol, RedistributionPolicy> getRedistributionPolicies() {
return _redistributionPolicies;
}

public Boolean getMaxMetricRouterLsa() {
return _maxMetricRouterLsa;
}

public void setMaxMetricRouterLsa(Boolean maxMetricRouterLsa) {
_maxMetricRouterLsa = maxMetricRouterLsa;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1682,6 +1682,18 @@ public void testOspfRedistributeBgpRouteMap() {
assertThat(policy.getRouteMap(), equalTo("foo"));
}

@Test
public void testOspfMaxMetricRouterLsaAdministrativeDefault() {
parseLines("router ospf");
assertThat(_frr.getOspfProcess().getMaxMetricRouterLsa(), equalTo(null));
}

@Test
public void testOspfMaxMetricRouterLsaAdministrative() {
parseLines("router ospf", "max-metric router-lsa administrative");
assertThat(_frr.getOspfProcess().getMaxMetricRouterLsa(), equalTo(true));
}

@Test
public void testOspfRedistributeBgpSetMetric_behavior() throws IOException {
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,26 @@ public void testToOspfProcess_RedistributionPolicy() {
new SetOspfMetricType(OspfMetricType.E2), new SetMetric(new LiteralLong(20L))));
}

@Test
public void testToOspfProcess_MaxMetricRouterLsa() {
OspfVrf ospfVrf = new OspfVrf(DEFAULT_VRF_NAME);
CumulusNcluConfiguration vsConfig = new CumulusNcluConfiguration();
OspfProcess vsOspf = new OspfProcess();
vsOspf.setMaxMetricRouterLsa(true);
vsConfig.setOspfProcess(vsOspf);

org.batfish.datamodel.ospf.OspfProcess ospfProcess =
toOspfProcess(
new Configuration("dummy", ConfigurationFormat.CUMULUS_NCLU),
vsConfig,
ospfVrf,
ImmutableMap.of(),
new Warnings());
assertThat(
ospfProcess.getMaxMetricTransitLinks(),
equalTo(CumulusConversions.DEFAULT_OSPF_MAX_METRIC));
}

@Test
public void testConvertOspfRedistributionPolicy() {
// setup VI model
Expand Down