diff options
author | Jakob Schlyter <jakob@cvs.openbsd.org> | 2003-12-26 20:52:15 +0000 |
---|---|---|
committer | Jakob Schlyter <jakob@cvs.openbsd.org> | 2003-12-26 20:52:15 +0000 |
commit | c4e8f05dc74bc167e19c10fa6246513737c64199 (patch) | |
tree | 5b7973090d5664fae7e69052f4835f2cac2c1a16 /usr.sbin | |
parent | 80546cee49628606ea0a02fa0b72ba955cd3b05f (diff) |
add option 'log updates' to log updates. ok henning@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bgpd/bgpd.conf.5 | 4 | ||||
-rw-r--r-- | usr.sbin/bgpd/bgpd.h | 5 | ||||
-rw-r--r-- | usr.sbin/bgpd/config.c | 3 | ||||
-rw-r--r-- | usr.sbin/bgpd/parse.y | 8 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde.c | 28 |
5 files changed, 43 insertions, 5 deletions
diff --git a/usr.sbin/bgpd/bgpd.conf.5 b/usr.sbin/bgpd/bgpd.conf.5 index 59e7fc593f2..b6aad2a7110 100644 --- a/usr.sbin/bgpd/bgpd.conf.5 +++ b/usr.sbin/bgpd/bgpd.conf.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: bgpd.conf.5,v 1.6 2003/12/26 20:40:10 henning Exp $ +.\" $OpenBSD: bgpd.conf.5,v 1.7 2003/12/26 20:52:14 jakob Exp $ .\" .\" Copyright (c) 2003 Henning Brauer <henning@openbsd.org> .\" Copyright (c) 2002 Daniel Hartmeier <dhartmei@openbsd.org> @@ -129,6 +129,8 @@ daemon should listen on. .Bd -literal -offset indent listen on 127.0.0.1 .Ed +.It Ar log updates +Log received and sent updates. .It Ar no fib-update Do not update the Forward Information Base aka the kernel routing table. .El diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index 396718f9f53..22f429f11c7 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.39 2003/12/26 20:06:01 jakob Exp $ */ +/* $OpenBSD: bgpd.h,v 1.40 2003/12/26 20:52:14 jakob Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -43,6 +43,8 @@ #define BGPD_FLAG_NO_FIB_UPDATE 0x0001 +#define BGPD_LOG_UPDATES 0x0001 + enum { PROC_MAIN, PROC_SE, @@ -104,6 +106,7 @@ struct bgpd_config { u_int16_t holdtime; u_int16_t min_holdtime; int flags; + int log; struct sockaddr_in listen_addr; struct peer *peers; }; diff --git a/usr.sbin/bgpd/config.c b/usr.sbin/bgpd/config.c index a7f6172fc18..6f229d13b87 100644 --- a/usr.sbin/bgpd/config.c +++ b/usr.sbin/bgpd/config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: config.c,v 1.8 2003/12/26 18:07:32 henning Exp $ */ +/* $OpenBSD: config.c,v 1.9 2003/12/26 20:52:14 jakob Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -71,6 +71,7 @@ merge_config(struct bgpd_config *xconf, struct bgpd_config *conf) sizeof(xconf->listen_addr)); xconf->flags = conf->flags; + xconf->log = conf->log; /* * as we cannot get the negotiated holdtime in the main process, diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y index f2dedab8e22..d19c26d6437 100644 --- a/usr.sbin/bgpd/parse.y +++ b/usr.sbin/bgpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.19 2003/12/26 18:07:32 henning Exp $ */ +/* $OpenBSD: parse.y,v 1.20 2003/12/26 20:52:14 jakob Exp $ */ /* * Copyright (c) 2002, 2003 Henning Brauer <henning@openbsd.org> @@ -87,6 +87,7 @@ typedef struct { %token REMOTEAS DESCR LOCALADDR MULTIHOP PASSIVE %token ERROR %token MRTDUMP +%token LOG UPDATES %token <v.string> STRING %type <v.number> number %type <v.string> string @@ -158,6 +159,9 @@ conf_main : AS number { | NO FIBUPDATE { conf->flags |= BGPD_FLAG_NO_FIB_UPDATE; } + | LOG UPDATES { + conf->log |= BGPD_LOG_UPDATES; + } /* * XXX this is bad. * a) number should be optional @@ -313,6 +317,7 @@ lookup(char *s) { "holdtime", HOLDTIME}, { "listen", LISTEN}, { "local-addr", LOCALADDR}, + { "log", LOG}, { "min", YMIN}, { "mrtdump", MRTDUMP}, { "multihop", MULTIHOP}, @@ -322,6 +327,7 @@ lookup(char *s) { "passive", PASSIVE}, { "remote-as", REMOTEAS}, { "set", SET}, + { "updates", UPDATES}, }; const struct keywords *p; diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index 2f48e8a402b..7c9bd4d99a2 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.33 2003/12/26 18:33:11 henning Exp $ */ +/* $OpenBSD: rde.c,v 1.34 2003/12/26 20:52:14 jakob Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -41,6 +41,9 @@ int rde_update_get_prefix(u_char *, u_int16_t, struct in_addr *, void init_attr_flags(struct attr_flags *); int rde_update_get_attr(u_char *, u_int16_t, struct attr_flags *); void rde_update_err(u_int32_t, enum suberr_update); +void rde_update_log(const char *, + const struct rde_peer *, const struct attr_flags *, + const struct in_addr *, u_int8_t); void peer_init(struct bgpd_config *, u_long); struct rde_peer *peer_add(u_int32_t, struct peer_config *); @@ -312,6 +315,7 @@ rde_update_dispatch(struct imsg *imsg) } p += pos; withdrawn_len -= pos; + rde_update_log("withdraw", peer, NULL, &prefix, prefixlen); prefix_remove(peer, prefix, prefixlen); } @@ -346,6 +350,7 @@ rde_update_dispatch(struct imsg *imsg) } p += pos; nlri_len -= pos; + rde_update_log("update", peer, &attrs, &prefix, prefixlen); path_update(peer, &attrs, prefix, prefixlen); } @@ -503,6 +508,27 @@ rde_update_err(u_int32_t peerid, enum suberr_update errorcode) fatal("imsg_compose error"); } +void +rde_update_log(const char *message, + const struct rde_peer *peer, const struct attr_flags *attr, + const struct in_addr *prefix, u_int8_t prefixlen) +{ + char *neighbor; + + if (! (conf->log & BGPD_LOG_UPDATES)) + return; + + neighbor = strdup(inet_ntoa(peer->conf.remote_addr.sin_addr)); + if (neighbor == NULL) + return; + + logit(LOG_DEBUG, "neighbor %s (AS%u) %s %s/%u", + neighbor, peer->conf.remote_as, message, + inet_ntoa(*prefix), prefixlen); + + free(neighbor); +} + /* * kroute specific functions */ |