From 798afa8add61711044a18dab9e8bc0713ff3fd9f Mon Sep 17 00:00:00 2001 From: Mahesh Kumar Date: Thu, 17 Oct 2024 03:52:57 -0700 Subject: [PATCH 1/4] added support for encapsulation mpls next-hop self source-interface --- .../documentation/devices/router-bgp-evpn-mpls.md | 3 ++- .../intended/configs/router-bgp-evpn-mpls.cfg | 1 + .../inventory/host_vars/router-bgp-evpn-mpls.yml | 2 ++ .../roles/eos_cli_config_gen/docs/tables/router-bgp.md | 4 ++++ .../_eos_cli_config_gen/j2templates/eos/router-bgp.j2 | 8 +++++++- .../schema/eos_cli_config_gen.schema.yml | 3 +++ .../schema/schema_fragments/router_bgp.schema.yml | 3 +++ 7 files changed, 22 insertions(+), 2 deletions(-) diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/router-bgp-evpn-mpls.md b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/router-bgp-evpn-mpls.md index a4b663331bd..37075e00f17 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/router-bgp-evpn-mpls.md +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/router-bgp-evpn-mpls.md @@ -103,7 +103,7 @@ ASN Notation: asplain | Neighbor | Activate | Encapsulation | | -------- | -------- | ------------- | | 192.168.255.3 | True | default | -| 192.168.255.4 | False | default | +| 192.168.255.4 | False | mpls | ##### EVPN Neighbor Default Encapsulation @@ -145,5 +145,6 @@ router bgp 65101 neighbor 192.168.255.3 activate neighbor 192.168.255.4 rcf in Address_Family_EVPN_In() neighbor 192.168.255.4 rcf out Address_Family_EVPN_Out() + neighbor 192.168.255.4 encapsulation mpls next-hop-self source-interface Ethernet1 layer-2 fec in-place update timeout 100 seconds ``` diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/router-bgp-evpn-mpls.cfg b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/router-bgp-evpn-mpls.cfg index 8dc866980e4..fbd0ce41546 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/router-bgp-evpn-mpls.cfg +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/router-bgp-evpn-mpls.cfg @@ -34,4 +34,5 @@ router bgp 65101 neighbor 192.168.255.3 activate neighbor 192.168.255.4 rcf in Address_Family_EVPN_In() neighbor 192.168.255.4 rcf out Address_Family_EVPN_Out() + neighbor 192.168.255.4 encapsulation mpls next-hop-self source-interface Ethernet1 layer-2 fec in-place update timeout 100 seconds diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/router-bgp-evpn-mpls.yml b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/router-bgp-evpn-mpls.yml index 739bf7afadb..7aa5a5372e4 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/router-bgp-evpn-mpls.yml +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/router-bgp-evpn-mpls.yml @@ -55,6 +55,8 @@ router_bgp: - ip_address: 192.168.255.4 rcf_in: Address_Family_EVPN_In() rcf_out: Address_Family_EVPN_Out() + encapsulation: mpls + next_hop_self_source_interface: Ethernet1 peer_groups: - name: EVPN-OVERLAY-PEERS activate: true diff --git a/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/router-bgp.md b/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/router-bgp.md index da99f910a3c..c04a3445dc3 100644 --- a/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/router-bgp.md +++ b/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/router-bgp.md @@ -368,6 +368,7 @@ | [          send](## "router_bgp.address_family_evpn.neighbors.[].additional_paths.send") | String | | | Valid Values:
- any
- backup
- ecmp
- limit
- disabled | Select an option to send multiple paths for same prefix through bgp updates.
any: Send any eligible path.
backup: Best path and installed backup path.
ecmp: All paths in best path ECMP group.
limit: Limit to n eligible paths.
disabled: Disable sending any paths. | | [          send_limit](## "router_bgp.address_family_evpn.neighbors.[].additional_paths.send_limit") | Integer | | | Min: 2
Max: 64 | Number of paths to send through bgp updates. For this setting, `send` must be set to `limit` or `ecmp`. | | [        encapsulation](## "router_bgp.address_family_evpn.neighbors.[].encapsulation") | String | | | Valid Values:
- vxlan
- mpls
- path-selection | Transport encapsulation for the neighbor. | + | [        next_hop_self_source_interface](## "router_bgp.address_family_evpn.neighbors.[].next_hop_self_source_interface") | String | | | | Source interface name. | | [    peer_groups](## "router_bgp.address_family_evpn.peer_groups") | List, items: Dictionary | | | | | | [      - name](## "router_bgp.address_family_evpn.peer_groups.[].name") | String | Required, Unique | | | Peer-group name. | | [        activate](## "router_bgp.address_family_evpn.peer_groups.[].activate") | Boolean | | | | | @@ -2286,6 +2287,9 @@ # Transport encapsulation for the neighbor. encapsulation: + + # Source interface name. + next_hop_self_source_interface: peer_groups: # Peer-group name. diff --git a/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos/router-bgp.j2 b/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos/router-bgp.j2 index d477194a94b..f6650d2c6c9 100644 --- a/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos/router-bgp.j2 +++ b/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos/router-bgp.j2 @@ -924,8 +924,14 @@ router bgp {{ router_bgp.as }} neighbor {{ neighbor.ip_address }} additional-paths send {{ neighbor.additional_paths.send }} {% endif %} {% endif %} -{% if neighbor.encapsulation is arista.avd.defined %} +{% if neighbor.encapsulation is arista.avd.defined and neighbor.encapsulation in ["vxlan", "path-selection"] %} neighbor {{ neighbor.ip_address }} encapsulation {{ neighbor.encapsulation }} +{% elif neighbor.encapsulation is arista.avd.defined("mpls") %} +{% set encapsulation_cli = "neighbor " ~ neighbor.ip_address ~ " encapsulation mpls" %} +{% if neighbor.next_hop_self_source_interface is arista.avd.defined %} +{% set encapsulation_cli = encapsulation_cli ~ " next-hop-self source-interface " ~ neighbor.next_hop_self_source_interface %} +{% endif %} + {{ encapsulation_cli }} {% endif %} {% endfor %} {% if router_bgp.address_family_evpn.domain_identifier is arista.avd.defined %} diff --git a/python-avd/pyavd/_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml b/python-avd/pyavd/_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml index 2a4b8346936..2dc6f04c962 100644 --- a/python-avd/pyavd/_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml +++ b/python-avd/pyavd/_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml @@ -13150,6 +13150,9 @@ keys: - mpls - path-selection description: Transport encapsulation for the neighbor. + next_hop_self_source_interface: + type: str + description: Source interface name. peer_groups: type: list primary_key: name diff --git a/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/router_bgp.schema.yml b/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/router_bgp.schema.yml index 275fb466252..4c8e05a3b5f 100644 --- a/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/router_bgp.schema.yml +++ b/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/router_bgp.schema.yml @@ -1329,6 +1329,9 @@ keys: - "mpls" - "path-selection" description: Transport encapsulation for the neighbor. + next_hop_self_source_interface: + type: str + description: Source interface name. peer_groups: type: list primary_key: name From 7e6c79b80723da42654eea9f0e06644b8a08bf75 Mon Sep 17 00:00:00 2001 From: Mahesh Kumar Date: Thu, 17 Oct 2024 04:25:46 -0700 Subject: [PATCH 2/4] updated the description --- .../avd/roles/eos_cli_config_gen/docs/tables/router-bgp.md | 4 ++-- .../_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml | 3 ++- .../schema/schema_fragments/router_bgp.schema.yml | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/router-bgp.md b/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/router-bgp.md index c04a3445dc3..1bc832bf1f8 100644 --- a/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/router-bgp.md +++ b/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/router-bgp.md @@ -368,7 +368,7 @@ | [          send](## "router_bgp.address_family_evpn.neighbors.[].additional_paths.send") | String | | | Valid Values:
- any
- backup
- ecmp
- limit
- disabled | Select an option to send multiple paths for same prefix through bgp updates.
any: Send any eligible path.
backup: Best path and installed backup path.
ecmp: All paths in best path ECMP group.
limit: Limit to n eligible paths.
disabled: Disable sending any paths. | | [          send_limit](## "router_bgp.address_family_evpn.neighbors.[].additional_paths.send_limit") | Integer | | | Min: 2
Max: 64 | Number of paths to send through bgp updates. For this setting, `send` must be set to `limit` or `ecmp`. | | [        encapsulation](## "router_bgp.address_family_evpn.neighbors.[].encapsulation") | String | | | Valid Values:
- vxlan
- mpls
- path-selection | Transport encapsulation for the neighbor. | - | [        next_hop_self_source_interface](## "router_bgp.address_family_evpn.neighbors.[].next_hop_self_source_interface") | String | | | | Source interface name. | + | [        next_hop_self_source_interface](## "router_bgp.address_family_evpn.neighbors.[].next_hop_self_source_interface") | String | | | | Source interface name for MPLS encapsulation. Requires `encapsulation` to be set as `mpls`. | | [    peer_groups](## "router_bgp.address_family_evpn.peer_groups") | List, items: Dictionary | | | | | | [      - name](## "router_bgp.address_family_evpn.peer_groups.[].name") | String | Required, Unique | | | Peer-group name. | | [        activate](## "router_bgp.address_family_evpn.peer_groups.[].activate") | Boolean | | | | | @@ -2288,7 +2288,7 @@ # Transport encapsulation for the neighbor. encapsulation: - # Source interface name. + # Source interface name for MPLS encapsulation. Requires `encapsulation` to be set as `mpls`. next_hop_self_source_interface: peer_groups: diff --git a/python-avd/pyavd/_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml b/python-avd/pyavd/_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml index 2dc6f04c962..b8744e344aa 100644 --- a/python-avd/pyavd/_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml +++ b/python-avd/pyavd/_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml @@ -13152,7 +13152,8 @@ keys: description: Transport encapsulation for the neighbor. next_hop_self_source_interface: type: str - description: Source interface name. + description: Source interface name for MPLS encapsulation. Requires + `encapsulation` to be set as `mpls`. peer_groups: type: list primary_key: name diff --git a/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/router_bgp.schema.yml b/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/router_bgp.schema.yml index 4c8e05a3b5f..97c7e4fec18 100644 --- a/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/router_bgp.schema.yml +++ b/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/router_bgp.schema.yml @@ -1331,7 +1331,7 @@ keys: description: Transport encapsulation for the neighbor. next_hop_self_source_interface: type: str - description: Source interface name. + description: Source interface name for MPLS encapsulation. Requires `encapsulation` to be set as `mpls`. peer_groups: type: list primary_key: name From 0c27b8067ea12990b54c6049c6919b5e988a4c61 Mon Sep 17 00:00:00 2001 From: Mahesh Kumar Date: Fri, 18 Oct 2024 04:34:53 -0700 Subject: [PATCH 3/4] updated the logic --- .../_eos_cli_config_gen/j2templates/eos/router-bgp.j2 | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos/router-bgp.j2 b/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos/router-bgp.j2 index f6650d2c6c9..0352e523ae1 100644 --- a/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos/router-bgp.j2 +++ b/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos/router-bgp.j2 @@ -924,11 +924,9 @@ router bgp {{ router_bgp.as }} neighbor {{ neighbor.ip_address }} additional-paths send {{ neighbor.additional_paths.send }} {% endif %} {% endif %} -{% if neighbor.encapsulation is arista.avd.defined and neighbor.encapsulation in ["vxlan", "path-selection"] %} - neighbor {{ neighbor.ip_address }} encapsulation {{ neighbor.encapsulation }} -{% elif neighbor.encapsulation is arista.avd.defined("mpls") %} -{% set encapsulation_cli = "neighbor " ~ neighbor.ip_address ~ " encapsulation mpls" %} -{% if neighbor.next_hop_self_source_interface is arista.avd.defined %} +{% if neighbor.encapsulation is arista.avd.defined %} +{% set encapsulation_cli = "neighbor " ~ neighbor.ip_address ~ " encapsulation " ~ neighbor.encapsulation %} +{% if neighbor.encapsulation == "mpls" and neighbor.next_hop_self_source_interface is arista.avd.defined %} {% set encapsulation_cli = encapsulation_cli ~ " next-hop-self source-interface " ~ neighbor.next_hop_self_source_interface %} {% endif %} {{ encapsulation_cli }} From 46ac58ed5906acdbdca5c47b8072cd4e967d1830 Mon Sep 17 00:00:00 2001 From: Mahesh Kumar Date: Mon, 28 Oct 2024 17:01:15 +0530 Subject: [PATCH 4/4] added description for another next_hop_self_source_interface key --- .../avd/roles/eos_cli_config_gen/docs/tables/router-bgp.md | 4 ++-- .../_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml | 3 ++- .../schema/schema_fragments/router_bgp.schema.yml | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/router-bgp.md b/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/router-bgp.md index 1bc832bf1f8..91ea4d5d640 100644 --- a/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/router-bgp.md +++ b/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/router-bgp.md @@ -347,7 +347,7 @@ | [    domain_identifier](## "router_bgp.address_family_evpn.domain_identifier") | String | | | | | | [    neighbor_default](## "router_bgp.address_family_evpn.neighbor_default") | Dictionary | | | | | | [      encapsulation](## "router_bgp.address_family_evpn.neighbor_default.encapsulation") | String | | | Valid Values:
- vxlan
- mpls
- path-selection | Transport encapsulation for neighbor. | - | [      next_hop_self_source_interface](## "router_bgp.address_family_evpn.neighbor_default.next_hop_self_source_interface") | String | | | | Source interface name. | + | [      next_hop_self_source_interface](## "router_bgp.address_family_evpn.neighbor_default.next_hop_self_source_interface") | String | | | | Source interface name for MPLS encapsulation. Requires `encapsulation` to be set as `mpls`. | | [      next_hop_self_received_evpn_routes](## "router_bgp.address_family_evpn.neighbor_default.next_hop_self_received_evpn_routes") | Dictionary | | | | | | [        enable](## "router_bgp.address_family_evpn.neighbor_default.next_hop_self_received_evpn_routes.enable") | Boolean | | | | | | [        inter_domain](## "router_bgp.address_family_evpn.neighbor_default.next_hop_self_received_evpn_routes.inter_domain") | Boolean | | | | | @@ -2237,7 +2237,7 @@ # Transport encapsulation for neighbor. encapsulation: - # Source interface name. + # Source interface name for MPLS encapsulation. Requires `encapsulation` to be set as `mpls`. next_hop_self_source_interface: next_hop_self_received_evpn_routes: enable: diff --git a/python-avd/pyavd/_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml b/python-avd/pyavd/_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml index 3b9f83a0386..4b80c1eda3a 100644 --- a/python-avd/pyavd/_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml +++ b/python-avd/pyavd/_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml @@ -13077,7 +13077,8 @@ keys: - path-selection description: Transport encapsulation for neighbor. next_hop_self_source_interface: - description: Source interface name. + description: Source interface name for MPLS encapsulation. Requires + `encapsulation` to be set as `mpls`. type: str next_hop_self_received_evpn_routes: type: dict diff --git a/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/router_bgp.schema.yml b/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/router_bgp.schema.yml index 97c7e4fec18..697daced949 100644 --- a/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/router_bgp.schema.yml +++ b/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/router_bgp.schema.yml @@ -1259,7 +1259,7 @@ keys: - "path-selection" description: Transport encapsulation for neighbor. next_hop_self_source_interface: - description: Source interface name. + description: Source interface name for MPLS encapsulation. Requires `encapsulation` to be set as `mpls`. type: str next_hop_self_received_evpn_routes: type: dict