From ec3b71ae00bfab2fcaa31425a4f9de097389f43a Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 8 Dec 2011 09:00:13 +0100 Subject: BGP: Add support for specifying interface names to allow peerings using link-local addresses --- proto/bgp/bgp.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'proto/bgp/bgp.c') diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c index 28396a5..67594c7 100644 --- a/proto/bgp/bgp.c +++ b/proto/bgp/bgp.c @@ -585,6 +585,11 @@ bgp_connect(struct bgp_proto *p) /* Enter Connect state and start establishing c s->tos = IP_PREC_INTERNET_CONTROL; s->password = p->cf->password; s->tx_hook = bgp_connected; + + /* Can only be NULL for multihop instances */ + if (p->neigh && *p->cf->interface) + s->iface = p->neigh->iface; + BGP_TRACE(D_EVENTS, "Connecting to %I from local address %I", s->daddr, s->saddr); bgp_setup_conn(p, conn); bgp_setup_sk(conn, s); @@ -793,7 +798,7 @@ bgp_start_locked(struct object_lock *lock) return; } - p->neigh = neigh_find(&p->p, &cf->remote_ip, NEF_STICKY); + p->neigh = neigh_find_ifname(&p->p, &cf->remote_ip, (*cf->interface) ? cf->interface : NULL, NEF_STICKY); if (!p->neigh || (p->neigh->scope == SCOPE_HOST)) { log(L_ERR "%s: Invalid remote address %I", p->p.name, cf->remote_ip); @@ -807,7 +812,7 @@ bgp_start_locked(struct object_lock *lock) if (p->neigh->iface) bgp_start_neighbor(p); else - BGP_TRACE(D_EVENTS, "Waiting for %I to become my neighbor", cf->remote_ip); + BGP_TRACE(D_EVENTS, "Waiting for %I to become my neighbor%s%s", cf->remote_ip, (*cf->interface) ? " on " : "", cf->interface); } static int @@ -852,6 +857,7 @@ bgp_start(struct proto *P) lock->iface = NULL; lock->hook = bgp_start_locked; lock->data = p; + olock_acquire(lock); return PS_START; -- cgit v1.2.3