Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 Jun 2014 20:59:08 +1000
From:      Brian Scott <bscott@bunyatech.com.au>
To:        rea@FreeBSD.org
Cc:        ports@FreeBSD.org
Subject:   FreeBSD Port: openospfd-4.3_1
Message-ID:  <53A2C27C.4050800@bunyatech.com.au>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------040302030000000108040402
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Hi,

Attached are some patches that allow openospfd to be compiled in the
absence of IFT_CARP on recent systems. (conditional on not being defined
to allow it compile if there is a system version with it defined).

The kroute.c patch should include the existing kroute.c patch.

I've also added an include for stdlib.h to the parse.y patch to make
clang happy.

I aven't had a chance to verify that the software works correctly with
these patches (i.e. that nothing else has changed) but at least it
builds and installs properly.

Hope they are of some help.

Brian Scott

--------------040302030000000108040402
Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0";
 name="patch-ospfctl_ospfctl.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="patch-ospfctl_ospfctl.c"

--- ./ospfctl/ospfctl.c.orig	2007-10-15 12:16:35.000000000 +1000
+++ ./ospfctl/ospfctl.c	2014-06-19 20:24:27.000000000 +1000
@@ -340,8 +340,10 @@
 		return (IFM_ETHER);
 	case IFT_FDDI:
 		return (IFM_FDDI);
+#ifdef IFT_CARP
 	case IFT_CARP:
 		return (IFM_CARP);
+#endif
 	case IFT_PPP:
 		return (IFM_TDM);
 	default:
@@ -1234,9 +1236,11 @@
 		case IFT_FDDI:
 			ifms_type = IFM_FDDI;
 			break;
+#ifdef IFT_CARP
 		case IFT_CARP:
 			ifms_type = IFM_CARP;
 			break;
+#endif
 		default:
 			ifms_type = 0;
 			break;

--------------040302030000000108040402
Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0";
 name="patch-ospfd_parse.y"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="patch-ospfd_parse.y"

--- ./ospfd/parse.y.orig	2008-02-26 21:09:58.000000000 +1100
+++ ./ospfd/parse.y	2014-06-19 20:23:32.000000000 +1000
@@ -35,6 +35,7 @@
 #include <limits.h>
 #include <stdarg.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 
 #include "ospf.h"
@@ -503,6 +504,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 < 1 || $3 > 255) {
 				yyerror("demote count out of range (1-255)");
 				free($2);
@@ -523,6 +529,7 @@
 				    area->demote_group);
 				YYERROR;
 			}
+#endif
 		}
 		| defaults
 		;
@@ -599,6 +606,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)) {
@@ -613,6 +625,7 @@
 				    iface->demote_group);
 				YYERROR;
 			}
+#endif
 		}
 		| defaults
 		;

--------------040302030000000108040402
Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0";
 name="patch-ospfd_ospfe.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="patch-ospfd_ospfe.c"

--- ./ospfd/ospfe.c.orig	2007-10-13 23:21:24.000000000 +1000
+++ ./ospfd/ospfe.c	2014-06-19 20:23:15.000000000 +1000
@@ -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);
@@ -166,8 +167,8 @@
 	event_add(&oeconf->ev, NULL);
 
 	/* remove unneeded config stuff */
-	while ((r = SIMPLEQ_FIRST(&oeconf->redist_list)) != NULL) {
-		SIMPLEQ_REMOVE_HEAD(&oeconf->redist_list, entry);
+	while ((r = STAILQ_FIRST(&oeconf->redist_list)) != NULL) {
+		STAILQ_REMOVE_HEAD(&oeconf->redist_list, entry);
 		free(r);
 	}
 
@@ -257,23 +258,11 @@
 	struct iface	*iface = NULL;
 	struct kif	*kif;
 	struct auth_md	 md;
-	int		 n, link_ok, stub_changed, shut = 0;
+	int		 link_ok, stub_changed, shut = 0;
+	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)
@@ -289,8 +278,11 @@
 			kif = imsg.data;
 			link_ok = (kif->flags & IFF_UP) &&
 			    (LINK_STATE_IS_UP(kif->link_state) ||
-			    (kif->link_state == LINK_STATE_UNKNOWN &&
-			    kif->media_type != IFT_CARP));
+			    (kif->link_state == LINK_STATE_UNKNOWN
+#ifdef IFT_CARP
+				&& kif->media_type != IFT_CARP
+#endif
+				));
 
 
 			LIST_FOREACH(area, &oeconf->area_list, entry) {
@@ -401,24 +393,12 @@
 	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)
@@ -799,9 +779,12 @@
 			}
 
 			if ((iface->flags & IFF_UP) == 0 ||
-			    iface->linkstate == LINK_STATE_DOWN ||
-			    (!LINK_STATE_IS_UP(iface->linkstate) &&
-			    iface->media_type == IFT_CARP))
+			    iface->linkstate == LINK_STATE_DOWN
+#ifdef IFT_CARP
+		  	    || (!LINK_STATE_IS_UP(iface->linkstate) &&
+			    iface->media_type == IFT_CARP)
+#endif
+				)
 				continue;
 
 			log_debug("orig_rtr_lsa: stub net, "

--------------040302030000000108040402
Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0";
 name="patch-ospfd_kroute.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="patch-ospfd_kroute.c"

--- ./ospfd/kroute.c.orig	2007-10-18 06:52:42.000000000 +1000
+++ ./ospfd/kroute.c	2014-06-19 20:23:02.000000000 +1000
@@ -941,8 +941,11 @@
 
 	reachable = (kif->flags & IFF_UP) &&
 	    (LINK_STATE_IS_UP(kif->link_state) ||
-	    (kif->link_state == LINK_STATE_UNKNOWN &&
-	    kif->media_type != IFT_CARP));
+	    (kif->link_state == LINK_STATE_UNKNOWN
+#ifdef IFT_CARP
+		&& kif->media_type != IFT_CARP
+#endif
+		));
 
 	if (reachable == kif->nh_reachable)
 		return;		/* nothing changed wrt nexthop validity */
