Skip to content

[multi-asic] Changes in FRR templates #6901

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

Merged
merged 1 commit into from
Feb 27, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions dockers/docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ipv6 prefix-list LOCAL_VLAN_IPV6_PREFIX seq {{ loop.index * 5 }} permit {{ prefi
{% if DEVICE_METADATA['localhost']['sub_role'] == 'FrontEnd' or DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
route-map HIDE_INTERNAL permit 10
set community local-AS
{% set multi_asic = True %}
!
{% endif %}
!
Expand All @@ -54,15 +55,15 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
{% endif %}
!
{# set router-id #}
{% if multi_asic() %}
{% if DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
bgp router-id {{ get_ipv4_loopback_address(LOOPBACK_INTERFACE, "Loopback4096") | ip }}
{% else %}
bgp router-id {{ get_ipv4_loopback_address(LOOPBACK_INTERFACE, "Loopback0") | ip }}
{% endif %}
!
{# advertise loopback #}
network {{ get_ipv4_loopback_address(LOOPBACK_INTERFACE, "Loopback0") | ip }}/32
{% if multi_asic() %}
{% if multi_asic is defined %}
network {{ get_ipv4_loopback_address(LOOPBACK_INTERFACE, "Loopback4096") | ip }}/32 route-map HIDE_INTERNAL
{% endif %}
!
Expand All @@ -71,7 +72,7 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
network {{ get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback0") | ip }}/64
exit-address-family
{% endif %}
{% if multi_asic() %}
{% if multi_asic is defined %}
{% if get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback4096") != 'None' %}
address-family ipv6
network {{ get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback4096") | ip }}/64 route-map HIDE_INTERNAL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
neighbor {{ neighbor_addr }} peer-group INTERNAL_PEER_V4
!
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
neighbor {{ neighbor_addr }} next-hop-self force
neighbor {{ neighbor_addr }} route-map FROM_BGP_INTERNAL_PEER_V4 in
{% endif %}
!
Expand All @@ -18,6 +19,7 @@
neighbor {{ neighbor_addr }} peer-group INTERNAL_PEER_V6
!
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
neighbor {{ neighbor_addr }} next-hop-self force
neighbor {{ neighbor_addr }} route-map FROM_BGP_INTERNAL_PEER_V6 in
{% endif %}
{% endif %}
Expand All @@ -26,7 +28,6 @@
neighbor {{ neighbor_addr }} route-reflector-client
{% endif %}
!
neighbor {{ neighbor_addr }} next-hop-self force
!
neighbor {{ neighbor_addr }} activate
exit-address-family
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,27 @@
! template: bgpd/templates/internal/policies.conf.j2
!
!
{% from "common/functions.conf.j2" import get_ipv4_loopback_address %}
!
route-map FROM_BGP_INTERNAL_PEER_V4 permit 100
!
route-map TO_BGP_INTERNAL_PEER_V4 permit 100
!
!
route-map FROM_BGP_INTERNAL_PEER_V6 permit 1
on-match next
set ipv6 next-hop prefer-global
on-match next
!
route-map FROM_BGP_INTERNAL_PEER_V6 permit 100
!
route-map TO_BGP_INTERNAL_PEER_V6 permit 100
!
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
route-map FROM_BGP_INTERNAL_PEER_V4 permit 2
set originator-id {{ loopback0_ipv4 | ip }}
set originator-id {{ get_ipv4_loopback_address(CONFIG_DB__LOOPBACK_INTERFACE, "Loopback4096") | ip }}
!
route-map FROM_BGP_INTERNAL_PEER_V6 permit 2
set originator-id {{ loopback0_ipv4 | ip }}
set originator-id {{ get_ipv4_loopback_address(CONFIG_DB__LOOPBACK_INTERFACE, "Loopback4096") | ip }}
{% endif %}
!
! end of template: bgpd/templates/internal/policies.conf.j2
Expand Down
4 changes: 3 additions & 1 deletion src/sonic-bgpcfgd/bgpcfgd/managers_bgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ def add_peer(self, vrf, nbr, data):
'neighbor_addr': nbr,
'bgp_session': data,
'loopback0_ipv4': lo0_ipv4,
'CONFIG_DB__LOOPBACK_INTERFACE':{ tuple(key.split('|')) : {} for key in self.directory.get_slot("CONFIG_DB", swsscommon.CFG_LOOPBACK_INTERFACE_TABLE_NAME)
if '|' in key }
}
if self.check_neig_meta:
neigmeta = self.directory.get_slot("CONFIG_DB", swsscommon.CFG_DEVICE_NEIGHBOR_METADATA_TABLE_NAME)
Expand Down Expand Up @@ -384,4 +386,4 @@ def load_peers():
log_crit("Can't read vrf '%s' neighbors: %s" % (vrf, str(err)))
raise Exception("Can't read vrf '%s' neighbors: %s" % (vrf, str(err)))

return peers
return peers
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
neighbor 10.10.10.10 timers 3 10
address-family ipv4
neighbor 10.10.10.10 peer-group INTERNAL_PEER_V4
neighbor 10.10.10.10 next-hop-self force
neighbor 10.10.10.10 route-map FROM_BGP_INTERNAL_PEER_V4 in
neighbor 10.10.10.10 route-reflector-client
neighbor 10.10.10.10 next-hop-self force
neighbor 10.10.10.10 activate
exit-address-family
!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
neighbor fc::10 timers 3 10
address-family ipv6
neighbor fc::10 peer-group INTERNAL_PEER_V6
neighbor fc::10 next-hop-self force
neighbor fc::10 route-map FROM_BGP_INTERNAL_PEER_V6 in
neighbor fc::10 route-reflector-client
neighbor fc::10 next-hop-self force
neighbor fc::10 activate
exit-address-family
!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
neighbor 10.10.10.10 timers 3 10
address-family ipv4
neighbor 10.10.10.10 peer-group INTERNAL_PEER_V4
neighbor 10.10.10.10 next-hop-self force
neighbor 10.10.10.10 activate
exit-address-family
!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
neighbor fc::10 timers 3 10
address-family ipv6
neighbor fc::10 peer-group INTERNAL_PEER_V6
neighbor fc::10 next-hop-self force
neighbor fc::10 activate
exit-address-family
!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"sub_role": "BackEnd"
}
},
"loopback0_ipv4": "10.10.10.10/32"
}
"CONFIG_DB__LOOPBACK_INTERFACE": {
"Loopback4096|10.10.10.10/32": {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ route-map FROM_BGP_INTERNAL_PEER_V4 permit 100
route-map TO_BGP_INTERNAL_PEER_V4 permit 100
!
route-map FROM_BGP_INTERNAL_PEER_V6 permit 1
on-match next
set ipv6 next-hop prefer-global
on-match next
!
route-map FROM_BGP_INTERNAL_PEER_V6 permit 100
!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ route-map FROM_BGP_INTERNAL_PEER_V4 permit 100
route-map TO_BGP_INTERNAL_PEER_V4 permit 100
!
route-map FROM_BGP_INTERNAL_PEER_V6 permit 1
on-match next
set ipv6 next-hop prefer-global
on-match next
!
route-map FROM_BGP_INTERNAL_PEER_V6 permit 100
!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@ router bgp 55555
bgp router-id 55.55.55.55
!
network 55.55.55.55/32
network 55.55.55.56/32 route-map HIDE_INTERNAL
!
address-family ipv6
network fc00::1/64
exit-address-family
address-family ipv6
network fc00::2/64 route-map HIDE_INTERNAL
exit-address-family
!
network 10.10.10.1/24
address-family ipv6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
},
"LOOPBACK_INTERFACE": {
"Loopback0|55.55.55.55/32": {},
"Loopback0|fc00::1/128": {}
"Loopback0|fc00::1/128": {},
"Loopback4096|55.55.55.56/32": {},
"Loopback4096|fc00::2/128": {}
},
"VLAN_INTERFACE": {
"Vlan10|10.10.10.1/24": {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ router bgp 55555
bgp router-id 55.55.55.55
!
network 55.55.55.55/32
network 55.55.55.56/32 route-map HIDE_INTERNAL
!
address-family ipv6
network fc00::1/64
exit-address-family
address-family ipv6
network fc00::2/64 route-map HIDE_INTERNAL
exit-address-family
!
network 10.10.10.1/24
address-family ipv6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
},
"LOOPBACK_INTERFACE": {
"Loopback0|55.55.55.55/32": {},
"Loopback0|fc00::1/128": {}
"Loopback0|fc00::1/128": {},
"Loopback4096|55.55.55.56/32": {},
"Loopback4096|fc00::2/128": {}
},
"VLAN_INTERFACE": {
"Vlan10|10.10.10.1/24": {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ router bgp 55555
bgp router-id 55.55.55.55
!
network 55.55.55.55/32
network 55.55.55.56/32 route-map HIDE_INTERNAL
!
address-family ipv6
network fc00::1/64
exit-address-family
address-family ipv6
network fc00::2/64 route-map HIDE_INTERNAL
exit-address-family
!
network 10.10.10.1/24
address-family ipv6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
},
"LOOPBACK_INTERFACE": {
"Loopback0|55.55.55.55/32": {},
"Loopback0|fc00::1/128": {}
"Loopback0|fc00::1/128": {},
"Loopback4096|55.55.55.56/32": {},
"Loopback4096|fc00::2/128": {}
},
"VLAN_INTERFACE": {
"Vlan10|10.10.10.1/24": {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ link-detect
ip route 0.0.0.0/0 10.10.10.1 200
!!
!
!
! add static ipv6 /64 loopback route to allow bgpd to advertise the loopback route prefix
ipv6 route fc00::/64 Loopback0
!
!!
!
! template: bgpd/bgpd.main.conf.j2
!
! bgp multiple-instance
Expand Down Expand Up @@ -75,10 +74,14 @@ router bgp 55555
bgp router-id 55.55.55.55
!
network 55.55.55.55/32
network 55.55.55.56/32 route-map HIDE_INTERNAL
!
address-family ipv6
network fc00::1/64
exit-address-family
address-family ipv6
network fc00::2/64 route-map HIDE_INTERNAL
exit-address-family
!
network 10.10.10.1/24
address-family ipv6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
},
"LOOPBACK_INTERFACE": {
"Loopback0|55.55.55.55/32": {},
"Loopback0|fc00::1/128": {}
"Loopback0|fc00::1/128": {},
"Loopback4096|55.55.55.56/32": {},
"Loopback4096|fc00::2/128": {}
},
"VLAN_INTERFACE": {
"Vlan10|10.10.10.1/24": {},
Expand All @@ -43,4 +45,4 @@
}
}
}
}
}
4 changes: 1 addition & 3 deletions src/sonic-config-engine/sonic-cfggen
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ from functools import partial
from minigraph import minigraph_encoder, parse_xml, parse_device_desc_xml, parse_asic_sub_role
from portconfig import get_port_config, get_breakout_mode
from redis_bcc import RedisBytecodeCache
from sonic_py_common.multi_asic import get_asic_id_from_name, is_multi_asic
from sonic_py_common.multi_asic import get_asic_id_from_name
from sonic_py_common import device_info
from swsscommon.swsscommon import SonicV2Connector, ConfigDBConnector, SonicDBConfig, ConfigDBPipeConnector

Expand Down Expand Up @@ -251,8 +251,6 @@ def _get_jinja2_env(paths):
env.filters['ip_network'] = ip_network
for attr in ['ip', 'network', 'prefixlen', 'netmask', 'broadcast']:
env.filters[attr] = partial(prefix_attr, attr)
# Pass the is_multi_asic function as global
env.globals['multi_asic'] = is_multi_asic

return env

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
!
! template: bgpd/bgpd.conf.j2
!
!
! =========== Managed by sonic-cfggen DO NOT edit manually! ====================
! generated by templates/quagga/bgpd.conf.j2 with config DB data
! file: bgpd.conf
!
!
! template: common/daemons.common.conf.j2
!
hostname multi_npu_platform_01
password zebra
enable password zebra
!
log syslog informational
log facility local4
!
! end of template: common/daemons.common.conf.j2!
agentx
!
!
!
! template: bgpd/bgpd.main.conf.j2
!
! bgp multiple-instance
!
! BGP configuration
!
! TSA configuration
!
ip prefix-list PL_LoopbackV4 permit 10.1.0.32/32
!
ipv6 prefix-list PL_LoopbackV6 permit fc00:1::/64
!
!
route-map HIDE_INTERNAL permit 10
set community local-AS
!
!
router bgp 65100
!
bgp log-neighbor-changes
no bgp default ipv4-unicast
no bgp ebgp-requires-policy
!
bgp bestpath as-path multipath-relax
!
bgp graceful-restart restart-time 240
bgp graceful-restart
bgp graceful-restart preserve-fw-state
!
bgp router-id 8.0.0.5
!
network 10.1.0.32/32
network 8.0.0.5/32 route-map HIDE_INTERNAL
!
address-family ipv6
network fc00:1::32/64
exit-address-family
address-family ipv6
network fd00:4::32/64 route-map HIDE_INTERNAL
exit-address-family
!
!
!
!
address-family ipv4
maximum-paths 64
exit-address-family
address-family ipv6
maximum-paths 64
exit-address-family
!
! end of template: bgpd/bgpd.main.conf.j2
!!
! end of template: bgpd/bgpd.conf.j2
!
Loading