Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Feb 2008 19:57:47 +0300
From:      Eygene Ryabinkin <rea-fbsd@codelabs.ru>
To:        Josef Pojsl <jp@tns.cz>, Claudio Jeker <cjeker@diehard.n-r-g.com>, freebsd-net@freebsd.org, farrokhi@FreeBSD.org
Subject:   Re: ospf cost and route selection (openospfd)
Message-ID:  <BeIqwBu0LkRXuGRr9c834oJe11M@mkgs2gFQr6GPddtmfyJSxMBvIxA>
In-Reply-To: <Ntfg81bhcEB6BPmKzMb2iTN9oBA@ebJhc%2B9glC7W5vxxBJVH9quBZr0>
References:  <20080206144104.GL1122@bonifac.tns.cz> <jV/l2UkZT%2BCCNuE6npJv1SBs5CE@UCvaDHSF%2BGDEPQ7TSpdR%2BlgUSQM> <20080207074944.GA56085@bonifac.tns.cz> <20080207141422.GG11393@diehard.n-r-g.com> <20080206144104.GL1122@bonifac.tns.cz> <jV/l2UkZT%2BCCNuE6npJv1SBs5CE@UCvaDHSF%2BGDEPQ7TSpdR%2BlgUSQM> <20080207074944.GA56085@bonifac.tns.cz> <Ntfg81bhcEB6BPmKzMb2iTN9oBA@ebJhc%2B9glC7W5vxxBJVH9quBZr0>

next in thread | previous in thread | raw e-mail | index | archive | help

--7ZAtKRhVyVSsbBD2
Content-Type: text/plain; charset=koi8-r
Content-Disposition: inline

Me again.

Thu, Feb 07, 2008 at 05:58:32PM +0300, Eygene Ryabinkin wrote:
> Thu, Feb 07, 2008 at 03:14:22PM +0100, Claudio Jeker wrote:
> > On Thu, Feb 07, 2008 at 08:49:44AM +0100, Josef Pojsl wrote:
> > > Thanks a lot for your remarks. I absolutely agree with you
> > > that all columns are correct except the Nexthop.
> > > 
> > 
> > The nexthop selection for point to point links had a bug in versions
> > previous to 4.2. This should be fixed in the 4.2 and -current version of
> > OpenOSPFD.
> 
> Thanks for confirming this: I had started to suspectethis after
> some code digging.  Will try to update the port to 4.2, so expect
> some patches "Really Soon" (tm) ;))

OK, the first patch version is ready.  It compiles well and even
starts for the trivial configuration.  I will try to test it for
other configurations, but you may test it as well: I will appreciate
it very much.

One note: the provided patch if applied with the normal 'patch'
utility can fail to remove deleted patches from the 'files' directory.
The following files should not be present:

  files/patch-ospfctl_parser.c
  files/patch-ospfctl_parser.h

Thanks!
-- 
Eygene

--7ZAtKRhVyVSsbBD2
Content-Type: text/x-diff; charset=koi8-r
Content-Disposition: attachment; filename="4.0-to-4.2.patch"

>From 3167ee2d9f63ede4309dc64a7793c13111769c4c Mon Sep 17 00:00:00 2001
From: Eygene Ryabinkin <rea-fbsd@codelabs.ru>
Date: Thu, 7 Feb 2008 19:19:54 +0300
Subject: [PATCH] Update ospfd to 4.2.

o Provide LINK_STATE_IS_UP macros that is missing in FreeBSD.
o Disable CARP demotion: FreeBSD has no support for it.
o Disable check for the routing table number: FreeBSD has
  single routing table now.
o Disable route labeling: FreeBSD has no support for it.
o Rewrite old patch for the ospfctl/parser.{c,h}.

Signed-off-by: Eygene Ryabinkin <rea-fbsd@codelabs.ru>
---
 Makefile                     |    3 +-
 distinfo                     |    6 +-
 files/patch-LINK_STATE_IS_UP |   13 ++++
 files/patch-no_carp_demotion |   91 +++++++++++++++++++++++++++
 files/patch-ospfctl_parser   |   59 ++++++++++++++++++
 files/patch-ospfctl_parser.c |   26 --------
 files/patch-ospfctl_parser.h |   26 --------
 files/patch-ospfd_kroute.c   |  138 ++++++++++++++++++++++++++++++++++++------
 8 files changed, 286 insertions(+), 76 deletions(-)
 create mode 100644 files/patch-LINK_STATE_IS_UP
 create mode 100644 files/patch-no_carp_demotion
 create mode 100644 files/patch-ospfctl_parser
 delete mode 100644 files/patch-ospfctl_parser.c
 delete mode 100644 files/patch-ospfctl_parser.h

