Merge pull request #5292 from donaldsharp/ospf_vrf_data

Ospf vrf data
This commit is contained in:
Rafael Zalamena 2019-11-19 15:29:11 -03:00 committed by GitHub
commit abdd51c11f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 187 additions and 245 deletions

View File

@ -246,13 +246,6 @@ void msg_print(struct msg *msg)
return; return;
} }
#ifdef ORIGINAL_CODING
zlog_debug(
"msg=%p msgtype=%d msglen=%d msgseq=%d streamdata=%p streamsize=%lu\n",
msg, msg->hdr.msgtype, ntohs(msg->hdr.msglen),
ntohl(msg->hdr.msgseq), STREAM_DATA(msg->s),
STREAM_SIZE(msg->s));
#else /* ORIGINAL_CODING */
/* API message common header part. */ /* API message common header part. */
zlog_debug("API-msg [%s]: type(%d),len(%d),seq(%lu),data(%p),size(%zd)", zlog_debug("API-msg [%s]: type(%d),len(%d),seq(%lu),data(%p),size(%zd)",
ospf_api_typename(msg->hdr.msgtype), msg->hdr.msgtype, ospf_api_typename(msg->hdr.msgtype), msg->hdr.msgtype,
@ -260,16 +253,7 @@ void msg_print(struct msg *msg)
(unsigned long)ntohl(msg->hdr.msgseq), STREAM_DATA(msg->s), (unsigned long)ntohl(msg->hdr.msgseq), STREAM_DATA(msg->s),
STREAM_SIZE(msg->s)); STREAM_SIZE(msg->s));
/* API message body part. */
#ifdef ndef
/* Generic Hex/Ascii dump */
DumpBuf(STREAM_DATA(msg->s), STREAM_SIZE(msg->s)); /* Sorry, deleted! */
#else /* ndef */
/* Message-type dependent dump function. */
#endif /* ndef */
return; return;
#endif /* ORIGINAL_CODING */
} }
void msg_free(struct msg *msg) void msg_free(struct msg *msg)

View File

