diff options
author | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2017-12-08 02:26:17 +0100 |
---|---|---|
committer | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2017-12-08 02:26:17 +0100 |
commit | ccee67ca3b607130bf441b6060b88525b5e50ad9 (patch) | |
tree | 4ff576e235abe01e19e7d709ab635d984541680c /proto/bgp | |
parent | 830ba75e6dd369c3e64d122f0537cc85211e56e6 (diff) |
BGP: Autoconfigure BGP next hops from preferred addresses
Diffstat (limited to 'proto/bgp')
-rw-r--r-- | proto/bgp/bgp.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c index 30fe75ba..a26c0cb9 100644 --- a/proto/bgp/bgp.c +++ b/proto/bgp/bgp.c @@ -1504,6 +1504,20 @@ bgp_channel_start(struct channel *C) c->next_hop_addr = src; } + /* Use preferred addresses associated with interface / source address */ + if (ipa_zero(c->next_hop_addr)) + { + /* We know the iface for single-hop, we make lookup for multihop */ + struct neighbor *nbr = p->neigh ?: neigh_find2(&p->p, &src, NULL, 0); + struct iface *iface = nbr ? nbr->iface : NULL; + + if (bgp_channel_is_ipv4(c) && iface && iface->addr4) + c->next_hop_addr = iface->addr4->ip; + + if (bgp_channel_is_ipv6(c) && iface && iface->addr6) + c->next_hop_addr = iface->addr6->ip; + } + /* Exit if no feasible next hop address is found */ if (ipa_zero(c->next_hop_addr)) { @@ -2079,6 +2093,11 @@ bgp_show_proto_info(struct proto *P) { channel_show_info(&c->c); + if (ipa_zero(c->link_addr)) + cli_msg(-1006, " BGP Next hop: %I", c->next_hop_addr); + else + cli_msg(-1006, " BGP Next hop: %I %I", c->next_hop_addr, c->link_addr); + if (c->igp_table_ip4) cli_msg(-1006, " IGP IPv4 table: %s", c->igp_table_ip4->name); |