summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2004-03-01 16:47:07 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2004-03-01 16:47:07 +0000
commitbed3363948ab2ca2707cf5743f8e0d0d3026d554 (patch)
treec0e34ccc700df5a326898d02f93c18ec3c7f7e02 /usr.sbin
parentbced19cbcc23529eb0da815f2b0f74875d3ab68b (diff)
Sync printconfig.c with parse.y. OK henning@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bgpd/parse.y11
-rw-r--r--usr.sbin/bgpd/printconf.c112
2 files changed, 91 insertions, 32 deletions
diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y
index 5aa0f73f2fb..d137bbc07d2 100644
--- a/usr.sbin/bgpd/parse.y
+++ b/usr.sbin/bgpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.64 2004/03/01 16:02:01 claudio Exp $ */
+/* $OpenBSD: parse.y,v 1.65 2004/03/01 16:47:06 claudio Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -1183,8 +1183,13 @@ add_mrtconfig(enum mrt_type type, char *name, time_t timeout, struct peer *p)
}
n->ReopenTimerInterval = timeout;
if (p != NULL) {
- n->conf.peer_id = p->conf.id;
- n->conf.group_id = p->conf.groupid;
+ if (curgroup == p) {
+ n->conf.peer_id = 0;
+ n->conf.group_id = p->conf.id;
+ } else {
+ n->conf.peer_id = p->conf.id;
+ n->conf.group_id = 0;
+ }
}
LIST_INSERT_HEAD(mrtconf, n, list);
diff --git a/usr.sbin/bgpd/printconf.c b/usr.sbin/bgpd/printconf.c
index 8caa4611c6c..09de7ef6d5c 100644
--- a/usr.sbin/bgpd/printconf.c
+++ b/usr.sbin/bgpd/printconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: printconf.c,v 1.5 2004/02/24 15:43:03 claudio Exp $ */
+/* $OpenBSD: printconf.c,v 1.6 2004/03/01 16:47:06 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -19,13 +19,17 @@
#include <stdio.h>
#include "bgpd.h"
+#include "mrt.h"
#include "session.h"
void print_op(enum comp_ops);
+void print_set(struct filter_set *);
void print_mainconf(struct bgpd_config *);
void print_network(struct network_config *);
void print_peer(struct peer_config *);
void print_rule(struct peer *, struct filter_rule *);
+const char * mrt_type(enum mrt_type);
+void print_mrt(u_int32_t, u_int32_t, const char *);
void
print_op(enum comp_ops op)
@@ -62,6 +66,23 @@ print_op(enum comp_ops op)
}
void
+print_set(struct filter_set *set)
+{
+ if (set->flags) {
+ printf("set { ");
+ if (set->flags & SET_LOCALPREF)
+ printf("localpref %u ", set->localpref);
+ if (set->flags & SET_MED)
+ printf("med %u ", set->med);
+ if (set->flags & SET_NEXTHOP)
+ printf("nexthop %s ", inet_ntoa(set->nexthop));
+ if (set->flags & SET_PREPEND)
+ printf("prepend-self %u ", set->prepend);
+ printf("}");
+ }
+}
+
+void
print_mainconf(struct bgpd_config *conf)
{
struct in_addr ina;
@@ -79,6 +100,9 @@ print_mainconf(struct bgpd_config *conf)
else
printf("fib-update yes\n");
+ if (conf->flags & BGPD_FLAG_NO_EVALUATE)
+ printf("route-collector yes\n");
+
if (conf->log & BGPD_LOG_UPDATES)
printf("log updates\n");
@@ -89,7 +113,9 @@ print_mainconf(struct bgpd_config *conf)
void
print_network(struct network_config *n)
{
- printf("network %s/%u\n", log_addr(&n->prefix), n->prefixlen);
+ printf("network %s/%u", log_addr(&n->prefix), n->prefixlen);
+ print_set(&n->attrset);
+ printf("\n");
}
void
@@ -130,20 +156,15 @@ print_peer(struct peer_config *p)
printf("%s\tannounce ???\n", c);
if (p->tcp_md5_key[0])
printf("%s\ttcp md5sig\n", c);
- if (p->attrset.flags) {
- printf("%s\tset {\n", c);
- if (p->attrset.flags & SET_LOCALPREF)
- printf("%s\t\tlocalpref %u\n", c, p->attrset.localpref);
- if (p->attrset.flags & SET_MED)
- printf("%s\t\tmed %u\n", c, p->attrset.med);
- if (p->attrset.flags & SET_NEXTHOP)
- printf("%s\t\tnexthop %s\n",
- c, inet_ntoa(p->attrset.nexthop));
- if (p->attrset.flags & SET_PREPEND)
- printf("%s\t\tprepend-self %u\n",
- c, p->attrset.prepend);
- printf("%s\t}\n", c);
- }
+
+ if (p->attrset.flags)
+ printf("%s\t", c);
+ print_set(&p->attrset);
+ if (p->attrset.flags)
+ printf("\n");
+
+ print_mrt(p->id, p->groupid, c == nada ? "\t" : "\t\t");
+
printf("%s}\n", c);
if (p->group[0])
printf("}\n");
@@ -218,34 +239,67 @@ print_rule(struct peer *peer_l, struct filter_rule *r)
printf("unfluffy-AS %u ", r->match.as.as);
}
- if (r->set.flags) {
- printf("set { ");
- if (r->set.flags & SET_LOCALPREF)
- printf("localpref %u ", r->set.localpref);
- if (r->set.flags & SET_MED)
- printf("med %u ", r->set.med);
- if (r->set.flags & SET_NEXTHOP)
- printf("nexthop %s ", inet_ntoa(r->set.nexthop));
- if (r->set.flags & SET_PREPEND)
- printf("prepend-self %u ", r->set.prepend);
+ print_set(&r->set);
+ printf("\n");
+}
- printf("}");
+const char *
+mrt_type(enum mrt_type t)
+{
+ switch (t) {
+ case MRT_NONE:
+ return "unfluffy MRT";
+ case MRT_TABLE_DUMP:
+ return "table";
+ case MRT_ALL_IN:
+ return "all in";
+ case MRT_ALL_OUT:
+ return "all out";
+ case MRT_UPDATE_IN:
+ return "updates in";
+ case MRT_UPDATE_OUT:
+ return "updates out";
}
+ return "unfluffy MRT";
+}
- printf("\n");
+struct mrt_head *xmrt_l = NULL;
+
+void
+print_mrt(u_int32_t pid, u_int32_t gid, const char *prep)
+{
+ struct mrt *m;
+
+ if (xmrt_l == NULL)
+ return;
+
+ LIST_FOREACH(m, xmrt_l, list)
+ if ((gid != 0 && m->conf.group_id == gid) ||
+ (m->conf.peer_id == pid && m->conf.group_id == gid)) {
+ if (m->ReopenTimerInterval == 0)
+ printf("%sdump %s %s\n", prep,
+ mrt_type(m->conf.type), m->name);
+ else
+ printf("%sdump %s %s %d\n", prep,
+ mrt_type(m->conf.type),
+ m->name, m->ReopenTimerInterval);
+ }
}
void
print_config(struct bgpd_config *conf, struct network_head *net_l,
- struct peer *peer_l, struct filter_head *rules_l)
+ struct peer *peer_l, struct filter_head *rules_l, struct mrt_head *mrt_l)
{
struct peer *p;
struct filter_rule *r;
struct network *n;
+ xmrt_l = mrt_l;
print_mainconf(conf);
printf("\n");
+ print_mrt(0, 0, "");
+ printf("\n");
TAILQ_FOREACH(n, net_l, network_l)
print_network(&n->net);
printf("\n");