aboutsummaryrefslogtreecommitdiffstats
path: root/src/gb/gprs_ns2_sns.c
AgeCommit message (Collapse)AuthorFilesLines
2021-08-06gprs_ns2_sns: ensure the SNS fsm behave correct when no signalling NSVCs are ↵lynxis/ns2_nextAlexander Couzens1-5/+20
present When no remaining signalling NSVCs are available the SNS must be restarted (BSS) or go into unconfigured state (SGSN). Change-Id: I95e6bbb7a418d647a8426804879571597ae06ff8
2021-08-06gprs_ns2: improve reselection protectionAlexander Couzens1-0/+4
Change-Id: I375a7639fb8e0f92fd67bb4176bd6219978aa428
2021-08-06gprs_ns2: add correct filename/linenr to sns failed log messageAlexander Couzens1-1/+1
Change-Id: I117eaf8340fca50cb14392a3f05ea8feac1af3ed
2021-08-06gprs_ns2_sns: implement outbound SNS DEL proceduresAlexander Couzens1-7/+76
When removing a bind the remote side needs to be informed via the SNS DELETE procedure. Related: OS#5036 Change-Id: I53cd54dfd262c70c425c3f13dad3b29526daa523
2021-08-06gprs_ns2_sns: implement outbound SNS ADD proceduresAlexander Couzens1-34/+188
When adding a bind, the remote side needs to be informed via the SNS ADD procedure. Related: OS#5036 Change-Id: I71c33200bd1f0307ceb943ee958db5ebe3623d36
2021-08-06gprs_ns2_sns: implement local change weight procedureAlexander Couzens1-6/+454
When changing the bind ip-sns weight, initiate a SNS CHANGE WEIGHT procedure to inform the other side. Related: OS#5036 Change-Id: Icec4dabb46bc198f68f91bfe09ba279fbe68d454
2021-08-06gprs_ns2: dont use llist_for_each when freeing an elementAlexander Couzens1-2/+3
The problem are recursive execution because a free generates an event which could allow the use to free a nsvcs while the llist_for_each() is still running Change-Id: I902557fb6e56e6588728a46e43a9cbe3215d5c68
2021-08-06gprs_ns2: use an event to free the nsvscs when using SNSAlexander Couzens1-1/+11
Otherwise there could be recursive loop when free'ing NSVCs which in the end create an event which the SNS want to free the NSVCs a second time Change-Id: Ie99ba5fe8a84519fe8a8c0abdf875606715ab7f6
2021-08-06gprs_ns2_sns: rework sns clean upAlexander Couzens1-16/+33
Move the cleanup into it's own state. Also changing the SGSN unconfigured state which won't be triggered when a SIZE is received. Change-Id: I2639345fdf3cd300a934238d676c543065ceaa8b
2021-08-06gprs_ns2: move sns_event into internal.h to direct emit eventsAlexander Couzens1-17/+0
Creating just a proxy function seems more overhead instead of calling it direct. Change-Id: I8e3fae4367c112b5a71bffb33c302d903855cddc
2021-08-06gprs_ns2_sns: free the NSE if the SIZE PDU is not validAlexander Couzens1-0/+14
The SGSN fsm should be freed when becoming invalid instead of going into the unconfigured state. The unconfigured states should be only used when creating the NSE (on the SGSN side). Change-Id: Ife889091ecba4180a90743deb786767008fe863d
2021-08-06gprs_ns2_sns: refactor SNS failures into a functionAlexander Couzens1-10/+25
The SNS fsm is similar for BSS and SGSN. Terminate the SGSN failures by freeing the NSE. Change-Id: I1896f6c3ddb4f98ca261139c1cc77aa8f1558c6f
2021-06-13gprs_ns2_sns: bss: set gss->familyAlexander Couzens1-0/+1
gss->family (and gss->ip) was never set. So IPv6 should have never worked. Fixes: e769f5226be6 ("gprs_ns2_sns: rework IP-SNS initial remote") Related: OS#5036 Change-Id: I4e39dc5c7f766a7040645ceb62afdf6a9cfad00f
2021-06-13gprs_ns2_sns: replace ns2_sns_type with address familyAlexander Couzens1-28/+24
Reduces the code as the conversion between address family (bind) and ns2_sns_type is not needed anymore. Related: OS#5036 Change-Id: I1bcdd43af34c926d4b88491d00669422c299bef7
2021-06-13gprs_ns2_sns: refactor nss_weight_sum_data -> ip46_weight_sum_dataAlexander Couzens1-7/+7
Allow to use ip46_weight_sum_data for local endpoints as well. Related: OS#5036 Change-Id: I75d88f3da89ad13e34a3fd5ae72bd967d81f4abc
2021-06-13gprs_ns2_sns: refactor ip4_weight_sum/ip6_weight_sumAlexander Couzens1-16/+14
Use the new introduced struct ns2_sns_elems instead of the elems seperate. Related: OS#5036 Change-Id: I0956ab6085554210569188f52cae121e32fca19b
2021-06-13gprs_ns2_sns: add check for duplicates to add_ip6_elem()Alexander Couzens1-3/+8
The ip4 version already checks for duplicates. Related: OS#5036 Change-Id: I4a1528ea3427946ce465085919b2b522d3cedd07
2021-06-07gprs_ns2_sns: move gss->remote specific check out of add_ip4_elem/add_ip6_elemAlexander Couzens1-8/+8
Allow to use the add_ip4_elem also with local elemens. Related: OS#5036 Change-Id: Ib48dfd7567467e60c5af2348924ece5cc6124206
2021-06-07gprs_ns2_sns: use struct ns2_sns_elems in add/update/remove remote_elemsAlexander Couzens1-41/+47
Prepare to use the function also with local elems. Related: OS#5036 Change-Id: I7db43c8dbd5bd7e7b07a7d629d2615bfa18623db
2021-06-07gprs_ns2_sns: refactor ns2_clear_ipv46_entries_local to use new elems functionsAlexander Couzens1-19/+10
Related: OS#5036 Change-Id: I7225f7a4215842f0ea601ce6d9d38220f98f808d
2021-06-07gprs_ns2_sns: refactor local and remote entries into a structAlexander Couzens1-105/+102
The IPv4/IPv6 elemens are the same for local and remote. Refactor the entries into a struct to use function to manipulate them with a single function. Related: OS#5036 Change-Id: I05e053a9eb3328655502dfe2981c8f402104e292
2021-06-07gprs_ns2_sns: bss: improve validation of configurationAlexander Couzens1-1/+49
Some combination of IPv4 and IPv6 result in incomplete combination. E.g. IPv6 binds, but only IPv4 endpoints and vice versa. Related: OS#5036 Change-Id: I2fcf67bc2431ddac23c4ae23cebbb29771e573f1
2021-06-07gprs_ns2_sns: move selection of the next bind into own functionAlexander Couzens1-12/+10
It will be also used by del_bind() when removing an active bind Related: OS#5036 Change-Id: Ic39f0e5474ecc055d9a1b6a7b30777574d8b741d
2021-05-23gprs_ns2: sns: fix del bind()Alexander Couzens1-0/+1
When the bind to be removed is not the last entry, it would remove the wrong SNS bind resulting in use-after-free memory. Change-Id: I79062d404ebba9d5c8f7f209bebde146fa08c71f
2021-04-18gprs_ns2: SNS: allow transition missing transition GPRS_SNS_ST_UNCONFIGUREDAlexander Couzens1-1/+2
A transistion from GPRS_SNS_ST_UNCONFIGURED -> GPRS_SNS_ST_UNCONFIGURED. Related: OS#5036 Change-Id: I125e7e5a08ea6aff6e0308a18b5c0a6d0392ad32
2021-04-07gprs_ns2: sns: remove the initial SNS NSVC if it's not partAlexander Couzens1-0/+4
A SNS configuration can be done over a NSVC, however this initial NSVC doesn't need to be part of the configuration. Those NSVC need to be removed when the configuration is done. This wrong behaviour can be seen in the vty `show ns` on NSEI 00001: UDP, ALIVE FSM Instance Name: 'GPRS-NS2-SNS-BSS(NSE00001-SNS)[0x55c72c09b420]', ID: 'NSE00001-SNS' Log-Level: 'DEBUG', State: 'CONFIGURED' Maximum number of remote NS-VCs: 8192, IPv4 Endpoints: 8192, IPv6 Endpoints: 8192 Local IPv4 Endpoints: 10.0.0.1:23000, Signalling Weight: 1, Data Weight: 1 Remote IPv4 Endpoints: 10.0.2.2:23000, Signalling Weight: 1, Data Weight: 0 10.0.2.2:23001, Signalling Weight: 0, Data Weight: 1 3 NS-VC: NSVCI none: UNBLOCKED DYNAMIC data_weight=1 sig_weight=0 udp)[10.0.0.1]:23000<>[10.0.2.2]:23000 NSVCI none: UNBLOCKED DYNAMIC data_weight=0 sig_weight=1 udp)[10.0.0.1]:23000<>[10.0.2.2]:23001 NSVCI none: UNCONFIGURED DYNAMIC data_weight=1 sig_weight=1 udp)[10.0.0.1]:23000<>[10.0.2.2]:8888 The UNCONFIGURED NSVC should not be present in when SNS is in CONFIGURED. Related: SYS#5416 Change-Id: I4045ac6c033ae084743b17a16eef4fcff76589b9
2021-04-06gprs_ns2: sns: ensure the sns->alive state is correctAlexander Couzens1-0/+12
The SNS fsms also track the NSE however since the NSVC starts now in ALIVE for SNS the SNS must check when synchronize the alive state when entering the ST_CONFIGURED. Related: SYS#5416 Change-Id: Ib6a1cc1fd84959e69c07b72ef780642205d2cd18
2021-03-29gprs_ns2: fix memory leaks when receiving SNS or invalid packetsAlexander Couzens1-3/+8
Change-Id: I8834d3f092e6cbe4f527e95e1eebd8133a386207
2021-03-29gprs_ns2_sns: Fix memory leak when creating ip[46]_local arraysHarald Welte1-3/+2
Prior to this patch, we would unconditionally allocate new memory for the local SNS IP endpoints. This results in a memory leak on every SNS-SIZE procedure. Let's move to talloc_realloc() which recycles any previously allocated memory. Change-Id: I12cb670e087c6d6190f3f5bf8483ea62008ae06f
2021-03-24gprs_ns2_sns: Don't create NS-VCs for binds outside the NSEHarald Welte1-5/+9
We may very well have any number of binds configured, but which are not part of the current NSE. When creating the "full mesh" of NS-VCs after SNS-CONFIG, we must only iterate over those binds that are part of the NSE (or 'ipa-sns-default bind' in cae of SGSN role), but not over all the other binds that may exist in the system. Closes: OS#5092 Change-Id: Ida361fa02ad1d86844d54c8f0664c996ed28e30a
2021-03-24gprs_ns2_sns: remove code duplication in create_missing_nsvcs()Harald Welte1-24/+25
Change-Id: I78d79c3bc92f0c0bebbbbe639b8406c4b188582f
2021-03-24gprs_ns2_sns: Compute local endpoints before using themHarald Welte1-1/+3
This fixes some bug introduced in Change-Id I1638f04ba45fef3ba0b237948dff6022267141fb Related: OS#3373 Change-Id: Ic0873e63f1f046b674c7898480ff070a18a7abc7
2021-03-24gprs_ns2: Add comments explaining the nsvc->sns_only fieldHarald Welte1-0/+3
Change-Id: I16009a1b03d8027de2be56b7d5013b755c9550fd
2021-03-24gprs_ns2_sns: Implement checks during processing of inbound SNS-SIZEHarald Welte1-1/+59
As per 3GPP TS 48.016 section 6.2.4.1, we need to perform some consistency checks during the SNS-SIZE procedure. Let's implement them. Change-Id: I1638f04ba45fef3ba0b237948dff6022267141fb Related: OS#3373
2021-03-24gprs_ns2_sns: Assume the SGSN has a very large number of max. NSVCHarald Welte1-2/+3
It is the SGSN's job to ensure sufficient NS-VC capacity. As the SGSN doesn't tell the BSS, we should not make assumptions of only 4. Change-Id: I41f493643cf51d7853959ab9c7bbc0ffae4e1f4b
2021-03-24gprs_ns2_sns: SNS-SIZE contains the actual number of local endpointsHarald Welte1-2/+2
The SNS-SIZE sent from BSS to SGSN contains the actual number of local IP endpoints on the BSS side, and not the maximum number of remote IP endpoints supported. Change-Id: I62a8bca4a3f7c47bcb9f292b045fa867d8877a09
2021-03-24gprs_ns2_sns: Verify mandatory IE presence in incoming SNS-SIZEHarald Welte1-2/+11
Change-Id: I40571e313c3332d8cead8fb4aa9768d0d083804d
2021-03-24gprs_ns2_sns: Don't clear remote IP endpoints in SGSN roleHarald Welte1-7/+15
In BSS role, we can clear local + remote endpoints when sending SNS-CONFIG, as we are first. In SGSN role, we must not clear remote endpoints when sending SNS-CONFIG, as we are last, and the BSS has just previously told us its IP endpoints in the BSS-originated SNS-CONFIG. Change-Id: I58549707ac5a3a0aae5f9348ed76f16c09ad3e46 Related: OS#3373
2021-03-23gprs_ns2_sns: Rename BSS-side states to include 'bss' in nameHarald Welte1-47/+48
Clearly separate those states that only occur on the BSS side from those of the SGSN side (which already have a prefix) Change-Id: Iebc97637063b2676abff4a7dce50272d9b4e336b Related: OS#3373
2021-03-23gprs_ns2_sns: Add some more OSMO_ASSERT about BSS roleHarald Welte1-1/+17
Some functions are only to be called when operating in BSS role, let's enforce that by sprinkling some OSMO_ASSERT() around. Related: OS#3373 Change-Id: I20d1bd8df62e0bb84696e291756e2d96acf49246
2021-03-23gprs_ns2_sns: Support for SGSN-side IP-SNSHarald Welte1-5/+275
This adds the core functionality of implementing the SGSN-side of IP-SNS inside a new FSM. The SGSN-side FSM shares states, events, structures and code with the BSS-side whenever possible. Note that this commit does not yet use the SGSN-side FSM, that is part of subsequent commits. Closes: OS#3373 Change-Id: I780413ffacd9cb71f64cc38057aae781eeb59b2b
2021-03-10gprs_ns2_sns: Split allstate action in generic and BSS-specific partHarald Welte1-37/+50
Related: OS#3373 Change-Id: Icd40bd76df12795b4efcaf5865c6cf00da145f94
2021-03-10gprs_ns2_sns: Unify handling of SNS-CONFIG for IPv4 + IPv6Harald Welte1-108/+72
Related: OS#3373 Change-Id: I49e5ca4a09bc772ef5a0cd5c2a76c8b200e56d1b
2021-03-05gprs_ns2_sns: refactor ns2_sns_st_size_onenter()Harald Welte1-31/+40
Let's move computing of the local IP endpoints to a separate function, so it can not only be used when entering the SNS_SIZE state. Preparation for SGSN-side IP-SNS. Change-Id: I5d7ce419135a8ef538cf9abcb76a49049ed7d5f9 Related: OS#3373
2021-03-05gprs_ns2_sns: Remove TODO (spec agrees, the correct cause code is used)Harald Welte1-1/+0
Change-Id: I6c431ba9e30d19425bf1cc1cc4d081949058610b
2021-03-05gprs_ns2_sns: Implement error log in case no binds found for NSEHarald Welte1-1/+1
Change-Id: I66ce4b429ad2597343b48210fdcbc95a1f34cbcd
2021-03-04gprs_ns2: Remove any references to DNS; we use DLNS in NS2.Harald Welte1-1/+0
Related: OS#5058 Change-Id: I1f047e022a029d5f982deae0b30fec9e5a00d1ac
2021-03-04gprs_ns2_sns: Dispatch inbound SNS-ACK to FSMHarald Welte1-2/+3
We don't really handle inbound SNS-ACK yet (as we don't originate SNS ADD/DEL/CHGWEIGHT procedures yet). However, the message receive code should already dispatch those events to the FSM, just like we do for the (equally unimplemented) handling of inbound SNS-SIZE which is already dispatched to the FSM. Change-Id: If6d5f96d85e6f05534fe49376f4473d912535ad4
2021-03-04cosmetic: ssn: some more commentsHarald Welte1-3/+3
Change-Id: I87f76ab19d834d96a268b0d47b9dfe2424151d63
2021-02-19gprs_ns2_sns: rename fsm events to include RX or REQ prefixAlexander Couzens1-67/+67
An event which originates by a received PDU is prefixed by RX. An event which originates by code gets a REQ prefix. Fixes: OS#5014 Change-Id: Ia8a6378cdca19b086e89058b1cc055f45c0bba7b