mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-11-10 05:08:42 +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
|
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;
|
rta *a = e->attrs;
|
||||||
static int msg_seq;
|
static int msg_seq;
|
||||||
struct iface *j, *i = a->nh.iface;
|
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;
|
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 %I/%d via %I\n", net->prefix, net->pxlen, a->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 +218,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(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;
|
||||||
@ -260,7 +260,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,12 +268,12 @@ 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 (a->dest)
|
||||||
{
|
{
|
||||||
@ -303,7 +303,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 +339,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 +347,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;
|
||||||
|
|
||||||
@ -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 */
|
/* 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;
|
||||||
@ -491,8 +490,6 @@ 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);
|
|
||||||
|
|
||||||
rta a = {
|
rta a = {
|
||||||
.source = RTS_INHERIT,
|
.source = RTS_INHERIT,
|
||||||
.scope = SCOPE_UNIVERSE,
|
.scope = SCOPE_UNIVERSE,
|
||||||
@ -519,7 +516,7 @@ krt_read_route(struct ks_msg *msg, struct krt_proto *p, int scan)
|
|||||||
if (!a.nh.iface)
|
if (!a.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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -542,13 +539,13 @@ krt_read_route(struct ks_msg *msg, struct krt_proto *p, int scan)
|
|||||||
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, a.nh.gw);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
done:;
|
done:;
|
||||||
rte e0 = { .attrs = &a, .net = net, };
|
rte e0 = { .attrs = &a, .net = &ndst, };
|
||||||
|
|
||||||
ea_list *ea = alloca(sizeof(ea_list) + 1 * sizeof(eattr));
|
ea_list *ea = alloca(sizeof(ea_list) + 1 * sizeof(eattr));
|
||||||
*ea = (ea_list) { .count = 1, .next = e0.attrs->eattrs };
|
*ea = (ea_list) { .count = 1, .next = e0.attrs->eattrs };
|
||||||
|
@ -70,10 +70,14 @@ alloc_page(void)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_ALIGNED_ALLOC
|
||||||
void *ret = aligned_alloc(page_size, page_size);
|
void *ret = aligned_alloc(page_size, page_size);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
bug("aligned_alloc(%lu) failed", page_size);
|
bug("aligned_alloc(%lu) failed", page_size);
|
||||||
return ret;
|
return ret;
|
||||||
|
#else
|
||||||
|
bug("BIRD should have already died on fatal error.");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +218,11 @@ void resource_sys_init(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_ALIGNED_ALLOC
|
||||||
log(L_WARN "Got strange memory page size (%lu), using the aligned allocator instead", page_size);
|
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 */
|
/* Too big or strange page, use the aligned allocator instead */
|
||||||
page_size = 4096;
|
page_size = 4096;
|
||||||
|
@ -681,7 +681,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; /* Passing the route directly for rt_notify() to ignore */
|
||||||
|
#else
|
||||||
return -1;
|
return -1;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!krt_capable(e))
|
if (!krt_capable(e))
|
||||||
return -1;
|
return -1;
|
||||||
@ -700,13 +704,10 @@ krt_rt_notify(struct proto *P, struct channel *ch UNUSED, const net_addr *net,
|
|||||||
|
|
||||||
#ifdef CONFIG_SINGLE_ROUTE
|
#ifdef CONFIG_SINGLE_ROUTE
|
||||||
/*
|
/*
|
||||||
* Implicit withdraw - when the imported kernel route becomes the best one,
|
* When the imported kernel route becomes the best one, we get it directly and
|
||||||
* we know that the previous one exported to the kernel was already removed,
|
* we simply know that it is already there. Nothing to do.
|
||||||
* 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->src->owner == &P->sources)
|
||||||
if (!new && best && (best->attrs->src->proto == P))
|
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user