summaryrefslogtreecommitdiff
path: root/ospf6d/ospf6_message.c
diff options
context:
space:
mode:
Diffstat (limited to 'ospf6d/ospf6_message.c')
-rw-r--r--ospf6d/ospf6_message.c93
1 files changed, 42 insertions, 51 deletions
diff --git a/ospf6d/ospf6_message.c b/ospf6d/ospf6_message.c
index bd180a9f55..7aedd3df45 100644
--- a/ospf6d/ospf6_message.c
+++ b/ospf6d/ospf6_message.c
@@ -49,6 +49,8 @@
#include <netinet/ip6.h>
+DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_MESSAGE, "OSPF6 message");
+
unsigned char conf_debug_ospf6_message[6] = {0x03, 0, 0, 0, 0, 0};
static const struct message ospf6_message_type_str[] = {
{OSPF6_MESSAGE_TYPE_HELLO, "Hello"},
@@ -86,13 +88,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 +98,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 +106,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 +113,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 +155,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 +164,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 +846,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 +1307,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 +1320,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 +1338,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 +1521,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 +1577,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 +1636,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 +1657,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 +1665,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 +1831,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));
@@ -1893,9 +1871,18 @@ int ospf6_dbdesc_send_newone(struct thread *thread)
so that ospf6_send_dbdesc () can send those LSAs */
size = sizeof(struct ospf6_lsa_header) + sizeof(struct ospf6_dbdesc);
for (ALL_LSDB(on->summary_list, lsa, lsanext)) {
+ /* if stub area then don't advertise AS-External LSAs */
+ if (IS_AREA_STUB(on->ospf6_if->area)
+ && ntohs(lsa->header->type) == OSPF6_LSTYPE_AS_EXTERNAL) {
+ ospf6_lsdb_remove(lsa, on->summary_list);
+ continue;
+ }
+
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;
}
@@ -1954,7 +1941,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;
}
@@ -2415,7 +2404,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;
}