Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Feb 2008 22:51:06 +0300
From:      Eygene Ryabinkin <rea-fbsd@codelabs.ru>
To:        Josef Pojsl <jp@tns.cz>
Cc:        freebsd-net@freebsd.org, farrokhi@FreeBSD.org, Claudio Jeker <cjeker@diehard.n-r-g.com>
Subject:   Re: ospf cost and route selection (openospfd)
Message-ID:  <mypgUDm3r88tl8BUtVK5EhYBPbg@Bd%2BEULvHKHKS9B%2B4wiqjGz6/WOE>
In-Reply-To: <BT4TiDDxXXg%2BA3Hm/RZG4ajuso0@iW7JDlNxJglv8iYoJTWnPBJ0iaQ>
References:  <jV/l2UkZT%2BCCNuE6npJv1SBs5CE@UCvaDHSF%2BGDEPQ7TSpdR%2BlgUSQM> <20080207074944.GA56085@bonifac.tns.cz> <20080207141422.GG11393@diehard.n-r-g.com> <20080206144104.GL1122@bonifac.tns.cz> <jV/l2UkZT%2BCCNuE6npJv1SBs5CE@UCvaDHSF%2BGDEPQ7TSpdR%2BlgUSQM> <20080207074944.GA56085@bonifac.tns.cz> <Ntfg81bhcEB6BPmKzMb2iTN9oBA@ebJhc%2B9glC7W5vxxBJVH9quBZr0> <BeIqwBu0LkRXuGRr9c834oJe11M@mkgs2gFQr6GPddtmfyJSxMBvIxA> <20080208105357.GF1142@bonifac.tns.cz> <BT4TiDDxXXg%2BA3Hm/RZG4ajuso0@iW7JDlNxJglv8iYoJTWnPBJ0iaQ>

next in thread | previous in thread | raw e-mail | index | archive | help
Wed, Feb 13, 2008 at 10:37:29PM +0300, Eygene Ryabinkin wrote:
> Attached is the modified patch for the port itself and the modified
> file 'files/patch-ospfd_packet.c': it is the only changed file from
> the previous version of my patch.  So, if you had already patched
> the port to 4.2 with previous version, just drop patch-ospfd_packet.c
> into the 'files/' directory and rebuild the patch.

Seems like new files/patch-ospfd_packet.c did not get through the
Mailman.  Attaching inline:
-----
--- ospfd/packet.c.orig	2006-11-17 11:55:31.000000000 +0300
+++ ospfd/packet.c	2008-02-13 22:13:04.000000000 +0300
@@ -36,7 +36,7 @@
 #include "log.h"
 #include "ospfe.h"
 
-int		 ip_hdr_sanity_check(const struct ip *, u_int16_t);
+int		 ip_hdr_sanity_check(struct ip *, u_int16_t);
 int		 ospf_hdr_sanity_check(const struct ip *,
 		    struct ospf_hdr *, u_int16_t, const struct iface *);
 struct iface	*find_iface(struct ospfd_conf *, unsigned int, struct in_addr);
@@ -70,7 +70,12 @@
 	ip_hdr.ip_v = IPVERSION;
 	ip_hdr.ip_hl = sizeof(ip_hdr) >> 2;
 	ip_hdr.ip_tos = IPTOS_PREC_INTERNETCONTROL;
+#if defined(__FreeBSD__) || defined(__NetBSD__)
+	/* FreeBSD/NetBSD wants the length in the native host byte order. */
+	ip_hdr.ip_len = len + sizeof(ip_hdr);
+#else
 	ip_hdr.ip_len = htons(len + sizeof(ip_hdr));
+#endif
 	ip_hdr.ip_id = 0;  /* 0 means kernel set appropriate value */
 	ip_hdr.ip_off = 0;
 	ip_hdr.ip_ttl = iface->type != IF_TYPE_VIRTUALLINK ?
@@ -248,8 +253,13 @@
 }
 
 int
-ip_hdr_sanity_check(const struct ip *ip_hdr, u_int16_t len)
+ip_hdr_sanity_check(struct ip *ip_hdr, u_int16_t len)
 {
+#if defined(__NetBSD__) || defined(__FreeBSD__)
+	/* FreeBSD and NetBSD modify the IP header. Undo it! */
+	ip_hdr->ip_len = htons(ip_hdr->ip_len + (ip_hdr->ip_hl << 2));
+#endif
+
 	if (ntohs(ip_hdr->ip_len) != len) {
 		log_debug("recv_packet: invalid IP packet length %u",
 		    ntohs(ip_hdr->ip_len));
-----
-- 
Eygene



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?mypgUDm3r88tl8BUtVK5EhYBPbg>