]> 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 16:31:27 +0000 (17:31 +0100)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Sun, 3 Feb 2019 16:31:27 +0000 (17: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 4d3bbe8c257451a58e30913f197aa8457931edbf..a1559782a2bb00629d3d771200919502dcf588b1 100644 (file)
@@ -238,6 +238,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)
 {
@@ -434,6 +442,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;
       }
@@ -457,7 +466,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 54d643c65e550f9b87254627a988d4c0175cc928..c143b1306fa94a16cc0ef4828f777c42f3e70f1b 100644 (file)
@@ -608,6 +608,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 23289ccd503c88c4f4d73abfaa9705eeb240b320..d3f12738907d6815c87be7c04a1a620300360543 100644 (file)
@@ -1041,6 +1041,7 @@ uint ospf_hello3_options(struct ospf_packet *pkt);
 /* 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);
 uint ospf_dbdes3_options(struct ospf_packet *pkt);