0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-10-18 09:58:43 +00:00

bgpsec-mbaer: simple after merge fixes

This commit is contained in:
Pavel Tvrdik 2016-06-02 10:28:20 +02:00
parent f857f67485
commit 8e24b2bd92
6 changed files with 20 additions and 7 deletions

View File

@ -30,7 +30,9 @@
#define MAX(a,b) MAX_(a,b)
#endif
#ifndef U64
#define U64(c) UINT64_C(c)
#endif
#define ABS(a) ((a)>=0 ? (a) : -(a))
#define DELTA(a,b) (((a)>=(b))?(a)-(b):(b)-(a))
#define ARRAY_SIZE(a) (sizeof(a)/sizeof(*(a)))

View File

@ -400,7 +400,7 @@ decode_bgpsec_attr(struct bgp_proto *bgp,
p, err, path_id, prefix, pxlen and goto 'done:' */
int err = 0;
u32 path_id = 0;
ip_addr prefix = 0;
ip_addr prefix = IPA_NONE;
int pxlen = 0;
/* Is it long enough to have a minimal valid bgpseg_path_attr */
@ -2433,14 +2433,16 @@ bgp_remove_as4_attrs(struct bgp_proto *p, rta *a)
* @len: length of attribute block
* @pool: linear pool to make all the allocations in
* @mandatory: 1 iff presence of mandatory attributes has to be checked
* @nlri: FIXME
* @nlri_len: FIXME
*
* This function takes a BGP attribute block (a part of an Update message), checks
* its consistency and converts it to a list of BIRD route attributes represented
* by a &rta.
*/
struct rta *
bgp_decode_attrs(struct bgp_conn *conn, byte *attr, uint len, struct linpool *pool, int mandatory,
byte *nlri, int nlri_len)
bgp_decode_attrs(struct bgp_conn *conn, byte *attr, unsigned int len,
struct linpool *pool, int mandatory, byte *nlri, int nlri_len)
{
struct bgp_proto *bgp = conn->bgp;
rta *a = lp_alloc(pool, sizeof(struct rta));
@ -2754,3 +2756,6 @@ bgp_get_route_info(rte *e, byte *buf, ea_list *attrs)
buf += bsprintf(buf, "%c", "ie?"[o->u.data]);
strcpy(buf, "]");
}

View File

@ -1371,7 +1371,7 @@ bgp_check_config(struct bgp_config *c)
#ifdef CONFIG_BGPSEC
/* create a binary SKI from config */
if ( c->enable_bgpsec ) {
if ( strnlen(c->bgpsec_ski, (2 * BGPSEC_SKI_LENGTH))
if ( c->bgpsec_ski == NULL || strnlen(c->bgpsec_ski, (2 * BGPSEC_SKI_LENGTH))
!= (BGPSEC_SKI_LENGTH * 2) ) {
cf_error("BGPSEC: bad length of the configured SKI value");
}

View File

@ -300,7 +300,7 @@ static inline void set_next_hop(byte *b, ip_addr addr) { ((ip_addr *) b)[0] = ad
void bgp_attach_attr(struct ea_list **to, struct linpool *pool, unsigned attr, uintptr_t val);
byte *bgp_attach_attr_wa(struct ea_list **to, struct linpool *pool, unsigned attr, unsigned len);
struct rta *bgp_decode_attrs(struct bgp_conn *conn, byte *a, uint len, struct linpool *pool, int mandatory, byte * nlri, int nlri_len);
struct rta *bgp_decode_attrs(struct bgp_conn *conn, byte *attr, unsigned int len, struct linpool *pool, int mandatory, byte * nlri, int nlri_len);
int bgp_get_attr(struct eattr *e, byte *buf, int buflen);
int bgp_rte_better(struct rte *, struct rte *);
int bgp_rte_mergable(rte *pri, rte *sec);
@ -317,6 +317,11 @@ void bgp_get_route_info(struct rte *, byte *buf, struct ea_list *attrs);
inline static void bgp_attach_attr_ip(struct ea_list **to, struct linpool *pool, unsigned attr, ip_addr a)
{ *(ip_addr *) bgp_attach_attr_wa(to, pool, attr, sizeof(ip_addr)) = a; }
#ifdef CONFIG_BGPSEC
unsigned int encode_bgpsec_attr(struct bgp_conn *conn, ea_list *attr_list, byte *w, int remains, byte *nlri);
#endif
/* packets.c */
void mrt_dump_bgp_state_change(struct bgp_conn *conn, unsigned old, unsigned new);

View File

@ -9,3 +9,4 @@ validate_tmp.o: ../../../../proto/bgp/bgpsec/validate.c
tests: tests.o validate_tmp.o
gcc -o $@ $^ bgpsec.o $(LDFLAGS) $(LIBS)

View File

@ -1370,7 +1370,7 @@ bgp_do_rx_update(struct bgp_conn *conn,
return;
/* Note: bgp_linpool, nlri, nlri_len needed for bgpsec decoding */
a0 = bgp_decode_attrs(conn, attrs, attr_len, bgp_linpool, nlri, nlri_len);
a0 = bgp_decode_attrs(conn, attrs, attr_len, bgp_linpool, nlri_len, nlri, nlri_len); /* XXX */
if (conn->state != BS_ESTABLISHED) /* fatal error during decoding */
return;
@ -1464,7 +1464,7 @@ bgp_do_rx_update(struct bgp_conn *conn,
p->mp_reach_len = 0;
p->mp_unreach_len = 0;
a0 = bgp_decode_attrs(conn, attrs, attr_len, bgp_linpool, nlri, nlri_len);
a0 = bgp_decode_attrs(conn, attrs, attr_len, bgp_linpool, 0, nlri, nlri_len);
if (conn->state != BS_ESTABLISHED) /* fatal error during decoding */
return;