mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 17:51:53 +00:00
LOCAL_PREF is now always present and exported over all ibgp connections [draft]
Allow setting of address of the local end of the TCP connection. Several bug fixes.
This commit is contained in:
parent
2a9e064d7b
commit
8b258e4e65
@ -6,9 +6,6 @@
|
|||||||
* Can be freely distributed and used under the terms of the GNU GPL.
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* FIXME: Latest draft says that LOCAL_PREF is mandatory for iBGP */
|
|
||||||
/* FIXME: Mandatory attributes may be missing in messages that don't contain NLRI */
|
|
||||||
|
|
||||||
#define LOCAL_DEBUG
|
#define LOCAL_DEBUG
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -352,7 +349,7 @@ bgp_get_bucket(struct bgp_proto *p, ea_list *old, ea_list *tmp, int originate)
|
|||||||
new = alloca(ea_scan(tmp));
|
new = alloca(ea_scan(tmp));
|
||||||
ea_merge(tmp, new);
|
ea_merge(tmp, new);
|
||||||
t->next = NULL;
|
t->next = NULL;
|
||||||
ea_sort(tmp);
|
ea_sort(new);
|
||||||
|
|
||||||
/* Normalize attributes */
|
/* Normalize attributes */
|
||||||
d = new->attrs;
|
d = new->attrs;
|
||||||
@ -470,14 +467,14 @@ bgp_rt_notify(struct proto *P, net *n, rte *new, rte *old, ea_list *tmpa)
|
|||||||
static int
|
static int
|
||||||
bgp_create_attrs(struct bgp_proto *p, rte *e, ea_list **attrs, struct linpool *pool)
|
bgp_create_attrs(struct bgp_proto *p, rte *e, ea_list **attrs, struct linpool *pool)
|
||||||
{
|
{
|
||||||
ea_list *ea = lp_alloc(pool, sizeof(ea_list) + 3*sizeof(eattr));
|
ea_list *ea = lp_alloc(pool, sizeof(ea_list) + 4*sizeof(eattr));
|
||||||
eattr *a = ea->attrs;
|
eattr *a = ea->attrs;
|
||||||
rta *rta = e->attrs;
|
rta *rta = e->attrs;
|
||||||
|
|
||||||
ea->next = *attrs;
|
ea->next = *attrs;
|
||||||
*attrs = ea;
|
*attrs = ea;
|
||||||
ea->flags = EALF_SORTED;
|
ea->flags = EALF_SORTED;
|
||||||
ea->count = 3;
|
ea->count = 4;
|
||||||
|
|
||||||
a->id = EA_CODE(EAP_BGP, BA_ORIGIN);
|
a->id = EA_CODE(EAP_BGP, BA_ORIGIN);
|
||||||
a->flags = BAF_TRANSITIVE;
|
a->flags = BAF_TRANSITIVE;
|
||||||
@ -502,7 +499,7 @@ bgp_create_attrs(struct bgp_proto *p, rte *e, ea_list **attrs, struct linpool *p
|
|||||||
a->u.ptr = lp_alloc(pool, sizeof(struct adata) + 4);
|
a->u.ptr = lp_alloc(pool, sizeof(struct adata) + 4);
|
||||||
a->u.ptr->length = 4;
|
a->u.ptr->length = 4;
|
||||||
z = a->u.ptr->data;
|
z = a->u.ptr->data;
|
||||||
z[0] = 2; /* AS_SEQUENCE */
|
z[0] = AS_PATH_SEQUENCE;
|
||||||
z[1] = 1; /* 1 AS */
|
z[1] = 1; /* 1 AS */
|
||||||
put_u16(z+2, p->local_as);
|
put_u16(z+2, p->local_as);
|
||||||
}
|
}
|
||||||
@ -519,6 +516,12 @@ bgp_create_attrs(struct bgp_proto *p, rte *e, ea_list **attrs, struct linpool *p
|
|||||||
*(ip_addr *)a->u.ptr->data = p->local_addr;
|
*(ip_addr *)a->u.ptr->data = p->local_addr;
|
||||||
else
|
else
|
||||||
*(ip_addr *)a->u.ptr->data = e->attrs->gw;
|
*(ip_addr *)a->u.ptr->data = e->attrs->gw;
|
||||||
|
a++;
|
||||||
|
|
||||||
|
a->id = EA_CODE(EAP_BGP, BA_LOCAL_PREF);
|
||||||
|
a->flags = BAF_OPTIONAL;
|
||||||
|
a->type = EAF_TYPE_INT;
|
||||||
|
a->u.data = 0;
|
||||||
|
|
||||||
return 0; /* Leave decision to the filters */
|
return 0; /* Leave decision to the filters */
|
||||||
}
|
}
|
||||||
@ -822,6 +825,20 @@ bgp_decode_attrs(struct bgp_conn *conn, byte *attr, unsigned int len, struct lin
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If there's no local preference, define one */
|
||||||
|
if (!(seen[0] && (1 << BA_LOCAL_PREF)))
|
||||||
|
{
|
||||||
|
ea = lp_alloc(pool, sizeof(ea_list) + sizeof(eattr));
|
||||||
|
ea->next = a->eattrs;
|
||||||
|
a->eattrs = ea;
|
||||||
|
ea->flags = 0;
|
||||||
|
ea->count = 1;
|
||||||
|
ea->attrs[0].id = EA_CODE(EAP_BGP, BA_LOCAL_PREF);
|
||||||
|
ea->attrs[0].flags = BAF_OPTIONAL;
|
||||||
|
ea->attrs[0].type = EAF_TYPE_INT;
|
||||||
|
ea->attrs[0].u.data = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Fill in the remaining rta fields */
|
/* Fill in the remaining rta fields */
|
||||||
e = ea_find(a->eattrs, EA_CODE(EAP_BGP, BA_NEXT_HOP));
|
e = ea_find(a->eattrs, EA_CODE(EAP_BGP, BA_NEXT_HOP));
|
||||||
ASSERT(e);
|
ASSERT(e);
|
||||||
|
@ -210,7 +210,10 @@ bgp_connect(struct bgp_proto *p) /* Enter Connect state and start establishing c
|
|||||||
DBG("BGP: Connecting\n");
|
DBG("BGP: Connecting\n");
|
||||||
s = sk_new(p->p.pool);
|
s = sk_new(p->p.pool);
|
||||||
s->type = SK_TCP_ACTIVE;
|
s->type = SK_TCP_ACTIVE;
|
||||||
s->saddr = p->local_addr;
|
if (ipa_nonzero(p->cf->source_addr))
|
||||||
|
s->saddr = p->cf->source_addr;
|
||||||
|
else
|
||||||
|
s->saddr = p->local_addr;
|
||||||
s->daddr = p->cf->remote_ip;
|
s->daddr = p->cf->remote_ip;
|
||||||
s->dport = BGP_PORT;
|
s->dport = BGP_PORT;
|
||||||
bgp_setup_sk(p, conn, s);
|
bgp_setup_sk(p, conn, s);
|
||||||
|
@ -20,6 +20,7 @@ struct bgp_config {
|
|||||||
ip_addr remote_ip;
|
ip_addr remote_ip;
|
||||||
int multihop; /* Number of hops if multihop */
|
int multihop; /* Number of hops if multihop */
|
||||||
ip_addr multihop_via; /* Multihop: address to route to */
|
ip_addr multihop_via; /* Multihop: address to route to */
|
||||||
|
ip_addr source_addr; /* Source address to use */
|
||||||
int next_hop_self; /* Always set next hop to local IP address */
|
int next_hop_self; /* Always set next hop to local IP address */
|
||||||
int compare_path_lengths; /* Use path lengths when selecting best route */
|
int compare_path_lengths; /* Use path lengths when selecting best route */
|
||||||
u32 default_local_pref; /* Default value for LOCAL_PREF attribute */
|
u32 default_local_pref; /* Default value for LOCAL_PREF attribute */
|
||||||
|
@ -17,7 +17,7 @@ CF_DECLS
|
|||||||
CF_KEYWORDS(BGP, LOCAL, NEIGHBOR, AS, HOLD, TIME, CONNECT, RETRY, KEEPALIVE,
|
CF_KEYWORDS(BGP, LOCAL, NEIGHBOR, AS, HOLD, TIME, CONNECT, RETRY, KEEPALIVE,
|
||||||
MULTIHOP, STARTUP, VIA, NEXT, HOP, SELF, DEFAULT, PATH, METRIC,
|
MULTIHOP, STARTUP, VIA, NEXT, HOP, SELF, DEFAULT, PATH, METRIC,
|
||||||
BGP_PATH, BGP_LOCAL_PREF, BGP_MED, BGP_ORIGIN, BGP_NEXT_HOP,
|
BGP_PATH, BGP_LOCAL_PREF, BGP_MED, BGP_ORIGIN, BGP_NEXT_HOP,
|
||||||
BGP_ATOMIC_AGGR, BGP_AGGREGATOR, BGP_COMMUNITY)
|
BGP_ATOMIC_AGGR, BGP_AGGREGATOR, BGP_COMMUNITY, SOURCE, ADDRESS)
|
||||||
|
|
||||||
CF_GRAMMAR
|
CF_GRAMMAR
|
||||||
|
|
||||||
@ -55,6 +55,7 @@ bgp_proto:
|
|||||||
| bgp_proto PATH METRIC NUM ';' { BGP_CFG->compare_path_lengths = $4; }
|
| bgp_proto PATH METRIC NUM ';' { BGP_CFG->compare_path_lengths = $4; }
|
||||||
| bgp_proto DEFAULT BGP_MED NUM ';' { BGP_CFG->default_med = $4; }
|
| bgp_proto DEFAULT BGP_MED NUM ';' { BGP_CFG->default_med = $4; }
|
||||||
| bgp_proto DEFAULT BGP_LOCAL_PREF NUM ';' { BGP_CFG->default_local_pref = $4; }
|
| bgp_proto DEFAULT BGP_LOCAL_PREF NUM ';' { BGP_CFG->default_local_pref = $4; }
|
||||||
|
| bgp_proto SOURCE ADDRESS IPA ';' { BGP_CFG->source_addr = $4; }
|
||||||
;
|
;
|
||||||
|
|
||||||
CF_ADDTO(dynamic_attr, BGP_PATH
|
CF_ADDTO(dynamic_attr, BGP_PATH
|
||||||
|
Loading…
Reference in New Issue
Block a user