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

Junos: Add missing vxlan grammar #8112

Merged
merged 22 commits into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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 @@ -1978,6 +1978,8 @@ OUTPUT_VLAN_MAP: 'output-vlan-map';

OUTER: 'outer';

OVERLAY_ECMP: 'overlay-ecmp';

OVERLOAD: 'overload';

OVERRIDE_METRIC: 'override-metric';
Expand Down Expand Up @@ -2862,6 +2864,8 @@ VTEP_SOURCE_INTERFACE

VXLAN: 'vxlan';

VXLAN_ROUTING: 'vxlan-routing';

WEB_MANAGEMENT: 'web-management';

WEBAPI: 'webapi';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ s_vlans_named
| vlt_interface
| vlt_l3_interface
| vlt_vlan_id
| vlt_vni_id
)
;

Expand Down Expand Up @@ -220,3 +221,8 @@ vlt_vlan_id
:
VLAN_ID id = dec
;

vlt_vni_id
:
VXLAN VNI id = dec
;
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ fo_null
) null_filler
;

fo_vxlan_routing
:
VXLAN_ROUTING
(
fov_overlay_ecmp
)
;

fod_active_server_group
:
ACTIVE_SERVER_GROUP name = junos_name
Expand Down Expand Up @@ -148,6 +156,11 @@ fohb_server_null
)?
;

fov_overlay_ecmp
:
OVERLAY_ECMP
;

s_forwarding_options
:
FORWARDING_OPTIONS
Expand All @@ -156,5 +169,6 @@ s_forwarding_options
| fo_dhcp_relay
| fo_helpers
| fo_null
| fo_vxlan_routing
)
;
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@
import org.batfish.grammar.flatjuniper.FlatJuniperParser.Filter_nameContext;
import org.batfish.grammar.flatjuniper.FlatJuniperParser.Flat_juniper_configurationContext;
import org.batfish.grammar.flatjuniper.FlatJuniperParser.Fo_dhcp_relayContext;
import org.batfish.grammar.flatjuniper.FlatJuniperParser.Fo_vxlan_routingContext;
import org.batfish.grammar.flatjuniper.FlatJuniperParser.Fod_active_server_groupContext;
import org.batfish.grammar.flatjuniper.FlatJuniperParser.Fod_groupContext;
import org.batfish.grammar.flatjuniper.FlatJuniperParser.Fod_server_groupContext;
Expand Down Expand Up @@ -673,6 +674,7 @@
import org.batfish.grammar.flatjuniper.FlatJuniperParser.Vlt_interfaceContext;
import org.batfish.grammar.flatjuniper.FlatJuniperParser.Vlt_l3_interfaceContext;
import org.batfish.grammar.flatjuniper.FlatJuniperParser.Vlt_vlan_idContext;
import org.batfish.grammar.flatjuniper.FlatJuniperParser.Vlt_vni_idContext;
import org.batfish.grammar.flatjuniper.FlatJuniperParser.ZoneContext;
import org.batfish.grammar.silent_syntax.SilentSyntaxCollection;
import org.batfish.representation.juniper.AddressAddressBookEntry;
Expand Down Expand Up @@ -2389,6 +2391,11 @@ public void enterFf_term(Ff_termContext ctx) {
FIREWALL_FILTER_TERM, defName, FIREWALL_FILTER_TERM_DEFINITION, getLine(ctx.name.start));
}

@Override
public void exitFo_vxlan_routing(Fo_vxlan_routingContext ctx) {
warn(ctx, "Batfish does not enable two-level equal-cost multipath next hops.");
}

@Override
public void enterFo_dhcp_relay(Fo_dhcp_relayContext ctx) {
_currentDhcpRelayGroup =
Expand Down Expand Up @@ -6527,6 +6534,12 @@ public void exitVlt_vlan_id(Vlt_vlan_idContext ctx) {
_currentNamedVlan.setVlanId(vlan);
}

@Override
public void exitVlt_vni_id(Vlt_vni_idContext ctx) {
int vni = toInt(ctx.id);
_currentNamedVlan.setVniId(vni);
}

@Override
public void exitVlt_interface(Vlt_interfaceContext ctx) {
String name = getInterfaceFullName(ctx.interface_id());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class Vlan implements Serializable {
private @Nonnull Set<String> _interfaces;
private @Nullable String _l3Interface;
private @Nullable Integer _vlanId;
private @Nullable Integer _vniId;

public Vlan(String name) {
_name = name;
Expand All @@ -41,10 +42,18 @@ public void addInterface(String ifname) {
return _vlanId;
}

public @Nullable Integer getVniId() {
return _vniId;
}

public void setVlanId(int vlanId) {
_vlanId = vlanId;
}

public void setVniId(int vniId) {
_vniId = vniId;
}

public void setL3Interface(String l3Interface) {
_l3Interface = l3Interface;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5000,6 +5000,19 @@ public void testOspfSummaries() {
LineAction.PERMIT, Prefix.ZERO, new SubRange(0, Prefix.MAX_PREFIX_LENGTH)))));
}

@Test
public void testOverlayEcmp() throws IOException {
String hostname = "juniper-overlay-ecmp";
Batfish batfish = getBatfishForConfigurationNames(hostname);
ParseVendorConfigurationAnswerElement pvcae =
batfish.loadParseVendorConfigurationAnswerElement(batfish.getSnapshot());
assertThat(
pvcae,
hasParseWarning(
"configs/" + hostname,
equalTo("Batfish does not enable two-level equal-cost multipath next hops.")));
}

@Test
public void testParsingRecovery() {
String recoveryText = readResource("org/batfish/grammar/juniper/testconfigs/recovery", UTF_8);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
set system host-name interface-vni
#
set interfaces ge-0/0/0 unit 0 family ethernet-switching vlan members VLAN_TEST

set vlans VLAN_TEST vlan-id 101

set vlans VLAN_TEST vlan-id 101
set vlans VLAN_TEST vxlan vni 10101
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
set system host-name juniper-evpn
#
set interfaces ge-0/0/0 unit 0 family ethernet-switching vlan members VLAN_TEST

set vlans VLAN_TEST vlan-id 101

set vlans VLAN_TEST vlan-id 101
set vlans VLAN_TEST vxlan vni 10101


set protocols evpn vni-options vni 10101 vrf-target target:65310:11003
set protocols evpn encapsulation vxlan
set protocols evpn multicast-mode ingress-replication
set protocols evpn default-gateway no-gateway-community
set protocols evpn extended-vni-list all
set protocols evpn duplicate-mac-detection auto-recovery-time 15
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#
set system host-name juniper-overlay-ecmp
#
set forwarding-options vxlan-routing overlay-ecmp