summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2005-02-08 12:56:49 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2005-02-08 12:56:49 +0000
commit5b3ed4f761de8749a1b214cf758da3fa41004bde (patch)
tree752d3dffbd971bf883c9c3a80604addbb47b5746
parentb446f1a72b19951eed072490294f1706b8d57e66 (diff)
The LSA seq_num should be unsigned as it is expected by ntohl/htonl() even
though the seq_num needs to be compared as signed number. No idea how IETF came up with such a stupid idea especially because the seq_num is not allowed to wrap. requested by henning@ OK henning@
-rw-r--r--usr.sbin/ospfd/lsack.c4
-rw-r--r--usr.sbin/ospfd/ospf.h5
-rw-r--r--usr.sbin/ospfd/rde_lsdb.c8
3 files changed, 11 insertions, 6 deletions
diff --git a/usr.sbin/ospfd/lsack.c b/usr.sbin/ospfd/lsack.c
index 0e725c11d75..cdbe21e3e69 100644
--- a/usr.sbin/ospfd/lsack.c
+++ b/usr.sbin/ospfd/lsack.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lsack.c,v 1.4 2005/02/02 19:29:15 henning Exp $ */
+/* $OpenBSD: lsack.c,v 1.5 2005/02/08 12:56:48 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -146,7 +146,7 @@ lsa_hdr_check(struct nbr *nbr, struct lsa_hdr *lsa_hdr)
}
/* invalid sequence number */
- if (ntohl(lsa_hdr->seq_num) == 0x80000000) {
+ if (ntohl(lsa_hdr->seq_num) == RESV_SEQ_NUM) {
log_debug("ls_hdr_check: invalid seq num, neighbor ID %s",
inet_ntoa(nbr->id));
return (0);
diff --git a/usr.sbin/ospfd/ospf.h b/usr.sbin/ospfd/ospf.h
index 969c8924de9..5d1d36b9e96 100644
--- a/usr.sbin/ospfd/ospf.h
+++ b/usr.sbin/ospfd/ospf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospf.h,v 1.5 2005/02/04 07:38:04 claudio Exp $ */
+/* $OpenBSD: ospf.h,v 1.6 2005/02/08 12:56:48 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -91,6 +91,7 @@
#define CHECK_AGE 300
#define MAX_AGE_DIFF 900
#define LS_INFINITY 0xffffff
+#define RESV_SEQ_NUM 0x80000000 /* reserved and "unused" */
#define INIT_SEQ_NUM 0x80000001
#define MAX_SEQ_NUM 0x7fffffff
@@ -196,7 +197,7 @@ struct lsa_hdr {
u_int8_t type;
u_int32_t ls_id;
u_int32_t adv_rtr;
- int32_t seq_num;
+ u_int32_t seq_num;
u_int16_t ls_chksum;
u_int16_t len;
};
diff --git a/usr.sbin/ospfd/rde_lsdb.c b/usr.sbin/ospfd/rde_lsdb.c
index 90935138e51..eafb5ed0502 100644
--- a/usr.sbin/ospfd/rde_lsdb.c
+++ b/usr.sbin/ospfd/rde_lsdb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde_lsdb.c,v 1.5 2005/02/07 05:51:00 david Exp $ */
+/* $OpenBSD: rde_lsdb.c,v 1.6 2005/02/08 12:56:48 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org>
@@ -110,6 +110,10 @@ lsa_newer(struct lsa_hdr *a, struct lsa_hdr *b)
if (b == NULL)
return (1);
+ /*
+ * The sequnece number is defined as signed 32-bit integer,
+ * no idea how IETF came up with such a stupid idea.
+ */
a32 = (int32_t)ntohl(a->seq_num);
b32 = (int32_t)ntohl(b->seq_num);
@@ -169,7 +173,7 @@ lsa_check(struct rde_nbr *nbr, struct lsa *lsa, u_int16_t len)
}
/* invalid sequence number */
- if (ntohl(lsa->hdr.seq_num) == 0x80000000) {
+ if (ntohl(lsa->hdr.seq_num) == RESV_SEQ_NUM) {
log_debug("ls_check: bad seq num");
return (0);
}