mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-05 02:46:37 +00:00
ldpd: create helper functions to log sent/received messages
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
This commit is contained in:
parent
8afbd8942a
commit
faf757937f
@ -30,6 +30,8 @@ static int gen_address_list_tlv(struct ibuf *, uint16_t, int,
|
||||
struct if_addr_head *, unsigned int);
|
||||
static void address_list_add(struct if_addr_head *, struct if_addr *);
|
||||
static void address_list_clr(struct if_addr_head *);
|
||||
static void log_msg_address(int, uint16_t, struct nbr *, int,
|
||||
union ldpd_addr *);
|
||||
|
||||
static void
|
||||
send_address(struct nbr *nbr, int af, struct if_addr_head *addr_list,
|
||||
@ -92,9 +94,7 @@ send_address(struct nbr *nbr, int af, struct if_addr_head *addr_list,
|
||||
}
|
||||
|
||||
while ((if_addr = LIST_FIRST(addr_list)) != NULL) {
|
||||
debug_msg_send("%s: lsr-id %s address %s",
|
||||
msg_name(msg_type), inet_ntoa(nbr->id),
|
||||
log_addr(af, &if_addr->addr));
|
||||
log_msg_address(1, msg_type, nbr, af, &if_addr->addr);
|
||||
|
||||
LIST_REMOVE(if_addr, entry);
|
||||
free(if_addr);
|
||||
@ -223,8 +223,7 @@ recv_address(struct nbr *nbr, char *buf, uint16_t len)
|
||||
fatalx("recv_address: unknown af");
|
||||
}
|
||||
|
||||
debug_msg_recv("%s: lsr-id %s address %s", msg_name(msg_type),
|
||||
inet_ntoa(nbr->id), log_addr(lde_addr.af, &lde_addr.addr));
|
||||
log_msg_address(0, msg_type, nbr, lde_addr.af, &lde_addr.addr);
|
||||
|
||||
ldpe_imsg_compose_lde(type, nbr->peerid, 0, &lde_addr,
|
||||
sizeof(lde_addr));
|
||||
@ -292,3 +291,11 @@ address_list_clr(struct if_addr_head *addr_list)
|
||||
free(if_addr);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
log_msg_address(int out, uint16_t msg_type, struct nbr *nbr, int af,
|
||||
union ldpd_addr *addr)
|
||||
{
|
||||
debug_msg(out, "%s: lsr-id %s, address %s", msg_name(msg_type),
|
||||
inet_ntoa(nbr->id), log_addr(af, addr));
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ static int gen_label_tlv(struct ibuf *, uint32_t);
|
||||
static int tlv_decode_label(struct nbr *, struct ldp_msg *, char *,
|
||||
uint16_t, uint32_t *);
|
||||
static int gen_reqid_tlv(struct ibuf *, uint32_t);
|
||||
static void log_msg_mapping(int, uint16_t, struct nbr *, struct map *);
|
||||
|
||||
static void
|
||||
enqueue_pdu(struct nbr *nbr, struct ibuf *buf, uint16_t size)
|
||||
@ -124,9 +125,7 @@ send_labelmessage(struct nbr *nbr, uint16_t type, struct mapping_head *mh)
|
||||
return;
|
||||
}
|
||||
|
||||
debug_msg_send("%s: lsr-id %s fec %s label %s", msg_name(type),
|
||||
inet_ntoa(nbr->id), log_map(&me->map),
|
||||
log_label(me->map.label));
|
||||
log_msg_mapping(1, type, nbr, &me->map);
|
||||
|
||||
TAILQ_REMOVE(mh, me, entry);
|
||||
free(me);
|
||||
@ -396,9 +395,7 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type)
|
||||
if (me->map.flags & F_MAP_REQ_ID)
|
||||
me->map.requestid = reqid;
|
||||
|
||||
debug_msg_recv("%s: lsr-id %s fec %s label %s", msg_name(type),
|
||||
inet_ntoa(nbr->id), log_map(&me->map),
|
||||
log_label(me->map.label));
|
||||
log_msg_mapping(0, type, nbr, &me->map);
|
||||
|
||||
switch (type) {
|
||||
case MSG_TYPE_LABELMAPPING:
|
||||
@ -759,3 +756,10 @@ tlv_decode_fec_elm(struct nbr *nbr, struct ldp_msg *msg, char *buf,
|
||||
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static void
|
||||
log_msg_mapping(int out, uint16_t msg_type, struct nbr *nbr, struct map *map)
|
||||
{
|
||||
debug_msg(out, "%s: lsr-id %s, fec %s, label %s", msg_name(msg_type),
|
||||
inet_ntoa(nbr->id), log_map(map), log_label(map->label));
|
||||
}
|
||||
|
@ -104,6 +104,14 @@ do { \
|
||||
log_debug("msg[out]: " emsg, __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define debug_msg(out, emsg, ...) \
|
||||
do { \
|
||||
if (out) \
|
||||
debug_msg_send(emsg, __VA_ARGS__); \
|
||||
else \
|
||||
debug_msg_recv(emsg, __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define debug_kalive_recv(emsg, ...) \
|
||||
do { \
|
||||
if (LDP_DEBUG(msg, MSG_RECV_ALL)) \
|
||||
|
@ -24,6 +24,8 @@
|
||||
#include "ldpe.h"
|
||||
#include "ldp_debug.h"
|
||||
|
||||
static void log_msg_notification(int, struct nbr *, struct notify_msg *);
|
||||
|
||||
void
|
||||
send_notification_full(struct tcp_conn *tcp, struct notify_msg *nm)
|
||||
{
|
||||
@ -64,15 +66,7 @@ send_notification_full(struct tcp_conn *tcp, struct notify_msg *nm)
|
||||
}
|
||||
|
||||
if (tcp->nbr) {
|
||||
debug_msg_send("notification: lsr-id %s status %s%s",
|
||||
inet_ntoa(tcp->nbr->id), status_code_name(nm->status_code),
|
||||
(nm->status_code & STATUS_FATAL) ? " (fatal)" : "");
|
||||
if (nm->flags & F_NOTIF_FEC)
|
||||
debug_msg_send("notification: fec %s",
|
||||
log_map(&nm->fec));
|
||||
if (nm->flags & F_NOTIF_PW_STATUS)
|
||||
debug_msg_send("notification: pw-status %s",
|
||||
(nm->pw_status) ? "not forwarding" : "forwarding");
|
||||
log_msg_notification(1, tcp->nbr, nm);
|
||||
nbr_fsm(tcp->nbr, NBR_EVT_PDU_SENT);
|
||||
}
|
||||
|
||||
@ -198,14 +192,7 @@ recv_notification(struct nbr *nbr, char *buf, uint16_t len)
|
||||
}
|
||||
}
|
||||
|
||||
debug_msg_recv("notification: lsr-id %s: %s%s", inet_ntoa(nbr->id),
|
||||
status_code_name(ntohl(st.status_code)),
|
||||
(st.status_code & htonl(STATUS_FATAL)) ? " (fatal)" : "");
|
||||
if (nm.flags & F_NOTIF_FEC)
|
||||
debug_msg_recv("notification: fec %s", log_map(&nm.fec));
|
||||
if (nm.flags & F_NOTIF_PW_STATUS)
|
||||
debug_msg_recv("notification: pw-status %s",
|
||||
(nm.pw_status) ? "not forwarding" : "forwarding");
|
||||
log_msg_notification(0, nbr, &nm);
|
||||
|
||||
if (st.status_code & htonl(STATUS_FATAL)) {
|
||||
if (nbr->state == NBR_STA_OPENSENT)
|
||||
@ -241,3 +228,22 @@ gen_status_tlv(struct ibuf *buf, uint32_t status_code, uint32_t msg_id,
|
||||
|
||||
return (ibuf_add(buf, &st, STATUS_SIZE));
|
||||
}
|
||||
|
||||
void
|
||||
log_msg_notification(int out, struct nbr *nbr, struct notify_msg *nm)
|
||||
{
|
||||
if (nm->status_code & STATUS_FATAL) {
|
||||
debug_msg(out, "notification: lsr-id %s, status %s "
|
||||
"(fatal error)", inet_ntoa(nbr->id),
|
||||
status_code_name(nm->status_code));
|
||||
return;
|
||||
}
|
||||
|
||||
debug_msg(out, "notification: lsr-id %s, status %s",
|
||||
inet_ntoa(nbr->id), status_code_name(nm->status_code));
|
||||
if (nm->flags & F_NOTIF_FEC)
|
||||
debug_msg(out, "notification: fec %s", log_map(&nm->fec));
|
||||
if (nm->flags & F_NOTIF_PW_STATUS)
|
||||
debug_msg(out, "notification: pw-status %s",
|
||||
(nm->pw_status) ? "not forwarding" : "forwarding");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user