summaryrefslogtreecommitdiff
path: root/usr.sbin/ldpd
diff options
context:
space:
mode:
authorRenato Westphal <renato@cvs.openbsd.org>2013-10-15 20:36:31 +0000
committerRenato Westphal <renato@cvs.openbsd.org>2013-10-15 20:36:31 +0000
commitbb2d46071aaf1941ffb47634f9e88c29b2755a62 (patch)
tree8fdb737078f32648b99f25c10477830cd8406a5d /usr.sbin/ldpd
parent1a89b0eee567045382bc6925b124c28d9fc63a21 (diff)
Simplify the lde_nbr_new() function.
There's no need the pass a whole lde_nbr structure as argument if we want only the neighbor IP address. Also, remove the lde_nbr_del() prototype on lde.h because it's a duplicate. OK claudio@
Diffstat (limited to 'usr.sbin/ldpd')
-rw-r--r--usr.sbin/ldpd/lde.c16
-rw-r--r--usr.sbin/ldpd/lde.h3
-rw-r--r--usr.sbin/ldpd/neighbor.c11
3 files changed, 12 insertions, 18 deletions
diff --git a/usr.sbin/ldpd/lde.c b/usr.sbin/ldpd/lde.c
index 10aa3b8b7c5..9ccbea4f812 100644
--- a/usr.sbin/ldpd/lde.c
+++ b/usr.sbin/ldpd/lde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lde.c,v 1.26 2013/10/15 20:34:02 renato Exp $ */
+/* $OpenBSD: lde.c,v 1.27 2013/10/15 20:36:30 renato Exp $ */
/*
* Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org>
@@ -45,7 +45,7 @@ void lde_dispatch_imsg(int, short, void *);
void lde_dispatch_parent(int, short, void *);
struct lde_nbr *lde_nbr_find(u_int32_t);
-struct lde_nbr *lde_nbr_new(u_int32_t, struct lde_nbr *);
+struct lde_nbr *lde_nbr_new(u_int32_t, struct in_addr *);
void lde_nbr_del(struct lde_nbr *);
void lde_nbr_clear(void);
@@ -196,7 +196,7 @@ lde_dispatch_imsg(int fd, short event, void *bula)
struct imsgev *iev = bula;
struct imsgbuf *ibuf = &iev->ibuf;
struct imsg imsg;
- struct lde_nbr rn, *nbr;
+ struct lde_nbr *nbr;
struct map map;
struct timespec tp;
struct in_addr addr;
@@ -310,14 +310,14 @@ lde_dispatch_imsg(int fd, short event, void *bula)
break;
case IMSG_NEIGHBOR_UP:
- if (imsg.hdr.len - IMSG_HEADER_SIZE != sizeof(rn))
+ if (imsg.hdr.len - IMSG_HEADER_SIZE != sizeof(addr))
fatalx("invalid size of OE request");
- memcpy(&rn, imsg.data, sizeof(rn));
+ memcpy(&addr, imsg.data, sizeof(addr));
if (lde_nbr_find(imsg.hdr.peerid))
fatalx("lde_dispatch_imsg: "
"neighbor already exists");
- lde_nbr_new(imsg.hdr.peerid, &rn);
+ lde_nbr_new(imsg.hdr.peerid, &addr);
break;
case IMSG_NEIGHBOR_DOWN:
lde_nbr_del(lde_nbr_find(imsg.hdr.peerid));
@@ -591,14 +591,14 @@ lde_nbr_find(u_int32_t peerid)
}
struct lde_nbr *
-lde_nbr_new(u_int32_t peerid, struct lde_nbr *new)
+lde_nbr_new(u_int32_t peerid, struct in_addr *id)
{
struct lde_nbr *nbr;
if ((nbr = calloc(1, sizeof(*nbr))) == NULL)
fatal("lde_nbr_new");
- memcpy(nbr, new, sizeof(*nbr));
+ nbr->id.s_addr = id->s_addr;
nbr->peerid = peerid;
fec_init(&nbr->recv_map);
fec_init(&nbr->sent_map);
diff --git a/usr.sbin/ldpd/lde.h b/usr.sbin/ldpd/lde.h
index b431da20db0..89bba380675 100644
--- a/usr.sbin/ldpd/lde.h
+++ b/usr.sbin/ldpd/lde.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: lde.h,v 1.22 2013/10/15 20:34:03 renato Exp $ */
+/* $OpenBSD: lde.h,v 1.23 2013/10/15 20:36:30 renato Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -105,7 +105,6 @@ void lde_send_labelrequest(struct lde_nbr *, struct rt_node *);
void lde_send_labelrelease(struct lde_nbr *, struct rt_node *, u_int32_t);
void lde_send_notification(u_int32_t, u_int32_t, u_int32_t, u_int32_t);
-void lde_nbr_del(struct lde_nbr *);
void lde_nbr_do_mappings(struct rt_node *);
struct lde_map *lde_map_add(struct lde_nbr *, struct rt_node *, int);
void lde_map_del(struct lde_nbr *, struct lde_map *, int);
diff --git a/usr.sbin/ldpd/neighbor.c b/usr.sbin/ldpd/neighbor.c
index 1cbc6432121..b0da8ef8bb6 100644
--- a/usr.sbin/ldpd/neighbor.c
+++ b/usr.sbin/ldpd/neighbor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: neighbor.c,v 1.40 2013/10/15 20:31:13 renato Exp $ */
+/* $OpenBSD: neighbor.c,v 1.41 2013/10/15 20:36:30 renato Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -527,15 +527,10 @@ nbr_establish_connection(struct nbr *nbr)
int
nbr_act_session_operational(struct nbr *nbr)
{
- struct lde_nbr rn;
-
nbr->idtimer_cnt = 0;
- bzero(&rn, sizeof(rn));
- rn.id.s_addr = nbr->id.s_addr;
-
- return (ldpe_imsg_compose_lde(IMSG_NEIGHBOR_UP, nbr->peerid, 0, &rn,
- sizeof(rn)));
+ return (ldpe_imsg_compose_lde(IMSG_NEIGHBOR_UP, nbr->peerid, 0,
+ &nbr->id, sizeof(nbr->id)));
}
void