Update to 4.2
PR: 120788 Submitted by: Eygene Ryabinkin <rea-fbsd@codelabs.ru> Tested by: Doichin Dokov <root@net1.cc> Approved by: maintainer timeout
This commit is contained in:
parent
c07b463efd
commit
86cd978706
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=223467
11 changed files with 393 additions and 37 deletions
|
@ -6,8 +6,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
PORTNAME= openospfd
|
PORTNAME= openospfd
|
||||||
PORTVERSION= 4.0
|
PORTVERSION= 4.2
|
||||||
PORTREVISION= 3
|
|
||||||
CATEGORIES= net
|
CATEGORIES= net
|
||||||
MASTER_SITES= ftp://ftp.dkuug.dk/pub/OpenBSD/OpenBGPD/:openbsd \
|
MASTER_SITES= ftp://ftp.dkuug.dk/pub/OpenBSD/OpenBGPD/:openbsd \
|
||||||
${MASTER_SITE_LOCAL:S/$/:freebsd/g}
|
${MASTER_SITE_LOCAL:S/$/:freebsd/g}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
MD5 (openospfd/openospfd-4.0.tgz) = 6dcf9170627120f009ff9d5917b49376
|
MD5 (openospfd/openospfd-4.2.tgz) = ac919e4883105b28a846106e7c60bb80
|
||||||
SHA256 (openospfd/openospfd-4.0.tgz) = c9e87e849664a6674a4a650a453754b53d6c0bd1110ee5e82a7b6cc7fbad6ee7
|
SHA256 (openospfd/openospfd-4.2.tgz) = 896a9e29447d7da46a1c7c1717e1527b3770425840e8f0180419ec313d3d7b00
|
||||||
SIZE (openospfd/openospfd-4.0.tgz) = 84459
|
SIZE (openospfd/openospfd-4.2.tgz) = 93661
|
||||||
MD5 (openospfd/if_media.h) = 4ff9297f5c133425dafe3ca565c0f811
|
MD5 (openospfd/if_media.h) = 4ff9297f5c133425dafe3ca565c0f811
|
||||||
SHA256 (openospfd/if_media.h) = 58225d0ed363c2beb23426f0f8254089d4541c3334776f3750ba434d4491a1d1
|
SHA256 (openospfd/if_media.h) = 58225d0ed363c2beb23426f0f8254089d4541c3334776f3750ba434d4491a1d1
|
||||||
SIZE (openospfd/if_media.h) = 23762
|
SIZE (openospfd/if_media.h) = 23762
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
--- ospfctl/parser.c.orig Fri Jul 27 15:11:46 2007
|
--- ospfctl/parser.c.orig 2008-02-07 19:13:50.000000000 +0300
|
||||||
+++ ospfctl/parser.c Fri Jul 27 15:12:01 2007
|
+++ ospfctl/parser.c 2008-02-07 19:15:47.000000000 +0300
|
||||||
@@ -32,23 +32,6 @@
|
@@ -32,23 +32,6 @@
|
||||||
|
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
--- ospfctl/parser.h.orig Fri Jul 27 15:11:55 2007
|
--- ospfctl/parser.h.orig 2008-02-07 19:12:58.000000000 +0300
|
||||||
+++ ospfctl/parser.h Fri Jul 27 15:12:01 2007
|
+++ ospfctl/parser.h 2008-02-07 19:15:45.000000000 +0300
|
||||||
@@ -50,6 +50,23 @@
|
@@ -50,6 +50,16 @@
|
||||||
RELOAD
|
RELOAD
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -14,6 +14,13 @@
|
||||||
+ IFNAME
|
+ IFNAME
|
||||||
+};
|
+};
|
||||||
+
|
+
|
||||||
|
struct parse_result {
|
||||||
|
struct in_addr addr;
|
||||||
|
char ifname[IF_NAMESIZE];
|
||||||
|
@@ -58,6 +68,13 @@
|
||||||
|
u_int8_t prefixlen;
|
||||||
|
};
|
||||||
|
|
||||||
+struct token {
|
+struct token {
|
||||||
+ enum token_type type;
|
+ enum token_type type;
|
||||||
+ const char *keyword;
|
+ const char *keyword;
|
||||||
|
@ -21,6 +28,6 @@
|
||||||
+ const struct token *next;
|
+ const struct token *next;
|
||||||
+};
|
+};
|
||||||
+
|
+
|
||||||
struct parse_result {
|
struct parse_result *parse(int, char *[]);
|
||||||
struct in_addr addr;
|
const struct token *match_token(const char *, const struct token []);
|
||||||
char ifname[IF_NAMESIZE];
|
void show_valid_args(const struct token []);
|
||||||
|
|
22
net/openospfd/files/patch-ospfd_carp.c
Normal file
22
net/openospfd/files/patch-ospfd_carp.c
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
--- 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__) */
|
|
@ -1,36 +1,136 @@
|
||||||
--- ospfd/kroute.c.orig Mon Nov 20 14:41:22 2006
|
--- ospfd/kroute.c.orig 2008-02-07 18:58:38.000000000 +0300
|
||||||
+++ ospfd/kroute.c Mon Nov 20 14:42:17 2006
|
+++ ospfd/kroute.c 2008-02-07 19:09:58.000000000 +0300
|
||||||
@@ -875,10 +875,6 @@
|
@@ -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);
|
send_rtmsg(kr_state.fd, RTM_DELETE, &kr->r);
|
||||||
free(kr);
|
free(kr);
|
||||||
} else {
|
} else {
|
||||||
- if ((label = (struct sockaddr_rtlabel *)
|
+#if !defined(__FreeBSD__) /* FreeBSD has no route labeling. */
|
||||||
- rti_info[RTAX_LABEL]) != NULL)
|
if ((label = (struct sockaddr_rtlabel *)
|
||||||
- kr->r.rtlabel =
|
rti_info[RTAX_LABEL]) != NULL) {
|
||||||
- rtlabel_name2id(label->sr_label);
|
kr->r.rtlabel =
|
||||||
|
@@ -1164,6 +1171,7 @@
|
||||||
|
kr->r.ext_tag =
|
||||||
|
rtlabel_id2tag(kr->r.rtlabel);
|
||||||
|
}
|
||||||
|
+#endif /* !defined(__FreeBSD__) */
|
||||||
kroute_insert(kr);
|
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);
|
rtlabel_unref(kr->r.rtlabel);
|
||||||
kr->r.rtlabel = 0;
|
kr->r.rtlabel = 0;
|
||||||
- if ((label = (struct sockaddr_rtlabel *)
|
kr->r.ext_tag = 0;
|
||||||
- rti_info[RTAX_LABEL]) != NULL)
|
+#if !defined(__FreeBSD__) /* FreeBSD has no route labeling. */
|
||||||
- kr->r.rtlabel =
|
if ((label = (struct sockaddr_rtlabel *)
|
||||||
- rtlabel_name2id(label->sr_label);
|
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))
|
if (kif_validate(kr->r.ifindex))
|
||||||
kr->r.flags &= ~F_DOWN;
|
kr->r.flags &= ~F_DOWN;
|
||||||
@@ -1098,11 +1090,6 @@
|
@@ -1413,6 +1427,7 @@
|
||||||
kr->r.nexthop.s_addr = nexthop.s_addr;
|
|
||||||
kr->r.flags = flags;
|
kr->r.flags = flags;
|
||||||
kr->r.ifindex = ifindex;
|
kr->r.ifindex = ifindex;
|
||||||
-
|
|
||||||
- if ((label = (struct sockaddr_rtlabel *)
|
+#if !defined(__FreeBSD__) /* FreeBSD has no route labeling */
|
||||||
- rti_info[RTAX_LABEL]) != NULL)
|
if ((label = (struct sockaddr_rtlabel *)
|
||||||
- kr->r.rtlabel =
|
rti_info[RTAX_LABEL]) != NULL) {
|
||||||
- rtlabel_name2id(label->sr_label);
|
kr->r.rtlabel =
|
||||||
|
@@ -1420,6 +1435,7 @@
|
||||||
|
kr->r.ext_tag =
|
||||||
|
rtlabel_id2tag(kr->r.rtlabel);
|
||||||
|
}
|
||||||
|
+#endif /* !defined(__FreeBSD__) */
|
||||||
|
|
||||||
kroute_insert(kr);
|
kroute_insert(kr);
|
||||||
}
|
}
|
||||||
|
|
27
net/openospfd/files/patch-ospfd_ospfd.c
Normal file
27
net/openospfd/files/patch-ospfd_ospfd.c
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
--- 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",
|
13
net/openospfd/files/patch-ospfd_ospfd.h
Normal file
13
net/openospfd/files/patch-ospfd_ospfd.h
Normal file
|
@ -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;
|
|
@ -1,6 +1,6 @@
|
||||||
--- ospfd/packet.c.orig 9 Mar 2006 13:31:57 -0000 1.20
|
--- ospfd/packet.c.orig 2006-11-17 11:55:31.000000000 +0300
|
||||||
+++ ospfd/packet.c 16 Mar 2006 18:21:38 -0000
|
+++ ospfd/packet.c 2008-02-13 22:13:04.000000000 +0300
|
||||||
@@ -34,7 +34,7 @@
|
@@ -36,7 +36,7 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "ospfe.h"
|
#include "ospfe.h"
|
||||||
|
|
||||||
|
@ -8,8 +8,21 @@
|
||||||
+int ip_hdr_sanity_check(struct ip *, u_int16_t);
|
+int ip_hdr_sanity_check(struct ip *, u_int16_t);
|
||||||
int ospf_hdr_sanity_check(const struct ip *,
|
int ospf_hdr_sanity_check(const struct ip *,
|
||||||
struct ospf_hdr *, u_int16_t, const struct iface *);
|
struct ospf_hdr *, u_int16_t, const struct iface *);
|
||||||
struct iface *find_iface(struct ospfd_conf *, struct in_addr);
|
struct iface *find_iface(struct ospfd_conf *, unsigned int, struct in_addr);
|
||||||
@@ -196,8 +196,13 @@ recv_packet(int fd, short event, void *b
|
@@ -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
|
int
|
||||||
|
|
42
net/openospfd/files/patch-ospfd_parse.y
Normal file
42
net/openospfd/files/patch-ospfd_parse.y
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
--- 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
|
||||||
|
;
|
133
net/openospfd/files/patch-ospfd_rde_spf.c
Normal file
133
net/openospfd/files/patch-ospfd_rde_spf.c
Normal file
|
@ -0,0 +1,133 @@
|
||||||
|
--- 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@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 */
|
Loading…
Reference in a new issue