diff options
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r-- | usr.sbin/bgpd/bgpd.h | 8 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde.c | 19 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde.h | 7 | ||||
-rw-r--r-- | usr.sbin/bgpd/session.c | 21 |
4 files changed, 41 insertions, 14 deletions
diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index 70f10248857..5460caf2110 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.64 2004/01/11 19:42:27 henning Exp $ */ +/* $OpenBSD: bgpd.h,v 1.65 2004/01/11 20:13:00 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -211,6 +211,12 @@ struct kroute_nexthop { struct kroute kr; }; +struct session_up { + u_int32_t remote_bgpid; + struct bgpd_addr local_addr; + struct bgpd_addr remote_addr; +}; + struct ctl_show_nexthop { struct bgpd_addr addr; u_int8_t valid; diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index ee6f398ca87..5e7d8794b65 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.53 2004/01/11 02:39:05 henning Exp $ */ +/* $OpenBSD: rde.c,v 1.54 2004/01/11 20:13:00 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -54,7 +54,7 @@ void peer_init(struct peer *, u_long); struct rde_peer *peer_add(u_int32_t, struct peer_config *); void peer_remove(struct rde_peer *); struct rde_peer *peer_get(u_int32_t); -void peer_up(u_int32_t, u_int32_t); +void peer_up(u_int32_t, struct session_up *); void peer_down(u_int32_t); volatile sig_atomic_t rde_quit = 0; @@ -179,7 +179,7 @@ void rde_dispatch_imsg_session(struct imsgbuf *ibuf) { struct imsg imsg; - u_int32_t rid; + struct session_up sup; int n; if ((n = imsg_read(ibuf)) == -1) @@ -198,10 +198,10 @@ rde_dispatch_imsg_session(struct imsgbuf *ibuf) rde_update_dispatch(&imsg); break; case IMSG_SESSION_UP: - if (imsg.hdr.len - IMSG_HEADER_SIZE != sizeof(rid)) + if (imsg.hdr.len - IMSG_HEADER_SIZE != sizeof(sup)) fatalx("incorrect size of session request"); - memcpy(&rid, imsg.data, sizeof(rid)); - peer_up(imsg.hdr.peerid, rid); + memcpy(&sup, imsg.data, sizeof(sup)); + peer_up(imsg.hdr.peerid, &sup); break; case IMSG_SESSION_DOWN: peer_down(imsg.hdr.peerid); @@ -777,7 +777,7 @@ peer_remove(struct rde_peer *peer) } void -peer_up(u_int32_t id, u_int32_t rid) +peer_up(u_int32_t id, struct session_up *sup) { struct rde_peer *peer; @@ -786,7 +786,10 @@ peer_up(u_int32_t id, u_int32_t rid) logit(LOG_CRIT, "peer_up: unknown peer id %d", id); return; } - peer->remote_bgpid = ntohl(rid); + peer->remote_bgpid = ntohl(sup->remote_bgpid); + memcpy(&peer->local_addr, &sup->local_addr, sizeof(peer->local_addr)); + memcpy(&peer->remote_addr, &sup->remote_addr, + sizeof(peer->remote_addr)); peer->state = PEER_UP; up_init(peer); } diff --git a/usr.sbin/bgpd/rde.h b/usr.sbin/bgpd/rde.h index b0110dd2c88..4645f69110c 100644 --- a/usr.sbin/bgpd/rde.h +++ b/usr.sbin/bgpd/rde.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.h,v 1.13 2004/01/10 22:25:42 claudio Exp $ */ +/* $OpenBSD: rde.h,v 1.14 2004/01/11 20:13:00 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and @@ -59,9 +59,10 @@ struct rde_peer { LIST_ENTRY(rde_peer) peer_l; /* list of all peers */ struct aspath_head path_h; /* list of all as paths */ struct peer_config conf; - u_int32_t remote_bgpid; enum peer_state state; - struct in_addr if_ip; /* nexthop for announcements*/ + u_int32_t remote_bgpid; + struct bgpd_addr remote_addr; + struct bgpd_addr local_addr; u_int32_t up_pcnt; u_int32_t up_acnt; u_int32_t up_nlricnt; diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c index dad56ae34a6..8f4ba4de1e1 100644 --- a/usr.sbin/bgpd/session.c +++ b/usr.sbin/bgpd/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.85 2004/01/11 18:42:25 henning Exp $ */ +/* $OpenBSD: session.c,v 1.86 2004/01/11 20:13:00 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -1528,9 +1528,26 @@ session_down(struct peer *peer) void session_up(struct peer *peer) { + struct session_up sup; + + sup.remote_bgpid = peer->remote_bgpid; + + switch (peer->sa_local.ss_family) { + case AF_INET: + sup.local_addr.af = AF_INET; + sup.local_addr.v4 = + ((struct sockaddr_in *)&peer->sa_local)->sin_addr; + sup.remote_addr.af = AF_INET; + sup.remote_addr.v4 = + ((struct sockaddr_in *)&peer->sa_remote)->sin_addr; + break; + default: + fatalx("session_up: only AF_INET supported"); + } + peer->stats.last_updown = time(NULL); if (imsg_compose(&ibuf_rde, IMSG_SESSION_UP, peer->conf.id, - &peer->remote_bgpid, sizeof(peer->remote_bgpid)) == -1) + &sup, sizeof(sup)) == -1) fatalx("imsg_compose error"); } |