Diff for /embedaddon/quagga/ospfd/ospf_lsa.c between versions 1.1.1.3.2.1 and 1.1.1.4

version 1.1.1.3.2.1, 2013/07/22 00:08:32 version 1.1.1.4, 2016/11/02 10:09:12
Line 50 Line 50
 #include "ospfd/ospf_ase.h"  #include "ospfd/ospf_ase.h"
 #include "ospfd/ospf_zebra.h"  #include "ospfd/ospf_zebra.h"
   
 u_int32_t  u_int32_t
 get_metric (u_char *metric)  get_metric (u_char *metric)
 {  {
Line 61  get_metric (u_char *metric) Line 61  get_metric (u_char *metric)
   return m;    return m;
 }  }
   
 struct timeval  struct timeval
 tv_adjust (struct timeval a)  tv_adjust (struct timeval a)
 {  {
Line 108  int2tv (int a) Line 108  int2tv (int a)
 }  }
   
 struct timeval  struct timeval
   msec2tv (int a)
   {
     struct timeval ret;
   
     ret.tv_sec = 0;
     ret.tv_usec = a * 1000;
   
     return tv_adjust (ret);
   }
   
   struct timeval
 tv_add (struct timeval a, struct timeval b)  tv_add (struct timeval a, struct timeval b)
 {  {
   struct timeval ret;    struct timeval ret;
Line 145  ospf_lsa_refresh_delay (struct ospf_lsa *lsa) Line 156  ospf_lsa_refresh_delay (struct ospf_lsa *lsa)
   quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);    quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
   delta = tv_sub (now, lsa->tv_orig);    delta = tv_sub (now, lsa->tv_orig);
   
  if (tv_cmp (delta, int2tv (OSPF_MIN_LS_INTERVAL)) < 0)  if (tv_cmp (delta, msec2tv (OSPF_MIN_LS_INTERVAL)) < 0)
     {      {
      delay = tv_ceil (tv_sub (int2tv (OSPF_MIN_LS_INTERVAL), delta));      delay = tv_ceil (tv_sub (msec2tv (OSPF_MIN_LS_INTERVAL), delta));
   
       if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))        if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
         zlog_debug ("LSA[Type%d:%s]: Refresh timer delay %d seconds",          zlog_debug ("LSA[Type%d:%s]: Refresh timer delay %d seconds",
Line 159  ospf_lsa_refresh_delay (struct ospf_lsa *lsa) Line 170  ospf_lsa_refresh_delay (struct ospf_lsa *lsa)
   return delay;    return delay;
 }  }
   
 int  int
 get_age (struct ospf_lsa *lsa)  get_age (struct ospf_lsa *lsa)
 {  {
Line 171  get_age (struct ospf_lsa *lsa) Line 182  get_age (struct ospf_lsa *lsa)
   return age;    return age;
 }  }
   
 /* Fletcher Checksum -- Refer to RFC1008. */  /* Fletcher Checksum -- Refer to RFC1008. */
   
 /* All the offsets are zero-based. The offsets in the RFC1008 are   /* All the offsets are zero-based. The offsets in the RFC1008 are 
Line 205  ospf_lsa_checksum_valid (struct lsa_header *lsa) Line 216  ospf_lsa_checksum_valid (struct lsa_header *lsa)
 }  }
   
   
 /* Create OSPF LSA. */  /* Create OSPF LSA. */
 struct ospf_lsa *  struct ospf_lsa *
 ospf_lsa_new ()  ospf_lsa_new ()
Line 248  ospf_lsa_dup (struct ospf_lsa *lsa) Line 259  ospf_lsa_dup (struct ospf_lsa *lsa)
   new->refresh_list = -1;    new->refresh_list = -1;
   
   if (IS_DEBUG_OSPF (lsa, LSA))    if (IS_DEBUG_OSPF (lsa, LSA))
    zlog_debug ("LSA: duplicated %p (new: %p)", lsa, new);    zlog_debug ("LSA: duplicated %p (new: %p)", (void *)lsa, (void *)new);
   
   return new;    return new;
 }  }
Line 260  ospf_lsa_free (struct ospf_lsa *lsa) Line 271  ospf_lsa_free (struct ospf_lsa *lsa)
   assert (lsa->lock == 0);    assert (lsa->lock == 0);
       
   if (IS_DEBUG_OSPF (lsa, LSA))    if (IS_DEBUG_OSPF (lsa, LSA))
    zlog_debug ("LSA: freed %p", lsa);    zlog_debug ("LSA: freed %p", (void *)lsa);
   
   /* Delete LSA data. */    /* Delete LSA data. */
   if (lsa->data != NULL)    if (lsa->data != NULL)
Line 336  ospf_lsa_data_free (struct lsa_header *lsah) Line 347  ospf_lsa_data_free (struct lsa_header *lsah)
 {  {
   if (IS_DEBUG_OSPF (lsa, LSA))    if (IS_DEBUG_OSPF (lsa, LSA))
     zlog_debug ("LSA[Type%d:%s]: data freed %p",      zlog_debug ("LSA[Type%d:%s]: data freed %p",
               lsah->type, inet_ntoa (lsah->id), lsah);               lsah->type, inet_ntoa (lsah->id), (void *)lsah);
   
   XFREE (MTYPE_OSPF_LSA_DATA, lsah);    XFREE (MTYPE_OSPF_LSA_DATA, lsah);
 }  }
   
 /* LSA general functions. */  /* LSA general functions. */
   
 const char *  const char *
Line 393  lsa_header_set (struct stream *s, u_char options, Line 404  lsa_header_set (struct stream *s, u_char options,
   
   stream_forward_endp (s, OSPF_LSA_HEADER_SIZE);    stream_forward_endp (s, OSPF_LSA_HEADER_SIZE);
 }  }
   
   
   
 /* router-LSA related functions. */  /* router-LSA related functions. */
 /* Get router-LSA flags. */  /* Get router-LSA flags. */
 static u_char  static u_char
