gbproxy: Check tlli_info when patching, fix APN patching

Currently the numeric TLLI or tlli_info's enable_patching flag is
used to decide, whether a APN shall be patched or the secondary SGSN
shall be used. Using the numeric TLLI imposes a problem, when
TLLI/P-TMSI patching is used, since gbproxy_check_tlli uses the BSS
side TLLI namespace when trying to get the tlli_info.

This patch modifies the gbproxy_check_tlli() function to accept a
tlli_info pointer instead of a numeric TLLI. The tlli_info is already
available when the function is called. Since this a similar approach
has been used by accessing the enable_patching flag directly, this
commit unifies checking by always using this function instead of the
flag outside of gb_proxy_tlli.c.

This fixes the APN patching that doesn't work currently when P-TMSI
patching is enabled.

Sponsored-by: On-Waves ehf
This commit is contained in:
Jacob Erlbeck 2014-09-08 09:59:16 +02:00
parent 82add78f89
commit 18a3787296
5 changed files with 18 additions and 15 deletions

View File

@ -177,7 +177,9 @@ void gbprox_reset(struct gbproxy_config *cfg);
/* TLLI state handling */
void gbproxy_delete_tllis(struct gbproxy_peer *peer);
int gbproxy_check_tlli(struct gbproxy_peer *peer, uint32_t tlli);
int gbproxy_check_tlli(
struct gbproxy_peer *peer,
struct gbproxy_tlli_info *tlli_info);
struct gbproxy_tlli_info *gbprox_find_tlli_by_ptmsi(
struct gbproxy_peer *peer,
uint32_t ptmsi);

View File

@ -330,7 +330,7 @@ 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) {
if (tlli_info && cfg->route_to_sgsn2 && gbproxy_check_tlli(peer, tlli_info)) {
sgsn_nsei = cfg->nsip_sgsn2_nsei;
send_msg_directly = 1;
}

View File

@ -278,7 +278,7 @@ int gbproxy_patch_llc(struct msgb *msg, uint8_t *llc, size_t llc_len,
if (parse_ctx->apn_ie &&
peer->cfg->core_apn &&
!parse_ctx->to_bss &&
gbproxy_check_tlli(peer, parse_ctx->tlli)) {
gbproxy_check_tlli(peer, tlli_info)) {
size_t new_len;
gbproxy_patch_apn_ie(msg,
parse_ctx->apn_ie, parse_ctx->apn_ie_len,

View File

@ -369,18 +369,12 @@ static void gbproxy_unregister_tlli(struct gbproxy_peer *peer, uint32_t tlli)
}
}
int gbproxy_check_tlli(struct gbproxy_peer *peer, uint32_t tlli)
int gbproxy_check_tlli(struct gbproxy_peer *peer,
struct gbproxy_tlli_info *tlli_info)
{
struct gbproxy_tlli_info *tlli_info;
LOGP(DGPRS, LOGL_INFO, "Checking TLLI %08x, class: %d\n",
tlli, gprs_tlli_type(tlli));
if (!peer->cfg->check_imsi)
return 1;
tlli_info = gbproxy_find_tlli(peer, tlli);
return tlli_info != NULL && tlli_info->enable_patching;
}

View File

@ -2136,16 +2136,17 @@ PROCESSING ACT PDP CTX REQ (REPLACE APN) from 0x01020304:1111
CALLBACK, event 0, msg length 76, bvci 0x1002
00 00 10 02 01 c0 0f 73 04 00 00 04 08 88 11 22 33 40 50 60 12 34 00 80 0e 00 35 01 c0 0d 0a 41 05 03 0c 00 00 1f 10 00 00 00 00 00 00 00 00 02 01 21 28 03 02 61 62 27 14 80 80 21 10 01 00 00 10 81 06 00 00 00 00 83 06 00 00 00 00 5a ff 02
NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 76 (gprs_ns_sendmsg)
MESSAGE to SGSN at 0x05060708:32000, msg length 80
00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 35 01 c0 0d 0a 41 05 03 0c 00 00 1f 10 00 00 00 00 00 00 00 00 02 01 21 28 03 02 61 62 27 14 80 80 21 10 01 00 00 10 81 06 00 00 00 00 83 06 00 00 00 00 5a ff 02
NS UNITDATA MESSAGE to SGSN, BVCI 0x1002, msg length 81 (gprs_ns_sendmsg)
MESSAGE to SGSN at 0x05060708:32000, msg length 85
00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 21 63 54 40 50 60 12 34 00 80 0e 00 3a 01 c0 0d 0a 41 05 03 0c 00 00 1f 10 00 00 00 00 00 00 00 00 02 01 21 28 08 03 66 6f 6f 03 62 61 72 27 14 80 80 21 10 01 00 00 10 81 06 00 00 00 00 83 06 00 00 00 00 24 9d 75
result (ACT PDP CTX REQ (REPLACE APN)) = 80
result (ACT PDP CTX REQ (REPLACE APN)) = 85
Peers:
NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
RAID patched (BSS ): 5
RAID patched (SGSN): 1
APN patched : 1
TLLI patched (BSS ): 4
TLLI patched (SGSN): 3
P-TMSI patched (SGSN): 1
@ -2205,6 +2206,7 @@ Peers:
NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
RAID patched (BSS ): 7
RAID patched (SGSN): 1
APN patched : 1
TLLI patched (BSS ): 6
TLLI patched (SGSN): 5
P-TMSI patched (SGSN): 1
@ -2228,6 +2230,7 @@ Peers:
NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
RAID patched (BSS ): 7
RAID patched (SGSN): 1
APN patched : 1
TLLI patched (BSS ): 7
TLLI patched (SGSN): 5
P-TMSI patched (SGSN): 1
@ -2251,6 +2254,7 @@ Peers:
NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
RAID patched (BSS ): 8
RAID patched (SGSN): 1
APN patched : 1
TLLI patched (BSS ): 8
TLLI patched (SGSN): 5
P-TMSI patched (SGSN): 1
@ -2274,6 +2278,7 @@ Peers:
NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
RAID patched (BSS ): 8
RAID patched (SGSN): 2
APN patched : 1
TLLI patched (BSS ): 8
TLLI patched (SGSN): 6
P-TMSI patched (SGSN): 1
@ -2340,6 +2345,7 @@ Peers:
NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
RAID patched (BSS ): 9
RAID patched (SGSN): 3
APN patched : 1
TLLI patched (BSS ): 10
TLLI patched (SGSN): 7
P-TMSI patched (SGSN): 1
@ -2363,6 +2369,7 @@ Peers:
NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96
RAID patched (BSS ): 9
RAID patched (SGSN): 3
APN patched : 1
TLLI patched (BSS ): 10
TLLI patched (SGSN): 8
P-TMSI patched (SGSN): 1