<p>Harald Welte <strong>merged</strong> this change.</p><p><a href="https://gerrit.osmocom.org/13761">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Jenkins Builder: Verified
Harald Welte: Looks good to me, approved
Pau Espin Pedrol: Looks good to me, approved
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">gb_proxy.h: Add missing comments; improve comments<br><br>When the patching and routing features were introduced, a lot of the<br>new structures were not documented at the same level as the pre-existing<br>code. Let's fix that.<br><br>Change-Id: I61bdd3b1cec037bce825c234a8a274b70629adc8<br>---<br>M include/osmocom/sgsn/gb_proxy.h<br>1 file changed, 46 insertions(+), 13 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/osmocom/sgsn/gb_proxy.h b/include/osmocom/sgsn/gb_proxy.h</span><br><span>index 7e2ae42..a3e1a02 100644</span><br><span>--- a/include/osmocom/sgsn/gb_proxy.h</span><br><span>+++ b/include/osmocom/sgsn/gb_proxy.h</span><br><span>@@ -70,29 +70,30 @@</span><br><span> };</span><br><span> </span><br><span> enum gbproxy_keep_mode {</span><br><span style="color: hsl(0, 100%, 40%);">- GBPROX_KEEP_NEVER,</span><br><span style="color: hsl(0, 100%, 40%);">- GBPROX_KEEP_REATTACH,</span><br><span style="color: hsl(0, 100%, 40%);">- GBPROX_KEEP_IDENTIFIED,</span><br><span style="color: hsl(0, 100%, 40%);">- GBPROX_KEEP_ALWAYS,</span><br><span style="color: hsl(120, 100%, 40%);">+ GBPROX_KEEP_NEVER, /* don't ever keep TLLI/IMSI state of de-registered subscribers */</span><br><span style="color: hsl(120, 100%, 40%);">+ GBPROX_KEEP_REATTACH, /* keep if re-attach has been requested by SGSN */</span><br><span style="color: hsl(120, 100%, 40%);">+ GBPROX_KEEP_IDENTIFIED, /* keep if we had resolved an IMSI */</span><br><span style="color: hsl(120, 100%, 40%);">+ GBPROX_KEEP_ALWAYS, /* always keep */</span><br><span> };</span><br><span> </span><br><span> enum gbproxy_match_id {</span><br><span style="color: hsl(0, 100%, 40%);">- GBPROX_MATCH_PATCHING,</span><br><span style="color: hsl(0, 100%, 40%);">- GBPROX_MATCH_ROUTING,</span><br><span style="color: hsl(120, 100%, 40%);">+ GBPROX_MATCH_PATCHING, /* match rule on whether or not we should patch */</span><br><span style="color: hsl(120, 100%, 40%);">+ GBPROX_MATCH_ROUTING, /* match rule on whether or not we should route (2-SGSN) */</span><br><span> GBPROX_MATCH_LAST</span><br><span> };</span><br><span> </span><br><span> struct gbproxy_match {</span><br><span style="color: hsl(0, 100%, 40%);">- int enable;</span><br><span style="color: hsl(0, 100%, 40%);">- char *re_str;</span><br><span style="color: hsl(0, 100%, 40%);">- regex_t re_comp;</span><br><span style="color: hsl(120, 100%, 40%);">+ int enable; /* is this match enabled? */</span><br><span style="color: hsl(120, 100%, 40%);">+ char *re_str; /* regular expression (for IMSI) in string format */</span><br><span style="color: hsl(120, 100%, 40%);">+ regex_t re_comp; /* compiled regular expression (for IMSI) */</span><br><span> };</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/* global gb-proxy configuration */</span><br><span> struct gbproxy_config {</span><br><span> /* parsed from config file */</span><br><span> uint16_t nsip_sgsn_nsei;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- /* misc */</span><br><span style="color: hsl(120, 100%, 40%);">+ /* NS instance of libosmogb */</span><br><span> struct gprs_ns_inst *nsi;</span><br><span> </span><br><span> /* Linked list of all Gb peers (except SGSN) */</span><br><span>@@ -101,10 +102,13 @@</span><br><span> /* Counter */</span><br><span> struct rate_ctr_group *ctrg;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- /* force mcc/mnc */</span><br><span style="color: hsl(120, 100%, 40%);">+ /* MCC/MNC to be patched into RA-ID on the way from BSS to SGSN? */</span><br><span> struct osmo_plmn_id core_plmn;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* APN to be patched into PDP CTX ACT REQ on the way from BSS to SGSN */</span><br><span> uint8_t* core_apn;</span><br><span> size_t core_apn_size;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* Frequency (sec) at which timer to clean stale links is fired (0 disabled) */</span><br><span> unsigned int clean_stale_timer_freq;</span><br><span> /* If !0, Max age to consider a struct gbproxy_link_info as stale */</span><br><span>@@ -114,14 +118,18 @@</span><br><span> /* If !0, Max len of gbproxy_link_info->stored_msgs (list of msgb) */</span><br><span> uint32_t stored_msgs_max_len;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- /* Experimental config */</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Should the P-TMSI be patched on the fly (required for 2-SGSN config) */</span><br><span> int patch_ptmsi;</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Should the IMSI be acquired by the proxy (required for 2-SGSN config) */</span><br><span> int acquire_imsi;</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Should we route subscribers to two different SGSNs? */</span><br><span> int route_to_sgsn2;</span><br><span style="color: hsl(120, 100%, 40%);">+ /* NSEI of the second SGSN */</span><br><span> uint16_t nsip_sgsn2_nsei;</span><br><span style="color: hsl(120, 100%, 40%);">+ /* should we keep a cache of per-subscriber state even after de-registration? */</span><br><span> enum gbproxy_keep_mode keep_link_infos;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- /* IMSI checking/matching */</span><br><span style="color: hsl(120, 100%, 40%);">+ /* IMSI checking/matching for 2-SGSN routing and patching */</span><br><span> struct gbproxy_match matches[GBPROX_MATCH_LAST];</span><br><span> };</span><br><span> </span><br><span>@@ -133,7 +141,9 @@</span><br><span> int logical_link_count;</span><br><span> };</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/* one peer at NS level that we interact with (BSS/PCU) */</span><br><span> struct gbproxy_peer {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* linked to gbproxy_config.bts_peers */</span><br><span> struct llist_head list;</span><br><span> </span><br><span> /* point back to the config */</span><br><span>@@ -152,6 +162,7 @@</span><br><span> /* Counter */</span><br><span> struct rate_ctr_group *ctrg;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /* State related to on-the-fly patching of certain messages */</span><br><span> struct gbproxy_patch_state patch_state;</span><br><span> </span><br><span> /* Fired periodically to clean up stale links from list */</span><br><span>@@ -159,32 +170,54 @@</span><br><span> };</span><br><span> </span><br><span> struct gbproxy_tlli_state {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* currently active TLLI */</span><br><span> uint32_t current;</span><br><span style="color: hsl(120, 100%, 40%);">+ /* newly-assigned TLLI (e.g. during P-TMSI allocation procedure) */</span><br><span> uint32_t assigned;</span><br><span style="color: hsl(120, 100%, 40%);">+ /* has the BSS side validated (confirmed) the new TLLI? */</span><br><span> int bss_validated;</span><br><span style="color: hsl(120, 100%, 40%);">+ /* has the SGSN side validated (confirmed) the new TLLI? */</span><br><span> int net_validated;</span><br><span style="color: hsl(120, 100%, 40%);">+ /* NOTE: once both are validated, we set current = assigned and assigned = 0 */</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /* The P-TMSI for this subscriber */</span><br><span> uint32_t ptmsi;</span><br><span> };</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/* One TLLI (= UE, = Subscriber) served via this proxy */</span><br><span> struct gbproxy_link_info {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* link to gbproxy_peer.patch_state.logical_links */</span><br><span> struct llist_head list;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /* TLLI on the BSS/PCU side */</span><br><span> struct gbproxy_tlli_state tlli;</span><br><span style="color: hsl(120, 100%, 40%);">+ /* TLLI on the SGSN side (can be different in case of P-TMSI patching) */</span><br><span> struct gbproxy_tlli_state sgsn_tlli;</span><br><span style="color: hsl(120, 100%, 40%);">+ /* NSEI of the SGSN serving this link */</span><br><span> uint32_t sgsn_nsei;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /* timestamp when we last had any contact with this UE */</span><br><span> time_t timestamp;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* IMSI of the subscriber (if/once known) */</span><br><span> uint8_t *imsi;</span><br><span> size_t imsi_len;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /* is the IMSI acquisition still pending? */</span><br><span> int imsi_acq_pending;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* queue of stored UL messages (until IMSI acquisition completes and we can</span><br><span style="color: hsl(120, 100%, 40%);">+ * determine which of the SGSNs we should route this to */</span><br><span> struct llist_head stored_msgs;</span><br><span> uint32_t stored_msgs_len;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* generated N(U) we use (required due to IMSI acquisition */</span><br><span> unsigned vu_gen_tx_bss;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /* is this subscriber deregistered (TLLI invalidated)? */</span><br><span> int is_deregistered;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /* does this link match either the (2-SGSN) routing or the patching rule? */</span><br><span> int is_matching[GBPROX_MATCH_LAST];</span><br><span> };</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/13761">change 13761</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/13761"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: osmo-sgsn </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I61bdd3b1cec037bce825c234a8a274b70629adc8 </div>
<div style="display:none"> Gerrit-Change-Number: 13761 </div>
<div style="display:none"> Gerrit-PatchSet: 4 </div>
<div style="display:none"> Gerrit-Owner: Harald Welte <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: Harald Welte <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder (1000002) </div>
<div style="display:none"> Gerrit-Reviewer: Pau Espin Pedrol <pespin@sysmocom.de> </div>