From owner-freebsd-net@FreeBSD.ORG Wed Feb 13 19:51:09 2008 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 010B616A41A; Wed, 13 Feb 2008 19:51:09 +0000 (UTC) (envelope-from rea-fbsd@codelabs.ru) Received: from 0.mx.codelabs.ru (0.mx.codelabs.ru [144.206.177.45]) by mx1.freebsd.org (Postfix) with ESMTP id A8D4713C442; Wed, 13 Feb 2008 19:51:08 +0000 (UTC) (envelope-from rea-fbsd@codelabs.ru) DomainKey-Signature: a=rsa-sha1; q=dns; c=simple; s=one; d=codelabs.ru; h=Received:Date:From:To:Cc:Message-ID:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:Sender:X-Spam-Status:Subject; b=ex1lDHz1S6RS9YnmjKIXCxI2mWp51XzvAPOp1Y+UYCnNbB5TdE4rxwmalmEO51Qc2feLwJ24T2ZHCD20PRLObFiGH4VRJAZiO4cXVtZi/PqUG4Zf8+35jauvQTcP9rBq/tfss4aDVjY+ltMUCQ15Vvj0yHSOvW3/NyscIWHgyyg=; Received: from void.codelabs.ru (void.codelabs.ru [144.206.177.25]) by 0.mx.codelabs.ru with esmtpsa (TLSv1:AES256-SHA:256) id 1JPNdL-0009x0-D4; Wed, 13 Feb 2008 22:51:07 +0300 Date: Wed, 13 Feb 2008 22:51:06 +0300 From: Eygene Ryabinkin To: Josef Pojsl Message-ID: References: <20080207074944.GA56085@bonifac.tns.cz> <20080207141422.GG11393@diehard.n-r-g.com> <20080206144104.GL1122@bonifac.tns.cz> <20080207074944.GA56085@bonifac.tns.cz> <20080208105357.GF1142@bonifac.tns.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: Sender: rea-fbsd@codelabs.ru X-Spam-Status: No, score=-1.9 required=4.0 tests=ALL_TRUSTED,AWL,BAYES_40 Cc: freebsd-net@freebsd.org, farrokhi@FreeBSD.org, Claudio Jeker Subject: Re: ospf cost and route selection (openospfd) X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Feb 2008 19:51:09 -0000 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