summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/ripd/Makefile6
-rw-r--r--usr.sbin/ripd/name2id.c173
-rw-r--r--usr.sbin/ripd/parse.y159
-rw-r--r--usr.sbin/ripd/printconf.c55
-rw-r--r--usr.sbin/ripd/rde.c13
-rw-r--r--usr.sbin/ripd/ripd.c76
-rw-r--r--usr.sbin/ripd/ripd.h45
-rw-r--r--usr.sbin/ripd/ripe.c13
8 files changed, 434 insertions, 106 deletions
diff --git a/usr.sbin/ripd/Makefile b/usr.sbin/ripd/Makefile
index 1210b600dc7..9a7539f747a 100644
--- a/usr.sbin/ripd/Makefile
+++ b/usr.sbin/ripd/Makefile
@@ -1,9 +1,9 @@
-# $OpenBSD: Makefile,v 1.2 2006/11/26 11:31:13 deraadt Exp $
+# $OpenBSD: Makefile,v 1.3 2007/01/08 13:01:10 claudio Exp $
PROG= ripd
SRCS= auth.c buffer.c control.c imsg.c interface.c kroute.c \
- log.c message.c neighbor.c packet.c parse.y printconf.c \
- rde.c rde_rib.c ripe.c ripd.c
+ log.c message.c name2id.c neighbor.c packet.c parse.y \
+ printconf.c rde.c rde_rib.c ripe.c ripd.c
MAN= ripd.8 ripd.conf.5
diff --git a/usr.sbin/ripd/name2id.c b/usr.sbin/ripd/name2id.c
new file mode 100644
index 00000000000..f5c2387c89f
--- /dev/null
+++ b/usr.sbin/ripd/name2id.c
@@ -0,0 +1,173 @@
+/* $OpenBSD: name2id.c,v 1.1 2007/01/08 13:01:10 claudio Exp $ */
+
+/*
+ * Copyright (c) 2004, 2005 Henning Brauer <henning@openbsd.org>
+ *
+ * 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 MIND, 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.
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <net/route.h>
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "ripd.h"
+
+#define IDVAL_MAX 50000
+
+struct n2id_label {
+ TAILQ_ENTRY(n2id_label) entry;
+ char *name;
+ u_int16_t id;
+ int ref;
+};
+
+TAILQ_HEAD(n2id_labels, n2id_label);
+
+u_int16_t _name2id(struct n2id_labels *, const char *);
+const char *_id2name(struct n2id_labels *, u_int16_t);
+void _unref(struct n2id_labels *, u_int16_t);
+void _ref(struct n2id_labels *, u_int16_t);
+
+struct n2id_labels rt_labels = TAILQ_HEAD_INITIALIZER(rt_labels);
+
+u_int16_t
+rtlabel_name2id(const char *name)
+{
+ return (_name2id(&rt_labels, name));
+}
+
+const char *
+rtlabel_id2name(u_int16_t id)
+{
+ return (_id2name(&rt_labels, id));
+}
+
+void
+rtlabel_unref(u_int16_t id)
+{
+ _unref(&rt_labels, id);
+}
+
+/*
+void
+rtlabel_ref(u_int16_t id)
+{
+ _ref(&rt_labels, id);
+}
+*/
+
+u_int16_t
+_name2id(struct n2id_labels *head, const char *name)
+{
+ struct n2id_label *label, *p = NULL;
+ u_int16_t new_id = 1;
+
+ if (!name[0]) {
+ errno = EINVAL;
+ return (0);
+ }
+
+ TAILQ_FOREACH(label, head, entry)
+ if (strcmp(name, label->name) == 0) {
+ label->ref++;
+ return (label->id);
+ }
+
+ /*
+ * to avoid fragmentation, we do a linear search from the beginning
+ * and take the first free slot we find. if there is none or the list
+ * is empty, append a new entry at the end.
+ */
+
+ if (!TAILQ_EMPTY(head))
+ for (p = TAILQ_FIRST(head); p != NULL &&
+ p->id == new_id; p = TAILQ_NEXT(p, entry))
+ new_id = p->id + 1;
+
+ if (new_id > IDVAL_MAX) {
+ errno = ERANGE;
+ return (0);
+ }
+
+ if ((label = calloc(1, sizeof(struct n2id_label))) == NULL)
+ return (0);
+ if ((label->name = strdup(name)) == NULL) {
+ free(label);
+ return (0);
+ }
+ label->id = new_id;
+ label->ref++;
+
+ if (p != NULL) /* insert new entry before p */
+ TAILQ_INSERT_BEFORE(p, label, entry);
+ else /* either list empty or no free slot in between */
+ TAILQ_INSERT_TAIL(head, label, entry);
+
+ return (label->id);
+}
+
+const char *
+_id2name(struct n2id_labels *head, u_int16_t id)
+{
+ struct n2id_label *label;
+
+ if (id == 0)
+ return ("");
+
+ TAILQ_FOREACH(label, head, entry)
+ if (label->id == id)
+ return (label->name);
+
+ return ("");
+}
+
+void
+_unref(struct n2id_labels *head, u_int16_t id)
+{
+ struct n2id_label *p, *next;
+
+ if (id == 0)
+ return;
+
+ for (p = TAILQ_FIRST(head); p != NULL; p = next) {
+ next = TAILQ_NEXT(p, entry);
+ if (id == p->id) {
+ if (--p->ref == 0) {
+ TAILQ_REMOVE(head, p, entry);
+ free(p->name);
+ free(p);
+ }
+ break;
+ }
+ }
+}
+
+void
+_ref(struct n2id_labels *head, u_int16_t id)
+{
+ struct n2id_label *label;
+
+ if (id == 0)
+ return;
+
+ TAILQ_FOREACH(label, head, entry)
+ if (label->id == id) {
+ ++label->ref;
+ break;
+ }
+}
diff --git a/usr.sbin/ripd/parse.y b/usr.sbin/ripd/parse.y
index 04da8b4cf51..6c6e7618c1b 100644
--- a/usr.sbin/ripd/parse.y
+++ b/usr.sbin/ripd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.4 2006/10/25 20:01:49 henning Exp $ */
+/* $OpenBSD: parse.y,v 1.5 2007/01/08 13:01:10 claudio Exp $ */
/*
* Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it>
@@ -50,17 +50,18 @@ char *start_state;
struct iface *iface = NULL;
-int yyerror(const char *, ...);
-int yyparse(void);
-int kw_cmp(const void *, const void *);
-int lookup(char *);
-int lgetc(FILE *);
-int lungetc(int);
-int findeol(void);
-int yylex(void);
-void clear_config(struct ripd_conf *);
-int check_file_secrecy(int fd, const char *fname);
-u_int32_t get_rtr_id(void);
+int yyerror(const char *, ...);
+int yyparse(void);
+int kw_cmp(const void *, const void *);
+int lookup(char *);
+int lgetc(FILE *);
+int lungetc(int);
+int findeol(void);
+int yylex(void);
+void clear_config(struct ripd_conf *);
+int check_file_secrecy(int, const char *);
+u_int32_t get_rtr_id(void);
+int host(const char *, struct in_addr *, struct in_addr *);
static struct {
char auth_key[MAX_SIMPLE_AUTH_LEN];
@@ -95,11 +96,12 @@ typedef struct {
%token SPLIT_HORIZON TRIGGERED_UPDATES FIBUPDATE REDISTRIBUTE
%token AUTHKEY AUTHTYPE AUTHMD AUTHMDKEYID
-%token INTERFACE
+%token INTERFACE RTLABEL
%token COST PASSIVE
+%token YES NO
%token ERROR
%token <v.string> STRING
-%type <v.number> number yesno
+%type <v.number> number yesno no
%type <v.string> string
%%
@@ -139,20 +141,13 @@ string : string STRING {
| STRING
;
-yesno : STRING {
- if (!strcmp($1, "yes"))
- $$ = 1;
- else if (!strcmp($1, "no"))
- $$ = 0;
- else {
- free($1);
- yyerror("recognized values are yes or no");
- YYERROR;
- }
- free($1);
- }
+yesno : YES { $$ = 1; }
+ | NO { $$ = 0; }
;
+no : /* empty */ { $$ = 0; }
+ | NO { $$ = 1; }
+
varset : STRING '=' string {
if (conf->opts & RIPD_OPT_VERBOSE)
printf("%s = \"%s\"\n", $1, $3);
@@ -192,24 +187,54 @@ conf_main : SPLIT_HORIZON STRING {
else
conf->flags &= ~RIPD_FLAG_NO_FIB_UPDATE;
}
- | REDISTRIBUTE STRING {
- if (!strcmp($2, "static"))
- conf->redistribute_flags |=
- REDISTRIBUTE_STATIC;
- else if (!strcmp($2, "connected"))
- conf->redistribute_flags |=
- REDISTRIBUTE_CONNECTED;
- else if (!strcmp($2, "default"))
- conf->redistribute_flags |=
- REDISTRIBUTE_DEFAULT;
- else if (!strcmp($2, "none"))
- conf->redistribute_flags = 0;
- else {
- yyerror("unknown redistribute type");
- free($2);
- YYERROR;
+ | no REDISTRIBUTE STRING {
+ struct redistribute *r;
+
+ if (!strcmp($3, "default")) {
+ if (!$1)
+ conf->redistribute |=
+ REDISTRIBUTE_DEFAULT;
+ else
+ conf->redistribute &=
+ ~REDISTRIBUTE_DEFAULT;
+ } else {
+ if ((r = calloc(1, sizeof(*r))) == NULL)
+ fatal(NULL);
+ if (!strcmp($3, "static"))
+ r->type = REDIST_STATIC;
+ else if (!strcmp($3, "connected"))
+ r->type = REDIST_CONNECTED;
+ else if (host($3, &r->addr, &r->mask))
+ r->type = REDIST_ADDR;
+ else {
+ yyerror("unknown redistribute type");
+ free($3);
+ free(r);
+ YYERROR;
+ }
+
+ if ($1)
+ r->type |= REDIST_NO;
+
+ SIMPLEQ_INSERT_TAIL(&conf->redist_list, r,
+ entry);
}
- free($2);
+ conf->redistribute |= REDISTRIBUTE_ON;
+ free($3);
+ }
+ | no REDISTRIBUTE RTLABEL STRING {
+ struct redistribute *r;
+
+ if ((r = calloc(1, sizeof(*r))) == NULL)
+ fatal(NULL);
+ r->type = REDIST_LABEL;
+ r->label = rtlabel_name2id($4);
+ if ($1)
+ r->type |= REDIST_NO;
+ free($4);
+
+ SIMPLEQ_INSERT_TAIL(&conf->redist_list, r, entry);
+ conf->redistribute |= REDISTRIBUTE_ON;
}
;
@@ -365,17 +390,20 @@ lookup(char *s)
{
/* this has to be sorted always */
static const struct keywords keywords[] = {
- {"auth-key", AUTHKEY},
- {"auth-md", AUTHMD},
- {"auth-md-keyid", AUTHMDKEYID},
- {"auth-type", AUTHTYPE},
- {"cost", COST},
- {"fib-update", FIBUPDATE},
- {"interface", INTERFACE},
- {"passive", PASSIVE},
- {"redistribute", REDISTRIBUTE},
- {"split-horizon", SPLIT_HORIZON},
- {"triggered-updates", TRIGGERED_UPDATES}
+ {"auth-key", AUTHKEY},
+ {"auth-md", AUTHMD},
+ {"auth-md-keyid", AUTHMDKEYID},
+ {"auth-type", AUTHTYPE},
+ {"cost", COST},
+ {"fib-update", FIBUPDATE},
+ {"interface", INTERFACE},
+ {"no", NO},
+ {"passive", PASSIVE},
+ {"redistribute", REDISTRIBUTE},
+ {"rtlabel", RTLABEL},
+ {"split-horizon", SPLIT_HORIZON},
+ {"triggered-updates", TRIGGERED_UPDATES},
+ {"yes", YES}
};
const struct keywords *p;
@@ -597,7 +625,7 @@ parse_config(char *filename, int opts)
infile = filename;
conf->opts = opts;
- conf->redistribute_flags = 0;
+ SIMPLEQ_INIT(&conf->redist_list);
if (!(conf->opts & RIPD_OPT_NOACTION))
if (check_file_secrecy(fileno(fin), filename)) {
@@ -740,3 +768,24 @@ clear_config(struct ripd_conf *xconf)
free(xconf);
}
+
+int
+host(const char *s, struct in_addr *addr, struct in_addr *mask)
+{
+ struct in_addr ina;
+ int bits = 32;
+
+ bzero(&ina, sizeof(struct in_addr));
+ if (strrchr(s, '/') != NULL) {
+ if ((bits = inet_net_pton(AF_INET, s, &ina, sizeof(ina))) == -1)
+ return (0);
+ } else {
+ if (inet_pton(AF_INET, s, &ina) != 1)
+ return (0);
+ }
+
+ addr->s_addr = ina.s_addr;
+ mask->s_addr = prefixlen2mask(bits);
+
+ return (1);
+}
diff --git a/usr.sbin/ripd/printconf.c b/usr.sbin/ripd/printconf.c
index 6e8da516f2b..3eac0201c4c 100644
--- a/usr.sbin/ripd/printconf.c
+++ b/usr.sbin/ripd/printconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: printconf.c,v 1.2 2006/11/09 04:06:09 joel Exp $ */
+/* $OpenBSD: printconf.c,v 1.3 2007/01/08 13:01:10 claudio Exp $ */
/*
* Copyright (c) 2004, 2005, 2006 Esben Norby <norby@openbsd.org>
@@ -28,8 +28,10 @@
#include "ripd.h"
#include "ripe.h"
-void print_mainconf(struct ripd_conf *);
-void print_iface(struct iface *);
+void print_mainconf(struct ripd_conf *);
+const char *print_no(u_int16_t);
+void print_redistribute(struct ripd_conf *);
+void print_iface(struct iface *);
void
print_mainconf(struct ripd_conf *conf)
@@ -39,14 +41,7 @@ print_mainconf(struct ripd_conf *conf)
else
printf("fib-update yes\n");
- if (conf->redistribute_flags & REDISTRIBUTE_STATIC)
- printf("redistribute static\n");
- else if (conf->redistribute_flags & REDISTRIBUTE_CONNECTED)
- printf("redistribute connected\n");
- else if (conf->redistribute_flags & REDISTRIBUTE_DEFAULT)
- printf("redistribute default\n");
- else
- printf("redistribute none\n");
+ print_redistribute(conf);
if (conf->options & OPT_SPLIT_HORIZON)
printf("split-horizon default\n");
@@ -61,6 +56,44 @@ print_mainconf(struct ripd_conf *conf)
printf("triggered-updates no\n");
}
+const char *
+print_no(u_int16_t type)
+{
+ if (type & REDIST_NO)
+ return ("no ");
+ else
+ return ("");
+}
+
+void
+print_redistribute(struct ripd_conf *conf)
+{
+ struct redistribute *r;
+
+ if (conf->redistribute & REDISTRIBUTE_DEFAULT)
+ printf("redistribute default\n");
+
+ SIMPLEQ_FOREACH(r, &conf->redist_list, entry) {
+ switch (r->type & ~REDIST_NO) {
+ case REDIST_STATIC:
+ printf("%sredistribute static\n", print_no(r->type));
+ break;
+ case REDIST_CONNECTED:
+ printf("%sredistribute connected\n", print_no(r->type));
+ break;
+ case REDIST_LABEL:
+ printf("%sredistribute rtlabel %s\n",
+ print_no(r->type), rtlabel_id2name(r->label));
+ break;
+ case REDIST_ADDR:
+ printf("%ssredistribute %s/%d\n",
+ print_no(r->type), inet_ntoa(r->addr),
+ mask2prefixlen(r->mask.s_addr));
+ break;
+ }
+ }
+}
+
void
print_iface(struct iface *iface)
{
diff --git a/usr.sbin/ripd/rde.c b/usr.sbin/ripd/rde.c
index 82269981e73..9f75bba78a6 100644
--- a/usr.sbin/ripd/rde.c
+++ b/usr.sbin/ripd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.2 2006/10/24 16:37:48 david Exp $ */
+/* $OpenBSD: rde.c,v 1.3 2007/01/08 13:01:10 claudio Exp $ */
/*
* Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it>
@@ -75,8 +75,9 @@ pid_t
rde(struct ripd_conf *xconf, int pipe_parent2rde[2], int pipe_ripe2rde[2],
int pipe_parent2ripe[2])
{
- struct passwd *pw;
struct event ev_sigint, ev_sigterm;
+ struct passwd *pw;
+ struct redistribute *r;
pid_t pid;
switch (pid = fork()) {
@@ -137,8 +138,14 @@ rde(struct ripd_conf *xconf, int pipe_parent2rde[2], int pipe_ripe2rde[2],
event_set(&ibuf_main->ev, ibuf_main->fd, ibuf_main->events,
ibuf_main->handler, ibuf_main);
event_add(&ibuf_main->ev, NULL);
-
rt_init();
+
+ /* remove unneeded config stuff */
+ while ((r = SIMPLEQ_FIRST(&rdeconf->redist_list)) != NULL) {
+ SIMPLEQ_REMOVE_HEAD(&rdeconf->redist_list, entry);
+ free(r);
+ }
+
event_dispatch();
rde_shutdown();
diff --git a/usr.sbin/ripd/ripd.c b/usr.sbin/ripd/ripd.c
index f0fc22e2678..cd0fb308570 100644
--- a/usr.sbin/ripd/ripd.c
+++ b/usr.sbin/ripd/ripd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ripd.c,v 1.1 2006/10/18 16:11:58 norby Exp $ */
+/* $OpenBSD: ripd.c,v 1.2 2007/01/08 13:01:10 claudio Exp $ */
/*
* Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it>
@@ -55,6 +55,7 @@ void ripd_shutdown(void);
void main_dispatch_ripe(int, short, void *);
void main_dispatch_rde(int, short, void *);
int check_file_secrecy(int, const char *);
+void ripd_redistribute_default(int);
int pipe_parent2ripe[2];
int pipe_parent2rde[2];
@@ -251,6 +252,9 @@ main(int argc, char *argv[])
if (kr_init(!(conf->flags & RIPD_FLAG_NO_FIB_UPDATE)) == -1)
fatalx("kr_init failed");
+ /* redistribute default */
+ ripd_redistribute_default(IMSG_NETWORK_ADD);
+
event_dispatch();
ripd_shutdown();
@@ -468,29 +472,63 @@ check_file_secrecy(int fd, const char *fname)
int
rip_redistribute(struct kroute *kr)
{
+ struct redistribute *r;
+
if (kr->flags & F_RIPD_INSERTED)
return (1);
- /* XXX this is funky, it is not possible to distribute static and
- * connected. OSPFD has a much better way to do this including rtlabel
- * support
- */
- switch (conf->redistribute_flags) {
- case REDISTRIBUTE_NONE:
+ /* only allow 0.0.0.0/0 via REDISTRIBUTE_DEFAULT */
+ if (kr->prefix.s_addr == INADDR_ANY && kr->netmask.s_addr == INADDR_ANY)
return (0);
- case REDISTRIBUTE_STATIC:
- return (kr->flags & F_KERNEL ? 1 : 0);
- case REDISTRIBUTE_CONNECTED:
- return (kr->flags & F_CONNECTED ? 1 : 0);
- case REDISTRIBUTE_DEFAULT:
- if (kr->prefix.s_addr == INADDR_ANY &&
- kr->netmask.s_addr == INADDR_ANY)
- return (1);
- else
- return (0);
- default:
- fatalx("unknown redistribute type");
+
+ SIMPLEQ_FOREACH(r, &conf->redist_list, entry) {
+ switch (r->type & ~REDIST_NO) {
+ case REDIST_LABEL:
+ if (kr->rtlabel == r->label)
+ return (r->type & REDIST_NO ? 0 : 1);
+ break;
+ case REDIST_STATIC:
+ /*
+ * Dynamic routes are not redistributable. Placed here
+ * so that link local addresses can be redistributed
+ * via a rtlabel.
+ */
+ if (kr->flags & F_DYNAMIC)
+ continue;
+ if (kr->flags & F_STATIC)
+ return (r->type & REDIST_NO ? 0 : 1);
+ break;
+ case REDIST_CONNECTED:
+ if (kr->flags & F_DYNAMIC)
+ continue;
+ if (kr->flags & F_CONNECTED)
+ return (r->type & REDIST_NO ? 0 : 1);
+ break;
+ case REDIST_ADDR:
+ if (kr->flags & F_DYNAMIC)
+ continue;
+ if ((kr->prefix.s_addr & r->mask.s_addr) ==
+ (r->addr.s_addr & r->mask.s_addr) &&
+ (kr->netmask.s_addr & r->mask.s_addr) ==
+ r->mask.s_addr)
+ return (r->type & REDIST_NO? 0 : 1);
+ break;
+ }
}
+
+ return (0);
+}
+
+void
+ripd_redistribute_default(int type)
+{
+ struct kroute kr;
+
+ if (!(conf->redistribute & REDISTRIBUTE_DEFAULT))
+ return;
+
+ bzero(&kr, sizeof(kr));
+ main_imsg_compose_rde(type, 0, &kr, sizeof(struct kroute));
}
/* this needs to be added here so that ripctl can be used without libevent */
diff --git a/usr.sbin/ripd/ripd.h b/usr.sbin/ripd/ripd.h
index ff10de1516c..b4fb382efef 100644
--- a/usr.sbin/ripd/ripd.h
+++ b/usr.sbin/ripd/ripd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ripd.h,v 1.4 2006/11/15 20:21:46 deraadt Exp $ */
+/* $OpenBSD: ripd.h,v 1.5 2007/01/08 13:01:10 claudio Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -57,10 +57,8 @@
#define F_OSPFD_INSERTED 0x0080
#define F_REDISTRIBUTED 0x0100
-#define REDISTRIBUTE_NONE 0x0
-#define REDISTRIBUTE_STATIC 0x01
-#define REDISTRIBUTE_CONNECTED 0x02
-#define REDISTRIBUTE_DEFAULT 0x04
+#define REDISTRIBUTE_ON 0x01
+#define REDISTRIBUTE_DEFAULT 0x02
#define OPT_SPLIT_HORIZON 0x01
#define OPT_SPLIT_POISONED 0x02
@@ -252,28 +250,46 @@ enum {
PROC_RDE_ENGINE
} ripd_process;
+#define REDIST_CONNECTED 0x01
+#define REDIST_STATIC 0x02
+#define REDIST_LABEL 0x04
+#define REDIST_ADDR 0x08
+#define REDIST_NO 0x10
+
+struct redistribute {
+ SIMPLEQ_ENTRY(redistribute) entry;
+ struct in_addr addr;
+ struct in_addr mask;
+ u_int32_t metric;
+ u_int16_t label;
+ u_int16_t type;
+};
+
struct ripd_conf {
struct event ev;
struct event report_timer;
LIST_HEAD(, iface) iface_list;
+ SIMPLEQ_HEAD(, redistribute) redist_list;
+
u_int32_t opts;
#define RIPD_OPT_VERBOSE 0x00000001
#define RIPD_OPT_VERBOSE2 0x00000002
#define RIPD_OPT_NOACTION 0x00000004
int flags;
- int redistribute_flags;
int options;
int rip_socket;
+ int redistribute;
};
/* kroute */
struct kroute {
- struct in_addr prefix;
- struct in_addr netmask;
- struct in_addr nexthop;
- u_int8_t metric;
- u_int16_t flags;
- u_short ifindex;
+ struct in_addr prefix;
+ struct in_addr netmask;
+ struct in_addr nexthop;
+ u_int16_t flags;
+ u_int16_t rtlabel;
+ u_short ifindex;
+ u_int8_t metric;
};
struct kif {
@@ -390,4 +406,9 @@ const char *nbr_state_name(int);
/* interface.c */
struct iface *if_find_index(u_short);
+/* name2id.c */
+u_int16_t rtlabel_name2id(const char *);
+const char *rtlabel_id2name(u_int16_t);
+void rtlabel_unref(u_int16_t);
+
#endif /* _RIPD_H_ */
diff --git a/usr.sbin/ripd/ripe.c b/usr.sbin/ripd/ripe.c
index 4abbb4040c2..559a32fd557 100644
--- a/usr.sbin/ripd/ripe.c
+++ b/usr.sbin/ripd/ripe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ripe.c,v 1.4 2006/11/28 19:21:16 reyk Exp $ */
+/* $OpenBSD: ripe.c,v 1.5 2007/01/08 13:01:10 claudio Exp $ */
/*
* Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it>
@@ -69,10 +69,11 @@ pid_t
ripe(struct ripd_conf *xconf, int pipe_parent2ripe[2], int pipe_ripe2rde[2],
int pipe_parent2rde[2])
{
- struct iface *iface = NULL;
+ struct event ev_sigint, ev_sigterm;
struct sockaddr_in addr;
+ struct iface *iface = NULL;
struct passwd *pw;
- struct event ev_sigint, ev_sigterm;
+ struct redistribute *r;
pid_t pid;
switch (pid = fork()) {
@@ -170,6 +171,12 @@ ripe(struct ripd_conf *xconf, int pipe_parent2ripe[2], int pipe_ripe2rde[2],
recv_packet, oeconf);
event_add(&oeconf->ev, NULL);
+ /* remove unneeded config stuff */
+ while ((r = SIMPLEQ_FIRST(&oeconf->redist_list)) != NULL) {
+ SIMPLEQ_REMOVE_HEAD(&oeconf->redist_list, entry);
+ free(r);
+ }
+
/* listen on ripd control socket */
TAILQ_INIT(&ctl_conns);
control_listen();