summaryrefslogtreecommitdiff
path: root/usr.sbin/ospf6d
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2007-10-11 18:43:43 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2007-10-11 18:43:43 +0000
commitc21299fb858339f872a81938f9e140b59c1f620d (patch)
tree9f78109fa6f4cc7b1285be903b1d1b90f5a7b3a1 /usr.sbin/ospf6d
parent775044fa393742aee6a9a9752c013a116f4a94c1 (diff)
From ospfd:
Do not overload nbr->options with the dd exchange bits. nbr->options is used by the hello protocol. Instead add a dd_more flag that is used together with (the renamed) dd_master flag.
Diffstat (limited to 'usr.sbin/ospf6d')
-rw-r--r--usr.sbin/ospf6d/database.c61
-rw-r--r--usr.sbin/ospf6d/neighbor.c10
-rw-r--r--usr.sbin/ospf6d/ospfe.h5
3 files changed, 39 insertions, 37 deletions
diff --git a/usr.sbin/ospf6d/database.c b/usr.sbin/ospf6d/database.c
index 6eeb4d467ca..3179ade15c0 100644
--- a/usr.sbin/ospf6d/database.c
+++ b/usr.sbin/ospf6d/database.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: database.c,v 1.2 2007/10/10 14:09:25 claudio Exp $ */
+/* $OpenBSD: database.c,v 1.3 2007/10/11 18:43:42 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -45,6 +45,7 @@ send_db_description(struct nbr *nbr)
struct lsa_entry *le, *nle;
struct buf *buf;
int ret = 0;
+ u_int8_t bits = 0;
if ((buf = buf_open(nbr->iface->mtu - sizeof(struct ip))) == NULL)
fatal("send_db_description");
@@ -69,23 +70,24 @@ send_db_description(struct nbr *nbr)
ret = -1;
goto done;
case NBR_STA_XSTRT:
- nbr->options |= OSPF_DBD_MS | OSPF_DBD_M | OSPF_DBD_I;
+ bits |= OSPF_DBD_MS | OSPF_DBD_M | OSPF_DBD_I;
+ nbr->dd_more = 1;
break;
case NBR_STA_XCHNG:
- if (nbr->master) {
- /* master */
- nbr->options |= OSPF_DBD_MS;
+ if (nbr->dd_master)
+ bits |= OSPF_DBD_MS;
+ else
+ bits &= ~OSPF_DBD_MS;
+
+ if (TAILQ_EMPTY(&nbr->db_sum_list)) {
+ bits &= ~OSPF_DBD_M;
+ nbr->dd_more = 0;
} else {
- /* slave */
- nbr->options &= ~OSPF_DBD_MS;
+ bits |= OSPF_DBD_M;
+ nbr->dd_more = 1;
}
- if (TAILQ_EMPTY(&nbr->db_sum_list))
- nbr->options &= ~OSPF_DBD_M;
- else
- nbr->options |= OSPF_DBD_M;
-
- nbr->options &= ~OSPF_DBD_I;
+ bits &= ~OSPF_DBD_I;
/* build LSA list, keep space for a possible md5 sum */
for (le = TAILQ_FIRST(&nbr->db_sum_list); le != NULL &&
@@ -98,16 +100,14 @@ send_db_description(struct nbr *nbr)
break;
case NBR_STA_LOAD:
case NBR_STA_FULL:
- if (nbr->master) {
- /* master */
- nbr->options |= OSPF_DBD_MS;
- } else {
- /* slave */
- nbr->options &= ~OSPF_DBD_MS;
- }
- nbr->options &= ~OSPF_DBD_M;
- nbr->options &= ~OSPF_DBD_I;
+ if (nbr->dd_master)
+ bits |= OSPF_DBD_MS;
+ else
+ bits &= ~OSPF_DBD_MS;
+ bits &= ~OSPF_DBD_M;
+ bits &= ~OSPF_DBD_I;
+ nbr->dd_more = 0;
break;
default:
fatalx("send_db_description: unknown neighbor state");
@@ -135,7 +135,7 @@ send_db_description(struct nbr *nbr)
}
dd_hdr.opts = oeconf->options;
- dd_hdr.bits = nbr->options;
+ dd_hdr.bits = bits;
dd_hdr.dd_seq_num = htonl(nbr->dd_seq_num);
memcpy(buf_seek(buf, sizeof(struct ospf_hdr), sizeof(dd_hdr)),
@@ -181,7 +181,8 @@ recv_db_description(struct nbr *nbr, char *buf, u_int16_t len)
if (nbr->last_rx_options == dd_hdr.opts &&
nbr->last_rx_bits == dd_hdr.bits &&
- ntohl(dd_hdr.dd_seq_num) == nbr->dd_seq_num - nbr->master ? 1 : 0) {
+ ntohl(dd_hdr.dd_seq_num) == nbr->dd_seq_num - nbr->dd_master ?
+ 1 : 0) {
log_debug("recv_db_description: dupe");
dupe = 1;
}
@@ -213,7 +214,7 @@ recv_db_description(struct nbr *nbr, char *buf, u_int16_t len)
if ((ntohl(nbr->id.s_addr)) >
ntohl(ospfe_router_id())) {
/* slave */
- nbr->master = 0;
+ nbr->dd_master = 0;
nbr->dd_seq_num = ntohl(dd_hdr.dd_seq_num);
/* event negotiation done */
@@ -251,7 +252,7 @@ recv_db_description(struct nbr *nbr, char *buf, u_int16_t len)
case NBR_STA_LOAD:
case NBR_STA_FULL:
if (dd_hdr.bits & OSPF_DBD_I ||
- !(dd_hdr.bits & OSPF_DBD_MS) == !nbr->master) {
+ !(dd_hdr.bits & OSPF_DBD_MS) == !nbr->dd_master) {
log_warnx("recv_db_description: seq num mismatch, "
"bad flags");
nbr_fsm(nbr, NBR_EVT_SEQ_NUM_MIS);
@@ -266,7 +267,7 @@ recv_db_description(struct nbr *nbr, char *buf, u_int16_t len)
}
if (dupe) {
- if (!nbr->master)
+ if (!nbr->dd_master)
/* retransmit */
start_db_tx_timer(nbr);
return;
@@ -281,7 +282,7 @@ recv_db_description(struct nbr *nbr, char *buf, u_int16_t len)
}
/* sanity check dd seq number */
- if (nbr->master) {
+ if (nbr->dd_master) {
/* master */
if (ntohl(dd_hdr.dd_seq_num) != nbr->dd_seq_num) {
log_warnx("recv_db_description: invalid "
@@ -316,7 +317,7 @@ recv_db_description(struct nbr *nbr, char *buf, u_int16_t len)
if (!(dd_hdr.bits & OSPF_DBD_M) &&
TAILQ_EMPTY(&nbr->db_sum_list))
- if (!nbr->master || !(nbr->options & OSPF_DBD_M))
+ if (!nbr->dd_master || !nbr->dd_more)
nbr_fsm(nbr, NBR_EVT_XCHNG_DONE);
break;
default:
@@ -386,7 +387,7 @@ db_tx_timer(int fd, short event, void *arg)
}
/* reschedule db_tx_timer but only in master mode */
- if (nbr->master) {
+ if (nbr->dd_master) {
timerclear(&tv);
tv.tv_sec = nbr->iface->rxmt_interval;
if (evtimer_add(&nbr->db_tx_timer, &tv) == -1)
diff --git a/usr.sbin/ospf6d/neighbor.c b/usr.sbin/ospf6d/neighbor.c
index 0b154db78f5..a126d631c55 100644
--- a/usr.sbin/ospf6d/neighbor.c
+++ b/usr.sbin/ospf6d/neighbor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: neighbor.c,v 1.1 2007/10/08 10:44:50 norby Exp $ */
+/* $OpenBSD: neighbor.c,v 1.2 2007/10/11 18:43:42 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -276,7 +276,7 @@ nbr_new(u_int32_t nbr_id, struct iface *iface, int self)
fatal("nbr_new");
nbr->state = NBR_STA_DOWN;
- nbr->master = 1;
+ nbr->dd_master = 1;
nbr->dd_seq_num = arc4random(); /* RFC: some unique value */
nbr->id.s_addr = nbr_id;
@@ -503,7 +503,7 @@ nbr_act_eval(struct nbr *nbr)
}
nbr->state = NBR_STA_XSTRT;
- nbr->master = 1;
+ nbr->dd_master = 1;
nbr->dd_seq_num++; /* as per RFC */
nbr->dd_pending = 0;
/* initial db negotiation */
@@ -527,7 +527,7 @@ nbr_act_snapshot(struct nbr *nbr)
int
nbr_act_exchange_done(struct nbr *nbr)
{
- if (nbr->master)
+ if (nbr->dd_master)
stop_db_tx_timer(nbr);
if (ls_req_list_empty(nbr) && nbr->state == NBR_STA_XCHNG &&
@@ -569,7 +569,7 @@ nbr_act_restart_dd(struct nbr *nbr)
}
nbr->state = NBR_STA_XSTRT;
- nbr->master = 1;
+ nbr->dd_master = 1;
nbr->dd_seq_num += arc4random() & 0xffff;
nbr->dd_pending = 0;
diff --git a/usr.sbin/ospf6d/ospfe.h b/usr.sbin/ospf6d/ospfe.h
index 5b8ba269187..84214b574e2 100644
--- a/usr.sbin/ospf6d/ospfe.h
+++ b/usr.sbin/ospf6d/ospfe.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfe.h,v 1.4 2007/10/10 14:09:25 claudio Exp $ */
+/* $OpenBSD: ospfe.h,v 1.5 2007/10/11 18:43:42 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -90,7 +90,8 @@ struct nbr {
u_int8_t options;
u_int8_t last_rx_options;
u_int8_t last_rx_bits;
- u_int8_t master;
+ u_int8_t dd_master;
+ u_int8_t dd_more;
};
/* database.c */