summaryrefslogtreecommitdiff
path: root/proto/bgp
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2017-04-28 11:19:12 +0200
committerOndrej Zajicek (work) <santiago@crfreenet.org>2017-04-28 11:19:12 +0200
commite919601aaf29615edb2a231e58a358c2c5c9d286 (patch)
tree48f97c590500563051d71a165a77567857204293 /proto/bgp
parent5ca4bd5d9018bb7572f10825e1ca431444601be7 (diff)
parent33b6c292c3e3a8972d0b9f43d156aae50db65720 (diff)
Merge master into int-new
Diffstat (limited to 'proto/bgp')
-rw-r--r--proto/bgp/attrs.c4
-rw-r--r--proto/bgp/bgp.c12
-rw-r--r--proto/bgp/bgp.h1
-rw-r--r--proto/bgp/config.Y1
4 files changed, 10 insertions, 8 deletions
diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c
index cf9db1c8..882ba44e 100644
--- a/proto/bgp/attrs.c
+++ b/proto/bgp/attrs.c
@@ -358,14 +358,14 @@ bgp_decode_med(struct bgp_parse_state *s, uint code UNUSED, uint flags, byte *da
static void
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);
}
static void
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");
if (len != 4)
diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c
index 86f7be1b..b9a1d157 100644
--- a/proto/bgp/bgp.c
+++ b/proto/bgp/bgp.c
@@ -979,7 +979,7 @@ bgp_find_proto(sock *sk)
WALK_LIST(p, proto_list)
if ((p->p.proto == &proto_bgp) &&
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)) &&
(p->cf->local_port == sk->sport))
return p;
@@ -1608,11 +1608,8 @@ bgp_postconfig(struct proto_config *CF)
if (!cf->remote_as)
cf_error("Remote AS number must be set");
- // if (ipa_is_link_local(c->remote_ip) && !c->iface)
- // 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 (ipa_is_link_local(cf->remote_ip) && !cf->iface)
+ cf_error("Link-local neighbor address requires specified interface");
if (!(cf->capabilities && cf->enable_as4) && (cf->remote_as > 0xFFFF))
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)))
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)
cf_error("Multihop BGP cannot depend on link state");
diff --git a/proto/bgp/bgp.h b/proto/bgp/bgp.h
index 61d3600d..7ffcb68a 100644
--- a/proto/bgp/bgp.h
+++ b/proto/bgp/bgp.h
@@ -105,6 +105,7 @@ struct bgp_config {
int passive; /* Do not initiate outgoing connection */
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_pref; /* Allow LOCAL_PREF in EBGP sessions */
int gr_mode; /* Graceful restart mode (BGP_GR_*) */
int setkey; /* Set MD5 password to system SA/SP database */
unsigned gr_time; /* Graceful restart timeout */
diff --git a/proto/bgp/config.Y b/proto/bgp/config.Y
index 63e82285..941ae5b6 100644
--- a/proto/bgp/config.Y
+++ b/proto/bgp/config.Y
@@ -126,6 +126,7 @@ bgp_proto:
| 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 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 AWARE ';' { BGP_CFG->gr_mode = BGP_GR_AWARE; }
| bgp_proto GRACEFUL RESTART TIME expr ';' { BGP_CFG->gr_time = $5; }