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

PAN: support for BGP multihop #6370

Merged
merged 1 commit into from
Oct 29, 2020
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 @@ -952,6 +952,11 @@ MULTICAST
'multicast'
;

MULTIHOP
:
'multihop'
;

NAT
:
'nat'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ bgppgp_connection_options
CONNECTION_OPTIONS
(
bgppgp_co_incoming_bgp_connection
| bgppgp_co_multihop
| bgppgp_co_null
| bgppgp_co_outgoing_bgp_connection
)
Expand All @@ -142,6 +143,11 @@ bgppgp_coi_remote_port
REMOTE_PORT p = port_number
;

bgppgp_co_multihop
:
MULTIHOP num = uint8 // 0-255
;

bgppgp_co_null
:
(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
import org.batfish.grammar.palo_alto.PaloAltoParser.Bgppg_definitionContext;
import org.batfish.grammar.palo_alto.PaloAltoParser.Bgppg_enableContext;
import org.batfish.grammar.palo_alto.PaloAltoParser.Bgppg_peerContext;
import org.batfish.grammar.palo_alto.PaloAltoParser.Bgppgp_co_multihopContext;
import org.batfish.grammar.palo_alto.PaloAltoParser.Bgppgp_coi_allowContext;
import org.batfish.grammar.palo_alto.PaloAltoParser.Bgppgp_coi_remote_portContext;
import org.batfish.grammar.palo_alto.PaloAltoParser.Bgppgp_coo_allowContext;
Expand Down Expand Up @@ -927,6 +928,11 @@ public void exitBgppgp_coi_remote_port(Bgppgp_coi_remote_portContext ctx) {
_currentBgpPeer.getConnectionOptions().setRemotePort(toInteger(ctx.p));
}

@Override
public void enterBgppgp_co_multihop(Bgppgp_co_multihopContext ctx) {
_currentBgpPeer.setMultihop(toInteger(ctx.num));
}

@Override
public void exitBgppgp_coo_allow(Bgppgp_coo_allowContext ctx) {
_currentBgpPeer.getConnectionOptions().setOutgoingAllow(toBoolean(ctx.yn));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ public void setLocalInterface(@Nullable String localInterface) {
_localInterface = localInterface;
}

@Nullable
public Integer getMultihop() {
return _multihop;
}

public void setMultihop(@Nullable Integer multihop) {
_multihop = multihop;
}

public @Nonnull String getName() {
return _name;
}
Expand Down Expand Up @@ -90,4 +99,5 @@ public void setReflectorClient(@Nullable ReflectorClient reflectorClient) {
private @Nullable Ip _peerAddress;
private @Nullable Long _peerAs;
private @Nullable ReflectorClient _reflectorClient;
private @Nullable Integer _multihop;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2084,6 +2084,10 @@ private void convertPeer(
.setGroup(pg.getName())
.setLocalAs(localAs)
.setPeerAddress(peer.getPeerAddress())
// Multihop (as batfish VI model understands it) is always on for PAN because of
// "number + 2" computation
// See https://knowledgebase.paloaltonetworks.com/KCSArticleDetail?id=kA10g000000ClKkCAK
.setEbgpMultihop(true)
.setRemoteAs(peerAs);
if (peer.getLocalAddress() != null) {
peerB.setLocalIp(peer.getLocalAddress());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3713,4 +3713,33 @@ public void testSecurityRuleTag() {
.getTags(),
contains("TAG"));
}

@Test
public void testBgpMultihopExtraction() {
String hostname = "bgp-multihop";
PaloAltoConfiguration vs = parsePaloAltoConfig(hostname);
assertThat(
vs.getVirtualRouters()
.get("vr1")
.getBgp()
.getPeerGroups()
.get("pg1")
.getPeers()
.get("peer1")
.getMultihop(),
equalTo(0));
}

@Test
public void testBgpMultihopConversion() {
String hostname = "bgp-multihop";
Configuration c = parseConfig(hostname);
assertTrue(
c.getVrfs()
.get("vr1")
.getBgpProcess()
.getActiveNeighbors()
.get(Prefix.parse("120.120.120.120/32"))
.getEbgpMultihop());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
set deviceconfig system hostname bgp-multihop

set network interface ethernet ethernet1/3 layer3 units ethernet1/3.5 ip 1.1.1.3/24
set network virtual-router vr1 interface ethernet1/3.5

set network virtual-router vr1 protocol bgp enable yes
set network virtual-router vr1 protocol bgp router-id 1.1.1.1
set network virtual-router vr1 protocol bgp local-as 1

set network virtual-router vr1 protocol bgp peer-group pg1 enable yes
set network virtual-router vr1 protocol bgp peer-group pg1 peer peer1 local-address interface ethernet1/3.5
set network virtual-router vr1 protocol bgp peer-group pg1 peer peer1 peer-address ip 120.120.120.120
set network virtual-router vr1 protocol bgp peer-group pg1 peer peer1 peer-as 2345
set network virtual-router vr1 protocol bgp peer-group pg1 peer peer1 enable yes
set network virtual-router vr1 protocol bgp peer-group pg1 peer peer1 connection-options multihop 0