summaryrefslogtreecommitdiff
path: root/src/ipcpd
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@ugent.be>2018-07-25 11:42:53 +0200
committerDimitri Staessens <dimitri.staessens@ugent.be>2018-07-25 13:29:15 +0200
commit55e1cd4caffbf8f31b03c53b99f27dc85c3a9aba (patch)
tree3ef70f9bfdfe4993b4d58ec7ede03f91618f994d /src/ipcpd
parentd4ce582882e832acda9cbf3802ac1ee7cd5abbfd (diff)
downloadouroboros-55e1cd4caffbf8f31b03c53b99f27dc85c3a9aba.tar.gz
ouroboros-55e1cd4caffbf8f31b03c53b99f27dc85c3a9aba.zip
ipcpd: Fix sequence number check for link state0.11.11
Commit a3903da659e introduced sequence number for the LSAs to make it more robust, but the check was not done properly, and the seqno was always changed regardless of whether it was an old LSA or not. Signed-off-by: Sander Vrijders <sander.vrijders@ugent.be> Signed-off-by: Dimitri Staessens <dimitri.staessens@ugent.be>
Diffstat (limited to 'src/ipcpd')
-rw-r--r--src/ipcpd/normal/pol/link_state.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/ipcpd/normal/pol/link_state.c b/src/ipcpd/normal/pol/link_state.c
index 8e5d3807..c6d641c2 100644
--- a/src/ipcpd/normal/pol/link_state.c
+++ b/src/ipcpd/normal/pol/link_state.c
@@ -60,10 +60,6 @@
#define CLOCK_REALTIME_COARSE CLOCK_REALTIME
#endif
-#define LSA_NEW 0
-#define LSA_UPDATED 1
-#define LSA_OLD 2
-
struct lsa {
uint64_t d_addr;
uint64_t s_addr;
@@ -401,7 +397,7 @@ static int lsdb_add_link(uint64_t src,
struct list_head * p;
struct adjacency * adj;
struct timespec now;
- int ret;
+ int ret = -1;
clock_gettime(CLOCK_REALTIME_COARSE, &now);
@@ -410,9 +406,11 @@ static int lsdb_add_link(uint64_t src,
list_for_each(p, &ls.db) {
struct adjacency * a = list_entry(p, struct adjacency, next);
if (a->dst == dst && a->src == src) {
- ret = (a->seqno <= seqno ? LSA_OLD : LSA_UPDATED);
- a->stamp = now.tv_sec;
- a->seqno = seqno;
+ if (a->seqno < seqno) {
+ a->stamp = now.tv_sec;
+ a->seqno = seqno;
+ ret = 0;
+ }
pthread_rwlock_unlock(&ls.db_lock);
return ret;
}
@@ -443,7 +441,7 @@ static int lsdb_add_link(uint64_t src,
set_pff_modified();
- return LSA_NEW;
+ return 0;
}
static int lsdb_del_link(uint64_t src,
@@ -738,8 +736,10 @@ static void * lsreader(void * o)
if (lsdb_add_link(ntoh64(msg->s_addr),
ntoh64(msg->d_addr),
ntoh64(msg->seqno),
- &qs) != LSA_OLD)
- forward_lsm(buf, len, fd);
+ &qs))
+ continue;
+
+ forward_lsm(buf, len, fd);
}
}