Minor fixes to previous patches.

This commit is contained in:
Ondrej Zajicek 2010-04-02 11:31:20 +02:00
parent 126683feed
commit bed417288e
7 changed files with 100 additions and 96 deletions

1
aclocal.m4 vendored
View file

@ -158,6 +158,7 @@ if $CC -Wall -Wno-pointer-sign conftest.c >&AS_MESSAGE_LOG_FD 2>&1 ; then
else else
bird_cv_c_option_no_pointer_sign=no bird_cv_c_option_no_pointer_sign=no
fi fi
rm -rf conftest* a.out
])]) ])])
# BIRD_CHECK_PROG_FLAVOR_GNU(PROGRAM-PATH, IF-SUCCESS, [IF-FAILURE]) # BIRD_CHECK_PROG_FLAVOR_GNU(PROGRAM-PATH, IF-SUCCESS, [IF-FAILURE])

View file

@ -66,11 +66,11 @@ if test -z "$GCC" ; then
fi fi
AC_MSG_CHECKING([what CFLAGS should we use]) 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 BIRD_CHECK_GCC_OPTIONS
CFLAGS="$CFLAGS -Wall -Wstrict-prototypes -Wno-parentheses" 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" CFLAGS="$CFLAGS -Wno-pointer-sign"
fi fi
fi fi

View file

@ -662,31 +662,31 @@ ospf_ifa_notify(struct proto *p, unsigned flags, struct ifa *a)
WALK_LIST(ac, cf->area_list) WALK_LIST(ac, cf->area_list)
{ {
u32 found_new[8] = {}; 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 /* If true, we already assigned that IID and we skip
this to implement first-match behavior */ this to implement first-match behavior */
if (iflag_test(found_new, ip->instance_id)) if (iflag_test(found_new, ipt->instance_id))
continue; continue;
/* If true, we already assigned that in a different area, /* If true, we already assigned that in a different area,
we log collision */ 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", 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; continue;
} }
iflag_set(found_all, ip->instance_id); iflag_set(found_all, ipt->instance_id);
iflag_set(found_new, ip->instance_id); iflag_set(found_new, ipt->instance_id);
ospf_iface_new(po, a->iface, a, ac, ip); ospf_iface_new(po, a->iface, a, ac, ipt);
} }
} }
} }

View file

@ -348,7 +348,7 @@ ospf_rx_hook(sock *sk, int size)
if ((areaid == ifa->oa->areaid) if ((areaid == ifa->oa->areaid)
#ifdef OSPFv3 #ifdef OSPFv3
&& (ps->instance_id != ifa->instance_id) && (ps->instance_id == ifa->instance_id)
#endif #endif
) )
{ {

View file

@ -150,18 +150,18 @@ sysio_process_rx_cmsgs(sock *s, struct msghdr *msg)
// log(L_WARN "RX %I %d", s->laddr, s->lifindex); // log(L_WARN "RX %I %d", s->laddr, s->lifindex);
} }
/* Unfortunately, IP_SENDSRCADDR does not work for raw IP sockets on BSD kernels */
void static void
sysio_prepare_tx_cmsgs(sock *s, struct msghdr *msg) sysio_prepare_tx_cmsgs(sock *s, struct msghdr *msg, void *cbuf, size_t cbuflen)
{ {
struct cmsghdr *cm; struct cmsghdr *cm;
struct in_addr *sa; struct in_addr *sa;
if (!(s->flags & SKF_LADDR_TX)) if (!(s->flags & SKF_LADDR_TX))
{ return;
msg->msg_controllen = 0;
return; msg->msg_control = cbuf;
} msg->msg_controllen = cbuflen;
if (s->iface) if (s->iface)
{ {

View file

@ -272,17 +272,17 @@ sysio_process_rx_cmsgs(sock *s, struct msghdr *msg)
} }
void static void
sysio_prepare_tx_cmsgs(sock *s, struct msghdr *msg) sysio_prepare_tx_cmsgs(sock *s, struct msghdr *msg, void *cbuf, size_t cbuflen)
{ {
struct cmsghdr *cm; struct cmsghdr *cm;
struct in_pktinfo *pi; struct in_pktinfo *pi;
if (!(s->flags & SKF_LADDR_TX)) if (!(s->flags & SKF_LADDR_TX))
{ return;
msg->msg_controllen = 0;
return; msg->msg_control = cbuf;
} msg->msg_controllen = cbuflen;
cm = CMSG_FIRSTHDR(msg); cm = CMSG_FIRSTHDR(msg);
cm->cmsg_level = IPPROTO_IP; cm->cmsg_level = IPPROTO_IP;

View file

@ -660,6 +660,77 @@ get_sockaddr(struct sockaddr_in *sa, ip_addr *a, unsigned *port, int check)
#endif #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 * static char *
sk_set_ttl_int(sock *s) sk_set_ttl_int(sock *s)
{ {
@ -856,71 +927,6 @@ sk_leave_group(sock *s, ip_addr maddr)
return 0; 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 */ #else /* IPV4 */
@ -1216,12 +1222,9 @@ sk_maybe_write(sock *s)
.msg_name = &sa, .msg_name = &sa,
.msg_namelen = sizeof(sa), .msg_namelen = sizeof(sa),
.msg_iov = &iov, .msg_iov = &iov,
.msg_iovlen = 1, .msg_iovlen = 1};
.msg_control = cmsg_buf,
.msg_controllen = sizeof(cmsg_buf),
.msg_flags = 0};
sysio_prepare_tx_cmsgs(s, &msg); sysio_prepare_tx_cmsgs(s, &msg, cmsg_buf, sizeof(cmsg_buf));
e = sendmsg(s->fd, &msg, 0); e = sendmsg(s->fd, &msg, 0);
if (e < 0) if (e < 0)