Line 568  lsa_link_broadcast_set (struct stream *s, struct ospf_ Line 579  lsa_link_broadcast_set (struct stream *s, struct ospf_
   /* Describe Type 3 Link. */    /* Describe Type 3 Link. */
   if (oi->state == ISM_Waiting)    if (oi->state == ISM_Waiting)
     {      {
         if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
           zlog_debug ("LSA[Type1]: Interface %s is in state Waiting. "
                       "Adding stub interface", oi->ifp->name);
       masklen2ip (oi->address->prefixlen, &mask);        masklen2ip (oi->address->prefixlen, &mask);
       id.s_addr = oi->address->u.prefix4.s_addr & mask.s_addr;        id.s_addr = oi->address->u.prefix4.s_addr & mask.s_addr;
       return link_info_set (s, id, mask, LSA_LINK_TYPE_STUB, 0,        return link_info_set (s, id, mask, LSA_LINK_TYPE_STUB, 0,
Line 580  lsa_link_broadcast_set (struct stream *s, struct ospf_ Line 594  lsa_link_broadcast_set (struct stream *s, struct ospf_
              IPV4_ADDR_SAME (&oi->address->u.prefix4, &DR (oi))) &&               IPV4_ADDR_SAME (&oi->address->u.prefix4, &DR (oi))) &&
       ospf_nbr_count (oi, NSM_Full) > 0)        ospf_nbr_count (oi, NSM_Full) > 0)
     {      {
         if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
           zlog_debug ("LSA[Type1]: Interface %s has a DR. "
                       "Adding transit interface", oi->ifp->name);
       return link_info_set (s, DR (oi), oi->address->u.prefix4,        return link_info_set (s, DR (oi), oi->address->u.prefix4,
                             LSA_LINK_TYPE_TRANSIT, 0, cost);                              LSA_LINK_TYPE_TRANSIT, 0, cost);
     }      }
   /* Describe type 3 link. */    /* Describe type 3 link. */
   else    else
     {      {
         if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
           zlog_debug ("LSA[Type1]: Interface %s has no DR. "
                       "Adding stub interface", oi->ifp->name);
       masklen2ip (oi->address->prefixlen, &mask);        masklen2ip (oi->address->prefixlen, &mask);
       id.s_addr = oi->address->u.prefix4.s_addr & mask.s_addr;        id.s_addr = oi->address->u.prefix4.s_addr & mask.s_addr;
       return link_info_set (s, id, mask, LSA_LINK_TYPE_STUB, 0,        return link_info_set (s, id, mask, LSA_LINK_TYPE_STUB, 0,
Line 737  ospf_router_lsa_body_set (struct stream *s, struct osp Line 757  ospf_router_lsa_body_set (struct stream *s, struct osp
   /* Set # of links here. */    /* Set # of links here. */
   stream_putw_at (s, putp, cnt);    stream_putw_at (s, putp, cnt);
 }  }
 static int  static int
 ospf_stub_router_timer (struct thread *t)  ospf_stub_router_timer (struct thread *t)
 {  {
Line 794  ospf_stub_router_check (struct ospf_area *area) Line 814  ospf_stub_router_check (struct ospf_area *area)
   OSPF_AREA_TIMER_ON (area->t_stub_router, ospf_stub_router_timer,    OSPF_AREA_TIMER_ON (area->t_stub_router, ospf_stub_router_timer,
                       area->ospf->stub_router_startup_time);                        area->ospf->stub_router_startup_time);
 }  }
  
 /* Create new router-LSA. */  /* Create new router-LSA. */
 static struct ospf_lsa *  static struct ospf_lsa *
 ospf_router_lsa_new (struct ospf_area *area)  ospf_router_lsa_new (struct ospf_area *area)
Line 879  ospf_router_lsa_originate (struct ospf_area *area) Line 899  ospf_router_lsa_originate (struct ospf_area *area)
   if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))    if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
     {      {
       zlog_debug ("LSA[Type%d:%s]: Originate router-LSA %p",        zlog_debug ("LSA[Type%d:%s]: Originate router-LSA %p",
                 new->data->type, inet_ntoa (new->data->id), new);                 new->data->type, inet_ntoa (new->data->id), (void *)new);
       ospf_lsa_header_dump (new->data);        ospf_lsa_header_dump (new->data);
     }      }
   
Line 996  ospf_router_lsa_update (struct ospf *ospf) Line 1016  ospf_router_lsa_update (struct ospf *ospf)
   return 0;    return 0;
 }  }
   
 /* network-LSA related functions. */  /* network-LSA related functions. */
 /* Originate Network-LSA. */  /* Originate Network-LSA. */
 static void  static void
Line 1114  ospf_network_lsa_update (struct ospf_interface *oi) Line 1134  ospf_network_lsa_update (struct ospf_interface *oi)
   if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))    if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
     {      {
       zlog_debug ("LSA[Type%d:%s]: Originate network-LSA %p",        zlog_debug ("LSA[Type%d:%s]: Originate network-LSA %p",
                 new->data->type, inet_ntoa (new->data->id), new);                 new->data->type, inet_ntoa (new->data->id), (void *)new);
       ospf_lsa_header_dump (new->data);        ospf_lsa_header_dump (new->data);
     }      }
   
Line 1175  ospf_network_lsa_refresh (struct ospf_lsa *lsa) Line 1195  ospf_network_lsa_refresh (struct ospf_lsa *lsa)
   
   return new;    return new;
 }  }
 static void  static void
 stream_put_ospf_metric (struct stream *s, u_int32_t metric_value)  stream_put_ospf_metric (struct stream *s, u_int32_t metric_value)
 {  {
Line 1291  ospf_summary_lsa_originate (struct prefix_ipv4 *p, u_i Line 1311  ospf_summary_lsa_originate (struct prefix_ipv4 *p, u_i
   if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))    if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
     {      {
       zlog_debug ("LSA[Type%d:%s]: Originate summary-LSA %p",        zlog_debug ("LSA[Type%d:%s]: Originate summary-LSA %p",
                 new->data->type, inet_ntoa (new->data->id), new);                 new->data->type, inet_ntoa (new->data->id), (void *)new);
       ospf_lsa_header_dump (new->data);        ospf_lsa_header_dump (new->data);
     }      }
   
Line 1334  ospf_summary_lsa_refresh (struct ospf *ospf, struct os Line 1354  ospf_summary_lsa_refresh (struct ospf *ospf, struct os
   return new;    return new;
 }  }
   
 /* summary-ASBR-LSA related functions. */  /* summary-ASBR-LSA related functions. */
 static void  static void
 ospf_summary_asbr_lsa_body_set (struct stream *s, struct prefix *p,  ospf_summary_asbr_lsa_body_set (struct stream *s, struct prefix *p,
Line 1434  ospf_summary_asbr_lsa_originate (struct prefix_ipv4 *p Line 1454  ospf_summary_asbr_lsa_originate (struct prefix_ipv4 *p
   if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))    if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
     {      {
       zlog_debug ("LSA[Type%d:%s]: Originate summary-ASBR-LSA %p",        zlog_debug ("LSA[Type%d:%s]: Originate summary-ASBR-LSA %p",
                 new->data->type, inet_ntoa (new->data->id), new);                 new->data->type, inet_ntoa (new->data->id), (void *)new);
       ospf_lsa_header_dump (new->data);        ospf_lsa_header_dump (new->data);
     }      }
   
Line 2067  ospf_external_lsa_originate (struct ospf *ospf, struct Line 2087  ospf_external_lsa_originate (struct ospf *ospf, struct
   if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))    if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
     {      {
       zlog_debug ("LSA[Type%d:%s]: Originate AS-external-LSA %p",        zlog_debug ("LSA[Type%d:%s]: Originate AS-external-LSA %p",
                 new->data->type, inet_ntoa (new->data->id), new);                 new->data->type, inet_ntoa (new->data->id), (void *)new);
       ospf_lsa_header_dump (new->data);        ospf_lsa_header_dump (new->data);
     }      }
   
Line 2187  ospf_nssa_lsa_flush (struct ospf *ospf, struct prefix_ Line 2207  ospf_nssa_lsa_flush (struct ospf *ospf, struct prefix_
 void  void
 ospf_external_lsa_flush (struct ospf *ospf,  ospf_external_lsa_flush (struct ospf *ospf,
                          u_char type, struct prefix_ipv4 *p,                           u_char type, struct prefix_ipv4 *p,
                         unsigned int ifindex /*, struct in_addr nexthop */)                         ifindex_t ifindex /*, struct in_addr nexthop */)
 {  {
   struct ospf_lsa *lsa;    struct ospf_lsa *lsa;
   
Line 2252  ospf_external_lsa_refresh_default (struct ospf *ospf) Line 2272  ospf_external_lsa_refresh_default (struct ospf *ospf)
       if (lsa)        if (lsa)
         {          {
           if (IS_DEBUG_OSPF_EVENT)            if (IS_DEBUG_OSPF_EVENT)
            zlog_debug ("LSA[Type5:0.0.0.0]: Refresh AS-external-LSA %p", lsa);            zlog_debug ("LSA[Type5:0.0.0.0]: Refresh AS-external-LSA %p",
                        (void *)lsa);
           ospf_external_lsa_refresh (ospf, lsa, ei, LSA_REFRESH_FORCE);            ospf_external_lsa_refresh (ospf, lsa, ei, LSA_REFRESH_FORCE);
         }          }
       else        else
Line 2369  ospf_external_lsa_refresh (struct ospf *ospf, struct o Line 2390  ospf_external_lsa_refresh (struct ospf *ospf, struct o
   return new;    return new;
 }  }
   
 /* LSA installation functions. */  /* LSA installation functions. */
   
 /* Install router-LSA to an area. */  /* Install router-LSA to an area. */
Line 2401  ospf_router_lsa_install (struct ospf *ospf, struct osp Line 2422  ospf_router_lsa_install (struct ospf *ospf, struct osp
       ospf_refresher_register_lsa (ospf, new);        ospf_refresher_register_lsa (ospf, new);
     }      }
   if (rt_recalc)    if (rt_recalc)
    ospf_spf_calculate_schedule (ospf);    ospf_spf_calculate_schedule (ospf, SPF_FLAG_ROUTER_LSA_INSTALL);
 
   return new;    return new;
 }  }
   
Line 2436  ospf_network_lsa_install (struct ospf *ospf, Line 2456  ospf_network_lsa_install (struct ospf *ospf,
       ospf_refresher_register_lsa (ospf, new);        ospf_refresher_register_lsa (ospf, new);
     }      }
   if (rt_recalc)    if (rt_recalc)
    ospf_spf_calculate_schedule (ospf);    ospf_spf_calculate_schedule (ospf, SPF_FLAG_NETWORK_LSA_INSTALL);
   
   return new;    return new;
 }  }
Line 2459  ospf_summary_lsa_install (struct ospf *ospf, struct os Line 2479  ospf_summary_lsa_install (struct ospf *ospf, struct os
       /* This doesn't exist yet... */        /* This doesn't exist yet... */
       ospf_summary_incremental_update(new); */        ospf_summary_incremental_update(new); */
 #else /* #if 0 */  #else /* #if 0 */
      ospf_spf_calculate_schedule (ospf);      ospf_spf_calculate_schedule (ospf, SPF_FLAG_SUMMARY_LSA_INSTALL);
 #endif /* #if 0 */  #endif /* #if 0 */
     
       if (IS_DEBUG_OSPF (lsa, LSA_INSTALL))  
         zlog_debug ("ospf_summary_lsa_install(): SPF scheduled");  
     }      }
   
   if (IS_LSA_SELF (new))    if (IS_LSA_SELF (new))
Line 2492  ospf_summary_asbr_lsa_install (struct ospf *ospf, stru Line 2510  ospf_summary_asbr_lsa_install (struct ospf *ospf, stru
          - RFC 2328 Section 16.5 implies it should be */           - RFC 2328 Section 16.5 implies it should be */
       /* ospf_ase_calculate_schedule(); */        /* ospf_ase_calculate_schedule(); */
 #else  /* #if 0 */  #else  /* #if 0 */
      ospf_spf_calculate_schedule (ospf);      ospf_spf_calculate_schedule (ospf, SPF_FLAG_ASBR_SUMMARY_LSA_INSTALL);
 #endif /* #if 0 */  #endif /* #if 0 */
     }      }
   
Line 2577  ospf_discard_from_db (struct ospf *ospf, Line 2595  ospf_discard_from_db (struct ospf *ospf,
       ospf_ase_unregister_external_lsa (old, ospf);        ospf_ase_unregister_external_lsa (old, ospf);
       ospf_ls_retransmit_delete_nbr_as (ospf, old);        ospf_ls_retransmit_delete_nbr_as (ospf, old);
       break;        break;
 #ifdef HAVE_OPAQUE_LSA  
     case OSPF_OPAQUE_AS_LSA:      case OSPF_OPAQUE_AS_LSA:
       ospf_ls_retransmit_delete_nbr_as (ospf, old);        ospf_ls_retransmit_delete_nbr_as (ospf, old);
       break;        break;
 #endif /* HAVE_OPAQUE_LSA */  
     case OSPF_AS_NSSA_LSA:      case OSPF_AS_NSSA_LSA:
       ospf_ls_retransmit_delete_nbr_area (old->area, old);        ospf_ls_retransmit_delete_nbr_area (old->area, old);
       ospf_ase_unregister_external_lsa (old, ospf);        ospf_ase_unregister_external_lsa (old, ospf);
Line 2615  ospf_lsa_install (struct ospf *ospf, struct ospf_inter Line 2631  ospf_lsa_install (struct ospf *ospf, struct ospf_inter
         lsdb = ospf->lsdb;          lsdb = ospf->lsdb;
       break;        break;
     case OSPF_AS_EXTERNAL_LSA:      case OSPF_AS_EXTERNAL_LSA:
 #ifdef HAVE_OPAQUE_LSA  
     case OSPF_OPAQUE_AS_LSA:      case OSPF_OPAQUE_AS_LSA:
 #endif /* HAVE_OPAQUE_LSA */  
       lsdb = ospf->lsdb;        lsdb = ospf->lsdb;
       break;        break;
     default:      default:
Line 2682  ospf_lsa_install (struct ospf *ospf, struct ospf_inter Line 2696  ospf_lsa_install (struct ospf *ospf, struct ospf_inter
             {              {
               zlog_debug ("ospf_lsa_install() Premature Aging "                zlog_debug ("ospf_lsa_install() Premature Aging "
                          "lsa 0x%p, seqnum 0x%x",                           "lsa 0x%p, seqnum 0x%x",
                         lsa, ntohl(lsa->data->ls_seqnum));                         (void *)lsa, ntohl(lsa->data->ls_seqnum));
               ospf_lsa_header_dump (lsa->data);                ospf_lsa_header_dump (lsa->data);
             }              }
         }          }
Line 2729  ospf_lsa_install (struct ospf *ospf, struct ospf_inter Line 2743  ospf_lsa_install (struct ospf *ospf, struct ospf_inter
     case OSPF_AS_EXTERNAL_LSA:      case OSPF_AS_EXTERNAL_LSA:
       new = ospf_external_lsa_install (ospf, lsa, rt_recalc);        new = ospf_external_lsa_install (ospf, lsa, rt_recalc);
       break;        break;
 #ifdef HAVE_OPAQUE_LSA  
     case OSPF_OPAQUE_LINK_LSA:      case OSPF_OPAQUE_LINK_LSA:
       if (IS_LSA_SELF (lsa))        if (IS_LSA_SELF (lsa))
         lsa->oi = oi; /* Specify outgoing ospf-interface for this LSA. */          lsa->oi = oi; /* Specify outgoing ospf-interface for this LSA. */
Line 2742  ospf_lsa_install (struct ospf *ospf, struct ospf_inter Line 2755  ospf_lsa_install (struct ospf *ospf, struct ospf_inter
     case OSPF_OPAQUE_AS_LSA:      case OSPF_OPAQUE_AS_LSA:
       new = ospf_opaque_lsa_install (lsa, rt_recalc);        new = ospf_opaque_lsa_install (lsa, rt_recalc);
       break;        break;
 #endif /* HAVE_OPAQUE_LSA */  
     case OSPF_AS_NSSA_LSA:      case OSPF_AS_NSSA_LSA:
       new = ospf_external_lsa_install (ospf, lsa, rt_recalc);        new = ospf_external_lsa_install (ospf, lsa, rt_recalc);
     default: /* type-6,8,9....nothing special */      default: /* type-6,8,9....nothing special */
Line 2760  ospf_lsa_install (struct ospf *ospf, struct ospf_inter Line 2772  ospf_lsa_install (struct ospf *ospf, struct ospf_inter
       switch (lsa->data->type)        switch (lsa->data->type)
         {          {
         case OSPF_AS_EXTERNAL_LSA:          case OSPF_AS_EXTERNAL_LSA:
 #ifdef HAVE_OPAQUE_LSA  
         case OSPF_OPAQUE_AS_LSA:          case OSPF_OPAQUE_AS_LSA:
 #endif /* HAVE_OPAQUE_LSA */  
         case OSPF_AS_NSSA_LSA:          case OSPF_AS_NSSA_LSA:
           zlog_debug ("LSA[%s]: Install %s",            zlog_debug ("LSA[%s]: Install %s",
                  dump_lsa_key (new),                   dump_lsa_key (new),
Line 2785  ospf_lsa_install (struct ospf *ospf, struct ospf_inter Line 2795  ospf_lsa_install (struct ospf *ospf, struct ospf_inter
     {      {
       if (IS_DEBUG_OSPF (lsa, LSA_INSTALL))        if (IS_DEBUG_OSPF (lsa, LSA_INSTALL))
         zlog_debug ("LSA[Type%d:%s]: Install LSA 0x%p, MaxAge",          zlog_debug ("LSA[Type%d:%s]: Install LSA 0x%p, MaxAge",
                   new->data->type,                    new->data->type,
                   inet_ntoa (new->data->id),                    inet_ntoa (new->data->id),
                   lsa);                   (void *)lsa);
       ospf_lsa_maxage (ospf, lsa);        ospf_lsa_maxage (ospf, lsa);
     }      }
   
   return new;    return new;
 }  }
   
static intint
 ospf_check_nbr_status (struct ospf *ospf)  ospf_check_nbr_status (struct ospf *ospf)
 {  {
   struct listnode *node, *nnode;    struct listnode *node, *nnode;
Line 2819  ospf_check_nbr_status (struct ospf *ospf) Line 2829  ospf_check_nbr_status (struct ospf *ospf)
   return 1;    return 1;
 }  }
   
   
   
   
 static int  static int
 ospf_maxage_lsa_remover (struct thread *thread)  ospf_maxage_lsa_remover (struct thread *thread)
 {  {
Line 2844  ospf_maxage_lsa_remover (struct thread *thread) Line 2854  ospf_maxage_lsa_remover (struct thread *thread)
             continue;              continue;
           }            }
   
           /* There is at least one neighbor from which we still await an ack
            * for that LSA, so we are not allowed to remove it from our lsdb yet
            * as per RFC 2328 section 14 para 4 a) */
         if (lsa->retransmit_counter > 0)          if (lsa->retransmit_counter > 0)
           {            {
             reschedule = 1;              reschedule = 1;
Line 2852  ospf_maxage_lsa_remover (struct thread *thread) Line 2865  ospf_maxage_lsa_remover (struct thread *thread)
                   
         /* TODO: maybe convert this function to a work-queue */          /* TODO: maybe convert this function to a work-queue */
         if (thread_should_yield (thread))          if (thread_should_yield (thread))
          OSPF_TIMER_ON (ospf->t_maxage, ospf_maxage_lsa_remover, 0);          {
             OSPF_TIMER_ON (ospf->t_maxage, ospf_maxage_lsa_remover, 0);
             route_unlock_node(rn); /* route_top/route_next */
             return 0;
           }
                       
         /* Remove LSA from the LSDB */          /* Remove LSA from the LSDB */
         if (IS_LSA_SELF (lsa))          if (IS_LSA_SELF (lsa))
Line 2867  ospf_maxage_lsa_remover (struct thread *thread) Line 2884  ospf_maxage_lsa_remover (struct thread *thread)
         if (CHECK_FLAG (lsa->flags, OSPF_LSA_PREMATURE_AGE))          if (CHECK_FLAG (lsa->flags, OSPF_LSA_PREMATURE_AGE))
           {            {
             if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))              if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
              zlog_debug ("originating new lsa for lsa 0x%p\n", lsa);              zlog_debug ("originating new lsa for lsa 0x%p\n", (void *)lsa);
             ospf_lsa_refresh (ospf, lsa);              ospf_lsa_refresh (ospf, lsa);
           }            }
   
Line 2897  void Line 2914  void
 ospf_lsa_maxage_delete (struct ospf *ospf, struct ospf_lsa *lsa)  ospf_lsa_maxage_delete (struct ospf *ospf, struct ospf_lsa *lsa)
 {  {
   struct route_node *rn;    struct route_node *rn;
  struct prefix_ls lsa_prefix;  struct prefix_ptr lsa_prefix;
   
  ls_prefix_set (&lsa_prefix, lsa);  lsa_prefix.family = 0;
   lsa_prefix.prefixlen = sizeof(lsa_prefix.prefix) * CHAR_BIT;
   lsa_prefix.prefix = (uintptr_t) lsa;
   
   if ((rn = route_node_lookup(ospf->maxage_lsa,    if ((rn = route_node_lookup(ospf->maxage_lsa,
                               (struct prefix *)&lsa_prefix)))                                (struct prefix *)&lsa_prefix)))
Line 2909  ospf_lsa_maxage_delete (struct ospf *ospf, struct ospf Line 2928  ospf_lsa_maxage_delete (struct ospf *ospf, struct ospf
           UNSET_FLAG(lsa->flags, OSPF_LSA_IN_MAXAGE);            UNSET_FLAG(lsa->flags, OSPF_LSA_IN_MAXAGE);
           ospf_lsa_unlock (&lsa); /* maxage_lsa */            ospf_lsa_unlock (&lsa); /* maxage_lsa */
           rn->info = NULL;            rn->info = NULL;
          route_unlock_node (rn); /* route_node_lookup */          route_unlock_node (rn); /* unlock node because lsa is deleted */
         }          }
          route_unlock_node (rn); /* route_node_lookup */      route_unlock_node (rn); /* route_node_lookup */
     }      }
 }  }
   
Line 2923  ospf_lsa_maxage_delete (struct ospf *ospf, struct ospf Line 2942  ospf_lsa_maxage_delete (struct ospf *ospf, struct ospf
 void  void
 ospf_lsa_maxage (struct ospf *ospf, struct ospf_lsa *lsa)  ospf_lsa_maxage (struct ospf *ospf, struct ospf_lsa *lsa)
 {  {
  struct prefix_ls lsa_prefix;  struct prefix_ptr lsa_prefix;
   struct route_node *rn;    struct route_node *rn;
   
   /* When we saw a MaxAge LSA flooded to us, we put it on the list    /* When we saw a MaxAge LSA flooded to us, we put it on the list
Line 2932  ospf_lsa_maxage (struct ospf *ospf, struct ospf_lsa *l Line 2951  ospf_lsa_maxage (struct ospf *ospf, struct ospf_lsa *l
     {      {
       if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))        if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
         zlog_debug ("LSA[Type%d:%s]: %p already exists on MaxAge LSA list",          zlog_debug ("LSA[Type%d:%s]: %p already exists on MaxAge LSA list",
                   lsa->data->type, inet_ntoa (lsa->data->id), lsa);                   lsa->data->type, inet_ntoa (lsa->data->id), (void *)lsa);
       return;        return;
     }      }
   
  ls_prefix_set (&lsa_prefix, lsa);  lsa_prefix.family = 0;
   lsa_prefix.prefixlen = sizeof(lsa_prefix.prefix) * CHAR_BIT;
   lsa_prefix.prefix = (uintptr_t) lsa;
 
   if ((rn = route_node_get (ospf->maxage_lsa,    if ((rn = route_node_get (ospf->maxage_lsa,
                             (struct prefix *)&lsa_prefix)) != NULL)                              (struct prefix *)&lsa_prefix)) != NULL)
     {      {
       if (rn->info != NULL)        if (rn->info != NULL)
         {          {
             if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
               zlog_debug ("LSA[%s]: found LSA (%p) in table for LSA %p %d",
                           dump_lsa_key (lsa), rn->info, (void *)lsa,
                           lsa_prefix.prefixlen);
           route_unlock_node (rn);            route_unlock_node (rn);
         }          }
       else        else
Line 2980  ospf_lsa_maxage_walker_remover (struct ospf *ospf, str Line 3006  ospf_lsa_maxage_walker_remover (struct ospf *ospf, str
   
         switch (lsa->data->type)          switch (lsa->data->type)
           {            {
 #ifdef HAVE_OPAQUE_LSA  
           case OSPF_OPAQUE_LINK_LSA:            case OSPF_OPAQUE_LINK_LSA:
           case OSPF_OPAQUE_AREA_LSA:            case OSPF_OPAQUE_AREA_LSA:
           case OSPF_OPAQUE_AS_LSA:            case OSPF_OPAQUE_AS_LSA:
Line 2993  ospf_lsa_maxage_walker_remover (struct ospf *ospf, str Line 3018  ospf_lsa_maxage_walker_remover (struct ospf *ospf, str
              * topology, and thus, routing recalculation is not needed here.               * topology, and thus, routing recalculation is not needed here.
              */               */
             break;              break;
 #endif /* HAVE_OPAQUE_LSA */  
           case OSPF_AS_EXTERNAL_LSA:            case OSPF_AS_EXTERNAL_LSA:
           case OSPF_AS_NSSA_LSA:            case OSPF_AS_NSSA_LSA:
             ospf_ase_incremental_update (ospf, lsa);              ospf_ase_incremental_update (ospf, lsa);
             break;              break;
           default:            default:
            ospf_spf_calculate_schedule (ospf);            ospf_spf_calculate_schedule (ospf, SPF_FLAG_MAXAGE);
             break;              break;
           }            }
         ospf_lsa_maxage (ospf, lsa);          ospf_lsa_maxage (ospf, lsa);
Line 3034  ospf_lsa_maxage_walker (struct thread *thread) Line 3058  ospf_lsa_maxage_walker (struct thread *thread)
         ospf_lsa_maxage_walker_remover (ospf, lsa);          ospf_lsa_maxage_walker_remover (ospf, lsa);
       LSDB_LOOP (ASBR_SUMMARY_LSDB (area), rn, lsa)        LSDB_LOOP (ASBR_SUMMARY_LSDB (area), rn, lsa)
         ospf_lsa_maxage_walker_remover (ospf, lsa);          ospf_lsa_maxage_walker_remover (ospf, lsa);
 #ifdef HAVE_OPAQUE_LSA  
       LSDB_LOOP (OPAQUE_AREA_LSDB (area), rn, lsa)        LSDB_LOOP (OPAQUE_AREA_LSDB (area), rn, lsa)
         ospf_lsa_maxage_walker_remover (ospf, lsa);          ospf_lsa_maxage_walker_remover (ospf, lsa);
       LSDB_LOOP (OPAQUE_LINK_LSDB (area), rn, lsa)        LSDB_LOOP (OPAQUE_LINK_LSDB (area), rn, lsa)
         ospf_lsa_maxage_walker_remover (ospf, lsa);          ospf_lsa_maxage_walker_remover (ospf, lsa);
 #endif /* HAVE_OPAQUE_LSA */  
       LSDB_LOOP (NSSA_LSDB (area), rn, lsa)        LSDB_LOOP (NSSA_LSDB (area), rn, lsa)
         ospf_lsa_maxage_walker_remover (ospf, lsa);          ospf_lsa_maxage_walker_remover (ospf, lsa);
     }      }
Line 3049  ospf_lsa_maxage_walker (struct thread *thread) Line 3071  ospf_lsa_maxage_walker (struct thread *thread)
     {      {
       LSDB_LOOP (EXTERNAL_LSDB (ospf), rn, lsa)        LSDB_LOOP (EXTERNAL_LSDB (ospf), rn, lsa)
         ospf_lsa_maxage_walker_remover (ospf, lsa);          ospf_lsa_maxage_walker_remover (ospf, lsa);
 #ifdef HAVE_OPAQUE_LSA  
       LSDB_LOOP (OPAQUE_AS_LSDB (ospf), rn, lsa)        LSDB_LOOP (OPAQUE_AS_LSDB (ospf), rn, lsa)
         ospf_lsa_maxage_walker_remover (ospf, lsa);          ospf_lsa_maxage_walker_remover (ospf, lsa);
 #endif /* HAVE_OPAQUE_LSA */  
     }      }
   
   OSPF_TIMER_ON (ospf->t_maxage_walker, ospf_lsa_maxage_walker,    OSPF_TIMER_ON (ospf->t_maxage_walker, ospf_lsa_maxage_walker,
Line 3105  ospf_lsa_lookup (struct ospf_area *area, u_int32_t typ Line 3125  ospf_lsa_lookup (struct ospf_area *area, u_int32_t typ
     case OSPF_SUMMARY_LSA:      case OSPF_SUMMARY_LSA:
     case OSPF_ASBR_SUMMARY_LSA:      case OSPF_ASBR_SUMMARY_LSA:
     case OSPF_AS_NSSA_LSA:      case OSPF_AS_NSSA_LSA:
 #ifdef HAVE_OPAQUE_LSA  
     case OSPF_OPAQUE_LINK_LSA:      case OSPF_OPAQUE_LINK_LSA:
     case OSPF_OPAQUE_AREA_LSA:      case OSPF_OPAQUE_AREA_LSA:
 #endif /* HAVE_OPAQUE_LSA */  
       return ospf_lsdb_lookup_by_id (area->lsdb, type, id, adv_router);        return ospf_lsdb_lookup_by_id (area->lsdb, type, id, adv_router);
     case OSPF_AS_EXTERNAL_LSA:      case OSPF_AS_EXTERNAL_LSA:
 #ifdef HAVE_OPAQUE_LSA  
     case OSPF_OPAQUE_AS_LSA:      case OSPF_OPAQUE_AS_LSA:
 #endif /* HAVE_OPAQUE_LSA */  
       return ospf_lsdb_lookup_by_id (ospf->lsdb, type, id, adv_router);        return ospf_lsdb_lookup_by_id (ospf->lsdb, type, id, adv_router);
     default:      default:
       break;        break;
Line 3149  ospf_lsa_lookup_by_id (struct ospf_area *area, u_int32 Line 3165  ospf_lsa_lookup_by_id (struct ospf_area *area, u_int32
       return ospf_lsdb_lookup_by_id (area->lsdb, type, id, id);        return ospf_lsdb_lookup_by_id (area->lsdb, type, id, id);
     case OSPF_AS_EXTERNAL_LSA:      case OSPF_AS_EXTERNAL_LSA:
     case OSPF_AS_NSSA_LSA:      case OSPF_AS_NSSA_LSA:
 #ifdef HAVE_OPAQUE_LSA  
     case OSPF_OPAQUE_LINK_LSA:      case OSPF_OPAQUE_LINK_LSA:
     case OSPF_OPAQUE_AREA_LSA:      case OSPF_OPAQUE_AREA_LSA:
     case OSPF_OPAQUE_AS_LSA:      case OSPF_OPAQUE_AS_LSA:
       /* Currently not used. */        /* Currently not used. */
       break;        break;
 #endif /* HAVE_OPAQUE_LSA */  
     default:      default:
       break;        break;
     }      }
Line 3168  ospf_lsa_lookup_by_header (struct ospf_area *area, str Line 3182  ospf_lsa_lookup_by_header (struct ospf_area *area, str
 {  {
   struct ospf_lsa *match;    struct ospf_lsa *match;
   
 #ifdef HAVE_OPAQUE_LSA  
   /*    /*
    * Strictly speaking, the LSA-ID field for Opaque-LSAs (type-9/10/11)     * Strictly speaking, the LSA-ID field for Opaque-LSAs (type-9/10/11)
    * is redefined to have two subfields; opaque-type and opaque-id.     * is redefined to have two subfields; opaque-type and opaque-id.
    * However, it is harmless to treat the two sub fields together, as if     * However, it is harmless to treat the two sub fields together, as if
    * they two were forming a unique LSA-ID.     * they two were forming a unique LSA-ID.
    */     */
 #endif /* HAVE_OPAQUE_LSA */  
   
   match = ospf_lsa_lookup (area, lsah->type, lsah->id, lsah->adv_router);    match = ospf_lsa_lookup (area, lsah->type, lsah->id, lsah->adv_router);
   
Line 3326  ospf_lsa_flush_schedule (struct ospf *ospf, struct osp Line 3338  ospf_lsa_flush_schedule (struct ospf *ospf, struct osp
   
   switch (lsa->data->type)    switch (lsa->data->type)
     {      {
 #ifdef HAVE_OPAQUE_LSA  
     /* Opaque wants to be notified of flushes */      /* Opaque wants to be notified of flushes */
     case OSPF_OPAQUE_LINK_LSA:      case OSPF_OPAQUE_LINK_LSA:
     case OSPF_OPAQUE_AREA_LSA:      case OSPF_OPAQUE_AREA_LSA:
     case OSPF_OPAQUE_AS_LSA:      case OSPF_OPAQUE_AS_LSA:
       ospf_opaque_lsa_refresh (lsa);        ospf_opaque_lsa_refresh (lsa);
       break;        break;
 #endif /* HAVE_OPAQUE_LSA */  
     default:      default:
       ospf_refresher_unregister_lsa (ospf, lsa);        ospf_refresher_unregister_lsa (ospf, lsa);
       ospf_lsa_flush (ospf, lsa);        ospf_lsa_flush (ospf, lsa);
Line 3393  ospf_flush_self_originated_lsas_now (struct ospf *ospf Line 3403  ospf_flush_self_originated_lsas_now (struct ospf *ospf
         ospf_lsa_flush_schedule (ospf, lsa);          ospf_lsa_flush_schedule (ospf, lsa);
       LSDB_LOOP (ASBR_SUMMARY_LSDB (area), rn, lsa)        LSDB_LOOP (ASBR_SUMMARY_LSDB (area), rn, lsa)
         ospf_lsa_flush_schedule (ospf, lsa);          ospf_lsa_flush_schedule (ospf, lsa);
 #ifdef HAVE_OPAQUE_LSA  
       LSDB_LOOP (OPAQUE_LINK_LSDB (area), rn, lsa)        LSDB_LOOP (OPAQUE_LINK_LSDB (area), rn, lsa)
         ospf_lsa_flush_schedule (ospf, lsa);          ospf_lsa_flush_schedule (ospf, lsa);
       LSDB_LOOP (OPAQUE_AREA_LSDB (area), rn, lsa)        LSDB_LOOP (OPAQUE_AREA_LSDB (area), rn, lsa)
         ospf_lsa_flush_schedule (ospf, lsa);          ospf_lsa_flush_schedule (ospf, lsa);
 #endif /* HAVE_OPAQUE_LSA */  
     }      }
   
   if (need_to_flush_ase)    if (need_to_flush_ase)
     {      {
       LSDB_LOOP (EXTERNAL_LSDB (ospf), rn, lsa)        LSDB_LOOP (EXTERNAL_LSDB (ospf), rn, lsa)
         ospf_lsa_flush_schedule (ospf, lsa);          ospf_lsa_flush_schedule (ospf, lsa);
 #ifdef HAVE_OPAQUE_LSA  
       LSDB_LOOP (OPAQUE_AS_LSDB (ospf), rn, lsa)        LSDB_LOOP (OPAQUE_AS_LSDB (ospf), rn, lsa)
         ospf_lsa_flush_schedule (ospf, lsa);          ospf_lsa_flush_schedule (ospf, lsa);
 #endif /* HAVE_OPAQUE_LSA */  
     }      }
   
   /*    /*
Line 3516  ospf_lsa_unique_id (struct ospf *ospf, Line 3522  ospf_lsa_unique_id (struct ospf *ospf,
   return id;    return id;
 }  }
   
 #define LSA_ACTION_FLOOD_AREA 1  #define LSA_ACTION_FLOOD_AREA 1
 #define LSA_ACTION_FLUSH_AREA 2  #define LSA_ACTION_FLUSH_AREA 2
   
Line 3579  ospf_schedule_lsa_flush_area (struct ospf_area *area,  Line 3585  ospf_schedule_lsa_flush_area (struct ospf_area *area, 
   thread_add_event (master, ospf_lsa_action, data, 0);    thread_add_event (master, ospf_lsa_action, data, 0);
 }  }
   
 /* LSA Refreshment functions. */  /* LSA Refreshment functions. */
 struct ospf_lsa *  struct ospf_lsa *
 ospf_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa)  ospf_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa)
Line 3617  ospf_lsa_refresh (struct ospf *ospf, struct ospf_lsa * Line 3623  ospf_lsa_refresh (struct ospf *ospf, struct ospf_lsa *
       else        else
         ospf_lsa_flush_as (ospf, lsa);          ospf_lsa_flush_as (ospf, lsa);
       break;        break;
 #ifdef HAVE_OPAQUE_LSA  
     case OSPF_OPAQUE_LINK_LSA:      case OSPF_OPAQUE_LINK_LSA:
     case OSPF_OPAQUE_AREA_LSA:      case OSPF_OPAQUE_AREA_LSA:
     case OSPF_OPAQUE_AS_LSA:      case OSPF_OPAQUE_AS_LSA:
       new = ospf_opaque_lsa_refresh (lsa);        new = ospf_opaque_lsa_refresh (lsa);
       break;        break;
 #endif /* HAVE_OPAQUE_LSA */  
     default:      default:
       break;        break;
     }      }
Line 3671  ospf_refresher_register_lsa (struct ospf *ospf, struct Line 3675  ospf_refresher_register_lsa (struct ospf *ospf, struct
       if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))        if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
         zlog_debug ("LSA[Refresh:%s]: ospf_refresher_register_lsa(): "          zlog_debug ("LSA[Refresh:%s]: ospf_refresher_register_lsa(): "
                    "setting refresh_list on lsa %p (slod %d)",                      "setting refresh_list on lsa %p (slod %d)", 
                   inet_ntoa (lsa->data->id), lsa, index);                   inet_ntoa (lsa->data->id), (void *)lsa, index);
     }      }
 }  }
   
Line 3742  ospf_lsa_refresh_walker (struct thread *t) Line 3746  ospf_lsa_refresh_walker (struct thread *t)
             {              {
               if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))                if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
                 zlog_debug ("LSA[Refresh:%s]: ospf_lsa_refresh_walker(): "                  zlog_debug ("LSA[Refresh:%s]: ospf_lsa_refresh_walker(): "
                           "refresh lsa %p (slot %d)",                            "refresh lsa %p (slot %d)",
                           inet_ntoa (lsa->data->id), lsa, i);                           inet_ntoa (lsa->data->id), (void *)lsa, i);
              
               assert (lsa->lock > 0);                assert (lsa->lock > 0);
               list_delete_node (refresh_list, node);                list_delete_node (refresh_list, node);
               lsa->refresh_list = -1;                lsa->refresh_list = -1;

Removed from v.1.1.1.3.2.1  
changed lines
  Added in v.1.1.1.4


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>