1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-25 04:43:33 +00:00

- Update to 4.2.

- Provide LINK_STATE_IS_UP macros that is missing in FreeBSD.
- Disable CARP demotion: FreeBSD has no support for it.
- Disable check for the routing table number: FreeBSD has single routing table
  now.
- Disable route labeling: FreeBSD has no support for it.

PR:		121831
Submitted by:	Matthieu Guegan <matthieu@virtua.ch>
Approved by:	maintainer timeout (9 months)
This commit is contained in:
Stefan Walter 2008-12-17 15:58:32 +00:00
parent e6377ab3b0
commit 073943d1f3
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=224336
18 changed files with 522 additions and 114 deletions

View File

@ -6,7 +6,7 @@
#
PORTNAME?= openbgpd
PORTVERSION?= 4.0
PORTVERSION?= 4.2
PORTREVISION?= 0
CATEGORIES= net
MASTER_SITES= ftp://ftp.openbsd.org/pub/OpenBSD/OpenBGPD/:openbsd \
@ -68,7 +68,9 @@ post-patch:
@${REINPLACE_CMD} -e "s|__dead||" \
${WRKSRC}/bgpd/bgpd.c \
${WRKSRC}/bgpd/bgpd.h \
${WRKSRC}/bgpctl/bgpctl.c
${WRKSRC}/bgpctl/bgpctl.c \
${WRKSRC}/bgpctl/irrfilter.h \
${WRKSRC}/bgpctl/irrfilter.c
@${REINPLACE_CMD} -e "s|SIMPLEQ|STAILQ|" ${WRKSRC}/bgpd/*.[chy]
@${REINPLACE_CMD} -e "s|<net/if_media.h>|\"if_media.h\"|" ${WRKSRC}/bgpctl/bgpctl.c
@${REINPLACE_CMD} -e "s|pfkey.c|pfkey_compat.c|" ${WRKSRC}/bgpd/Makefile
@ -78,6 +80,7 @@ post-patch:
${WRKSRC}/bgpd/rde_update.c
@${REINPLACE_CMD} -e "s|rtm_fmask|rtm_use|" ${WRKSRC}/bgpd/kroute.c
@${REINPLACE_CMD} -e "s|RTLABEL_LEN|PFTABLE_LEN|" ${WRKSRC}/bgpd/bgpd.h
@${REINPLACE_CMD} -e "s|ulong|unsigned\ long|" ${WRKSRC}/bgpctl/irr_parser.c
do-build:
.for i in ${SUBDIRS}

View File

@ -1,12 +1,9 @@
MD5 (openbgpd/openbgpd-4.0.tgz) = aced25bd206de43738f9be9c87a6a322
SHA256 (openbgpd/openbgpd-4.0.tgz) = bc2f3f40e81824a4a7bebb18f1230658b9d0449cccddadbd3dd4f528b4f28b30
SIZE (openbgpd/openbgpd-4.0.tgz) = 141510
MD5 (openbgpd/openbgpd-4.2.tgz) = e5f16db7f76648f08eec67727dc5342f
SHA256 (openbgpd/openbgpd-4.2.tgz) = fb64f17acb9360bf91c7d76f406b86fbb04578c256a48d178e9e7e198e28e0de
SIZE (openbgpd/openbgpd-4.2.tgz) = 158762
MD5 (openbgpd/if_media.h) = 4ff9297f5c133425dafe3ca565c0f811
SHA256 (openbgpd/if_media.h) = 58225d0ed363c2beb23426f0f8254089d4541c3334776f3750ba434d4491a1d1
SIZE (openbgpd/if_media.h) = 23762
MD5 (openbgpd/pfkey_compat.c) = 8c3bdf02fd308b327bd30e09674c1858
SHA256 (openbgpd/pfkey_compat.c) = 46f559c945552ec11174d218c24eeacb3d0bc1dc010a80f07af525b751df1180
SIZE (openbgpd/pfkey_compat.c) = 360
MD5 (openbgpd/hash.h) = 0c397692b9b152f1bca968b6248bc09c
SHA256 (openbgpd/hash.h) = 0c5561c6765325f49d82d5c5fd9471dbfadf21f44e554758eb112a23f7c317b1
SIZE (openbgpd/hash.h) = 3488

View File

@ -1,15 +1,10 @@
--- 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
--- bgpctl/Makefile 2007-03-03 12:45:30.000000000 +0100
+++ bgpctl/Makefile 2008-03-18 13:27:29.000000000 +0100
@@ -6,6 +6,7 @@
SRCS= bgpctl.c parser.c buffer.c imsg.c util.c
SRCS+= irrfilter.c whois.c irr_asset.c irr_prefix.c irr_output.c
SRCS+= irr_parser.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,15 +1,10 @@
$FreeBSD$
--- bgpctl/bgpctl.8.orig
+++ bgpctl/bgpctl.8
@@ -138,8 +138,8 @@
and message counters.
--- bgpctl/bgpctl.8 2007-05-31 21:20:22.000000000 +0200
+++ bgpctl/bgpctl.8 2008-03-18 14:51:41.000000000 +0100
@@ -240,7 +240,7 @@
.El
.Sh FILES
-.Bl -tag -width "/etc/bgpd.conf" -compact
.Bl -tag -width "/var/run/bgpd.sockXXX" -compact
-.It Pa /etc/bgpd.conf
+.Bl -tag -width "%%PREFIX%%/etc/bgpd.conf" -compact
+.It Pa %%PREFIX%%/etc/bgpd.conf
default
.Xr bgpd 8

View File

@ -1,6 +1,14 @@
--- 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 @@
--- bgpctl/bgpctl.c 2007-08-06 21:16:06.000000000 +0200
+++ bgpctl/bgpctl.c 2008-03-18 14:27:24.000000000 +0100
@@ -20,7 +20,6 @@
#include <sys/socket.h>
#include <sys/un.h>
#include <net/if.h>
-#include <net/if_media.h>
#include <net/if_types.h>
#include <err.h>
@@ -29,14 +28,19 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@ -12,10 +20,12 @@
#include "log.h"
#include "parser.h"
+#include "util.h"
#include "irrfilter.h"
+#include "if_media.h"
+
+#if defined(__FreeBSD__) /* FreeBSD has no LINK_STATE_IS_UP macro. */
+#define LINK_STATE_IS_UP(_s) ((_s) >= LINK_STATE_UP)
+#endif /* defined(__FreeBSD__) */
enum neighbor_views {
NV_DEFAULT,
Index: fmt_scaled.c
===================================================================
RCS file: fmt_scaled.c
diff -N fmt_scaled.c

View File

@ -1,7 +1,7 @@
--- /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 $ */
+++ bgpctl/fmt_scaled.c 2008-03-18 13:27:29.000000000 +0100
@@ -0,0 +1,268 @@
+/* $OpenBSD: fmt_scaled.c,v 1.9 2007/03/20 03:42:52 tedu Exp $ */
+
+/*
+ * Copyright (c) 2001, 2002, 2003 Ian F. Darwin. All rights reserved.
@ -68,6 +68,122 @@
+
+#define MAX_DIGITS (SCALE_LENGTH * 3) /* XXX strlen(sprintf("%lld", -1)? */
+
+/** Convert the given input string "scaled" into numeric in "result".
+ * Return 0 on success, -1 and errno set on error.
+ */
+int
+scan_scaled(char *scaled, long long *result)
+{
+ char *p = scaled;
+ int sign = 0;
+ unsigned int i, ndigits = 0, fract_digits = 0;
+ long long scale_fact = 1, whole = 0, fpart = 0;
+
+ /* Skip leading whitespace */
+ while (isascii(*p) && isspace(*p))
+ ++p;
+
+ /* Then at most one leading + or - */
+ while (*p == '-' || *p == '+') {
+ if (*p == '-') {
+ if (sign) {
+ errno = EINVAL;
+ return -1;
+ }
+ sign = -1;
+ ++p;
+ } else if (*p == '+') {
+ if (sign) {
+ errno = EINVAL;
+ return -1;
+ }
+ sign = +1;
+ ++p;
+ }
+ }
+
+ /* Main loop: Scan digits, find decimal point, if present.
+ * We don't allow exponentials, so no scientific notation
+ * (but note that E for Exa might look like e to some!).
+ * Advance 'p' to end, to get scale factor.
+ */
+ for (; isascii(*p) && (isdigit(*p) || *p=='.'); ++p) {
+ if (*p == '.') {
+ if (fract_digits > 0) { /* oops, more than one '.' */
+ errno = EINVAL;
+ return -1;
+ }
+ fract_digits = 1;
+ continue;
+ }
+
+ i = (*p) - '0'; /* whew! finally a digit we can use */
+ if (fract_digits > 0) {
+ if (fract_digits >= MAX_DIGITS-1)
+ /* ignore extra fractional digits */
+ continue;
+ fract_digits++; /* for later scaling */
+ fpart *= 10;
+ fpart += i;
+ } else { /* normal digit */
+ if (++ndigits >= MAX_DIGITS) {
+ errno = ERANGE;
+ return -1;
+ }
+ whole *= 10;
+ whole += i;
+ }
+ }
+
+ if (sign) {
+ whole *= sign;
+ fpart *= sign;
+ }
+
+ /* If no scale factor given, we're done. fraction is discarded. */
+ if (!*p) {
+ *result = whole;
+ return 0;
+ }
+
+ /* Validate scale factor, and scale whole and fraction by it. */
+ for (i = 0; i < SCALE_LENGTH; i++) {
+
+ /** Are we there yet? */
+ if (*p == scale_chars[i] ||
+ *p == tolower(scale_chars[i])) {
+
+ /* If it ends with alphanumerics after the scale char, bad. */
+ if (isalnum(*(p+1))) {
+ errno = EINVAL;
+ return -1;
+ }
+ scale_fact = scale_factors[i];
+
+ /* scale whole part */
+ whole *= scale_fact;
+
+ /* truncate fpart so it does't overflow.
+ * then scale fractional part.
+ */
+ while (fpart >= LLONG_MAX / scale_fact) {
+ fpart /= 10;
+ fract_digits--;
+ }
+ fpart *= scale_fact;
+ if (fract_digits > 0) {
+ for (i = 0; i < fract_digits -1; i++)
+ fpart /= 10;
+ }
+ whole += fpart;
+ *result = whole;
+ return 0;
+ }
+ }
+ errno = ERANGE;
+ return -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.
@ -153,7 +269,3 @@
+ return 0;
+}
+#endif
Index: util.h
===================================================================
RCS file: util.h
diff -N util.h

View File

@ -1,11 +1,122 @@
--- /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
--- /dev/null 1970-01-01 01:00:00.000000000 +0100
+++ bgpctl/util.h 2008-03-18 13:27:29.000000000 +0100
@@ -0,0 +1,119 @@
+/* $OpenBSD: util.h,v 1.27 2006/06/14 02:14:25 krw Exp $ */
+/* $NetBSD: util.h,v 1.2 1996/05/16 07:00:22 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 1995
+ * The Regents of the University of California. All rights reserved.
+ * Portions Copyright (c) 1996, Jason Downs. 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. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
+ */
+
+#define FMT_SCALED_STRSIZE 7
+#ifndef _UTIL_H_
+#define _UTIL_H_
+
+int fmt_scaled(long long number, char *result);
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+/*
+ * fparseln() specific operation flags.
+ */
+#define FPARSELN_UNESCESC 0x01
+#define FPARSELN_UNESCCONT 0x02
+#define FPARSELN_UNESCCOMM 0x04
+#define FPARSELN_UNESCREST 0x08
+#define FPARSELN_UNESCALL 0x0f
+
+/*
+ * opendev() specific operation flags.
+ */
+#define OPENDEV_PART 0x01 /* Try to open the raw partition. */
+#define OPENDEV_BLCK 0x04 /* Open block, not character device. */
+
+/*
+ * uucplock(3) specific flags.
+ */
+#define UU_LOCK_INUSE (1)
+#define UU_LOCK_OK (0)
+#define UU_LOCK_OPEN_ERR (-1)
+#define UU_LOCK_READ_ERR (-2)
+#define UU_LOCK_CREAT_ERR (-3)
+#define UU_LOCK_WRITE_ERR (-4)
+#define UU_LOCK_LINK_ERR (-5)
+#define UU_LOCK_TRY_ERR (-6)
+#define UU_LOCK_OWNER_ERR (-7)
+
+/*
+ * fmt_scaled(3) specific flags.
+ */
+#define FMT_SCALED_STRSIZE 7 /* minus sign, 4 digits, suffix, null byte */
+
+/*
+ * stub struct definitions.
+ */
+struct __sFILE;
+struct login_cap;
+struct passwd;
+struct termios;
+struct utmp;
+struct winsize;
+
+__BEGIN_DECLS
+char *fparseln(struct __sFILE *, size_t *, size_t *, const char[3], int);
+void login(struct utmp *);
+int login_tty(int);
+int logout(const char *);
+void logwtmp(const char *, const char *, const char *);
+int opendev(char *, int, int, char **);
+int pidfile(const char *);
+void pw_setdir(const char *);
+char *pw_file(const char *);
+int pw_lock(int retries);
+int pw_mkdb(char *, int);
+int pw_abort(void);
+void pw_init(void);
+void pw_edit(int, const char *);
+void pw_prompt(void);
+void pw_copy(int, int, const struct passwd *, const struct passwd *);
+int pw_scan(char *, struct passwd *, int *);
+void pw_error(const char *, int, int);
+int openpty(int *, int *, char *, struct termios *, struct winsize *);
+int opendisk(const char *path, int flags, char *buf, size_t buflen,
+ int iscooked);
+pid_t forkpty(int *, char *, struct termios *, struct winsize *);
+int getmaxpartitions(void);
+int getrawpartition(void);
+void login_fbtab(const char *, uid_t, gid_t);
+int login_check_expire(struct __sFILE *, struct passwd *, char *, int);
+char *readlabelfs(char *, int);
+const char *uu_lockerr(int _uu_lockresult);
+int uu_lock(const char *_ttyname);
+int uu_lock_txfr(const char *_ttyname, pid_t _pid);
+int uu_unlock(const char *_ttyname);
+int fmt_scaled(long long number, char *result);
+int scan_scaled(char *scaled, long long *result);
+__END_DECLS
+
+#endif /* !_UTIL_H_ */

View File

@ -1,5 +1,5 @@
--- bgpd/bgpd.8.orig Tue May 16 17:14:46 2006
+++ bgpd/bgpd.8 Tue May 16 17:16:27 2006
--- bgpd/bgpd.8 2007-05-31 21:20:22.000000000 +0200
+++ bgpd/bgpd.8 2008-03-18 14:54:19.000000000 +0100
@@ -48,9 +48,9 @@
.Nm
is usually started at boot time, and can be enabled by
@ -12,7 +12,7 @@
.Pp
See
.Xr rc 8
@@ -92,7 +92,7 @@
@@ -117,7 +117,7 @@
.Ar file
as the configuration file,
instead of the default
@ -21,7 +21,7 @@
.It Fl n
Configtest mode.
Only check the configuration file for validity.
@@ -110,7 +110,7 @@
@@ -135,7 +135,7 @@
.El
.Sh FILES
.Bl -tag -width "/var/run/bgpd.sockXXX" -compact

View File

@ -1,9 +1,6 @@
$FreeBSD$
--- bgpd/bgpd.conf.5.orig
+++ bgpd/bgpd.conf.5
@@ -431,11 +431,11 @@
--- bgpd/bgpd.conf.5 2007-05-31 21:20:22.000000000 +0200
+++ bgpd/bgpd.conf.5 2008-03-18 14:55:31.000000000 +0100
@@ -611,11 +611,11 @@
With
.Xr isakmpd 8 ,
it is sufficient to copy the peer's public key, found in
@ -17,8 +14,8 @@ $FreeBSD$
The local public key must be copied to the peer in the same way.
As
.Xr bgpd 8
@@ -819,8 +819,8 @@
.Em AS path .
@@ -1133,8 +1133,8 @@
is a local non-transitive attribute and a bgpd-specific extension.
.El
.Sh FILES
-.Bl -tag -width "/etc/bgpd.conf" -compact

View File

@ -1,6 +1,6 @@
--- 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)
--- bgpd/carp.c 2007-04-23 16:52:28.000000000 +0200
+++ bgpd/carp.c 2008-03-18 13:27:29.000000000 +0100
@@ -102,28 +102,7 @@
int
carp_demote_get(char *group)
{
@ -21,16 +21,15 @@
- else
- log_warn("carp_demote_get: ioctl");
- close(s);
- return (-1);
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)
@@ -156,26 +135,5 @@
int
carp_demote_ioctl(char *group, int demote)
{
@ -39,7 +38,7 @@
-
- if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
- log_warn("carp_demote_get: socket");
- return (-1);
return (-1);
- }
-
- bzero(&ifgr, sizeof(ifgr));
@ -54,12 +53,6 @@
- log_info("%s the demote state of group '%s'",
- (demote > 0) ? "incremented" : "decremented", group);
-
- close (s);
- 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,50 +1,136 @@
--- 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;
+#if 0
struct sockaddr_rtlabel label;
+#endif
} r;
--- bgpd/kroute.c 2007-05-11 13:27:59.000000000 +0200
+++ bgpd/kroute.c 2008-05-28 11:04:19.000000000 +0200
@@ -1738,7 +1738,9 @@
struct sockaddr_in prefix;
struct sockaddr_in nexthop;
struct sockaddr_in mask;
+#if !defined(__FreeBSD__) /* FreeBSD has no route labeling. */
struct sockaddr_rtlabel label;
+#endif /* !defined(__FreeBSD__) */
int iovcnt = 0;
if (kr_state.fib_sync == 0)
@@ -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));
+#if 0
r.label.sr_len = sizeof(r.label);
strlcpy(r.label.sr_label, rtlabel_id2name(kroute->labelid),
sizeof(r.label.sr_label));
@@ -1748,14 +1750,16 @@
bzero(&hdr, sizeof(hdr));
hdr.rtm_version = RTM_VERSION;
hdr.rtm_type = action;
+#if !defined(__FreeBSD__) /* XXX: FreeBSD has no multiple routing tables */
hdr.rtm_tableid = kr_state.rtableid;
+#endif
hdr.rtm_flags = RTF_PROTO1;
if (kroute->flags & F_BLACKHOLE)
hdr.rtm_flags |= RTF_BLACKHOLE;
if (kroute->flags & F_REJECT)
hdr.rtm_flags |= RTF_REJECT;
if (action == RTM_CHANGE) /* reset these flags on change */
- hdr.rtm_fmask = RTF_REJECT|RTF_BLACKHOLE;
+ hdr.rtm_use = RTF_REJECT|RTF_BLACKHOLE;
hdr.rtm_seq = kr_state.rtseq++; /* overflow doesn't matter */
hdr.rtm_msglen = sizeof(hdr);
/* adjust iovec */
@@ -1799,6 +1803,7 @@
iov[iovcnt++].iov_len = sizeof(mask);
if (kroute->labelid) {
+#if !defined(__FreeBSD__) /* FreeBSD has no route labeling. */
bzero(&label, sizeof(label));
label.sr_len = sizeof(label);
strlcpy(label.sr_label, rtlabel_id2name(kroute->labelid),
@@ -1809,6 +1814,7 @@
/* adjust iovec */
iov[iovcnt].iov_base = &label;
iov[iovcnt++].iov_len = sizeof(label);
+#endif /* !defined(__FreeBSD__) */
}
retry:
if (write(fd, &r, sizeof(r)) == -1) {
@@ -1808,7 +1812,9 @@ send_rt6msg(int fd, int action, struct k
struct sockaddr_in6 prefix;
struct sockaddr_in6 nexthop;
struct sockaddr_in6 mask;
+#if 0
struct sockaddr_rtlabel label;
+#endif
} r;
@@ -1850,7 +1856,9 @@
struct sockaddr_in6 prefix;
struct sockaddr_in6 nexthop;
struct sockaddr_in6 mask;
+#if !defined(__FreeBSD__) /* FreeBSD has no route labeling. */
struct sockaddr_rtlabel label;
+#endif /* !defined(__FreeBSD__) */
int iovcnt = 0;
if (kr_state.fib_sync == 0)
@@ -1841,9 +1847,11 @@ send_rt6msg(int fd, int action, struct k
memcpy(&r.mask.sin6_addr, prefixlen2mask6(kroute->prefixlen),
sizeof(struct in6_addr));
+#if 0
r.label.sr_len = sizeof(r.label);
strlcpy(r.label.sr_label, rtlabel_id2name(kroute->labelid),
sizeof(r.label.sr_label));
@@ -1860,14 +1868,16 @@
bzero(&hdr, sizeof(hdr));
hdr.rtm_version = RTM_VERSION;
hdr.rtm_type = action;
+#if !defined(__FreeBSD__) /* XXX: FreeBSD has no multiple routing tables */
hdr.rtm_tableid = kr_state.rtableid;
+#endif
hdr.rtm_flags = RTF_PROTO1;
if (kroute->flags & F_BLACKHOLE)
hdr.rtm_flags |= RTF_BLACKHOLE;
if (kroute->flags & F_REJECT)
hdr.rtm_flags |= RTF_REJECT;
if (action == RTM_CHANGE) /* reset these flags on change */
- hdr.rtm_fmask = RTF_REJECT|RTF_BLACKHOLE;
+ hdr.rtm_use = RTF_REJECT|RTF_BLACKHOLE;
hdr.rtm_seq = kr_state.rtseq++; /* overflow doesn't matter */
hdr.rtm_msglen = sizeof(hdr);
/* adjust iovec */
@@ -1914,6 +1924,7 @@
iov[iovcnt++].iov_len = sizeof(mask);
if (kroute->labelid) {
+#if !defined(__FreeBSD__) /* FreeBSD has no route labeling. */
bzero(&label, sizeof(label));
label.sr_len = sizeof(label);
strlcpy(label.sr_label, rtlabel_id2name(kroute->labelid),
@@ -1924,6 +1935,7 @@
/* adjust iovec */
iov[iovcnt].iov_base = &label;
iov[iovcnt++].iov_len = sizeof(label);
+#endif /* !defined(__FreeBSD__) */
}
retry:
if (write(fd, &r, sizeof(r)) == -1) {
Index: pfkey_compat.c
===================================================================
RCS file: pfkey_compat.c
diff -N pfkey_compat.c
@@ -1960,8 +1972,8 @@
int
fetchtable(u_int rtableid, int connected_only)
{
- size_t len;
- int mib[7];
+ size_t len;
+ int mib[6];
char *buf, *next, *lim;
struct rt_msghdr *rtm;
struct sockaddr *sa, *gw, *rti_info[RTAX_MAX];
@@ -1976,9 +1988,8 @@
mib[3] = 0;
mib[4] = NET_RT_DUMP;
mib[5] = 0;
- mib[6] = rtableid;
- if (sysctl(mib, 7, NULL, &len, NULL, 0) == -1) {
+ if (sysctl(mib, 6, NULL, &len, NULL, 0) == -1) {
if (rtableid != 0 && errno == EINVAL) /* table nonexistant */
return (0);
log_warn("sysctl");
@@ -1988,7 +1999,7 @@
log_warn("fetchtable");
return (-1);
}
- if (sysctl(mib, 7, buf, &len, NULL, 0) == -1) {
+ if (sysctl(mib, 6, buf, &len, NULL, 0) == -1) {
log_warn("sysctl");
free(buf);
return (-1);
@@ -2240,12 +2251,14 @@
continue;
connected_only = 0;
+#if !defined(__FreeBSD__) /* XXX: FreeBSD has no multiple routing tables */
if (rtm->rtm_tableid != kr_state.rtableid) {
if (rtm->rtm_tableid == 0)
connected_only = 1;
else
continue;
}
+#endif
if (dispatch_rtmsg_addr(rtm, rti_info,
connected_only) == -1)

View File

@ -0,0 +1,19 @@
--- bgpd/parse.y 2007-05-31 20:38:58.000000000 +0200
+++ bgpd/parse.y 2008-03-18 13:27:29.000000000 +0100
@@ -523,11 +523,16 @@
free($4);
}
| RTABLE number {
+#ifdef __FreeBSD__
+ yyerror("rtable id not supported in FreeBSD, yet");
+ YYERROR;
+#else
if ($2 > RT_TABLEID_MAX || $2 < 0) {
yyerror("invalid rtable id");
YYERROR;
}
conf->rtableid = $2;
+#endif
}
;

View File

@ -0,0 +1,11 @@
--- bgpd/printconf.c 2008-03-18 15:24:06.000000000 +0100
+++ bgpd/printconf.c 2008-03-18 13:27:29.000000000 +0100
@@ -24,6 +24,8 @@
#include "mrt.h"
#include "session.h"
+#include <limits.h>
+
void print_op(enum comp_ops);
void print_community(int, int);
void print_set(struct filter_set_head *);

View File

@ -0,0 +1,20 @@
--- bgpd/rde_attr.c 2007-05-22 16:03:31.000000000 +0200
+++ bgpd/rde_attr.c 2008-03-18 15:30:31.000000000 +0100
@@ -17,7 +17,6 @@
*/
#include <sys/types.h>
-#include <sys/hash.h>
#include <sys/queue.h>
#include <netinet/in.h>
@@ -28,6 +27,9 @@
#include "bgpd.h"
#include "rde.h"
+#include "hash.h"
+
+#include <limits.h>
int
attr_write(void *p, u_int16_t p_len, u_int8_t flags, u_int8_t type,

View File

@ -0,0 +1,17 @@
--- bgpd/rde_rib.c 2008-03-18 15:39:58.000000000 +0100
+++ bgpd/rde_rib.c 2008-03-18 15:31:36.000000000 +0100
@@ -18,13 +18,13 @@
#include <sys/types.h>
#include <sys/queue.h>
-#include <sys/hash.h>
#include <stdlib.h>
#include <string.h>
#include "bgpd.h"
#include "rde.h"
+#include "hash.h"
/*
* BGP RIB -- Routing Information Base

View File

@ -0,0 +1,19 @@
--- bgpd/rde_update.c 2008-03-18 15:40:50.000000000 +0100
+++ bgpd/rde_update.c 2008-03-18 15:32:21.000000000 +0100
@@ -17,13 +17,15 @@
*/
#include <sys/types.h>
#include <sys/queue.h>
-#include <sys/hash.h>
#include <stdlib.h>
#include <string.h>
#include "bgpd.h"
#include "rde.h"
+#include "hash.h"
+
+#include <limits.h>
in_addr_t up_get_nexthop(struct rde_peer *, struct rde_aspath *);
int up_generate_mp_reach(struct rde_peer *, struct update_attr *,

View File

@ -0,0 +1,13 @@
--- bgpd/session.c 2008-03-18 15:24:06.000000000 +0100
+++ bgpd/session.c 2008-03-18 13:27:29.000000000 +0100
@@ -52,6 +52,10 @@
#define PFD_SOCK_RCTL 4
#define PFD_LISTENERS_START 5
+#if defined(__FreeBSD__) /* FreeBSD has no LINK_STATE_IS_UP macro. */
+#define LINK_STATE_IS_UP(_s) ((_s) >= LINK_STATE_UP)
+#endif /* defined(__FreeBSD__) */
+
void session_sighdlr(int);
int setup_listeners(u_int *);
void init_conf(struct bgpd_config *);

View File

@ -0,0 +1,10 @@
--- bgpd/util.c 2008-03-18 15:24:06.000000000 +0100
+++ bgpd/util.c 2008-03-18 13:27:29.000000000 +0100
@@ -18,6 +18,7 @@
*/
#include <sys/types.h>
#include <sys/socket.h>
+#include <sys/limits.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>