- Update net/openbgpd to 4.0.

- Add some information about the configuration file and its permissions.
This commit is contained in:
Florent Thoumie 2007-07-19 11:58:59 +00:00
parent fb12d36933
commit b5ed954f0f
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=195889
15 changed files with 369 additions and 90 deletions

View file

@ -6,15 +6,14 @@
#
PORTNAME?= openbgpd
PORTVERSION?= 3.9
PORTVERSION?= 4.0
PORTREVISION?= 0
CATEGORIES= net
MASTER_SITES= ftp://ftp.openbsd.org/pub/OpenBSD/OpenBGPD/:openbsd \
${MASTER_SITE_LOCAL:S/$/:freebsd/g}
MASTER_SITE_SUBDIR= flz/openbgpd/:freebsd
DISTFILES?= ${PORTNAME}-${PORTVERSION}.tgz:openbsd,freebsd
DISTFILES+= if_media.h:freebsd pfkey_compat.c:freebsd \
hash.h:freebsd strtonum.c:freebsd
DISTFILES+= if_media.h:freebsd hash.h:freebsd strtonum.c:freebsd
DIST_SUBDIR= openbgpd
EXTRACT_ONLY= ${PORTNAME}-${PORTVERSION}.tgz
@ -30,11 +29,11 @@ MAKE_ENV= BINDIR="${PREFIX}/sbin" \
MANDIR="${PREFIX}/man/man"
COPTS+= -DRTA_LABEL=0
EXTRA_PATCHES?= ${.CURDIR}/files/stable-bgpd_bgpd.8
PLIST_FILES= sbin/bgpctl \
sbin/bgpd
SUB_FILES= pkg-message
MAN5= bgpd.conf.5
MAN8= bgpctl.8 \
bgpd.8
@ -50,9 +49,7 @@ IGNORE= requires macros present in <sys/tree.h>
post-extract:
@${CP} ${DISTDIR}/${DIST_SUBDIR}/if_media.h ${WRKSRC}/bgpctl/
@${CP} ${DISTDIR}/${DIST_SUBDIR}/pfkey_compat.c ${WRKSRC}/bgpd/
@${CP} ${DISTDIR}/${DIST_SUBDIR}/hash.h ${WRKSRC}/bgpd/
@${CP} ${DISTDIR}/${DIST_SUBDIR}/strtonum.c ${WRKSRC}/bgpctl/
post-patch:
@${REINPLACE_CMD} -e "s|%%PREFIX%%|${PREFIX}|g" \
@ -62,6 +59,8 @@ post-patch:
${WRKSRC}/bgpd/bgpd.conf.5 \
${WRKSRC}/bgpctl/Makefile \
${WRKSRC}/bgpctl/bgpctl.8
@${REINPLACE_CMD} -e "/__dead2/d" \
${WRKSRC}/bgpd/bgpd.h
@${REINPLACE_CMD} -e "s|__dead||" \
${WRKSRC}/bgpd/bgpd.c \
${WRKSRC}/bgpd/bgpd.h \
@ -88,5 +87,6 @@ do-install:
post-install:
@${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
@${CAT} ${PKGMESSAGE}
.include <bsd.port.post.mk>

View file

@ -1,6 +1,6 @@
MD5 (openbgpd/openbgpd-3.9.tgz) = 818f0e1725f7804e2ef5f7e5d2da9029
SHA256 (openbgpd/openbgpd-3.9.tgz) = 041bb2e56dd94db8e755df0825467c0f068bb3abe8e3b613b77aede13cc3fc33
SIZE (openbgpd/openbgpd-3.9.tgz) = 134112
MD5 (openbgpd/openbgpd-4.0.tgz) = aced25bd206de43738f9be9c87a6a322
SHA256 (openbgpd/openbgpd-4.0.tgz) = bc2f3f40e81824a4a7bebb18f1230658b9d0449cccddadbd3dd4f528b4f28b30
SIZE (openbgpd/openbgpd-4.0.tgz) = 141510
MD5 (openbgpd/if_media.h) = 4ff9297f5c133425dafe3ca565c0f811
SHA256 (openbgpd/if_media.h) = 58225d0ed363c2beb23426f0f8254089d4541c3334776f3750ba434d4491a1d1
SIZE (openbgpd/if_media.h) = 23762

View file

@ -0,0 +1,15 @@
--- bgpctl/Makefile 17 Aug 2006 16:46:38 -0000 1.7
+++ bgpctl/Makefile 8 Feb 2007 10:32:19 -0000
@@ -4,6 +4,7 @@
PROG= bgpctl
SRCS= bgpctl.c parser.c buffer.c imsg.c util.c
+SRCS+= fmt_scaled.c
CFLAGS+= -Wall
CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes
CFLAGS+= -Wmissing-declarations
Index: bgpctl.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpctl/bgpctl.c,v
retrieving revision 1.110
diff -u -p -r1.110 bgpctl.c

View file

@ -1,26 +1,21 @@
--- bgpctl/bgpctl.c.orig Tue Jan 24 15:28:03 2006
+++ bgpctl/bgpctl.c Mon Mar 20 11:55:29 2006
@@ -29,7 +29,11 @@
--- bgpctl/bgpctl.c 28 Aug 2006 05:28:49 -0000 1.110
+++ bgpctl/bgpctl.c 8 Feb 2007 10:32:19 -0000
@@ -29,13 +29,13 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#if defined(__OpenBSD__)
#include <util.h>
+#else /* defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) */
+#include <libutil.h>
+#endif
-#include <util.h>
#include "bgpd.h"
#include "session.h"
@@ -1032,7 +1039,11 @@
{
static char buf[16];
#include "rde.h"
#include "log.h"
#include "parser.h"
+#include "util.h"
+#if defined(__OpenBSD__)
if (fmt_scaled(num, buf) == -1)
+#else /* defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) */
+ if (humanize_number(buf, 16, num, "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL) == -1)
+#endif
snprintf(buf, sizeof(buf), "%lldB", num);
return (buf);
enum neighbor_views {
NV_DEFAULT,
Index: fmt_scaled.c
===================================================================
RCS file: fmt_scaled.c
diff -N fmt_scaled.c

View file

@ -0,0 +1,159 @@
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ bgpctl/fmt_scaled.c 8 Feb 2007 10:32:19 -0000
@@ -0,0 +1,152 @@
+/* $OpenBSD: fmt_scaled.c,v 1.8 2005/10/19 18:48:11 deraadt Exp $ */
+
+/*
+ * Copyright (c) 2001, 2002, 2003 Ian F. Darwin. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * fmt_scaled: Format numbers scaled for human comprehension
+ * scan_scaled: Scan numbers in this format.
+ *
+ * "Human-readable" output uses 4 digits max, and puts a unit suffix at
+ * the end. Makes output compact and easy-to-read esp. on huge disks.
+ * Formatting code was originally in OpenBSD "df", converted to library routine.
+ * Scanning code written for OpenBSD libutil.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include <ctype.h>
+#include <limits.h>
+
+#include "util.h"
+
+typedef enum {
+ NONE = 0, KILO = 1, MEGA = 2, GIGA = 3, TERA = 4, PETA = 5, EXA = 6
+} unit_type;
+
+/* These three arrays MUST be in sync! XXX make a struct */
+static unit_type units[] = { NONE, KILO, MEGA, GIGA, TERA, PETA, EXA };
+static char scale_chars[] = "BKMGTPE";
+static long long scale_factors[] = {
+ 1LL,
+ 1024LL,
+ 1024LL*1024,
+ 1024LL*1024*1024,
+ 1024LL*1024*1024*1024,
+ 1024LL*1024*1024*1024*1024,
+ 1024LL*1024*1024*1024*1024*1024,
+};
+#define SCALE_LENGTH (sizeof(units)/sizeof(units[0]))
+
+#define MAX_DIGITS (SCALE_LENGTH * 3) /* XXX strlen(sprintf("%lld", -1)? */
+
+/* Format the given "number" into human-readable form in "result".
+ * Result must point to an allocated buffer of length FMT_SCALED_STRSIZE.
+ * Return 0 on success, -1 and errno set if error.
+ */
+int
+fmt_scaled(long long number, char *result)
+{
+ long long abval, fract = 0;
+ unsigned int i;
+ unit_type unit = NONE;
+
+ abval = (number < 0LL) ? -number : number; /* no long long_abs yet */
+
+ /* Not every negative long long has a positive representation.
+ * Also check for numbers that are just too darned big to format
+ */
+ if (abval < 0 || abval / 1024 >= scale_factors[SCALE_LENGTH-1]) {
+ errno = ERANGE;
+ return -1;
+ }
+
+ /* scale whole part; get unscaled fraction */
+ for (i = 0; i < SCALE_LENGTH; i++) {
+ if (abval/1024 < scale_factors[i]) {
+ unit = units[i];
+ fract = (i == 0) ? 0 : abval % scale_factors[i];
+ number /= scale_factors[i];
+ if (i > 0)
+ fract /= scale_factors[i - 1];
+ break;
+ }
+ }
+
+ fract = (10 * fract + 512) / 1024;
+ /* if the result would be >= 10, round main number */
+ if (fract == 10) {
+ if (number >= 0)
+ number++;
+ else
+ number--;
+ fract = 0;
+ }
+
+ if (number == 0)
+ strlcpy(result, "0B", FMT_SCALED_STRSIZE);
+ else if (unit == NONE || number >= 100 || number <= -100) {
+ if (fract >= 5) {
+ if (number >= 0)
+ number++;
+ else
+ number--;
+ }
+ (void)snprintf(result, FMT_SCALED_STRSIZE, "%lld%c",
+ number, scale_chars[unit]);
+ } else
+ (void)snprintf(result, FMT_SCALED_STRSIZE, "%lld.%1lld%c",
+ number, fract, scale_chars[unit]);
+
+ return 0;
+}
+
+#ifdef MAIN
+/*
+ * This is the original version of the program in the man page.
+ * Copy-and-paste whatever you need from it.
+ */
+int
+main(int argc, char **argv)
+{
+ char *cinput = "1.5K", buf[FMT_SCALED_STRSIZE];
+ long long ninput = 10483892, result;
+
+ if (scan_scaled(cinput, &result) == 0)
+ printf("\"%s\" -> %lld\n", cinput, result);
+ else
+ perror(cinput);
+
+ if (fmt_scaled(ninput, buf) == 0)
+ printf("%lld -> \"%s\"\n", ninput, buf);
+ else
+ fprintf(stderr, "%lld invalid (%s)\n", ninput, strerror(errno));
+
+ return 0;
+}
+#endif
Index: util.h
===================================================================
RCS file: util.h
diff -N util.h

View file

@ -1,12 +0,0 @@
--- bgpctl/parser.c.orig Mon Mar 20 11:57:05 2006
+++ bgpctl/parser.c Mon Mar 20 11:57:27 2006
@@ -29,6 +29,9 @@
#include "parser.h"
+/* Ok, this is awful. */
+#include "strtonum.c"
+
enum token_type {
NOTOKEN,
ENDTOKEN,

View file

@ -0,0 +1,11 @@
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ bgpctl/util.h 8 Feb 2007 10:32:19 -0000
@@ -0,0 +1,8 @@
+/*
+ * Written by Claudio Jeker, Public Domain
+ */
+
+#define FMT_SCALED_STRSIZE 7
+
+int fmt_scaled(long long number, char *result);
+

View file

@ -1,6 +1,6 @@
--- bgpd/bgpd.8.orig
+++ bgpd/bgpd.8
@@ -46,9 +46,9 @@
--- bgpd/bgpd.8.orig Tue May 16 17:14:46 2006
+++ bgpd/bgpd.8 Tue May 16 17:16:27 2006
@@ -48,9 +48,9 @@
.Nm
is usually started at boot time, and can be enabled by
setting the following in
@ -8,11 +8,11 @@
+.Pa /etc/rc.conf :
.Pp
-.Dl bgpd_flags=\&"\&"
+.Dl openbgpd_enable=\&"YES\&"
+.Dl openbgpd_flags=\&"YES\&"
.Pp
See
.Xr rc 8
@@ -90,7 +90,7 @@
@@ -92,7 +92,7 @@
.Ar file
as the configuration file,
instead of the default
@ -21,13 +21,11 @@
.It Fl n
Configtest mode.
Only check the configuration file for validity.
@@ -98,8 +98,8 @@
Produce more verbose output.
@@ -110,7 +110,7 @@
.El
.Sh FILES
-.Bl -tag -width "/etc/bgpd.confXXX" -compact
.Bl -tag -width "/var/run/bgpd.sockXXX" -compact
-.It Pa /etc/bgpd.conf
+.Bl -tag -width "%%PREFIX%%/etc/bgpd.confXXX" -compact
+.It Pa %%PREFIX%%/etc/bgpd.conf
default
.Nm

View file

@ -1,10 +1,11 @@
--- bgpd/bgpd.h.orig Thu Jul 19 12:52:38 2007
+++ bgpd/bgpd.h Thu Jul 19 12:52:28 2007
@@ -30,9 +30,11 @@
#include <poll.h>
#include <stdarg.h>
$FreeBSD$
--- bgpd/bgpd.h.orig
+++ bgpd/bgpd.h
@@ -31,7 +31,7 @@
+#define RTA_LABEL 0
+
#define BGP_VERSION 4
#define BGP_PORT 179
-#define CONFFILE "/etc/bgpd.conf"
@ -12,3 +13,38 @@ $FreeBSD$
#define BGPD_USER "_bgpd"
#define PEER_DESCR_LEN 32
#define PFTABLE_LEN 16
@@ -467,12 +469,12 @@
struct kroute_label {
struct kroute kr;
- char label[RTLABEL_LEN];
+ char label[PFTABLE_LEN];
};
struct kroute6_label {
struct kroute6 kr;
- char label[RTLABEL_LEN];
+ char label[PFTABLE_LEN];
};
#define F_RIB_ELIGIBLE 0x01
@@ -644,7 +646,7 @@
struct bgpd_addr nexthop;
struct filter_community community;
char pftable[PFTABLE_LEN];
- char rtlabel[RTLABEL_LEN];
+ char rtlabel[PFTABLE_LEN];
} action;
enum action_types type;
};
@@ -709,8 +711,8 @@
void log_warnx(const char *, ...);
void log_info(const char *, ...);
void log_debug(const char *, ...);
-void fatal(const char *) __dead;
-void fatalx(const char *) __dead;
+void fatal(const char *) ;
+void fatalx(const char *) ;
/* parse.y */
int cmdline_symset(char *);

View file

@ -0,0 +1,65 @@
--- bgpd/carp.c 19 Jun 2006 12:06:24 -0000 1.3
+++ bgpd/carp.c 8 Feb 2007 10:31:16 -0000
@@ -102,28 +102,7 @@ carp_demote_shutdown(void)
int
carp_demote_get(char *group)
{
- int s;
- struct ifgroupreq ifgr;
-
- if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
- log_warn("carp_demote_get: socket");
- return (-1);
- }
-
- bzero(&ifgr, sizeof(ifgr));
- strlcpy(ifgr.ifgr_name, group, sizeof(ifgr.ifgr_name));
-
- if (ioctl(s, SIOCGIFGATTR, (caddr_t)&ifgr) == -1) {
- if (errno == ENOENT)
- log_warnx("group \"%s\" does not exist", group);
- else
- log_warn("carp_demote_get: ioctl");
- close(s);
- return (-1);
- }
-
- close(s);
- return ((int)ifgr.ifgr_attrib.ifg_carp_demoted);
+ return (-1);
}
int
@@ -156,26 +135,5 @@ carp_demote_set(char *group, int demote)
int
carp_demote_ioctl(char *group, int demote)
{
- int s, res;
- struct ifgroupreq ifgr;
-
- if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
- log_warn("carp_demote_get: socket");
- return (-1);
- }
-
- bzero(&ifgr, sizeof(ifgr));
- strlcpy(ifgr.ifgr_name, group, sizeof(ifgr.ifgr_name));
- ifgr.ifgr_attrib.ifg_carp_demoted = demote;
-
- if ((res = ioctl(s, SIOCSIFGATTR, (caddr_t)&ifgr)) == -1)
- log_warn("unable to %s the demote state "
- "of group '%s'", (demote > 0) ? "increment" : "decrement",
- group);
- else
- log_info("%s the demote state of group '%s'",
- (demote > 0) ? "incremented" : "decremented", group);
-
- close (s);
- return (res);
+ return (-1);
}
Index: kroute.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/kroute.c,v
retrieving revision 1.147
diff -u -p -r1.147 kroute.c

View file

@ -1,6 +1,6 @@
--- bgpd/kroute.c.orig 23 Feb 2006 15:25:18 -0000 1.144
+++ bgpd/kroute.c 16 Mar 2006 18:09:15 -0000
@@ -1723,7 +1723,9 @@ send_rtmsg(int fd, int action, struct kr
--- bgpd/kroute.c 3 Aug 2006 22:40:25 -0000 1.147
+++ bgpd/kroute.c 8 Feb 2007 10:31:16 -0000
@@ -1732,7 +1732,9 @@ send_rtmsg(int fd, int action, struct kr
struct sockaddr_in prefix;
struct sockaddr_in nexthop;
struct sockaddr_in mask;
@ -10,7 +10,7 @@
} r;
if (kr_state.fib_sync == 0)
@@ -1756,9 +1758,11 @@ send_rtmsg(int fd, int action, struct kr
@@ -1765,9 +1767,11 @@ send_rtmsg(int fd, int action, struct kr
r.mask.sin_family = AF_INET;
r.mask.sin_addr.s_addr = htonl(prefixlen2mask(kroute->prefixlen));
@ -22,7 +22,7 @@
retry:
if (write(fd, &r, sizeof(r)) == -1) {
@@ -1799,7 +1803,9 @@ send_rt6msg(int fd, int action, struct k
@@ -1808,7 +1812,9 @@ send_rt6msg(int fd, int action, struct k
struct sockaddr_in6 prefix;
struct sockaddr_in6 nexthop;
struct sockaddr_in6 mask;
@ -32,7 +32,7 @@
} r;
if (kr_state.fib_sync == 0)
@@ -1832,9 +1838,11 @@ send_rt6msg(int fd, int action, struct k
@@ -1841,9 +1847,11 @@ send_rt6msg(int fd, int action, struct k
memcpy(&r.mask.sin6_addr, prefixlen2mask6(kroute->prefixlen),
sizeof(struct in6_addr));
@ -44,3 +44,7 @@
retry:
if (write(fd, &r, sizeof(r)) == -1) {
Index: pfkey_compat.c
===================================================================
RCS file: pfkey_compat.c
diff -N pfkey_compat.c

View file

@ -0,0 +1,30 @@
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ bgpd/pfkey_compat.c 8 Feb 2007 10:31:16 -0000
@@ -0,0 +1,27 @@
+#include "bgpd.h"
+#include "session.h"
+
+int
+pfkey_establish(struct peer *p)
+{
+ if (p->conf.auth.method)
+ return (-1);
+ return (0);
+}
+
+int
+pfkey_remove(struct peer *p)
+{
+ if (p->conf.auth.method)
+ return (-1);
+ return (0);
+}
+
+int
+pfkey_init(struct bgpd_sysdep *sysdep)
+{
+ log_warnx("no kernel support for PF_KEY");
+ sysdep->no_pfkey = 1;
+ return (0);
+}
+

View file

@ -1,13 +0,0 @@
$FreeBSD$
--- bgpd/rde_filter.c.orig
+++ bgpd/rde_filter.c
@@ -16,6 +16,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/types.h>
+#include <sys/limits.h>
#include <sys/queue.h>
#include <stdlib.h>

View file

@ -1,15 +0,0 @@
--- bgpd/session.c.orig Thu Sep 9 23:53:57 2004
+++ bgpd/session.c Sun Mar 20 15:33:51 2005
@@ -206,9 +206,12 @@
setproctitle("session engine");
bgpd_process = PROC_SE;
+/* we don't have PF_KEY implemented in a way OpenBSD has
+
if (pfkey_init(&sysdep) == -1)
fatalx("pfkey setup failed");
+*/
if (setgroups(1, &pw->pw_gid) ||
setegid(pw->pw_gid) || setgid(pw->pw_gid) ||
seteuid(pw->pw_uid) || setuid(pw->pw_uid))

View file

@ -0,0 +1,6 @@
------------------------------------------------------------------
OpenBGPD has been successfully installed.
Configuration file must be created at %%PREFIX%%/etc/bgpd.conf
and permission set to 0600.
------------------------------------------------------------------