mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2025-01-03 07:31:54 +00:00
Fixed various build problems on FreeBSD and/or CLang
This commit is contained in:
parent
1127f19a7a
commit
343628d8c0
@ -338,7 +338,6 @@ CF_KEYWORDS(FUNCTION, PRINT, PRINTN, UNSET, RETURN,
|
|||||||
%type <xp> cmds_int cmd_prep
|
%type <xp> cmds_int cmd_prep
|
||||||
%type <x> term cmd cmd_var cmds cmds_scoped constant constructor print_list var var_init var_list function_call symbol_value bgp_path_expr bgp_path bgp_path_tail
|
%type <x> term cmd cmd_var cmds cmds_scoped constant constructor print_list var var_init var_list function_call symbol_value bgp_path_expr bgp_path bgp_path_tail
|
||||||
%type <fsa> static_attr
|
%type <fsa> static_attr
|
||||||
%type <fab> attr_bit
|
|
||||||
%type <f> filter where_filter
|
%type <f> filter where_filter
|
||||||
%type <fl> filter_body function_body
|
%type <fl> filter_body function_body
|
||||||
%type <flv> lvalue
|
%type <flv> lvalue
|
||||||
@ -846,10 +845,6 @@ term:
|
|||||||
| constructor { $$ = $1; }
|
| constructor { $$ = $1; }
|
||||||
|
|
||||||
| static_attr { $$ = f_new_inst(FI_RTA_GET, $1); }
|
| static_attr { $$ = f_new_inst(FI_RTA_GET, $1); }
|
||||||
| attr_bit {
|
|
||||||
struct f_inst *c = f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_INT, .val.i = (1U << $1.bit)});
|
|
||||||
$$ = f_new_inst(FI_EQ, c, f_new_inst(FI_BITAND, f_new_inst(FI_EA_GET, $1.class), c));
|
|
||||||
}
|
|
||||||
|
|
||||||
| term '.' IS_V4 { $$ = f_new_inst(FI_IS_V4, $1); }
|
| term '.' IS_V4 { $$ = f_new_inst(FI_IS_V4, $1); }
|
||||||
| term '.' TYPE { $$ = f_new_inst(FI_TYPE, $1); }
|
| term '.' TYPE { $$ = f_new_inst(FI_TYPE, $1); }
|
||||||
@ -979,14 +974,6 @@ cmd:
|
|||||||
cf_error("Attribute %s is read-only", $3->attribute->name);
|
cf_error("Attribute %s is read-only", $3->attribute->name);
|
||||||
$$ = f_new_inst(FI_EA_UNSET, $3->attribute);
|
$$ = f_new_inst(FI_EA_UNSET, $3->attribute);
|
||||||
}
|
}
|
||||||
| attr_bit '=' term ';' {
|
|
||||||
$$ = f_new_inst(FI_CONDITION, $3,
|
|
||||||
f_generate_complex_default(FI_BITOR, $1.class,
|
|
||||||
f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_INT, .val.i = (1U << $1.bit)}), 0),
|
|
||||||
f_generate_complex_default(FI_BITAND, $1.class,
|
|
||||||
f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_INT, .val.i = ~(1U << $1.bit)}), 0)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
| break_command print_list ';' {
|
| break_command print_list ';' {
|
||||||
struct f_inst *breaker = f_new_inst(FI_DIE, $1);
|
struct f_inst *breaker = f_new_inst(FI_DIE, $1);
|
||||||
if ($2) {
|
if ($2) {
|
||||||
|
@ -9,13 +9,22 @@
|
|||||||
#ifndef _BIRD_BIRDLIB_H_
|
#ifndef _BIRD_BIRDLIB_H_
|
||||||
#define _BIRD_BIRDLIB_H_
|
#define _BIRD_BIRDLIB_H_
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#include "sysdep/config.h"
|
#include "sysdep/config.h"
|
||||||
#include "lib/alloca.h"
|
#include "lib/alloca.h"
|
||||||
|
|
||||||
/* Ugly structure offset handling macros */
|
/* Ugly structure offset handling macros */
|
||||||
|
|
||||||
#define SAME_TYPE(a, b) ({ int _ = ((a) != (b)); !_; })
|
#define SAME_TYPE(a, b) ({ int _ = ((a) != (b)); !_; })
|
||||||
|
#define TYPE_CAST(from, to, what) ( SAME_TYPE(((from) NULL), (what)), ((to) (what)))
|
||||||
|
|
||||||
|
#ifdef offsetof
|
||||||
|
#define OFFSETOF offsetof
|
||||||
|
#else
|
||||||
#define OFFSETOF(s, i) ((size_t) &((s *)0)->i)
|
#define OFFSETOF(s, i) ((size_t) &((s *)0)->i)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define SKIP_BACK(s, i, p) ({ s *_ptr = ((s *)((char *)p - OFFSETOF(s, i))); SAME_TYPE(&_ptr->i, p); _ptr; })
|
#define SKIP_BACK(s, i, p) ({ s *_ptr = ((s *)((char *)p - OFFSETOF(s, i))); SAME_TYPE(&_ptr->i, p); _ptr; })
|
||||||
#define BIRD_ALIGN(s, a) (((s)+a-1)&~(a-1))
|
#define BIRD_ALIGN(s, a) (((s)+a-1)&~(a-1))
|
||||||
#define CPU_STRUCT_ALIGN (MAX_(_Alignof(void*), _Alignof(u64)))
|
#define CPU_STRUCT_ALIGN (MAX_(_Alignof(void*), _Alignof(u64)))
|
||||||
|
@ -32,7 +32,7 @@ struct settle {
|
|||||||
|
|
||||||
STATIC_ASSERT(OFFSETOF(struct settle, hook) == OFFSETOF(struct settle, tm) + OFFSETOF(timer, hook));
|
STATIC_ASSERT(OFFSETOF(struct settle, hook) == OFFSETOF(struct settle, tm) + OFFSETOF(timer, hook));
|
||||||
|
|
||||||
#define SETTLE_INIT(_cfp, _hook, _data) (struct settle) { .tm = { .data = (_data), }, .hook = (_hook), .cf = ({ASSERT_DIE((_cfp)->min <= (_cfp)->max); *(_cfp); }), }
|
#define SETTLE_INIT(_cfp, _hook, _data) (struct settle) { .tm = { .data = (_data), .hook = TYPE_CAST(void (*)(struct settle *), void (*)(struct timer *), (_hook)), }, .cf = ({ASSERT_DIE((_cfp)->min <= (_cfp)->max); *(_cfp); }), }
|
||||||
|
|
||||||
|
|
||||||
static inline void settle_init(struct settle *s, struct settle_config *cf, void (*hook)(struct settle *), void *data)
|
static inline void settle_init(struct settle *s, struct settle_config *cf, void (*hook)(struct settle *), void *data)
|
||||||
|
@ -3352,8 +3352,8 @@ ea_set_hostentry(ea_list **to, rtable *dep, rtable *src, ip_addr gw, ip_addr ll,
|
|||||||
struct {
|
struct {
|
||||||
struct adata ad;
|
struct adata ad;
|
||||||
struct hostentry *he;
|
struct hostentry *he;
|
||||||
u32 labels[lnum];
|
u32 labels[0];
|
||||||
} *head = (void *) tmp_alloc_adata(sizeof *head - sizeof(struct adata));
|
} *head = (void *) tmp_alloc_adata(sizeof *head + sizeof(u32) * lnum - sizeof(struct adata));
|
||||||
|
|
||||||
RT_LOCKED(src, tab)
|
RT_LOCKED(src, tab)
|
||||||
head->he = rt_get_hostentry(tab, gw, ll, dep);
|
head->he = rt_get_hostentry(tab, gw, ll, dep);
|
||||||
|
@ -148,15 +148,18 @@ static struct krt_proto *krt_table_map[KRT_MAX_TABLES][2];
|
|||||||
int
|
int
|
||||||
krt_capable(rte *e)
|
krt_capable(rte *e)
|
||||||
{
|
{
|
||||||
rta *a = e->attrs;
|
ea_list *eattrs = e->attrs;
|
||||||
|
eattr *nhea = ea_find(eattrs, &ea_gen_nexthop);
|
||||||
|
struct nexthop_adata *nh = nhea ? (struct nexthop_adata *) nhea->u.ptr : NULL;
|
||||||
|
int dest = nhea_dest(nhea);
|
||||||
|
|
||||||
return
|
return
|
||||||
((a->dest == RTD_UNICAST && !a->nh.next) /* No multipath support */
|
((dest == RTD_UNICAST && !NEXTHOP_ONE(nh)) /* No multipath support */
|
||||||
#ifdef RTF_REJECT
|
#ifdef RTF_REJECT
|
||||||
|| a->dest == RTD_UNREACHABLE
|
|| dest == RTD_UNREACHABLE
|
||||||
#endif
|
#endif
|
||||||
#ifdef RTF_BLACKHOLE
|
#ifdef RTF_BLACKHOLE
|
||||||
|| a->dest == RTD_BLACKHOLE
|
|| dest == RTD_BLACKHOLE
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -197,18 +200,22 @@ sockaddr_fill_dl(struct sockaddr_dl *sa, struct iface *ifa)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
krt_send_route(struct krt_proto *p, int cmd, rte *e)
|
krt_send_route(struct krt_proto *p, int cmd, const rte *e)
|
||||||
{
|
{
|
||||||
net *net = e->net;
|
const net_addr *net = e->net;
|
||||||
rta *a = e->attrs;
|
ea_list *eattrs = e->attrs;
|
||||||
|
eattr *nhea = ea_find(eattrs, &ea_gen_nexthop);
|
||||||
|
struct nexthop_adata *nh = nhea ? (struct nexthop_adata *) nhea->u.ptr : NULL;
|
||||||
|
int dest = nhea_dest(nhea);
|
||||||
|
|
||||||
static int msg_seq;
|
static int msg_seq;
|
||||||
struct iface *j, *i = a->nh.iface;
|
struct iface *j, *i = (dest == RTD_UNICAST) ? nh->nh.iface : NULL;
|
||||||
int l;
|
int l;
|
||||||
struct ks_msg msg;
|
struct ks_msg msg;
|
||||||
char *body = (char *)msg.buf;
|
char *body = (char *)msg.buf;
|
||||||
sockaddr gate, mask, dst;
|
sockaddr gate, mask, dst;
|
||||||
|
|
||||||
DBG("krt-sock: send %I/%d via %I\n", net->n.prefix, net->n.pxlen, a->gw);
|
DBG("krt-sock: send %N via %I\n", net, nh->nh.gw);
|
||||||
|
|
||||||
bzero(&msg,sizeof (struct rt_msghdr));
|
bzero(&msg,sizeof (struct rt_msghdr));
|
||||||
msg.rtm.rtm_version = RTM_VERSION;
|
msg.rtm.rtm_version = RTM_VERSION;
|
||||||
@ -218,7 +225,7 @@ krt_send_route(struct krt_proto *p, int cmd, rte *e)
|
|||||||
msg.rtm.rtm_flags = RTF_UP | RTF_PROTO1;
|
msg.rtm.rtm_flags = RTF_UP | RTF_PROTO1;
|
||||||
|
|
||||||
/* XXXX */
|
/* XXXX */
|
||||||
if (net_pxlen(net->n.addr) == net_max_prefix_length[net->n.addr->type])
|
if (net_pxlen(e->net) == net_max_prefix_length[net->type])
|
||||||
msg.rtm.rtm_flags |= RTF_HOST;
|
msg.rtm.rtm_flags |= RTF_HOST;
|
||||||
else
|
else
|
||||||
msg.rtm.rtm_addrs |= RTA_NETMASK;
|
msg.rtm.rtm_addrs |= RTA_NETMASK;
|
||||||
@ -228,11 +235,11 @@ krt_send_route(struct krt_proto *p, int cmd, rte *e)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef RTF_REJECT
|
#ifdef RTF_REJECT
|
||||||
if(a->dest == RTD_UNREACHABLE)
|
if(dest == RTD_UNREACHABLE)
|
||||||
msg.rtm.rtm_flags |= RTF_REJECT;
|
msg.rtm.rtm_flags |= RTF_REJECT;
|
||||||
#endif
|
#endif
|
||||||
#ifdef RTF_BLACKHOLE
|
#ifdef RTF_BLACKHOLE
|
||||||
if(a->dest == RTD_BLACKHOLE)
|
if(dest == RTD_BLACKHOLE)
|
||||||
msg.rtm.rtm_flags |= RTF_BLACKHOLE;
|
msg.rtm.rtm_flags |= RTF_BLACKHOLE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -260,7 +267,7 @@ krt_send_route(struct krt_proto *p, int cmd, rte *e)
|
|||||||
|
|
||||||
int af = AF_UNSPEC;
|
int af = AF_UNSPEC;
|
||||||
|
|
||||||
switch (net->n.addr->type) {
|
switch (net->type) {
|
||||||
case NET_IP4:
|
case NET_IP4:
|
||||||
af = AF_INET;
|
af = AF_INET;
|
||||||
break;
|
break;
|
||||||
@ -268,19 +275,19 @@ krt_send_route(struct krt_proto *p, int cmd, rte *e)
|
|||||||
af = AF_INET6;
|
af = AF_INET6;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
log(L_ERR "KRT: Not sending route %N to kernel", net->n.addr);
|
log(L_ERR "KRT: Not sending route %N to kernel", net);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sockaddr_fill(&dst, af, net_prefix(net->n.addr), NULL, 0);
|
sockaddr_fill(&dst, af, net_prefix(net), NULL, 0);
|
||||||
sockaddr_fill(&mask, af, net_pxmask(net->n.addr), NULL, 0);
|
sockaddr_fill(&mask, af, net_pxmask(net), NULL, 0);
|
||||||
|
|
||||||
switch (a->dest)
|
switch (dest)
|
||||||
{
|
{
|
||||||
case RTD_UNICAST:
|
case RTD_UNICAST:
|
||||||
if (ipa_nonzero(a->nh.gw))
|
if (ipa_nonzero(nh->nh.gw))
|
||||||
{
|
{
|
||||||
ip_addr gw = a->nh.gw;
|
ip_addr gw = nh->nh.gw;
|
||||||
|
|
||||||
/* Embed interface ID to link-local address */
|
/* Embed interface ID to link-local address */
|
||||||
if (ipa_is_link_local(gw))
|
if (ipa_is_link_local(gw))
|
||||||
@ -292,6 +299,8 @@ krt_send_route(struct krt_proto *p, int cmd, rte *e)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Fall through */
|
||||||
|
|
||||||
#ifdef RTF_REJECT
|
#ifdef RTF_REJECT
|
||||||
case RTD_UNREACHABLE:
|
case RTD_UNREACHABLE:
|
||||||
#endif
|
#endif
|
||||||
@ -303,7 +312,7 @@ krt_send_route(struct krt_proto *p, int cmd, rte *e)
|
|||||||
|
|
||||||
#if __OpenBSD__
|
#if __OpenBSD__
|
||||||
/* Keeping temporarily old code for OpenBSD */
|
/* Keeping temporarily old code for OpenBSD */
|
||||||
struct ifa *addr = (net->n.addr->type == NET_IP4) ? i->addr4 : (i->addr6 ?: i->llv6);
|
struct ifa *addr = (net->type == NET_IP4) ? i->addr4 : (i->addr6 ?: i->llv6);
|
||||||
|
|
||||||
if (!addr)
|
if (!addr)
|
||||||
{
|
{
|
||||||
@ -339,7 +348,7 @@ krt_send_route(struct krt_proto *p, int cmd, rte *e)
|
|||||||
msg.rtm.rtm_msglen = l;
|
msg.rtm.rtm_msglen = l;
|
||||||
|
|
||||||
if ((l = write(p->sys.sk->fd, (char *)&msg, l)) < 0) {
|
if ((l = write(p->sys.sk->fd, (char *)&msg, l)) < 0) {
|
||||||
log(L_ERR "KRT: Error sending route %N to kernel: %m", net->n.addr);
|
log(L_ERR "KRT: Error sending route %N to kernel: %m", net);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,7 +356,7 @@ krt_send_route(struct krt_proto *p, int cmd, rte *e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
krt_replace_rte(struct krt_proto *p, net *n, rte *new, rte *old)
|
krt_replace_rte(struct krt_proto *p, const net_addr *n UNUSED, rte *new, const rte *old)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
@ -398,7 +407,6 @@ krt_read_route(struct ks_msg *msg, struct krt_proto *p, int scan)
|
|||||||
/* p is NULL iff KRT_SHARED_SOCKET and !scan */
|
/* p is NULL iff KRT_SHARED_SOCKET and !scan */
|
||||||
|
|
||||||
int ipv6;
|
int ipv6;
|
||||||
net *net;
|
|
||||||
sockaddr dst, gate, mask;
|
sockaddr dst, gate, mask;
|
||||||
ip_addr idst, igate, imask;
|
ip_addr idst, igate, imask;
|
||||||
net_addr ndst;
|
net_addr ndst;
|
||||||
@ -515,73 +523,81 @@ krt_read_route(struct ks_msg *msg, struct krt_proto *p, int scan)
|
|||||||
else
|
else
|
||||||
src = KRT_SRC_KERNEL;
|
src = KRT_SRC_KERNEL;
|
||||||
|
|
||||||
net = net_get(p->p.main_channel->table, &ndst);
|
union {
|
||||||
|
struct {
|
||||||
rta a = {
|
struct adata ad;
|
||||||
|
struct nexthop nh;
|
||||||
|
u32 labels[MPLS_MAX_LABEL_STACK];
|
||||||
};
|
};
|
||||||
|
struct nexthop_adata nhad;
|
||||||
|
} nhad = {};
|
||||||
|
|
||||||
ea_set_attr_u32(&a->eattrs, &ea_gen_source, 0, RTS_INHERIT);
|
ea_list *eattrs = NULL;
|
||||||
|
|
||||||
|
ea_set_attr_u32(&eattrs, &ea_gen_source, 0, RTS_INHERIT);
|
||||||
|
|
||||||
/* reject/blackhole routes have also set RTF_GATEWAY,
|
/* reject/blackhole routes have also set RTF_GATEWAY,
|
||||||
we wil check them first. */
|
we wil check them first. */
|
||||||
|
|
||||||
#ifdef RTF_REJECT
|
#ifdef RTF_REJECT
|
||||||
if(flags & RTF_REJECT) {
|
if(flags & RTF_REJECT) {
|
||||||
a.dest = RTD_UNREACHABLE;
|
nhad.nhad = NEXTHOP_DEST_LITERAL(RTD_UNREACHABLE);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef RTF_BLACKHOLE
|
#ifdef RTF_BLACKHOLE
|
||||||
if(flags & RTF_BLACKHOLE) {
|
if(flags & RTF_BLACKHOLE) {
|
||||||
a.dest = RTD_BLACKHOLE;
|
nhad.nhad = NEXTHOP_DEST_LITERAL(RTD_BLACKHOLE);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
a.nh.iface = if_find_by_index(msg->rtm.rtm_index);
|
nhad.nh.iface = if_find_by_index(msg->rtm.rtm_index);
|
||||||
if (!a.nh.iface)
|
if (!nhad.nh.iface)
|
||||||
{
|
{
|
||||||
log(L_ERR "KRT: Received route %N with unknown ifindex %u",
|
log(L_ERR "KRT: Received route %N with unknown ifindex %u",
|
||||||
net->n.addr, msg->rtm.rtm_index);
|
&ndst, msg->rtm.rtm_index);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
a.dest = RTD_UNICAST;
|
|
||||||
if (flags & RTF_GATEWAY)
|
if (flags & RTF_GATEWAY)
|
||||||
{
|
{
|
||||||
a.nh.gw = igate;
|
nhad.nh.gw = igate;
|
||||||
|
|
||||||
/* Clean up embedded interface ID returned in link-local address */
|
/* Clean up embedded interface ID returned in link-local address */
|
||||||
if (ipa_is_link_local(a.nh.gw))
|
if (ipa_is_link_local(nhad.nh.gw))
|
||||||
_I0(a.nh.gw) = 0xfe800000;
|
_I0(nhad.nh.gw) = 0xfe800000;
|
||||||
|
|
||||||
/* The BSD kernel does not support an onlink flag. We heuristically
|
/* The BSD kernel does not support an onlink flag. We heuristically
|
||||||
set the onlink flag, if the iface has only host addresses. */
|
set the onlink flag, if the iface has only host addresses. */
|
||||||
if (krt_assume_onlink(a.nh.iface, ipv6))
|
if (krt_assume_onlink(nhad.nh.iface, ipv6))
|
||||||
a.nh.flags |= RNF_ONLINK;
|
nhad.nh.flags |= RNF_ONLINK;
|
||||||
|
|
||||||
neighbor *nbr;
|
neighbor *nbr;
|
||||||
nbr = neigh_find(&p->p, a.nh.gw, a.nh.iface,
|
nbr = neigh_find(&p->p, nhad.nh.gw, nhad.nh.iface,
|
||||||
(a.nh.flags & RNF_ONLINK) ? NEF_ONLINK : 0);
|
(nhad.nh.flags & RNF_ONLINK) ? NEF_ONLINK : 0);
|
||||||
if (!nbr || (nbr->scope == SCOPE_HOST))
|
if (!nbr || (nbr->scope == SCOPE_HOST))
|
||||||
{
|
{
|
||||||
/* Ignore routes with next-hop 127.0.0.1, host routes with such
|
/* Ignore routes with next-hop 127.0.0.1, host routes with such
|
||||||
next-hop appear on OpenBSD for address aliases. */
|
next-hop appear on OpenBSD for address aliases. */
|
||||||
if (ipa_classify(a.nh.gw) == (IADDR_HOST | SCOPE_HOST))
|
if (ipa_classify(nhad.nh.gw) == (IADDR_HOST | SCOPE_HOST))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
log(L_ERR "KRT: Received route %N with strange next-hop %I",
|
log(L_ERR "KRT: Received route %N with strange next-hop %I",
|
||||||
net->n.addr, a.nh.gw);
|
&ndst, nhad.nh.gw);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
done:;
|
nhad.ad.length = (void *) NEXTHOP_NEXT(&nhad.nh) - (void *) nhad.ad.data;
|
||||||
rte e0 = { .attrs = &a, .net = net, };
|
|
||||||
|
|
||||||
ea_set_attr(e0.attrs->eattrs,
|
done:
|
||||||
EA_LITERAL_EMBEDDED(EA_KRT_SOURCE, T_INT, 0, src2));
|
ea_set_attr(&eattrs, EA_LITERAL_DIRECT_ADATA(&ea_gen_nexthop, 0, &nhad.ad));
|
||||||
|
rte e0 = { .attrs = eattrs, .net = &ndst, };
|
||||||
|
|
||||||
|
ea_set_attr(&e0.attrs,
|
||||||
|
EA_LITERAL_EMBEDDED(&ea_krt_source, 0, src2));
|
||||||
|
|
||||||
if (scan)
|
if (scan)
|
||||||
krt_got_route(p, &e0, src);
|
krt_got_route(p, &e0, src);
|
||||||
@ -822,6 +838,7 @@ krt_read_msg(struct proto *p, struct ks_msg *msg, int scan)
|
|||||||
{
|
{
|
||||||
case RTM_GET:
|
case RTM_GET:
|
||||||
if(!scan) return;
|
if(!scan) return;
|
||||||
|
/* Fall through */
|
||||||
case RTM_ADD:
|
case RTM_ADD:
|
||||||
case RTM_DELETE:
|
case RTM_DELETE:
|
||||||
case RTM_CHANGE:
|
case RTM_CHANGE:
|
||||||
|
@ -15,6 +15,8 @@ CF_KEYWORDS(KERNEL, TABLE, METRIC, NETLINK, RX, BUFFER,
|
|||||||
KRT_LOCK_SSTRESH, KRT_LOCK_CWND, KRT_LOCK_ADVMSS, KRT_LOCK_REORDERING,
|
KRT_LOCK_SSTRESH, KRT_LOCK_CWND, KRT_LOCK_ADVMSS, KRT_LOCK_REORDERING,
|
||||||
KRT_LOCK_HOPLIMIT, KRT_LOCK_RTO_MIN, KRT_FEATURE_ECN, KRT_FEATURE_ALLFRAG)
|
KRT_LOCK_HOPLIMIT, KRT_LOCK_RTO_MIN, KRT_FEATURE_ECN, KRT_FEATURE_ALLFRAG)
|
||||||
|
|
||||||
|
%type <fab> attr_bit
|
||||||
|
|
||||||
CF_GRAMMAR
|
CF_GRAMMAR
|
||||||
|
|
||||||
kern_proto: kern_proto kern_sys_item ';' ;
|
kern_proto: kern_proto kern_sys_item ';' ;
|
||||||
@ -42,6 +44,25 @@ attr_bit: KRT_LOCK_RTO_MIN { $$ = f_new_dynamic_attr_bit(13, "krt_lock"); } ;
|
|||||||
attr_bit: KRT_FEATURE_ECN { $$ = f_new_dynamic_attr_bit(0, "krt_features"); } ;
|
attr_bit: KRT_FEATURE_ECN { $$ = f_new_dynamic_attr_bit(0, "krt_features"); } ;
|
||||||
attr_bit: KRT_FEATURE_ALLFRAG { $$ = f_new_dynamic_attr_bit(3, "krt_features"); } ;
|
attr_bit: KRT_FEATURE_ALLFRAG { $$ = f_new_dynamic_attr_bit(3, "krt_features"); } ;
|
||||||
|
|
||||||
|
/* Getting attribute bits (moved here to not confuse Bison on *BSD) */
|
||||||
|
term:
|
||||||
|
attr_bit {
|
||||||
|
struct f_inst *c = f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_INT, .val.i = (1U << $1.bit)});
|
||||||
|
$$ = f_new_inst(FI_EQ, c, f_new_inst(FI_BITAND, f_new_inst(FI_EA_GET, $1.class), c));
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
/* Setting attribute bits (moved here to not confuse Bison on *BSD) */
|
||||||
|
cmd:
|
||||||
|
attr_bit '=' term ';' {
|
||||||
|
$$ = f_new_inst(FI_CONDITION, $3,
|
||||||
|
f_generate_complex_default(FI_BITOR, $1.class,
|
||||||
|
f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_INT, .val.i = (1U << $1.bit)}), 0),
|
||||||
|
f_generate_complex_default(FI_BITAND, $1.class,
|
||||||
|
f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_INT, .val.i = ~(1U << $1.bit)}), 0)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
CF_CODE
|
CF_CODE
|
||||||
|
|
||||||
|
@ -83,11 +83,15 @@ uint dg_order(struct domain_generic *dg)
|
|||||||
|
|
||||||
void do_lock(struct domain_generic *dg, struct domain_generic **lsp)
|
void do_lock(struct domain_generic *dg, struct domain_generic **lsp)
|
||||||
{
|
{
|
||||||
|
struct lock_order stack_copy;
|
||||||
|
memcpy(&stack_copy, &locking_stack, sizeof(stack_copy));
|
||||||
|
struct domain_generic **lll = last_locked;
|
||||||
|
|
||||||
if ((char *) lsp - (char *) &locking_stack != dg->order)
|
if ((char *) lsp - (char *) &locking_stack != dg->order)
|
||||||
bug("Trying to lock on bad position: order=%u, lsp=%p, base=%p", dg->order, lsp, &locking_stack);
|
bug("Trying to lock on bad position: order=%u, lsp=%p, base=%p", dg->order, lsp, &locking_stack);
|
||||||
|
|
||||||
if (lsp <= last_locked)
|
if (lsp <= last_locked)
|
||||||
bug("Trying to lock in a bad order");
|
bug("Trying to lock in a bad order: %p %p", &stack_copy, lll);
|
||||||
if (*lsp)
|
if (*lsp)
|
||||||
bug("Inconsistent locking stack state on lock");
|
bug("Inconsistent locking stack state on lock");
|
||||||
|
|
||||||
|
@ -290,18 +290,6 @@ krt_metric(rte *a)
|
|||||||
return ea ? ea->u.data : 0;
|
return ea ? ea->u.data : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
|
||||||
krt_same_key(rte *a, rte *b)
|
|
||||||
{
|
|
||||||
return (krt_metric(a) == krt_metric(b));
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int
|
|
||||||
krt_uptodate(rte *a, rte *b)
|
|
||||||
{
|
|
||||||
return (a->attrs == b->attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
krt_learn_alien_attr(struct channel *c, rte *e)
|
krt_learn_alien_attr(struct channel *c, rte *e)
|
||||||
{
|
{
|
||||||
@ -444,10 +432,13 @@ krt_got_route(struct krt_proto *p, rte *e, s8 src)
|
|||||||
switch (src)
|
switch (src)
|
||||||
{
|
{
|
||||||
case KRT_SRC_KERNEL:
|
case KRT_SRC_KERNEL:
|
||||||
goto ignore;
|
krt_trace_in(p, e, "ignored");
|
||||||
|
return;
|
||||||
|
|
||||||
case KRT_SRC_REDIRECT:
|
case KRT_SRC_REDIRECT:
|
||||||
goto delete;
|
krt_trace_in(p, e, "deleting");
|
||||||
|
krt_replace_rte(p, e->net, NULL, e);
|
||||||
|
return;
|
||||||
|
|
||||||
case KRT_SRC_ALIEN:
|
case KRT_SRC_ALIEN:
|
||||||
if (KRT_CF->learn)
|
if (KRT_CF->learn)
|
||||||
@ -457,6 +448,7 @@ krt_got_route(struct krt_proto *p, rte *e, s8 src)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The rest is for KRT_SRC_BIRD (or KRT_SRC_UNKNOWN) */
|
/* The rest is for KRT_SRC_BIRD (or KRT_SRC_UNKNOWN) */
|
||||||
|
|
||||||
RT_LOCKED(p->p.main_channel->table, tab)
|
RT_LOCKED(p->p.main_channel->table, tab)
|
||||||
@ -719,7 +711,11 @@ static int
|
|||||||
krt_preexport(struct channel *C, rte *e)
|
krt_preexport(struct channel *C, rte *e)
|
||||||
{
|
{
|
||||||
if (e->src->owner == &C->proto->sources)
|
if (e->src->owner == &C->proto->sources)
|
||||||
|
#ifdef CONFIG_SINGLE_ROUTE
|
||||||
|
return 1;
|
||||||
|
#else
|
||||||
return -1;
|
return -1;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!krt_capable(e))
|
if (!krt_capable(e))
|
||||||
return -1;
|
return -1;
|
||||||
@ -737,14 +733,8 @@ krt_rt_notify(struct proto *P, struct channel *ch UNUSED, const net_addr *net,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef CONFIG_SINGLE_ROUTE
|
#ifdef CONFIG_SINGLE_ROUTE
|
||||||
/*
|
/* Got the same route as we imported. Keep it, do nothing. */
|
||||||
* Implicit withdraw - when the imported kernel route becomes the best one,
|
if (new && new->src->owner == &P->sources)
|
||||||
* we know that the previous one exported to the kernel was already removed,
|
|
||||||
* but if we processed the update as usual, we would send withdraw to the
|
|
||||||
* kernel, which would remove the new imported route instead.
|
|
||||||
*/
|
|
||||||
rte *best = net->routes;
|
|
||||||
if (!new && best && (best->attrs->src->proto == P))
|
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user