Skip to content

Commit 1c41d6c

Browse files
Merge pull request #39 from LarryLaffer-dev/auth_aka_cluster
auth: Update CacheDB handling for AV state management and logging
2 parents b802190 + ce2a948 commit 1c41d6c

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

modules/auth_aka/aka_av_mgm.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -801,10 +801,9 @@ int aka_av_add(str *pub_id, str *priv_id, int algmask,
801801
ret = 1;
802802
LM_DBG("adding av %p\n", av);
803803

804-
/* Store AV in CacheDB for cross-node synchronization */
805-
if (aka_cdb_store_av(pub_id, priv_id, av) < 0) {
806-
LM_WARN("failed to store AV in cachedb, cross-node auth may fail\n");
807-
}
804+
/* Note: Don't store AV in CacheDB here with state=NEW.
805+
* The AV will be stored when it's marked as USING in aka_av_get_new().
806+
* This ensures cross-node lookups always find AVs in a valid state. */
808807
end:
809808
aka_user_release(user);
810809
return ret;

modules/auth_aka/auth_aka.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -905,13 +905,17 @@ static int aka_authorize(struct sip_msg *_msg, str *_realm,
905905
if (user == NULL) {
906906
/* User not found locally - check CacheDB if configured */
907907
if (aka_cdb && digest->nonce.len) {
908-
LM_DBG("user not found locally, checking CacheDB for nonce %.*s\n",
908+
LM_DBG("user not found locally, checking CacheDB for %.*s/%.*s nonce %.*s\n",
909+
public_id->len, public_id->s, private_id->len, private_id->s,
909910
digest->nonce.len, digest->nonce.s);
910911
av = aka_cdb_fetch_av(public_id, private_id, &digest->nonce);
911912
if (av) {
913+
LM_DBG("AV fetched from CacheDB: state=%d algmask=%d alg=%d\n",
914+
av->state, av->algmask, av->alg);
912915
/* Check state - only USING or USED states are valid */
913916
if (av->state != AKA_AV_USING && av->state != AKA_AV_USED) {
914-
LM_DBG("AV found in CacheDB but invalid state %d\n", av->state);
917+
LM_WARN("AV from CacheDB has invalid state %d (expected USING=%d or USED=%d)\n",
918+
av->state, AKA_AV_USING, AKA_AV_USED);
915919
shm_free(av);
916920
return STALE_NONCE;
917921
}

0 commit comments

Comments
 (0)