summaryrefslogtreecommitdiff
path: root/ldpd/packet.c
diff options
context:
space:
mode:
Diffstat (limited to 'ldpd/packet.c')
-rw-r--r--ldpd/packet.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/ldpd/packet.c b/ldpd/packet.c
index 46893b992b..be7f2ba649 100644
--- a/ldpd/packet.c
+++ b/ldpd/packet.c
@@ -27,7 +27,7 @@
#include "sockopt.h"
static struct iface *disc_find_iface(unsigned int, int,
- union ldpd_addr *, int);
+ union ldpd_addr *);
static int session_read(struct thread *);
static int session_write(struct thread *);
static ssize_t session_get_pdu(struct ibuf_read *, char **);
@@ -134,7 +134,7 @@ disc_recv_packet(struct thread *thread)
int af;
union ldpd_addr src;
unsigned int ifindex = 0;
- struct iface *iface;
+ struct iface *iface = NULL;
uint16_t len;
struct ldp_hdr ldp_hdr;
uint16_t pdu_len;
@@ -143,7 +143,8 @@ disc_recv_packet(struct thread *thread)
struct in_addr lsr_id;
/* reschedule read */
- *threadp = thread_add_read(master, disc_recv_packet, threadp, fd);
+ *threadp = NULL;
+ thread_add_read(master, disc_recv_packet, threadp, fd, &*threadp);
/* setup buffer */
memset(&m, 0, sizeof(m));
@@ -212,9 +213,11 @@ disc_recv_packet(struct thread *thread)
ifindex = getsockopt_ifindex(af, &m);
/* find a matching interface */
- iface = disc_find_iface(ifindex, af, &src, multicast);
- if (iface == NULL)
- return (0);
+ if (multicast) {
+ iface = disc_find_iface(ifindex, af, &src);
+ if (iface == NULL)
+ return (0);
+ }
/* check packet size */
len = (uint16_t)r;
@@ -280,8 +283,7 @@ disc_recv_packet(struct thread *thread)
}
static struct iface *
-disc_find_iface(unsigned int ifindex, int af, union ldpd_addr *src,
- int multicast)
+disc_find_iface(unsigned int ifindex, int af, union ldpd_addr *src)
{
struct iface *iface;
struct iface_af *ia;
@@ -299,7 +301,7 @@ disc_find_iface(unsigned int ifindex, int af, union ldpd_addr *src,
* "Link-local IPv6 address MUST be used as the source IP address in
* IPv6 LDP Link Hellos".
*/
- if (multicast && af == AF_INET6 && !IN6_IS_ADDR_LINKLOCAL(&src->v6))
+ if (af == AF_INET6 && !IN6_IS_ADDR_LINKLOCAL(&src->v6))
return (NULL);
return (iface);
@@ -426,7 +428,8 @@ session_read(struct thread *thread)
uint16_t pdu_len, msg_len, msg_size, max_pdu_len;
int ret;
- tcp->rev = thread_add_read(master, session_read, nbr, fd);
+ tcp->rev = NULL;
+ thread_add_read(master, session_read, nbr, fd, &tcp->rev);
if ((n = read(fd, tcp->rbuf->buf + tcp->rbuf->wpos,
sizeof(tcp->rbuf->buf) - tcp->rbuf->wpos)) == -1) {
@@ -519,6 +522,8 @@ session_read(struct thread *thread)
return (0);
}
break;
+ case MSG_TYPE_NOTIFICATION:
+ break;
default:
if (nbr->state != NBR_STA_OPER) {
session_shutdown(nbr, S_SHUTDOWN,
@@ -661,8 +666,6 @@ session_shutdown(struct nbr *nbr, uint32_t status, uint32_t msg_id,
case NBR_STA_OPENREC:
case NBR_STA_OPENSENT:
case NBR_STA_OPER:
- log_debug("%s: lsr-id %s", __func__, inet_ntoa(nbr->id));
-
send_notification(nbr->tcp, status, msg_id, msg_type);
nbr_fsm(nbr, NBR_EVT_CLOSE_SESSION);
@@ -730,7 +733,8 @@ tcp_new(int fd, struct nbr *nbr)
if ((tcp->rbuf = calloc(1, sizeof(struct ibuf_read))) == NULL)
fatal(__func__);
- tcp->rev = thread_add_read(master, session_read, nbr, tcp->fd);
+ tcp->rev = NULL;
+ thread_add_read(master, session_read, nbr, tcp->fd, &tcp->rev);
tcp->nbr = nbr;
}
@@ -776,8 +780,9 @@ pending_conn_new(int fd, int af, union ldpd_addr *addr)
pconn->af = af;
pconn->addr = *addr;
TAILQ_INSERT_TAIL(&global.pending_conns, pconn, entry);
- pconn->ev_timeout = thread_add_timer(master, pending_conn_timeout,
- pconn, PENDING_CONN_TIMEOUT);
+ pconn->ev_timeout = NULL;
+ thread_add_timer(master, pending_conn_timeout, pconn, PENDING_CONN_TIMEOUT,
+ &pconn->ev_timeout);
return (pconn);
}