mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-08 14:34:22 +00:00
ldpd: kill send_notification_nbr()
Be more clever and trigger the PDU SENT event inside send_notification() when tcp->nbr is set. This way we can eliminate send_notification_nbr() and always use send_notification() instead. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
This commit is contained in:
parent
05aac414e6
commit
adbdf4653f
@ -177,7 +177,7 @@ recv_address(struct nbr *nbr, char *buf, uint16_t len)
|
|||||||
return (0);
|
return (0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
send_notification_nbr(nbr, S_UNSUP_ADDR, msg.id, msg.type);
|
send_notification(nbr->tcp, S_UNSUP_ADDR, msg.id, msg.type);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
buf += sizeof(alt);
|
buf += sizeof(alt);
|
||||||
|
@ -118,7 +118,7 @@ recv_init(struct nbr *nbr, char *buf, uint16_t len)
|
|||||||
return (-1);
|
return (-1);
|
||||||
default:
|
default:
|
||||||
if (!(ntohs(tlv.type) & UNKNOWN_FLAG))
|
if (!(ntohs(tlv.type) & UNKNOWN_FLAG))
|
||||||
send_notification_nbr(nbr, S_UNKNOWN_TLV,
|
send_notification(nbr->tcp, S_UNKNOWN_TLV,
|
||||||
msg.id, msg.type);
|
msg.id, msg.type);
|
||||||
/* ignore unknown tlv */
|
/* ignore unknown tlv */
|
||||||
break;
|
break;
|
||||||
|
@ -163,7 +163,7 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type)
|
|||||||
|
|
||||||
memcpy(&ft, buf, sizeof(ft));
|
memcpy(&ft, buf, sizeof(ft));
|
||||||
if (ntohs(ft.type) != TLV_TYPE_FEC) {
|
if (ntohs(ft.type) != TLV_TYPE_FEC) {
|
||||||
send_notification_nbr(nbr, S_MISS_MSG, msg.id, msg.type);
|
send_notification(nbr->tcp, S_MISS_MSG, msg.id, msg.type);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
feclen = ntohs(ft.length);
|
feclen = ntohs(ft.length);
|
||||||
@ -187,7 +187,7 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type)
|
|||||||
!(map.flags & F_MAP_PW_ID) &&
|
!(map.flags & F_MAP_PW_ID) &&
|
||||||
type != MSG_TYPE_LABELWITHDRAW &&
|
type != MSG_TYPE_LABELWITHDRAW &&
|
||||||
type != MSG_TYPE_LABELRELEASE) {
|
type != MSG_TYPE_LABELRELEASE) {
|
||||||
send_notification_nbr(nbr, S_MISS_MSG, msg.id,
|
send_notification(nbr->tcp, S_MISS_MSG, msg.id,
|
||||||
msg.type);
|
msg.type);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@ -341,7 +341,7 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (!(ntohs(tlv.type) & UNKNOWN_FLAG))
|
if (!(ntohs(tlv.type) & UNKNOWN_FLAG))
|
||||||
send_notification_nbr(nbr, S_UNKNOWN_TLV,
|
send_notification(nbr->tcp, S_UNKNOWN_TLV,
|
||||||
msg.id, msg.type);
|
msg.id, msg.type);
|
||||||
/* ignore unknown tlv */
|
/* ignore unknown tlv */
|
||||||
break;
|
break;
|
||||||
@ -462,7 +462,7 @@ tlv_decode_label(struct nbr *nbr, struct ldp_msg *msg, char *buf,
|
|||||||
memcpy(<, buf, sizeof(lt));
|
memcpy(<, buf, sizeof(lt));
|
||||||
|
|
||||||
if (!(ntohs(lt.type) & TLV_TYPE_GENERICLABEL)) {
|
if (!(ntohs(lt.type) & TLV_TYPE_GENERICLABEL)) {
|
||||||
send_notification_nbr(nbr, S_MISS_MSG, msg->id, msg->type);
|
send_notification(nbr->tcp, S_MISS_MSG, msg->id, msg->type);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -642,7 +642,7 @@ tlv_decode_fec_elm(struct nbr *nbr, struct ldp_msg *msg, char *buf,
|
|||||||
map->fec.prefix.af = AF_INET6;
|
map->fec.prefix.af = AF_INET6;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
send_notification_nbr(nbr, S_UNSUP_ADDR, msg->id,
|
send_notification(nbr->tcp, S_UNSUP_ADDR, msg->id,
|
||||||
msg->type);
|
msg->type);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@ -753,7 +753,7 @@ tlv_decode_fec_elm(struct nbr *nbr, struct ldp_msg *msg, char *buf,
|
|||||||
|
|
||||||
return (off);
|
return (off);
|
||||||
default:
|
default:
|
||||||
send_notification_nbr(nbr, S_UNKNOWN_FEC, msg->id, msg->type);
|
send_notification(nbr->tcp, S_UNKNOWN_FEC, msg->id, msg->type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,9 +166,7 @@ int recv_keepalive(struct nbr *, char *, uint16_t);
|
|||||||
|
|
||||||
/* notification.c */
|
/* notification.c */
|
||||||
void send_notification_full(struct tcp_conn *, struct notify_msg *);
|
void send_notification_full(struct tcp_conn *, struct notify_msg *);
|
||||||
void send_notification(uint32_t, struct tcp_conn *, uint32_t,
|
void send_notification(struct tcp_conn *, uint32_t, uint32_t, uint16_t);
|
||||||
uint16_t);
|
|
||||||
void send_notification_nbr(struct nbr *, uint32_t, uint32_t, uint16_t);
|
|
||||||
int recv_notification(struct nbr *, char *, uint16_t);
|
int recv_notification(struct nbr *, char *, uint16_t);
|
||||||
int gen_status_tlv(struct ibuf *, uint32_t, uint32_t, uint16_t);
|
int gen_status_tlv(struct ibuf *, uint32_t, uint32_t, uint16_t);
|
||||||
|
|
||||||
|
@ -63,17 +63,19 @@ send_notification_full(struct tcp_conn *tcp, struct notify_msg *nm)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tcp->nbr)
|
if (tcp->nbr) {
|
||||||
debug_msg_send("notification: lsr-id %s status %s%s",
|
debug_msg_send("notification: lsr-id %s status %s%s",
|
||||||
inet_ntoa(tcp->nbr->id), status_code_name(nm->status_code),
|
inet_ntoa(tcp->nbr->id), status_code_name(nm->status_code),
|
||||||
(nm->status_code & STATUS_FATAL) ? " (fatal)" : "");
|
(nm->status_code & STATUS_FATAL) ? " (fatal)" : "");
|
||||||
|
nbr_fsm(tcp->nbr, NBR_EVT_PDU_SENT);
|
||||||
|
}
|
||||||
|
|
||||||
evbuf_enqueue(&tcp->wbuf, buf);
|
evbuf_enqueue(&tcp->wbuf, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* send a notification without optional tlvs */
|
/* send a notification without optional tlvs */
|
||||||
void
|
void
|
||||||
send_notification(uint32_t status_code, struct tcp_conn *tcp, uint32_t msg_id,
|
send_notification(struct tcp_conn *tcp, uint32_t status_code, uint32_t msg_id,
|
||||||
uint16_t msg_type)
|
uint16_t msg_type)
|
||||||
{
|
{
|
||||||
struct notify_msg nm;
|
struct notify_msg nm;
|
||||||
@ -86,14 +88,6 @@ send_notification(uint32_t status_code, struct tcp_conn *tcp, uint32_t msg_id,
|
|||||||
send_notification_full(tcp, &nm);
|
send_notification_full(tcp, &nm);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
send_notification_nbr(struct nbr *nbr, uint32_t status_code, uint32_t msg_id,
|
|
||||||
uint16_t msg_type)
|
|
||||||
{
|
|
||||||
send_notification(status_code, nbr->tcp, msg_id, msg_type);
|
|
||||||
nbr_fsm(nbr, NBR_EVT_PDU_SENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
recv_notification(struct nbr *nbr, char *buf, uint16_t len)
|
recv_notification(struct nbr *nbr, char *buf, uint16_t len)
|
||||||
{
|
{
|
||||||
@ -172,7 +166,7 @@ recv_notification(struct nbr *nbr, char *buf, uint16_t len)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (!(ntohs(tlv.type) & UNKNOWN_FLAG))
|
if (!(ntohs(tlv.type) & UNKNOWN_FLAG))
|
||||||
send_notification_nbr(nbr, S_UNKNOWN_TLV,
|
send_notification(nbr->tcp, S_UNKNOWN_TLV,
|
||||||
msg.id, msg.type);
|
msg.id, msg.type);
|
||||||
/* ignore unknown tlv */
|
/* ignore unknown tlv */
|
||||||
break;
|
break;
|
||||||
@ -183,7 +177,7 @@ recv_notification(struct nbr *nbr, char *buf, uint16_t len)
|
|||||||
|
|
||||||
if (nm.status_code == S_PW_STATUS) {
|
if (nm.status_code == S_PW_STATUS) {
|
||||||
if (!(nm.flags & (F_NOTIF_PW_STATUS|F_NOTIF_FEC))) {
|
if (!(nm.flags & (F_NOTIF_PW_STATUS|F_NOTIF_FEC))) {
|
||||||
send_notification_nbr(nbr, S_MISS_MSG,
|
send_notification(nbr->tcp, S_MISS_MSG,
|
||||||
msg.id, msg.type);
|
msg.id, msg.type);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@ -192,7 +186,7 @@ recv_notification(struct nbr *nbr, char *buf, uint16_t len)
|
|||||||
case MAP_TYPE_PWID:
|
case MAP_TYPE_PWID:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
send_notification_nbr(nbr, S_BAD_TLV_VAL,
|
send_notification(nbr->tcp, S_BAD_TLV_VAL,
|
||||||
msg.id, msg.type);
|
msg.id, msg.type);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
@ -564,7 +564,7 @@ session_read(struct thread *thread)
|
|||||||
log_debug("%s: unknown LDP message from nbr %s",
|
log_debug("%s: unknown LDP message from nbr %s",
|
||||||
__func__, inet_ntoa(nbr->id));
|
__func__, inet_ntoa(nbr->id));
|
||||||
if (!(ntohs(msg->type) & UNKNOWN_FLAG))
|
if (!(ntohs(msg->type) & UNKNOWN_FLAG))
|
||||||
send_notification_nbr(nbr,
|
send_notification(nbr->tcp,
|
||||||
S_UNKNOWN_MSG, msg->id, msg->type);
|
S_UNKNOWN_MSG, msg->id, msg->type);
|
||||||
/* ignore the message */
|
/* ignore the message */
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -632,7 +632,7 @@ session_shutdown(struct nbr *nbr, uint32_t status, uint32_t msg_id,
|
|||||||
case NBR_STA_OPER:
|
case NBR_STA_OPER:
|
||||||
log_debug("%s: lsr-id %s", __func__, inet_ntoa(nbr->id));
|
log_debug("%s: lsr-id %s", __func__, inet_ntoa(nbr->id));
|
||||||
|
|
||||||
send_notification_nbr(nbr, status, msg_id, msg_type);
|
send_notification(nbr->tcp, status, msg_id, msg_type);
|
||||||
|
|
||||||
nbr_fsm(nbr, NBR_EVT_CLOSE_SESSION);
|
nbr_fsm(nbr, NBR_EVT_CLOSE_SESSION);
|
||||||
break;
|
break;
|
||||||
@ -788,7 +788,7 @@ pending_conn_timeout(struct thread *thread)
|
|||||||
* notification message reliably.
|
* notification message reliably.
|
||||||
*/
|
*/
|
||||||
tcp = tcp_new(pconn->fd, NULL);
|
tcp = tcp_new(pconn->fd, NULL);
|
||||||
send_notification(S_NO_HELLO, tcp, 0, 0);
|
send_notification(tcp, S_NO_HELLO, 0, 0);
|
||||||
msgbuf_write(&tcp->wbuf.wbuf);
|
msgbuf_write(&tcp->wbuf.wbuf);
|
||||||
|
|
||||||
pending_conn_del(pconn);
|
pending_conn_del(pconn);
|
||||||
|
Loading…
Reference in New Issue
Block a user