0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-11-08 12:18:42 +00:00

BGP: Allow to specify interface for regular sessions

This may be useful if multple interfaces share the same network range.

Thanks to Fritz Grimpen for the original patch.
This commit is contained in:
Ondrej Zajicek (work) 2017-03-14 12:56:47 +01:00
parent 27f6ba651e
commit 33b6c292c3
2 changed files with 9 additions and 8 deletions

View File

@ -1883,8 +1883,9 @@ using the following configuration parameters:
<tag><label id="bgp-iface">interface <m/string/</tag> <tag><label id="bgp-iface">interface <m/string/</tag>
Define interface we should use for link-local BGP IPv6 sessions. Define interface we should use for link-local BGP IPv6 sessions.
Interface can also be specified as a part of <cf/neighbor address/ Interface can also be specified as a part of <cf/neighbor address/
(e.g., <cf/neighbor fe80::1234%eth0 as 65000;/). It is an error to use (e.g., <cf/neighbor fe80::1234%eth0 as 65000;/). The option may also be
this parameter for non link-local sessions. used for non link-local sessions when it is necessary to explicitly
specify an interface, but only for direct (not multihop) sessions.
<tag><label id="bgp-direct">direct</tag> <tag><label id="bgp-direct">direct</tag>
Specify that the neighbor is directly connected. The IP address of the Specify that the neighbor is directly connected. The IP address of the

View File

@ -790,7 +790,7 @@ bgp_find_proto(sock *sk)
{ {
struct bgp_proto *p = (struct bgp_proto *) pc->proto; struct bgp_proto *p = (struct bgp_proto *) pc->proto;
if (ipa_equal(p->cf->remote_ip, sk->daddr) && if (ipa_equal(p->cf->remote_ip, sk->daddr) &&
(!ipa_is_link_local(sk->daddr) || (p->cf->iface == sk->iface))) (!p->cf->iface || (p->cf->iface == sk->iface)))
return p; return p;
} }
@ -1324,11 +1324,8 @@ bgp_check_config(struct bgp_config *c)
if (!c->remote_as) if (!c->remote_as)
cf_error("Remote AS number must be set"); cf_error("Remote AS number must be set");
// if (ipa_is_link_local(c->remote_ip) && !c->iface) if (ipa_is_link_local(c->remote_ip) && !c->iface)
// cf_error("Link-local neighbor address requires specified interface"); cf_error("Link-local neighbor address requires specified interface");
if (!ipa_is_link_local(c->remote_ip) != !c->iface)
cf_error("Link-local address and interface scope must be used together");
if (!(c->capabilities && c->enable_as4) && (c->remote_as > 0xFFFF)) if (!(c->capabilities && c->enable_as4) && (c->remote_as > 0xFFFF))
cf_error("Neighbor AS number out of range (AS4 not available)"); cf_error("Neighbor AS number out of range (AS4 not available)");
@ -1346,6 +1343,9 @@ bgp_check_config(struct bgp_config *c)
ipa_is_link_local(c->source_addr))) ipa_is_link_local(c->source_addr)))
cf_error("Multihop BGP cannot be used with link-local addresses"); cf_error("Multihop BGP cannot be used with link-local addresses");
if (c->multihop && c->iface)
cf_error("Multihop BGP cannot be bound to interface");
if (c->multihop && c->check_link) if (c->multihop && c->check_link)
cf_error("Multihop BGP cannot depend on link state"); cf_error("Multihop BGP cannot depend on link state");