Commit 5e8df049 authored by Ondřej Zajíček's avatar Ondřej Zajíček

Babel: Update to integrated branch

parent 2119ae74
......@@ -185,8 +185,7 @@ fi
AC_SUBST(iproutedir)
# all_protocols="$proto_bfd babel bgp ospf pipe radv rip $proto_rpki static"
all_protocols="$proto_bfd bgp ospf pipe radv rip $proto_rpki static "
all_protocols="$proto_bfd babel bgp ospf pipe radv rip $proto_rpki static"
all_protocols=`echo $all_protocols | sed 's/ /,/g'`
......
This diff is collapsed.
......@@ -52,7 +52,7 @@
/* Max interval that will not overflow when carried as 16-bit centiseconds */
#define BABEL_MAX_INTERVAL (0xFFFF/BABEL_TIME_UNITS)
#define BABEL_OVERHEAD (SIZE_OF_IP_HEADER+UDP_HEADER_LENGTH)
#define BABEL_OVERHEAD (IP6_HEADER_LENGTH+UDP_HEADER_LENGTH)
#define BABEL_MIN_MTU (512 + BABEL_OVERHEAD)
......@@ -208,7 +208,6 @@ struct babel_route {
};
struct babel_entry {
struct fib_node n;
struct babel_proto *proto;
struct babel_route *selected_in;
struct babel_route *selected_out;
......@@ -217,13 +216,14 @@ struct babel_entry {
list sources; /* Source entries for this prefix (struct babel_source). */
list routes; /* Routes for this prefix (struct babel_route) */
struct fib_node n;
};
/* Stores forwarded seqno requests for duplicate suppression. */
struct babel_seqno_request {
node n;
ip_addr prefix;
u8 plen;
net_addr net;
u64 router_id;
u16 seqno;
bird_clock_t updated;
......@@ -265,12 +265,11 @@ struct babel_msg_ihu {
struct babel_msg_update {
u8 type;
u8 wildcard;
u8 plen;
u16 interval;
u16 seqno;
u16 metric;
ip_addr prefix;
u64 router_id;
net_addr net;
ip_addr next_hop;
ip_addr sender;
};
......@@ -278,17 +277,15 @@ struct babel_msg_update {
struct babel_msg_route_request {
u8 type;
u8 full;
u8 plen;
ip_addr prefix;
net_addr net;
};
struct babel_msg_seqno_request {
u8 type;
u8 plen;
u16 seqno;
u8 hop_count;
u16 seqno;
u64 router_id;
ip_addr prefix;
net_addr net;
ip_addr sender;
};
......
......@@ -30,11 +30,13 @@ CF_ADDTO(proto, babel_proto)
babel_proto_start: proto_start BABEL
{
this_proto = proto_config_new(&proto_babel, $1);
this_proto->net_type = NET_IP6;
init_list(&BABEL_CFG->iface_list);
};
babel_proto_item:
proto_item
| proto_channel
| INTERFACE babel_iface
;
......
......@@ -146,7 +146,8 @@ struct babel_write_state {
#define TLV_HDR(tlv,t,l) ({ tlv->type = t; tlv->length = l - sizeof(struct babel_tlv); })
#define TLV_HDR0(tlv,t) TLV_HDR(tlv, t, tlv_data[t].min_length)
#define BYTES(n) ((((uint) n) + 7) / 8)
#define NET_SIZE(n) BYTES(net_pxlen(n))
static inline u16
get_time16(const void *p)
......@@ -161,19 +162,19 @@ put_time16(void *p, u16 v)
put_u16(p, v * BABEL_TIME_UNITS);
}
static inline ip6_addr
get_ip6_px(const void *p, uint plen)
static inline void
read_ip6_px(net_addr *n, const void *p, uint plen)
{
ip6_addr addr = IPA_NONE;
memcpy(&addr, p, BYTES(plen));
return ip6_ntoh(addr);
net_fill_ip6(n, ip6_ntoh(addr), plen);
}
static inline void
put_ip6_px(void *p, ip6_addr addr, uint plen)
put_ip6_px(void *p, net_addr *n)
{
addr = ip6_hton(addr);
memcpy(p, &addr, BYTES(plen));
ip6_addr addr = ip6_hton(net6_prefix(n));
memcpy(p, &addr, NET_SIZE(n));
}
static inline ip6_addr
......@@ -480,6 +481,9 @@ babel_read_update(struct babel_tlv *hdr, union babel_msg *m,
if (tlv->plen > 0)
return PARSE_ERROR;
if (msg->metric != 65535)
return PARSE_ERROR;
msg->wildcard = 1;
break;
......@@ -488,7 +492,7 @@ babel_read_update(struct babel_tlv *hdr, union babel_msg *m,
return PARSE_IGNORE;
case BABEL_AE_IP6:
if (tlv->plen > MAX_PREFIX_LENGTH)
if (tlv->plen > IP6_MAX_PREFIX_LENGTH)
return PARSE_ERROR;
/* Cannot omit data if there is no saved prefix */
......@@ -499,18 +503,18 @@ babel_read_update(struct babel_tlv *hdr, union babel_msg *m,
memcpy(buf, state->def_ip6_prefix, tlv->omitted);
memcpy(buf + tlv->omitted, tlv->addr, len);
msg->plen = tlv->plen;
msg->prefix = ipa_from_ip6(get_ip6(buf));
ip6_addr prefix = get_ip6(buf);
net_fill_ip6(&msg->net, prefix, tlv->plen);
if (tlv->flags & BABEL_FLAG_DEF_PREFIX)
{
put_ip6(state->def_ip6_prefix, msg->prefix);
put_ip6(state->def_ip6_prefix, prefix);
state->def_ip6_prefix_seen = 1;
}
if (tlv->flags & BABEL_FLAG_ROUTER_ID)
{
state->router_id = ((u64) _I2(msg->prefix)) << 32 | _I3(msg->prefix);
state->router_id = ((u64) _I2(prefix)) << 32 | _I3(prefix);
state->router_id_seen = 1;
}
break;
......@@ -559,7 +563,7 @@ babel_write_update(struct babel_tlv *hdr, union babel_msg *m,
tlv = (struct babel_tlv_update *) NEXT_TLV(tlv);
}
uint len = sizeof(struct babel_tlv_update) + BYTES(msg->plen);
uint len = sizeof(struct babel_tlv_update) + NET_SIZE(&msg->net);
if (len0 + len > max_len)
return 0;
......@@ -575,8 +579,8 @@ babel_write_update(struct babel_tlv *hdr, union babel_msg *m,
else
{
tlv->ae = BABEL_AE_IP6;
tlv->plen = msg->plen;
put_ip6_px(tlv->addr, msg->prefix, msg->plen);
tlv->plen = net6_pxlen(&msg->net);
put_ip6_px(tlv->addr, &msg->net);
}
put_time16(&tlv->interval, msg->interval);
......@@ -610,14 +614,13 @@ babel_read_route_request(struct babel_tlv *hdr, union babel_msg *m,
return PARSE_IGNORE;
case BABEL_AE_IP6:
if (tlv->plen > MAX_PREFIX_LENGTH)
if (tlv->plen > IP6_MAX_PREFIX_LENGTH)
return PARSE_ERROR;
if (TLV_OPT_LENGTH(tlv) < BYTES(tlv->plen))
return PARSE_ERROR;
msg->plen = tlv->plen;
msg->prefix = get_ip6_px(tlv->addr, tlv->plen);
read_ip6_px(&msg->net, tlv->addr, tlv->plen);
return PARSE_SUCCESS;
case BABEL_AE_IP6_LL:
......@@ -637,7 +640,7 @@ babel_write_route_request(struct babel_tlv *hdr, union babel_msg *m,
struct babel_tlv_route_request *tlv = (void *) hdr;
struct babel_msg_route_request *msg = &m->route_request;
uint len = sizeof(struct babel_tlv_route_request) + BYTES(msg->plen);
uint len = sizeof(struct babel_tlv_route_request) + NET_SIZE(&msg->net);
if (len > max_len)
return 0;
......@@ -652,8 +655,8 @@ babel_write_route_request(struct babel_tlv *hdr, union babel_msg *m,
else
{
tlv->ae = BABEL_AE_IP6;
tlv->plen = msg->plen;
put_ip6_px(tlv->addr, msg->prefix, msg->plen);
tlv->plen = net6_pxlen(&msg->net);
put_ip6_px(tlv->addr, &msg->net);
}
return len;
......@@ -685,14 +688,13 @@ babel_read_seqno_request(struct babel_tlv *hdr, union babel_msg *m,
return PARSE_IGNORE;
case BABEL_AE_IP6:
if (tlv->plen > MAX_PREFIX_LENGTH)
if (tlv->plen > IP6_MAX_PREFIX_LENGTH)
return PARSE_ERROR;
if (TLV_OPT_LENGTH(tlv) < BYTES(tlv->plen))
return PARSE_ERROR;
msg->plen = tlv->plen;
msg->prefix = get_ip6_px(tlv->addr, tlv->plen);
read_ip6_px(&msg->net, tlv->addr, tlv->plen);
return PARSE_SUCCESS;
case BABEL_AE_IP6_LL:
......@@ -712,18 +714,18 @@ babel_write_seqno_request(struct babel_tlv *hdr, union babel_msg *m,
struct babel_tlv_seqno_request *tlv = (void *) hdr;
struct babel_msg_seqno_request *msg = &m->seqno_request;
uint len = sizeof(struct babel_tlv_seqno_request) + BYTES(msg->plen);
uint len = sizeof(struct babel_tlv_seqno_request) + NET_SIZE(&msg->net);
if (len > max_len)
return 0;
TLV_HDR(tlv, BABEL_TLV_SEQNO_REQUEST, len);
tlv->ae = BABEL_AE_IP6;
tlv->plen = msg->plen;
tlv->plen = net6_pxlen(&msg->net);
put_u16(&tlv->seqno, msg->seqno);
tlv->hop_count = msg->hop_count;
put_u64(&tlv->router_id, msg->router_id);
put_ip6_px(tlv->addr, msg->prefix, msg->plen);
put_ip6_px(tlv->addr, &msg->net);
return len;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment