ports/129881: [patch] net/openospfd: update to 4.3 and fix some bugs
Eygene Ryabinkin
rea-fbsd at codelabs.ru
Tue Dec 23 12:40:02 UTC 2008
>Number: 129881
>Category: ports
>Synopsis: [patch] net/openospfd: update to 4.3 and fix some bugs
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Tue Dec 23 12:40:01 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator: Eygene Ryabinkin
>Release: FreeBSD 7.1-PRERELEASE i386
>Organization:
Code Labs
>Environment:
System: FreeBSD 7.1-PRERELEASE i386
>Description:
OpenOSPFD 4.3 is out,
ftp://ftp.openbsd.org/pub/OpenBSD/OpenBGPD/openospfd-4.3.tgz
>How-To-Repeat:
Look at the above URL. Moreover, issue with libevent's processing
in OpenOSPFD was found by Remko Lodder, the provided patchset fixes
it as well.
>Fix:
The following patches update the port to 4.3 and fix some important
problems, most notably -- libevent-related issue Remko Lodder was
trouble with.
Update to 4.3 itself:
--- update-to-4.3-pack1.diff begins here ---
>From e2c61733ea1201a1709779aa26f2b243fa206a1d Mon Sep 17 00:00:00 2001
From: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
Date: Fri, 19 Dec 2008 18:30:30 +0300
Signed-off-by: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
---
net/openospfd/Makefile | 6 +-
net/openospfd/distinfo | 6 +-
net/openospfd/files/patch-ospfd_kroute.c | 48 +++++++----
net/openospfd/files/patch-ospfd_parse.y | 16 ++--
net/openospfd/files/patch-ospfd_rde_spf.c | 133 -----------------------------
5 files changed, 46 insertions(+), 163 deletions(-)
delete mode 100644 net/openospfd/files/patch-ospfd_rde_spf.c
diff --git a/net/openospfd/Makefile b/net/openospfd/Makefile
index 512932c..56b919d 100644
--- a/net/openospfd/Makefile
+++ b/net/openospfd/Makefile
@@ -6,11 +6,11 @@
#
PORTNAME= openospfd
-PORTVERSION= 4.2
+PORTVERSION= 4.3
CATEGORIES= net
-MASTER_SITES= ftp://ftp.dkuug.dk/pub/OpenBSD/OpenBGPD/:openbsd \
+MASTER_SITES= ${MASTER_SITE_OPENBSD:S/$/:openbsd/g} \
${MASTER_SITE_LOCAL:S/$/:freebsd/g}
-MASTER_SITE_SUBDIR= flz/openospfd/:freebsd
+MASTER_SITE_SUBDIR= flz/openospfd/:freebsd OpenBGPD/:openbsd
DISTFILES= ${PORTNAME}-${PORTVERSION}.tgz:openbsd \
if_media.h:freebsd hash.h:freebsd
DIST_SUBDIR= ${PORTNAME}
diff --git a/net/openospfd/distinfo b/net/openospfd/distinfo
index 870d644..50f62f0 100644
--- a/net/openospfd/distinfo
+++ b/net/openospfd/distinfo
@@ -1,6 +1,6 @@
-MD5 (openospfd/openospfd-4.2.tgz) = ac919e4883105b28a846106e7c60bb80
-SHA256 (openospfd/openospfd-4.2.tgz) = 896a9e29447d7da46a1c7c1717e1527b3770425840e8f0180419ec313d3d7b00
-SIZE (openospfd/openospfd-4.2.tgz) = 93661
+MD5 (openospfd/openospfd-4.3.tgz) = dffeb5cf21cbd4f15534e658682cb6ee
+SHA256 (openospfd/openospfd-4.3.tgz) = 8fd4ffb393cc06f5936e9eb444b54f72d3fb7ec27285d0d746de5e8050959a66
+SIZE (openospfd/openospfd-4.3.tgz) = 97515
MD5 (openospfd/if_media.h) = 4ff9297f5c133425dafe3ca565c0f811
SHA256 (openospfd/if_media.h) = 58225d0ed363c2beb23426f0f8254089d4541c3334776f3750ba434d4491a1d1
SIZE (openospfd/if_media.h) = 23762
diff --git a/net/openospfd/files/patch-ospfd_kroute.c b/net/openospfd/files/patch-ospfd_kroute.c
index 2b1bd77..2e270f4 100644
--- a/net/openospfd/files/patch-ospfd_kroute.c
+++ b/net/openospfd/files/patch-ospfd_kroute.c
@@ -1,6 +1,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 @@
+--- ospfd/kroute.c.orig 2007-10-18 00:52:42.000000000 +0400
++++ ospfd/kroute.c 2008-12-19 18:07:06.000000000 +0300
+@@ -1024,9 +1024,11 @@
struct sockaddr_in prefix;
struct sockaddr_in nexthop;
struct sockaddr_in mask;
@@ -13,7 +13,23 @@
if (kr_state.fib_sync == 0)
return (0);
-@@ -1011,6 +1013,7 @@
+@@ -1035,9 +1037,14 @@
+ bzero(&hdr, sizeof(hdr));
+ hdr.rtm_version = RTM_VERSION;
+ hdr.rtm_type = action;
++#if !defined(__FreeBSD__)
+ hdr.rtm_flags = RTF_PROTO2|RTF_MPATH;
++#else
++ /* No multipath routing in FreeBSD yet */
++ hdr.rtm_flags = RTF_PROTO2;
++#endif /* !defined(__FreeBSD__) */
+ if (action == RTM_CHANGE) /* force PROTO2 reset the other flags */
+- hdr.rtm_fmask = RTF_PROTO2|RTF_PROTO1|RTF_REJECT|RTF_BLACKHOLE;
++ hdr.rtm_use = RTF_PROTO2|RTF_PROTO1|RTF_REJECT|RTF_BLACKHOLE;
+ hdr.rtm_seq = kr_state.rtseq++; /* overflow doesn't matter */
+ hdr.rtm_msglen = sizeof(hdr);
+ /* adjust iovec */
+@@ -1080,6 +1087,7 @@
iov[iovcnt].iov_base = &mask;
iov[iovcnt++].iov_len = sizeof(mask);
@@ -21,7 +37,7 @@
if (kroute->rtlabel != 0) {
sa_rl.sr_len = sizeof(sa_rl);
sa_rl.sr_family = AF_UNSPEC;
-@@ -1027,6 +1030,7 @@
+@@ -1096,6 +1104,7 @@
iov[iovcnt].iov_base = &sa_rl;
iov[iovcnt++].iov_len = sizeof(sa_rl);
}
@@ -29,7 +45,7 @@
retry:
-@@ -1069,7 +1073,9 @@
+@@ -1138,7 +1147,9 @@
struct rt_msghdr *rtm;
struct sockaddr *sa, *rti_info[RTAX_MAX];
struct sockaddr_in *sa_in;
@@ -39,7 +55,7 @@
struct kroute_node *kr;
mib[0] = CTL_NET;
-@@ -1078,9 +1084,13 @@
+@@ -1147,9 +1158,13 @@
mib[3] = AF_INET;
mib[4] = NET_RT_DUMP;
mib[5] = 0;
@@ -53,7 +69,7 @@
log_warn("sysctl");
return (-1);
}
-@@ -1098,7 +1098,11 @@
+@@ -1157,7 +1172,11 @@
log_warn("fetchtable");
return (-1);
}
@@ -65,7 +81,7 @@
log_warn("sysctl");
free(buf);
return (-1);
-@@ -1157,6 +1163,7 @@
+@@ -1228,6 +1247,7 @@
send_rtmsg(kr_state.fd, RTM_DELETE, &kr->r);
free(kr);
} else {
@@ -73,7 +89,7 @@
if ((label = (struct sockaddr_rtlabel *)
rti_info[RTAX_LABEL]) != NULL) {
kr->r.rtlabel =
-@@ -1164,6 +1171,7 @@
+@@ -1235,6 +1255,7 @@
kr->r.ext_tag =
rtlabel_id2tag(kr->r.rtlabel);
}
@@ -81,7 +97,7 @@
kroute_insert(kr);
}
-@@ -1257,7 +1265,9 @@
+@@ -1328,7 +1349,9 @@
struct ifa_msghdr *ifam;
struct sockaddr *sa, *rti_info[RTAX_MAX];
struct sockaddr_in *sa_in;
@@ -91,7 +107,7 @@
struct kroute_node *kr, *okr;
struct in_addr prefix, nexthop;
u_int8_t prefixlen;
-@@ -1289,8 +1299,10 @@
+@@ -1362,8 +1385,10 @@
sa = (struct sockaddr *)(rtm + 1);
get_rtaddrs(rtm->rtm_addrs, sa, rti_info);
@@ -102,7 +118,7 @@
if (rtm->rtm_pid == kr_state.pid) /* caused by us */
continue;
-@@ -1385,6 +1397,7 @@
+@@ -1458,6 +1483,7 @@
rtlabel_unref(kr->r.rtlabel);
kr->r.rtlabel = 0;
kr->r.ext_tag = 0;
@@ -110,7 +126,7 @@
if ((label = (struct sockaddr_rtlabel *)
rti_info[RTAX_LABEL]) != NULL) {
kr->r.rtlabel =
-@@ -1392,6 +1405,7 @@
+@@ -1465,6 +1491,7 @@
kr->r.ext_tag =
rtlabel_id2tag(kr->r.rtlabel);
}
@@ -118,7 +134,7 @@
if (kif_validate(kr->r.ifindex))
kr->r.flags &= ~F_DOWN;
-@@ -1413,6 +1427,7 @@
+@@ -1486,6 +1513,7 @@
kr->r.flags = flags;
kr->r.ifindex = ifindex;
@@ -126,7 +142,7 @@
if ((label = (struct sockaddr_rtlabel *)
rti_info[RTAX_LABEL]) != NULL) {
kr->r.rtlabel =
-@@ -1420,6 +1435,7 @@
+@@ -1493,6 +1521,7 @@
kr->r.ext_tag =
rtlabel_id2tag(kr->r.rtlabel);
}
diff --git a/net/openospfd/files/patch-ospfd_parse.y b/net/openospfd/files/patch-ospfd_parse.y
index 7023a9d..6c40c3e 100644
--- a/net/openospfd/files/patch-ospfd_parse.y
+++ b/net/openospfd/files/patch-ospfd_parse.y
@@ -1,6 +1,6 @@
---- 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 @@
+--- ospfd/parse.y.orig 2008-02-26 13:09:58.000000000 +0300
++++ ospfd/parse.y 2008-12-19 17:52:39.000000000 +0300
+@@ -503,6 +503,11 @@
areaoptsl : interface
| DEMOTE STRING demotecount {
@@ -9,10 +9,10 @@
+ free($2);
+ YYERROR;
+#else
- if ($3 > 255) {
- yyerror("demote count too big: max 255");
+ if ($3 < 1 || $3 > 255) {
+ yyerror("demote count out of range (1-255)");
free($2);
-@@ -505,6 +510,7 @@
+@@ -523,6 +528,7 @@
area->demote_group);
YYERROR;
}
@@ -20,7 +20,7 @@
}
| defaults
;
-@@ -581,6 +587,11 @@
+@@ -599,6 +605,11 @@
interfaceoptsl : PASSIVE { iface->passive = 1; }
| DEMOTE STRING {
@@ -32,7 +32,7 @@
if (strlcpy(iface->demote_group, $2,
sizeof(iface->demote_group)) >=
sizeof(iface->demote_group)) {
-@@ -595,6 +606,7 @@
+@@ -613,6 +624,7 @@
iface->demote_group);
YYERROR;
}
diff --git a/net/openospfd/files/patch-ospfd_rde_spf.c b/net/openospfd/files/patch-ospfd_rde_spf.c
deleted file mode 100644
index e0391f3..0000000
--- a/net/openospfd/files/patch-ospfd_rde_spf.c
+++ /dev/null
@@ -1,133 +0,0 @@
---- 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.6.0.5
--- update-to-4.3-pack1.diff ends here ---
Add comments to all patches to give an idea why they are needed:
--- update-to-4.3-pack2.diff begins here ---
>From 6155fa523818154876ddae5c54da8e825cff0d82 Mon Sep 17 00:00:00 2001
From: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
Date: Sun, 21 Dec 2008 16:31:31 +0300
Subject: [PATCH 2/3] net/openospfd: add comments to the FreeBSD patches for OpenOSPFD
Signed-off-by: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
---
net/openospfd/files/patch-ospfctl_parser.c | 6 ++++++
net/openospfd/files/patch-ospfctl_parser.h | 6 ++++++
net/openospfd/files/patch-ospfd_carp.c | 2 ++
net/openospfd/files/patch-ospfd_kroute.c | 9 +++++++++
net/openospfd/files/patch-ospfd_ospfd.c | 2 ++
net/openospfd/files/patch-ospfd_ospfd.h | 2 ++
net/openospfd/files/patch-ospfd_packet.c | 7 +++++++
net/openospfd/files/patch-ospfd_parse.y | 2 ++
8 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/net/openospfd/files/patch-ospfctl_parser.c b/net/openospfd/files/patch-ospfctl_parser.c
index ad85723..ddbf159 100644
--- a/net/openospfd/files/patch-ospfctl_parser.c
+++ b/net/openospfd/files/patch-ospfctl_parser.c
@@ -1,3 +1,9 @@
+Move 'struct token' and 'enum token_type' definitions from parser.c
+to parser.h
+
+We need this because parser.h references 'struct token' and it is in turn
+references 'enum token_type'.
+
--- 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 @@
diff --git a/net/openospfd/files/patch-ospfctl_parser.h b/net/openospfd/files/patch-ospfctl_parser.h
index 677bee2..ad0aa42 100644
--- a/net/openospfd/files/patch-ospfctl_parser.h
+++ b/net/openospfd/files/patch-ospfctl_parser.h
@@ -1,3 +1,9 @@
+Move 'struct token' and 'enum token_type' definitions from parser.c
+to parser.h
+
+We need this because parser.h references 'struct token' and it is in turn
+references 'enum token_type'.
+
--- 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 @@
diff --git a/net/openospfd/files/patch-ospfd_carp.c b/net/openospfd/files/patch-ospfd_carp.c
index 798643b..a4c66a5 100644
--- a/net/openospfd/files/patch-ospfd_carp.c
+++ b/net/openospfd/files/patch-ospfd_carp.c
@@ -1,3 +1,5 @@
+Disable CARP demotion support
+
--- 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 @@
diff --git a/net/openospfd/files/patch-ospfd_kroute.c b/net/openospfd/files/patch-ospfd_kroute.c
index 2e270f4..b5f0d22 100644
--- a/net/openospfd/files/patch-ospfd_kroute.c
+++ b/net/openospfd/files/patch-ospfd_kroute.c
@@ -1,3 +1,12 @@
+Disable some stuff that is absent in FreeBSD
+
+- route labeling;
+- multipath routing flag;
+- multiple routing tables support.
+
+And use FreeBSD-specific names for route-related structures
+instead of OpenBSD-specific ones.
+
--- ospfd/kroute.c.orig 2007-10-18 00:52:42.000000000 +0400
+++ ospfd/kroute.c 2008-12-19 18:07:06.000000000 +0300
@@ -1024,9 +1024,11 @@
diff --git a/net/openospfd/files/patch-ospfd_ospfd.c b/net/openospfd/files/patch-ospfd_ospfd.c
index 419eb4f..58e7ddd 100644
--- a/net/openospfd/files/patch-ospfd_ospfd.c
+++ b/net/openospfd/files/patch-ospfd_ospfd.c
@@ -1,3 +1,5 @@
+Disable CARP demotion support
+
--- 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 @@
diff --git a/net/openospfd/files/patch-ospfd_ospfd.h b/net/openospfd/files/patch-ospfd_ospfd.h
index bcd1f6d..363712d 100644
--- a/net/openospfd/files/patch-ospfd_ospfd.h
+++ b/net/openospfd/files/patch-ospfd_ospfd.h
@@ -1,3 +1,5 @@
+Define macro LINK_STATE_IS_UP
+
--- 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 @@
diff --git a/net/openospfd/files/patch-ospfd_packet.c b/net/openospfd/files/patch-ospfd_packet.c
index cceb302..c490034 100644
--- a/net/openospfd/files/patch-ospfd_packet.c
+++ b/net/openospfd/files/patch-ospfd_packet.c
@@ -1,3 +1,10 @@
+Add some FreeBSD/NetBSD specifics
+
+- FreeBSD/NetBSD require IP packet length to be in the host's byte order;
+- FreeBSD/NetBSD substracts IP header length from the packet length,
+ (see sys/netinet/ip_input.c, routine ip_input); OpenBSD wants to see
+ the unmodified length.
+
--- 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 @@
diff --git a/net/openospfd/files/patch-ospfd_parse.y b/net/openospfd/files/patch-ospfd_parse.y
index 6c40c3e..7cf7fc2 100644
--- a/net/openospfd/files/patch-ospfd_parse.y
+++ b/net/openospfd/files/patch-ospfd_parse.y
@@ -1,3 +1,5 @@
+Disable CARP demotion support
+
--- ospfd/parse.y.orig 2008-02-26 13:09:58.000000000 +0300
+++ ospfd/parse.y 2008-12-19 17:52:39.000000000 +0300
@@ -503,6 +503,11 @@
--
1.6.0.5
--- update-to-4.3-pack2.diff ends here ---
Patch for libevent-related issue and fix for ARP-v2 stuff in 8-CURRENT:
--- update-to-4.3-pack3.diff begins here ---
>From b7c9024649187eabede98eb12cc7d0bc8e5fa24b Mon Sep 17 00:00:00 2001
From: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
Date: Tue, 23 Dec 2008 14:53:47 +0300
Subject: [PATCH 3/3] More fixes to OpenOSPFD
Add patch for libevent 'event' argument processing: both read
and write flags could be set for a single event.
Add patch for FreeBSD 8-CURRENT ARP-v2 rework: ARP addresses are
now moved from the main routing table, so there is no need to
check RTF_LLINFO flag.
Signed-off-by: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
---
net/openospfd/files/patch-RTF_LLINFO-ARP-v2-fix | 50 ++++
net/openospfd/files/patch-fix-libevent-READ-WRITE | 300 +++++++++++++++++++++
2 files changed, 350 insertions(+), 0 deletions(-)
create mode 100644 net/openospfd/files/patch-RTF_LLINFO-ARP-v2-fix
create mode 100644 net/openospfd/files/patch-fix-libevent-READ-WRITE
diff --git a/net/openospfd/files/patch-RTF_LLINFO-ARP-v2-fix b/net/openospfd/files/patch-RTF_LLINFO-ARP-v2-fix
new file mode 100644
index 0000000..f333795
--- /dev/null
+++ b/net/openospfd/files/patch-RTF_LLINFO-ARP-v2-fix
@@ -0,0 +1,50 @@
+From 1138f09b72a42ddb7b35780da0e51a0b378bea1b Mon Sep 17 00:00:00 2001
+From: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
+Date: Mon, 22 Dec 2008 12:13:13 +0300
+Subject: [PATCH] Fix usage of RTF_LLINFO due to the ARP-v2 changes
+
+ARP-v2, commited in SVN rev 186119, eliminated RTF_WASCLONE,
+RTF_CLONING and RTF_LLINFO,
+ http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/net/route.h?rev=1.77
+
+The latter flag was used in OpenOSPFD to skip ARP entries from the
+routing table. We're just conditionalizing the code on the existence of
+RTF_LLINFO variable. Perhaps checking __FreeBSD__ value will be better:
+errors due to the non-included net/route.h won't be spotted in the
+former case. But since many RTF_* constants are used in kroute.c, this
+shouldn't be a problem, at least now.
+
+Signed-off-by: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
+---
+ ospfd/kroute.c | 4 ++++
+ 1 files changed, 4 insertions(+), 0 deletions(-)
+
+diff --git a/ospfd/kroute.c b/ospfd/kroute.c
+index b46fa30..acc2a32 100644
+--- ospfd/kroute.c
++++ ospfd/kroute.c
+@@ -1174,8 +1174,10 @@ fetchtable(void)
+ if ((sa = rti_info[RTAX_DST]) == NULL)
+ continue;
+
++#if defined(RTF_LLINFO) /* FreeBSD dropped RTF_LLINFO after ARP-v2 rework */
+ if (rtm->rtm_flags & RTF_LLINFO) /* arp cache */
+ continue;
++#endif /* defined(RTF_LLINFO) */
+
+ if ((kr = calloc(1, sizeof(struct kroute_node))) == NULL) {
+ log_warn("fetchtable");
+@@ -1371,8 +1373,10 @@ dispatch_rtmsg(void)
+ if (rtm->rtm_errno) /* failed attempts... */
+ continue;
+
++#if defined(RTF_LLINFO) /* FreeBSD dropped RTF_LLINFO after ARP-v2 rework */
+ if (rtm->rtm_flags & RTF_LLINFO) /* arp cache */
+ continue;
++#endif /* defined(RTF_LLINFO) */
+
+ #ifdef RTF_MPATH
+ if (rtm->rtm_flags & RTF_MPATH)
+--
+1.6.0.4
+
diff --git a/net/openospfd/files/patch-fix-libevent-READ-WRITE b/net/openospfd/files/patch-fix-libevent-READ-WRITE
new file mode 100644
index 0000000..d74e804
--- /dev/null
+++ b/net/openospfd/files/patch-fix-libevent-READ-WRITE
@@ -0,0 +1,300 @@
+From 490cb06ef878bff1e45acf313105205df7baced1 Mon Sep 17 00:00:00 2001
+From: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
+Date: Sun, 21 Dec 2008 15:18:11 +0300
+Subject: [PATCH] Add processing of both READ and WRITE events inside libevent handlers
+
+If both read and write descriptors are ready, then libevent will set
+both EV_READ and EV_WRITE. Original OpenOSPFD sources were not ready to
+handle such situations, but OpenBSD's libevent (1.3e with some local
+tweaks) and even libevent 1.0 can also produce combined read/write
+events (if manual page is correct ;).
+
+Such errors were seen in the wild, for example Remko Lodder had been
+biten by this issue.
+
+I had created inline function that will be called from both 6 places
+that are handling READ/WRITE events to eliminate code duplication.
+
+Signed-off-by: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
+---
+ ospfd/libevent_helpers.h | 81 ++++++++++++++++++++++++++++++++++++++++++++++
+ ospfd/ospfd.c | 31 ++----------------
+ ospfd/ospfe.c | 39 ++++-----------------
+ ospfd/rde.c | 31 ++----------------
+ 4 files changed, 95 insertions(+), 87 deletions(-)
+ create mode 100644 ospfd/libevent_helpers.h
+
+diff --git a/ospfd/libevent_helpers.h b/ospfd/libevent_helpers.h
+new file mode 100644
+index 0000000..46f743d
+--- /dev/null
++++ ospfd/libevent_helpers.h
+@@ -0,0 +1,81 @@
++/*
++ * Copyright (c) 2008 Eygene Ryabinkin <rea-fbsd at codelabs.ru>
++ *
++ * Permission to use, copy, modify, and distribute this software for any
++ * purpose with or without fee is hereby granted, provided that the above
++ * copyright notice and this permission notice appear in all copies.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
++ */
++
++#ifndef _LIBEVENT_HELPERS_H_
++#define _LIBEVENT_HELPERS_H_
++
++#include <stdio.h>
++#include <sys/types.h>
++
++#include "log.h"
++#include "ospfd.h"
++
++/* Inline functions */
++
++/*
++ * A support function that processes libevent notification in the
++ * following way:
++ * - if we are ready to write, we will try to flush the queue;
++ * - if we are ready to read, we will read the input buffer and
++ * prepare variables 'n' and 'shut' accordingly.
++ *
++ * Such handling occurs at least 6 times within the OSPFD sources,
++ * so this inline function is just an alternative to the preprocessor
++ * macros.
++ *
++ * Function returns 0 if everything was handled and no further
++ * processing is needed; it returns EV_READ if the read processing
++ * was prepared to take place.
++ */
++static inline short
++dispatch_read_write_event(short _event, struct imsgbuf *_ibuf,
++ ssize_t *_n, int *_shut) __attribute__((always_inline));
++
++static inline short
++dispatch_read_write_event(short event, struct imsgbuf *ibuf,
++ ssize_t *n, int *shut)
++{
++ static char errbuf[128];
++
++ /*
++ * We can have both EV_READ and EV_WRITE, since we can be
++ * subscribed to both event types. Handle write readiness
++ * first (flush the queue) and then handle reads.
++ */
++ if ((event & ~(EV_WRITE|EV_READ))) {
++ snprintf(errbuf, sizeof(errbuf),
++ "unknown event 0x%hx", (unsigned short)event);
++ fatalx(errbuf);
++ }
++
++ if ((event & EV_WRITE)) {
++ if (msgbuf_write(&ibuf->w) == -1)
++ fatal("msgbuf_write");
++ imsg_event_add(ibuf);
++ }
++ if ((event & EV_READ)) {
++ if ((*n = imsg_read(ibuf)) == -1)
++ fatal("imsg_read error");
++ if (*n == 0) /* connection closed */
++ *shut = 1;
++ return EV_READ;
++ } else {
++ return 0;
++ }
++ /* NOTREACHED */
++}
++
++#endif /* _LIBEVENT_HELPERS_H_ */
+diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c
+index be69cab..4e62d09 100644
+--- ospfd/ospfd.c
++++ ospfd/ospfd.c
+@@ -46,6 +46,7 @@
+ #include "control.h"
+ #include "log.h"
+ #include "rde.h"
++#include "libevent_helpers.h"
+
+ void main_sig_handler(int, short, void *);
+ __dead void usage(void);
+@@ -355,21 +356,8 @@ main_dispatch_ospfe(int fd, short event, void *bula)
+ ssize_t n;
+ int shut = 0;
+
+- switch (event) {
+- case EV_READ:
+- if ((n = imsg_read(ibuf)) == -1)
+- fatal("imsg_read error");
+- if (n == 0) /* connection closed */
+- shut = 1;
+- break;
+- case EV_WRITE:
+- if (msgbuf_write(&ibuf->w) == -1)
+- fatal("msgbuf_write");
+- imsg_event_add(ibuf);
++ if (dispatch_read_write_event(event, ibuf, &n, &shut) != EV_READ)
+ return;
+- default:
+- fatalx("unknown event");
+- }
+
+ for (;;) {
+ if ((n = imsg_get(ibuf, &imsg)) == -1)
+@@ -434,21 +422,8 @@ main_dispatch_rde(int fd, short event, void *bula)
+ ssize_t n;
+ int count, shut = 0;
+
+- switch (event) {
+- case EV_READ:
+- if ((n = imsg_read(ibuf)) == -1)
+- fatal("imsg_read error");
+- if (n == 0) /* connection closed */
+- shut = 1;
+- break;
+- case EV_WRITE:
+- if (msgbuf_write(&ibuf->w) == -1)
+- fatal("msgbuf_write");
+- imsg_event_add(ibuf);
++ if (dispatch_read_write_event(event, ibuf, &n, &shut) != EV_READ)
+ return;
+- default:
+- fatalx("unknown event");
+- }
+
+ for (;;) {
+ if ((n = imsg_get(ibuf, &imsg)) == -1)
+diff --git a/ospfd/ospfe.c b/ospfd/ospfe.c
+index af7a406..d6a6aa9 100644
+--- ospfd/ospfe.c
++++ ospfd/ospfe.c
+@@ -42,6 +42,7 @@
+ #include "rde.h"
+ #include "control.h"
+ #include "log.h"
++#include "libevent_helpers.h"
+
+ void ospfe_sig_handler(int, short, void *);
+ void ospfe_shutdown(void);
+@@ -257,23 +258,11 @@ ospfe_dispatch_main(int fd, short event, void *bula)
+ struct iface *iface = NULL;
+ struct kif *kif;
+ struct auth_md md;
+- int n, link_ok, stub_changed, shut = 0;
+-
+- switch (event) {
+- case EV_READ:
+- if ((n = imsg_read(ibuf)) == -1)
+- fatal("imsg_read error");
+- if (n == 0) /* connection closed */
+- shut = 1;
+- break;
+- case EV_WRITE:
+- if (msgbuf_write(&ibuf->w) == -1)
+- fatal("msgbuf_write");
+- imsg_event_add(ibuf);
++ int link_ok, stub_changed, shut = 0;
++ ssize_t n;
++
++ if (dispatch_read_write_event(event, ibuf, &n, &shut) != EV_READ)
+ return;
+- default:
+- fatalx("unknown event");
+- }
+
+ for (;;) {
+ if ((n = imsg_get(ibuf, &imsg)) == -1)
+@@ -401,24 +390,12 @@ ospfe_dispatch_rde(int fd, short event, void *bula)
+ struct lsa_entry *le;
+ struct imsg imsg;
+ struct abr_rtr ar;
+- int n, noack = 0, shut = 0;
++ int noack = 0, shut = 0;
+ u_int16_t l, age;
++ ssize_t n;
+
+- switch (event) {
+- case EV_READ:
+- if ((n = imsg_read(ibuf)) == -1)
+- fatal("imsg_read error");
+- if (n == 0) /* connection closed */
+- shut = 1;
+- break;
+- case EV_WRITE:
+- if (msgbuf_write(&ibuf->w) == -1)
+- fatal("msgbuf_write");
+- imsg_event_add(ibuf);
++ if (dispatch_read_write_event(event, ibuf, &n, &shut) != EV_READ)
+ return;
+- default:
+- fatalx("unknown event");
+- }
+
+ for (;;) {
+ if ((n = imsg_get(ibuf, &imsg)) == -1)
+diff --git a/ospfd/rde.c b/ospfd/rde.c
+index 5dd0623..faa0c23 100644
+--- ospfd/rde.c
++++ ospfd/rde.c
+@@ -37,6 +37,7 @@
+ #include "ospfe.h"
+ #include "log.h"
+ #include "rde.h"
++#include "libevent_helpers.h"
+
+ void rde_sig_handler(int sig, short, void *);
+ void rde_shutdown(void);
+@@ -239,21 +240,8 @@ rde_dispatch_imsg(int fd, short event, void *bula)
+ int r, state, self, shut = 0;
+ u_int16_t l;
+
+- switch (event) {
+- case EV_READ:
+- if ((n = imsg_read(ibuf)) == -1)
+- fatal("imsg_read error");
+- if (n == 0) /* connection closed */
+- shut = 1;
+- break;
+- case EV_WRITE:
+- if (msgbuf_write(&ibuf->w) == -1)
+- fatal("msgbuf_write");
+- imsg_event_add(ibuf);
++ if (dispatch_read_write_event(event, ibuf, &n, &shut) != EV_READ)
+ return;
+- default:
+- fatalx("unknown event");
+- }
+
+ clock_gettime(CLOCK_MONOTONIC, &tp);
+ now = tp.tv_sec;
+@@ -584,21 +572,8 @@ rde_dispatch_parent(int fd, short event, void *bula)
+ ssize_t n;
+ int shut = 0;
+
+- switch (event) {
+- case EV_READ:
+- if ((n = imsg_read(ibuf)) == -1)
+- fatal("imsg_read error");
+- if (n == 0) /* connection closed */
+- shut = 1;
+- break;
+- case EV_WRITE:
+- if (msgbuf_write(&ibuf->w) == -1)
+- fatal("msgbuf_write");
+- imsg_event_add(ibuf);
++ if (dispatch_read_write_event(event, ibuf, &n, &shut) != EV_READ)
+ return;
+- default:
+- fatalx("unknown event");
+- }
+
+ for (;;) {
+ if ((n = imsg_get(ibuf, &imsg)) == -1)
+--
+1.6.0.5
+
--
1.6.0.5
--- update-to-4.3-pack3.diff ends here ---
ARP-v2 is added here:
http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/net/route.h?rev=1.77
And ARP-v2 patch for OpenOSPFD was slightly discuissed here:
http://lists.freebsd.org/pipermail/freebsd-current/2008-December/001447.html
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list