Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/ldpd Correct prefixlen->sockaddr calculation. Now l...
details: https://anonhg.NetBSD.org/src/rev/01687b342958
branches: trunk
changeset: 766139:01687b342958
user: kefren <kefren%NetBSD.org@localhost>
date: Thu Jun 16 20:42:15 2011 +0000
description:
Correct prefixlen->sockaddr calculation. Now ldpd may finally allow MPLS
forwarding for default route.
diffstat:
usr.sbin/ldpd/mpls_routes.c | 16 +++++++---------
1 files changed, 7 insertions(+), 9 deletions(-)
diffs (38 lines):
diff -r a2a3e6f248a0 -r 01687b342958 usr.sbin/ldpd/mpls_routes.c
--- a/usr.sbin/ldpd/mpls_routes.c Thu Jun 16 19:47:30 2011 +0000
+++ b/usr.sbin/ldpd/mpls_routes.c Thu Jun 16 20:42:15 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mpls_routes.c,v 1.7 2011/06/16 07:11:51 kefren Exp $ */
+/* $NetBSD: mpls_routes.c,v 1.8 2011/06/16 20:42:15 kefren Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -208,11 +208,7 @@
from_cidr_to_union(uint8_t prefixlen)
{
union sockunion *u;
- int32_t n = -1;
- uint32_t *m = (uint32_t*)&n;
-
- *m = (*m >> (32 - prefixlen) ) << (32 - prefixlen);
- *m = ntohl(*m);
+ uint32_t m = 0xFFFFFFFF;
u = calloc(1, sizeof(*u));
@@ -222,10 +218,12 @@
}
u->sin.sin_len = sizeof(struct sockaddr_in);
u->sin.sin_family = AF_INET;
- u->sin.sin_addr.s_addr = *m;
-
+ if (prefixlen != 0) {
+ m = (m >> (32 - prefixlen) ) << (32 - prefixlen);
+ m = ntohl(m);
+ u->sin.sin_addr.s_addr = m;
+ }
return u;
-
}
uint8_t
Home |
Main Index |
Thread Index |
Old Index