Several fixes for our net/olsrd port:
Make sendto() work for IPv4 by setting the IP_MULTICAST_IF socket option. Allows this port to drop the dependency on net/libnet and stop using the associated sendto() replacement hack (which supports only IPv4). Make IPv6 work: Fix adding/deleting IPv6 routes, and don't complain about a missing net.inet6.icmp6.rediraccept sysctl. Also enable the verbose build so build logs show the commands being used to compile things. ok danj@ sthen@
This commit is contained in:
parent
a16d534cd2
commit
d1ead8c734
@ -1,4 +1,4 @@
|
||||
# $OpenBSD: Makefile,v 1.29 2017/06/04 11:45:04 stsp Exp $
|
||||
# $OpenBSD: Makefile,v 1.30 2017/06/20 15:14:10 stsp Exp $
|
||||
|
||||
COMMENT-main= OLSR routing daemon
|
||||
COMMENT-gui= OLSR routing daemon GUI
|
||||
@ -7,7 +7,7 @@ VERSION= 0.9.6.1
|
||||
DISTNAME= olsrd-${VERSION}
|
||||
PKGNAME-main= olsrd-${VERSION}
|
||||
PKGNAME-gui= olsrd-gui-${VERSION}
|
||||
PKGNAME-plugins= olsrd-plugins-${VERSION}
|
||||
REVISION-main= 0
|
||||
|
||||
CATEGORIES= net
|
||||
|
||||
@ -23,8 +23,7 @@ MULTI_PACKAGES= -main -gui
|
||||
|
||||
BUILD_DEPENDS= devel/bison
|
||||
|
||||
LIB_DEPENDS-main= net/libnet/1.1
|
||||
WANTLIB-main= c lib/libnet-1.1/net=11
|
||||
WANTLIB-main= c
|
||||
|
||||
LIB_DEPENDS-gui= x11/gtk+2
|
||||
WANTLIB-gui= ${MODGETTEXT_WANTLIB}
|
||||
@ -41,11 +40,12 @@ NO_TEST= Yes
|
||||
MODULES= devel/gettext
|
||||
|
||||
ALL_TARGET= build_all
|
||||
MAKE_FLAGS= CC="${CC}" OS=obsd LIBNET=1
|
||||
MAKE_FLAGS= CC="${CC}" OS=obsd VERBOSE=1
|
||||
.ifdef DEBUG
|
||||
MAKE_FLAGS+= DEBUG=1
|
||||
.else
|
||||
MAKE_FLAGS+= DEBUG=0
|
||||
.endif
|
||||
CPPFLAGS+= "-I${PREFIX}/libnet-1.1"
|
||||
FAKE_FLAGS= SBINDIR=${DESTDIR}/${PREFIX}/sbin \
|
||||
ETCDIR=${DESTDIR}/${PREFIX}/share/examples/olsrd \
|
||||
LIBDIR=${DESTDIR}/${PREFIX}/lib/olsrd-plugins \
|
||||
@ -56,7 +56,7 @@ pre-configure:
|
||||
${SUBST_CMD} ${WRKSRC}/src/plugin_loader.c
|
||||
|
||||
post-build:
|
||||
cd ${WRKSRC}/gui/linux-gtk; ${SETENV} ${MAKE_ENV} ${MAKE_PROGRAM}
|
||||
cd ${WRKSRC}/gui/linux-gtk; ${SETENV} ${MAKE_ENV} ${MAKE_PROGRAM} ${MAKE_FLAGS}
|
||||
|
||||
INSTALL_TARGET= install_all
|
||||
|
||||
|
24
net/olsrd/patches/patch-make_hash_source_sh
Normal file
24
net/olsrd/patches/patch-make_hash_source_sh
Normal file
@ -0,0 +1,24 @@
|
||||
$OpenBSD: patch-make_hash_source_sh,v 1.1 2017/06/20 15:14:10 stsp Exp $
|
||||
|
||||
Index: make/hash_source.sh
|
||||
--- make/hash_source.sh.orig
|
||||
+++ make/hash_source.sh
|
||||
@@ -96,14 +96,16 @@ if [ ! -e "$buildDataTxt" ]; then
|
||||
if [ "$verbose" = "0" ]; then
|
||||
cp -p "$tmpBuildDataTxt" "$buildDataTxt"
|
||||
else
|
||||
- cp -p -v "$tmpBuildDataTxt" "$buildDataTxt"
|
||||
+ echo cp -p "$tmpBuildDataTxt" "$buildDataTxt"
|
||||
+ cp -p "$tmpBuildDataTxt" "$buildDataTxt"
|
||||
fi
|
||||
elif [ -n "$(diff -I "^const char build_date\[\].*\$" "$tmpBuildDataTxt" "$buildDataTxt" | sed 's/"/\\"/g')" ]; then
|
||||
echo "[UPDATE] $buildDataTxt"
|
||||
if [ "$verbose" = "0" ]; then
|
||||
cp -p "$tmpBuildDataTxt" "$buildDataTxt"
|
||||
else
|
||||
- cp -p -v "$tmpBuildDataTxt" "$buildDataTxt"
|
||||
+ echo cp -p "$tmpBuildDataTxt" "$buildDataTxt"
|
||||
+ cp -p "$tmpBuildDataTxt" "$buildDataTxt"
|
||||
fi
|
||||
fi
|
||||
rm -f "$tmpBuildDataTxt"
|
@ -1,4 +1,4 @@
|
||||
$OpenBSD: patch-src_bsd_kernel_routes_c,v 1.2 2017/06/04 11:45:04 stsp Exp $
|
||||
$OpenBSD: patch-src_bsd_kernel_routes_c,v 1.3 2017/06/20 15:14:10 stsp Exp $
|
||||
|
||||
Index: src/bsd/kernel_routes.c
|
||||
--- src/bsd/kernel_routes.c.orig
|
||||
@ -49,7 +49,58 @@ Index: src/bsd/kernel_routes.c
|
||||
|
||||
/* walk to the end of the header */
|
||||
walker = buff + sizeof(struct rt_msghdr);
|
||||
@@ -389,6 +405,9 @@ add_del_route6(const struct rt_entry *rt, int add)
|
||||
@@ -322,13 +338,15 @@ add_del_route6(const struct rt_entry *rt, int add)
|
||||
nexthop = olsr_get_nh(rt);
|
||||
if (0 != (rtm->rtm_flags & RTF_GATEWAY)) {
|
||||
memcpy(&sin6.sin6_addr.s6_addr, &nexthop->gateway.v6, sizeof(struct in6_addr));
|
||||
- memset(&sin6.sin6_addr.s6_addr, 0, 8);
|
||||
- sin6.sin6_addr.s6_addr[0] = 0xfe;
|
||||
- sin6.sin6_addr.s6_addr[1] = 0x80;
|
||||
- sin6.sin6_scope_id = nexthop->iif_index;
|
||||
+ if (IN6_IS_ADDR_LINKLOCAL(&sin6.sin6_addr))
|
||||
+ sin6.sin6_scope_id = nexthop->iif_index;
|
||||
#ifdef __KAME__
|
||||
- *(u_int16_t *) & sin6.sin6_addr.s6_addr[2] = htons(sin6.sin6_scope_id);
|
||||
- sin6.sin6_scope_id = 0;
|
||||
+ if (IN6_IS_ADDR_LINKLOCAL(&sin6.sin6_addr))
|
||||
+ {
|
||||
+ uint16_t tmp16 = htons(sin6.sin6_scope_id);
|
||||
+ memcpy(&sin6.sin6_addr.s6_addr[2], &tmp16, sizeof(uint16_t));
|
||||
+ sin6.sin6_scope_id = 0;
|
||||
+ }
|
||||
#endif /* __KAME__ */
|
||||
memcpy(walker, &sin6, sizeof(sin6));
|
||||
walker += sin_size;
|
||||
@@ -336,22 +354,15 @@ add_del_route6(const struct rt_entry *rt, int add)
|
||||
}
|
||||
else {
|
||||
/*
|
||||
- * Host is directly reachable, so add
|
||||
- * the output interface MAC address.
|
||||
+ * Host is directly reachable, add a cloning route.
|
||||
*/
|
||||
- memcpy(&sin6.sin6_addr.s6_addr, &rt->rt_dst.prefix.v6, sizeof(struct in6_addr));
|
||||
- memset(&sin6.sin6_addr.s6_addr, 0, 8);
|
||||
- sin6.sin6_addr.s6_addr[0] = 0xfe;
|
||||
- sin6.sin6_addr.s6_addr[1] = 0x80;
|
||||
+ sdl.sdl_index = nexthop->iif_index;
|
||||
sin6.sin6_scope_id = nexthop->iif_index;
|
||||
-#ifdef __KAME__
|
||||
- *(u_int16_t *) & sin6.sin6_addr.s6_addr[2] = htons(sin6.sin6_scope_id);
|
||||
- sin6.sin6_scope_id = 0;
|
||||
-#endif /* __KAME__ */
|
||||
- memcpy(walker, &sin6, sizeof(sin6));
|
||||
- walker += sin_size;
|
||||
+ memcpy(walker, &sdl, sizeof(sdl));
|
||||
+ walker += sdl_size;
|
||||
rtm->rtm_addrs |= RTA_GATEWAY;
|
||||
- rtm->rtm_flags |= RTF_GATEWAY;
|
||||
+ rtm->rtm_flags |= RTF_CLONING;
|
||||
+ rtm->rtm_flags &= ~RTF_GATEWAY;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
@@ -389,12 +400,21 @@ add_del_route6(const struct rt_entry *rt, int add)
|
||||
drtm->rtm_index = 0;
|
||||
drtm->rtm_flags = olsr_rt_flags(rt, add);
|
||||
drtm->rtm_seq = ++seq;
|
||||
@ -59,3 +110,15 @@ Index: src/bsd/kernel_routes.c
|
||||
|
||||
walker = dbuff + sizeof(struct rt_msghdr);
|
||||
memcpy(&sin6.sin6_addr.s6_addr, &rt->rt_dst.prefix.v6, sizeof(struct in6_addr));
|
||||
memcpy(walker, &sin6, sizeof(sin6));
|
||||
walker += sin_size;
|
||||
drtm->rtm_addrs = RTA_DST;
|
||||
+ if (0 == (drtm->rtm_flags & RTF_HOST)) {
|
||||
+ olsr_prefix_to_netmask((union olsr_ip_addr *)&sin6.sin6_addr, rt->rt_dst.prefix_len);
|
||||
+ memcpy(walker, &sin6, sizeof(sin6));
|
||||
+ walker += sin_size;
|
||||
+ drtm->rtm_addrs |= RTA_NETMASK;
|
||||
+ }
|
||||
drtm->rtm_msglen = (unsigned short)(walker - dbuff);
|
||||
len = write(olsr_cnf->rts, dbuff, drtm->rtm_msglen);
|
||||
if (len < 0) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
$OpenBSD: patch-src_bsd_net_c,v 1.4 2017/06/04 11:45:04 stsp Exp $
|
||||
$OpenBSD: patch-src_bsd_net_c,v 1.5 2017/06/20 15:14:10 stsp Exp $
|
||||
|
||||
Index: src/bsd/net.c
|
||||
--- src/bsd/net.c.orig
|
||||
@ -47,7 +47,39 @@ Index: src/bsd/net.c
|
||||
#endif /* defined __FreeBSD__ || defined __FreeBSD_kernel__ */
|
||||
|
||||
#ifdef __APPLE__
|
||||
@@ -747,39 +742,12 @@ olsr_select(int nfds, fd_set * readfds, fd_set * write
|
||||
@@ -192,9 +187,17 @@ net_os_set_global_ifoptions(void) {
|
||||
|
||||
/* do not accept ICMP redirects */
|
||||
|
||||
-#if defined(__OpenBSD__) || defined(__NetBSD__)
|
||||
- if (olsr_cnf->ip_version == AF_INET)
|
||||
+#if defined(__OpenBSD__)
|
||||
+ if (olsr_cnf->ip_version == AF_INET) {
|
||||
name = "net.inet.icmp.rediraccept";
|
||||
+ ignore_redir = set_sysctl_int(name, 0);
|
||||
+ } else {
|
||||
+ /* OpenBSD enables icmp6 rediraccept only if IPv6 autoconf is used. */
|
||||
+ ignore_redir = 1;
|
||||
+ }
|
||||
+#elif defined(__NetBSD__)
|
||||
+ if (olsr_cnf->ip_version == AF_INET) {
|
||||
+ name = "net.inet.icmp.rediraccept";
|
||||
else
|
||||
name = "net.inet6.icmp6.rediraccept";
|
||||
|
||||
@@ -341,6 +344,11 @@ getsocket(int bufspace, struct interface_olsr *ifp __a
|
||||
return -1;
|
||||
}
|
||||
|
||||
+ if (setsockopt(sock, IPPROTO_IP, IP_MULTICAST_IF, &ifp->int_addr.sin_addr.s_addr, sizeof(struct in_addr)) < 0) {
|
||||
+ perror("Set multicast if");
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
if(bufspace > 0) {
|
||||
for (on = bufspace;; on -= 1024) {
|
||||
if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char *)&on, sizeof(on)) == 0)
|
||||
@@ -747,39 +755,12 @@ olsr_select(int nfds, fd_set * readfds, fd_set * write
|
||||
int
|
||||
check_wireless_interface(char *ifname)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user