This patch fixes the nexthop used when transporting IPv4 routes over an IPv6 BGP peering. Previously, the bgp router id was used; with this patch, the lowest IP from the interface is used. Patch by David Lamparter , 2007-02-23 --- quagga/bgpd/bgp_zebra.c.orig 2006-11-30 17:36:57.000000000 +0100 +++ quagga/bgpd/bgp_zebra.c 2007-02-23 04:01:51.456015851 +0100 @@ -432,6 +432,28 @@ return NULL; } +static int +if_get_ipv4 (struct interface *ifp, struct in_addr *addr) +{ + struct listnode *cnode; + struct connected *connected; + struct prefix *cp; + int hit = 0; + + for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected)) + { + cp = connected->address; + + if (cp->family == AF_INET) + if (!hit || ntohl(cp->u.prefix4.s_addr) < ntohl(addr->s_addr)) + { + memcpy (addr, &cp->u.prefix4, IPV4_MAX_BYTELEN); + hit = 1; + } + } + return hit; +} + #ifdef HAVE_IPV6 struct interface * if_lookup_by_ipv6 (struct in6_addr *addr) @@ -586,7 +608,8 @@ struct interface *direct = NULL; /* IPv4 nexthop. I don't care about it. */ - if (peer->local_id.s_addr) + ret = if_get_ipv4 (ifp, &nexthop->v4); + if (!ret && peer->local_id.s_addr) nexthop->v4 = peer->local_id; /* Global address*/