Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/ldpd move code around a little bit in order to call...
details: https://anonhg.NetBSD.org/src/rev/4beb3904d45b
branches: trunk
changeset: 784641:4beb3904d45b
user: kefren <kefren%NetBSD.org@localhost>
date: Mon Feb 04 20:28:24 2013 +0000
description:
move code around a little bit in order to call get_ldp_peer correctly
check also for transport_address in get_ldp_peer
diffstat:
usr.sbin/ldpd/ldp_peer.c | 11 ++++++-----
usr.sbin/ldpd/socketops.c | 18 ++++++++++--------
2 files changed, 16 insertions(+), 13 deletions(-)
diffs (77 lines):
diff -r 5efad3137239 -r 4beb3904d45b usr.sbin/ldpd/ldp_peer.c
--- a/usr.sbin/ldpd/ldp_peer.c Mon Feb 04 20:03:11 2013 +0000
+++ b/usr.sbin/ldpd/ldp_peer.c Mon Feb 04 20:28:24 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ldp_peer.c,v 1.10 2013/02/04 17:14:31 kefren Exp $ */
+/* $NetBSD: ldp_peer.c,v 1.11 2013/02/04 20:28:24 kefren Exp $ */
/*
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -66,7 +66,8 @@
int
sockaddr_cmp(const struct sockaddr *a, const struct sockaddr *b)
{
- if (a->sa_len != b->sa_len || a->sa_family != b->sa_family)
+ if (a == NULL || b == NULL || a->sa_len != b->sa_len ||
+ a->sa_family != b->sa_family)
return -1;
return memcmp(a, b, a->sa_len);
}
@@ -226,9 +227,9 @@
(const void *) &p->ldp_id,
sizeof(struct in_addr)) == 0)
return p;
- if (sockaddr_cmp(a, p->address) == 0)
- return p;
- if (a->sa_family == AF_INET && check_ifaddr(p,a))
+ if (sockaddr_cmp(a, p->address) == 0 ||
+ sockaddr_cmp(a, p->transport_address) == 0 ||
+ check_ifaddr(p, a))
return p;
}
return NULL;
diff -r 5efad3137239 -r 4beb3904d45b usr.sbin/ldpd/socketops.c
--- a/usr.sbin/ldpd/socketops.c Mon Feb 04 20:03:11 2013 +0000
+++ b/usr.sbin/ldpd/socketops.c Mon Feb 04 20:28:24 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: socketops.c,v 1.25 2013/02/04 17:14:31 kefren Exp $ */
+/* $NetBSD: socketops.c,v 1.26 2013/02/04 20:28:24 kefren Exp $ */
/*
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -953,19 +953,13 @@
return;
}
- if (get_ldp_peer(&peer_address.sa) != NULL) {
- close(s);
- return;
- }
-
- warnp("Accepted a connection from %s\n", satos(&peer_address.sa));
-
if (getsockname(s, &my_address.sa,
& (socklen_t) { sizeof(union sockunion) } )) {
fatalp("new_peer_connection(): cannot getsockname\n");
close(s);
return;
}
+
if (peer_address.sa.sa_family == AF_INET)
peer_address.sin.sin_port = 0;
else if (peer_address.sa.sa_family == AF_INET6)
@@ -976,6 +970,14 @@
return;
}
+ /* Already peered or in holddown ? */
+ if (get_ldp_peer(&peer_address.sa) != NULL) {
+ close(s);
+ return;
+ }
+
+ warnp("Accepted a connection from %s\n", satos(&peer_address.sa));
+
/* Verify if it should connect - XXX: no check for INET6 */
if (peer_address.sa.sa_family == AF_INET &&
ntohl(peer_address.sin.sin_addr.s_addr) <
Home |
Main Index |
Thread Index |
Old Index