ports/120788: update ports/net/openospfd to 4.2 and fix multiple p2p interfaces problem
Eygene Ryabinkin
rea-fbsd at codelabs.ru
Mon Feb 18 11:50:04 UTC 2008
>Number: 120788
>Category: ports
>Synopsis: update ports/net/openospfd to 4.2 and fix multiple p2p interfaces problem
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: update
>Submitter-Id: current-users
>Arrival-Date: Mon Feb 18 11:50:03 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator: Eygene Ryabinkin
>Release: FreeBSD 7.0-PRERELEASE i386
>Organization:
Code Labs
>Environment:
System: FreeBSD XXX 7.0-PRERELEASE FreeBSD 7.0-PRERELEASE #15: Wed Jan 30 19:24:48 MSK 2008 root at XXX:/usr/obj/usr/src/sys/XXX i386
>Description:
OpenOSPFD 4.2 is out at October 7th 2007 [1]. FreeBSD port is still
at 4.0. Moreover, there are problems with multiple point-to-point
interfaces selection logic in both 4.0 and 4.2 [2]. A fix was
committed to the OpenBSD CVS [3], but it didn't get into 4.2.
[1] ftp://ftp.openbsd.org/pub/OpenBSD/OpenBGPD/
[2] http://lists.freebsd.org/pipermail/freebsd-net/2008-February/016718.html
[3] http://www.openbsd.org/cgi-bin/cvsweb/src/usr.sbin/ospfd/rde_spf.c?rev=1.64&content-type=text/x-cvsweb-markup
>How-To-Repeat:
Look at the reference [1] and read the thread starting with [2].
>Fix:
The following patches will update the port to 4.2 and fix the issue
with p2p interfaces. They received a limited testing by me
and Josef Pojsl: look into the thread [2] starting with
http://lists.freebsd.org/pipermail/freebsd-net/2008-February/016835.html
First patch, just to make OpenOSPFD 4.2 work on FreeBSD.
--- 4.0-to-4.2.patch begins here ---
>From c983b8cc45e3e95991479ae6e213e1ee805c3d91 Mon Sep 17 00:00:00 2001
From: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
Date: Thu, 7 Feb 2008 19:19:54 +0300
o Provide LINK_STATE_IS_UP macros that is missing in FreeBSD.
o Disable CARP demotion: FreeBSD has no support for it.
o Disable check for the routing table number: FreeBSD has
single routing table now.
o Disable route labeling: FreeBSD has no support for it.
o Disable htons() for IP header length: FreeBSD wants it to
be in the native host order.
o Rewrite old patch for the ospfctl/parser.{c,h}.
Signed-off-by: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
---
Makefile | 3 +-
distinfo | 6 +-
files/patch-LINK_STATE_IS_UP | 13 ++++
files/patch-no_carp_demotion | 91 +++++++++++++++++++++++++++
files/patch-ospfctl_parser | 59 ++++++++++++++++++
files/patch-ospfctl_parser.c | 26 --------
files/patch-ospfctl_parser.h | 26 --------
files/patch-ospfd_kroute.c | 138 ++++++++++++++++++++++++++++++++++++------
files/patch-ospfd_packet.c | 23 ++++++--
9 files changed, 304 insertions(+), 81 deletions(-)
create mode 100644 files/patch-LINK_STATE_IS_UP
create mode 100644 files/patch-no_carp_demotion
create mode 100644 files/patch-ospfctl_parser
delete mode 100644 files/patch-ospfctl_parser.c
delete mode 100644 files/patch-ospfctl_parser.h
diff --git a/Makefile b/Makefile
index 4423454..777f71b 100644
--- a/Makefile
+++ b/Makefile
@@ -6,8 +6,7 @@
#
PORTNAME= openospfd
-PORTVERSION= 4.0
-PORTREVISION= 2
+PORTVERSION= 4.2
CATEGORIES= net
MASTER_SITES= ftp://ftp.dkuug.dk/pub/OpenBSD/OpenBGPD/:openbsd \
${MASTER_SITE_LOCAL:S/$/:freebsd/g}
diff --git a/distinfo b/distinfo
index 84810c8..bf2bc20 100644
--- a/distinfo
+++ b/distinfo
@@ -1,6 +1,6 @@
-MD5 (openospfd/openospfd-4.0.tgz) = 6dcf9170627120f009ff9d5917b49376
-SHA256 (openospfd/openospfd-4.0.tgz) = c9e87e849664a6674a4a650a453754b53d6c0bd1110ee5e82a7b6cc7fbad6ee7
-SIZE (openospfd/openospfd-4.0.tgz) = 84459
+MD5 (openospfd/openospfd-4.2.tgz) = ac919e4883105b28a846106e7c60bb80
+SHA1 (openospfd/openospfd-4.2.tgz) = ebb476d834d3aa5ddc3a5e96ea2f494f2617c393
+SIZE (openospfd/openospfd-4.2.tgz) = 93661
MD5 (openospfd/if_media.h) = 4ff9297f5c133425dafe3ca565c0f811
SHA256 (openospfd/if_media.h) = 58225d0ed363c2beb23426f0f8254089d4541c3334776f3750ba434d4491a1d1
SIZE (openospfd/if_media.h) = 23762
diff --git a/files/patch-LINK_STATE_IS_UP b/files/patch-LINK_STATE_IS_UP
new file mode 100644
index 0000000..bcd1f6d
--- /dev/null
+++ b/files/patch-LINK_STATE_IS_UP
@@ -0,0 +1,13 @@
+--- ospfd/ospfd.h.orig 2008-02-07 18:57:03.000000000 +0300
++++ ospfd/ospfd.h 2008-02-07 18:56:54.000000000 +0300
+@@ -320,6 +320,10 @@
+ TAILQ_HEAD(lsa_head, lsa_entry);
+ TAILQ_HEAD(auth_md_head, auth_md);
+
++#if defined(__FreeBSD__) /* FreeBSD has no LINK_STATE_IS_UP macro. */
++#define LINK_STATE_IS_UP(_s) ((_s) >= LINK_STATE_UP)
++#endif /* defined(__FreeBSD__) */
++
+ struct iface {
+ LIST_ENTRY(iface) entry;
+ struct event hello_timer;
diff --git a/files/patch-no_carp_demotion b/files/patch-no_carp_demotion
new file mode 100644
index 0000000..2882279
--- /dev/null
+++ b/files/patch-no_carp_demotion
@@ -0,0 +1,91 @@
+--- ospfd/ospfd.c.orig 2008-02-07 18:31:27.000000000 +0300
++++ ospfd/ospfd.c 2008-02-07 18:41:46.000000000 +0300
+@@ -300,7 +300,9 @@
+
+ control_cleanup();
+ kr_shutdown();
++#if !defined(__FreeBSD__) /* XXX: FreeBSD has no carp demotion. */
+ carp_demote_shutdown();
++#endif /* defined(__FreeBSD__) */
+
+ do {
+ if ((pid = wait(NULL)) == -1 &&
+@@ -398,10 +400,14 @@
+ log_warnx("IFINFO request with wrong len");
+ break;
+ case IMSG_DEMOTE:
++#if !defined(__FreeBSD__) /* XXX: FreeBSD has no carp demotion support. */
+ if (imsg.hdr.len - IMSG_HEADER_SIZE != sizeof(dmsg))
+ fatalx("invalid size of OE request");
+ memcpy(&dmsg, imsg.data, sizeof(dmsg));
+ carp_demote_set(dmsg.demote_group, dmsg.level);
++#else
++ log_debug("main_dispatch_ospfe: no carp demotion support for FreeBSD");
++#endif /* defined(__FreeBSD__) */
+ break;
+ default:
+ log_debug("main_dispatch_ospfe: error handling imsg %d",
+--- ospfd/carp.c.orig 2008-02-07 18:26:32.000000000 +0300
++++ ospfd/carp.c 2008-02-07 18:39:58.000000000 +0300
+@@ -29,6 +29,13 @@
+ #include "ospfd.h"
+ #include "log.h"
+
++#if defined(__FreeBSD__) /* XXX: FreeBSD has no CARP demotion support */
++
++#warning "CARP demotion is not supported for FreeBSD."
++#warning "Demotion code is disconnected from the build."
++
++#else
++
+ struct carpgroup {
+ TAILQ_ENTRY(carpgroup) entry;
+ char *group;
+@@ -179,3 +186,5 @@
+ close(s);
+ return (res);
+ }
++
++#endif /* defined(__FreeBSD__) */
+--- ospfd/parse.y.orig 2008-02-07 18:34:22.000000000 +0300
++++ ospfd/parse.y 2008-02-07 18:37:46.000000000 +0300
+@@ -485,6 +485,11 @@
+
+ areaoptsl : interface
+ | DEMOTE STRING demotecount {
++#ifdef __FreeBSD__ /* XXX: FreeBSD has no carp demotion support. */
++ yyerror("FreeBSD has no CARP demotion support");
++ free($2);
++ YYERROR;
++#else
+ if ($3 > 255) {
+ yyerror("demote count too big: max 255");
+ free($2);
+@@ -505,6 +510,7 @@
+ area->demote_group);
+ YYERROR;
+ }
++#endif
+ }
+ | defaults
+ ;
+@@ -581,6 +587,11 @@
+
+ interfaceoptsl : PASSIVE { iface->passive = 1; }
+ | DEMOTE STRING {
++#ifdef __FreeBSD__ /* XXX: FreeBSD has no carp demotion support */
++ yyerror("FreeBSD has no CARP demotion support");
++ free($2);
++ YYERROR;
++#else
+ if (strlcpy(iface->demote_group, $2,
+ sizeof(iface->demote_group)) >=
+ sizeof(iface->demote_group)) {
+@@ -595,6 +606,7 @@
+ iface->demote_group);
+ YYERROR;
+ }
++#endif
+ }
+ | defaults
+ ;
diff --git a/files/patch-ospfctl_parser b/files/patch-ospfctl_parser
new file mode 100644
index 0000000..1d0a82c
--- /dev/null
+++ b/files/patch-ospfctl_parser
@@ -0,0 +1,59 @@
+--- ospfctl/parser.c.orig 2008-02-07 19:13:50.000000000 +0300
++++ ospfctl/parser.c 2008-02-07 19:15:47.000000000 +0300
+@@ -32,23 +32,6 @@
+
+ #include "parser.h"
+
+-enum token_type {
+- NOTOKEN,
+- ENDTOKEN,
+- KEYWORD,
+- ADDRESS,
+- FLAG,
+- PREFIX,
+- IFNAME
+-};
+-
+-struct token {
+- enum token_type type;
+- const char *keyword;
+- int value;
+- const struct token *next;
+-};
+-
+ static const struct token t_main[];
+ static const struct token t_fib[];
+ static const struct token t_show[];
+--- ospfctl/parser.h.orig 2008-02-07 19:12:58.000000000 +0300
++++ ospfctl/parser.h 2008-02-07 19:15:45.000000000 +0300
+@@ -50,6 +50,16 @@
+ RELOAD
+ };
+
++enum token_type {
++ NOTOKEN,
++ ENDTOKEN,
++ KEYWORD,
++ ADDRESS,
++ FLAG,
++ PREFIX,
++ IFNAME
++};
++
+ struct parse_result {
+ struct in_addr addr;
+ char ifname[IF_NAMESIZE];
+@@ -58,6 +68,13 @@
+ u_int8_t prefixlen;
+ };
+
++struct token {
++ enum token_type type;
++ const char *keyword;
++ int value;
++ const struct token *next;
++};
++
+ struct parse_result *parse(int, char *[]);
+ const struct token *match_token(const char *, const struct token []);
+ void show_valid_args(const struct token []);
diff --git a/files/patch-ospfctl_parser.c b/files/patch-ospfctl_parser.c
deleted file mode 100644
index c4f7fc8..0000000
--- a/files/patch-ospfctl_parser.c
+++ /dev/null
@@ -1,26 +0,0 @@
---- ospfctl/parser.c.orig Fri Jul 27 15:11:46 2007
-+++ ospfctl/parser.c Fri Jul 27 15:12:01 2007
-@@ -32,23 +32,6 @@
-
- #include "parser.h"
-
--enum token_type {
-- NOTOKEN,
-- ENDTOKEN,
-- KEYWORD,
-- ADDRESS,
-- FLAG,
-- PREFIX,
-- IFNAME
--};
--
--struct token {
-- enum token_type type;
-- const char *keyword;
-- int value;
-- const struct token *next;
--};
--
- static const struct token t_main[];
- static const struct token t_fib[];
- static const struct token t_show[];
diff --git a/files/patch-ospfctl_parser.h b/files/patch-ospfctl_parser.h
deleted file mode 100644
index b4eab49..0000000
--- a/files/patch-ospfctl_parser.h
+++ /dev/null
@@ -1,26 +0,0 @@
---- ospfctl/parser.h.orig Fri Jul 27 15:11:55 2007
-+++ ospfctl/parser.h Fri Jul 27 15:12:01 2007
-@@ -50,6 +50,23 @@
- RELOAD
- };
-
-+enum token_type {
-+ NOTOKEN,
-+ ENDTOKEN,
-+ KEYWORD,
-+ ADDRESS,
-+ FLAG,
-+ PREFIX,
-+ IFNAME
-+};
-+
-+struct token {
-+ enum token_type type;
-+ const char *keyword;
-+ int value;
-+ const struct token *next;
-+};
-+
- struct parse_result {
- struct in_addr addr;
- char ifname[IF_NAMESIZE];
diff --git a/files/patch-ospfd_kroute.c b/files/patch-ospfd_kroute.c
index 6415a3b..2b1bd77 100644
--- a/files/patch-ospfd_kroute.c
+++ b/files/patch-ospfd_kroute.c
@@ -1,36 +1,136 @@
---- ospfd/kroute.c.orig Mon Nov 20 14:41:22 2006
-+++ ospfd/kroute.c Mon Nov 20 14:42:17 2006
-@@ -875,10 +875,6 @@
+--- ospfd/kroute.c.orig 2008-02-07 18:58:38.000000000 +0300
++++ ospfd/kroute.c 2008-02-07 19:09:58.000000000 +0300
+@@ -955,9 +955,11 @@
+ struct sockaddr_in prefix;
+ struct sockaddr_in nexthop;
+ struct sockaddr_in mask;
++#if !defined(__FreeBSD__)
+ struct sockaddr_rtlabel sa_rl;
+- int iovcnt = 0;
+ const char *label;
++#endif /* !defined(__FreeBSD__) */
++ int iovcnt = 0;
+
+ if (kr_state.fib_sync == 0)
+ return (0);
+@@ -1011,6 +1013,7 @@
+ iov[iovcnt].iov_base = &mask;
+ iov[iovcnt++].iov_len = sizeof(mask);
+
++#if !defined(__FreeBSD__) /* FreeBSD has no route labeling. */
+ if (kroute->rtlabel != 0) {
+ sa_rl.sr_len = sizeof(sa_rl);
+ sa_rl.sr_family = AF_UNSPEC;
+@@ -1027,6 +1030,7 @@
+ iov[iovcnt].iov_base = &sa_rl;
+ iov[iovcnt++].iov_len = sizeof(sa_rl);
+ }
++#endif /* !defined(__FreeBSD__) */
+
+
+ retry:
+@@ -1069,7 +1073,9 @@
+ struct rt_msghdr *rtm;
+ struct sockaddr *sa, *rti_info[RTAX_MAX];
+ struct sockaddr_in *sa_in;
++#if !defined(__FreeBSD__)
+ struct sockaddr_rtlabel *label;
++#endif
+ struct kroute_node *kr;
+
+ mib[0] = CTL_NET;
+@@ -1078,9 +1084,13 @@
+ mib[3] = AF_INET;
+ mib[4] = NET_RT_DUMP;
+ mib[5] = 0;
++#if !defined(__FreeBSD__) /* FreeBSD has no multiple routing tables */
+ mib[6] = 0; /* rtableid */
+
+ if (sysctl(mib, 7, NULL, &len, NULL, 0) == -1) {
++#else
++ if (sysctl(mib, 6, NULL, &len, NULL, 0) == -1) {
++#endif /* !defined(__FreeBSD__) */
+ log_warn("sysctl");
+ return (-1);
+ }
+@@ -1098,7 +1098,11 @@
+ log_warn("fetchtable");
+ return (-1);
+ }
++#if !defined(__FreeBSD__) /* FreeBSD has no multiple routing tables */
+ if (sysctl(mib, 7, buf, &len, NULL, 0) == -1) {
++#else
++ if (sysctl(mib, 6, buf, &len, NULL, 0) == -1) {
++#endif /* !defined(__FreeBSD__) */
+ log_warn("sysctl");
+ free(buf);
+ return (-1);
+@@ -1157,6 +1163,7 @@
send_rtmsg(kr_state.fd, RTM_DELETE, &kr->r);
free(kr);
} else {
-- if ((label = (struct sockaddr_rtlabel *)
-- rti_info[RTAX_LABEL]) != NULL)
-- kr->r.rtlabel =
-- rtlabel_name2id(label->sr_label);
++#if !defined(__FreeBSD__) /* FreeBSD has no route labeling. */
+ if ((label = (struct sockaddr_rtlabel *)
+ rti_info[RTAX_LABEL]) != NULL) {
+ kr->r.rtlabel =
+@@ -1164,6 +1171,7 @@
+ kr->r.ext_tag =
+ rtlabel_id2tag(kr->r.rtlabel);
+ }
++#endif /* !defined(__FreeBSD__) */
kroute_insert(kr);
}
-@@ -1075,10 +1071,6 @@
+@@ -1257,7 +1265,9 @@
+ struct ifa_msghdr *ifam;
+ struct sockaddr *sa, *rti_info[RTAX_MAX];
+ struct sockaddr_in *sa_in;
++#if !defined(__FreeBSD__)
+ struct sockaddr_rtlabel *label;
++#endif /* !defined(__FreeBSD__) */
+ struct kroute_node *kr, *okr;
+ struct in_addr prefix, nexthop;
+ u_int8_t prefixlen;
+@@ -1289,8 +1299,10 @@
+ sa = (struct sockaddr *)(rtm + 1);
+ get_rtaddrs(rtm->rtm_addrs, sa, rti_info);
++#if !defined(__FreeBSD__) /* XXX: FreeBSD has no multiple routing tables */
+ if (rtm->rtm_tableid != 0)
+ continue;
++#endif
+
+ if (rtm->rtm_pid == kr_state.pid) /* caused by us */
+ continue;
+@@ -1385,6 +1397,7 @@
rtlabel_unref(kr->r.rtlabel);
kr->r.rtlabel = 0;
-- if ((label = (struct sockaddr_rtlabel *)
-- rti_info[RTAX_LABEL]) != NULL)
-- kr->r.rtlabel =
-- rtlabel_name2id(label->sr_label);
+ kr->r.ext_tag = 0;
++#if !defined(__FreeBSD__) /* FreeBSD has no route labeling. */
+ if ((label = (struct sockaddr_rtlabel *)
+ rti_info[RTAX_LABEL]) != NULL) {
+ kr->r.rtlabel =
+@@ -1392,6 +1405,7 @@
+ kr->r.ext_tag =
+ rtlabel_id2tag(kr->r.rtlabel);
+ }
++#endif /* !defined(__FreeBSD__) */
if (kif_validate(kr->r.ifindex))
kr->r.flags &= ~F_DOWN;
-@@ -1098,11 +1090,6 @@
- kr->r.nexthop.s_addr = nexthop.s_addr;
+@@ -1413,6 +1427,7 @@
kr->r.flags = flags;
kr->r.ifindex = ifindex;
--
-- if ((label = (struct sockaddr_rtlabel *)
-- rti_info[RTAX_LABEL]) != NULL)
-- kr->r.rtlabel =
-- rtlabel_name2id(label->sr_label);
+
++#if !defined(__FreeBSD__) /* FreeBSD has no route labeling */
+ if ((label = (struct sockaddr_rtlabel *)
+ rti_info[RTAX_LABEL]) != NULL) {
+ kr->r.rtlabel =
+@@ -1420,6 +1435,7 @@
+ kr->r.ext_tag =
+ rtlabel_id2tag(kr->r.rtlabel);
+ }
++#endif /* !defined(__FreeBSD__) */
kroute_insert(kr);
}
diff --git a/files/patch-ospfd_packet.c b/files/patch-ospfd_packet.c
index 414554a..cceb302 100644
--- a/files/patch-ospfd_packet.c
+++ b/files/patch-ospfd_packet.c
@@ -1,6 +1,6 @@
---- ospfd/packet.c.orig 9 Mar 2006 13:31:57 -0000 1.20
-+++ ospfd/packet.c 16 Mar 2006 18:21:38 -0000
-@@ -34,7 +34,7 @@
+--- 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"
@@ -8,8 +8,21 @@
+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 *, struct in_addr);
-@@ -196,8 +196,13 @@ recv_packet(int fd, short event, void *b
+ 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
--
1.5.3.8
--- 4.0-to-4.2.patch ends here ---
Patch from OpenBSD CVS that cures point-to-point interfaces selection
logics:
--- 4.2-p2p_interfaces begins here ---
>From 64d437bb476f5f4bb4716abd181289882a8378fa Mon Sep 17 00:00:00 2001
From: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
Date: Mon, 18 Feb 2008 14:29:16 +0300
Subject: [PATCH] Add patch that fixes selection logic for multiple p2p interfaces.
In the original code, the first point-to-point interface on this
router was chosen for the nexthop calculations, no matter what was
the cost for this interface. This was fixed in the upstream
repository, in rde_spf.c, version 1.64.
Patch from http://www.openbsd.org/cgi-bin/cvsweb/src/usr.sbin/ospfd/rde_spf.c.diff?r1=1.63&r2=1.64
Signed-off-by: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
---
files/patch-p2p_interfaces | 138 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 138 insertions(+), 0 deletions(-)
create mode 100644 files/patch-p2p_interfaces
diff --git a/files/patch-p2p_interfaces b/files/patch-p2p_interfaces
new file mode 100644
index 0000000..d626fd4
--- /dev/null
+++ b/files/patch-p2p_interfaces
@@ -0,0 +1,138 @@
+===================================================================
+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 <norby at openbsd.org>
+@@ -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 */
--
1.5.3.8
--- 4.2-p2p_interfaces ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list