[bgpcfgd]: Add on-match next rule for set ipv6 next-hop prefer-global (#6011)

* Add 'on-match next' after every 'set ipv6 next-hop prefer-global'
* Check that 'set ipv6 next-hop prefer-global' rule has 'on-match' next
This commit is contained in:
pavel-shirshov 2020-11-24 08:33:31 -08:00 committed by GitHub
parent 98d749128a
commit fd87ba0aee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 36 additions and 23 deletions

View File

@ -36,6 +36,7 @@ route-map TO_BGP_PEER_V4 permit 100
!
!
route-map FROM_BGP_PEER_V6 permit 1
on-match next
set ipv6 next-hop prefer-global
!
route-map FROM_BGP_PEER_V6 permit 100

View File

@ -9,6 +9,7 @@ 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
!
route-map FROM_BGP_INTERNAL_PEER_V6 permit 100

View File

@ -20,6 +20,7 @@ route-map FROM_BGP_PEER_V4 permit 100
route-map TO_BGP_PEER_V4 permit 100
!
route-map FROM_BGP_PEER_V6 permit 1
on-match next
set ipv6 next-hop prefer-global
!
route-map FROM_BGP_PEER_V6 permit 100

View File

@ -6,6 +6,7 @@ route-map FROM_BGP_PEER_V4 permit 100
route-map TO_BGP_PEER_V4 permit 100
!
route-map FROM_BGP_PEER_V6 permit 1
on-match next
set ipv6 next-hop prefer-global
!
route-map FROM_BGP_PEER_V6 permit 100

View File

@ -20,6 +20,7 @@ route-map FROM_BGP_PEER_V4 permit 100
route-map TO_BGP_PEER_V4 permit 100
!
route-map FROM_BGP_PEER_V6 permit 1
on-match next
set ipv6 next-hop prefer-global
!
route-map FROM_BGP_PEER_V6 permit 100

View File

@ -1,5 +1,5 @@
!
! template: bgpd/templates/general/instance.conf.j2
! template: bgpd/templates/internal/instance.conf.j2
!
neighbor 10.10.10.10 remote-as 555
neighbor 10.10.10.10 description remote_peer
@ -12,5 +12,5 @@
neighbor 10.10.10.10 activate
exit-address-family
!
! end of template: bgpd/templates/general/instance.conf.j2
! end of template: bgpd/templates/internal/instance.conf.j2
!

View File

@ -1,5 +1,5 @@
!
! template: bgpd/templates/general/instance.conf.j2
! template: bgpd/templates/internal/instance.conf.j2
!
neighbor fc::10 remote-as 555
neighbor fc::10 description remote_peer
@ -12,5 +12,5 @@
neighbor fc::10 activate
exit-address-family
!
! end of template: bgpd/templates/general/instance.conf.j2
! end of template: bgpd/templates/internal/instance.conf.j2
!

View File

@ -1,5 +1,5 @@
!
! template: bgpd/templates/general/instance.conf.j2
! template: bgpd/templates/internal/instance.conf.j2
!
neighbor 10.10.10.10 remote-as 555
neighbor 10.10.10.10 description remote_peer
@ -10,5 +10,5 @@
neighbor 10.10.10.10 activate
exit-address-family
!
! end of template: bgpd/templates/general/instance.conf.j2
! end of template: bgpd/templates/internal/instance.conf.j2
!

View File

@ -1,5 +1,5 @@
!
! template: bgpd/templates/general/instance.conf.j2
! template: bgpd/templates/internal/instance.conf.j2
!
neighbor fc::10 remote-as 555
neighbor fc::10 description remote_peer
@ -10,5 +10,5 @@
neighbor fc::10 activate
exit-address-family
!
! end of template: bgpd/templates/general/instance.conf.j2
! end of template: bgpd/templates/internal/instance.conf.j2
!

View File

@ -1,5 +1,5 @@
!
! template: bgpd/templates/general/peer-group.conf.j2
! template: bgpd/templates/internal/peer-group.conf.j2
!
neighbor INTERNAL_PEER_V4 peer-group
neighbor INTERNAL_PEER_V6 peer-group
@ -16,5 +16,5 @@
neighbor INTERNAL_PEER_V6 route-map TO_BGP_INTERNAL_PEER_V6 out
exit-address-family
!
! end of template: bgpd/templates/general/peer-group.conf.j2
! end of template: bgpd/templates/internal/peer-group.conf.j2
!

View File

@ -1,5 +1,5 @@
!
! template: bgpd/templates/general/peer-group.conf.j2
! template: bgpd/templates/internal/peer-group.conf.j2
!
neighbor INTERNAL_PEER_V4 peer-group
neighbor INTERNAL_PEER_V6 peer-group
@ -14,5 +14,5 @@
neighbor INTERNAL_PEER_V6 route-map TO_BGP_INTERNAL_PEER_V6 out
exit-address-family
!
! end of template: bgpd/templates/general/peer-group.conf.j2
! end of template: bgpd/templates/internal/peer-group.conf.j2
!

View File

@ -1,11 +1,12 @@
!
! template: bgpd/templates/general/policies.conf.j2
! template: bgpd/templates/internal/policies.conf.j2
!
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
!
route-map FROM_BGP_INTERNAL_PEER_V6 permit 100
@ -18,5 +19,5 @@ route-map FROM_BGP_INTERNAL_PEER_V4 permit 2
route-map FROM_BGP_INTERNAL_PEER_V6 permit 2
set originator-id 10.10.10.10
!
! end of template: bgpd/templates/general/policies.conf.j2
! end of template: bgpd/templates/internal/policies.conf.j2
!

View File

@ -1,16 +1,17 @@
!
! template: bgpd/templates/general/policies.conf.j2
! template: bgpd/templates/internal/policies.conf.j2
!
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
!
route-map FROM_BGP_INTERNAL_PEER_V6 permit 100
!
route-map TO_BGP_INTERNAL_PEER_V6 permit 100
!
! end of template: bgpd/templates/general/policies.conf.j2
! end of template: bgpd/templates/internal/policies.conf.j2
!

View File

@ -79,6 +79,7 @@ def extract_rm_from_peer_group(path, peer_group_name):
def check_routemap_in_file(filename, route_map_name):
route_map_re = re.compile(r'^route-map\s+%s\s+permit\s+(\d+)' % route_map_name)
set_re = re.compile(r'set ipv6 next-hop prefer-global')
next_re = re.compile(r'on-match next')
with open(filename) as fp:
lines = [line.strip() for line in fp if not line.strip().startswith('!') and line.strip() != '']
found_entry = False
@ -86,9 +87,13 @@ def check_routemap_in_file(filename, route_map_name):
route_map_entries = {}
for line in lines:
if found_entry:
route_map_entries[found_seq_no] = set_re.match(line) is not None
found_entry = False
found_seq_no = None
if set_re.match(line):
route_map_entries[found_seq_no][0] = True
elif next_re.match(line):
route_map_entries[found_seq_no][1] = True
else:
found_entry = False
found_seq_no = None
if route_map_re.match(line):
found_seq_no = None
seq_n_txt = route_map_re.match(line).group(1)
@ -96,11 +101,12 @@ def check_routemap_in_file(filename, route_map_name):
found_seq_no = int(seq_n_txt)
assert found_seq_no not in route_map_entries, "Route-map has duplicate entries: %s - %d" % (route_map_name, found_seq_no)
found_entry = True
route_map_entries[found_seq_no] = [False, False]
results = [route_map_entries[seq] for seq in sorted(route_map_entries.keys())]
if (len(results)):
err_msg = "route-map %s doesn't have mandatory permit entry for 'set ipv6 next-hop prefer-global" % route_map_name
assert results[0], err_msg
return len(results) > 0
err_msg = "route-map %s doesn't have mandatory permit entry for 'set ipv6 next-hop prefer-global" % route_map_name
assert len(results), err_msg
assert all(results[0]), "first ipv6 route-map entry doesn't have set ipv6 nexthop"
return True
def check_routemap(path, route_map_name):
result_files = load_results(path, "policies.conf")