summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2007-10-09 06:17:41 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2007-10-09 06:17:41 +0000
commitc9f9203edf9f32a6ebf3f0f1407751437b1ac315 (patch)
tree8bf26e133b1be28f9cffb3687336ee28c8cc4aac
parentd89be5ff25e1957448fcfdffd40c6b46b353c77d (diff)
Instead of IP_RECVIF we use IPV6_RECVPKTINFO to get the ifindex and the
destination address of incomming packets. This also removes the need for IP_HDRINCL. Additionally use IPV6_CHECKSUM to let the kernel do the necessary packet checksumming, way easier than doing it in userland. OK norby@
-rw-r--r--usr.sbin/ospf6d/interface.c41
-rw-r--r--usr.sbin/ospf6d/ospfe.c11
-rw-r--r--usr.sbin/ospf6d/ospfe.h6
3 files changed, 28 insertions, 30 deletions
diff --git a/usr.sbin/ospf6d/interface.c b/usr.sbin/ospf6d/interface.c
index be415114742..a818ae74996 100644
--- a/usr.sbin/ospf6d/interface.c
+++ b/usr.sbin/ospf6d/interface.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: interface.c,v 1.1 2007/10/08 10:44:50 norby Exp $ */
+/* $OpenBSD: interface.c,v 1.2 2007/10/09 06:17:40 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -27,6 +27,7 @@
#include <net/if_types.h>
#include <ctype.h>
#include <err.h>
+#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -654,19 +655,6 @@ if_to_ctl(struct iface *iface)
}
/* misc */
-int
-if_set_recvif(int fd, int enable)
-{
-#if 0
- if (setsockopt(fd, IPPROTO_IPV6, IP_RECVIF, &enable,
- sizeof(enable)) < 0) {
- log_warn("if_set_recvif: error setting IP_RECVIF");
- return (-1);
- }
-#endif
- return (0);
-}
-
void
if_set_recvbuf(int fd)
{
@@ -788,16 +776,27 @@ if_set_mcast_loop(int fd)
}
int
-if_set_ip_hdrincl(int fd)
+if_set_ipv6_pktinfo(int fd, int enable)
+{
+ if (setsockopt(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, &enable,
+ sizeof(enable)) < 0) {
+ log_warn("if_set_ipv6_pktinfo: error setting IPV6_PKTINFO");
+ return (-1);
+ }
+
+ return (0);
+}
+
+int
+if_set_ipv6_checksum(int fd)
{
-#if 0
- int hincl = 1;
+ int offset = offsetof(struct ospf_hdr, chksum);
- if (setsockopt(fd, IPPROTO_IPV6, IP_HDRINCL, &hincl,
- sizeof(hincl)) < 0) {
- log_warn("if_set_ip_hdrincl: error setting IP_HDRINCL");
+ log_debug("if_set_ipv6_checksum setting cksum offset to %i", offset);
+ if (setsockopt(fd, IPPROTO_IPV6, IPV6_CHECKSUM, &offset,
+ sizeof(offset)) < 0) {
+ log_warn("if_set_ipv6_checksum: error setting IPV6_CHECKSUM");
return (-1);
}
-#endif
return (0);
}
diff --git a/usr.sbin/ospf6d/ospfe.c b/usr.sbin/ospf6d/ospfe.c
index 9b09c98ea6e..05f3efca95d 100644
--- a/usr.sbin/ospf6d/ospfe.c
+++ b/usr.sbin/ospf6d/ospfe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfe.c,v 1.1 2007/10/08 10:44:50 norby Exp $ */
+/* $OpenBSD: ospfe.c,v 1.2 2007/10/09 06:17:40 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -100,10 +100,10 @@ ospfe(struct ospfd_conf *xconf, int pipe_parent2ospfe[2], int pipe_ospfe2rde[2],
/* set some defaults */
if (if_set_mcast_loop(xconf->ospf_socket) == -1)
fatal("if_set_mcast_loop");
- if (if_set_ip_hdrincl(xconf->ospf_socket) == -1)
- fatal("if_set_ip_hdrincl");
- if (if_set_recvif(xconf->ospf_socket, 1) == -1)
- fatal("if_set_recvif");
+ if (if_set_ipv6_checksum(xconf->ospf_socket) == -1)
+ fatal("if_set_ipv6_checksum");
+ if (if_set_ipv6_pktinfo(xconf->ospf_socket, 1) == -1)
+ fatal("if_set_ipv6_pktinfo");
if_set_recvbuf(xconf->ospf_socket);
oeconf = xconf;
@@ -183,7 +183,6 @@ ospfe(struct ospfd_conf *xconf, int pipe_parent2ospfe[2], int pipe_ospfe2rde[2],
ospfe_demote_area(area, 0);
LIST_FOREACH(iface, &area->iface_list, entry) {
if_init(xconf, iface);
- log_debug("fire up the barbeque on %s", iface->name);
if (if_fsm(iface, IF_EVT_UP)) {
log_debug("error starting interface %s",
iface->name);
diff --git a/usr.sbin/ospf6d/ospfe.h b/usr.sbin/ospf6d/ospfe.h
index ccbe153ae4e..6629dd07a4b 100644
--- a/usr.sbin/ospf6d/ospfe.h
+++ b/usr.sbin/ospf6d/ospfe.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfe.h,v 1.1 2007/10/08 10:44:50 norby Exp $ */
+/* $OpenBSD: ospfe.h,v 1.2 2007/10/09 06:17:40 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -140,10 +140,10 @@ struct ctl_iface *if_to_ctl(struct iface *);
int if_join_group(struct iface *, struct in6_addr *);
int if_leave_group(struct iface *, struct in6_addr *);
int if_set_mcast(struct iface *);
-int if_set_recvif(int, int);
void if_set_recvbuf(int);
int if_set_mcast_loop(int);
-int if_set_ip_hdrincl(int);
+int if_set_ipv6_pktinfo(int, int);
+int if_set_ipv6_checksum(int);
/* lsack.c */
int delay_lsa_ack(struct iface *, struct lsa_hdr *);