]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Fixes another bug in OSPFv3 vlinks.
authorOndrej Zajicek <santiago@crfreenet.org>
Wed, 31 Oct 2012 16:14:35 +0000 (17:14 +0100)
committerOndrej Zajicek <santiago@crfreenet.org>
Wed, 31 Oct 2012 16:14:35 +0000 (17:14 +0100)
proto/ospf/hello.c
proto/ospf/iface.c
proto/ospf/lsupd.c
proto/ospf/neighbor.c
proto/ospf/ospf.c
proto/ospf/ospf.h
proto/ospf/topology.c

index f9ba28f659665bb2f12a3ced76d6691e89e92297..6ec5c511bec88576247b00242584ef936af4d2b1 100644 (file)
@@ -261,7 +261,7 @@ ospf_hello_send(struct ospf_iface *ifa, int kind, struct ospf_neighbor *dirn)
   pkt->priority = ifa->priority;
 
 #ifdef OSPFv3
-  pkt->iface_id = htonl(ifa->iface->index);
+  pkt->iface_id = htonl(ifa->iface_id);
 
   pkt->options3 = ifa->oa->options >> 16;
   pkt->options2 = ifa->oa->options >> 8;
index a6a0c6c11efa7ddf5e8e96d22d12440460ba31ff..aa7f7892726daa4b18bb6cf08de9cadbe96d70d8 100644 (file)
@@ -567,6 +567,8 @@ ospf_iface_new(struct ospf_area *oa, struct ifa *addr, struct ospf_iface_patt *i
     log(L_WARN "%s: Cannot use interface %s as %s, forcing %s",
        p->name, iface->name, ospf_it[old_type], ospf_it[ifa->type]);
 
+  /* Assign iface ID, for vlinks, this is ugly hack */
+  ifa->iface_id = (ifa->type != OSPF_IT_VLINK) ? iface->index : oa->po->last_vlink_id++;
 
   init_list(&ifa->neigh_list);
   init_list(&ifa->nbma_list);
index 633ed53336a806184e2e34af2cf63c03ed18d047..a5da4251dae7ab7988ec60e3364f062c6db7c654 100644 (file)
@@ -123,7 +123,7 @@ ospf_lsa_flooding_allowed(struct ospf_lsa_header *lsa, u32 domain, struct ospf_i
   switch (scope)
     {
     case LSA_SCOPE_LINK:
-      return ifa->iface->index == domain;
+      return ifa->iface_id == domain;
 
     case LSA_SCOPE_AREA:
       return ifa->oa->areaid == domain;
index 642365b35a7c8484834c4a85609b99cbc68e2620..26d81dcebf86b8fce22c3a7af63035fd1c9ab5db 100644 (file)
@@ -459,7 +459,7 @@ bdr_election(struct ospf_iface *ifa)
 #else /* OSPFv3 */
   me.dr = ifa->drid;
   me.bdr = ifa->bdrid;
-  me.iface_id = ifa->iface->index;
+  me.iface_id = ifa->iface_id;
 #endif
 
   add_tail(&ifa->neigh_list, NODE & me);
index 5792453d92a7fd077036f878638bf5a108cd90ad..6654e107cbd09226362031c27322cd7e9c0223a5 100644 (file)
@@ -232,6 +232,7 @@ ospf_start(struct proto *p)
   struct ospf_area_config *ac;
 
   po->router_id = proto_get_router_id(p->cf);
+  po->last_vlink_id = 0x80000000;
   po->rfc1583 = c->rfc1583;
   po->ebit = 0;
   po->ecmp = c->ecmp;
index 3bffaf91c435b79ca69abdd08eafbcd10d781171..7111a13dfdeecfdd0673d455d78572a68a8d8f3a 100644 (file)
@@ -189,7 +189,8 @@ struct ospf_iface
   u32 rxmtint;                 /* number of seconds between LSA retransmissions */
   u32 pollint;                 /* Poll interval */
   u32 deadint;                 /* after "deadint" missing hellos is router dead */
-  u32 vid;                     /* Id of peer of virtual link */
+  u32 iface_id;                        /* Interface ID (iface->index or new value for vlinks) */
+  u32 vid;                     /* ID of peer of virtual link */
   ip_addr vip;                 /* IP of peer of virtual link */
   struct ospf_iface *vifa;     /* OSPF iface which the vlink goes through */
   struct ospf_area *voa;       /* OSPF area which the vlink goes through */
@@ -776,6 +777,7 @@ struct proto_ospf
   int lsab_size, lsab_used;
   linpool *nhpool;             /* Linpool used for next hops computed in SPF */
   u32 router_id;
+  u32 last_vlink_id;           /* Interface IDs for vlinks (starts at 0x80000000) */
 };
 
 struct ospf_iface_patt
index a9be12ee19a30b2aa38f5e84034231aa7a537da0..177cd53ac0499e5446e428f6dc31c6fa6bde17d5 100644 (file)
@@ -259,7 +259,7 @@ originate_rt_lsa_body(struct ospf_area *oa, u16 *length)
            ln->type = LSART_PTP;
            ln->id = neigh->rid;
            ln->data = (ifa->addr->flags & IA_PEER) ?
-             ifa->iface->index : ipa_to_u32(ifa->addr->ip);
+             ifa->iface_id : ipa_to_u32(ifa->addr->ip);
            ln->metric = ifa->cost;
            ln->padding = 0;
            i++;
@@ -368,7 +368,7 @@ add_lsa_rt_link(struct proto_ospf *po, struct ospf_iface *ifa, u8 type, u32 nif,
   ln->type = type;
   ln->padding = 0;
   ln->metric = ifa->cost;
-  ln->lif = ifa->iface->index;
+  ln->lif = ifa->iface_id;
   ln->nif = nif;
   ln->id = id;
 }
@@ -546,7 +546,7 @@ originate_net_lsa_body(struct ospf_iface *ifa, u16 *length,
     if (n->state == NEIGHBOR_FULL)
     {
 #ifdef OSPFv3
-      en = ospf_hash_find(po->gr, ifa->iface->index, n->iface_id, n->rid, LSA_T_LINK);
+      en = ospf_hash_find(po->gr, ifa->iface_id, n->iface_id, n->rid, LSA_T_LINK);
       if (en)
        options |= ((struct ospf_lsa_link *) en->lsa_body)->options;
 #endif
@@ -596,7 +596,7 @@ originate_net_lsa(struct ospf_iface *ifa)
   lsa.options = ifa->oa->options;
   lsa.id = ipa_to_u32(ifa->addr->ip);
 #else /* OSPFv3 */
-  lsa.id = ifa->iface->index;
+  lsa.id = ifa->iface_id;
 #endif
 
   lsa.rt = po->router_id;
@@ -1207,10 +1207,10 @@ originate_link_lsa(struct ospf_iface *ifa)
 
   lsa.age = 0;
   lsa.type = LSA_T_LINK;
-  lsa.id = ifa->iface->index;
+  lsa.id = ifa->iface_id;
   lsa.rt = po->router_id;
   lsa.sn = get_seqnum(ifa->link_lsa);
-  u32 dom = ifa->iface->index;
+  u32 dom = ifa->iface_id;
 
   body = originate_link_lsa_body(ifa, &lsa.length);
   lsasum_calculate(&lsa, body);
@@ -1471,7 +1471,7 @@ originate_prefix_net_lsa_body(struct ospf_iface *ifa, u16 *length)
 
   WALK_LIST(n, ifa->neigh_list)
     if ((n->state == NEIGHBOR_FULL) &&
-       (en = ospf_hash_find(po->gr, ifa->iface->index, n->iface_id, n->rid, LSA_T_LINK)))
+       (en = ospf_hash_find(po->gr, ifa->iface_id, n->iface_id, n->rid, LSA_T_LINK)))
       add_link_lsa(po, en, offset, &pxc);
 
   lp = po->lsab;
@@ -1493,7 +1493,7 @@ originate_prefix_net_lsa(struct ospf_iface *ifa)
 
   lsa.age = 0;
   lsa.type = LSA_T_PREFIX;
-  lsa.id = ifa->iface->index;
+  lsa.id = ifa->iface_id;
   lsa.rt = po->router_id;
   lsa.sn = get_seqnum(ifa->pxn_lsa);
   u32 dom = ifa->oa->areaid;
@@ -1664,7 +1664,7 @@ ospf_lsa_domain(u32 type, struct ospf_iface *ifa)
   switch (type & LSA_SCOPE_MASK)
     {
     case LSA_SCOPE_LINK:
-      return ifa->iface->index;
+      return ifa->iface_id;
 
     case LSA_SCOPE_AREA:
       return ifa->oa->areaid;