summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2004-08-11 16:48:46 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2004-08-11 16:48:46 +0000
commite21a047538205792863d5833675076439b6bf175 (patch)
treeef408c2025e48421f1c64961c046f3358d9a60a1 /usr.sbin
parent65fb9c46d43ad3a30b6c5acfa29dbe6fe6e3b97f (diff)
mrt dumps for cloned sessions did not work because the wrong address was used.
OK henning@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bgpd/mrt.c46
-rw-r--r--usr.sbin/bgpd/mrt.h7
-rw-r--r--usr.sbin/bgpd/session.c14
3 files changed, 38 insertions, 29 deletions
diff --git a/usr.sbin/bgpd/mrt.c b/usr.sbin/bgpd/mrt.c
index d7b5800249b..17347d1e5df 100644
--- a/usr.sbin/bgpd/mrt.c
+++ b/usr.sbin/bgpd/mrt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mrt.c,v 1.42 2004/08/11 09:37:11 claudio Exp $ */
+/* $OpenBSD: mrt.c,v 1.43 2004/08/11 16:48:45 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org>
@@ -85,7 +85,7 @@ static int mrt_open(struct mrt *, time_t);
int
mrt_dump_bgp_msg(struct mrt *mrt, void *pkg, u_int16_t pkglen,
- struct peer_config *peer, struct bgpd_config *bgp)
+ struct peer *peer, struct bgpd_config *bgp)
{
struct buf *buf;
u_int16_t len;
@@ -104,20 +104,24 @@ mrt_dump_bgp_msg(struct mrt *mrt, void *pkg, u_int16_t pkglen,
}
DUMP_SHORT(buf, bgp->as);
- DUMP_SHORT(buf, peer->remote_as);
+ DUMP_SHORT(buf, peer->conf.remote_as);
DUMP_SHORT(buf, /* ifindex */ 0);
- switch (peer->local_addr.af) {
+ switch (peer->sa_local.ss_family) {
case AF_INET:
DUMP_SHORT(buf, AFI_IPv4);
- DUMP_NLONG(buf, peer->local_addr.v4.s_addr);
- DUMP_NLONG(buf, peer->remote_addr.v4.s_addr);
+ DUMP_NLONG(buf,
+ ((struct sockaddr_in *)&peer->sa_local)->sin_addr.s_addr);
+ DUMP_NLONG(buf,
+ ((struct sockaddr_in *)&peer->sa_remote)->sin_addr.s_addr);
break;
case AF_INET6:
DUMP_SHORT(buf, AFI_IPv6);
- if (buf_add(buf, &peer->local_addr.v6,
- sizeof(peer->local_addr.v6)) == -1 ||
- buf_add(buf, &peer->remote_addr.v6,
- sizeof(peer->remote_addr.v6)) == -1) {
+ if (buf_add(buf,
+ &((struct sockaddr_in6 *)&peer->sa_local)->sin6_addr,
+ sizeof(struct in6_addr)) == -1 ||
+ buf_add(buf,
+ &((struct sockaddr_in6 *)&peer->sa_remote)->sin6_addr,
+ sizeof(struct in6_addr)) == -1) {
log_warnx("mrt_dump_bgp_msg: buf_add error");
buf_free(buf);
return (-1);
@@ -139,7 +143,7 @@ mrt_dump_bgp_msg(struct mrt *mrt, void *pkg, u_int16_t pkglen,
int
mrt_dump_state(struct mrt *mrt, u_int16_t old_state, u_int16_t new_state,
- struct peer_config *peer, struct bgpd_config *bgp)
+ struct peer *peer, struct bgpd_config *bgp)
{
struct buf *buf;
u_int16_t len;
@@ -158,20 +162,24 @@ mrt_dump_state(struct mrt *mrt, u_int16_t old_state, u_int16_t new_state,
}
DUMP_SHORT(buf, bgp->as);
- DUMP_SHORT(buf, peer->remote_as);
+ DUMP_SHORT(buf, peer->conf.remote_as);
DUMP_SHORT(buf, /* ifindex */ 0);
- switch (peer->local_addr.af) {
+ switch (peer->sa_local.ss_family) {
case AF_INET:
DUMP_SHORT(buf, AFI_IPv4);
- DUMP_NLONG(buf, peer->local_addr.v4.s_addr);
- DUMP_NLONG(buf, peer->remote_addr.v4.s_addr);
+ DUMP_NLONG(buf,
+ ((struct sockaddr_in *)&peer->sa_local)->sin_addr.s_addr);
+ DUMP_NLONG(buf,
+ ((struct sockaddr_in *)&peer->sa_remote)->sin_addr.s_addr);
break;
case AF_INET6:
DUMP_SHORT(buf, AFI_IPv6);
- if (buf_add(buf, &peer->local_addr.v6,
- sizeof(peer->local_addr.v6)) == -1 ||
- buf_add(buf, &peer->remote_addr.v6,
- sizeof(peer->remote_addr.v6)) == -1) {
+ if (buf_add(buf,
+ &((struct sockaddr_in6 *)&peer->sa_local)->sin6_addr,
+ sizeof(struct in6_addr)) == -1 ||
+ buf_add(buf,
+ &((struct sockaddr_in6 *)&peer->sa_remote)->sin6_addr,
+ sizeof(struct in6_addr)) == -1) {
log_warnx("mrt_dump_bgp_msg: buf_add error");
buf_free(buf);
return (-1);
diff --git a/usr.sbin/bgpd/mrt.h b/usr.sbin/bgpd/mrt.h
index d104a8a14b7..1f4942b18fa 100644
--- a/usr.sbin/bgpd/mrt.h
+++ b/usr.sbin/bgpd/mrt.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mrt.h,v 1.13 2004/07/28 16:00:02 claudio Exp $ */
+/* $OpenBSD: mrt.h,v 1.14 2004/08/11 16:48:45 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org>
@@ -272,14 +272,15 @@ struct mrt_config {
#define MRT2MC(x) ((struct mrt_config *)(x))
#define MRT_MAX_TIMEOUT 7200
+struct peer;
struct prefix;
struct pt_entry;
/* prototypes */
int mrt_dump_bgp_msg(struct mrt *, void *, u_int16_t,
- struct peer_config *, struct bgpd_config *);
+ struct peer *, struct bgpd_config *);
int mrt_dump_state(struct mrt *, u_int16_t, u_int16_t,
- struct peer_config *, struct bgpd_config *);
+ struct peer *, struct bgpd_config *);
void mrt_clear_seq(void);
void mrt_dump_upcall(struct pt_entry *, void *);
int mrt_write(struct mrt *);
diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c
index 11e70819e56..a681f32e21a 100644
--- a/usr.sbin/bgpd/session.c
+++ b/usr.sbin/bgpd/session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: session.c,v 1.187 2004/08/11 10:09:30 claudio Exp $ */
+/* $OpenBSD: session.c,v 1.188 2004/08/11 16:48:45 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -868,7 +868,7 @@ change_state(struct peer *peer, enum session_state state,
mrt->peer_id == peer->conf.id ||
mrt->group_id == peer->conf.groupid)
mrt_dump_state(mrt, peer->state, state,
- &peer->conf, conf);
+ peer, conf);
}
peer->state = state;
}
@@ -1204,7 +1204,7 @@ session_open(struct peer *p)
mrt->peer_id == p->conf.id ||
mrt->group_id == p->conf.groupid)
mrt_dump_bgp_msg(mrt, buf->buf, len,
- &p->conf, conf);
+ p, conf);
}
if (buf_close(&p->wbuf, buf) == -1) {
@@ -1257,7 +1257,7 @@ session_keepalive(struct peer *peer)
if ((mrt->peer_id == 0 && mrt->group_id == 0) ||
mrt->peer_id == peer->conf.id ||
mrt->group_id == peer->conf.groupid)
- mrt_dump_bgp_msg(mrt, buf->buf, len, &peer->conf, conf);
+ mrt_dump_bgp_msg(mrt, buf->buf, len, peer, conf);
}
if (buf_close(&peer->wbuf, buf) == -1) {
@@ -1316,7 +1316,7 @@ session_update(u_int32_t peerid, void *data, size_t datalen)
if ((mrt->peer_id == 0 && mrt->group_id == 0) ||
mrt->peer_id == p->conf.id ||
mrt->group_id == p->conf.groupid)
- mrt_dump_bgp_msg(mrt, buf->buf, len, &p->conf, conf);
+ mrt_dump_bgp_msg(mrt, buf->buf, len, p, conf);
}
if (buf_close(&p->wbuf, buf) == -1) {
@@ -1371,7 +1371,7 @@ session_notification(struct peer *peer, u_int8_t errcode, u_int8_t subcode,
if ((mrt->peer_id == 0 && mrt->group_id == 0) ||
mrt->peer_id == peer->conf.id ||
mrt->group_id == peer->conf.groupid)
- mrt_dump_bgp_msg(mrt, buf->buf, len, &peer->conf, conf);
+ mrt_dump_bgp_msg(mrt, buf->buf, len, peer, conf);
}
if (buf_close(&peer->wbuf, buf) == -1) {
@@ -1616,7 +1616,7 @@ parse_header(struct peer *peer, u_char *data, u_int16_t *len, u_int8_t *type)
if ((mrt->peer_id == 0 && mrt->group_id == 0) ||
mrt->peer_id == peer->conf.id ||
mrt->group_id == peer->conf.groupid)
- mrt_dump_bgp_msg(mrt, data, *len, &peer->conf, conf);
+ mrt_dump_bgp_msg(mrt, data, *len, peer, conf);
}
return (0);
}