diff --git a/Makefile b/Makefile
index 4423454..777f71b 100644
--- a/Makefile
+++ b/Makefile
@@ -6,8 +6,7 @@
 #
 
 PORTNAME=	openospfd
-PORTVERSION=	4.0
-PORTREVISION=	2
+PORTVERSION=	4.2
 CATEGORIES=	net
 MASTER_SITES=	ftp://ftp.dkuug.dk/pub/OpenBSD/OpenBGPD/:openbsd \
 		${MASTER_SITE_LOCAL:S/$/:freebsd/g}
diff --git a/distinfo b/distinfo
index 84810c8..bf2bc20 100644
--- a/distinfo
+++ b/distinfo
@@ -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
+SHA1 (openospfd/openospfd-4.2.tgz) = ebb476d834d3aa5ddc3a5e96ea2f494f2617c393
+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
diff --git a/files/patch-LINK_STATE_IS_UP b/files/patch-LINK_STATE_IS_UP
new file mode 100644
index 0000000..bcd1f6d
--- /dev/null
+++ b/files/patch-LINK_STATE_IS_UP
@@ -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;
diff --git a/files/patch-no_carp_demotion b/files/patch-no_carp_demotion
new file mode 100644
index 0000000..2882279
--- /dev/null
+++ b/files/patch-no_carp_demotion
@@ -0,0 +1,91 @@
+--- 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",
+--- 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__) */
+--- 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
+ 		;
diff --git a/files/patch-ospfctl_parser b/files/patch-ospfctl_parser
new file mode 100644
index 0000000..1d0a82c
--- /dev/null
+++ b/files/patch-ospfctl_parser
@@ -0,0 +1,59 @@
+--- 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"
+ 
+-enum token_type {
+-	NOTOKEN,
+-	ENDTOKEN,
+-	KEYWORD,
+-	ADDRESS,
+-	FLAG,
+-	PREFIX,
+-	IFNAME
+-};
+-
+-struct token {
+-	enum token_type		 type;
+-	const char		*keyword;
+-	int			 value;
+-	const struct token	*next;
+-};
+-
+ static const struct token t_main[];
+ static const struct token t_fib[];
+ static const struct token t_show[];
+--- 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
+ };
+ 
++enum token_type {
++	NOTOKEN,
++	ENDTOKEN,
++	KEYWORD,
++	ADDRESS,
++	FLAG,
++	PREFIX,
++	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;
++	int			 value;
++	const struct token	*next;
++};
++
+ struct parse_result	*parse(int, char *[]);
+ const struct token	*match_token(const char *, const struct token []);
+ void			 show_valid_args(const struct token []);
diff --git a/files/patch-ospfctl_parser.c b/files/patch-ospfctl_parser.c
deleted file mode 100644
index c4f7fc8..0000000
--- a/files/patch-ospfctl_parser.c
+++ /dev/null
@@ -1,26 +0,0 @@
---- ospfctl/parser.c.orig	Fri Jul 27 15:11:46 2007
-+++ ospfctl/parser.c	Fri Jul 27 15:12:01 2007
-@@ -32,23 +32,6 @@
- 
- #include "parser.h"
- 
--enum token_type {
--	NOTOKEN,
--	ENDTOKEN,
--	KEYWORD,
--	ADDRESS,
--	FLAG,
--	PREFIX,
--	IFNAME
--};
--
--struct token {
--	enum token_type		 type;
--	const char		*keyword;
--	int			 value;
--	const struct token	*next;
--};
--
- static const struct token t_main[];
- static const struct token t_fib[];
- static const struct token t_show[];
diff --git a/files/patch-ospfctl_parser.h b/files/patch-ospfctl_parser.h
deleted file mode 100644
index b4eab49..0000000
--- a/files/patch-ospfctl_parser.h
+++ /dev/null
@@ -1,26 +0,0 @@
---- 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 @@
- 	RELOAD
- };
- 
-+enum token_type {
-+	NOTOKEN,
-+	ENDTOKEN,
-+	KEYWORD,
-+	ADDRESS,
-+	FLAG,
-+	PREFIX,
-+	IFNAME
-+};
-+
-+struct token {
-+	enum token_type		 type;
-+	const char		*keyword;
-+	int			 value;
-+	const struct token	*next;
-+};
-+
- struct parse_result {
- 	struct in_addr	addr;
- 	char		ifname[IF_NAMESIZE];
diff --git a/files/patch-ospfd_kroute.c b/files/patch-ospfd_kroute.c
index 6415a3b..2b1bd77 100644
--- a/files/patch-ospfd_kroute.c
+++ b/files/patch-ospfd_kroute.c
@@ -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);
  			}
-- 
1.5.3.8


--7ZAtKRhVyVSsbBD2--



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