Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/ldpd Fix the transport address TLV mess I created a...
details: https://anonhg.NetBSD.org/src/rev/e2541866c65d
branches: trunk
changeset: 784454:e2541866c65d
user: kefren <kefren%NetBSD.org@localhost>
date: Mon Jan 28 20:06:52 2013 +0000
description:
Fix the transport address TLV mess I created after INET6 convert
Use a single loop to decrement and check hello list keepalives
Display transport address in show hello output
diffstat:
usr.sbin/ldpd/fsm.c | 53 ++++++++++++++++++++++++--------------------
usr.sbin/ldpd/ldp_command.c | 10 +++++--
usr.sbin/ldpd/socketops.c | 10 +++-----
usr.sbin/ldpd/socketops.h | 5 ++-
4 files changed, 43 insertions(+), 35 deletions(-)
diffs (165 lines):
diff -r d155a80b13cd -r e2541866c65d usr.sbin/ldpd/fsm.c
--- a/usr.sbin/ldpd/fsm.c Mon Jan 28 19:50:30 2013 +0000
+++ b/usr.sbin/ldpd/fsm.c Mon Jan 28 20:06:52 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fsm.c,v 1.7 2013/01/26 17:29:55 kefren Exp $ */
+/* $NetBSD: fsm.c,v 1.8 2013/01/28 20:06:52 kefren Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -55,7 +55,6 @@
struct sockaddr * padd, struct in_addr * ladd, int mysock)
{
struct ldp_peer *peer = NULL;
- union sockunion peer_addr;
struct transport_address_tlv *trtlv;
struct hello_info *hi;
@@ -77,6 +76,7 @@
return;
}
hi->ldp_id.s_addr = pduid->ldp_id.s_addr;
+ hi->transport_address.sa.sa_family = 0;
SLIST_INSERT_HEAD(&hello_info_head, hi, infos);
} else
/* Just update timer */
@@ -102,41 +102,46 @@
if (!get_ldp_peer_by_id(&pduid->ldp_id)) {
/* Check transport TLV */
if (pduid->length - PDU_PAYLOAD_LENGTH -
- sizeof(struct hello_tlv) > 3) {
- trtlv = (struct transport_address_tlv *) &ht[1];
- if (trtlv->type == TLV_IPV4_TRANSPORT) {
- peer_addr.sin.sin_family = AF_INET;
- peer_addr.sin.sin_len =
+ sizeof(struct hello_tlv) >= 8) {
+ trtlv = (struct transport_address_tlv *)(ht + 1);
+ if (trtlv->type == htons(TLV_IPV4_TRANSPORT)) {
+ hi->transport_address.sin.sin_family = AF_INET;
+ hi->transport_address.sin.sin_len =
sizeof(struct sockaddr_in);
- memcpy(&peer_addr.sin.sin_addr, &trtlv->address,
- sizeof(struct in_addr));
- } else if (trtlv->type == TLV_IPV6_TRANSPORT) {
- peer_addr.sin6.sin6_family = AF_INET6;
- peer_addr.sin6.sin6_len =
+ memcpy(&hi->transport_address.sin.sin_addr,
+ &trtlv->address, sizeof(struct in_addr));
+ } else if (trtlv->type == htons(TLV_IPV6_TRANSPORT)) {
+ hi->transport_address.sin6.sin6_family =
+ AF_INET6;
+ hi->transport_address.sin6.sin6_len =
sizeof(struct sockaddr_in6);
- memcpy(&peer_addr.sin6.sin6_addr,
+ memcpy(&hi->transport_address.sin6.sin6_addr,
&trtlv->address, sizeof(struct in6_addr));
- }
+ } else
+ warnp("Unknown AF %x for transport address\n",
+ ntohs(trtlv->type));
} else {
trtlv = NULL;
- peer_addr.sin.sin_family = AF_INET;
- peer_addr.sin.sin_len = sizeof(struct sockaddr_in);
- memcpy(&peer_addr.sin.sin_addr, &pduid->ldp_id,
- sizeof(struct in_addr));
+ hi->transport_address.sin.sin_family = AF_INET;
+ hi->transport_address.sin.sin_len =
+ sizeof(struct sockaddr_in);
+ memcpy(&hi->transport_address.sin.sin_addr,
+ &pduid->ldp_id, sizeof(struct in_addr));
}
/*
* RFC 5036 2.5.2: If A1 > A2, LSR1 plays the active role;
* otherwise it is passive.
*/
- /* XXX: check for IPv6 too */
- if (peer_addr.sa.sa_family == AF_INET &&
- ntohl(peer_addr.sin.sin_addr.s_addr)< ntohl(ladd->s_addr)) {
+ /* XXX TODO: check for IPv6 too */
+ if (hi->transport_address.sa.sa_family == AF_INET &&
+ ntohl(hi->transport_address.sin.sin_addr.s_addr) <
+ ntohl(ladd->s_addr)) {
peer = ldp_peer_new(&pduid->ldp_id, padd,
- trtlv != NULL ? &peer_addr.sa : NULL,
+ &hi->transport_address.sa,
ht->ch.holdtime, 0);
- if (!peer)
+ if (peer == NULL)
return;
- if (peer && peer->state == LDP_PEER_CONNECTED)
+ if (peer->state == LDP_PEER_CONNECTED)
send_initialize(peer);
}
}
diff -r d155a80b13cd -r e2541866c65d usr.sbin/ldpd/ldp_command.c
--- a/usr.sbin/ldpd/ldp_command.c Mon Jan 28 19:50:30 2013 +0000
+++ b/usr.sbin/ldpd/ldp_command.c Mon Jan 28 20:06:52 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ldp_command.c,v 1.8 2013/01/26 17:29:55 kefren Exp $ */
+/* $NetBSD: ldp_command.c,v 1.9 2013/01/28 20:06:52 kefren Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -555,8 +555,12 @@
struct hello_info *hi;
SLIST_FOREACH(hi, &hello_info_head, infos) {
- snprintf(sendspace, MAXSEND, "%s: %ds\n", inet_ntoa(hi->ldp_id),
- hi->keepalive);
+ snprintf(sendspace, MAXSEND,
+ "ID: %s\nKeepalive: %ds\nTransport address: %s\n\n",
+ inet_ntoa(hi->ldp_id),
+ hi->keepalive,
+ hi->transport_address.sa.sa_family != 0 ?
+ satos(&hi->transport_address.sa) : "None");
writestr(s, sendspace);
}
return 1;
diff -r d155a80b13cd -r e2541866c65d usr.sbin/ldpd/socketops.c
--- a/usr.sbin/ldpd/socketops.c Mon Jan 28 19:50:30 2013 +0000
+++ b/usr.sbin/ldpd/socketops.c Mon Jan 28 20:06:52 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: socketops.c,v 1.20 2013/01/26 21:07:49 kefren Exp $ */
+/* $NetBSD: socketops.c,v 1.21 2013/01/28 20:06:52 kefren Exp $ */
/*
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -751,15 +751,13 @@
}
}
- /* Decrement hello info keepalives */
- SLIST_FOREACH(hi, &hello_info_head, infos)
+ /* Decrement and Check hello keepalives */
+ SLIST_FOREACH_SAFE(hi, &hello_info_head, infos, hinext) {
if (hi->keepalive != 0xFFFF)
hi->keepalive--;
-
- /* Check hello keepalives */
- SLIST_FOREACH_SAFE(hi, &hello_info_head, infos, hinext)
if (hi->keepalive < 1)
SLIST_REMOVE(&hello_info_head, hi, hello_info, infos);
+ }
/* Set the alarm again and bail out */
alarm(1);
diff -r d155a80b13cd -r e2541866c65d usr.sbin/ldpd/socketops.h
--- a/usr.sbin/ldpd/socketops.h Mon Jan 28 19:50:30 2013 +0000
+++ b/usr.sbin/ldpd/socketops.h Mon Jan 28 20:06:52 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: socketops.h,v 1.4 2013/01/26 17:29:55 kefren Exp $ */
+/* $NetBSD: socketops.h,v 1.5 2013/01/28 20:06:52 kefren Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -56,7 +56,8 @@
int send_addresses(struct ldp_peer *);
struct hello_info {
- struct in_addr address, transport_address, ldp_id;
+ union sockunion transport_address;
+ struct in_addr ldp_id;
int keepalive;
SLIST_ENTRY(hello_info) infos;
};
Home |
Main Index |
Thread Index |
Old Index