diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2004-04-27 03:53:44 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2004-04-27 03:53:44 +0000 |
commit | ae9a95e5a45c594bab5d1a3640e2b549f561b252 (patch) | |
tree | 80e2410741bbd12859b3cdb1da265acd5d2b89d6 | |
parent | a2e4e918360b7565774dfd3c1b70c1d7c12bea0e (diff) |
initial route refresh support per RFC2918
process incoming route refresh request and notify the RDE
not advertised via capabilities yet, claudio ok
-rw-r--r-- | usr.sbin/bgpd/bgpd.h | 10 | ||||
-rw-r--r-- | usr.sbin/bgpd/session.c | 42 | ||||
-rw-r--r-- | usr.sbin/bgpd/session.h | 8 |
3 files changed, 55 insertions, 5 deletions
diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index aac3048f8d4..b235e8dc77c 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.111 2004/04/26 04:13:59 henning Exp $ */ +/* $OpenBSD: bgpd.h,v 1.112 2004/04/27 03:53:42 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -246,7 +246,8 @@ enum imsg_type { IMSG_CTL_SHOW_INTERFACE, IMSG_CTL_SHOW_RIB, IMSG_CTL_SHOW_RIB_AS, - IMSG_CTL_SHOW_RIB_PREFIX + IMSG_CTL_SHOW_RIB_PREFIX, + IMSG_REFRESH }; struct imsg_hdr { @@ -458,6 +459,11 @@ struct filter_rule { struct filter_set set; }; +struct rrefresh { + u_int16_t afi; + u_int8_t safi; +}; + /* Address Family Numbers as per rfc1700 */ #define AFI_IPv4 1 #define AFI_IPv6 2 diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c index cd3bf3356c5..c6fd6c01845 100644 --- a/usr.sbin/bgpd/session.c +++ b/usr.sbin/bgpd/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.152 2004/04/26 09:35:39 markus Exp $ */ +/* $OpenBSD: session.c,v 1.153 2004/04/27 03:53:43 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -73,6 +73,7 @@ int session_dispatch_msg(struct pollfd *, struct peer *); int parse_header(struct peer *, u_char *, u_int16_t *, u_int8_t *); int parse_open(struct peer *); int parse_update(struct peer *); +int parse_refresh(struct peer *); int parse_notification(struct peer *); int parse_keepalive(struct peer *); int parse_capabilities(struct peer *, u_char *, u_int16_t); @@ -1323,6 +1324,10 @@ session_dispatch_msg(struct pollfd *pfd, struct peer *p) bgp_fsm(p, EVNT_RCVD_KEEPALIVE); p->stats.msg_rcvd_keepalive++; break; + case RREFRESH: + parse_refresh(p); + p->stats.msg_rcvd_rrefresh++; + break; default: /* cannot happen */ session_notification(p, ERR_HEADER, ERR_HDR_TYPE, &msgtype, 1); @@ -1419,6 +1424,15 @@ parse_header(struct peer *peer, u_char *data, u_int16_t *len, u_int8_t *type) return (-1); } break; + case RREFRESH: + if (*len != MSGSIZE_RREFRESH) { + log_peer_warnx(&peer->conf, + "received RREFRESH: illegal len: %u byte", *len); + session_notification(peer, ERR_HEADER, ERR_HDR_LEN, + &olen, sizeof(olen)); + return (-1); + } + break; default: log_peer_warnx(&peer->conf, "received msg with unknown type %u", *type); @@ -1625,6 +1639,32 @@ parse_update(struct peer *peer) } int +parse_refresh(struct peer *peer) +{ + u_char *p; + struct rrefresh r; + + p = peer->rbuf->rptr; + p += MSGSIZE_HEADER; /* header is already checked */ + + /* afi, 2 byte */ + memcpy(&r.afi, p, sizeof(r.afi)); + p += 2; + /* reserved, 1 byte */ + p += 1; + /* safi, 1 byte */ + memcpy(&r.safi, p, sizeof(r.safi)); + + /* afi/safi unchecked - unrecognized values will be ignored anyway */ + + if (imsg_compose(&ibuf_rde, IMSG_REFRESH, peer->conf.id, &r, + sizeof(r)) == -1) + return (-1); + + return (0); +} + +int parse_notification(struct peer *peer) { u_char *p; diff --git a/usr.sbin/bgpd/session.h b/usr.sbin/bgpd/session.h index 51678c59fbc..2f013d75b20 100644 --- a/usr.sbin/bgpd/session.h +++ b/usr.sbin/bgpd/session.h @@ -1,4 +1,4 @@ -/* $OpenBSD: session.h,v 1.45 2004/04/26 09:35:39 markus Exp $ */ +/* $OpenBSD: session.h,v 1.46 2004/04/27 03:53:43 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -32,6 +32,7 @@ #define MSGSIZE_OPEN_MIN 29 #define MSGSIZE_UPDATE_MIN 23 #define MSGSIZE_KEEPALIVE MSGSIZE_HEADER +#define MSGSIZE_RREFRESH MSGSIZE_HEADER + 4 enum session_state { STATE_NONE, @@ -69,7 +70,8 @@ enum msg_type { OPEN = 1, UPDATE, NOTIFICATION, - KEEPALIVE + KEEPALIVE, + RREFRESH }; enum suberr_header { @@ -133,10 +135,12 @@ struct peer_stats { u_int64_t msg_rcvd_update; u_int64_t msg_rcvd_notification; u_int64_t msg_rcvd_keepalive; + u_int64_t msg_rcvd_rrefresh; u_int64_t msg_sent_open; u_int64_t msg_sent_update; u_int64_t msg_sent_notification; u_int64_t msg_sent_keepalive; + u_int64_t msg_sent_rrefresh; time_t last_updown; time_t last_read; }; |