diff options
author | Renato Westphal <renato@cvs.openbsd.org> | 2016-07-01 23:29:56 +0000 |
---|---|---|
committer | Renato Westphal <renato@cvs.openbsd.org> | 2016-07-01 23:29:56 +0000 |
commit | 2d65c4f7cd8db7125bb35dfe33fffd414d78888d (patch) | |
tree | b5b0b30b53123c4f47b94ac584b9dd4083e71c4a | |
parent | 78bebcb80236c6dddb7e534dd064346d688f08e6 (diff) |
Several minor tweaks.
-rw-r--r-- | usr.sbin/ldpd/address.c | 4 | ||||
-rw-r--r-- | usr.sbin/ldpd/hello.c | 4 | ||||
-rw-r--r-- | usr.sbin/ldpd/init.c | 18 | ||||
-rw-r--r-- | usr.sbin/ldpd/interface.c | 30 | ||||
-rw-r--r-- | usr.sbin/ldpd/labelmapping.c | 23 | ||||
-rw-r--r-- | usr.sbin/ldpd/lde_lib.c | 18 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpd.c | 7 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpd.conf.5 | 4 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpe.h | 4 | ||||
-rw-r--r-- | usr.sbin/ldpd/neighbor.c | 4 | ||||
-rw-r--r-- | usr.sbin/ldpd/notification.c | 10 | ||||
-rw-r--r-- | usr.sbin/ldpd/packet.c | 7 | ||||
-rw-r--r-- | usr.sbin/ldpd/socket.c | 4 |
13 files changed, 65 insertions, 72 deletions
diff --git a/usr.sbin/ldpd/address.c b/usr.sbin/ldpd/address.c index fe2e174046d..dec38cff901 100644 --- a/usr.sbin/ldpd/address.c +++ b/usr.sbin/ldpd/address.c @@ -1,4 +1,4 @@ -/* $OpenBSD: address.c,v 1.26 2016/06/27 19:06:33 renato Exp $ */ +/* $OpenBSD: address.c,v 1.27 2016/07/01 23:29:55 renato Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -163,7 +163,7 @@ recv_address(struct nbr *nbr, char *buf, uint16_t len) fatalx("recv_address: unknown af"); } - log_debug("%s: neighbor ID %s address %s%s", __func__, + log_debug("%s: lsr-id %s address %s%s", __func__, inet_ntoa(nbr->id), log_addr(lde_addr.af, &lde_addr.addr), ntohs(addr.type) == MSG_TYPE_ADDR ? "" : " (withdraw)"); diff --git a/usr.sbin/ldpd/hello.c b/usr.sbin/ldpd/hello.c index cfe6415a928..71d5f485d14 100644 --- a/usr.sbin/ldpd/hello.c +++ b/usr.sbin/ldpd/hello.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hello.c,v 1.54 2016/07/01 23:18:24 renato Exp $ */ +/* $OpenBSD: hello.c,v 1.55 2016/07/01 23:29:55 renato Exp $ */ /* * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org> @@ -233,7 +233,7 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *lm, int af, /* * RFC 7552 - Section 5.2: * "The link-local IPv6 addresses MUST NOT be used as the - * targeted LDP Hello packet's source or destination addresses. + * targeted LDP Hello packet's source or destination addresses". */ if (af == AF_INET6 && IN6_IS_SCOPE_EMBED(&src->v6)) { log_debug("%s: lsr-id %s: targeted hello with " diff --git a/usr.sbin/ldpd/init.c b/usr.sbin/ldpd/init.c index c6039cc2e19..819dd14086c 100644 --- a/usr.sbin/ldpd/init.c +++ b/usr.sbin/ldpd/init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init.c,v 1.30 2016/06/27 19:06:33 renato Exp $ */ +/* $OpenBSD: init.c,v 1.31 2016/07/01 23:29:55 renato Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -24,7 +24,7 @@ #include "ldpe.h" #include "log.h" -static int gen_init_prms_tlv(struct ibuf *, struct nbr *, uint16_t); +static int gen_init_prms_tlv(struct ibuf *, struct nbr *); static int tlv_decode_opt_init_prms(char *, uint16_t); void @@ -44,7 +44,7 @@ send_init(struct nbr *nbr) size -= LDP_HDR_SIZE; err |= gen_msg_hdr(buf, MSG_TYPE_INIT, size); size -= LDP_MSG_SIZE; - err |= gen_init_prms_tlv(buf, nbr, size); + err |= gen_init_prms_tlv(buf, nbr); if (err) { ibuf_free(buf); return; @@ -72,10 +72,6 @@ recv_init(struct nbr *nbr, char *buf, uint16_t len) return (-1); } memcpy(&sess, buf, sizeof(sess)); - if (ntohs(sess.keepalive_time) < MIN_KEEPALIVE) { - session_shutdown(nbr, S_KEEPALIVE_BAD, init.msgid, init.type); - return (-1); - } if (ntohs(sess.length) != SESS_PRMS_SIZE - TLV_HDR_LEN) { session_shutdown(nbr, S_BAD_TLV_LEN, init.msgid, init.type); return (-1); @@ -84,6 +80,10 @@ recv_init(struct nbr *nbr, char *buf, uint16_t len) session_shutdown(nbr, S_BAD_PROTO_VER, init.msgid, init.type); return (-1); } + if (ntohs(sess.keepalive_time) < MIN_KEEPALIVE) { + session_shutdown(nbr, S_KEEPALIVE_BAD, init.msgid, init.type); + return (-1); + } if (sess.lsr_id != leconf->rtr_id.s_addr || ntohs(sess.lspace_id) != 0) { session_shutdown(nbr, S_NO_HELLO, init.msgid, init.type); @@ -119,13 +119,13 @@ recv_init(struct nbr *nbr, char *buf, uint16_t len) } static int -gen_init_prms_tlv(struct ibuf *buf, struct nbr *nbr, uint16_t size) +gen_init_prms_tlv(struct ibuf *buf, struct nbr *nbr) { struct sess_prms_tlv parms; memset(&parms, 0, sizeof(parms)); parms.type = htons(TLV_TYPE_COMMONSESSION); - parms.length = htons(size - TLV_HDR_LEN); + parms.length = htons(SESS_PRMS_SIZE - TLV_HDR_LEN); parms.proto_version = htons(LDP_VERSION); parms.keepalive_time = htons(nbr_get_keepalive(nbr->af, nbr->id)); parms.reserved = 0; diff --git a/usr.sbin/ldpd/interface.c b/usr.sbin/ldpd/interface.c index 98c846bb31d..8ce9598b4cc 100644 --- a/usr.sbin/ldpd/interface.c +++ b/usr.sbin/ldpd/interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interface.c,v 1.46 2016/06/18 17:31:32 renato Exp $ */ +/* $OpenBSD: interface.c,v 1.47 2016/07/01 23:29:55 renato Exp $ */ /* * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org> @@ -82,8 +82,20 @@ if_new(struct kif *kif) return (iface); } +struct iface * +if_lookup(struct ldpd_conf *xconf, unsigned short ifindex) +{ + struct iface *iface; + + LIST_FOREACH(iface, &xconf->iface_list, entry) + if (iface->ifindex == ifindex) + return (iface); + + return (NULL); +} + void -if_del(struct iface *iface) +if_exit(struct iface *iface) { struct if_addr *if_addr; @@ -98,20 +110,6 @@ if_del(struct iface *iface) LIST_REMOVE(if_addr, entry); free(if_addr); } - - free(iface); -} - -struct iface * -if_lookup(struct ldpd_conf *xconf, unsigned short ifindex) -{ - struct iface *iface; - - LIST_FOREACH(iface, &xconf->iface_list, entry) - if (iface->ifindex == ifindex) - return (iface); - - return (NULL); } struct iface_af * diff --git a/usr.sbin/ldpd/labelmapping.c b/usr.sbin/ldpd/labelmapping.c index c901ea37ee1..43dc7a0c32b 100644 --- a/usr.sbin/ldpd/labelmapping.c +++ b/usr.sbin/ldpd/labelmapping.c @@ -1,4 +1,4 @@ -/* $OpenBSD: labelmapping.c,v 1.52 2016/06/27 19:06:33 renato Exp $ */ +/* $OpenBSD: labelmapping.c,v 1.53 2016/07/01 23:29:55 renato Exp $ */ /* * Copyright (c) 2014, 2015 Renato Westphal <renato@openbsd.org> @@ -382,28 +382,28 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type) switch (type) { case MSG_TYPE_LABELMAPPING: - log_debug("label mapping from nbr %s, FEC %s, " + log_debug("label mapping from lsr-id %s, FEC %s, " "label %u", inet_ntoa(nbr->id), log_map(&me->map), me->map.label); imsg_type = IMSG_LABEL_MAPPING; break; case MSG_TYPE_LABELREQUEST: - log_debug("label request from nbr %s, FEC %s", + log_debug("label request from lsr-id %s, FEC %s", inet_ntoa(nbr->id), log_map(&me->map)); imsg_type = IMSG_LABEL_REQUEST; break; case MSG_TYPE_LABELWITHDRAW: - log_debug("label withdraw from nbr %s, FEC %s", + log_debug("label withdraw from lsr-id %s, FEC %s", inet_ntoa(nbr->id), log_map(&me->map)); imsg_type = IMSG_LABEL_WITHDRAW; break; case MSG_TYPE_LABELRELEASE: - log_debug("label release from nbr %s, FEC %s", + log_debug("label release from lsr-id %s, FEC %s", inet_ntoa(nbr->id), log_map(&me->map)); imsg_type = IMSG_LABEL_RELEASE; break; case MSG_TYPE_LABELABORTREQ: - log_debug("label abort from nbr %s, FEC %s", + log_debug("label abort from lsr-id %s, FEC %s", inet_ntoa(nbr->id), log_map(&me->map)); imsg_type = IMSG_LABEL_ABORT; break; @@ -697,9 +697,6 @@ tlv_decode_fec_elm(struct nbr *nbr, struct ldp_msg *lm, char *buf, } memcpy(&stlv, buf + off, sizeof(stlv)); - off += SUBTLV_HDR_LEN; - pw_len -= SUBTLV_HDR_LEN; - switch (stlv.type) { case SUBTLV_IFMTU: if (stlv.length != FEC_SUBTLV_IFMTU_LEN) { @@ -707,8 +704,8 @@ tlv_decode_fec_elm(struct nbr *nbr, struct ldp_msg *lm, char *buf, lm->msgid, lm->type); return (-1); } - memcpy(&map->fec.pwid.ifmtu, buf + off, - sizeof(uint16_t)); + memcpy(&map->fec.pwid.ifmtu, buf + off + + SUBTLV_HDR_LEN, sizeof(uint16_t)); map->fec.pwid.ifmtu = ntohs(map->fec.pwid.ifmtu); map->flags |= F_MAP_PW_IFMTU; break; @@ -716,8 +713,8 @@ tlv_decode_fec_elm(struct nbr *nbr, struct ldp_msg *lm, char *buf, /* ignore */ break; } - off += stlv.length - SUBTLV_HDR_LEN; - pw_len -= stlv.length - SUBTLV_HDR_LEN; + off += stlv.length; + pw_len -= stlv.length; } return (off); diff --git a/usr.sbin/ldpd/lde_lib.c b/usr.sbin/ldpd/lde_lib.c index 36fa4a6f022..ac99fbd7e37 100644 --- a/usr.sbin/ldpd/lde_lib.c +++ b/usr.sbin/ldpd/lde_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lde_lib.c,v 1.61 2016/06/18 01:29:05 renato Exp $ */ +/* $OpenBSD: lde_lib.c,v 1.62 2016/07/01 23:29:55 renato Exp $ */ /* * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org> @@ -309,18 +309,18 @@ egress_label(enum fec_type fec_type) { switch (fec_type) { case FEC_TYPE_IPV4: - if (!(ldeconf->ipv4.flags & F_LDPD_AF_EXPNULL)) - return (MPLS_LABEL_IMPLNULL); - return (MPLS_LABEL_IPV4NULL); + if (ldeconf->ipv4.flags & F_LDPD_AF_EXPNULL) + return (MPLS_LABEL_IPV4NULL); + break; case FEC_TYPE_IPV6: - if (!(ldeconf->ipv6.flags & F_LDPD_AF_EXPNULL)) - return (MPLS_LABEL_IMPLNULL); - return (MPLS_LABEL_IPV6NULL); + if (ldeconf->ipv6.flags & F_LDPD_AF_EXPNULL) + return (MPLS_LABEL_IPV6NULL); + break; default: - log_warnx("%s: unexpected fec type", __func__); + fatalx("egress_label: unexpected fec type"); } - return (NO_LABEL); + return (MPLS_LABEL_IMPLNULL); } void diff --git a/usr.sbin/ldpd/ldpd.c b/usr.sbin/ldpd/ldpd.c index e2bc9d9a14b..51ef17dc5ec 100644 --- a/usr.sbin/ldpd/ldpd.c +++ b/usr.sbin/ldpd/ldpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpd.c,v 1.55 2016/07/01 23:14:31 renato Exp $ */ +/* $OpenBSD: ldpd.c,v 1.56 2016/07/01 23:29:55 renato Exp $ */ /* * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org> @@ -880,9 +880,8 @@ merge_ifaces(struct ldpd_conf *conf, struct ldpd_conf *xconf) if ((xi = if_lookup(xconf, iface->ifindex)) == NULL) { LIST_REMOVE(iface, entry); if (ldpd_process == PROC_LDP_ENGINE) - if_del(iface); - else - free(iface); + if_exit(iface); + free(iface); } } LIST_FOREACH_SAFE(xi, &xconf->iface_list, entry, itmp) { diff --git a/usr.sbin/ldpd/ldpd.conf.5 b/usr.sbin/ldpd/ldpd.conf.5 index 686e3ccfc6d..57ee2660968 100644 --- a/usr.sbin/ldpd/ldpd.conf.5 +++ b/usr.sbin/ldpd/ldpd.conf.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ldpd.conf.5,v 1.30 2016/07/01 23:14:31 renato Exp $ +.\" $OpenBSD: ldpd.conf.5,v 1.31 2016/07/01 23:29:55 renato Exp $ .\" .\" Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org> .\" Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -260,7 +260,7 @@ Neighbor-specific parameters are listed below. .It Ic keepalive Ar seconds Set the keepalive timeout in seconds. Inherited from the global configuration if not given. -The default value is 180; valid range is 3\-65535. +Valid range is 3\-65535. .It Xo .Ic gtsm-enable .Pq Ic yes Ns | Ns Ic no diff --git a/usr.sbin/ldpd/ldpe.h b/usr.sbin/ldpd/ldpe.h index ac0a285f8b7..4d9d77dfc57 100644 --- a/usr.sbin/ldpd/ldpe.h +++ b/usr.sbin/ldpd/ldpe.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpe.h,v 1.64 2016/07/01 23:14:31 renato Exp $ */ +/* $OpenBSD: ldpe.h,v 1.65 2016/07/01 23:29:55 renato Exp $ */ /* * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org> @@ -196,7 +196,7 @@ void mapping_list_clr(struct mapping_head *); /* interface.c */ struct iface *if_new(struct kif *); -void if_del(struct iface *); +void if_exit(struct iface *); struct iface *if_lookup(struct ldpd_conf *, unsigned short); struct iface_af *iface_af_get(struct iface *, int); void if_addr_add(struct kaddr *); diff --git a/usr.sbin/ldpd/neighbor.c b/usr.sbin/ldpd/neighbor.c index ef50fa8e64e..d58bf032bfa 100644 --- a/usr.sbin/ldpd/neighbor.c +++ b/usr.sbin/ldpd/neighbor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: neighbor.c,v 1.76 2016/07/01 23:22:42 renato Exp $ */ +/* $OpenBSD: neighbor.c,v 1.77 2016/07/01 23:29:55 renato Exp $ */ /* * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org> @@ -68,7 +68,9 @@ struct { {NBR_STA_OPENSENT, NBR_EVT_INIT_RCVD, NBR_ACT_KEEPALIVE_SEND, NBR_STA_OPENREC}, /* Session Maintenance */ {NBR_STA_OPER, NBR_EVT_PDU_RCVD, NBR_ACT_RST_KTIMEOUT, 0}, + {NBR_STA_SESSION, NBR_EVT_PDU_RCVD, NBR_ACT_NOTHING, 0}, {NBR_STA_OPER, NBR_EVT_PDU_SENT, NBR_ACT_RST_KTIMER, 0}, + {NBR_STA_SESSION, NBR_EVT_PDU_SENT, NBR_ACT_NOTHING, 0}, /* Session Close */ {NBR_STA_PRESENT, NBR_EVT_CLOSE_SESSION, NBR_ACT_NOTHING, 0}, {NBR_STA_SESSION, NBR_EVT_CLOSE_SESSION, NBR_ACT_CLOSE_SESSION, NBR_STA_PRESENT}, diff --git a/usr.sbin/ldpd/notification.c b/usr.sbin/ldpd/notification.c index e6c9cc92825..6c290ceaa82 100644 --- a/usr.sbin/ldpd/notification.c +++ b/usr.sbin/ldpd/notification.c @@ -1,4 +1,4 @@ -/* $OpenBSD: notification.c,v 1.36 2016/06/27 19:06:33 renato Exp $ */ +/* $OpenBSD: notification.c,v 1.37 2016/07/01 23:29:55 renato Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -25,7 +25,7 @@ #include "log.h" #include "ldpe.h" -static int gen_status_tlv(struct ibuf *, uint32_t, uint32_t, uint32_t); +static int gen_status_tlv(struct ibuf *, uint32_t, uint32_t, uint16_t); void send_notification_full(struct tcp_conn *tcp, struct notify_msg *nm) @@ -198,11 +198,11 @@ recv_notification(struct nbr *nbr, char *buf, uint16_t len) } if (st.status_code & htonl(STATUS_FATAL)) - log_warnx("received notification from neighbor %s: %s", + log_warnx("received notification from lsr-id %s: %s", inet_ntoa(nbr->id), notification_name(ntohl(st.status_code))); else - log_debug("received non-fatal notification from neighbor " + log_debug("received non-fatal notification from lsr-id " "%s: %s", inet_ntoa(nbr->id), notification_name(ntohl(st.status_code))); @@ -222,7 +222,7 @@ recv_notification(struct nbr *nbr, char *buf, uint16_t len) } static int -gen_status_tlv(struct ibuf *buf, uint32_t status, uint32_t msgid, uint32_t type) +gen_status_tlv(struct ibuf *buf, uint32_t status, uint32_t msgid, uint16_t type) { struct status_tlv st; diff --git a/usr.sbin/ldpd/packet.c b/usr.sbin/ldpd/packet.c index ababd18b7ba..fa3f1941c60 100644 --- a/usr.sbin/ldpd/packet.c +++ b/usr.sbin/ldpd/packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.65 2016/07/01 23:14:31 renato Exp $ */ +/* $OpenBSD: packet.c,v 1.66 2016/07/01 23:29:55 renato Exp $ */ /* * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org> @@ -472,19 +472,16 @@ session_read(int fd, short event, void *arg) 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; } - pdu += LDP_HDR_SIZE; len -= LDP_HDR_SIZE; - if (nbr->state == NBR_STA_OPER) - nbr_fsm(nbr, NBR_EVT_PDU_RCVD); + nbr_fsm(nbr, NBR_EVT_PDU_RCVD); while (len >= LDP_MSG_SIZE) { uint16_t type; diff --git a/usr.sbin/ldpd/socket.c b/usr.sbin/ldpd/socket.c index 039241a6fb2..e161099426b 100644 --- a/usr.sbin/ldpd/socket.c +++ b/usr.sbin/ldpd/socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: socket.c,v 1.8 2016/07/01 23:14:31 renato Exp $ */ +/* $OpenBSD: socket.c,v 1.9 2016/07/01 23:29:55 renato Exp $ */ /* * Copyright (c) 2016 Renato Westphal <renato@openbsd.org> @@ -382,7 +382,7 @@ sock_set_ipv6_mcast_loop(int fd) unsigned int loop = 0; if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, - (unsigned int *)&loop, sizeof(loop)) < 0) { + &loop, sizeof(loop)) < 0) { log_warn("%s: error setting IPV6_MULTICAST_LOOP", __func__); return (-1); } |