@@ -1024,9 +1027,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);
@@ -1035,7 +1040,12 @@
 	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_seq = kr_state.rtseq++;	/* overflow doesn't matter */
@@ -1080,6 +1090,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;
@@ -1096,6 +1107,7 @@
 		iov[iovcnt].iov_base = &sa_rl;
 		iov[iovcnt++].iov_len = sizeof(sa_rl);
 	}
+#endif /* !defined(__FreeBSD__) */
 
 
 retry:
@@ -1138,7 +1150,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;
@@ -1147,9 +1161,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);
 	}
@@ -1157,7 +1175,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);
@@ -1174,8 +1196,10 @@
 		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");
@@ -1228,6 +1252,7 @@
 			send_rtmsg(kr_state.fd, RTM_DELETE, &kr->r);
 			free(kr);
 		} else {
+#if !defined(__FreeBSD__) /* FreeBSD has no route labeling. */
 			if ((label = (struct sockaddr_rtlabel *)
 			    rti_info[RTAX_LABEL]) != NULL) {
 				kr->r.rtlabel =
@@ -1235,6 +1260,7 @@
 				kr->r.ext_tag =
 				    rtlabel_id2tag(kr->r.rtlabel);
 			}
+#endif /* !defined(__FreeBSD__) */
 			kroute_insert(kr);
 		}
 
@@ -1295,8 +1321,11 @@
 			kif->nh_reachable = (kif->flags & IFF_UP) &&
 			    (LINK_STATE_IS_UP(ifm.ifm_data.ifi_link_state) ||
 			    (ifm.ifm_data.ifi_link_state ==
-			    LINK_STATE_UNKNOWN &&
-			    ifm.ifm_data.ifi_type != IFT_CARP));
+			    LINK_STATE_UNKNOWN
+#ifdef IFT_CARP
+				&& ifm.ifm_data.ifi_type != IFT_CARP
+#endif
+				));
 			break;
 		case RTM_NEWADDR:
 			ifam = (struct ifa_msghdr *)rtm;
@@ -1328,7 +1357,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;
@@ -1362,8 +1393,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;
@@ -1371,8 +1404,10 @@
 			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)
@@ -1458,6 +1493,7 @@
 				rtlabel_unref(kr->r.rtlabel);
 				kr->r.rtlabel = 0;
 				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 =
@@ -1465,6 +1501,7 @@
 					kr->r.ext_tag =
 					    rtlabel_id2tag(kr->r.rtlabel);
 				}
+#endif /* !defined(__FreeBSD__) */
 
 				if (kif_validate(kr->r.ifindex))
 					kr->r.flags &= ~F_DOWN;
@@ -1486,6 +1523,7 @@
 				kr->r.flags = flags;
 				kr->r.ifindex = ifindex;
 
+#if !defined(__FreeBSD__) /* FreeBSD has no route labeling */
 				if ((label = (struct sockaddr_rtlabel *)
 				    rti_info[RTAX_LABEL]) != NULL) {
 					kr->r.rtlabel =
@@ -1493,6 +1531,7 @@
 					kr->r.ext_tag =
 					    rtlabel_id2tag(kr->r.rtlabel);
 				}
+#endif /* !defined(__FreeBSD__) */
 
 				kroute_insert(kr);
 			}

--------------040302030000000108040402
Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0";
 name="patch-ospfd_interface.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="patch-ospfd_interface.c"

--- ./ospfd/interface.c.orig	2007-09-12 02:02:55.000000000 +1000
+++ ./ospfd/interface.c	2014-06-19 20:22:48.000000000 +1000
@@ -323,19 +323,24 @@
 
 	if (!((iface->flags & IFF_UP) &&
 	    (LINK_STATE_IS_UP(iface->linkstate) ||
-	    (iface->linkstate == LINK_STATE_UNKNOWN &&
-	    iface->media_type != IFT_CARP)))) {
+	    (iface->linkstate == LINK_STATE_UNKNOWN
+#ifdef IFT_CARP
+		&& iface->media_type != IFT_CARP
+#endif
+			)))) {
 		log_debug("if_act_start: interface %s link down",
 		    iface->name);
 		return (0);
 	}
 
+#ifdef IFT_CARP
 	if (iface->media_type == IFT_CARP && iface->passive == 0) {
 		/* force passive mode on carp interfaces */
 		log_warnx("if_act_start: forcing interface %s to passive",
 		    iface->name);
 		iface->passive = 1;
 	}
+#endif
 
 	if (iface->passive) {
 		/* for an update of stub network entries */

--------------040302030000000108040402--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?53A2C27C.4050800>