pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/29336 )
Change subject: hnb_context_release(): Make sure assigned conn is freed
......................................................................
hnb_context_release(): Make sure assigned conn is freed
Otherwise, some paths calling hnb_context_release() (like failing to
transmit HNB-REGISTER-REJECT) would end up with a conn object alive with
no assigned hnb_context, which is something not wanted.
This way an alive conn object always has an associated hnb_context, and
they are only disassociated during synchronous release path.
Related: OS#5676
Change-Id: I44fea7ec74f14e0458861c92da4acf685ff695c1
---
M src/osmo-hnbgw/hnbgw.c
1 file changed, 13 insertions(+), 3 deletions(-)
Approvals:
Jenkins Builder: Verified
pespin: Looks good to me, approved
diff --git a/src/osmo-hnbgw/hnbgw.c b/src/osmo-hnbgw/hnbgw.c
index 3e94e7f..9c83053 100644
--- a/src/osmo-hnbgw/hnbgw.c
+++ b/src/osmo-hnbgw/hnbgw.c
@@ -300,9 +300,14 @@
static int hnb_closed_cb(struct osmo_stream_srv *conn)
{
struct hnb_context *hnb = osmo_stream_srv_get_data(conn);
+ if (!hnb)
+ return 0; /* hnb_context is being freed, nothing do be done */
- if (hnb)
- hnb_context_release(hnb);
+ /* hnb: conn became broken, let's release the associated hnb.
+ * conn object is being freed after closed_cb(), so unassign it from hnb
+ * if available to avoid it freeing it again: */
+ hnb->conn = NULL;
+ hnb_context_release(hnb);
return 0;
}
@@ -364,7 +369,12 @@
context_map_deactivate(map);
}
ue_context_free_by_hnb(ctx->gw, ctx);
- osmo_stream_srv_set_data(ctx->conn, NULL);
+
+ if (ctx->conn) { /* we own a conn, we must free it: */
+ /* Avoid our closed_cb calling hnb_context_release() again: */
+ osmo_stream_srv_set_data(ctx->conn, NULL);
+ osmo_stream_srv_destroy(ctx->conn);
+ } /* else: we are called from closed_cb, so conn is being freed separately */
talloc_free(ctx);
}
--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/29336
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: I44fea7ec74f14e0458861c92da4acf685ff695c1
Gerrit-Change-Number: 29336
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged
Attention is currently required from: neels.
Hello Jenkins Builder, neels, laforge,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/osmo-hnbgw/+/29336
to look at the new patch set (#2).
Change subject: hnb_context_release(): Make sure assigned conn is freed
......................................................................
hnb_context_release(): Make sure assigned conn is freed
Otherwise, some paths calling hnb_context_release() (like failing to
transmit HNB-REGISTER-REJECT) would end up with a conn object alive with
no assigned hnb_context, which is something not wanted.
This way an alive conn object always has an associated hnb_context, and
they are only disassociated during synchronous release path.
Related: OS#5676
Change-Id: I44fea7ec74f14e0458861c92da4acf685ff695c1
---
M src/osmo-hnbgw/hnbgw.c
1 file changed, 13 insertions(+), 3 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-hnbgw refs/changes/36/29336/2
--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/29336
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: I44fea7ec74f14e0458861c92da4acf685ff695c1
Gerrit-Change-Number: 29336
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de>
Gerrit-MessageType: newpatchset
Attention is currently required from: neels, pespin.
Hello Jenkins Builder, neels, laforge,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/osmo-hnbgw/+/29337
to look at the new patch set (#2).
Change subject: Improve logging around hnb_context and sctp conn lifecycle
......................................................................
Improve logging around hnb_context and sctp conn lifecycle
Change-Id: I44c79d86924ead84246b3d4937a6becae5d29185
---
M src/osmo-hnbgw/hnbgw.c
1 file changed, 8 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-hnbgw refs/changes/37/29337/2
--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/29337
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: I44c79d86924ead84246b3d4937a6becae5d29185
Gerrit-Change-Number: 29337
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newpatchset
Attention is currently required from: neels.
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/29336 )
Change subject: hnb_context_release(): Make sure assigned conn is freed
......................................................................
Patch Set 1:
(4 comments)
Commit Message:
https://gerrit.osmocom.org/c/osmo-hnbgw/+/29336/comment/730bcf09_d8dce4dd
PS1, Line 14: synchronous
> isn't release always async, because it involves messages to/from remote?
I'm precisely saying synchronous here to explain this happen in the the release code path freeing the struct, not whatever protocol transaction, hence no other unexpected code paths like select loop are possible with the conn or the hnb_context not referencing one another.
File src/osmo-hnbgw/hnbgw.c:
https://gerrit.osmocom.org/c/osmo-hnbgw/+/29336/comment/af144b64_2812da9b
PS1, Line 304: return 0; /* hnb_context is being freed, nothing do be done */
> (i thought now it is just hnb->hnb_registered == false?) […]
the hnb pointer being null means the hnb_context related to this conn is being freed (hnb_closed_cb is called as a result of osmo_stream_srv_destroy() being called by hnb_context_release()).
So "hnb_context is being freed" is totally accurate here, it will be freed right straigh away when returning from this callback.
https://gerrit.osmocom.org/c/osmo-hnbgw/+/29336/comment/f981fe67_99a39152
PS1, Line 306: /* hnb: conn became broken, let's release the associated hnb.
> maybe "conn closed on an active hnb_context" ... […]
hnb_registered=false is at the HNB layer through non having yet received an HNB-Register or after having received a HNB-De-Register message.
In here, the underlaying SCTP conn is being dropped, at which point we totally free the related hnb_context.
So there's basically no hnb_context without conn, or conn without hnb_context.
https://gerrit.osmocom.org/c/osmo-hnbgw/+/29336/comment/db3ce9a1_c57cf6eb
PS1, Line 374: to call
> calling
Ack
--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/29336
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: I44fea7ec74f14e0458861c92da4acf685ff695c1
Gerrit-Change-Number: 29336
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Comment-Date: Wed, 14 Sep 2022 10:13:19 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: neels <nhofmeyr(a)sysmocom.de>
Gerrit-MessageType: comment