From b36032cb27292146bd652337cf5b63087b223e69 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Thu, 25 Sep 2014 13:21:48 +0200 Subject: [PATCH] gbproxy: Use a separate regexp for routing Currently one regexp ('patching') is used for all matching. This patch adds a second category 'routing' which is exclusively used for SGSN selection. It also adds a corresponding VTY command: - match-imsi patching RE : MS related patching (currently APN) - match-imsi routing RE : Select secondary SGSN on match only - no match-imsi : Clear all filter expressions Ticket: OW#1258 Sponsored-by: On-Waves ehf --- openbsc/include/openbsc/gb_proxy.h | 1 + openbsc/src/gprs/gb_proxy.c | 2 +- openbsc/src/gprs/gb_proxy_vty.c | 10 ++++++---- openbsc/tests/gbproxy/gbproxy_test.c | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/openbsc/include/openbsc/gb_proxy.h b/openbsc/include/openbsc/gb_proxy.h index 78d618b21..74dc6d44e 100644 --- a/openbsc/include/openbsc/gb_proxy.h +++ b/openbsc/include/openbsc/gb_proxy.h @@ -61,6 +61,7 @@ enum gbproxy_keep_mode { enum gbproxy_match_id { GBPROX_MATCH_PATCHING, + GBPROX_MATCH_ROUTING, GBPROX_MATCH_LAST }; diff --git a/openbsc/src/gprs/gb_proxy.c b/openbsc/src/gprs/gb_proxy.c index 41ff4a785..c23e718c6 100644 --- a/openbsc/src/gprs/gb_proxy.c +++ b/openbsc/src/gprs/gb_proxy.c @@ -584,7 +584,7 @@ static int gbprox_process_bssgp_ul(struct gbproxy_config *cfg, if (link_info && cfg->route_to_sgsn2) { if (cfg->acquire_imsi && link_info->imsi_len == 0) sgsn_nsei = 0xffff; - else if (gbproxy_imsi_matches(cfg, GBPROX_MATCH_PATCHING, + else if (gbproxy_imsi_matches(cfg, GBPROX_MATCH_ROUTING, link_info)) sgsn_nsei = cfg->nsip_sgsn2_nsei; } diff --git a/openbsc/src/gprs/gb_proxy_vty.c b/openbsc/src/gprs/gb_proxy_vty.c index fa0b09d5e..eb7eb600a 100644 --- a/openbsc/src/gprs/gb_proxy_vty.c +++ b/openbsc/src/gprs/gb_proxy_vty.c @@ -60,6 +60,7 @@ static const struct value_string keep_modes[] = { static const struct value_string match_ids[] = { {GBPROX_MATCH_PATCHING, "patching"}, + {GBPROX_MATCH_ROUTING, "routing"}, {0, NULL} }; @@ -199,15 +200,16 @@ DEFUN(cfg_gbproxy_no_core_mcc, DEFUN(cfg_gbproxy_match_imsi, cfg_gbproxy_match_imsi_cmd, - "match-imsi patching .REGEXP", + "match-imsi (patching|routing) .REGEXP", GBPROXY_MATCH_IMSI_STR - "Patch MS related information elements or route to secondary SGSN on match only\n" + "Patch MS related information elements on match only\n" + "Route to the secondary SGSN on match only\n" "Regular expression for the IMSI match\n") { - const char *filter = argv[0]; + const char *filter = argv[1]; const char *err_msg = NULL; struct gbproxy_match *match; - enum gbproxy_match_id match_id = get_string_value(match_ids, "patching"); + enum gbproxy_match_id match_id = get_string_value(match_ids, argv[0]); OSMO_ASSERT(match_id >= GBPROX_MATCH_PATCHING && match_id < GBPROX_MATCH_LAST); diff --git a/openbsc/tests/gbproxy/gbproxy_test.c b/openbsc/tests/gbproxy/gbproxy_test.c index 5b298ded9..5aa301b6a 100644 --- a/openbsc/tests/gbproxy/gbproxy_test.c +++ b/openbsc/tests/gbproxy/gbproxy_test.c @@ -2786,7 +2786,7 @@ static void test_gbproxy_secondary_sgsn() gbcfg.route_to_sgsn2 = 1; gbcfg.nsip_sgsn2_nsei = SGSN2_NSEI; - if (gbproxy_set_patch_filter(&gbcfg.matches[GBPROX_MATCH_PATCHING], + if (gbproxy_set_patch_filter(&gbcfg.matches[GBPROX_MATCH_ROUTING], filter_re, &err_msg) != 0) { fprintf(stderr, "gbprox_set_patch_filter: got error: %s\n", err_msg); @@ -3219,7 +3219,7 @@ static void test_gbproxy_secondary_sgsn() dump_global(stdout, 0); - gbproxy_clear_patch_filter(&gbcfg.matches[GBPROX_MATCH_PATCHING]); + gbproxy_clear_patch_filter(&gbcfg.matches[GBPROX_MATCH_ROUTING]); gbprox_reset(&gbcfg); gprs_ns_destroy(nsi); nsi = NULL;