[quagga-dev 8893] Re: [PATCH 2/3] bgpd: bug #537: find proper source address for interface update-source

David Lamparter equinox at diac24.net
Thu Oct 6 15:21:32 BST 2011


On Wed, Aug 31, 2011 at 05:25:42PM +0200, David Lamparter wrote:
> if update-source was given as interface name, bgpd was unconditionally
> trying to bind to an IPv4 address from that interface.
> 
> change function to find the best-matching (number of address bits)
> same-family address on the interface.

Since this came up on IRC, I'll explain my use case for this particular
patch. I have "unnumbered" pointopoint links set up as:

(interface lo)
  ip address 127.0.0.1/8
  ip address 203.0.113.45/32
  ipv6 address ::1/128
  ipv6 address 2001:db8::cafe:babe/32
(interface pppX)
  ip address 169.254.123.45 peer 169.254.45.123/32 scope link
  ipv6 address fe80::dead:beef/64

(router bgp ...)
  neighbor fe80::ace:fade remote-as ...
  neighbor fe80::ace:fade interface pppX
  address-family ipv4
    neighbor fe80::ace:fade activate
  address-family ipv6
    neighbor fe80::ace:fade activate

So, one peering - over IPv6 - carries both IPv4 and IPv6 routes. It is
essential in this case that the IPv4 nexthop is properly filled in,
since the two peers only use the 169.254. IPv4 address for routing
purposes. In this setup, _all_ public IP addresses can change without
affecting the peer at all (!).

Without this patch, bgpd uses the router id as nexthop which will not
work. With the patch, it searches for addresses on the interface.

>    for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, connected))
>      {
> -      p = (struct prefix_ipv4 *) connected->address;
> -
> -      if (p->family == AF_INET)
> -	return &p->prefix;
> +      p = connected->address;
> +      if (p->family != d->family)
> +	continue;
> +      if (prefix_common_bits (p, d) > common)
> +	{
> +	  sel = p;
> +	  common = prefix_common_bits (sel, d);
> +	}
[...]
> -      addr = bgp_update_address (ifp);
> -      if (! addr)
> +      if (bgp_update_address (ifp, &peer->su, &addr))
>  	return;
>  
> -      bgp_bind_address (peer->fd, addr);
> +      sockunion_bind (peer->fd, &addr, 0, &addr);
>      }
>  

-equinox




More information about the Quagga-dev mailing list