Merge master into int-new

This commit is contained in:
Ondrej Zajicek (work) 2017-04-28 11:19:12 +02:00
commit e919601aaf
5 changed files with 32 additions and 20 deletions

View file

@ -2047,8 +2047,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
@ -2232,6 +2233,14 @@ using the following configuration parameters:
TX direction. When active, all available routes accepted by the export TX direction. When active, all available routes accepted by the export
filter are advertised to the neighbor. Default: off. filter are advertised to the neighbor. Default: off.
<tag><label id="bgp-allow-local-pref">allow bgp_local_pref <m/switch/</tag>
A standard BGP implementation do not send the Local Preference attribute
to eBGP neighbors and ignore this attribute if received from eBGP
neighbors, as per <rfc id="4271">. When this option is enabled on an
eBGP session, this attribute will be sent to and accepted from the peer,
which is useful for example if you have a setup like in <rfc id="7938">.
The option does not affect iBGP sessions. Default: off.
<tag><label id="bgp-allow-local-as">allow local as [<m/number/]</tag> <tag><label id="bgp-allow-local-as">allow local as [<m/number/]</tag>
BGP prevents routing loops by rejecting received routes with the local BGP prevents routing loops by rejecting received routes with the local
AS number in the AS path. This option allows to loose or disable the AS number in the AS path. This option allows to loose or disable the
@ -3991,16 +4000,17 @@ protocol rip [ng] [&lt;name&gt;] {
<p><code> <p><code>
protocol rip { protocol rip {
debug all; import all;
port 1520; export all;
period 12; interface "eth*" {
garbage time 60; metric 2;
interface "eth0" { metric 3; mode multicast; }; port 1520;
interface "eth*" { metric 2; mode broadcast; }; mode multicast;
authentication cryptographic; update time 12;
password "secret-shared-key" { algorithm hmac sha256; }; timeout time 60;
import filter { print "importing"; accept; }; authentication cryptographic;
export filter { print "exporting"; accept; }; password "secret" { algorithm hmac sha256; };
};
} }
</code> </code>

View file

@ -358,14 +358,14 @@ bgp_decode_med(struct bgp_parse_state *s, uint code UNUSED, uint flags, byte *da
static void static void
bgp_export_local_pref(struct bgp_export_state *s, eattr *a) bgp_export_local_pref(struct bgp_export_state *s, eattr *a)
{ {
if (!s->proto->is_interior) if (!s->proto->is_interior && !s->proto->cf->allow_local_pref)
UNSET(a); UNSET(a);
} }
static void static void
bgp_decode_local_pref(struct bgp_parse_state *s, uint code UNUSED, uint flags, byte *data, uint len, ea_list **to) bgp_decode_local_pref(struct bgp_parse_state *s, uint code UNUSED, uint flags, byte *data, uint len, ea_list **to)
{ {
if (!s->proto->is_interior) if (!s->proto->is_interior && !s->proto->cf->allow_local_pref)
DISCARD(BAD_EBGP, "LOCAL_PREF"); DISCARD(BAD_EBGP, "LOCAL_PREF");
if (len != 4) if (len != 4)

View file

@ -979,7 +979,7 @@ bgp_find_proto(sock *sk)
WALK_LIST(p, proto_list) WALK_LIST(p, proto_list)
if ((p->p.proto == &proto_bgp) && if ((p->p.proto == &proto_bgp) &&
ipa_equal(p->cf->remote_ip, sk->daddr) && 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)) &&
(ipa_zero(p->cf->local_ip) || ipa_equal(p->cf->local_ip, sk->saddr)) && (ipa_zero(p->cf->local_ip) || ipa_equal(p->cf->local_ip, sk->saddr)) &&
(p->cf->local_port == sk->sport)) (p->cf->local_port == sk->sport))
return p; return p;
@ -1608,11 +1608,8 @@ bgp_postconfig(struct proto_config *CF)
if (!cf->remote_as) if (!cf->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(cf->remote_ip) && !cf->iface)
// cf_error("Link-local neighbor address requires specified interface"); cf_error("Link-local neighbor address requires specified interface");
if (!ipa_is_link_local(cf->remote_ip) != !cf->iface)
cf_error("Link-local address and interface scope must be used together");
if (!(cf->capabilities && cf->enable_as4) && (cf->remote_as > 0xFFFF)) if (!(cf->capabilities && cf->enable_as4) && (cf->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)");
@ -1630,6 +1627,9 @@ bgp_postconfig(struct proto_config *CF)
ipa_is_link_local(cf->remote_ip))) ipa_is_link_local(cf->remote_ip)))
cf_error("Multihop BGP cannot be used with link-local addresses"); cf_error("Multihop BGP cannot be used with link-local addresses");
if (cf->multihop && cf->iface)
cf_error("Multihop BGP cannot be bound to interface");
if (cf->multihop && cf->check_link) if (cf->multihop && cf->check_link)
cf_error("Multihop BGP cannot depend on link state"); cf_error("Multihop BGP cannot depend on link state");

View file

@ -105,6 +105,7 @@ struct bgp_config {
int passive; /* Do not initiate outgoing connection */ int passive; /* Do not initiate outgoing connection */
int interpret_communities; /* Hardwired handling of well-known communities */ int interpret_communities; /* Hardwired handling of well-known communities */
int allow_local_as; /* Allow that number of local ASNs in incoming AS_PATHs */ int allow_local_as; /* Allow that number of local ASNs in incoming AS_PATHs */
int allow_local_pref; /* Allow LOCAL_PREF in EBGP sessions */
int gr_mode; /* Graceful restart mode (BGP_GR_*) */ int gr_mode; /* Graceful restart mode (BGP_GR_*) */
int setkey; /* Set MD5 password to system SA/SP database */ int setkey; /* Set MD5 password to system SA/SP database */
unsigned gr_time; /* Graceful restart timeout */ unsigned gr_time; /* Graceful restart timeout */

View file

@ -126,6 +126,7 @@ bgp_proto:
| bgp_proto INTERPRET COMMUNITIES bool ';' { BGP_CFG->interpret_communities = $4; } | bgp_proto INTERPRET COMMUNITIES bool ';' { BGP_CFG->interpret_communities = $4; }
| bgp_proto ALLOW LOCAL AS ';' { BGP_CFG->allow_local_as = -1; } | bgp_proto ALLOW LOCAL AS ';' { BGP_CFG->allow_local_as = -1; }
| bgp_proto ALLOW LOCAL AS expr ';' { BGP_CFG->allow_local_as = $5; } | bgp_proto ALLOW LOCAL AS expr ';' { BGP_CFG->allow_local_as = $5; }
| bgp_proto ALLOW BGP_LOCAL_PREF bool ';' { BGP_CFG->allow_local_pref = $4; }
| bgp_proto GRACEFUL RESTART bool ';' { BGP_CFG->gr_mode = $4; } | bgp_proto GRACEFUL RESTART bool ';' { BGP_CFG->gr_mode = $4; }
| bgp_proto GRACEFUL RESTART AWARE ';' { BGP_CFG->gr_mode = BGP_GR_AWARE; } | bgp_proto GRACEFUL RESTART AWARE ';' { BGP_CFG->gr_mode = BGP_GR_AWARE; }
| bgp_proto GRACEFUL RESTART TIME expr ';' { BGP_CFG->gr_time = $5; } | bgp_proto GRACEFUL RESTART TIME expr ';' { BGP_CFG->gr_time = $5; }