version 1.1.1.1, 2012/02/21 17:26:12
|
version 1.1.1.3.2.1, 2013/07/22 00:08:32
|
Line 192 ospf_lsa_checksum (struct lsa_header *lsa)
|
Line 192 ospf_lsa_checksum (struct lsa_header *lsa)
|
return fletcher_checksum(buffer, len, checksum_offset); |
return fletcher_checksum(buffer, len, checksum_offset); |
} |
} |
|
|
|
int |
|
ospf_lsa_checksum_valid (struct lsa_header *lsa) |
|
{ |
|
u_char *buffer = (u_char *) &lsa->options; |
|
int options_offset = buffer - (u_char *) &lsa->ls_age; /* should be 2 */ |
|
|
|
/* Skip the AGE field */ |
|
u_int16_t len = ntohs(lsa->length) - options_offset; |
|
|
|
return(fletcher_checksum(buffer, len, FLETCHER_CHECKSUM_VALIDATE) == 0); |
|
} |
|
|
|
|
|
|
/* Create OSPF LSA. */ |
/* Create OSPF LSA. */ |
struct ospf_lsa * |
struct ospf_lsa * |
Line 670 router_lsa_link_set (struct stream *s, struct ospf_are
|
Line 682 router_lsa_link_set (struct stream *s, struct ospf_are
|
{ |
{ |
if (oi->state != ISM_Down) |
if (oi->state != ISM_Down) |
{ |
{ |
|
oi->lsa_pos_beg = links; |
/* Describe each link. */ |
/* Describe each link. */ |
switch (oi->type) |
switch (oi->type) |
{ |
{ |
Line 691 router_lsa_link_set (struct stream *s, struct ospf_are
|
Line 704 router_lsa_link_set (struct stream *s, struct ospf_are
|
case OSPF_IFTYPE_LOOPBACK: |
case OSPF_IFTYPE_LOOPBACK: |
links += lsa_link_loopback_set (s, oi); |
links += lsa_link_loopback_set (s, oi); |
} |
} |
|
oi->lsa_pos_end = links; |
} |
} |
} |
} |
} |
} |
Line 746 ospf_stub_router_timer (struct thread *t)
|
Line 760 ospf_stub_router_timer (struct thread *t)
|
return 0; |
return 0; |
} |
} |
|
|
inline static void | static void |
ospf_stub_router_check (struct ospf_area *area) |
ospf_stub_router_check (struct ospf_area *area) |
{ |
{ |
/* area must either be administratively configured to be stub |
/* area must either be administratively configured to be stub |
Line 1326 static void
|
Line 1340 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, |
u_int32_t metric) |
u_int32_t metric) |
{ |
{ |
struct in_addr mask; |
|
|
|
masklen2ip (p->prefixlen, &mask); |
|
|
|
/* Put Network Mask. */ |
/* Put Network Mask. */ |
stream_put_ipv4 (s, mask.s_addr); | stream_put_ipv4 (s, (u_int32_t) 0); |
|
|
/* Set # TOS. */ |
/* Set # TOS. */ |
stream_putc (s, (u_char) 0); |
stream_putc (s, (u_char) 0); |
Line 1614 ospf_external_lsa_body_set (struct stream *s, struct e
|
Line 1624 ospf_external_lsa_body_set (struct stream *s, struct e
|
stream_put_ospf_metric (s, mvalue); |
stream_put_ospf_metric (s, mvalue); |
|
|
/* Get forwarding address to nexthop if on the Connection List, else 0. */ |
/* Get forwarding address to nexthop if on the Connection List, else 0. */ |
fwd_addr = ospf_external_lsa_nexthop_get (ospf, ei->nexthop); | fwd_addr = (ei->route_map_set.nexthop.s_addr != -1) ? |
| ROUTEMAP_NEXTHOP (ei) : ospf_external_lsa_nexthop_get (ospf, ei->nexthop); |
|
|
/* Put forwarding address. */ |
/* Put forwarding address. */ |
stream_put_ipv4 (s, fwd_addr.s_addr); |
stream_put_ipv4 (s, fwd_addr.s_addr); |
Line 1637 ospf_external_lsa_new (struct ospf *ospf,
|
Line 1648 ospf_external_lsa_new (struct ospf *ospf,
|
if (ei == NULL) |
if (ei == NULL) |
{ |
{ |
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE)) |
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE)) |
zlog_debug ("LSA[Type5]: External info is NULL, could not originated"); | zlog_debug ("LSA[Type5]: External info is NULL, can't originate"); |
return NULL; |
return NULL; |
} |
} |
|
|
Line 1852 ospf_translated_nssa_originate (struct ospf *ospf, str
|
Line 1863 ospf_translated_nssa_originate (struct ospf *ospf, str
|
|
|
if ( (new = ospf_lsa_install (ospf, NULL, new)) == NULL) |
if ( (new = ospf_lsa_install (ospf, NULL, new)) == NULL) |
{ |
{ |
if (IS_DEBUG_OSPF_NSSA); | if (IS_DEBUG_OSPF_NSSA) |
zlog_debug ("ospf_lsa_translated_nssa_originate(): " |
zlog_debug ("ospf_lsa_translated_nssa_originate(): " |
"Could not install LSA " |
"Could not install LSA " |
"id %s", inet_ntoa (type7->data->id)); |
"id %s", inet_ntoa (type7->data->id)); |
Line 2723 ospf_lsa_install (struct ospf *ospf, struct ospf_inter
|
Line 2734 ospf_lsa_install (struct ospf *ospf, struct ospf_inter
|
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. */ |
else |
else |
; /* Incoming "oi" for this LSA has set at LSUpd reception. */ | { |
| /* Incoming "oi" for this LSA has set at LSUpd reception. */ |
| } |
/* Fallthrough */ |
/* Fallthrough */ |
case OSPF_OPAQUE_AREA_LSA: |
case OSPF_OPAQUE_AREA_LSA: |
case OSPF_OPAQUE_AS_LSA: |
case OSPF_OPAQUE_AS_LSA: |
Line 2768 ospf_lsa_install (struct ospf *ospf, struct ospf_inter
|
Line 2781 ospf_lsa_install (struct ospf *ospf, struct ospf_inter
|
If received LSA' ls_age is MaxAge, or lsa is being prematurely aged |
If received LSA' ls_age is MaxAge, or lsa is being prematurely aged |
(it's getting flushed out of the area), set LSA on MaxAge LSA list. |
(it's getting flushed out of the area), set LSA on MaxAge LSA list. |
*/ |
*/ |
if ((lsa->flags & OSPF_LSA_PREMATURE_AGE) || | if (IS_LSA_MAXAGE (new)) |
(IS_LSA_MAXAGE (new) && !IS_LSA_SELF (new))) | |
{ |
{ |
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); |
lsa); |
ospf_lsa_flush (ospf, lsa); | ospf_lsa_maxage (ospf, lsa); |
} |
} |
|
|
return new; |
return new; |
Line 2814 ospf_maxage_lsa_remover (struct thread *thread)
|
Line 2826 ospf_maxage_lsa_remover (struct thread *thread)
|
{ |
{ |
struct ospf *ospf = THREAD_ARG (thread); |
struct ospf *ospf = THREAD_ARG (thread); |
struct ospf_lsa *lsa; |
struct ospf_lsa *lsa; |
struct listnode *node, *nnode; | struct route_node *rn; |
int reschedule = 0; |
int reschedule = 0; |
|
|
ospf->t_maxage = NULL; |
ospf->t_maxage = NULL; |
Line 2825 ospf_maxage_lsa_remover (struct thread *thread)
|
Line 2837 ospf_maxage_lsa_remover (struct thread *thread)
|
reschedule = !ospf_check_nbr_status (ospf); |
reschedule = !ospf_check_nbr_status (ospf); |
|
|
if (!reschedule) |
if (!reschedule) |
for (ALL_LIST_ELEMENTS (ospf->maxage_lsa, node, nnode, lsa)) | for (rn = route_top(ospf->maxage_lsa); rn; rn = route_next(rn)) |
{ |
{ |
|
if ((lsa = rn->info) == NULL) |
|
{ |
|
continue; |
|
} |
|
|
if (lsa->retransmit_counter > 0) |
if (lsa->retransmit_counter > 0) |
{ |
{ |
reschedule = 1; |
reschedule = 1; |
Line 2838 ospf_maxage_lsa_remover (struct thread *thread)
|
Line 2855 ospf_maxage_lsa_remover (struct thread *thread)
|
OSPF_TIMER_ON (ospf->t_maxage, ospf_maxage_lsa_remover, 0); |
OSPF_TIMER_ON (ospf->t_maxage, ospf_maxage_lsa_remover, 0); |
|
|
/* Remove LSA from the LSDB */ |
/* Remove LSA from the LSDB */ |
if (CHECK_FLAG (lsa->flags, OSPF_LSA_SELF)) | if (IS_LSA_SELF (lsa)) |
if (IS_DEBUG_OSPF (lsa, LSA_FLOODING)) |
if (IS_DEBUG_OSPF (lsa, LSA_FLOODING)) |
zlog_debug ("LSA[Type%d:%s]: LSA 0x%lx is self-oririnated: ", | zlog_debug ("LSA[Type%d:%s]: LSA 0x%lx is self-originated: ", |
lsa->data->type, inet_ntoa (lsa->data->id), (u_long)lsa); |
lsa->data->type, inet_ntoa (lsa->data->id), (u_long)lsa); |
|
|
if (IS_DEBUG_OSPF (lsa, LSA_FLOODING)) |
if (IS_DEBUG_OSPF (lsa, LSA_FLOODING)) |
Line 2879 ospf_maxage_lsa_remover (struct thread *thread)
|
Line 2896 ospf_maxage_lsa_remover (struct thread *thread)
|
void |
void |
ospf_lsa_maxage_delete (struct ospf *ospf, struct ospf_lsa *lsa) |
ospf_lsa_maxage_delete (struct ospf *ospf, struct ospf_lsa *lsa) |
{ |
{ |
struct listnode *n; | struct route_node *rn; |
| struct prefix_ls lsa_prefix; |
|
|
if ((n = listnode_lookup (ospf->maxage_lsa, lsa))) | ls_prefix_set (&lsa_prefix, lsa); |
| |
| if ((rn = route_node_lookup(ospf->maxage_lsa, |
| (struct prefix *)&lsa_prefix))) |
{ |
{ |
list_delete_node (ospf->maxage_lsa, n); | if (rn->info == lsa) |
UNSET_FLAG(lsa->flags, OSPF_LSA_IN_MAXAGE); | { |
ospf_lsa_unlock (&lsa); /* maxage_lsa */ | UNSET_FLAG(lsa->flags, OSPF_LSA_IN_MAXAGE); |
| ospf_lsa_unlock (&lsa); /* maxage_lsa */ |
| rn->info = NULL; |
| route_unlock_node (rn); /* route_node_lookup */ |
| } |
| route_unlock_node (rn); /* route_node_lookup */ |
} |
} |
} |
} |
|
|
Line 2897 ospf_lsa_maxage_delete (struct ospf *ospf, struct ospf
|
Line 2923 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 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 |
and schedule the MaxAge LSA remover. */ |
and schedule the MaxAge LSA remover. */ |
if (CHECK_FLAG(lsa->flags, OSPF_LSA_IN_MAXAGE)) |
if (CHECK_FLAG(lsa->flags, OSPF_LSA_IN_MAXAGE)) |
Line 2907 ospf_lsa_maxage (struct ospf *ospf, struct ospf_lsa *l
|
Line 2936 ospf_lsa_maxage (struct ospf *ospf, struct ospf_lsa *l
|
return; |
return; |
} |
} |
|
|
listnode_add (ospf->maxage_lsa, ospf_lsa_lock (lsa)); | ls_prefix_set (&lsa_prefix, lsa); |
SET_FLAG(lsa->flags, OSPF_LSA_IN_MAXAGE); | if ((rn = route_node_get (ospf->maxage_lsa, |
| (struct prefix *)&lsa_prefix)) != NULL) |
| { |
| if (rn->info != NULL) |
| { |
| route_unlock_node (rn); |
| } |
| else |
| { |
| rn->info = ospf_lsa_lock(lsa); |
| SET_FLAG(lsa->flags, OSPF_LSA_IN_MAXAGE); |
| } |
| } |
| else |
| { |
| zlog_err("Unable to allocate memory for maxage lsa\n"); |
| assert(0); |
| } |
|
|
if (IS_DEBUG_OSPF (lsa, LSA_FLOODING)) |
if (IS_DEBUG_OSPF (lsa, LSA_FLOODING)) |
zlog_debug ("LSA[%s]: MaxAge LSA remover scheduled.", dump_lsa_key (lsa)); |
zlog_debug ("LSA[%s]: MaxAge LSA remover scheduled.", dump_lsa_key (lsa)); |
Line 3389 ospf_lsa_is_self_originated (struct ospf *ospf, struct
|
Line 3435 ospf_lsa_is_self_originated (struct ospf *ospf, struct
|
|
|
/* This LSA is already checked. */ |
/* This LSA is already checked. */ |
if (CHECK_FLAG (lsa->flags, OSPF_LSA_SELF_CHECKED)) |
if (CHECK_FLAG (lsa->flags, OSPF_LSA_SELF_CHECKED)) |
return CHECK_FLAG (lsa->flags, OSPF_LSA_SELF); | return IS_LSA_SELF (lsa); |
|
|
/* Make sure LSA is self-checked. */ |
/* Make sure LSA is self-checked. */ |
SET_FLAG (lsa->flags, OSPF_LSA_SELF_CHECKED); |
SET_FLAG (lsa->flags, OSPF_LSA_SELF_CHECKED); |
Line 3414 ospf_lsa_is_self_originated (struct ospf *ospf, struct
|
Line 3460 ospf_lsa_is_self_originated (struct ospf *ospf, struct
|
{ |
{ |
/* to make it easier later */ |
/* to make it easier later */ |
SET_FLAG (lsa->flags, OSPF_LSA_SELF); |
SET_FLAG (lsa->flags, OSPF_LSA_SELF); |
return CHECK_FLAG (lsa->flags, OSPF_LSA_SELF); | return IS_LSA_SELF (lsa); |
} |
} |
} |
} |
|
|
return CHECK_FLAG (lsa->flags, OSPF_LSA_SELF); | return IS_LSA_SELF (lsa); |
} |
} |
|
|
/* Get unique Link State ID. */ |
/* Get unique Link State ID. */ |
Line 3541 ospf_lsa_refresh (struct ospf *ospf, struct ospf_lsa *
|
Line 3587 ospf_lsa_refresh (struct ospf *ospf, struct ospf_lsa *
|
struct external_info *ei; |
struct external_info *ei; |
struct ospf_lsa *new = NULL; |
struct ospf_lsa *new = NULL; |
assert (CHECK_FLAG (lsa->flags, OSPF_LSA_SELF)); |
assert (CHECK_FLAG (lsa->flags, OSPF_LSA_SELF)); |
|
assert (IS_LSA_SELF (lsa)); |
assert (lsa->lock > 0); |
assert (lsa->lock > 0); |
|
|
switch (lsa->data->type) |
switch (lsa->data->type) |
Line 3589 ospf_refresher_register_lsa (struct ospf *ospf, struct
|
Line 3636 ospf_refresher_register_lsa (struct ospf *ospf, struct
|
u_int16_t index, current_index; |
u_int16_t index, current_index; |
|
|
assert (lsa->lock > 0); |
assert (lsa->lock > 0); |
assert (CHECK_FLAG (lsa->flags, OSPF_LSA_SELF)); | assert (IS_LSA_SELF (lsa)); |
|
|
if (lsa->refresh_list < 0) |
if (lsa->refresh_list < 0) |
{ |
{ |
Line 3632 void
|
Line 3679 void
|
ospf_refresher_unregister_lsa (struct ospf *ospf, struct ospf_lsa *lsa) |
ospf_refresher_unregister_lsa (struct ospf *ospf, struct ospf_lsa *lsa) |
{ |
{ |
assert (lsa->lock > 0); |
assert (lsa->lock > 0); |
assert (CHECK_FLAG (lsa->flags, OSPF_LSA_SELF)); | assert (IS_LSA_SELF (lsa)); |
if (lsa->refresh_list >= 0) |
if (lsa->refresh_list >= 0) |
{ |
{ |
struct list *refresh_list = ospf->lsa_refresh_queue.qs[lsa->refresh_list]; |
struct list *refresh_list = ospf->lsa_refresh_queue.qs[lsa->refresh_list]; |