]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
OSPF: Reject duplicate DBDES packets after dead interval
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Sun, 3 Feb 2019 20:31:15 +0000 (21:31 +0100)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Sun, 3 Feb 2019 20:31:15 +0000 (21:31 +0100)
Master may free last DBDES packet immediately. Slave must wait dead
interval before freeing last DBDES packet and then reject duplicate
DBDES packets with SeqNumberMismatch.

proto/ospf/dbdes.c
proto/ospf/neighbor.c
proto/ospf/ospf.h

index e74baa823dece0844c620879ca4f3feb6bf8ff42..3c22850871ce3da378f41585ccceb9ad05e82a1c 100644 (file)
@@ -235,6 +235,14 @@ ospf_rxmt_dbdes(struct ospf_proto *p, struct ospf_neighbor *n)
   ospf_do_send_dbdes(p, n);
 }
 
+void
+ospf_reset_ldd(struct ospf_proto *p UNUSED, struct ospf_neighbor *n)
+{
+  mb_free(n->ldd_buffer);
+  n->ldd_buffer = NULL;
+  n->ldd_bsize = 0;
+}
+
 static int
 ospf_process_dbdes(struct ospf_proto *p, struct ospf_packet *pkt, struct ospf_neighbor *n)
 {
@@ -433,6 +441,7 @@ ospf_receive_dbdes(struct ospf_packet *pkt, struct ospf_iface *ifa,
       if (!(n->myimms & DBDES_M) && !(n->imms & DBDES_M))
       {
        tm_stop(n->dbdes_timer);
+       ospf_reset_ldd(p, n);
        ospf_neigh_sm(n, INM_EXDONE);
        break;
       }
@@ -456,7 +465,11 @@ ospf_receive_dbdes(struct ospf_packet *pkt, struct ospf_iface *ifa,
       ospf_send_dbdes(p, n);
 
       if (!(n->myimms & DBDES_M) && !(n->imms & DBDES_M))
+      {
+       /* Use dbdes timer to postpone freeing of Last DBDES packet buffer */
+       tm_start(n->dbdes_timer, n->ifa->deadint S);
        ospf_neigh_sm(n, INM_EXDONE);
+      }
     }
     break;
 
index 9239894ecbc687474315468bc8ec3470dde9ddb9..6d2f1fb2e401a745bade894165ee43b3a4359c53 100644 (file)
@@ -610,6 +610,12 @@ dbdes_timer_hook(timer *t)
 
   if ((n->state == NEIGHBOR_EXCHANGE) && (n->myimms & DBDES_MS))
     ospf_rxmt_dbdes(p, n);
+
+  if ((n->state > NEIGHBOR_LOADING) && !(n->myimms & DBDES_MS))
+  {
+    ospf_reset_ldd(p, n);
+    tm_stop(n->dbdes_timer);
+  }
 }
 
 static void
index 35fd667221d6bd143cc7825fdf2810ee23b99ca9..6a20300e523f9be2c270526d0611e8dca3589d6d 100644 (file)
@@ -989,6 +989,7 @@ void ospf_receive_hello(struct ospf_packet *pkt, struct ospf_iface *ifa, struct
 /* dbdes.c */
 void ospf_send_dbdes(struct ospf_proto *p, struct ospf_neighbor *n);
 void ospf_rxmt_dbdes(struct ospf_proto *p, struct ospf_neighbor *n);
+void ospf_reset_ldd(struct ospf_proto *p, struct ospf_neighbor *n);
 void ospf_receive_dbdes(struct ospf_packet *pkt, struct ospf_iface *ifa, struct ospf_neighbor *n);
 
 /* lsreq.c */