gtphub: don't always try to do GGSN resolution.

If a GGSN is already known from unmapping, don't invoke a host resolution.
In a live working environment, it wouldn't hurt, because the lookups would
mostly return from the cache. But in a testing environment without a name
server, it barfs on every packet.

Sponsored-by: On-Waves ehi
This commit is contained in:
Neels Hofmeyr
2015-11-11 19:26:09 +01:00
parent 16c3f57ed6
commit a208c734a2
2 changed files with 8 additions and 29 deletions

View File

@@ -1609,25 +1609,11 @@ int gtphub_from_sgsns_handle_buf(struct gtphub *hub,
return -1;
}
/* See what our GGSN guess would be from the packet data per se. */
/* TODO maybe not do this always? */
struct gtphub_peer_port *ggsn_from_packet;
if (gtphub_resolve_ggsn(hub, &p, &ggsn_from_packet) < 0)
return -1;
if (ggsn_from_packet && ggsn
&& (ggsn_from_packet != ggsn)) {
LOGERR("GGSN implied from packet does not match unmapped"
" GGSN, using unmapped GGSN:"
" from packet: %s unmapped: %s\n",
gtphub_port_str(ggsn_from_packet),
gtphub_port_str2(ggsn));
/* TODO return -1; ? */
if (!ggsn) {
if (gtphub_resolve_ggsn(hub, &p, &ggsn) < 0)
return -1;
}
if (!ggsn)
ggsn = ggsn_from_packet;
if (!ggsn) {
LOGERR("No GGSN to send to. Dropping packet.\n");
return -1;
@@ -1737,16 +1723,6 @@ static int gtphub_gc_peer(struct gtphub_peer *p)
* listed within p->addresses, referenced by TEI mappings from
* hub->tei_map. As long as those don't expire, this peer will stay. */
LOG("gc peer %p llist_empty %d seq_map_empty %d\n", p,
(int)llist_empty(&p->addresses), (int) nr_map_empty(&p->seq_map));
if (! nr_map_empty(&p->seq_map)) {
printf("not empty\n");
struct nr_mapping *nrm;
llist_for_each_entry(nrm, &p->seq_map.mappings, entry) {
printf("%p %s %d -> %d\n",
nrm->origin, gtphub_port_str(nrm->origin),nrm->orig, nrm->repl);
}
}
return llist_empty(&p->addresses)
&& nr_map_empty(&p->seq_map);
}

View File

@@ -98,7 +98,7 @@ static void ggsn_lookup_cb(void *arg, int status, int timeouts, struct hostent *
resolved_addr.len = hostent->h_length;
LOGP(DGTPHUB, LOGL_NOTICE, "resolved addr %s\n",
osmo_hexdump(&resolved_addr, sizeof(resolved_addr)));
osmo_hexdump((unsigned char*)&resolved_addr, sizeof(resolved_addr)));
gtphub_resolved_ggsn(lookup->hub, lookup->apn_oi_str, &resolved_addr,
gtphub_now());
@@ -197,7 +197,10 @@ struct gtphub_peer_port *gtphub_resolve_ggsn_addr(struct gtphub *hub,
expiry_add(&hub->expire_seq_maps, &lookup->expiry_entry, gtphub_now());
start_ares_query(lookup);
LOGP(DGTPHUB, LOGL_NOTICE, "resolution started.\n");
LOGP(DGTPHUB, LOGL_NOTICE, "Resolving %s %s ..."
" (Returning failure, hoping for a retry"
"once resolution has concluded)\n",
imsi_str, apn_ni_str);
return NULL;
}