Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/ldpd modify structures in order to accomodate IPv6 ...
details: https://anonhg.NetBSD.org/src/rev/f573d7b9efc6
branches: trunk
changeset: 784356:f573d7b9efc6
user: kefren <kefren%NetBSD.org@localhost>
date: Sat Jan 26 17:29:55 2013 +0000
description:
modify structures in order to accomodate IPv6 according to
draft-ietf-mpls-ldp-ipv6. Correct a little bit IPv6 hello path
diffstat:
usr.sbin/ldpd/fsm.c | 52 ++--
usr.sbin/ldpd/fsm.h | 4 +-
usr.sbin/ldpd/label.c | 12 +-
usr.sbin/ldpd/label.h | 9 +-
usr.sbin/ldpd/ldp.h | 6 +-
usr.sbin/ldpd/ldp_command.c | 32 ++-
usr.sbin/ldpd/ldp_errors.c | 35 +++-
usr.sbin/ldpd/ldp_errors.h | 5 +-
usr.sbin/ldpd/ldp_peer.c | 160 ++++++++++-----
usr.sbin/ldpd/ldp_peer.h | 64 +++---
usr.sbin/ldpd/mpls_interface.c | 26 +-
usr.sbin/ldpd/mpls_interface.h | 4 +-
usr.sbin/ldpd/mpls_routes.c | 20 +-
usr.sbin/ldpd/mpls_routes.h | 4 +-
usr.sbin/ldpd/pdu.c | 6 +-
usr.sbin/ldpd/pdu.h | 3 +-
usr.sbin/ldpd/socketops.c | 399 ++++++++++++++++++++++++----------------
usr.sbin/ldpd/socketops.h | 8 +-
usr.sbin/ldpd/tlv.h | 4 +-
usr.sbin/ldpd/tlv_stack.c | 103 +++++++---
usr.sbin/ldpd/tlv_stack.h | 10 +-
21 files changed, 592 insertions(+), 374 deletions(-)
diffs (truncated from 2094 to 300 lines):
diff -r ffe9d647e8a8 -r f573d7b9efc6 usr.sbin/ldpd/fsm.c
--- a/usr.sbin/ldpd/fsm.c Sat Jan 26 16:58:14 2013 +0000
+++ b/usr.sbin/ldpd/fsm.c Sat Jan 26 17:29:55 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fsm.c,v 1.6 2012/11/12 18:39:00 kefren Exp $ */
+/* $NetBSD: fsm.c,v 1.7 2013/01/26 17:29:55 kefren Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -52,11 +52,10 @@
/* Processing a hello */
void
run_ldp_hello(struct ldp_pdu * pduid, struct hello_tlv * ht,
- struct in_addr * padd, struct in_addr * ladd, int mysock)
+ struct sockaddr * padd, struct in_addr * ladd, int mysock)
{
struct ldp_peer *peer = NULL;
- struct in_addr peer_addr;
- struct in6_addr peer_addr6;
+ union sockunion peer_addr;
struct transport_address_tlv *trtlv;
struct hello_info *hi;
@@ -90,7 +89,7 @@
ht->ch.holdtime = ntohs(ht->ch.holdtime);
ht->ch.res = ntohs(ht->ch.res);
debugp("Common hello Type: 0x%.4X Length: %.2d R:%d T:%d"
- "Hold time: %d\n", ht->ch.type, ht->ch.length,
+ " Hold time: %d\n", ht->ch.type, ht->ch.length,
ht->ch.tr / 2, ht->ch.tr % 2, ht->ch.holdtime);
if (ht->ch.holdtime != 0)
hi->keepalive = ht->ch.holdtime;
@@ -100,34 +99,41 @@
else
hi->keepalive = LDP_THELLO_KEEP;
}
- if (!get_ldp_peer(&pduid->ldp_id)) {
- /* First of all set peer_addr to announced LDP_ID */
- memcpy(&peer_addr, &pduid->ldp_id,
- sizeof(struct in_addr));
- /*
- * Now let's see if there is any transport TLV in
- * there
- */
+ 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)
- memcpy(&peer_addr, &trtlv->address,
+ if (trtlv->type == TLV_IPV4_TRANSPORT) {
+ peer_addr.sin.sin_family = AF_INET;
+ peer_addr.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)
- memcpy(&peer_addr6, &trtlv->address,
- sizeof(struct in6_addr));
- } else
+ } else if (trtlv->type == TLV_IPV6_TRANSPORT) {
+ peer_addr.sin6.sin6_family = AF_INET6;
+ peer_addr.sin6.sin6_len =
+ sizeof(struct sockaddr_in6);
+ memcpy(&peer_addr.sin6.sin6_addr,
+ &trtlv->address, sizeof(struct in6_addr));
+ }
+ } 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));
+ }
/*
* RFC 5036 2.5.2: If A1 > A2, LSR1 plays the active role;
* otherwise it is passive.
*/
- if (ntohl(peer_addr.s_addr) < ntohl(ladd->s_addr)) {
-#define TR_INET4_ADDR (trtlv && trtlv->type == TLV_IPV4_TRANSPORT) ? &peer_addr : NULL
-#define TR_INET6_ADDR NULL
+ /* 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)) {
peer = ldp_peer_new(&pduid->ldp_id, padd,
- TR_INET4_ADDR, TR_INET6_ADDR, ht->ch.holdtime, 0);
+ trtlv != NULL ? &peer_addr.sa : NULL,
+ ht->ch.holdtime, 0);
if (!peer)
return;
if (peer && peer->state == LDP_PEER_CONNECTED)
diff -r ffe9d647e8a8 -r f573d7b9efc6 usr.sbin/ldpd/fsm.h
--- a/usr.sbin/ldpd/fsm.h Sat Jan 26 16:58:14 2013 +0000
+++ b/usr.sbin/ldpd/fsm.h Sat Jan 26 17:29:55 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fsm.h,v 1.1 2010/12/08 07:20:14 kefren Exp $ */
+/* $NetBSD: fsm.h,v 1.2 2013/01/26 17:29:55 kefren Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
#include "pdu.h"
void run_ldp_hello(struct ldp_pdu *, struct hello_tlv *,
- struct in_addr *, struct in_addr *, int);
+ struct sockaddr *, struct in_addr *, int);
struct address_list_tlv * build_address_list_tlv(void);
int set_my_ldp_id(void);
diff -r ffe9d647e8a8 -r f573d7b9efc6 usr.sbin/ldpd/label.c
--- a/usr.sbin/ldpd/label.c Sat Jan 26 16:58:14 2013 +0000
+++ b/usr.sbin/ldpd/label.c Sat Jan 26 17:29:55 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: label.c,v 1.3 2010/12/30 11:29:21 kefren Exp $ */
+/* $NetBSD: label.c,v 1.4 2013/01/26 17:29:55 kefren Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -89,7 +89,7 @@
warnp("[label_add] added binding %d for %s/%s\n", l->binding,
union_ntoa(so_dest), spreftmp);
- send_label_tlv_to_all(&(so_dest->sin.sin_addr),
+ send_label_tlv_to_all(&(so_dest->sa),
from_union_to_cidr(so_pref), l->binding);
return l;
}
@@ -223,12 +223,12 @@
* For Compatibility with old bindinds code
*/
struct label*
-label_get_by_prefix(struct in_addr *a, int prefixlen)
+label_get_by_prefix(const struct sockaddr *a, int prefixlen)
{
union sockunion *so_dest, *so_pref;
struct label *l;
- so_dest = make_inet_union(inet_ntoa(*a));
+ so_dest = make_inet_union(satos(a)); // XXX: grobian
so_pref = from_cidr_to_union(prefixlen);
l = label_get(so_dest, so_pref);
@@ -264,10 +264,10 @@
void
change_local_label(struct label *l, uint32_t newbind)
{
- send_withdraw_tlv_to_all(&(l->so_dest.sin.sin_addr),
+ send_withdraw_tlv_to_all(&(l->so_dest.sa),
from_union_to_cidr(&(l->so_pref)));
l->binding = newbind;
- send_label_tlv_to_all(&(l->so_dest.sin.sin_addr),
+ send_label_tlv_to_all(&(l->so_dest.sa),
from_union_to_cidr(&(l->so_pref)),
l->binding);
}
diff -r ffe9d647e8a8 -r f573d7b9efc6 usr.sbin/ldpd/label.h
--- a/usr.sbin/ldpd/label.h Sat Jan 26 16:58:14 2013 +0000
+++ b/usr.sbin/ldpd/label.h Sat Jan 26 17:29:55 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: label.h,v 1.1 2010/12/08 07:20:14 kefren Exp $ */
+/* $NetBSD: label.h,v 1.2 2013/01/26 17:29:55 kefren Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -44,14 +44,13 @@
/*
* MPLS label descriptor
*
- * so_dest and so_pref are obvious
- * so_gate is the IPV4 gate
+ * so_dest, so_pref and so_gate are the prefix identification and its GW
* binding is the local label
* label is the peer associated label
*/
struct label {
union sockunion so_dest, so_pref, so_gate;
- int binding, label;
+ int binding, label;
struct ldp_peer *p;
SLIST_ENTRY(label) labels;
};
@@ -65,7 +64,7 @@
void label_reattach_all_peer_labels(struct ldp_peer*, int);
void label_del_by_binding(uint32_t, int);
struct label * label_get(union sockunion *sodest, union sockunion *sopref);
-struct label * label_get_by_prefix(struct in_addr*, int);
+struct label * label_get_by_prefix(const struct sockaddr *, int);
uint32_t get_free_local_label(void);
void change_local_label(struct label*, uint32_t);
void label_reattach_route(struct label*, int);
diff -r ffe9d647e8a8 -r f573d7b9efc6 usr.sbin/ldpd/ldp.h
--- a/usr.sbin/ldpd/ldp.h Sat Jan 26 16:58:14 2013 +0000
+++ b/usr.sbin/ldpd/ldp.h Sat Jan 26 17:29:55 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ldp.h,v 1.4 2012/11/12 18:39:00 kefren Exp $ */
+/* $NetBSD: ldp.h,v 1.5 2013/01/26 17:29:55 kefren Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -35,9 +35,13 @@
#include <sys/types.h>
#include <netinet/in.h>
+/* RFC5036 */
#define ALL_ROUTERS "224.0.0.2"
+/* draft-ietf-mpls-ldp-ipv6 */
#define ALL_ROUTERS6 "FF02::2"
+/* RFC5036 */
#define LDP_PORT 646
+
#define LDP_COMMAND_PORT 2626
#define LDPD_VER "0.4.0"
diff -r ffe9d647e8a8 -r f573d7b9efc6 usr.sbin/ldpd/ldp_command.c
--- a/usr.sbin/ldpd/ldp_command.c Sat Jan 26 16:58:14 2013 +0000
+++ b/usr.sbin/ldpd/ldp_command.c Sat Jan 26 17:29:55 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ldp_command.c,v 1.7 2011/12/24 23:54:26 christos Exp $ */
+/* $NetBSD: ldp_command.c,v 1.8 2013/01/26 17:29:55 kefren Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -167,6 +167,7 @@
close(s);
return -1;
}
+ debugp("Command socket created (%d)\n", s);
return s;
}
@@ -410,16 +411,21 @@
socklen_t sin_len = sizeof(struct sockaddr_in);
int enc;
socklen_t enclen = sizeof(enc);
+ char traddress[39], nhaddress[39];
SLIST_FOREACH(p, &ldp_peer_head, peers) {
snprintf(sendspace, MAXSEND, "LDP peer: %s\n",
inet_ntoa(p->ldp_id));
writestr(s, sendspace);
+ inet_ntop(p->transport_address->sa_family,
+ p->transport_address->sa_data, traddress, 39);
snprintf(sendspace, MAXSEND, "Transport address: %s\n",
- inet_ntoa(p->transport_address));
+ traddress);
writestr(s, sendspace);
+ inet_ntop(p->address->sa_family, p->address->sa_data,
+ nhaddress, 39);
snprintf(sendspace, MAXSEND, "Next-hop address: %s\n",
- inet_ntoa(p->address));
+ nhaddress);
writestr(s, sendspace);
snprintf(sendspace, MAXSEND, "State: %s\n",
ldp_state_to_name(p->state));
@@ -465,8 +471,11 @@
snprintf(sendspace, MAXSEND,"Addresses bounded to this peer: ");
writestr(s, sendspace);
SLIST_FOREACH(wp, &p->ldp_peer_address_head, addresses) {
+ /* XXX: TODO */
+ if (wp->address.sa.sa_family != AF_INET)
+ continue;
snprintf(sendspace, MAXSEND, "%s ",
- inet_ntoa(wp->address));
+ inet_ntoa(wp->address.sin.sin_addr));
writestr(s, sendspace);
}
sendspace[0] = sendspace[1] = '\n';
@@ -487,7 +496,11 @@
continue;
SLIST_FOREACH(lm, &p->label_mapping_head, mappings) {
char lma[256];
- strlcpy(lma, inet_ntoa(lm->address), sizeof(lma));
+ /* XXX: TODO */
+ if (lm->address.sa.sa_family != AF_INET)
+ continue;
+ strlcpy(lma, inet_ntoa(lm->address.sin.sin_addr),
+ sizeof(lma));
snprintf(sendspace, MAXSEND, "%s:%d\t%s/%d\n",
inet_ntoa(p->ldp_id), lm->label, lma, lm->prefix);
writestr(s, sendspace);
@@ -500,6 +513,7 @@
show_bindings(int s, char *recvspace)
{
struct label *l;
+ char labelgw[39];
snprintf(sendspace, MAXSEND, "Local label\tNetwork\t\t\t\tNexthop\n");
writestr(s, sendspace);
@@ -509,10 +523,12 @@
writestr(s, sendspace);
snprintf(sendspace, MAXSEND, "%s", union_ntoa(&l->so_pref));
writestr(s, sendspace);
- if (l->p)
+ if (l->p) {
+ inet_ntop(l->p->address->sa_family,
+ l->p->address->sa_data, labelgw, 39);
snprintf(sendspace, MAXSEND, "\t%s:%d\n",
- inet_ntoa(l->p->address), l->label);
- else
Home |
Main Index |
Thread Index |
Old Index