Index: Makefile =================================================================== RCS file: /home/pcvs/ports/net/openospfd/Makefile,v retrieving revision 1.10 diff -u -r1.10 Makefile --- Makefile 19 Aug 2008 16:40:15 -0000 1.10 +++ Makefile 14 Oct 2008 22:10:48 -0000 @@ -6,8 +6,7 @@ # PORTNAME= openospfd -PORTVERSION= 4.0 -PORTREVISION= 3 +PORTVERSION= 4.2 CATEGORIES= net MASTER_SITES= ftp://ftp.dkuug.dk/pub/OpenBSD/OpenBGPD/:openbsd \ ${MASTER_SITE_LOCAL:S/$/:freebsd/g} Index: distinfo =================================================================== RCS file: /home/pcvs/ports/net/openospfd/distinfo,v retrieving revision 1.4 diff -u -r1.4 distinfo --- distinfo 27 Aug 2007 08:15:04 -0000 1.4 +++ distinfo 14 Oct 2008 22:10:48 -0000 @@ -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 +SHA256 (openospfd/openospfd-4.2.tgz) = 896a9e29447d7da46a1c7c1717e1527b3770425840e8f0180419ec313d3d7b00 +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 Index: files/patch-ospfctl_parser.c =================================================================== RCS file: /home/pcvs/ports/net/openospfd/files/patch-ospfctl_parser.c,v retrieving revision 1.1 diff -u -r1.1 patch-ospfctl_parser.c --- files/patch-ospfctl_parser.c 27 Aug 2007 08:15:04 -0000 1.1 +++ files/patch-ospfctl_parser.c 14 Oct 2008 22:10:48 -0000 @@ -1,5 +1,5 @@ ---- ospfctl/parser.c.orig Fri Jul 27 15:11:46 2007 -+++ ospfctl/parser.c Fri Jul 27 15:12:01 2007 +--- 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" Index: files/patch-ospfctl_parser.h =================================================================== RCS file: /home/pcvs/ports/net/openospfd/files/patch-ospfctl_parser.h,v retrieving revision 1.1 diff -u -r1.1 patch-ospfctl_parser.h --- files/patch-ospfctl_parser.h 27 Aug 2007 08:15:04 -0000 1.1 +++ files/patch-ospfctl_parser.h 14 Oct 2008 22:10:48 -0000 @@ -1,6 +1,6 @@ ---- 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 @@ +--- 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 }; @@ -14,6 +14,13 @@ + 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; @@ -21,6 +28,6 @@ + const struct token *next; +}; + - struct parse_result { - struct in_addr addr; - char ifname[IF_NAMESIZE]; + struct parse_result *parse(int, char *[]); + const struct token *match_token(const char *, const struct token []); + void show_valid_args(const struct token []); Index: files/patch-ospfd_carp.c =================================================================== RCS file: files/patch-ospfd_carp.c diff -N files/patch-ospfd_carp.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-ospfd_carp.c 14 Oct 2008 22:10:48 -0000 @@ -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__) */ Index: files/patch-ospfd_kroute.c =================================================================== RCS file: /home/pcvs/ports/net/openospfd/files/patch-ospfd_kroute.c,v retrieving revision 1.1 diff -u -r1.1 patch-ospfd_kroute.c --- files/patch-ospfd_kroute.c 27 Aug 2007 08:15:04 -0000 1.1 +++ files/patch-ospfd_kroute.c 14 Oct 2008 22:10:48 -0000 @@ -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); } Index: files/patch-ospfd_ospfd.c =================================================================== RCS file: files/patch-ospfd_ospfd.c diff -N files/patch-ospfd_ospfd.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-ospfd_ospfd.c 14 Oct 2008 22:10:48 -0000 @@ -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", Index: files/patch-ospfd_ospfd.h =================================================================== RCS file: files/patch-ospfd_ospfd.h diff -N files/patch-ospfd_ospfd.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-ospfd_ospfd.h 14 Oct 2008 22:10:48 -0000 @@ -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; Index: files/patch-ospfd_packet.c =================================================================== RCS file: /home/pcvs/ports/net/openospfd/files/patch-ospfd_packet.c,v retrieving revision 1.1 diff -u -r1.1 patch-ospfd_packet.c --- files/patch-ospfd_packet.c 20 Mar 2006 10:41:04 -0000 1.1 +++ files/patch-ospfd_packet.c 14 Oct 2008 22:10:48 -0000 @@ -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 Index: files/patch-ospfd_parse.y =================================================================== RCS file: files/patch-ospfd_parse.y diff -N files/patch-ospfd_parse.y --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-ospfd_parse.y 14 Oct 2008 22:10:48 -0000 @@ -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 + ; Index: files/patch-ospfd_rde_spf.c =================================================================== RCS file: files/patch-ospfd_rde_spf.c diff -N files/patch-ospfd_rde_spf.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-ospfd_rde_spf.c 14 Oct 2008 22:10:48 -0000 @@ -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 +@@ -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 */