Fix MAC frequency overwrite during handover causing integrity check failures
During N2 handover, the UE receives reconfigurationWithSync which correctly sets the target cell frequency in mac->phy_config.config_req.carrier_config via config_common_ue() call. However, when SIB1 is decoded after reconfiguration, nr_rrc_mac_config_req_sib1() calls config_common_ue_sa() which unconditionally overwrites the frequency with the command-line parameter (downlink_frequency), which corresponds to the source cell frequency. This causes a critical issue during RRC re-establishment: - The UE uses the wrong frequency (source cell) for key derivation (kgnb*) - The gNB uses the correct frequency (target cell) for key derivation - This mismatch results in different kgnb* keys on UE and gNB - Integrity check fails: "Integrity of RRCReestablishment failed, going to IDLE" Root cause: config_common_ue_sa() is used for SIB1 processing (initial cell selection) and uses ServingCellConfigCommonSIB which doesn't contain absoluteFrequencyPointA. It must derive frequency from command-line parameters. However, after handover, the frequency has already been correctly set by config_common_ue() (used for reconfigurationWithSync) which uses ServingCellConfigCommon with absolute frequency information. Solution: Modify config_common_ue_sa() to preserve the existing frequency if it's already initialized (non-zero). Only set frequency from command-line parameters during initial cell selection when dl_frequency is 0. This ensures: - Initial cell selection: frequency derived from command-line parameter, just once - After handover: frequency preserved from reconfigurationWithSync - MAC maintains its own frequency state independently The fix applies to both DL and UL frequencies to maintain consistency. There is probably room for more refactoring to the resync flow, since the functionalities in config_common_ue and config_common_ue_sa are partially overlapping and upon reconfigurationWithSync some other configurations might be applied twice.
Showing
Please register or sign in to comment