diff options
author | 2005-02-10 14:05:48 +0000 | |
---|---|---|
committer | 2005-02-10 14:05:48 +0000 | |
commit | 299d99d928b9ef0e481c4dcf17a0687232313859 (patch) | |
tree | 88d73c14b3939524ccca588660dd8d63e8980e1b | |
parent | Add NAT-T here too. (diff) | |
download | wireguard-openbsd-299d99d928b9ef0e481c4dcf17a0687232313859.tar.xz wireguard-openbsd-299d99d928b9ef0e481c4dcf17a0687232313859.zip |
Work around a timing issue in the db exchange phase. The DB description
packets comming from the net are looped through the RDE and may get
delayed because of this. The result is that the neighbor FSM ends in
state FULL instead of LOADING and so the LSDB is not correctly
synchronized. Issue found by norby@ OK norby@
-rw-r--r-- | usr.sbin/ospfd/database.c | 10 | ||||
-rw-r--r-- | usr.sbin/ospfd/lsreq.c | 4 | ||||
-rw-r--r-- | usr.sbin/ospfd/neighbor.c | 11 | ||||
-rw-r--r-- | usr.sbin/ospfd/ospfd.h | 3 | ||||
-rw-r--r-- | usr.sbin/ospfd/ospfe.c | 16 | ||||
-rw-r--r-- | usr.sbin/ospfd/ospfe.h | 4 | ||||
-rw-r--r-- | usr.sbin/ospfd/rde.c | 5 |
7 files changed, 40 insertions, 13 deletions
diff --git a/usr.sbin/ospfd/database.c b/usr.sbin/ospfd/database.c index dd0f5b5cd78..9f4d6ccf003 100644 --- a/usr.sbin/ospfd/database.c +++ b/usr.sbin/ospfd/database.c @@ -1,4 +1,4 @@ -/* $OpenBSD: database.c,v 1.4 2005/02/09 15:39:22 claudio Exp $ */ +/* $OpenBSD: database.c,v 1.5 2005/02/10 14:05:48 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -263,9 +263,11 @@ recv_db_description(struct nbr *nbr, char *buf, u_int16_t len) nbr->dd_seq_num++; /* this packet may already have data so pass it on */ - if (len > 0) + if (len > 0) { + nbr->dd_pending++; ospfe_imsg_compose_rde(IMSG_DD, nbr->peerid, 0, buf, len); + } /* event negotiation done */ nbr_fsm(nbr, NBR_EVT_NEG_DONE); @@ -337,9 +339,11 @@ recv_db_description(struct nbr *nbr, char *buf, u_int16_t len) } /* forward to RDE and let it decide which LSA's to request */ - if (len > 0) + if (len > 0) { + nbr->dd_pending++; ospfe_imsg_compose_rde(IMSG_DD, nbr->peerid, 0, buf, len); + } /* next packet */ db_sum_list_next(nbr); diff --git a/usr.sbin/ospfd/lsreq.c b/usr.sbin/ospfd/lsreq.c index fc3e5113673..1764cb011b9 100644 --- a/usr.sbin/ospfd/lsreq.c +++ b/usr.sbin/ospfd/lsreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lsreq.c,v 1.3 2005/02/02 19:15:07 henning Exp $ */ +/* $OpenBSD: lsreq.c,v 1.4 2005/02/10 14:05:48 claudio Exp $ */ /* * Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org> @@ -169,7 +169,7 @@ ls_req_list_free(struct nbr *nbr, struct lsa_entry *le) start_ls_req_tx_timer(nbr); } - if (ls_req_list_empty(nbr)) + if (ls_req_list_empty(nbr) && nbr->dd_pending == 0) nbr_fsm(nbr, NBR_EVT_LOAD_DONE); } diff --git a/usr.sbin/ospfd/neighbor.c b/usr.sbin/ospfd/neighbor.c index 207305ca3fc..5d314991bcb 100644 --- a/usr.sbin/ospfd/neighbor.c +++ b/usr.sbin/ospfd/neighbor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: neighbor.c,v 1.10 2005/02/10 10:16:02 claudio Exp $ */ +/* $OpenBSD: neighbor.c,v 1.11 2005/02/10 14:05:48 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -497,6 +497,7 @@ nbr_act_eval(struct nbr *nbr) nbr->state = NBR_STA_XSTRT; nbr->master = true; nbr->dd_seq_num++; /* as per RFC */ + nbr->dd_pending = 0; /* initial db negotiation */ start_db_tx_timer(nbr); @@ -524,13 +525,16 @@ nbr_act_exchange_done(struct nbr *nbr) if (nbr->master) stop_db_tx_timer(nbr); - if (ls_req_list_empty(nbr) && nbr->state == NBR_STA_XCHNG) { + if (ls_req_list_empty(nbr) && nbr->state == NBR_STA_XCHNG && + nbr->dd_pending == 0) { nbr->state = NBR_STA_FULL; return (0); } nbr->state = NBR_STA_LOAD; - start_ls_req_tx_timer(nbr); + + if (!ls_req_list_empty(nbr)) + start_ls_req_tx_timer(nbr); return (0); } @@ -566,6 +570,7 @@ nbr_act_restart_dd(struct nbr *nbr) nbr->state = NBR_STA_XSTRT; nbr->master = true; nbr->dd_seq_num += arc4random() & 0xffff; + nbr->dd_pending = 0; /* initial db negotiation */ start_db_tx_timer(nbr); diff --git a/usr.sbin/ospfd/ospfd.h b/usr.sbin/ospfd/ospfd.h index 5a2c3855d6d..f47a5cf22ac 100644 --- a/usr.sbin/ospfd/ospfd.h +++ b/usr.sbin/ospfd/ospfd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfd.h,v 1.7 2005/02/09 17:41:16 claudio Exp $ */ +/* $OpenBSD: ospfd.h,v 1.8 2005/02/10 14:05:48 claudio Exp $ */ /* * Copyright (c) 2004 Esben Norby <norby@openbsd.org> @@ -106,6 +106,7 @@ enum imsg_type { IMSG_NEIGHBOR_DOWN, IMSG_NEIGHBOR_CHANGE, IMSG_DD, + IMSG_DD_END, IMSG_DB_SNAPSHOT, IMSG_DB_END, IMSG_LS_REQ, diff --git a/usr.sbin/ospfd/ospfe.c b/usr.sbin/ospfd/ospfe.c index b6aae0bf494..3912470ab93 100644 --- a/usr.sbin/ospfd/ospfe.c +++ b/usr.sbin/ospfd/ospfe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfe.c,v 1.5 2005/02/09 20:40:23 claudio Exp $ */ +/* $OpenBSD: ospfe.c,v 1.6 2005/02/10 14:05:48 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -335,6 +335,20 @@ ospfe_dispatch_rde(int fd, short event, void *bula) memcpy(lhp, imsg.data, sizeof(*lhp)); ls_req_list_add(nbr, lhp); break; + case IMSG_DD_END: + nbr = nbr_find_peerid(imsg.hdr.peerid); + if (nbr == NULL) + fatalx("ospfe_dispatch_rde: " + "neighbor not found"); + + nbr->dd_pending--; + if (nbr->dd_pending == 0 && nbr->state & NBR_STA_LOAD) { + if (ls_req_list_empty(nbr)) + nbr_fsm(nbr, NBR_EVT_LOAD_DONE); + else + start_ls_req_tx_timer(nbr); + } + break; case IMSG_DB_SNAPSHOT: nbr = nbr_find_peerid(imsg.hdr.peerid); if (nbr == NULL) diff --git a/usr.sbin/ospfd/ospfe.h b/usr.sbin/ospfd/ospfe.h index 668ccdaa0e5..9ee7500a488 100644 --- a/usr.sbin/ospfd/ospfe.h +++ b/usr.sbin/ospfd/ospfe.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfe.h,v 1.5 2005/02/09 20:47:04 claudio Exp $ */ +/* $OpenBSD: ospfe.h,v 1.6 2005/02/10 14:05:48 claudio Exp $ */ /* * Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org> @@ -129,8 +129,8 @@ struct nbr { struct lsa_entry *dd_end; u_int32_t dd_seq_num; + u_int32_t dd_pending; u_int32_t peerid; /* unique ID in DB */ - u_int32_t ls_req_cnt; int state; diff --git a/usr.sbin/ospfd/rde.c b/usr.sbin/ospfd/rde.c index d52d0cc0b6a..a0125141205 100644 --- a/usr.sbin/ospfd/rde.c +++ b/usr.sbin/ospfd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.5 2005/02/09 22:58:08 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.6 2005/02/10 14:05:48 claudio Exp $ */ /* * Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org> @@ -294,6 +294,9 @@ rde_dispatch_imsg(int fd, short event, void *bula) log_warnx("rde_dispatch_imsg: peerid %lu, " "trailing garbage in Database Description " "packet", imsg.hdr.peerid); + + imsg_compose(ibuf_ospfe, IMSG_DD_END, imsg.hdr.peerid, + 0, -1, NULL, 0); break; case IMSG_LS_REQ: nbr = rde_nbr_find(imsg.hdr.peerid); |