From a208c734a20a525a897b7a7184361da61604208e Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Wed, 11 Nov 2015 19:26:09 +0100 Subject: 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 --- openbsc/src/gprs/gtphub.c | 30 +++--------------------------- openbsc/src/gprs/gtphub_ext.c | 7 +++++-- 2 files changed, 8 insertions(+), 29 deletions(-) (limited to 'openbsc/src') diff --git a/openbsc/src/gprs/gtphub.c b/openbsc/src/gprs/gtphub.c index f0c96bc01..a4b0360f0 100644 --- a/openbsc/src/gprs/gtphub.c +++ b/openbsc/src/gprs/gtphub.c @@ -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); } diff --git a/openbsc/src/gprs/gtphub_ext.c b/openbsc/src/gprs/gtphub_ext.c index 98a9a4014..81c4c12af 100644 --- a/openbsc/src/gprs/gtphub_ext.c +++ b/openbsc/src/gprs/gtphub_ext.c @@ -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; } -- cgit v1.2.3