git://git.onelab.eu
/
distributedratelimiting.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
bf4fd3e
)
Cleanups and debuging output.
author
Kevin Webb
<kcwebb@ucsd.edu>
Thu, 28 Jan 2010 16:56:54 +0000
(16:56 +0000)
committer
Kevin Webb
<kcwebb@ucsd.edu>
Thu, 28 Jan 2010 16:56:54 +0000
(16:56 +0000)
drl/ulogd_DRL.c
patch
|
blob
|
history
drl/util.c
patch
|
blob
|
history
diff --git
a/drl/ulogd_DRL.c
b/drl/ulogd_DRL.c
index
2bb4e52
..
f7b0272
100644
(file)
--- a/
drl/ulogd_DRL.c
+++ b/
drl/ulogd_DRL.c
@@
-1526,10
+1526,10
@@
static int init_drl(void) {
pthread_rwlock_init(&limiter.limiter_lock,NULL);
/* determine our local IP by iterating through interfaces */
pthread_rwlock_init(&limiter.limiter_lock,NULL);
/* determine our local IP by iterating through interfaces */
- if ((limiter.ip = get_local_ip())==0) {
- printlog(LOG_CRITICAL,
-
"ulogd_DRL unable to aquire local IP address, not registering.\n");
- return
(false)
;
+ limiter.ip = get_local_ip();
+ if (limiter.ip == NULL) {
+
printlog(LOG_CRITICAL,
"ulogd_DRL unable to aquire local IP address, not registering.\n");
+ return
false
;
}
limiter.localaddr = inet_addr(limiter.ip);
limiter.port = htons(LIMITER_LISTEN_PORT);
}
limiter.localaddr = inet_addr(limiter.ip);
limiter.port = htons(LIMITER_LISTEN_PORT);
diff --git
a/drl/util.c
b/drl/util.c
index
a99e27e
..
c03eced
100644
(file)
--- a/
drl/util.c
+++ b/
drl/util.c
@@
-257,6
+257,7
@@
char* get_local_ip(){
for (ifa = ifp; ifa; ifa=ifa->ifa_next){
for (ifa = ifp; ifa; ifa=ifa->ifa_next){
+ printlog(LOG_DEBUG, "get_local_ip: checking new addr.\n");
if (ifa->ifa_addr->sa_family == AF_INET){
salen = sizeof(struct sockaddr_in);
} else if( ifa->ifa_addr->sa_family == AF_INET6){
if (ifa->ifa_addr->sa_family == AF_INET){
salen = sizeof(struct sockaddr_in);
} else if( ifa->ifa_addr->sa_family == AF_INET6){
@@
-281,8
+282,12
@@
char* get_local_ip(){
/* is it MSB first? */
/* We don't want to choose the loopback. */
/* is it MSB first? */
/* We don't want to choose the loopback. */
- if (addrbyte == 127)
+ if (addrbyte == 127) {
+ printlog(LOG_DEBUG, "get_local_ip: ignoring the loopback.\n");
continue;
continue;
+ }
+
+ printlog(LOG_DEBUG, "get_local_ip: found address starting with %hhu\n", addrbyte);
/* If there's a non-local address, use that. */
if ((addrbyte != 192) && (addrbyte != 172) && (addrbyte != 10)){
/* If there's a non-local address, use that. */
if ((addrbyte != 192) && (addrbyte != 172) && (addrbyte != 10)){
@@
-291,6
+296,7
@@
char* get_local_ip(){
if (localip != NULL) {
free(localip);
}
if (localip != NULL) {
free(localip);
}
+ printlog(LOG_DEBUG, "get_local_ip: returning routable address %s\n", ip);
return(ip); /* for now return the IP address */
} else {
if (localip == NULL) {
return(ip); /* for now return the IP address */
} else {
if (localip == NULL) {
@@
-302,8
+308,10
@@
char* get_local_ip(){
freeifaddrs(ifp);
free(ip);
freeifaddrs(ifp);
free(ip);
- if (localip != NULL)
+ if (localip != NULL) {
+ printlog(LOG_DEBUG, "get_local_ip: returning local address %s\n", localip);
return localip;
return localip;
+ }
else
return(NULL);
}
else
return(NULL);
}