From owner-freebsd-net@FreeBSD.ORG Sun Feb 17 17:11:10 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 B0D3216A417; Sun, 17 Feb 2008 17:11:10 +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 31C0913C4F6; Sun, 17 Feb 2008 17:11:09 +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=aR4mBe2Io0hORr3swAMg/Wn8FaHqEMbIEGVFos3RA6tG0iAswzx/EVcescuHwuEmUlZ+au34FMZhCUE5rgAJ3motQnZxNic22lQM95EGwBH3xJiO0Rn0gRChWeU74LZRMyEj17Dd7+ejrGAmkJuiBGuzguiyJNXeoekBClqLwZQ=; Received: from amnesiac.at.no.dns (ppp85-141-160-36.pppoe.mtu-net.ru [85.141.160.36]) by 0.mx.codelabs.ru with esmtpsa (TLSv1:AES256-SHA:256) id 1JQn2g-000GNb-31; Sun, 17 Feb 2008 20:11:06 +0300 Date: Sun, 17 Feb 2008 20:11:04 +0300 From: Eygene Ryabinkin To: Josef Pojsl Message-ID: <5ZtxcL6cRo84tm1uYJcECu4DBCo@49l6neKHPg6j4SHeejH198Klzys> References: <20080206144104.GL1122@bonifac.tns.cz> <20080207074944.GA56085@bonifac.tns.cz> <20080208105357.GF1142@bonifac.tns.cz> <20080213203012.GB1157@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=-2.6 required=4.0 tests=ALL_TRUSTED,AWL,BAYES_00 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: Sun, 17 Feb 2008 17:11:10 -0000 Josef, good day. Thu, Feb 14, 2008 at 06:15:09PM +0300, Eygene Ryabinkin wrote: > > OK, I will up my gifX interfaces and will try to simulate your problem. > > OK, problem recreated. Will try to understand and fix the issue. > Will drop a mail, once the situation will be more clear. > > Thinking, 20%... ;)) I should more carefully study current OpenBSD CVS: the fix for your problem was committed 5 months ago. Claudio mentioned it (and he is the author of the patch itself), but the fix didn't get into 4.2. The funny thing is that I had wrote simular (but lower quality) fix for the problem today and decided to look at the current OpenOSPFD code. And looking at the last revision of ospfd/rde_spf.c I had found calls to calc_nexthop() that were very simular to mine ones ;)) OK, to the point: the inlined patch should go to the 'files' directory, named 'patch-p2p_interfaces'. I assume that all my previous patches to make 4.2 to compile and run were applied. --- begin files/patch-p2p_interfaces --- =================================================================== RCS file: /usr/OpenBSD/cvs/src/usr.sbin/ospfd/rde_spf.c,v retrieving revision 1.63 retrieving revision 1.64 diff -u -r1.63 -r1.64 --- ospfd/rde_spf.c 2007/08/06 11:32:34 1.63 +++ ospfd/rde_spf.c 2007/09/16 15:00:11 1.64 @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_spf.c,v 1.63 2007/08/06 11:32:34 claudio Exp $ */ +/* $OpenBSD: rde_spf.c,v 1.64 2007/09/16 15:00:11 claudio Exp $ */ /* * Copyright (c) 2005 Esben Norby @@ -37,7 +37,8 @@ void calc_nexthop_clear(struct vertex *); void calc_nexthop_add(struct vertex *, struct vertex *, u_int32_t); -void calc_nexthop(struct vertex *, struct vertex *); +void calc_nexthop(struct vertex *, struct vertex *, + struct area *, struct lsa_rtr_link *); void rt_nexthop_clear(struct rt_node *); void rt_nexthop_add(struct rt_node *, struct v_nexthead *, struct in_addr); @@ -134,7 +135,7 @@ if (d < w->cost) { w->cost = d; calc_nexthop_clear(w); - calc_nexthop(w, v); + calc_nexthop(w, v, area, rtr_link); /* * need to readd to candidate list * because the list is sorted @@ -143,12 +144,12 @@ cand_list_add(w); } else /* equal cost path */ - calc_nexthop(w, v); + calc_nexthop(w, v, area, rtr_link); } else if (w->cost == LS_INFINITY && d < LS_INFINITY) { w->cost = d; calc_nexthop_clear(w); - calc_nexthop(w, v); + calc_nexthop(w, v, area, rtr_link); cand_list_add(w); } } @@ -384,54 +385,51 @@ } void -calc_nexthop(struct vertex *dst, struct vertex *parent) +calc_nexthop(struct vertex *dst, struct vertex *parent, + struct area *area, struct lsa_rtr_link *rtr_link) { - struct lsa_rtr_link *rtr_link = NULL; struct v_nexthop *vn; + struct iface *iface; int i; /* case 1 */ if (parent == spf_root) { switch (dst->type) { case LSA_TYPE_ROUTER: - for (i = 0; i < lsa_num_links(dst); i++) { - rtr_link = get_rtr_link(dst, i); - if (rtr_link->type == LINK_TYPE_POINTTOPOINT && - ntohl(rtr_link->id) == parent->ls_id) { + if (rtr_link->type != LINK_TYPE_POINTTOPOINT) + fatalx("inconsistent SPF tree"); + LIST_FOREACH(iface, &area->iface_list, entry) { + if (rtr_link->data == iface->addr.s_addr) { calc_nexthop_add(dst, parent, - rtr_link->data); - break; + iface->dst.s_addr); + return; } } - return; + fatalx("no interface found for interface"); case LSA_TYPE_NETWORK: - for (i = 0; i < lsa_num_links(parent); i++) { - rtr_link = get_rtr_link(parent, i); - switch (rtr_link->type) { - case LINK_TYPE_POINTTOPOINT: - /* ignore */ - break; - case LINK_TYPE_TRANSIT_NET: - if ((htonl(dst->ls_id) & - dst->lsa->data.net.mask) == - (rtr_link->data & - dst->lsa->data.net.mask)) { - calc_nexthop_add(dst, parent, - rtr_link->data); - } - break; - case LINK_TYPE_STUB_NET: - break; - - default: - fatalx("calc_nexthop: invalid link " - "type"); + switch (rtr_link->type) { + case LINK_TYPE_POINTTOPOINT: + case LINK_TYPE_STUB_NET: + /* ignore */ + break; + case LINK_TYPE_TRANSIT_NET: + if ((htonl(dst->ls_id) & + dst->lsa->data.net.mask) == + (rtr_link->data & + dst->lsa->data.net.mask)) { + calc_nexthop_add(dst, parent, + rtr_link->data); } + break; + default: + fatalx("calc_nexthop: invalid link " + "type"); } return; default: fatalx("calc_nexthop: invalid dst type"); } + return; } /* case 2 */ @@ -459,7 +457,7 @@ /* case 3 */ TAILQ_FOREACH(vn, &parent->nexthop, entry) - calc_nexthop_add(dst, parent, vn->nexthop.s_addr); + calc_nexthop_add(dst, parent, vn->nexthop.s_addr); } /* candidate list */ --- end files/patch-p2p_interfaces --- Please, test it. I had tested it on my lab setup with three gifX interfaces between two hosts and it seems to work correctly in many cases. If things will be fine, I think I'll open PR to bump OpenOSPFD port to 4.2, if it was not already opened. Thanks for your patience! -- Eygene