diff options
Diffstat (limited to 'ldpd/packet.c')
| -rw-r--r-- | ldpd/packet.c | 80 |
1 files changed, 33 insertions, 47 deletions
diff --git a/ldpd/packet.c b/ldpd/packet.c index 56af16d280..707878ca9f 100644 --- a/ldpd/packet.c +++ b/ldpd/packet.c @@ -28,12 +28,12 @@ static struct iface *disc_find_iface(unsigned int, int, union ldpd_addr *); -static int session_read(struct thread *); -static int session_write(struct thread *); +static void session_read(struct thread *thread); +static void session_write(struct thread *thread); static ssize_t session_get_pdu(struct ibuf_read *, char **); static void tcp_close(struct tcp_conn *); static struct pending_conn *pending_conn_new(int, int, union ldpd_addr *); -static int pending_conn_timeout(struct thread *); +static void pending_conn_timeout(struct thread *thread); int gen_ldp_hdr(struct ibuf *buf, uint16_t size) @@ -106,8 +106,7 @@ send_packet(int fd, int af, union ldpd_addr *dst, struct iface_af *ia, } /* Discovery functions */ -int -disc_recv_packet(struct thread *thread) +void disc_recv_packet(struct thread *thread) { int fd = THREAD_FD(thread); struct thread **threadp = THREAD_ARG(thread); @@ -158,7 +157,7 @@ disc_recv_packet(struct thread *thread) if (errno != EAGAIN && errno != EINTR) log_debug("%s: read error: %s", __func__, strerror(errno)); - return (0); + return; } sa2addr((struct sockaddr *)&from, &af, &src, NULL); @@ -205,7 +204,7 @@ disc_recv_packet(struct thread *thread) if (bad_addr(af, &src)) { log_debug("%s: invalid source address: %s", __func__, log_addr(af, &src)); - return (0); + return; } ifindex = getsockopt_ifindex(af, &m); @@ -213,7 +212,7 @@ disc_recv_packet(struct thread *thread) if (multicast) { iface = disc_find_iface(ifindex, af, &src); if (iface == NULL) - return (0); + return; } /* check packet size */ @@ -221,7 +220,7 @@ disc_recv_packet(struct thread *thread) if (len < (LDP_HDR_SIZE + LDP_MSG_SIZE) || len > LDP_MAX_LEN) { log_debug("%s: bad packet size, source %s", __func__, log_addr(af, &src)); - return (0); + return; } /* LDP header sanity checks */ @@ -229,12 +228,12 @@ disc_recv_packet(struct thread *thread) if (ntohs(ldp_hdr.version) != LDP_VERSION) { log_debug("%s: invalid LDP version %d, source %s", __func__, ntohs(ldp_hdr.version), log_addr(af, &src)); - return (0); + return; } if (ntohs(ldp_hdr.lspace_id) != 0) { log_debug("%s: invalid label space %u, source %s", __func__, ntohs(ldp_hdr.lspace_id), log_addr(af, &src)); - return (0); + return; } /* check "PDU Length" field */ pdu_len = ntohs(ldp_hdr.length); @@ -242,7 +241,7 @@ disc_recv_packet(struct thread *thread) (pdu_len > (len - LDP_HDR_DEAD_LEN))) { log_debug("%s: invalid LDP packet length %u, source %s", __func__, ntohs(ldp_hdr.length), log_addr(af, &src)); - return (0); + return; } buf += LDP_HDR_SIZE; len -= LDP_HDR_SIZE; @@ -261,7 +260,7 @@ disc_recv_packet(struct thread *thread) if (msg_len < LDP_MSG_LEN || ((msg_len + LDP_MSG_DEAD_LEN) > pdu_len)) { log_debug("%s: invalid LDP message length %u, source %s", __func__, ntohs(msg.length), log_addr(af, &src)); - return (0); + return; } buf += LDP_MSG_SIZE; len -= LDP_MSG_SIZE; @@ -275,8 +274,6 @@ disc_recv_packet(struct thread *thread) log_debug("%s: unknown LDP packet type, source %s", __func__, log_addr(af, &src)); } - - return (0); } static struct iface * @@ -304,8 +301,7 @@ disc_find_iface(unsigned int ifindex, int af, union ldpd_addr *src) return (iface); } -int -session_accept(struct thread *thread) +void session_accept(struct thread *thread) { int fd = THREAD_FD(thread); struct sockaddr_storage src; @@ -328,7 +324,7 @@ session_accept(struct thread *thread) errno != ECONNABORTED) log_debug("%s: accept error: %s", __func__, strerror(errno)); - return (0); + return; } sock_set_nonblock(newfd); @@ -357,22 +353,20 @@ session_accept(struct thread *thread) close(newfd); else pending_conn_new(newfd, af, &addr); - return (0); + return; } /* protection against buggy implementations */ if (nbr_session_active_role(nbr)) { close(newfd); - return (0); + return; } if (nbr->state != NBR_STA_PRESENT) { log_debug("%s: lsr-id %pI4: rejecting additional transport connection", __func__, &nbr->id); close(newfd); - return (0); + return; } session_accept_nbr(nbr, newfd); - - return (0); } void @@ -411,8 +405,7 @@ session_accept_nbr(struct nbr *nbr, int fd) nbr_fsm(nbr, NBR_EVT_MATCH_ADJ); } -static int -session_read(struct thread *thread) +static void session_read(struct thread *thread) { int fd = THREAD_FD(thread); struct nbr *nbr = THREAD_ARG(thread); @@ -431,16 +424,16 @@ session_read(struct thread *thread) if (errno != EINTR && errno != EAGAIN) { log_warn("%s: read error", __func__); nbr_fsm(nbr, NBR_EVT_CLOSE_SESSION); - return (0); + return; } /* retry read */ - return (0); + return; } if (n == 0) { /* connection closed */ log_debug("%s: connection closed by remote end", __func__); nbr_fsm(nbr, NBR_EVT_CLOSE_SESSION); - return (0); + return; } tcp->rbuf->wpos += n; @@ -450,7 +443,7 @@ session_read(struct thread *thread) if (ntohs(ldp_hdr->version) != LDP_VERSION) { session_shutdown(nbr, S_BAD_PROTO_VER, 0, 0); free(buf); - return (0); + return; } pdu_len = ntohs(ldp_hdr->length); @@ -467,14 +460,14 @@ session_read(struct thread *thread) pdu_len > max_pdu_len) { session_shutdown(nbr, S_BAD_PDU_LEN, 0, 0); free(buf); - return (0); + return; } pdu_len -= LDP_HDR_PDU_LEN; if (ldp_hdr->lsr_id != nbr->id.s_addr || ldp_hdr->lspace_id != 0) { session_shutdown(nbr, S_BAD_LDP_ID, 0, 0); free(buf); - return (0); + return; } pdu += LDP_HDR_SIZE; len -= LDP_HDR_SIZE; @@ -492,7 +485,7 @@ session_read(struct thread *thread) session_shutdown(nbr, S_BAD_MSG_LEN, msg->id, msg->type); free(buf); - return (0); + return; } msg_size = msg_len + LDP_MSG_DEAD_LEN; pdu_len -= msg_size; @@ -505,7 +498,7 @@ session_read(struct thread *thread) session_shutdown(nbr, S_SHUTDOWN, msg->id, msg->type); free(buf); - return (0); + return; } break; case MSG_TYPE_KEEPALIVE: @@ -514,7 +507,7 @@ session_read(struct thread *thread) session_shutdown(nbr, S_SHUTDOWN, msg->id, msg->type); free(buf); - return (0); + return; } break; case MSG_TYPE_NOTIFICATION: @@ -524,7 +517,7 @@ session_read(struct thread *thread) session_shutdown(nbr, S_SHUTDOWN, msg->id, msg->type); free(buf); - return (0); + return; } break; } @@ -571,7 +564,7 @@ session_read(struct thread *thread) if (ret == -1) { /* parser failed, giving up */ free(buf); - return (0); + return; } /* no errors - update per neighbor message counters */ @@ -618,7 +611,7 @@ session_read(struct thread *thread) buf = NULL; if (len != 0) { session_shutdown(nbr, S_BAD_PDU_LEN, 0, 0); - return (0); + return; } } @@ -626,11 +619,9 @@ session_read(struct thread *thread) * allocated - but let's get rid of the SA warning. */ free(buf); - return (0); } -static int -session_write(struct thread *thread) +static void session_write(struct thread *thread) { struct tcp_conn *tcp = THREAD_ARG(thread); struct nbr *nbr = tcp->nbr; @@ -647,12 +638,10 @@ session_write(struct thread *thread) * close the socket. */ tcp_close(tcp); - return (0); + return; } evbuf_event_add(&tcp->wbuf); - - return (0); } void @@ -817,8 +806,7 @@ pending_conn_find(int af, union ldpd_addr *addr) return (NULL); } -static int -pending_conn_timeout(struct thread *thread) +static void pending_conn_timeout(struct thread *thread) { struct pending_conn *pconn = THREAD_ARG(thread); struct tcp_conn *tcp; @@ -837,6 +825,4 @@ pending_conn_timeout(struct thread *thread) msgbuf_write(&tcp->wbuf.wbuf); pending_conn_del(pconn); - - return (0); } |
