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

[BGP]Adding configuration knob to allow advertise Loopback ipv6 /128 prefix #30

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions dockers/docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
ip prefix-list PL_LoopbackV4 permit {{ get_ipv4_loopback_address(LOOPBACK_INTERFACE, "Loopback0") | ip }}/32
!
{% if get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback0") != 'None' %}
{% if DEVICE_METADATA['localhost']['bgp_adv_lo_prefix_as_128'] == 'true' %}
ipv6 prefix-list PL_LoopbackV6 permit {{ get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback0") | ip_network }}/128
{% else %}
ipv6 prefix-list PL_LoopbackV6 permit {{ get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback0") | replace('/128', '/64') | ip_network }}/64
{% endif %}
{% endif %}
!
{% if VLAN_INTERFACE is defined %}
{% set vnet_intfs = get_vnet_interfaces(VLAN_INTERFACE) %}
Expand Down Expand Up @@ -89,7 +93,11 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
!
{% if get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback0") != 'None' %}
address-family ipv6
{% if DEVICE_METADATA['localhost']['bgp_adv_lo_prefix_as_128'] == 'true' %}
network {{ get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback0") | ip }}/128
{% else %}
network {{ get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback0") | ip }}/64
{% endif %}
exit-address-family
{% endif %}
{% if ((multi_asic is defined and DEVICE_METADATA['localhost']['switch_type'] != 'chassis-packet') or (DEVICE_METADATA['localhost']['switch_type'] == 'voq')) %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
{% from "common/functions.conf.j2" import get_ipv4_loopback_address, get_ipv6_loopback_address, get_vnet_interfaces %}
!
{% block loopback_route %}
! add static ipv6 /64 loopback route to allow bgpd to advertise the loopback route prefix
{% if get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback0") != 'None' %}
{% if DEVICE_METADATA['localhost']['bgp_adv_lo_prefix_as_128'] == 'true' %}
! add static ipv6 /128 loopback route to allow bgpd to advertise the loopback route prefix
ipv6 route {{ get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback0") | ip_network }}/128 Loopback0
{% else %}
! add static ipv6 /64 loopback route to allow bgpd to advertise the loopback route prefix
ipv6 route {{ get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback0") | replace('/128', '/64') | ip_network }}/64 Loopback0
{% endif %}
{% endif %}
{% endblock loopback_route %}
!
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
!
! template: bgpd/bgpd.main.conf.j2
!
! bgp multiple-instance
!
! BGP configuration
!
! TSA configuration
!
ip prefix-list PL_LoopbackV4 permit 55.55.55.55/32
!
ipv6 prefix-list PL_LoopbackV6 permit fc00::1/128
!
router bgp 55555
!
bgp log-neighbor-changes
no bgp default ipv4-unicast
no bgp ebgp-requires-policy
!
bgp router-id 55.55.55.55
!
network 55.55.55.55/32
!
address-family ipv6
network fc00::1/128
! end of template: bgpd/bgpd.main.conf.j2
!
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"DEVICE_METADATA": {
"localhost": {
"bgp_asn": "55555",
"bgp_adv_lo_prefix_as_128": "true"
}
},
"LOOPBACK_INTERFACE": {
"Loopback0|fc00::1/128": {}
},
"constants": {
"bgp": {
"multipath_relax": {},
"graceful_restart": {},
"maximum_paths": {}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
!
! add static ipv6 /128 loopback route to allow bgpd to advertise the loopback route prefix
ipv6 route fc00:1::32/128 Loopback0
!!
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"DEVICE_METADATA": {
"localhost": {
"bgp_adv_lo_prefix_as_128": "true"
}
},
"LOOPBACK_INTERFACE": {
"Loopback0|FC00:1::32/128": {}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"DEVICE_METADATA": {
"localhost": {
}
},
"LOOPBACK_INTERFACE": {
"Loopback0|FC00:1::32/128": {}
}
Expand Down
12 changes: 12 additions & 0 deletions src/sonic-bgpcfgd/tests/test_sonic-cfggen.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ def test_bgpd_main_conf_packet_chassis():
"bgpd.main.conf.j2/packet_chassis.json",
"bgpd.main.conf.j2/packet_chassis.conf")

def test_bgpd_lo_ipv6_conf_base():
run_test("IPv6 Loopback bgpd.main.conf.j2",
"bgpd/bgpd.main.conf.j2",
"bgpd.main.conf.j2/base.json",
"bgpd.main.conf.j2/base.conf")

def test_tsa_isolate():
run_test("tsa/bgpd.tsa.isolate.conf.j2",
"bgpd/tsa/bgpd.tsa.isolate.conf.j2",
Expand Down Expand Up @@ -87,6 +93,12 @@ def test_staticd_loopback_route():
"staticd/staticd.loopback_route.conf.json",
"staticd/staticd.loopback_route.conf")

def test_staticd_loopback_ipv6_128_route():
run_test("staticd.loopback_ipv6_128_route.conf.j2",
"staticd/staticd.loopback_route.conf.j2",
"staticd/staticd.loopback_ipv6_128_route.conf.json",
"staticd/staticd.loopback_ipv6_128_route.conf")

def test_staticd():
run_test("staticd.conf.j2",
"staticd/staticd.conf.j2",
Expand Down
4 changes: 4 additions & 0 deletions src/sonic-yang-models/doc/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,7 @@ instance is supported in SONiC.
"bgp_asn": "65100",
"deployment_id": "1",
"type": "ToRRouter",
"bgp_adv_lo_prefix_as_128" : "true",
"buffer_model": "traditional"
}
}
Expand Down Expand Up @@ -933,6 +934,9 @@ Loopback interface configuration lies in **LOOPBACK_INTERFACE** table
and has similar schema with data plane interfaces. The loopback device
name and loopback IP prefix act as multi-level key for loopback
interface objects.
By default SONiC advertises Loopback interface IPv6 /128 subnet address
as prefix with /64 subnet. To overcome this set "bgp_adv_lo_prefix_as_128"
to true in DEVICE_METADATA

```
{
Expand Down
3 changes: 2 additions & 1 deletion src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@
"switch_type": "voq",
"max_cores": "8",
"sub_role": "FrontEnd",
"dhcp_server": "disabled"
"dhcp_server": "disabled",
"bgp_adv_lo_prefix_as_128": "true"
}
},
"VLAN": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@
"DEVICE_METADATA_INVALID_DHCP_SERVER": {
"desc": "Verifying invalid dhcp_server configuration.",
"eStrKey": "InvalidValue"
},
"DEVICE_METADATA_ADVERTISE_LO_PREFIX_AS_128": {
"desc": "Verifying advertising lo prefix as /128."
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -311,5 +311,15 @@
}
}
}
},
"DEVICE_METADATA_ADVERTISE_LO_PREFIX_AS_128": {
"sonic-device_metadata:sonic-device_metadata": {
"sonic-device_metadata:DEVICE_METADATA": {
"sonic-device_metadata:localhost": {
"bgp_asn": "65001",
"bgp_adv_lo_prefix_as_128": "true"
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ module sonic-device_metadata {
type stypes:admin_mode;
description "Indicate whether enable the embedded DHCP server.";
}

leaf bgp_adv_lo_prefix_as_128 {
type boolean;
description "Advertise Loopback0 interface IPv6 /128 subnet address as it is with set to true.
By default SONiC advertises /128 subnet prefix in Loopback0 as /64 subnet route";
}
}
/* end of container localhost */
}
Expand Down