Skip to content

Commit

Permalink
backport #1004
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-mangin committed Mar 20, 2021
1 parent a592718 commit 5bbba84
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Version explained:
Version 4.2.14
* Fix: issue reading data from the peer
reported by: isjerryxiao
* Feature: allow IPv6 redirect
patch by: rzalamena

Version 4.2.13
* Fix: issue when there is no route to the peer and the connection looked like it established with the API
Expand Down
20 changes: 16 additions & 4 deletions lib/exabgp/configuration/flow/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,22 @@ def redirect(tokeniser):
raise ValueError('route target is a 32 bits number, value too large %s' % route_target)
return NoNextHop, ExtendedCommunities().add(TrafficRedirect(asn, route_target))
else:
elements = data.split(':')
ip = ':'.join(elements[:-1])
asn = int(elements[-1])
return IP.create(ip), ExtendedCommunities().add(TrafficRedirectIPv6(ip, asn))
explicit_v6 = ']:' in data

# ipv4
if not explicit_v6 and data.count(':') == 1:
return IP.create(data), ExtendedCommunities().add(TrafficNextHopSimpson(False))

# ipv6 using []: notation
if explicit_v6:
ip, asn = data.split(']:')
ip = ip.replace('[', '', 1)
# FIXME: should this be 2^16 ??
if asn >= pow(2, 32):
raise ValueError('asn is a 32 bits number, value too large %s' % asn)
return IP.create(ip), ExtendedCommunities().add(TrafficRedirectIPv6(ip, asn))

raise ValueError('it looks like you tried to use an IPv6 but did not enclose it in []')


def redirect_next_hop(tokeniser):
Expand Down

0 comments on commit 5bbba84

Please sign in to comment.