diff options
Diffstat (limited to 'ospf6d/ospf6_message.c')
| -rw-r--r-- | ospf6d/ospf6_message.c | 84 |
1 files changed, 33 insertions, 51 deletions
diff --git a/ospf6d/ospf6_message.c b/ospf6d/ospf6_message.c index 349dc50b8c..aebe43b9ec 100644 --- a/ospf6d/ospf6_message.c +++ b/ospf6d/ospf6_message.c @@ -86,13 +86,9 @@ const uint16_t ospf6_lsa_minlen[OSPF6_LSTYPE_SIZE] = { static void ospf6_header_print(struct ospf6_header *oh) { - char router_id[16], area_id[16]; - inet_ntop(AF_INET, &oh->router_id, router_id, sizeof(router_id)); - inet_ntop(AF_INET, &oh->area_id, area_id, sizeof(area_id)); - - zlog_debug(" OSPFv%d Type:%d Len:%hu Router-ID:%s", oh->version, - oh->type, ntohs(oh->length), router_id); - zlog_debug(" Area-ID:%s Cksum:%hx Instance-ID:%d", area_id, + zlog_debug(" OSPFv%d Type:%d Len:%hu Router-ID:%pI4", oh->version, + oh->type, ntohs(oh->length), &oh->router_id); + zlog_debug(" Area-ID:%pI4 Cksum:%hx Instance-ID:%d", &oh->area_id, ntohs(oh->checksum), oh->instance_id); } @@ -100,7 +96,6 @@ void ospf6_hello_print(struct ospf6_header *oh) { struct ospf6_hello *hello; char options[16]; - char drouter[16], bdrouter[16], neighbor[16]; char *p; ospf6_header_print(oh); @@ -109,8 +104,6 @@ void ospf6_hello_print(struct ospf6_header *oh) hello = (struct ospf6_hello *)((caddr_t)oh + sizeof(struct ospf6_header)); - inet_ntop(AF_INET, &hello->drouter, drouter, sizeof(drouter)); - inet_ntop(AF_INET, &hello->bdrouter, bdrouter, sizeof(bdrouter)); ospf6_options_printbuf(hello->options, options, sizeof(options)); zlog_debug(" I/F-Id:%ld Priority:%d Option:%s", @@ -118,14 +111,12 @@ void ospf6_hello_print(struct ospf6_header *oh) options); zlog_debug(" HelloInterval:%hu DeadInterval:%hu", ntohs(hello->hello_interval), ntohs(hello->dead_interval)); - zlog_debug(" DR:%s BDR:%s", drouter, bdrouter); + zlog_debug(" DR:%pI4 BDR:%pI4", &hello->drouter, &hello->bdrouter); for (p = (char *)((caddr_t)hello + sizeof(struct ospf6_hello)); p + sizeof(uint32_t) <= OSPF6_MESSAGE_END(oh); - p += sizeof(uint32_t)) { - inet_ntop(AF_INET, (void *)p, neighbor, sizeof(neighbor)); - zlog_debug(" Neighbor: %s", neighbor); - } + p += sizeof(uint32_t)) + zlog_debug(" Neighbor: %pI4", (in_addr_t *)p); assert(p == OSPF6_MESSAGE_END(oh)); } @@ -162,7 +153,6 @@ void ospf6_dbdesc_print(struct ospf6_header *oh) void ospf6_lsreq_print(struct ospf6_header *oh) { - char id[16], adv_router[16]; char *p; ospf6_header_print(oh); @@ -172,11 +162,9 @@ void ospf6_lsreq_print(struct ospf6_header *oh) p + sizeof(struct ospf6_lsreq_entry) <= OSPF6_MESSAGE_END(oh); p += sizeof(struct ospf6_lsreq_entry)) { struct ospf6_lsreq_entry *e = (struct ospf6_lsreq_entry *)p; - inet_ntop(AF_INET, &e->adv_router, adv_router, - sizeof(adv_router)); - inet_ntop(AF_INET, &e->id, id, sizeof(id)); - zlog_debug(" [%s Id:%s Adv:%s]", ospf6_lstype_name(e->type), - id, adv_router); + + zlog_debug(" [%s Id:%pI4 Adv:%pI4]", + ospf6_lstype_name(e->type), &e->id, &e->adv_router); } assert(p == OSPF6_MESSAGE_END(oh)); @@ -856,15 +844,11 @@ static void ospf6_lsreq_recv(struct in6_addr *src, struct in6_addr *dst, /* Find database copy */ lsa = ospf6_lsdb_lookup(e->type, e->id, e->adv_router, lsdb); if (lsa == NULL) { - char id[16], adv_router[16]; if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) { - inet_ntop(AF_INET, &e->id, id, sizeof(id)); - inet_ntop(AF_INET, &e->adv_router, adv_router, - sizeof(adv_router)); zlog_debug( - "Can't find requested [%s Id:%s Adv:%s]", - ospf6_lstype_name(e->type), id, - adv_router); + "Can't find requested [%s Id:%pI4 Adv:%pI4]", + ospf6_lstype_name(e->type), &e->id, + &e->adv_router); } thread_add_event(master, bad_lsreq, on, 0, NULL); return; @@ -1321,7 +1305,6 @@ static int ospf6_rxpacket_examin(struct ospf6_interface *oi, struct ospf6_header *oh, const unsigned bytesonwire) { - char buf[2][INET_ADDRSTRLEN]; if (MSG_OK != ospf6_packet_examin(oh, bytesonwire)) return MSG_NG; @@ -1335,13 +1318,10 @@ static int ospf6_rxpacket_examin(struct ospf6_interface *oi, oi->interface->name); else zlog_warn( - "VRF %s: I/F %s Area-ID mismatch (my %s, rcvd %s)", + "VRF %s: I/F %s Area-ID mismatch (my %pI4, rcvd %pI4)", vrf_id_to_name(oi->interface->vrf_id), - oi->interface->name, - inet_ntop(AF_INET, &oi->area->area_id, buf[0], - INET_ADDRSTRLEN), - inet_ntop(AF_INET, &oh->area_id, buf[1], - INET_ADDRSTRLEN)); + oi->interface->name, &oi->area->area_id, + &oh->area_id); return MSG_NG; } @@ -1356,11 +1336,9 @@ static int ospf6_rxpacket_examin(struct ospf6_interface *oi, /* Router-ID check */ if (oh->router_id == oi->area->ospf6->router_id) { - zlog_warn("VRF %s: I/F %s Duplicate Router-ID (%s)", + zlog_warn("VRF %s: I/F %s Duplicate Router-ID (%pI4)", vrf_id_to_name(oi->interface->vrf_id), - oi->interface->name, - inet_ntop(AF_INET, &oh->router_id, buf[0], - INET_ADDRSTRLEN)); + oi->interface->name, &oh->router_id); return MSG_NG; } return MSG_OK; @@ -1541,7 +1519,6 @@ int ospf6_receive(struct thread *thread) { int sockfd; unsigned int len; - char srcname[64], dstname[64]; struct in6_addr src, dst; ifindex_t ifindex; struct iovec iovector[2]; @@ -1598,13 +1575,11 @@ int ospf6_receive(struct thread *thread) /* Log */ if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) { - inet_ntop(AF_INET6, &src, srcname, sizeof(srcname)); - inet_ntop(AF_INET6, &dst, dstname, sizeof(dstname)); zlog_debug("%s received on %s", lookup_msg(ospf6_message_type_str, oh->type, NULL), oi->interface->name); - zlog_debug(" src: %s", srcname); - zlog_debug(" dst: %s", dstname); + zlog_debug(" src: %pI6", &src); + zlog_debug(" dst: %pI6", &dst); switch (oh->type) { case OSPF6_MESSAGE_TYPE_HELLO: @@ -1659,7 +1634,7 @@ static void ospf6_send(struct in6_addr *src, struct in6_addr *dst, struct ospf6_interface *oi, struct ospf6_header *oh) { unsigned int len; - char srcname[64], dstname[64]; + char srcname[64]; struct iovec iovector[2]; /* initialize */ @@ -1680,7 +1655,6 @@ static void ospf6_send(struct in6_addr *src, struct in6_addr *dst, /* Log */ if (IS_OSPF6_DEBUG_MESSAGE(oh->type, SEND)) { - inet_ntop(AF_INET6, dst, dstname, sizeof(dstname)); if (src) inet_ntop(AF_INET6, src, srcname, sizeof(srcname)); else @@ -1689,7 +1663,7 @@ static void ospf6_send(struct in6_addr *src, struct in6_addr *dst, lookup_msg(ospf6_message_type_str, oh->type, NULL), oi->interface->name); zlog_debug(" src: %s", srcname); - zlog_debug(" dst: %s", dstname); + zlog_debug(" dst: %pI6", dst); switch (oh->type) { case OSPF6_MESSAGE_TYPE_HELLO: @@ -1855,7 +1829,9 @@ int ospf6_dbdesc_send(struct thread *thread) /* MTU check */ if (p - sendbuf + sizeof(struct ospf6_lsa_header) > ospf6_packet_max(on->ospf6_if)) { - ospf6_lsdb_lsa_unlock(lsa); + ospf6_lsa_unlock(lsa); + if (lsanext) + ospf6_lsa_unlock(lsanext); break; } memcpy(p, lsa->header, sizeof(struct ospf6_lsa_header)); @@ -1902,7 +1878,9 @@ int ospf6_dbdesc_send_newone(struct thread *thread) if (size + sizeof(struct ospf6_lsa_header) > ospf6_packet_max(on->ospf6_if)) { - ospf6_lsdb_lsa_unlock(lsa); + ospf6_lsa_unlock(lsa); + if (lsanext) + ospf6_lsa_unlock(lsanext); break; } @@ -1961,7 +1939,9 @@ int ospf6_lsreq_send(struct thread *thread) /* MTU check */ if (p - sendbuf + sizeof(struct ospf6_lsreq_entry) > ospf6_packet_max(on->ospf6_if)) { - ospf6_lsdb_lsa_unlock(lsa); + ospf6_lsa_unlock(lsa); + if (lsanext) + ospf6_lsa_unlock(lsanext); break; } @@ -2422,7 +2402,9 @@ int ospf6_lsack_send_interface(struct thread *thread) thread_add_event(master, ospf6_lsack_send_interface, oi, 0, &oi->thread_send_lsack); - ospf6_lsdb_lsa_unlock(lsa); + ospf6_lsa_unlock(lsa); + if (lsanext) + ospf6_lsa_unlock(lsanext); break; } |
