-/* $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>
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)");
-/* $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>
/*
* 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 "
-/* $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>
#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
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;
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);
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);
}
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;
-/* $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>
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;
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 *
-/* $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>
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;
}
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) {
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;
/* ignore */
break;
}
- off += stlv.length - SUBTLV_HDR_LEN;
- pw_len -= stlv.length - SUBTLV_HDR_LEN;
+ off += stlv.length;
+ pw_len -= stlv.length;
}
return (off);
-/* $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>
{
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
-/* $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>
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) {
-.\" $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>
.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
-/* $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>
/* 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 *);
-/* $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>
{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},
-/* $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>
#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)
}
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)));
}
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;
-/* $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>
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;
-/* $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>
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);
}