diff options
Diffstat (limited to 'ospfd/ospf_packet.c')
| -rw-r--r-- | ospfd/ospf_packet.c | 232 |
1 files changed, 142 insertions, 90 deletions
diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index 56b83d22d5..c4c4d2f030 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -35,7 +35,7 @@ #include "checksum.h" #include "md5.h" #include "vrf.h" -#include "ospf_errors.h" +#include "lib_errors.h" #include "ospfd/ospfd.h" #include "ospfd/ospf_network.h" @@ -50,6 +50,7 @@ #include "ospfd/ospf_spf.h" #include "ospfd/ospf_flood.h" #include "ospfd/ospf_dump.h" +#include "ospfd/ospf_errors.h" /* * OSPF Fragmentation / fragmented writes @@ -232,7 +233,7 @@ void ospf_packet_add(struct ospf_interface *oi, struct ospf_packet *op) { if (!oi->obuf) { flog_err( - OSPF_ERR_PKT_PROCESS, + EC_OSPF_PKT_PROCESS, "ospf_packet_add(interface %s in state %d [%s], packet type %s, " "destination %s) called with NULL obuf, ignoring " "(please report this bug)!\n", @@ -256,7 +257,7 @@ static void ospf_packet_add_top(struct ospf_interface *oi, { if (!oi->obuf) { flog_err( - OSPF_ERR_PKT_PROCESS, + EC_OSPF_PKT_PROCESS, "ospf_packet_add(interface %s in state %d [%s], packet type %s, " "destination %s) called with NULL obuf, ignoring " "(please report this bug)!\n", @@ -291,7 +292,7 @@ struct ospf_packet *ospf_packet_dup(struct ospf_packet *op) if (stream_get_endp(op->s) != op->length) /* XXX size_t */ - zlog_warn( + zlog_debug( "ospf_packet_dup stream %lu ospf_packet %u size mismatch", (unsigned long)STREAM_SIZE(op->s), op->length); @@ -341,8 +342,8 @@ static int ospf_check_md5_digest(struct ospf_interface *oi, ck = ospf_crypt_key_lookup(OSPF_IF_PARAM(oi, auth_crypt), ospfh->u.crypt.key_id); if (ck == NULL) { - zlog_warn("interface %s: ospf_check_md5 no key %d", IF_NAME(oi), - ospfh->u.crypt.key_id); + flog_warn(EC_OSPF_MD5, "interface %s: ospf_check_md5 no key %d", + IF_NAME(oi), ospfh->u.crypt.key_id); return 0; } @@ -351,7 +352,8 @@ static int ospf_check_md5_digest(struct ospf_interface *oi, if (nbr && ntohl(nbr->crypt_seqnum) > ntohl(ospfh->u.crypt.crypt_seqnum)) { - zlog_warn( + flog_warn( + EC_OSPF_MD5, "interface %s: ospf_check_md5 bad sequence %d (expect %d)", IF_NAME(oi), ntohl(ospfh->u.crypt.crypt_seqnum), ntohl(nbr->crypt_seqnum)); @@ -367,7 +369,8 @@ static int ospf_check_md5_digest(struct ospf_interface *oi, /* compare the two */ if (memcmp((caddr_t)ospfh + length, digest, OSPF_AUTH_MD5_SIZE)) { - zlog_warn("interface %s: ospf_check_md5 checksum mismatch", + flog_warn(EC_OSPF_MD5, + "interface %s: ospf_check_md5 checksum mismatch", IF_NAME(oi)); return 0; } @@ -433,7 +436,8 @@ static int ospf_make_md5_digest(struct ospf_interface *oi, if (stream_get_endp(op->s) != op->length) /* XXX size_t */ - zlog_warn( + flog_warn( + EC_OSPF_MD5, "ospf_make_md5_digest: length mismatch stream %lu ospf_packet %u", (unsigned long)stream_get_endp(op->s), op->length); @@ -596,7 +600,8 @@ static void ospf_write_frags(int fd, struct ospf_packet *op, struct ip *iph, sockopt_iphdrincl_swab_systoh(iph); if (ret < 0) - zlog_warn( + flog_err( + EC_LIB_SOCKET, "*** ospf_write_frags: sendmsg failed to %s," " id %d, off %d, len %d, mtu %u failed with %s", inet_ntoa(iph->ip_dst), iph->ip_id, iph->ip_off, @@ -799,7 +804,8 @@ static int ospf_write(struct thread *thread) iph.ip_len, oi->ifp->name, oi->ifp->mtu); if (ret < 0) - zlog_warn( + flog_err( + EC_LIB_SOCKET, "*** sendmsg in ospf_write failed to %s, " "id %d, off %d, len %d, interface %s, mtu %u: %s", inet_ntoa(iph.ip_dst), iph.ip_id, iph.ip_off, @@ -915,7 +921,8 @@ static void ospf_hello(struct ip *iph, struct ospf_header *ospfh, if (oi->type != OSPF_IFTYPE_POINTOPOINT && oi->type != OSPF_IFTYPE_VIRTUALLINK) if (oi->address->prefixlen != p.prefixlen) { - zlog_warn( + flog_warn( + EC_OSPF_PACKET, "Packet %s [Hello:RECV]: NetworkMask mismatch on %s (configured prefix length is %d, but hello packet indicates %d).", inet_ntoa(ospfh->router_id), IF_NAME(oi), (int)oi->address->prefixlen, (int)p.prefixlen); @@ -924,11 +931,12 @@ static void ospf_hello(struct ip *iph, struct ospf_header *ospfh, /* Compare Router Dead Interval. */ if (OSPF_IF_PARAM(oi, v_wait) != ntohl(hello->dead_interval)) { - zlog_warn( - "Packet %s [Hello:RECV]: RouterDeadInterval mismatch " - "(expected %u, but received %u).", - inet_ntoa(ospfh->router_id), OSPF_IF_PARAM(oi, v_wait), - ntohl(hello->dead_interval)); + flog_warn(EC_OSPF_PACKET, + "Packet %s [Hello:RECV]: RouterDeadInterval mismatch " + "(expected %u, but received %u).", + inet_ntoa(ospfh->router_id), + OSPF_IF_PARAM(oi, v_wait), + ntohl(hello->dead_interval)); return; } @@ -936,7 +944,8 @@ static void ospf_hello(struct ip *iph, struct ospf_header *ospfh, if (OSPF_IF_PARAM(oi, fast_hello) == 0) { if (OSPF_IF_PARAM(oi, v_hello) != ntohs(hello->hello_interval)) { - zlog_warn( + flog_warn( + EC_OSPF_PACKET, "Packet %s [Hello:RECV]: HelloInterval mismatch " "(expected %u, but received %u).", inet_ntoa(ospfh->router_id), @@ -961,7 +970,8 @@ static void ospf_hello(struct ip *iph, struct ospf_header *ospfh, * Drop this Hello packet not to establish neighbor * relationship. */ - zlog_warn("Packet %s [Hello:RECV]: T-bit on, drop it.", + flog_warn(EC_OSPF_PACKET, + "Packet %s [Hello:RECV]: T-bit on, drop it.", inet_ntoa(ospfh->router_id)); return; } @@ -973,7 +983,8 @@ static void ospf_hello(struct ip *iph, struct ospf_header *ospfh, * This router does know the correct usage of O-bit * the bit should be set in DD packet only. */ - zlog_warn("Packet %s [Hello:RECV]: O-bit abuse?", + flog_warn(EC_OSPF_PACKET, + "Packet %s [Hello:RECV]: O-bit abuse?", inet_ntoa(ospfh->router_id)); #ifdef STRICT_OBIT_USAGE_CHECK return; /* Reject this packet. */ @@ -989,7 +1000,8 @@ static void ospf_hello(struct ip *iph, struct ospf_header *ospfh, && CHECK_FLAG(hello->options, OSPF_OPTION_NP) && !CHECK_FLAG(OPTIONS(oi), OSPF_OPTION_E) && !CHECK_FLAG(hello->options, OSPF_OPTION_E))) { - zlog_warn( + flog_warn( + EC_OSPF_PACKET, "NSSA-Packet-%s[Hello:RECV]: my options: %x, his options %x", inet_ntoa(ospfh->router_id), OPTIONS(oi), hello->options); @@ -1006,7 +1018,8 @@ static void ospf_hello(struct ip *iph, struct ospf_header *ospfh, Packet's Options field should be ignored. */ if (CHECK_FLAG(OPTIONS(oi), OSPF_OPTION_E) != CHECK_FLAG(hello->options, OSPF_OPTION_E)) { - zlog_warn( + flog_warn( + EC_OSPF_PACKET, "Packet %s [Hello:RECV]: my options: %x, his options %x", inet_ntoa(ospfh->router_id), OPTIONS(oi), hello->options); @@ -1123,7 +1136,8 @@ static void ospf_db_desc_proc(struct stream *s, struct ospf_interface *oi, /* Unknown LS type. */ if (lsah->type < OSPF_MIN_LSA || lsah->type >= OSPF_MAX_LSA) { - zlog_warn("Packet [DD:RECV]: Unknown LS type %d.", + flog_warn(EC_OSPF_PACKET, + "Packet [DD:RECV]: Unknown LS type %d.", lsah->type); OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_SeqNumberMismatch); return; @@ -1131,7 +1145,8 @@ static void ospf_db_desc_proc(struct stream *s, struct ospf_interface *oi, if (IS_OPAQUE_LSA(lsah->type) && !CHECK_FLAG(nbr->options, OSPF_OPTION_O)) { - zlog_warn("LSA[Type%d:%s]: Opaque capability mismatch?", + flog_warn(EC_OSPF_PACKET, + "LSA[Type%d:%s]: Opaque capability mismatch?", lsah->type, inet_ntoa(lsah->id)); OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_SeqNumberMismatch); return; @@ -1144,7 +1159,8 @@ static void ospf_db_desc_proc(struct stream *s, struct ospf_interface *oi, but allow if from NSSA. */ if (oi->area->external_routing == OSPF_AREA_STUB) { - zlog_warn( + flog_warn( + EC_OSPF_PACKET, "Packet [DD:RECV]: LSA[Type%d:%s] from %s area.", lsah->type, inet_ntoa(lsah->id), (oi->area->external_routing @@ -1271,7 +1287,7 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh, nbr = ospf_nbr_lookup(oi, iph, ospfh); if (nbr == NULL) { - zlog_warn("Packet[DD]: Unknown Neighbor %s", + flog_warn(EC_OSPF_PACKET, "Packet[DD]: Unknown Neighbor %s", inet_ntoa(ospfh->router_id)); return; } @@ -1279,7 +1295,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh, /* Check MTU. */ if ((OSPF_IF_PARAM(oi, mtu_ignore) == 0) && (ntohs(dd->mtu) > oi->ifp->mtu)) { - zlog_warn( + flog_warn( + EC_OSPF_PACKET, "Packet[DD]: Neighbor %s MTU %u is larger than [%s]'s MTU %u", inet_ntoa(nbr->router_id), ntohs(dd->mtu), IF_NAME(oi), oi->ifp->mtu); @@ -1318,7 +1335,7 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh, * In Hello protocol, optional capability must have checked * to prevent this T-bit enabled router be my neighbor. */ - zlog_warn("Packet[DD]: Neighbor %s: T-bit on?", + flog_warn(EC_OSPF_PACKET, "Packet[DD]: Neighbor %s: T-bit on?", inet_ntoa(nbr->router_id)); return; } @@ -1342,7 +1359,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh, case NSM_Down: case NSM_Attempt: case NSM_TwoWay: - zlog_warn( + flog_warn( + EC_OSPF_PACKET, "Packet[DD]: Neighbor %s state is %s, packet discarded.", inet_ntoa(nbr->router_id), lookup_msg(ospf_nsm_state_msg, nbr->state, NULL)); @@ -1396,7 +1414,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh, /* Reset I, leaving MS */ UNSET_FLAG(nbr->dd_flags, OSPF_DD_FLAG_I); } else { - zlog_warn("Packet[DD]: Neighbor %s Negotiation fails.", + flog_warn(EC_OSPF_PACKET, + "Packet[DD]: Neighbor %s Negotiation fails.", inet_ntoa(nbr->router_id)); break; } @@ -1416,10 +1435,9 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh, if (!CHECK_FLAG(nbr->options, OSPF_OPTION_O) && IPV4_ADDR_SAME(&DR(oi), &nbr->address.u.prefix4)) { - zlog_warn( - "DR-neighbor[%s] is NOT opaque-capable; " - "Opaque-LSAs cannot be reliably advertised " - "in this network.", + flog_warn( + EC_OSPF_PACKET, + "DR-neighbor[%s] is NOT opaque-capable; Opaque-LSAs cannot be reliably advertised in this network.", inet_ntoa(nbr->router_id)); /* This situation is undesirable, but not a real * error. */ @@ -1454,7 +1472,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh, /* Check Master/Slave bit mismatch */ if (IS_SET_DD_MS(dd->flags) != IS_SET_DD_MS(nbr->last_recv.flags)) { - zlog_warn("Packet[DD]: Neighbor %s MS-bit mismatch.", + flog_warn(EC_OSPF_PACKET, + "Packet[DD]: Neighbor %s MS-bit mismatch.", inet_ntoa(nbr->router_id)); OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_SeqNumberMismatch); if (IS_DEBUG_OSPF_EVENT) @@ -1478,7 +1497,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh, /* Save the new options for debugging */ nbr->options = dd->options; #endif /* ORIGINAL_CODING */ - zlog_warn("Packet[DD]: Neighbor %s options mismatch.", + flog_warn(EC_OSPF_PACKET, + "Packet[DD]: Neighbor %s options mismatch.", inet_ntoa(nbr->router_id)); OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_SeqNumberMismatch); break; @@ -1489,7 +1509,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh, && ntohl(dd->dd_seqnum) != nbr->dd_seqnum) || (!IS_SET_DD_MS(nbr->dd_flags) && ntohl(dd->dd_seqnum) != nbr->dd_seqnum + 1)) { - zlog_warn( + flog_warn( + EC_OSPF_PACKET, "Packet[DD]: Neighbor %s sequence number mismatch.", inet_ntoa(nbr->router_id)); OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_SeqNumberMismatch); @@ -1539,7 +1560,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh, OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_SeqNumberMismatch); break; default: - zlog_warn("Packet[DD]: Neighbor %s NSM illegal status %u.", + flog_warn(EC_OSPF_PACKET, + "Packet[DD]: Neighbor %s NSM illegal status %u.", inet_ntoa(nbr->router_id), nbr->state); break; } @@ -1565,7 +1587,8 @@ static void ospf_ls_req(struct ip *iph, struct ospf_header *ospfh, nbr = ospf_nbr_lookup(oi, iph, ospfh); if (nbr == NULL) { - zlog_warn("Link State Request: Unknown Neighbor %s.", + flog_warn(EC_OSPF_PACKET, + "Link State Request: Unknown Neighbor %s.", inet_ntoa(ospfh->router_id)); return; } @@ -1576,9 +1599,9 @@ static void ospf_ls_req(struct ip *iph, struct ospf_header *ospfh, /* Neighbor State should be Exchange or later. */ if (nbr->state != NSM_Exchange && nbr->state != NSM_Loading && nbr->state != NSM_Full) { - zlog_warn( - "Link State Request received from %s: " - "Neighbor state is %s, packet discarded.", + flog_warn( + EC_OSPF_PACKET, + "Link State Request received from %s: Neighbor state is %s, packet discarded.", inet_ntoa(ospfh->router_id), lookup_msg(ospf_nsm_state_msg, nbr->state, NULL)); return; @@ -1669,7 +1692,8 @@ static struct list *ospf_ls_upd_list_lsa(struct ospf_neighbor *nbr, length = ntohs(lsah->length); if (length > size) { - zlog_warn( + flog_warn( + EC_OSPF_PACKET, "Link State Update: LSA length exceeds packet size."); break; } @@ -1683,7 +1707,8 @@ static struct list *ospf_ls_upd_list_lsa(struct ospf_neighbor *nbr, * have a better * chance to compress repeated messages in syslog on the * other */ - zlog_warn( + flog_warn( + EC_OSPF_PACKET, "Link State Update: LSA checksum error %x/%x, ID=%s from: nbr %s, router ID %s, adv router %s", sum, lsah->checksum, inet_ntoa(lsah->id), inet_ntoa(nbr->src), inet_ntoa(nbr->router_id), @@ -1693,7 +1718,8 @@ static struct list *ospf_ls_upd_list_lsa(struct ospf_neighbor *nbr, /* Examine the LSA's LS type. */ if (lsah->type < OSPF_MIN_LSA || lsah->type >= OSPF_MAX_LSA) { - zlog_warn("Link State Update: Unknown LS type %d", + flog_warn(EC_OSPF_PACKET, + "Link State Update: Unknown LS type %d", lsah->type); continue; } @@ -1717,7 +1743,8 @@ static struct list *ospf_ls_upd_list_lsa(struct ospf_neighbor *nbr, * the bit will be set in Type-9,10,11 LSAs * only. */ - zlog_warn("LSA[Type%d:%s]: O-bit abuse?", + flog_warn(EC_OSPF_PACKET, + "LSA[Type%d:%s]: O-bit abuse?", lsah->type, inet_ntoa(lsah->id)); continue; } @@ -1736,7 +1763,8 @@ static struct list *ospf_ls_upd_list_lsa(struct ospf_neighbor *nbr, continue; } } else if (IS_OPAQUE_LSA(lsah->type)) { - zlog_warn("LSA[Type%d:%s]: Opaque capability mismatch?", + flog_warn(EC_OSPF_PACKET, + "LSA[Type%d:%s]: Opaque capability mismatch?", lsah->type, inet_ntoa(lsah->id)); continue; } @@ -1806,7 +1834,8 @@ static void ospf_ls_upd(struct ospf *ospf, struct ip *iph, /* Check neighbor. */ nbr = ospf_nbr_lookup(oi, iph, ospfh); if (nbr == NULL) { - zlog_warn("Link State Update: Unknown Neighbor %s on int: %s", + flog_warn(EC_OSPF_PACKET, + "Link State Update: Unknown Neighbor %s on int: %s", inet_ntoa(ospfh->router_id), IF_NAME(oi)); return; } @@ -1917,18 +1946,18 @@ static void ospf_ls_upd(struct ospf *ospf, struct ip *iph, char buf2[INET_ADDRSTRLEN]; char buf3[INET_ADDRSTRLEN]; - flog_err(OSPF_ERR_ROUTER_LSA_MISMATCH, - "Incoming Router-LSA from %s with " - "Adv-ID[%s] != LS-ID[%s]", - inet_ntop(AF_INET, &ospfh->router_id, - buf1, INET_ADDRSTRLEN), - inet_ntop(AF_INET, &lsa->data->id, - buf2, INET_ADDRSTRLEN), - inet_ntop(AF_INET, - &lsa->data->adv_router, - buf3, INET_ADDRSTRLEN)); + flog_err(EC_OSPF_ROUTER_LSA_MISMATCH, + "Incoming Router-LSA from %s with " + "Adv-ID[%s] != LS-ID[%s]", + inet_ntop(AF_INET, &ospfh->router_id, + buf1, INET_ADDRSTRLEN), + inet_ntop(AF_INET, &lsa->data->id, + buf2, INET_ADDRSTRLEN), + inet_ntop(AF_INET, + &lsa->data->adv_router, buf3, + INET_ADDRSTRLEN)); flog_err( - OSPF_ERR_DOMAIN_CORRUPT, + EC_OSPF_DOMAIN_CORRUPT, "OSPF domain compromised by attack or corruption. " "Verify correct operation of -ALL- OSPF routers."); DISCARD_LSA(lsa, 0); @@ -1971,7 +2000,7 @@ static void ospf_ls_upd(struct ospf *ospf, struct ip *iph, * Just send an LSAck message to cease retransmission. */ if (IS_LSA_MAXAGE(lsa)) { - zlog_warn("LSA[%s]: Boomerang effect?", + zlog_info("LSA[%s]: Boomerang effect?", dump_lsa_key(lsa)); ospf_ls_ack_send(nbr, lsa); ospf_lsa_discard(lsa); @@ -2087,7 +2116,8 @@ static void ospf_ls_upd(struct ospf *ospf, struct ip *iph, if (ospf_ls_request_lookup(nbr, lsa)) { OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_BadLSReq); - zlog_warn( + flog_warn( + EC_OSPF_PACKET, "LSA[%s] instance exists on Link state request list", dump_lsa_key(lsa)); @@ -2200,7 +2230,8 @@ static void ospf_ls_ack(struct ip *iph, struct ospf_header *ospfh, nbr = ospf_nbr_lookup(oi, iph, ospfh); if (nbr == NULL) { - zlog_warn("Link State Acknowledgment: Unknown Neighbor %s.", + flog_warn(EC_OSPF_PACKET, + "Link State Acknowledgment: Unknown Neighbor %s.", inet_ntoa(ospfh->router_id)); return; } @@ -2270,12 +2301,14 @@ static struct stream *ospf_recv_packet(struct ospf *ospf, int fd, ret = stream_recvmsg(ibuf, fd, &msgh, 0, OSPF_MAX_PACKET_SIZE + 1); if (ret < 0) { - zlog_warn("stream_recvmsg failed: %s", safe_strerror(errno)); + flog_warn(EC_OSPF_PACKET, "stream_recvmsg failed: %s", + safe_strerror(errno)); return NULL; } if ((unsigned int)ret < sizeof(iph)) /* ret must be > 0 now */ { - zlog_warn( + flog_warn( + EC_OSPF_PACKET, "ospf_recv_packet: discarding runt packet of length %d " "(ip header size is %u)", ret, (unsigned int)sizeof(iph)); @@ -2321,7 +2354,8 @@ static struct stream *ospf_recv_packet(struct ospf *ospf, int fd, *ifp = if_lookup_by_index(ifindex, ospf->vrf_id); if (ret != ip_len) { - zlog_warn( + flog_warn( + EC_OSPF_PACKET, "ospf_recv_packet read length mismatch: ip_len is %d, " "but recvmsg returned %d", ip_len, ret); @@ -2427,7 +2461,8 @@ static int ospf_check_auth(struct ospf_interface *oi, struct ospf_header *ospfh) case OSPF_AUTH_NULL: /* RFC2328 D.5.1 */ if (OSPF_AUTH_NULL != (iface_auth_type = ospf_auth_type(oi))) { if (IS_DEBUG_OSPF_PACKET(ospfh->type - 1, RECV)) - zlog_warn( + flog_warn( + EC_OSPF_PACKET, "interface %s: auth-type mismatch, local %s, rcvd Null", IF_NAME(oi), lookup_msg(ospf_auth_type_str, @@ -2436,7 +2471,8 @@ static int ospf_check_auth(struct ospf_interface *oi, struct ospf_header *ospfh) } if (!ospf_check_sum(ospfh)) { if (IS_DEBUG_OSPF_PACKET(ospfh->type - 1, RECV)) - zlog_warn( + flog_warn( + EC_OSPF_PACKET, "interface %s: Null auth OK, but checksum error, Router-ID %s", IF_NAME(oi), inet_ntoa(ospfh->router_id)); @@ -2447,7 +2483,8 @@ static int ospf_check_auth(struct ospf_interface *oi, struct ospf_header *ospfh) if (OSPF_AUTH_SIMPLE != (iface_auth_type = ospf_auth_type(oi))) { if (IS_DEBUG_OSPF_PACKET(ospfh->type - 1, RECV)) - zlog_warn( + flog_warn( + EC_OSPF_PACKET, "interface %s: auth-type mismatch, local %s, rcvd Simple", IF_NAME(oi), lookup_msg(ospf_auth_type_str, @@ -2457,13 +2494,15 @@ static int ospf_check_auth(struct ospf_interface *oi, struct ospf_header *ospfh) if (memcmp(OSPF_IF_PARAM(oi, auth_simple), ospfh->u.auth_data, OSPF_AUTH_SIMPLE_SIZE)) { if (IS_DEBUG_OSPF_PACKET(ospfh->type - 1, RECV)) - zlog_warn("interface %s: Simple auth failed", + flog_warn(EC_OSPF_PACKET, + "interface %s: Simple auth failed", IF_NAME(oi)); return 0; } if (!ospf_check_sum(ospfh)) { if (IS_DEBUG_OSPF_PACKET(ospfh->type - 1, RECV)) - zlog_warn( + flog_warn( + EC_OSPF_PACKET, "interface %s: Simple auth OK, checksum error, Router-ID %s", IF_NAME(oi), inet_ntoa(ospfh->router_id)); @@ -2474,7 +2513,8 @@ static int ospf_check_auth(struct ospf_interface *oi, struct ospf_header *ospfh) if (OSPF_AUTH_CRYPTOGRAPHIC != (iface_auth_type = ospf_auth_type(oi))) { if (IS_DEBUG_OSPF_PACKET(ospfh->type - 1, RECV)) - zlog_warn( + flog_warn( + EC_OSPF_PACKET, "interface %s: auth-type mismatch, local %s, rcvd Cryptographic", IF_NAME(oi), lookup_msg(ospf_auth_type_str, @@ -2483,7 +2523,8 @@ static int ospf_check_auth(struct ospf_interface *oi, struct ospf_header *ospfh) } if (ospfh->checksum) { if (IS_DEBUG_OSPF_PACKET(ospfh->type - 1, RECV)) - zlog_warn( + flog_warn( + EC_OSPF_PACKET, "interface %s: OSPF header checksum is not 0", IF_NAME(oi)); return 0; @@ -2498,14 +2539,16 @@ static int ospf_check_auth(struct ospf_interface *oi, struct ospf_header *ospfh) bug? */ !ospf_check_md5_digest(oi, ospfh)) { if (IS_DEBUG_OSPF_PACKET(ospfh->type - 1, RECV)) - zlog_warn("interface %s: MD5 auth failed", + flog_warn(EC_OSPF_MD5, + "interface %s: MD5 auth failed", IF_NAME(oi)); return 0; } return 1; default: if (IS_DEBUG_OSPF_PACKET(ospfh->type - 1, RECV)) - zlog_warn( + flog_warn( + EC_OSPF_PACKET, "interface %s: invalid packet auth-type (%02x)", IF_NAME(oi), pkt_auth_type); return 0; @@ -2854,14 +2897,16 @@ static int ospf_verify_header(struct stream *ibuf, struct ospf_interface *oi, { /* Check Area ID. */ if (!ospf_check_area_id(oi, ospfh)) { - zlog_warn("interface %s: ospf_read invalid Area ID %s.", + flog_warn(EC_OSPF_PACKET, + "interface %s: ospf_read invalid Area ID %s.", IF_NAME(oi), inet_ntoa(ospfh->area_id)); return -1; } /* Check network mask, Silently discarded. */ if (!ospf_check_network_mask(oi, iph->ip_src)) { - zlog_warn( + flog_warn( + EC_OSPF_PACKET, "interface %s: ospf_read network address is not same [%s]", IF_NAME(oi), inet_ntoa(iph->ip_src)); return -1; @@ -3006,12 +3051,14 @@ int ospf_read(struct thread *thread) */ else if (oi->ifp != ifp) { if (IS_DEBUG_OSPF_EVENT) - zlog_warn("Packet from [%s] received on wrong link %s", + flog_warn(EC_OSPF_PACKET, + "Packet from [%s] received on wrong link %s", inet_ntoa(iph->ip_src), ifp->name); return 0; } else if (oi->state == ISM_Down) { char buf[2][INET_ADDRSTRLEN]; - zlog_warn( + flog_warn( + EC_OSPF_PACKET, "Ignoring packet from %s to %s received on interface that is " "down [%s]; interface flags are %s", inet_ntop(AF_INET, &iph->ip_src, buf[0], @@ -3036,7 +3083,8 @@ int ospf_read(struct thread *thread) */ if (iph->ip_dst.s_addr == htonl(OSPF_ALLDROUTERS) && (oi->state != ISM_DR && oi->state != ISM_Backup)) { - zlog_warn( + flog_warn( + EC_OSPF_PACKET, "Dropping packet for AllDRouters from [%s] via [%s] (ISM: %s)", inet_ntoa(iph->ip_src), IF_NAME(oi), lookup_msg(ospf_ism_state_msg, oi->state, NULL)); @@ -3099,7 +3147,8 @@ int ospf_read(struct thread *thread) ospf_ls_ack(iph, ospfh, ibuf, oi, length); break; default: - zlog_warn("interface %s: OSPF packet header type %d is illegal", + flog_warn(EC_OSPF_PACKET, + "interface %s: OSPF packet header type %d is illegal", IF_NAME(oi), ospfh->type); break; } @@ -3830,7 +3879,8 @@ static struct ospf_packet *ospf_ls_upd_packet_new(struct list *update, if ((OSPF_LS_UPD_MIN_SIZE + ntohs(lsa->data->length)) > ospf_packet_max(oi)) { if (!warned) { - zlog_warn( + flog_warn( + EC_OSPF_LARGE_LSA, "ospf_ls_upd_packet_new: oversized LSA encountered!" "will need to fragment. Not optimal. Try divide up" " your network with areas. Use 'debug ospf packet send'" @@ -3858,12 +3908,12 @@ static struct ospf_packet *ospf_ls_upd_packet_new(struct list *update, size = oi->ifp->mtu; if (size > OSPF_MAX_PACKET_SIZE) { - zlog_warn( - "ospf_ls_upd_packet_new: oversized LSA id:%s too big," - " %d bytes, packet size %ld, dropping it completely." - " OSPF routing is broken!", - inet_ntoa(lsa->data->id), ntohs(lsa->data->length), - (long int)size); + flog_warn(EC_OSPF_LARGE_LSA, + "ospf_ls_upd_packet_new: oversized LSA id:%s too big," + " %d bytes, packet size %ld, dropping it completely." + " OSPF routing is broken!", + inet_ntoa(lsa->data->id), ntohs(lsa->data->length), + (long int)size); list_delete_node(update, ln); return NULL; } @@ -4019,10 +4069,12 @@ void ospf_ls_upd_send(struct ospf_neighbor *nbr, struct list *update, int flag, if (oi->type == OSPF_IFTYPE_NBMA) { if (flag == OSPF_SEND_PACKET_INDIRECT) - zlog_warn( + flog_warn( + EC_OSPF_PACKET, "* LS-Update is directly sent on NBMA network."); if (IPV4_ADDR_SAME(&oi->address->u.prefix4, &p.prefix)) - zlog_warn("* LS-Update is sent to myself."); + flog_warn(EC_OSPF_PACKET, + "* LS-Update is sent to myself."); } rn = route_node_get(oi->ls_upd_queue, (struct prefix *)&p); @@ -4037,7 +4089,7 @@ void ospf_ls_upd_send(struct ospf_neighbor *nbr, struct list *update, int flag, ospf_lsa_lock(lsa)); /* oi->ls_upd_queue */ if (send_lsupd_now) { struct list *send_update_list; - struct route_node *rn, *rnext; + struct route_node *rnext; for (rn = route_top(oi->ls_upd_queue); rn; rn = rnext) { rnext = route_next(rn); |
