aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2014-08-27 12:51:07 +0200
committerJacob Erlbeck <jerlbeck@sysmocom.de>2014-09-08 09:27:36 +0200
commitcabd24b33f51a109242c2a9188f7405ff8de64bc (patch)
treec26e89f47a124dc1524ac490f60bdd0b4fcab545
parentf181f9ec2a1ad61ca040e0224835a08878bda795 (diff)
gbproxy: Use secondary SGSN if IMSI matches
This patch modifies gbprox_process_bssgp_ul() to send the message to the secondary SGSN if the IMSI has matched and routing to the secondary SGSN is enabled. The destination for stored messages is modified accordingly. Ticket: OW#1261 Sponsored-by: On-Waves ehf
-rw-r--r--openbsc/src/gprs/gb_proxy.c16
-rw-r--r--openbsc/tests/gbproxy/gbproxy_test.ok46
2 files changed, 38 insertions, 24 deletions
diff --git a/openbsc/src/gprs/gb_proxy.c b/openbsc/src/gprs/gb_proxy.c
index 539e3aef9..6e93e1493 100644
--- a/openbsc/src/gprs/gb_proxy.c
+++ b/openbsc/src/gprs/gb_proxy.c
@@ -263,6 +263,8 @@ static int gbprox_process_bssgp_ul(struct gbproxy_config *cfg,
int len_change = 0;
time_t now;
struct gbproxy_tlli_info *tlli_info = NULL;
+ uint32_t sgsn_nsei = cfg->nsip_sgsn_nsei;
+ int send_msg_directly = 0;
if (!cfg->core_mcc && !cfg->core_mnc && !cfg->core_apn &&
!cfg->acquire_imsi)
@@ -328,6 +330,11 @@ static int gbprox_process_bssgp_ul(struct gbproxy_config *cfg,
tlli_info = gbproxy_update_tlli_state_ul(peer, now, &parse_ctx);
+ if (tlli_info && tlli_info->enable_patching && cfg->route_to_sgsn2) {
+ sgsn_nsei = cfg->nsip_sgsn2_nsei;
+ send_msg_directly = 1;
+ }
+
if (tlli_info && tlli_info->imsi_acq_pending && parse_ctx.g48_hdr &&
parse_ctx.g48_hdr->proto_discr == GSM48_PDISC_MM_GPRS &&
parse_ctx.g48_hdr->msg_type == GSM48_MT_GMM_ID_RESP &&
@@ -359,7 +366,7 @@ static int gbprox_process_bssgp_ul(struct gbproxy_config *cfg,
&tmp_parse_ctx);
rc = gbprox_relay2sgsn(cfg, stored_msg, msgb_bvci(msg),
- cfg->nsip_sgsn_nsei);
+ sgsn_nsei);
if (rc < 0)
LOGP(DLLC, LOGL_ERROR,
@@ -425,6 +432,13 @@ static int gbprox_process_bssgp_ul(struct gbproxy_config *cfg,
gbproxy_update_tlli_state_after(peer, tlli_info, now, &parse_ctx);
+ if (send_msg_directly) {
+ /* Send message directly to the selected SGSN */
+ rc = gbprox_relay2sgsn(cfg, msg, msgb_bvci(msg), sgsn_nsei);
+ /* Don't let the calling code handle the transmission */
+ return 0;
+ }
+
return 1;
}
diff --git a/openbsc/tests/gbproxy/gbproxy_test.ok b/openbsc/tests/gbproxy/gbproxy_test.ok
index 7416ffcad..90900eb17 100644
--- a/openbsc/tests/gbproxy/gbproxy_test.ok
+++ b/openbsc/tests/gbproxy/gbproxy_test.ok
@@ -3418,8 +3418,8 @@ PROCESSING IDENT RESPONSE from 0x01020304:1111
CALLBACK, event 0, msg length 40, bvci 0x1002
00 00 10 02 01 80 00 be ef 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 15 08 16 08 11 12 99 99 99 16 17 18 b2 dd 58
-NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 75 (gprs_ns_sendmsg)
-MESSAGE to SGSN at 0x05060708:32000, msg length 79
+NS UNITDATA MESSAGE to SGSN 2, BVCI 0x1002, msg length 75 (gprs_ns_sendmsg)
+MESSAGE to SGSN 2 at 0x15161718:32001, msg length 79
00 00 10 02 01 7e b5 2d fb 00 00 04 08 88 21 63 54 00 63 60 12 34 00 80 0e 00 34 01 c0 11 08 01 02 f5 e0 21 08 02 05 f4 fb c5 46 79 11 22 33 40 50 60 19 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 bf 00 5c
result (IDENT RESPONSE) = 0
@@ -3466,11 +3466,11 @@ PROCESSING IDENT RESPONSE from 0x01020304:1111
CALLBACK, event 0, msg length 40, bvci 0x1002
00 00 10 02 01 80 00 be ef 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 11 01 c0 19 08 16 08 11 12 13 14 15 16 17 18 35 23 fc
-NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 40 (gprs_ns_sendmsg)
-MESSAGE to SGSN at 0x05060708:32000, msg length 44
+NS UNITDATA MESSAGE to SGSN 2, BVCI 0x1002, msg length 40 (gprs_ns_sendmsg)
+MESSAGE to SGSN 2 at 0x15161718:32001, msg length 44
00 00 10 02 01 7e b5 2d fb 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 11 01 c0 19 08 16 08 11 12 13 14 15 16 17 18 35 23 fc
-result (IDENT RESPONSE) = 44
+result (IDENT RESPONSE) = 0
Peers:
NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
@@ -3514,11 +3514,11 @@ PROCESSING ATTACH COMPLETE from 0x01020304:1111
CALLBACK, event 0, msg length 31, bvci 0x1002
00 00 10 02 01 e6 56 aa 1f 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 08 01 c0 1d 08 03 5e 3a ea
-NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
-MESSAGE to SGSN at 0x05060708:32000, msg length 35
+NS UNITDATA MESSAGE to SGSN 2, BVCI 0x1002, msg length 31 (gprs_ns_sendmsg)
+MESSAGE to SGSN 2 at 0x15161718:32001, msg length 35
00 00 10 02 01 e0 98 76 54 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 08 01 c0 1d 08 03 5e 3a ea
-result (ATTACH COMPLETE) = 35
+result (ATTACH COMPLETE) = 0
Peers:
NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
@@ -3562,11 +3562,11 @@ PROCESSING XID (UL) from 0x01020304:1111
CALLBACK, event 0, msg length 38, bvci 0x1002
00 00 10 02 01 e6 56 aa 1f 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 0f 41 fb 01 00 0e 00 64 11 05 16 01 90 66 b3 28
-NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 38 (gprs_ns_sendmsg)
-MESSAGE to SGSN at 0x05060708:32000, msg length 42
+NS UNITDATA MESSAGE to SGSN 2, BVCI 0x1002, msg length 38 (gprs_ns_sendmsg)
+MESSAGE to SGSN 2 at 0x15161718:32001, msg length 42
00 00 10 02 01 e0 98 76 54 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 0f 41 fb 01 00 0e 00 64 11 05 16 01 90 66 b3 28
-result (XID (UL)) = 42
+result (XID (UL)) = 0
PROCESSING XID (DL) from 0x15161718:32001
00 00 10 02 00 e0 98 76 54 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 16 17 18 00 81 00 0e 8c 41 fb 30 84 10 61 b6 64 e4 a9 1a 9e
@@ -3586,11 +3586,11 @@ PROCESSING LL11 DNS QUERY (UL) from 0x01020304:1111
CALLBACK, event 0, msg length 89, bvci 0x1002
00 00 10 02 01 e6 56 aa 1f 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 42 0b c0 01 65 00 00 00 45 00 00 38 95 72 00 00 45 11 20 85 0a c0 07 e4 ac 10 01 0a ad ab 00 35 00 24 0e 1c 3b e0 01 00 00 01 00 00 00 00 00 00 01 6d 05 68 65 69 73 65 02 64 65 00 00 01 00 01 47 8f 07
-NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 89 (gprs_ns_sendmsg)
-MESSAGE to SGSN at 0x05060708:32000, msg length 93
+NS UNITDATA MESSAGE to SGSN 2, BVCI 0x1002, msg length 89 (gprs_ns_sendmsg)
+MESSAGE to SGSN 2 at 0x15161718:32001, msg length 93
00 00 10 02 01 e0 98 76 54 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 42 0b c0 01 65 00 00 00 45 00 00 38 95 72 00 00 45 11 20 85 0a c0 07 e4 ac 10 01 0a ad ab 00 35 00 24 0e 1c 3b e0 01 00 00 01 00 00 00 00 00 00 01 6d 05 68 65 69 73 65 02 64 65 00 00 01 00 01 47 8f 07
-result (LL11 DNS QUERY (UL)) = 93
+result (LL11 DNS QUERY (UL)) = 0
PROCESSING LL11 DNS RESP (DL) from 0x15161718:32001
00 00 10 02 00 e0 98 76 54 00 50 20 16 82 02 58 13 99 18 b3 43 2b 25 96 62 00 60 80 9a c2 c6 62 00 60 80 ba c8 c6 62 00 60 80 00 0a 82 08 02 0d 88 11 12 99 99 99 16 17 18 00 81 00 0e 00 d0 4b c0 01 65 00 00 00 45 00 00 c6 00 00 40 00 3e 11 7c 69 ac 10 01 0a 0a c0 07 e4 00 35 ad ab 00 b2 74 4e 3b e0 81 80 00 01 00 01 00 05 00 00 01 6d 05 68 65 69 73 65 02 64 65 00 00 01 00 01 c0 0c 00 01 00 01 00 00 0e 10 00 04 c1 63 90 58 c0 0e 00 02 00 01 00 00 0e 10 00 16 03 6e 73 32 0c 70 6f 70 2d 68 61 6e 6e 6f 76 65 72 03 6e 65 74 00 c0 0e 00 02 00 01 00 00 0e 10 00 10 02 6e 73 01 73 08 70 6c 75 73 6c 69 6e 65 c0 14 c0 0e 00 02 00 01 00 00 0e 10 00 05 02 6e 73 c0 0e c0 0e 00 02 00 01 00 00 0e 10 00 05 02 6e 73 c0 5f c0 0e 00 02 00 01 00 00 0e 10 00 12 02 6e 73 0c 70 6f 70 2d 68 61 6e 6e 6f 76 65 72 c0 14 aa df 31
@@ -3622,11 +3622,11 @@ PROCESSING LLC_DISCARDED from 0x01020304:1111
CALLBACK, event 0, msg length 19, bvci 0x0000
00 00 00 00 2c 1f 84 e6 56 aa 1f 0f 81 01 04 82 10 02 25 83 00 00 0c
-NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 19 (gprs_ns_sendmsg)
-MESSAGE to SGSN at 0x05060708:32000, msg length 23
+NS UNITDATA MESSAGE to SGSN 2, BVCI 0x0000, msg length 19 (gprs_ns_sendmsg)
+MESSAGE to SGSN 2 at 0x15161718:32001, msg length 23
00 00 00 00 2c 1f 84 e0 98 76 54 0f 81 01 04 82 10 02 25 83 00 00 0c
-result (LLC_DISCARDED) = 23
+result (LLC_DISCARDED) = 0
Peers:
NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
@@ -3670,11 +3670,11 @@ PROCESSING BVC_SUSPEND from 0x01020304:1111
CALLBACK, event 0, msg length 15, bvci 0x0000
00 00 00 00 0b 1f 84 e6 56 aa 1f 1b 86 11 22 33 40 50 60
-NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 15 (gprs_ns_sendmsg)
-MESSAGE to SGSN at 0x05060708:32000, msg length 19
+NS UNITDATA MESSAGE to SGSN 2, BVCI 0x0000, msg length 15 (gprs_ns_sendmsg)
+MESSAGE to SGSN 2 at 0x15161718:32001, msg length 19
00 00 00 00 0b 1f 84 e0 98 76 54 1b 86 21 63 54 40 50 60
-result (BVC_SUSPEND) = 19
+result (BVC_SUSPEND) = 0
Peers:
NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
@@ -3769,11 +3769,11 @@ PROCESSING DETACH REQ from 0x01020304:1111
CALLBACK, event 0, msg length 44, bvci 0x1002
00 00 10 02 01 e6 56 aa 1f 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 15 01 c0 25 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 1e 60 92
-NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 44 (gprs_ns_sendmsg)
-MESSAGE to SGSN at 0x05060708:32000, msg length 48
+NS UNITDATA MESSAGE to SGSN 2, BVCI 0x1002, msg length 44 (gprs_ns_sendmsg)
+MESSAGE to SGSN 2 at 0x15161718:32001, msg length 48
00 00 10 02 01 e0 98 76 54 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 15 01 c0 25 08 05 01 18 05 f4 e0 98 76 54 19 03 b9 97 cb 29 9a 54
-result (DETACH REQ) = 48
+result (DETACH REQ) = 0
Peers:
NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96