mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 17:51:53 +00:00
Fixed build errors for OpenBSD
This commit is contained in:
parent
f9e098c98a
commit
493d45d950
@ -197,9 +197,9 @@ sockaddr_fill_dl(struct sockaddr_dl *sa, struct iface *ifa)
|
||||
}
|
||||
|
||||
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;
|
||||
static int msg_seq;
|
||||
struct iface *j, *i = a->nh.iface;
|
||||
@ -208,7 +208,7 @@ krt_send_route(struct krt_proto *p, int cmd, rte *e)
|
||||
char *body = (char *)msg.buf;
|
||||
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 %I/%d via %I\n", net->prefix, net->pxlen, a->gw);
|
||||
|
||||
bzero(&msg,sizeof (struct rt_msghdr));
|
||||
msg.rtm.rtm_version = RTM_VERSION;
|
||||
@ -218,7 +218,7 @@ krt_send_route(struct krt_proto *p, int cmd, rte *e)
|
||||
msg.rtm.rtm_flags = RTF_UP | RTF_PROTO1;
|
||||
|
||||
/* XXXX */
|
||||
if (net_pxlen(net->n.addr) == net_max_prefix_length[net->n.addr->type])
|
||||
if (net_pxlen(net) == net_max_prefix_length[net->type])
|
||||
msg.rtm.rtm_flags |= RTF_HOST;
|
||||
else
|
||||
msg.rtm.rtm_addrs |= RTA_NETMASK;
|
||||
@ -260,7 +260,7 @@ krt_send_route(struct krt_proto *p, int cmd, rte *e)
|
||||
|
||||
int af = AF_UNSPEC;
|
||||
|
||||
switch (net->n.addr->type) {
|
||||
switch (net->type) {
|
||||
case NET_IP4:
|
||||
af = AF_INET;
|
||||
break;
|
||||
@ -268,12 +268,12 @@ krt_send_route(struct krt_proto *p, int cmd, rte *e)
|
||||
af = AF_INET6;
|
||||
break;
|
||||
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;
|
||||
}
|
||||
|
||||
sockaddr_fill(&dst, af, net_prefix(net->n.addr), NULL, 0);
|
||||
sockaddr_fill(&mask, af, net_pxmask(net->n.addr), NULL, 0);
|
||||
sockaddr_fill(&dst, af, net_prefix(net), NULL, 0);
|
||||
sockaddr_fill(&mask, af, net_pxmask(net), NULL, 0);
|
||||
|
||||
switch (a->dest)
|
||||
{
|
||||
@ -303,7 +303,7 @@ krt_send_route(struct krt_proto *p, int cmd, rte *e)
|
||||
|
||||
#if __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)
|
||||
{
|
||||
@ -339,7 +339,7 @@ krt_send_route(struct krt_proto *p, int cmd, rte *e)
|
||||
msg.rtm.rtm_msglen = l;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -347,7 +347,7 @@ krt_send_route(struct krt_proto *p, int cmd, rte *e)
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@ -374,7 +374,6 @@ krt_read_route(struct ks_msg *msg, struct krt_proto *p, int scan)
|
||||
/* p is NULL iff KRT_SHARED_SOCKET and !scan */
|
||||
|
||||
int ipv6;
|
||||
net *net;
|
||||
sockaddr dst, gate, mask;
|
||||
ip_addr idst, igate, imask;
|
||||
net_addr ndst;
|
||||
@ -491,8 +490,6 @@ krt_read_route(struct ks_msg *msg, struct krt_proto *p, int scan)
|
||||
else
|
||||
src = KRT_SRC_KERNEL;
|
||||
|
||||
net = net_get(p->p.main_channel->table, &ndst);
|
||||
|
||||
rta a = {
|
||||
.source = RTS_INHERIT,
|
||||
.scope = SCOPE_UNIVERSE,
|
||||
@ -519,7 +516,7 @@ krt_read_route(struct ks_msg *msg, struct krt_proto *p, int scan)
|
||||
if (!a.nh.iface)
|
||||
{
|
||||
log(L_ERR "KRT: Received route %N with unknown ifindex %u",
|
||||
net->n.addr, msg->rtm.rtm_index);
|
||||
&ndst, msg->rtm.rtm_index);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -542,13 +539,13 @@ krt_read_route(struct ks_msg *msg, struct krt_proto *p, int scan)
|
||||
return;
|
||||
|
||||
log(L_ERR "KRT: Received route %N with strange next-hop %I",
|
||||
net->n.addr, a.nh.gw);
|
||||
&ndst, a.nh.gw);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
done:;
|
||||
rte e0 = { .attrs = &a, .net = net, };
|
||||
rte e0 = { .attrs = &a, .net = &ndst, };
|
||||
|
||||
ea_list *ea = alloca(sizeof(ea_list) + 1 * sizeof(eattr));
|
||||
*ea = (ea_list) { .count = 1, .next = e0.attrs->eattrs };
|
||||
|
@ -70,10 +70,14 @@ alloc_page(void)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#ifdef HAVE_ALIGNED_ALLOC
|
||||
void *ret = aligned_alloc(page_size, page_size);
|
||||
if (!ret)
|
||||
bug("aligned_alloc(%lu) failed", page_size);
|
||||
return ret;
|
||||
#else
|
||||
bug("BIRD should have already died on fatal error.");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -214,7 +218,11 @@ void resource_sys_init(void)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef HAVE_ALIGNED_ALLOC
|
||||
log(L_WARN "Got strange memory page size (%lu), using the aligned allocator instead", page_size);
|
||||
#else
|
||||
die("Got strange memory page size (%lu) and aligned_alloc is not available", page_size);
|
||||
#endif
|
||||
|
||||
/* Too big or strange page, use the aligned allocator instead */
|
||||
page_size = 4096;
|
||||
|
@ -681,7 +681,11 @@ static int
|
||||
krt_preexport(struct channel *c, rte *e)
|
||||
{
|
||||
if (e->src->owner == &c->proto->sources)
|
||||
#ifdef CONFIG_SINGLE_ROUTE
|
||||
return 1; /* Passing the route directly for rt_notify() to ignore */
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
if (!krt_capable(e))
|
||||
return -1;
|
||||
@ -700,13 +704,10 @@ krt_rt_notify(struct proto *P, struct channel *ch UNUSED, const net_addr *net,
|
||||
|
||||
#ifdef CONFIG_SINGLE_ROUTE
|
||||
/*
|
||||
* Implicit withdraw - when the imported kernel route becomes the best one,
|
||||
* 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.
|
||||
* When the imported kernel route becomes the best one, we get it directly and
|
||||
* we simply know that it is already there. Nothing to do.
|
||||
*/
|
||||
rte *best = net->routes;
|
||||
if (!new && best && (best->attrs->src->proto == P))
|
||||
if (new->src->owner == &P->sources)
|
||||
return;
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user