From bed417288e989c48a1362bb1177f436a2e2f9f4f Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Fri, 2 Apr 2010 11:31:20 +0200 Subject: Minor fixes to previous patches. --- aclocal.m4 | 1 + configure.in | 4 +- proto/ospf/iface.c | 20 +++---- proto/ospf/packet.c | 2 +- sysdep/bsd/sysio.h | 14 ++--- sysdep/linux/sysio.h | 12 ++--- sysdep/unix/io.c | 143 ++++++++++++++++++++++++++------------------------- 7 files changed, 100 insertions(+), 96 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index e98a413..34a0511 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -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]) diff --git a/configure.in b/configure.in index 3c988b1..9e82735 100644 --- a/configure.in +++ b/configure.in @@ -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 diff --git a/proto/ospf/iface.c b/proto/ospf/iface.c index 83d591b..0416355 100644 --- a/proto/ospf/iface.c +++ b/proto/ospf/iface.c @@ -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); } } } diff --git a/proto/ospf/packet.c b/proto/ospf/packet.c index dd8fa5f..b47cbfc 100644 --- a/proto/ospf/packet.c +++ b/proto/ospf/packet.c @@ -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 ) { diff --git a/sysdep/bsd/sysio.h b/sysdep/bsd/sysio.h index 9ee4ade..87c78fb 100644 --- a/sysdep/bsd/sysio.h +++ b/sysdep/bsd/sysio.h @@ -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) { diff --git a/sysdep/linux/sysio.h b/sysdep/linux/sysio.h index 91cbdcd..1cfbcc4 100644 --- a/sysdep/linux/sysio.h +++ b/sysdep/linux/sysio.h @@ -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; diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c index e9d78b6..abfa5c2 100644 --- a/sysdep/unix/io.c +++ b/sysdep/unix/io.c @@ -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) -- cgit v1.2.3