Exa-Networks / exabgp

The BGP swiss army knife of networking
Other
2.1k stars 447 forks source link

Bug to announce flow with redirect in IPv6 #1183

Closed channelsss closed 5 months ago

channelsss commented 1 year ago

Hey,

I have a problem with ExaBGP to send annouce flow with redirect in IPv6. Oct 9 14:56:02 bgp exabgp[336824]: 14:56:02 | 336824 | version | 4.2.8 Oct 9 14:56:02 bgp exabgp[336824]: 14:56:02 | 336824 | interpreter | 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]

In IPv4 : echo "announce flow route { match { source 0.0.0.0/0; destination 10.0.0.1/24; } then { community 65000:660; redirect 10.1.1.122; } }" > /run/exabgp/exabgp.in Oct 9 15:21:50 bgp exabgp[336824]: 15:21:50 | 336824 | configuration | the route family is not configured on neighbor Oct 9 15:21:50 bgp exabgp[336824]: 15:21:50 | 336824 | api | flow added to neighbor x.x.x.1 local-ip x.x.x.152 local-as 65101 peer-as 209097 router-id x.x.x.152 family-allowed in-open, neighbor xxxx:xxxx::1 local-ip xxxx:xxxx:1::152 local-as 65101 peer-as 209097 router-id x.x.x.152 family-allowed in-open : flow destination-ipv4 10.0.0.1/24 source-ipv4 0.0.0.0/0 next-hop 10.10.1.1 community 65000:660 extended-community redirect-to-nexthop and correctly interpreted by Cisco Router.

In IPv6 : echo "announce flow route { match { source 0:0:0:0:0:0:0:0/0; destination fd01:0:0:0:0:0:0:0/128; } then { community 65000:660; redirect xxxx:xxxx::122; } }" >> /run/exabgp/exabgp.in Oct 9 15:22:01 bgp exabgp[336824]: 15:22:01 | 336824 | reactor | async | api-internal-cli-339c4a50 | problem with function Oct 9 15:22:01 bgp exabgp[336824]: 15:22:01 | 336824 | reactor | async | api-internal-cli-339c4a50 | illegal IP address string passed to inet_pton

channelsss commented 1 year ago

I upgraded to 4.2.21 Oct 9 15:33:08 wanguard exabgp[357828]: 15:33:08 | 357828 | api | command could not parse flow in : announce flow route { match { source 0:0:0:0:0:0:0:0/0; destination fd01:0:0:0:0:0:0:0/128; } then { community 65000:660; redirect 2001::1; } } Oct 9 15:33:08 wanguard exabgp[357828]: 15:33:08 | 357828 | api | reason: it looks like you tried to use an IPv6 but did not enclose it in []

Oct 9 15:33:28 wanguard exabgp[357828]: 15:33:28 | 357828 | api | command could not parse flow in : announce flow route { match { source 0:0:0:0:0:0:0:0/0; destination fd01:0:0:0:0:0:0:0/128; } then { community 65000:660; redirect [ 2001::1 ]; } } Oct 9 15:33:28 wanguard exabgp[357828]: 15:33:28 | 357828 | api | reason: can not decode this ip address : [

channelsss commented 1 year ago

I have write a little workaround :

src/exabgp/configuration/flow line 299

Before :

    else:
        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))

After :

    else:
        return IP.create(data), ExtendedCommunities().add(TrafficNextHopSimpson(False))
thomas-mangin commented 1 year ago

Thank you for pointing me to the right place to look.

thomas-mangin commented 1 year ago

I rewrote the parsing as it has issues. Can you please let me know if the new main branch works for you.

thomas-mangin commented 5 months ago

no news is good news. Assuming this is fixed and closing the issue