summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ldpd
diff options
context:
space:
mode:
authorrenato <renato@openbsd.org>2017-03-03 23:41:27 +0000
committerrenato <renato@openbsd.org>2017-03-03 23:41:27 +0000
commit02a212ee06450d0181143d259c46ebf0aef722e3 (patch)
tree2d433155bf11b1a06c9caa634deba47136139eb4 /usr.sbin/ldpd
parentAllow to run on a non-default rdomain. (diff)
downloadwireguard-openbsd-02a212ee06450d0181143d259c46ebf0aef722e3.tar.xz
wireguard-openbsd-02a212ee06450d0181143d259c46ebf0aef722e3.zip
Minor tweaks.
Diffstat (limited to 'usr.sbin/ldpd')
-rw-r--r--usr.sbin/ldpd/interface.c26
-rw-r--r--usr.sbin/ldpd/kroute.c10
-rw-r--r--usr.sbin/ldpd/labelmapping.c12
-rw-r--r--usr.sbin/ldpd/lde.c8
-rw-r--r--usr.sbin/ldpd/lde.h5
-rw-r--r--usr.sbin/ldpd/lde_lib.c8
-rw-r--r--usr.sbin/ldpd/ldp.h3
-rw-r--r--usr.sbin/ldpd/ldpe.c5
-rw-r--r--usr.sbin/ldpd/parse.y6
9 files changed, 42 insertions, 41 deletions
diff --git a/usr.sbin/ldpd/interface.c b/usr.sbin/ldpd/interface.c
index eb928356256..c5796bb3c60 100644
--- a/usr.sbin/ldpd/interface.c
+++ b/usr.sbin/ldpd/interface.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: interface.c,v 1.49 2017/03/03 23:36:06 renato Exp $ */
+/* $OpenBSD: interface.c,v 1.50 2017/03/03 23:41:27 renato Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
@@ -83,18 +83,6 @@ 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_exit(struct iface *iface)
{
@@ -113,6 +101,18 @@ if_exit(struct iface *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 *
iface_af_get(struct iface *iface, int af)
{
diff --git a/usr.sbin/ldpd/kroute.c b/usr.sbin/ldpd/kroute.c
index a65e039fa8e..6a2f921f773 100644
--- a/usr.sbin/ldpd/kroute.c
+++ b/usr.sbin/ldpd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.63 2017/03/03 23:36:06 renato Exp $ */
+/* $OpenBSD: kroute.c,v 1.64 2017/03/03 23:41:27 renato Exp $ */
/*
* Copyright (c) 2015, 2016 Renato Westphal <renato@openbsd.org>
@@ -264,7 +264,7 @@ kr_change(struct kroute *kr)
return (0);
-miss:
+ miss:
log_warnx("%s: lost FEC %s/%d nexthop %s", __func__,
log_addr(kr->af, &kr->prefix), kr->prefixlen,
log_addr(kr->af, &kr->nexthop));
@@ -565,7 +565,7 @@ kr_redist_eval(struct kroute *kr)
main_imsg_compose_lde(IMSG_NETWORK_ADD, 0, kr, sizeof(*kr));
return (1);
-dont_redistribute:
+ dont_redistribute:
return (0);
}
@@ -754,7 +754,7 @@ kroute_remove(struct kroute *kr)
return (0);
-notfound:
+ notfound:
log_warnx("%s failed to find %s/%u", __func__,
log_addr(kr->af, &kr->prefix), kr->prefixlen);
return (-1);
@@ -1284,7 +1284,7 @@ send_rtmsg_v4(int fd, int action, struct kroute *kr, int family)
}
}
-retry:
+ retry:
if (writev(fd, iov, iovcnt) == -1) {
if (errno == ESRCH) {
if (hdr.rtm_type == RTM_CHANGE && family == AF_MPLS) {
diff --git a/usr.sbin/ldpd/labelmapping.c b/usr.sbin/ldpd/labelmapping.c
index 2d2389c111f..9917d9ea28f 100644
--- a/usr.sbin/ldpd/labelmapping.c
+++ b/usr.sbin/ldpd/labelmapping.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: labelmapping.c,v 1.61 2016/09/02 17:16:24 renato Exp $ */
+/* $OpenBSD: labelmapping.c,v 1.62 2017/03/03 23:41:27 renato Exp $ */
/*
* Copyright (c) 2014, 2015 Renato Westphal <renato@openbsd.org>
@@ -399,8 +399,8 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type)
if (me->map.flags & F_MAP_REQ_ID)
me->map.requestid = reqid;
- log_debug("msg-in: label mapping: lsr-id %s, fec %s, label %s",
- inet_ntoa(nbr->id), log_map(&me->map),
+ log_debug("msg-in: %s: lsr-id %s, fec %s, label %s",
+ msg_name(type), inet_ntoa(nbr->id), log_map(&me->map),
log_label(me->map.label));
switch (type) {
@@ -426,14 +426,14 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type)
ldpe_imsg_compose_lde(imsg_type, nbr->peerid, 0, &me->map,
sizeof(struct map));
-next:
+ next:
TAILQ_REMOVE(&mh, me, entry);
free(me);
}
return (0);
-err:
+ err:
mapping_list_clr(&mh);
return (-1);
@@ -565,7 +565,7 @@ gen_fec_tlv(struct ibuf *buf, struct map *map)
break;
case MAP_TYPE_PWID:
if (map->flags & F_MAP_PW_ID)
- pw_len += PW_STATUS_TLV_LEN;
+ pw_len += FEC_PWID_SIZE;
if (map->flags & F_MAP_PW_IFMTU)
pw_len += FEC_SUBTLV_IFMTU_SIZE;
diff --git a/usr.sbin/ldpd/lde.c b/usr.sbin/ldpd/lde.c
index 8eada02827d..20cf060ffd1 100644
--- a/usr.sbin/ldpd/lde.c
+++ b/usr.sbin/ldpd/lde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lde.c,v 1.68 2017/01/20 12:19:18 benno Exp $ */
+/* $OpenBSD: lde.c,v 1.69 2017/03/03 23:41:27 renato Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
@@ -44,7 +44,7 @@ static __dead void lde_shutdown(void);
static int lde_imsg_compose_parent(int, pid_t, void *, uint16_t);
static void lde_dispatch_imsg(int, short, void *);
static void lde_dispatch_parent(int, short, void *);
-static __inline int lde_nbr_compare(struct lde_nbr *,
+static __inline int lde_nbr_compare(struct lde_nbr *,
struct lde_nbr *);
static struct lde_nbr *lde_nbr_new(uint32_t, struct lde_nbr *);
static void lde_nbr_del(struct lde_nbr *);
@@ -935,7 +935,7 @@ lde_send_labelrelease(struct lde_nbr *ln, struct fec_node *fn, uint32_t label)
}
void
-lde_send_notification(uint32_t peerid, uint32_t status_code, uint32_t msg_id,
+lde_send_notification(struct lde_nbr *ln, uint32_t status_code, uint32_t msg_id,
uint16_t msg_type)
{
struct notify_msg nm;
@@ -946,7 +946,7 @@ lde_send_notification(uint32_t peerid, uint32_t status_code, uint32_t msg_id,
nm.msg_id = msg_id;
nm.msg_type = msg_type;
- lde_imsg_compose_ldpe(IMSG_NOTIFICATION_SEND, peerid, 0,
+ lde_imsg_compose_ldpe(IMSG_NOTIFICATION_SEND, ln->peerid, 0,
&nm, sizeof(nm));
}
diff --git a/usr.sbin/ldpd/lde.h b/usr.sbin/ldpd/lde.h
index 20b3ea6881e..c0c4da771b2 100644
--- a/usr.sbin/ldpd/lde.h
+++ b/usr.sbin/ldpd/lde.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: lde.h,v 1.44 2016/09/02 17:10:34 renato Exp $ */
+/* $OpenBSD: lde.h,v 1.45 2017/03/03 23:41:27 renato Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
@@ -138,7 +138,8 @@ void lde_send_labelwithdraw(struct lde_nbr *, struct fec_node *,
void lde_send_labelwithdraw_all(struct fec_node *, uint32_t);
void lde_send_labelrelease(struct lde_nbr *, struct fec_node *,
uint32_t);
-void lde_send_notification(uint32_t, uint32_t, uint32_t, uint16_t);
+void lde_send_notification(struct lde_nbr *, uint32_t, uint32_t,
+ uint16_t);
struct lde_nbr *lde_nbr_find_by_lsrid(struct in_addr);
struct lde_nbr *lde_nbr_find_by_addr(int, union ldpd_addr *);
struct lde_map *lde_map_add(struct lde_nbr *, struct fec_node *, int);
diff --git a/usr.sbin/ldpd/lde_lib.c b/usr.sbin/ldpd/lde_lib.c
index 29e986151b3..67a6eeca428 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.63 2016/07/01 23:36:38 renato Exp $ */
+/* $OpenBSD: lde_lib.c,v 1.64 2017/03/03 23:41:27 renato Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
@@ -529,7 +529,7 @@ lde_check_request(struct map *map, struct lde_nbr *ln)
fn = (struct fec_node *)fec_find(&ft, &fec);
if (fn == NULL || LIST_EMPTY(&fn->nexthops)) {
/* LRq.5: send No Route notification */
- lde_send_notification(ln->peerid, S_NO_ROUTE, map->msg_id,
+ lde_send_notification(ln, S_NO_ROUTE, map->msg_id,
htons(MSG_TYPE_LABELREQUEST));
return;
}
@@ -543,8 +543,8 @@ lde_check_request(struct map *map, struct lde_nbr *ln)
continue;
/* LRq.4: send Loop Detected notification */
- lde_send_notification(ln->peerid, S_LOOP_DETECTED,
- map->msg_id, htons(MSG_TYPE_LABELREQUEST));
+ lde_send_notification(ln, S_LOOP_DETECTED, map->msg_id,
+ htons(MSG_TYPE_LABELREQUEST));
return;
default:
break;
diff --git a/usr.sbin/ldpd/ldp.h b/usr.sbin/ldpd/ldp.h
index d50a3d0ba15..82ee6976f8d 100644
--- a/usr.sbin/ldpd/ldp.h
+++ b/usr.sbin/ldpd/ldp.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldp.h,v 1.35 2016/09/03 16:07:08 renato Exp $ */
+/* $OpenBSD: ldp.h,v 1.36 2017/03/03 23:41:27 renato Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
@@ -244,6 +244,7 @@ struct address_list_tlv {
#define FEC_ELM_WCARD_LEN 1
#define FEC_ELM_PREFIX_MIN_LEN 4
#define FEC_PWID_ELM_MIN_LEN 8
+#define FEC_PWID_SIZE 4
#define MAP_TYPE_WILDCARD 0x01
#define MAP_TYPE_PREFIX 0x02
diff --git a/usr.sbin/ldpd/ldpe.c b/usr.sbin/ldpd/ldpe.c
index 3d273ab7dc2..5de42b5b8e1 100644
--- a/usr.sbin/ldpd/ldpe.c
+++ b/usr.sbin/ldpd/ldpe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldpe.c,v 1.72 2017/03/03 23:30:57 renato Exp $ */
+/* $OpenBSD: ldpe.c,v 1.73 2017/03/03 23:41:27 renato Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
@@ -730,8 +730,7 @@ ldpe_iface_af_ctl(struct ctl_conn *c, int af, unsigned int idx)
continue;
ictl = if_to_ctl(ia);
- imsg_compose_event(&c->iev,
- IMSG_CTL_SHOW_INTERFACE,
+ imsg_compose_event(&c->iev, IMSG_CTL_SHOW_INTERFACE,
0, 0, -1, ictl, sizeof(struct ctl_iface));
}
}
diff --git a/usr.sbin/ldpd/parse.y b/usr.sbin/ldpd/parse.y
index aa34df21666..7593c5a39df 100644
--- a/usr.sbin/ldpd/parse.y
+++ b/usr.sbin/ldpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.60 2017/03/03 23:36:06 renato Exp $ */
+/* $OpenBSD: parse.y,v 1.61 2017/03/03 23:41:27 renato Exp $ */
/*
* Copyright (c) 2013, 2015, 2016 Renato Westphal <renato@openbsd.org>
@@ -969,7 +969,7 @@ yylex(void)
int quotec, next, c;
int token;
-top:
+ top:
p = buf;
while ((c = lgetc(0)) == ' ' || c == '\t')
; /* nothing */
@@ -1071,7 +1071,7 @@ top:
}
return (NUMBER);
} else {
-nodigits:
+ nodigits:
while (p > buf + 1)
lungetc(*--p);
c = *--p;