@ -140,16 +140,10 @@ struct msg_unregister_opaque_type {
* Power2[0] is not used. */ * Power2[0] is not used. */
#ifdef ORIGINAL_CODING
static const uint16_t Power2[] = {0x0, 0x1, 0x2, 0x4, 0x8, 0x10,
0x20, 0x40, 0x80, 0x100, 0x200, 0x400,
0x800, 0x1000, 0x2000, 0x4000, 0x8000};
#else
static const uint16_t Power2[] = { static const uint16_t Power2[] = {
0, (1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4), 0, (1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4),
(1 << 5), (1 << 6), (1 << 7), (1 << 8), (1 << 9), (1 << 10), (1 << 5), (1 << 6), (1 << 7), (1 << 8), (1 << 9), (1 << 10),
(1 << 11), (1 << 12), (1 << 13), (1 << 14), (1 << 15)}; (1 << 11), (1 << 12), (1 << 13), (1 << 14), (1 << 15)};
#endif /* ORIGINAL_CODING */
struct lsa_filter_type { struct lsa_filter_type {
uint16_t typemask; /* bitmask for selecting LSA types (1..16) */ uint16_t typemask; /* bitmask for selecting LSA types (1..16) */

View File

@ -238,20 +238,23 @@ struct ospf_lsa *ospf_external_info_find_lsa(struct ospf *ospf,
/* Update ASBR status. */ /* Update ASBR status. */
void ospf_asbr_status_update(struct ospf *ospf, uint8_t status) void ospf_asbr_status_update(struct ospf *ospf, uint8_t status)
{ {
zlog_info("ASBR[Status:%d]: Update", status); zlog_info("ASBR[%s:Status:%d]: Update",
ospf_get_name(ospf), status);
/* ASBR on. */ /* ASBR on. */
if (status) { if (status) {
/* Already ASBR. */ /* Already ASBR. */
if (IS_OSPF_ASBR(ospf)) { if (IS_OSPF_ASBR(ospf)) {
zlog_info("ASBR[Status:%d]: Already ASBR", status); zlog_info("ASBR[%s:Status:%d]: Already ASBR",
ospf_get_name(ospf), status);
return; return;
} }
SET_FLAG(ospf->flags, OSPF_FLAG_ASBR); SET_FLAG(ospf->flags, OSPF_FLAG_ASBR);
} else { } else {
/* Already non ASBR. */ /* Already non ASBR. */
if (!IS_OSPF_ASBR(ospf)) { if (!IS_OSPF_ASBR(ospf)) {
zlog_info("ASBR[Status:%d]: Already non ASBR", status); zlog_info("ASBR[%s:Status:%d]: Already non ASBR",
ospf_get_name(ospf), status);
return; return;
} }
UNSET_FLAG(ospf->flags, OSPF_FLAG_ASBR); UNSET_FLAG(ospf->flags, OSPF_FLAG_ASBR);

View File

@ -501,23 +501,6 @@ static void ospf_packet_ls_ack_dump(struct stream *s, uint16_t length)
stream_set_getp(s, sp); stream_set_getp(s, sp);
} }
/* Expects header to be in host order */
void ospf_ip_header_dump(struct ip *iph)
{
/* IP Header dump. */
zlog_debug("ip_v %d", iph->ip_v);
zlog_debug("ip_hl %d", iph->ip_hl);
zlog_debug("ip_tos %d", iph->ip_tos);
zlog_debug("ip_len %d", iph->ip_len);
zlog_debug("ip_id %u", (uint32_t)iph->ip_id);
zlog_debug("ip_off %u", (uint32_t)iph->ip_off);
zlog_debug("ip_ttl %d", iph->ip_ttl);
zlog_debug("ip_p %d", iph->ip_p);
zlog_debug("ip_sum 0x%x", (uint32_t)iph->ip_sum);
zlog_debug("ip_src %s", inet_ntoa(iph->ip_src));
zlog_debug("ip_dst %s", inet_ntoa(iph->ip_dst));
}
static void ospf_header_dump(struct ospf_header *ospfh) static void ospf_header_dump(struct ospf_header *ospfh)
{ {
char buf[9]; char buf[9];

View File

@ -108,11 +108,6 @@
(conf_debug_ospf_packet[a] & OSPF_DEBUG_##b) (conf_debug_ospf_packet[a] & OSPF_DEBUG_##b)
#define IS_CONF_DEBUG_OSPF(a, b) (conf_debug_ospf_##a & OSPF_DEBUG_##b) #define IS_CONF_DEBUG_OSPF(a, b) (conf_debug_ospf_##a & OSPF_DEBUG_##b)
#ifdef ORIGINAL_CODING
#else /* ORIGINAL_CODING */
struct stream;
#endif /* ORIGINAL_CODING */
#define AREA_NAME(A) ospf_area_name_string ((A)) #define AREA_NAME(A) ospf_area_name_string ((A))
#define IF_NAME(I) ospf_if_name_string ((I)) #define IF_NAME(I) ospf_if_name_string ((I))
@ -138,7 +133,6 @@ extern const char *ospf_if_name_string(struct ospf_interface *);
extern void ospf_nbr_state_message(struct ospf_neighbor *, char *, size_t); extern void ospf_nbr_state_message(struct ospf_neighbor *, char *, size_t);
extern const char *ospf_timer_dump(struct thread *, char *, size_t); extern const char *ospf_timer_dump(struct thread *, char *, size_t);
extern const char *ospf_timeval_dump(struct timeval *, char *, size_t); extern const char *ospf_timeval_dump(struct timeval *, char *, size_t);
extern void ospf_ip_header_dump(struct ip *);
extern void ospf_packet_dump(struct stream *); extern void ospf_packet_dump(struct stream *);
extern void ospf_debug_init(void); extern void ospf_debug_init(void);

View File

@ -157,9 +157,9 @@ static void ospf_process_self_originated_lsa(struct ospf *ospf,
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug( zlog_debug(
"LSA[Type%d:%s]: Process self-originated LSA seq 0x%x", "%s:LSA[Type%d:%s]: Process self-originated LSA seq 0x%x",
new->data->type, inet_ntoa(new->data->id), ospf_get_name(ospf), new->data->type,
ntohl(new->data->ls_seqnum)); inet_ntoa(new->data->id), ntohl(new->data->ls_seqnum));
/* If we're here, we installed a self-originated LSA that we received /* If we're here, we installed a self-originated LSA that we received
from a neighbor, i.e. it's more recent. We must see whether we want from a neighbor, i.e. it's more recent. We must see whether we want
@ -276,8 +276,8 @@ int ospf_flood(struct ospf *ospf, struct ospf_neighbor *nbr,
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug( zlog_debug(
"LSA[Flooding]: start, NBR %s (%s), cur(%p), New-LSA[%s]", "%s:LSA[Flooding]: start, NBR %s (%s), cur(%p), New-LSA[%s]",
inet_ntoa(nbr->router_id), ospf_get_name(ospf), inet_ntoa(nbr->router_id),
lookup_msg(ospf_nsm_state_msg, nbr->state, NULL), lookup_msg(ospf_nsm_state_msg, nbr->state, NULL),
(void *)current, dump_lsa_key(new)); (void *)current, dump_lsa_key(new));
@ -295,15 +295,16 @@ int ospf_flood(struct ospf *ospf, struct ospf_neighbor *nbr,
== OSPF_INITIAL_SEQUENCE_NUMBER)) { == OSPF_INITIAL_SEQUENCE_NUMBER)) {
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug( zlog_debug(
"LSA[Flooding]: Got a self-originated LSA, " "%s:LSA[Flooding]: Got a self-originated LSA, while local one is initial instance.",
"while local one is initial instance."); ospf_get_name(ospf));
; /* Accept this LSA for quick LSDB resynchronization. ; /* Accept this LSA for quick LSDB resynchronization.
*/ */
} else if (monotime_since(&current->tv_recv, NULL) } else if (monotime_since(&current->tv_recv, NULL)
< ospf->min_ls_arrival * 1000LL) { < ospf->min_ls_arrival * 1000LL) {
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug( zlog_debug(
"LSA[Flooding]: LSA is received recently."); "%s:LSA[Flooding]: LSA is received recently.",
ospf_get_name(ospf));
return -1; return -1;
} }
} }
@ -376,9 +377,8 @@ static int ospf_flood_through_interface(struct ospf_interface *oi,
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug( zlog_debug(
"ospf_flood_through_interface(): " "%s:ospf_flood_through_interface(): considering int %s, INBR(%s), LSA[%s] AGE %u",
"considering int %s, INBR(%s), LSA[%s] AGE %u", ospf_get_name(oi->ospf), IF_NAME(oi), inbr ? inet_ntoa(inbr->router_id) : "NULL",
IF_NAME(oi), inbr ? inet_ntoa(inbr->router_id) : "NULL",
dump_lsa_key(lsa), ntohs(lsa->data->ls_age)); dump_lsa_key(lsa), ntohs(lsa->data->ls_age));
if (!ospf_if_is_enable(oi)) if (!ospf_if_is_enable(oi))
@ -399,8 +399,9 @@ static int ospf_flood_through_interface(struct ospf_interface *oi,
onbr = rn->info; onbr = rn->info;
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug( zlog_debug(
"ospf_flood_through_interface(): considering nbr %s (%s)", "ospf_flood_through_interface(): considering nbr %s(%s) (%s)",
inet_ntoa(onbr->router_id), inet_ntoa(onbr->router_id),
ospf_get_name(oi->ospf),
lookup_msg(ospf_nsm_state_msg, onbr->state, lookup_msg(ospf_nsm_state_msg, onbr->state,
NULL)); NULL));
@ -454,13 +455,8 @@ static int ospf_flood_through_interface(struct ospf_interface *oi,
} }
} }
/* If the new LSA was received from this neighbor, /* If the new LSA was received from this neighbor,
examine the next neighbor. */ examine the next neighbor. */
#ifdef ORIGINAL_CODING
if (inbr)
if (IPV4_ADDR_SAME(&inbr->router_id, &onbr->router_id))
continue;
#else /* ORIGINAL_CODING */
if (inbr) { if (inbr) {
/* /*
* Triggered by LSUpd message parser "ospf_ls_upd ()". * Triggered by LSUpd message parser "ospf_ls_upd ()".
@ -486,7 +482,6 @@ static int ospf_flood_through_interface(struct ospf_interface *oi,
continue; continue;
} }
} }
#endif /* ORIGINAL_CODING */
/* Add the new LSA to the Link state retransmission list /* Add the new LSA to the Link state retransmission list
for the adjacency. The LSA will be retransmitted for the adjacency. The LSA will be retransmitted
@ -691,43 +686,14 @@ int ospf_flood_through(struct ospf *ospf, struct ospf_neighbor *inbr,
{ {
int lsa_ack_flag = 0; int lsa_ack_flag = 0;
/* Type-7 LSA's for NSSA are flooded throughout the AS here, and /* Type-7 LSA's for NSSA are flooded throughout the AS here, and
upon return are updated in the LSDB for Type-7's. Later, upon return are updated in the LSDB for Type-7's. Later,
re-fresh will re-send them (and also, if ABR, packet code will re-fresh will re-send them (and also, if ABR, packet code will
translate to Type-5's) translate to Type-5's)
As usual, Type-5 LSA's (if not DISCARDED because we are STUB or As usual, Type-5 LSA's (if not DISCARDED because we are STUB or
NSSA) are flooded throughout the AS, and are updated in the NSSA) are flooded throughout the AS, and are updated in the
global table. */ global table. */
#ifdef ORIGINAL_CODING
switch (lsa->data->type) {
case OSPF_ROUTER_LSA:
case OSPF_NETWORK_LSA:
case OSPF_SUMMARY_LSA:
case OSPF_ASBR_SUMMARY_LSA:
case OSPF_OPAQUE_LINK_LSA: /* ospf_flood_through_interface ? */
case OSPF_OPAQUE_AREA_LSA:
lsa_ack_flag =
ospf_flood_through_area(inbr->oi->area, inbr, lsa);
break;
case OSPF_AS_EXTERNAL_LSA: /* Type-5 */
case OSPF_OPAQUE_AS_LSA:
lsa_ack_flag = ospf_flood_through_as(ospf, inbr, lsa);
break;
/* Type-7 Only received within NSSA, then flooded */
case OSPF_AS_NSSA_LSA:
/* Any P-bit was installed with the Type-7. */
lsa_ack_flag =
ospf_flood_through_area(inbr->oi->area, inbr, lsa);
if (IS_DEBUG_OSPF_NSSA)
zlog_debug(
"ospf_flood_through: LOCAL NSSA FLOOD of Type-7.");
break;
default:
break;
}
#else /* ORIGINAL_CODING */
/* /*
* At the common sub-sub-function "ospf_flood_through_interface()", * At the common sub-sub-function "ospf_flood_through_interface()",
* a parameter "inbr" will be used to distinguish the called context * a parameter "inbr" will be used to distinguish the called context
@ -757,7 +723,6 @@ int ospf_flood_through(struct ospf *ospf, struct ospf_neighbor *inbr,
lsa_ack_flag = ospf_flood_through_area(lsa->area, inbr, lsa); lsa_ack_flag = ospf_flood_through_area(lsa->area, inbr, lsa);
break; break;
} }
#endif /* ORIGINAL_CODING */
return (lsa_ack_flag); return (lsa_ack_flag);
} }
@ -773,9 +738,10 @@ void ospf_ls_request_add(struct ospf_neighbor *nbr, struct ospf_lsa *lsa)
* the common function "ospf_lsdb_add()" -- endo. * the common function "ospf_lsdb_add()" -- endo.
*/ */
if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) if (IS_DEBUG_OSPF(lsa, LSA_FLOODING))
zlog_debug("RqstL(%lu)++, NBR(%s), LSA[%s]", zlog_debug("RqstL(%lu)++, NBR(%s(%s)), LSA[%s]",
ospf_ls_request_count(nbr), ospf_ls_request_count(nbr),
inet_ntoa(nbr->router_id), dump_lsa_key(lsa)); inet_ntoa(nbr->router_id),
ospf_get_name(nbr->oi->ospf), dump_lsa_key(lsa));
ospf_lsdb_add(&nbr->ls_req, lsa); ospf_lsdb_add(&nbr->ls_req, lsa);
} }
@ -799,9 +765,10 @@ void ospf_ls_request_delete(struct ospf_neighbor *nbr, struct ospf_lsa *lsa)
} }
if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) /* -- endo. */ if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) /* -- endo. */
zlog_debug("RqstL(%lu)--, NBR(%s), LSA[%s]", zlog_debug("RqstL(%lu)--, NBR(%s(%s)), LSA[%s]",
ospf_ls_request_count(nbr), ospf_ls_request_count(nbr),
inet_ntoa(nbr->router_id), dump_lsa_key(lsa)); inet_ntoa(nbr->router_id),
ospf_get_name(nbr->oi->ospf), dump_lsa_key(lsa));
ospf_lsdb_delete(&nbr->ls_req, lsa); ospf_lsdb_delete(&nbr->ls_req, lsa);
} }
@ -859,6 +826,12 @@ void ospf_ls_retransmit_add(struct ospf_neighbor *nbr, struct ospf_lsa *lsa)
if (ospf_lsa_more_recent(old, lsa) < 0) { if (ospf_lsa_more_recent(old, lsa) < 0) {
if (old) { if (old) {
old->retransmit_counter--; old->retransmit_counter--;
if (IS_DEBUG_OSPF(lsa, LSA_FLOODING))
zlog_debug("RXmtL(%lu)--, NBR(%s(%s)), LSA[%s]",
ospf_ls_retransmit_count(nbr),
inet_ntoa(nbr->router_id),
ospf_get_name(nbr->oi->ospf),
dump_lsa_key(old));
ospf_lsdb_delete(&nbr->ls_rxmt, old); ospf_lsdb_delete(&nbr->ls_rxmt, old);
} }
lsa->retransmit_counter++; lsa->retransmit_counter++;
@ -871,9 +844,10 @@ void ospf_ls_retransmit_add(struct ospf_neighbor *nbr, struct ospf_lsa *lsa)
* the common function "ospf_lsdb_add()" -- endo. * the common function "ospf_lsdb_add()" -- endo.
*/ */
if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) if (IS_DEBUG_OSPF(lsa, LSA_FLOODING))
zlog_debug("RXmtL(%lu)++, NBR(%s), LSA[%s]", zlog_debug("RXmtL(%lu)++, NBR(%s(%s)), LSA[%s]",
ospf_ls_retransmit_count(nbr), ospf_ls_retransmit_count(nbr),
inet_ntoa(nbr->router_id), inet_ntoa(nbr->router_id),
ospf_get_name(nbr->oi->ospf),
dump_lsa_key(lsa)); dump_lsa_key(lsa));
ospf_lsdb_add(&nbr->ls_rxmt, lsa); ospf_lsdb_add(&nbr->ls_rxmt, lsa);
} }
@ -885,9 +859,10 @@ void ospf_ls_retransmit_delete(struct ospf_neighbor *nbr, struct ospf_lsa *lsa)
if (ospf_ls_retransmit_lookup(nbr, lsa)) { if (ospf_ls_retransmit_lookup(nbr, lsa)) {
lsa->retransmit_counter--; lsa->retransmit_counter--;
if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) /* -- endo. */ if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) /* -- endo. */
zlog_debug("RXmtL(%lu)--, NBR(%s), LSA[%s]", zlog_debug("RXmtL(%lu)--, NBR(%s(%s)), LSA[%s]",
ospf_ls_retransmit_count(nbr), ospf_ls_retransmit_count(nbr),
inet_ntoa(nbr->router_id), inet_ntoa(nbr->router_id),
ospf_get_name(nbr->oi->ospf),
dump_lsa_key(lsa)); dump_lsa_key(lsa));
ospf_lsdb_delete(&nbr->ls_rxmt, lsa); ospf_lsdb_delete(&nbr->ls_rxmt, lsa);
} }

