Add more messages, wait for directory service to start first

And make sure gaps in sockaddr_in are zeroed.
This commit is contained in:
Jeremy Lakeman 2012-12-10 14:24:52 +10:30
parent 2932544eb8
commit c3f573ea7f
4 changed files with 19 additions and 9 deletions

View File

@ -269,9 +269,11 @@ int load_subscriber_address(struct subscriber *subscriber)
return -1; return -1;
} }
struct sockaddr_in addr; struct sockaddr_in addr;
bzero(&addr, sizeof(addr));
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
addr.sin_addr = hostc->address; addr.sin_addr = hostc->address;
addr.sin_port = htons(hostc->port); addr.sin_port = htons(hostc->port);
DEBUGF("Loaded address %s:%d for %s", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port), alloca_tohex_sid(subscriber->sid));
return overlay_send_probe(subscriber, addr, interface); return overlay_send_probe(subscriber, addr, interface);
} }

View File

@ -307,7 +307,8 @@ overlay_interface_init_socket(int interface_index)
interface->state=INTERFACE_STATE_UP; interface->state=INTERFACE_STATE_UP;
INFOF("Interface %s addr %s, is up",interface->name, inet_ntoa(interface->broadcast_address.sin_addr)); INFOF("Interface %s addr %s:%d, is up",interface->name,
inet_ntoa(interface->address.sin_addr), ntohs(interface->address.sin_port));
directory_registration(); directory_registration();
@ -333,6 +334,7 @@ overlay_interface_init(const char *name, struct in_addr src_addr, struct in_addr
interface->port= ifconfig->port; interface->port= ifconfig->port;
interface->type= ifconfig->type; interface->type= ifconfig->type;
interface->default_route = ifconfig->default_route; interface->default_route = ifconfig->default_route;
DEBUGF("interface->default_route=%d",interface->default_route);
interface->last_tick_ms= -1; // not ticked yet interface->last_tick_ms= -1; // not ticked yet
interface->alarm.poll.fd=0; interface->alarm.poll.fd=0;
@ -371,7 +373,6 @@ overlay_interface_init(const char *name, struct in_addr src_addr, struct in_addr
interface->send_broadcasts=0; interface->send_broadcasts=0;
INFOF("Interface %s is running tickless", name); INFOF("Interface %s is running tickless", name);
} }
if (ifconfig->dummy[0]) { if (ifconfig->dummy[0]) {
interface->fileP = 1; interface->fileP = 1;
char dummyfile[1024]; char dummyfile[1024];
@ -383,12 +384,14 @@ overlay_interface_init(const char *name, struct in_addr src_addr, struct in_addr
return WHYF("could not open dummy interface file %s for append", dummyfile); return WHYF("could not open dummy interface file %s for append", dummyfile);
} }
bzero(&interface->address, sizeof(interface->address));
interface->address.sin_family=AF_INET; interface->address.sin_family=AF_INET;
interface->address.sin_port = htons(PORT_DNA); interface->address.sin_port = htons(PORT_DNA);
interface->address.sin_addr = ifconfig->dummy_address; interface->address.sin_addr = ifconfig->dummy_address;
interface->netmask=ifconfig->dummy_netmask; interface->netmask=ifconfig->dummy_netmask;
bzero(&interface->broadcast_address, sizeof(interface->address));
interface->broadcast_address.sin_family=AF_INET; interface->broadcast_address.sin_family=AF_INET;
interface->broadcast_address.sin_port = htons(PORT_DNA); interface->broadcast_address.sin_port = htons(PORT_DNA);
interface->broadcast_address.sin_addr.s_addr = interface->address.sin_addr.s_addr | ~interface->netmask.s_addr; interface->broadcast_address.sin_addr.s_addr = interface->address.sin_addr.s_addr | ~interface->netmask.s_addr;
@ -408,10 +411,8 @@ overlay_interface_init(const char *name, struct in_addr src_addr, struct in_addr
schedule(&interface->alarm); schedule(&interface->alarm);
interface->state=INTERFACE_STATE_UP; interface->state=INTERFACE_STATE_UP;
INFOF("Dummy interface %s is up",interface->name); INFOF("Dummy interface %s addr %s:%d, is up",interface->name,
DEBUGF("Address %s",inet_ntoa(interface->address.sin_addr)); inet_ntoa(interface->address.sin_addr), ntohs(interface->address.sin_port));
DEBUGF("Netmask %s",inet_ntoa(interface->netmask));
DEBUGF("Broadcast %s",inet_ntoa(interface->broadcast_address.sin_addr));
directory_registration(); directory_registration();
@ -568,7 +569,8 @@ void overlay_dummy_poll(struct sched_ent *alarm)
(struct sockaddr*)&packet.src_addr, sizeof(packet.src_addr))) { (struct sockaddr*)&packet.src_addr, sizeof(packet.src_addr))) {
WARN("Unsupported packet from dummy interface"); WARN("Unsupported packet from dummy interface");
} }
} }else
DEBUGF("Ignoring packet addressed to %s:%d", inet_ntoa(packet.dst_addr.sin_addr), ntohs(packet.dst_addr.sin_port));
} }
/* keep reading new packets as fast as possible, /* keep reading new packets as fast as possible,

View File

@ -367,8 +367,8 @@ int overlay_send_probe(struct subscriber *peer, struct sockaddr_in addr, overlay
op_free(frame); op_free(frame);
return -1; return -1;
} }
DEBUGF("Queued probe packet on interface %s to %s for %s", DEBUGF("Queued probe packet on interface %s to %s:%d for %s",
interface->name, inet_ntoa(addr.sin_addr), peer?alloca_tohex_sid(peer->sid):"ANY"); interface->name, inet_ntoa(addr.sin_addr), ntohs(addr.sin_port), peer?alloca_tohex_sid(peer->sid):"ANY");
return 0; return 0;
} }

View File

@ -85,6 +85,11 @@ test_publish() {
assert_status_all_servald_servers running assert_status_all_servald_servers running
} }
interface_up() {
grep "Dummy interface .* is up" $instance_servald_log || return 1
return 0
}
start_routing_instance() { start_routing_instance() {
executeOk_servald config \ executeOk_servald config \
set server.dummy_interface_dir "$SERVALD_VAR" \ set server.dummy_interface_dir "$SERVALD_VAR" \
@ -94,6 +99,7 @@ start_routing_instance() {
set log.show_time on \ set log.show_time on \
set debug.mdprequests Yes set debug.mdprequests Yes
start_servald_server start_servald_server
wait_until interface_up
} }
setup_routing() { setup_routing() {