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

Minor fixes to previous patches.

parent 126683fe
......@@ -158,6 +158,7 @@ if $CC -Wall -Wno-pointer-sign conftest.c >&AS_MESSAGE_LOG_FD 2>&1 ; then
else
bird_cv_c_option_no_pointer_sign=no
fi
rm -rf conftest* a.out
])])
# BIRD_CHECK_PROG_FLAVOR_GNU(PROGRAM-PATH, IF-SUCCESS, [IF-FAILURE])
......
......@@ -66,11 +66,11 @@ if test -z "$GCC" ; then
fi
AC_MSG_CHECKING([what CFLAGS should we use])
if test "$bird_cflags_default" == yes ; then
if test "$bird_cflags_default" = yes ; then
BIRD_CHECK_GCC_OPTIONS
CFLAGS="$CFLAGS -Wall -Wstrict-prototypes -Wno-parentheses"
if test "$bird_cv_c_option_no_pointer_sign" == yes ; then
if test "$bird_cv_c_option_no_pointer_sign" = yes ; then
CFLAGS="$CFLAGS -Wno-pointer-sign"
fi
fi
......
......@@ -662,31 +662,31 @@ ospf_ifa_notify(struct proto *p, unsigned flags, struct ifa *a)
WALK_LIST(ac, cf->area_list)
{
u32 found_new[8] = {};
struct iface_patt *p;
struct iface_patt *pt;
WALK_LIST(p, ac->patt_list)
WALK_LIST(pt, ac->patt_list)
{
if (iface_patt_match(p, i, a))
if (iface_patt_match(pt, a->iface, a))
{
struct ospf_iface_patt *ip = (struct ospf_iface_patt *) p;
struct ospf_iface_patt *ipt = (struct ospf_iface_patt *) pt;
/* If true, we already assigned that IID and we skip
this to implement first-match behavior */
if (iflag_test(found_new, ip->instance_id))
if (iflag_test(found_new, ipt->instance_id))
continue;
/* If true, we already assigned that in a different area,
we log collision */
if (iflag_test(found_all, ip->instance_id))
if (iflag_test(found_all, ipt->instance_id))
{
log(L_WARN "%s: Interface %s (IID %d) matches for multiple areas",
p->name, a->iface->name, ip->instance_id);
p->name, a->iface->name, ipt->instance_id);
continue;
}
iflag_set(found_all, ip->instance_id);
iflag_set(found_new, ip->instance_id);
ospf_iface_new(po, a->iface, a, ac, ip);
iflag_set(found_all, ipt->instance_id);
iflag_set(found_new, ipt->instance_id);
ospf_iface_new(po, a->iface, a, ac, ipt);
}
}
}
......
......@@ -348,7 +348,7 @@ ospf_rx_hook(sock *sk, int size)
if ((areaid == ifa->oa->areaid)
#ifdef OSPFv3
&& (ps->instance_id != ifa->instance_id)
&& (ps->instance_id == ifa->instance_id)
#endif
)
{
......
......@@ -150,18 +150,18 @@ sysio_process_rx_cmsgs(sock *s, struct msghdr *msg)
// log(L_WARN "RX %I %d", s->laddr, s->lifindex);
}
void
sysio_prepare_tx_cmsgs(sock *s, struct msghdr *msg)
/* Unfortunately, IP_SENDSRCADDR does not work for raw IP sockets on BSD kernels */
static void
sysio_prepare_tx_cmsgs(sock *s, struct msghdr *msg, void *cbuf, size_t cbuflen)
{
struct cmsghdr *cm;
struct in_addr *sa;
if (!(s->flags & SKF_LADDR_TX))
{
msg->msg_controllen = 0;
return;
}
return;
msg->msg_control = cbuf;
msg->msg_controllen = cbuflen;
if (s->iface)
{
......
......@@ -272,17 +272,17 @@ sysio_process_rx_cmsgs(sock *s, struct msghdr *msg)
}
void
sysio_prepare_tx_cmsgs(sock *s, struct msghdr *msg)
static void
sysio_prepare_tx_cmsgs(sock *s, struct msghdr *msg, void *cbuf, size_t cbuflen)
{
struct cmsghdr *cm;
struct in_pktinfo *pi;
if (!(s->flags & SKF_LADDR_TX))
{
msg->msg_controllen = 0;
return;
}
return;
msg->msg_control = cbuf;
msg->msg_controllen = cbuflen;
cm = CMSG_FIRSTHDR(msg);
cm->cmsg_level = IPPROTO_IP;
......
......@@ -660,6 +660,77 @@ get_sockaddr(struct sockaddr_in *sa, ip_addr *a, unsigned *port, int check)
#endif
#ifdef IPV6
/* PKTINFO handling is also standardized in IPv6 */
#define CMSG_RX_SPACE CMSG_SPACE(sizeof(struct in6_pktinfo))
#define CMSG_TX_SPACE CMSG_SPACE(sizeof(struct in6_pktinfo))
static char *
sysio_register_cmsgs(sock *s)
{
int ok = 1;
if ((s->flags & SKF_LADDR_RX) &&
setsockopt(s->fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, &ok, sizeof(ok)) < 0)
return "IPV6_RECVPKTINFO";
return NULL;
}
static void
sysio_process_rx_cmsgs(sock *s, struct msghdr *msg)
{
struct cmsghdr *cm;
struct in6_pktinfo *pi = NULL;
if (!(s->flags & SKF_LADDR_RX))
return;
for (cm = CMSG_FIRSTHDR(msg); cm != NULL; cm = CMSG_NXTHDR(msg, cm))
{
if (cm->cmsg_level == IPPROTO_IPV6 && cm->cmsg_type == IPV6_PKTINFO)
pi = (struct in6_pktinfo *) CMSG_DATA(cm);
}
if (!pi)
{
s->laddr = IPA_NONE;
s->lifindex = 0;
return;
}
get_inaddr(&s->laddr, &pi->ipi6_addr);
s->lifindex = pi->ipi6_ifindex;
return;
}
static void
sysio_prepare_tx_cmsgs(sock *s, struct msghdr *msg, void *cbuf, size_t cbuflen)
{
struct cmsghdr *cm;
struct in6_pktinfo *pi;
if (!(s->flags & SKF_LADDR_TX))
return;
msg->msg_control = cbuf;
msg->msg_controllen = cbuflen;
cm = CMSG_FIRSTHDR(msg);
cm->cmsg_level = IPPROTO_IPV6;
cm->cmsg_type = IPV6_PKTINFO;
cm->cmsg_len = CMSG_LEN(sizeof(*pi));
pi = (struct in6_pktinfo *) CMSG_DATA(cm);
set_inaddr(&pi->ipi6_addr, s->saddr);
pi->ipi6_ifindex = s->iface ? s->iface->index : 0;
msg->msg_controllen = cm->cmsg_len;
return;
}
#endif
static char *
sk_set_ttl_int(sock *s)
{
......@@ -856,71 +927,6 @@ sk_leave_group(sock *s, ip_addr maddr)
return 0;
}
/* PKTINFO handling is also standardized in IPv6 */
#define CMSG_RX_SPACE CMSG_SPACE(sizeof(struct in6_pktinfo))
static char *
sysio_register_cmsgs(sock *s)
{
int ok = 1;
if ((s->flags & SKF_LADDR_RX) &&
setsockopt(s->fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, &ok, sizeof(ok)) < 0)
return "IPV6_RECVPKTINFO";
return NULL;
}
void
sysio_process_rx_cmsgs(sock *s, struct msghdr *msg)
{
struct cmsghdr *cm;
struct in6_pktinfo *pi = NULL;
if (!(s->flags & SKF_LADDR_RX))
return;
for (cm = CMSG_FIRSTHDR(msg); cm != NULL; cm = CMSG_NXTHDR(msg, cm))
{
if (cm->cmsg_level == IPPROTO_IPV6 && cm->cmsg_type == IPV6_PKTINFO)
pi = (struct in6_pktinfo *) CMSG_DATA(cm);
}
if (!pi)
{
s->laddr = IPA_NONE;
s->lifindex = 0;
return;
}
get_inaddr(&s->laddr, &pi->ipi6_addr);
s->lifindex = pi->ipi6_ifindex;
return;
}
void
sysio_prepare_tx_cmsgs(sock *s, struct msghdr *msg)
{
struct cmsghdr *cm;
struct in6_pktinfo *pi;
if (!(s->flags & SKF_LADDR_TX))
{
msg->msg_controllen = 0;
return;
}
cm = CMSG_FIRSTHDR(msg);
cm->cmsg_level = IPPROTO_IPV6;
cm->cmsg_type = PIV6_PKTINFO;
cm->cmsg_len = CMSG_LEN(sizeof(*pi));
pi = (struct in6_pktinfo *) CMSG_DATA(cm);
set_inaddr(&pi->ipi6_addr, s->saddr);
pi->ipi6_ifindex = s->iface ? s->iface->index : 0;
msg->msg_controllen = cmsg->cmsg_len;
return;
}
#else /* IPV4 */
......@@ -1216,12 +1222,9 @@ sk_maybe_write(sock *s)
.msg_name = &sa,
.msg_namelen = sizeof(sa),
.msg_iov = &iov,
.msg_iovlen = 1,
.msg_control = cmsg_buf,
.msg_controllen = sizeof(cmsg_buf),
.msg_flags = 0};
.msg_iovlen = 1};
sysio_prepare_tx_cmsgs(s, &msg);
sysio_prepare_tx_cmsgs(s, &msg, cmsg_buf, sizeof(cmsg_buf));
e = sendmsg(s->fd, &msg, 0);
if (e < 0)
......
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