View File

@ -273,7 +273,7 @@ struct ospf_interface *ospf_if_new(struct ospf *ospf, struct interface *ifp,
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug("%s: ospf interface %s vrf %s id %u created", zlog_debug("%s: ospf interface %s vrf %s id %u created",
__PRETTY_FUNCTION__, ifp->name, __PRETTY_FUNCTION__, ifp->name,
ospf_vrf_id_to_name(ospf->vrf_id), ospf->vrf_id); ospf_get_name(ospf), ospf->vrf_id);
return oi; return oi;
} }
@ -832,7 +832,7 @@ struct ospf_interface *ospf_vl_new(struct ospf *ospf,
struct prefix_ipv4 *p; struct prefix_ipv4 *p;
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug("ospf_vl_new(): Start"); zlog_debug("ospf_vl_new()(%s): Start", ospf_get_name(ospf));
if (vlink_count == OSPF_VL_MAX_COUNT) { if (vlink_count == OSPF_VL_MAX_COUNT) {
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug( zlog_debug(

View File

@ -3202,45 +3202,6 @@ int ospf_lsa_different(struct ospf_lsa *l1, struct ospf_lsa *l2)
return 0; return 0;
} }
#ifdef ORIGINAL_CODING
void ospf_lsa_flush_self_originated(struct ospf_neighbor *nbr,
struct ospf_lsa *self, struct ospf_lsa *new)
{
uint32_t seqnum;
/* Adjust LS Sequence Number. */
seqnum = ntohl(new->data->ls_seqnum) + 1;
self->data->ls_seqnum = htonl(seqnum);
/* Recalculate LSA checksum. */
ospf_lsa_checksum(self->data);
/* Reflooding LSA. */
/* RFC2328 Section 13.3
On non-broadcast networks, separate Link State Update
packets must be sent, as unicasts, to each adjacent neighbor
(i.e., those in state Exchange or greater). The destination
IP addresses for these packets are the neighbors' IP
addresses. */
if (nbr->oi->type == OSPF_IFTYPE_NBMA) {
struct route_node *rn;
struct ospf_neighbor *onbr;
for (rn = route_top(nbr->oi->nbrs); rn; rn = route_next(rn))
if ((onbr = rn->info) != NULL)
if (onbr != nbr->oi->nbr_self
&& onbr->status >= NSM_Exchange)
ospf_ls_upd_send_lsa(
onbr, self,
OSPF_SEND_PACKET_DIRECT);
} else
ospf_ls_upd_send_lsa(nbr, self, OSPF_SEND_PACKET_INDIRECT);
if (IS_DEBUG_OSPF(lsa, LSA_GENERATE))
zlog_debug("LSA[Type%d:%s]: Flush self-originated LSA",
self->data->type, inet_ntoa(self->data->id));
}
#else /* ORIGINAL_CODING */
int ospf_lsa_flush_schedule(struct ospf *ospf, struct ospf_lsa *lsa) int ospf_lsa_flush_schedule(struct ospf *ospf, struct ospf_lsa *lsa)
{ {
if (lsa == NULL || !IS_LSA_SELF(lsa)) if (lsa == NULL || !IS_LSA_SELF(lsa))
@ -3345,7 +3306,6 @@ void ospf_flush_self_originated_lsas_now(struct ospf *ospf)
return; return;
} }
#endif /* ORIGINAL_CODING */
/* If there is self-originated LSA, then return 1, otherwise return 0. */ /* If there is self-originated LSA, then return 1, otherwise return 0. */
/* An interface-independent version of ospf_lsa_is_self_originated */ /* An interface-independent version of ospf_lsa_is_self_originated */

View File

@ -65,8 +65,9 @@ static int ospf_inactivity_timer(struct thread *thread)
nbr->t_inactivity = NULL; nbr->t_inactivity = NULL;
if (IS_DEBUG_OSPF(nsm, NSM_TIMERS)) if (IS_DEBUG_OSPF(nsm, NSM_TIMERS))
zlog_debug("NSM[%s:%s]: Timer (Inactivity timer expire)", zlog_debug("NSM[%s:%s:%s]: Timer (Inactivity timer expire)",
IF_NAME(nbr->oi), inet_ntoa(nbr->router_id)); IF_NAME(nbr->oi), inet_ntoa(nbr->router_id),
ospf_get_name(nbr->oi->ospf));
OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_InactivityTimer); OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_InactivityTimer);
@ -81,8 +82,9 @@ static int ospf_db_desc_timer(struct thread *thread)
nbr->t_db_desc = NULL; nbr->t_db_desc = NULL;
if (IS_DEBUG_OSPF(nsm, NSM_TIMERS)) if (IS_DEBUG_OSPF(nsm, NSM_TIMERS))
zlog_debug("NSM[%s:%s]: Timer (DD Retransmit timer expire)", zlog_debug("NSM[%s:%s:%s]: Timer (DD Retransmit timer expire)",
IF_NAME(nbr->oi), inet_ntoa(nbr->src)); IF_NAME(nbr->oi), inet_ntoa(nbr->src),
ospf_get_name(nbr->oi->ospf));
/* resent last send DD packet. */ /* resent last send DD packet. */
assert(nbr->last_send); assert(nbr->last_send);
@ -387,9 +389,10 @@ static int nsm_kill_nbr(struct ospf_neighbor *nbr)
if (IS_DEBUG_OSPF(nsm, NSM_EVENTS)) if (IS_DEBUG_OSPF(nsm, NSM_EVENTS))
zlog_debug( zlog_debug(
"NSM[%s:%s]: Down (PollIntervalTimer scheduled)", "NSM[%s:%s:%s]: Down (PollIntervalTimer scheduled)",
IF_NAME(nbr->oi), IF_NAME(nbr->oi),
inet_ntoa(nbr->address.u.prefix4)); inet_ntoa(nbr->address.u.prefix4),
ospf_get_name(nbr->oi->ospf));
} }
return 0; return 0;
@ -585,8 +588,9 @@ static void nsm_notice_state_change(struct ospf_neighbor *nbr, int next_state,
{ {
/* Logging change of status. */ /* Logging change of status. */
if (IS_DEBUG_OSPF(nsm, NSM_STATUS)) if (IS_DEBUG_OSPF(nsm, NSM_STATUS))
zlog_debug("NSM[%s:%s]: State change %s -> %s (%s)", zlog_debug("NSM[%s:%s:%s]: State change %s -> %s (%s)",
IF_NAME(nbr->oi), inet_ntoa(nbr->router_id), IF_NAME(nbr->oi), inet_ntoa(nbr->router_id),
ospf_get_name(nbr->oi->ospf),
lookup_msg(ospf_nsm_state_msg, nbr->state, NULL), lookup_msg(ospf_nsm_state_msg, nbr->state, NULL),
lookup_msg(ospf_nsm_state_msg, next_state, NULL), lookup_msg(ospf_nsm_state_msg, next_state, NULL),
ospf_nsm_event_str[event]); ospf_nsm_event_str[event]);
@ -595,8 +599,9 @@ static void nsm_notice_state_change(struct ospf_neighbor *nbr, int next_state,
if (CHECK_FLAG(nbr->oi->ospf->config, OSPF_LOG_ADJACENCY_CHANGES) if (CHECK_FLAG(nbr->oi->ospf->config, OSPF_LOG_ADJACENCY_CHANGES)
&& (CHECK_FLAG(nbr->oi->ospf->config, OSPF_LOG_ADJACENCY_DETAIL) && (CHECK_FLAG(nbr->oi->ospf->config, OSPF_LOG_ADJACENCY_DETAIL)
|| (next_state == NSM_Full) || (next_state < nbr->state))) || (next_state == NSM_Full) || (next_state < nbr->state)))
zlog_notice("AdjChg: Nbr %s on %s: %s -> %s (%s)", zlog_notice("AdjChg: Nbr %s(%s) on %s: %s -> %s (%s)",
inet_ntoa(nbr->router_id), IF_NAME(nbr->oi), inet_ntoa(nbr->router_id),
ospf_get_name(nbr->oi->ospf), IF_NAME(nbr->oi),
lookup_msg(ospf_nsm_state_msg, nbr->state, NULL), lookup_msg(ospf_nsm_state_msg, nbr->state, NULL),
lookup_msg(ospf_nsm_state_msg, next_state, NULL), lookup_msg(ospf_nsm_state_msg, next_state, NULL),
ospf_nsm_event_str[event]); ospf_nsm_event_str[event]);
@ -677,9 +682,10 @@ static void nsm_change_state(struct ospf_neighbor *nbr, int state)
if (CHECK_FLAG(oi->ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) if (CHECK_FLAG(oi->ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
zlog_info( zlog_info(
"%s:(%s, %s -> %s): " "%s:[%s:%s], %s -> %s): "
"scheduling new router-LSA origination", "scheduling new router-LSA origination",
__PRETTY_FUNCTION__, inet_ntoa(nbr->router_id), __PRETTY_FUNCTION__, inet_ntoa(nbr->router_id),
ospf_get_name(oi->ospf),
lookup_msg(ospf_nsm_state_msg, old_state, NULL), lookup_msg(ospf_nsm_state_msg, old_state, NULL),
lookup_msg(ospf_nsm_state_msg, state, NULL)); lookup_msg(ospf_nsm_state_msg, state, NULL));
@ -753,8 +759,9 @@ int ospf_nsm_event(struct thread *thread)
event = THREAD_VAL(thread); event = THREAD_VAL(thread);
if (IS_DEBUG_OSPF(nsm, NSM_EVENTS)) if (IS_DEBUG_OSPF(nsm, NSM_EVENTS))
zlog_debug("NSM[%s:%s]: %s (%s)", IF_NAME(nbr->oi), zlog_debug("NSM[%s:%s:%s]: %s (%s)", IF_NAME(nbr->oi),
inet_ntoa(nbr->router_id), inet_ntoa(nbr->router_id),
ospf_get_name(nbr->oi->ospf),
lookup_msg(ospf_nsm_state_msg, nbr->state, NULL), lookup_msg(ospf_nsm_state_msg, nbr->state, NULL),
ospf_nsm_event_str[event]); ospf_nsm_event_str[event]);
@ -777,9 +784,10 @@ int ospf_nsm_event(struct thread *thread)
*/ */
flog_err( flog_err(
EC_OSPF_FSM_INVALID_STATE, EC_OSPF_FSM_INVALID_STATE,
"NSM[%s:%s]: %s (%s): " "NSM[%s:%s:%s]: %s (%s): "
"Warning: action tried to change next_state to %s", "Warning: action tried to change next_state to %s",
IF_NAME(nbr->oi), inet_ntoa(nbr->router_id), IF_NAME(nbr->oi), inet_ntoa(nbr->router_id),
ospf_get_name(nbr->oi->ospf),
lookup_msg(ospf_nsm_state_msg, nbr->state, lookup_msg(ospf_nsm_state_msg, nbr->state,
NULL), NULL),
ospf_nsm_event_str[event], ospf_nsm_event_str[event],

View File

@ -614,13 +614,6 @@ static void ospf_write_frags(int fd, struct ospf_packet *op, struct ip *iph,
"ospf_write_frags: sent id %d, off %d, len %d to %s\n", "ospf_write_frags: sent id %d, off %d, len %d to %s\n",
iph->ip_id, iph->ip_off, iph->ip_len, iph->ip_id, iph->ip_off, iph->ip_len,
inet_ntoa(iph->ip_dst)); inet_ntoa(iph->ip_dst));
if (IS_DEBUG_OSPF_PACKET(type - 1, DETAIL)) {
zlog_debug(
"-----------------IP Header Dump----------------------");
ospf_ip_header_dump(iph);
zlog_debug(
"-----------------------------------------------------");
}
} }
iph->ip_off += offset; iph->ip_off += offset;
@ -824,7 +817,6 @@ static int ospf_write(struct thread *thread)
if (IS_DEBUG_OSPF_PACKET(type - 1, DETAIL)) { if (IS_DEBUG_OSPF_PACKET(type - 1, DETAIL)) {
zlog_debug( zlog_debug(
"-----------------------------------------------------"); "-----------------------------------------------------");
ospf_ip_header_dump(&iph);
stream_set_getp(op->s, 0); stream_set_getp(op->s, 0);
ospf_packet_dump(op->s); ospf_packet_dump(op->s);
} }
@ -1505,10 +1497,6 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh,
/* Check DD Options. */ /* Check DD Options. */
if (dd->options != nbr->options) { if (dd->options != nbr->options) {
#ifdef ORIGINAL_CODING
/* Save the new options for debugging */
nbr->options = dd->options;
#endif /* ORIGINAL_CODING */
flog_warn(EC_OSPF_PACKET, flog_warn(EC_OSPF_PACKET,
"Packet[DD]: Neighbor %s options mismatch.", "Packet[DD]: Neighbor %s options mismatch.",
inet_ntoa(nbr->router_id)); inet_ntoa(nbr->router_id));
@ -2322,10 +2310,12 @@ static struct stream *ospf_recv_packet(struct ospf *ospf, int fd,
msgh.msg_control = (caddr_t)buff; msgh.msg_control = (caddr_t)buff;
msgh.msg_controllen = sizeof(buff); msgh.msg_controllen = sizeof(buff);
ret = stream_recvmsg(ibuf, fd, &msgh, 0, OSPF_MAX_PACKET_SIZE + 1); ret = stream_recvmsg(ibuf, fd, &msgh, MSG_DONTWAIT,
OSPF_MAX_PACKET_SIZE + 1);
if (ret < 0) { if (ret < 0) {
flog_warn(EC_OSPF_PACKET, "stream_recvmsg failed: %s", if (errno != EAGAIN && errno != EWOULDBLOCK)
safe_strerror(errno)); flog_warn(EC_OSPF_PACKET, "stream_recvmsg failed: %s",
safe_strerror(errno));
return NULL; return NULL;
} }
if ((unsigned int)ret < sizeof(iph)) /* ret must be > 0 now */ if ((unsigned int)ret < sizeof(iph)) /* ret must be > 0 now */
@ -2385,6 +2375,10 @@ static struct stream *ospf_recv_packet(struct ospf *ospf, int fd,
return NULL; return NULL;
} }
if (IS_DEBUG_OSPF_PACKET(0, RECV))
zlog_debug("%s: fd %d(%s) on interface %d(%s)",
__PRETTY_FUNCTION__, fd, ospf_get_name(ospf),
ifindex, *ifp ? (*ifp)->name : "Unknown");
return ibuf; return ibuf;
} }
@ -2943,56 +2937,60 @@ static int ospf_verify_header(struct stream *ibuf, struct ospf_interface *oi,
return 0; return 0;
} }
/* Starting point of packet process function. */ enum ospf_read_return_enum {
int ospf_read(struct thread *thread) OSPF_READ_ERROR,
OSPF_READ_CONTINUE,
};
static enum ospf_read_return_enum ospf_read_helper(struct ospf *ospf)
{ {
int ret; int ret;
struct stream *ibuf; struct stream *ibuf;
struct ospf *ospf;
struct ospf_interface *oi; struct ospf_interface *oi;
struct ip *iph; struct ip *iph;
struct ospf_header *ospfh; struct ospf_header *ospfh;
uint16_t length; uint16_t length;
struct interface *ifp = NULL;
struct connected *c; struct connected *c;
struct interface *ifp = NULL;
/* first of all get interface pointer. */
ospf = THREAD_ARG(thread);
/* prepare for next packet. */
ospf->t_read = NULL;
thread_add_read(master, ospf_read, ospf, ospf->fd, &ospf->t_read);
stream_reset(ospf->ibuf); stream_reset(ospf->ibuf);
ibuf = ospf_recv_packet(ospf, ospf->fd, &ifp, ospf->ibuf); ibuf = ospf_recv_packet(ospf, ospf->fd, &ifp, ospf->ibuf);
if (ibuf == NULL) if (ibuf == NULL)
return -1; return OSPF_READ_ERROR;
/* This raw packet is known to be at least as big as its IP header. */
/* Note that there should not be alignment problems with this assignment /*
because this is at the beginning of the stream data buffer. */ * This raw packet is known to be at least as big as its
* IP header. Note that there should not be alignment problems with
* this assignment because this is at the beginning of the
* stream data buffer.
*/
iph = (struct ip *)STREAM_DATA(ibuf); iph = (struct ip *)STREAM_DATA(ibuf);
/* Note that sockopt_iphdrincl_swab_systoh was called in /*
* ospf_recv_packet. */ * Note that sockopt_iphdrincl_swab_systoh was called in
* ospf_recv_packet.
*/
if (ifp == NULL) { if (ifp == NULL) {
/* Handle cases where the platform does not support retrieving /*
the ifindex, * Handle cases where the platform does not support
and also platforms (such as Solaris 8) that claim to support * retrieving the ifindex, and also platforms (such as
ifindex * Solaris 8) that claim to support ifindex retrieval but do
retrieval but do not. */ * not.
*/
c = if_lookup_address((void *)&iph->ip_src, AF_INET, c = if_lookup_address((void *)&iph->ip_src, AF_INET,
ospf->vrf_id); ospf->vrf_id);
if (c) if (c)
ifp = c->ifp; ifp = c->ifp;
if (ifp == NULL) if (ifp == NULL) {
return 0; if (IS_DEBUG_OSPF_PACKET(0, RECV))
zlog_debug(
"%s: Unable to determine incoming interface from: %s(%s)",
__PRETTY_FUNCTION__,
inet_ntoa(iph->ip_src),
ospf_get_name(ospf));
return OSPF_READ_CONTINUE;
}
} }
/* IP Header dump. */
if (IS_DEBUG_OSPF_PACKET(0, RECV))
ospf_ip_header_dump(iph);
/* Self-originated packet should be discarded silently. */ /* Self-originated packet should be discarded silently. */
if (ospf_if_lookup_by_local_addr(ospf, NULL, iph->ip_src)) { if (ospf_if_lookup_by_local_addr(ospf, NULL, iph->ip_src)) {
if (IS_DEBUG_OSPF_PACKET(0, RECV)) { if (IS_DEBUG_OSPF_PACKET(0, RECV)) {
@ -3000,30 +2998,32 @@ int ospf_read(struct thread *thread)
"ospf_read[%s]: Dropping self-originated packet", "ospf_read[%s]: Dropping self-originated packet",
inet_ntoa(iph->ip_src)); inet_ntoa(iph->ip_src));
} }
return 0; return OSPF_READ_CONTINUE;
} }
/* Advance from IP header to OSPF header (iph->ip_hl has been verified /*
by ospf_recv_packet() to be correct). */ * Advance from IP header to OSPF header (iph->ip_hl has
* been verified by ospf_recv_packet() to be correct).
*/
stream_forward_getp(ibuf, iph->ip_hl * 4); stream_forward_getp(ibuf, iph->ip_hl * 4);
ospfh = (struct ospf_header *)stream_pnt(ibuf); ospfh = (struct ospf_header *)stream_pnt(ibuf);
if (MSG_OK if (MSG_OK
!= ospf_packet_examin( != ospf_packet_examin(ospfh, stream_get_endp(ibuf)
ospfh, stream_get_endp(ibuf) - stream_get_getp(ibuf))) - stream_get_getp(ibuf)))
return -1; return OSPF_READ_CONTINUE;
/* Now it is safe to access all fields of OSPF packet header. */ /* Now it is safe to access all fields of OSPF packet header. */
/* associate packet with ospf interface */ /* associate packet with ospf interface */
oi = ospf_if_lookup_recv_if(ospf, iph->ip_src, ifp); oi = ospf_if_lookup_recv_if(ospf, iph->ip_src, ifp);
/* ospf_verify_header() relies on a valid "oi" and thus can be called /*
only * ospf_verify_header() relies on a valid "oi" and thus can be called
after the passive/backbone/other checks below are passed. These * only after the passive/backbone/other checks below are passed.
checks * These checks in turn access the fields of unverified "ospfh"
in turn access the fields of unverified "ospfh" structure for their * structure for their own purposes and must remain very accurate
own * in doing this.
purposes and must remain very accurate in doing this. */ */
/* If incoming interface is passive one, ignore it. */ /* If incoming interface is passive one, ignore it. */
if (oi && OSPF_IF_PASSIVE_STATUS(oi) == OSPF_IF_PASSIVE) { if (oi && OSPF_IF_PASSIVE_STATUS(oi) == OSPF_IF_PASSIVE) {
@ -3031,8 +3031,7 @@ int ospf_read(struct thread *thread)
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug( zlog_debug(
"ignoring packet from router %s sent to %s, " "ignoring packet from router %s sent to %s, received on a passive interface, %s",
"received on a passive interface, %s",
inet_ntop(AF_INET, &ospfh->router_id, buf[0], inet_ntop(AF_INET, &ospfh->router_id, buf[0],
sizeof(buf[0])), sizeof(buf[0])),
inet_ntop(AF_INET, &iph->ip_dst, buf[1], inet_ntop(AF_INET, &iph->ip_dst, buf[1],
@ -3048,7 +3047,7 @@ int ospf_read(struct thread *thread)
OI_MEMBER_JOINED(oi, MEMBER_ALLROUTERS); OI_MEMBER_JOINED(oi, MEMBER_ALLROUTERS);
ospf_if_set_multicast(oi); ospf_if_set_multicast(oi);
} }
return 0; return OSPF_READ_CONTINUE;
} }
@ -3056,34 +3055,35 @@ int ospf_read(struct thread *thread)
* or header area is backbone but ospf_interface is not * or header area is backbone but ospf_interface is not
* check for VLINK interface * check for VLINK interface
*/ */
if ((oi == NULL) || (OSPF_IS_AREA_ID_BACKBONE(ospfh->area_id) if ((oi == NULL)
&& !OSPF_IS_AREA_ID_BACKBONE(oi->area->area_id))) { || (OSPF_IS_AREA_ID_BACKBONE(ospfh->area_id)
&& !OSPF_IS_AREA_ID_BACKBONE(oi->area->area_id))) {
if ((oi = ospf_associate_packet_vl(ospf, ifp, iph, ospfh)) if ((oi = ospf_associate_packet_vl(ospf, ifp, iph, ospfh))
== NULL) { == NULL) {
if (!ospf->instance && IS_DEBUG_OSPF_EVENT) if (!ospf->instance && IS_DEBUG_OSPF_EVENT)
zlog_debug( zlog_debug(
"Packet from [%s] received on link %s" "Packet from [%s] received on link %s but no ospf_interface",
" but no ospf_interface",
inet_ntoa(iph->ip_src), ifp->name); inet_ntoa(iph->ip_src), ifp->name);
return 0; return OSPF_READ_CONTINUE;
} }
} }
/* else it must be a local ospf interface, check it was received on /*
* correct link * else it must be a local ospf interface, check it was
* received on correct link
*/ */
else if (oi->ifp != ifp) { else if (oi->ifp != ifp) {
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
flog_warn(EC_OSPF_PACKET, flog_warn(EC_OSPF_PACKET,
"Packet from [%s] received on wrong link %s", "Packet from [%s] received on wrong link %s",
inet_ntoa(iph->ip_src), ifp->name); inet_ntoa(iph->ip_src), ifp->name);
return 0; return OSPF_READ_CONTINUE;
} else if (oi->state == ISM_Down) { } else if (oi->state == ISM_Down) {
char buf[2][INET_ADDRSTRLEN]; char buf[2][INET_ADDRSTRLEN];
flog_warn( flog_warn(
EC_OSPF_PACKET, EC_OSPF_PACKET,
"Ignoring packet from %s to %s received on interface that is " "Ignoring packet from %s to %s received on interface that is down [%s]; interface flags are %s",
"down [%s]; interface flags are %s",
inet_ntop(AF_INET, &iph->ip_src, buf[0], inet_ntop(AF_INET, &iph->ip_src, buf[0],
sizeof(buf[0])), sizeof(buf[0])),
inet_ntop(AF_INET, &iph->ip_dst, buf[1], inet_ntop(AF_INET, &iph->ip_dst, buf[1],
@ -3096,13 +3096,15 @@ int ospf_read(struct thread *thread)
OI_MEMBER_JOINED(oi, MEMBER_DROUTERS); OI_MEMBER_JOINED(oi, MEMBER_DROUTERS);
if (oi->multicast_memberships) if (oi->multicast_memberships)
ospf_if_set_multicast(oi); ospf_if_set_multicast(oi);
return 0; return OSPF_READ_CONTINUE;
} }
/* /*
* If the received packet is destined for AllDRouters, the packet * If the received packet is destined for AllDRouters, the
* should be accepted only if the received ospf interface state is * packet should be accepted only if the received ospf
* either DR or Backup -- endo. * interface state is either DR or Backup -- endo.
*
* I wonder who endo is?
*/ */
if (iph->ip_dst.s_addr == htonl(OSPF_ALLDROUTERS) if (iph->ip_dst.s_addr == htonl(OSPF_ALLDROUTERS)
&& (oi->state != ISM_DR && oi->state != ISM_Backup)) { && (oi->state != ISM_DR && oi->state != ISM_Backup)) {
@ -3114,7 +3116,7 @@ int ospf_read(struct thread *thread)
/* Try to fix multicast membership. */ /* Try to fix multicast membership. */
SET_FLAG(oi->multicast_memberships, MEMBER_DROUTERS); SET_FLAG(oi->multicast_memberships, MEMBER_DROUTERS);
ospf_if_set_multicast(oi); ospf_if_set_multicast(oi);
return 0; return OSPF_READ_CONTINUE;
} }
/* Verify more OSPF header fields. */ /* Verify more OSPF header fields. */
@ -3125,7 +3127,7 @@ int ospf_read(struct thread *thread)
"ospf_read[%s]: Header check failed, " "ospf_read[%s]: Header check failed, "
"dropping.", "dropping.",
inet_ntoa(iph->ip_src)); inet_ntoa(iph->ip_src));
return ret; return OSPF_READ_CONTINUE;
} }
/* Show debug receiving packet. */ /* Show debug receiving packet. */
@ -3152,7 +3154,8 @@ int ospf_read(struct thread *thread)
/* Adjust size to message length. */ /* Adjust size to message length. */
length = ntohs(ospfh->length) - OSPF_HEADER_SIZE; length = ntohs(ospfh->length) - OSPF_HEADER_SIZE;
/* Read rest of the packet and call each sort of packet routine. */ /* Read rest of the packet and call each sort of packet routine.
*/
switch (ospfh->type) { switch (ospfh->type) {
case OSPF_MSG_HELLO: case OSPF_MSG_HELLO:
ospf_hello(iph, ospfh, ibuf, oi, length); ospf_hello(iph, ospfh, ibuf, oi, length);
@ -3170,12 +3173,41 @@ int ospf_read(struct thread *thread)
ospf_ls_ack(iph, ospfh, ibuf, oi, length); ospf_ls_ack(iph, ospfh, ibuf, oi, length);
break; break;
default: default:
flog_warn(EC_OSPF_PACKET, flog_warn(
"interface %s: OSPF packet header type %d is illegal", EC_OSPF_PACKET,
IF_NAME(oi), ospfh->type); "interface %s(%s): OSPF packet header type %d is illegal",
IF_NAME(oi), ospf_get_name(ospf), ospfh->type);
break; break;
} }
return OSPF_READ_CONTINUE;
}
/* Starting point of packet process function. */
int ospf_read(struct thread *thread)
{
struct ospf *ospf;
int32_t count = 0;
enum ospf_read_return_enum ret;
/* first of all get interface pointer. */
ospf = THREAD_ARG(thread);
/* prepare for next packet. */
thread_add_read(master, ospf_read, ospf, ospf->fd, &ospf->t_read);
while (count < ospf->write_oi_count) {
count++;
ret = ospf_read_helper(ospf);
switch (ret) {
case OSPF_READ_ERROR:
return -1;
break;
case OSPF_READ_CONTINUE:
break;
}
}
return 0; return 0;
} }

View File

@ -2173,3 +2173,11 @@ const char *ospf_vrf_id_to_name(vrf_id_t vrf_id)
return vrf ? vrf->name : "NIL"; return vrf ? vrf->name : "NIL";
} }
const char *ospf_get_name(const struct ospf *ospf)
{
if (ospf->name)
return ospf->name;
else
return VRF_DEFAULT_NAME;
}

View File

@ -572,4 +572,5 @@ extern void ospf_vrf_unlink(struct ospf *ospf, struct vrf *vrf);
const char *ospf_vrf_id_to_name(vrf_id_t vrf_id); const char *ospf_vrf_id_to_name(vrf_id_t vrf_id);
int ospf_area_nssa_no_summary_set(struct ospf *, struct in_addr); int ospf_area_nssa_no_summary_set(struct ospf *, struct in_addr);
const char *ospf_get_name(const struct ospf *ospf);
#endif /* _ZEBRA_OSPFD_H */ #endif /* _ZEBRA_OSPFD_H */