-.\" $OpenBSD: agentx.3,v 1.8 2022/03/31 17:27:15 naddy Exp $
+.\" $OpenBSD: agentx.3,v 1.9 2022/10/14 15:26:58 martijn Exp $
.\"
.\" Copyright (c) 2020 Martijn van Duren <martijn@openbsd.org>
.\"
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: March 31 2022 $
+.Dd $Mdocdate: October 14 2022 $
.Dt AGENTX 3
.Os
.Sh NAME
.Nm agentx_log_debug ,
.Nm agentx ,
.Nm agentx_connect ,
+.Nm agentx_retry ,
.Nm agentx_read ,
.Nm agentx_write ,
.Nm agentx_wantwrite ,
.Ft void
.Fn agentx_connect "struct agentx *sa" "int fd"
.Ft void
+.Fn agentx_retry "struct agentx *sa"
+.Ft void
.Fn agentx_read "struct agentx *sa"
.Ft void
.Fn agentx_write "struct agentx *sa"
.Fn agentx_write
should be called.
.Pp
+If any of the session, agentcaps, region, index, or objects failed to enable
+correctly
+.Pq as can be seen by the admin through the logs
+they can be retried through
+.Fn agentx_retry.
+.Pp
.Fa sa
can be freed via
.Fn agentx_free .
-/* $OpenBSD: agentx.c,v 1.18 2022/10/14 15:20:33 martijn Exp $ */
+/* $OpenBSD: agentx.c,v 1.19 2022/10/14 15:26:58 martijn Exp $ */
/*
* Copyright (c) 2019 Martijn van Duren <martijn@openbsd.org>
*
agentx_wantwritenow;
static void agentx_reset(struct agentx *);
static void agentx_free_finalize(struct agentx *);
+static int agentx_session_retry(struct agentx_session *);
static int agentx_session_start(struct agentx_session *);
static int agentx_session_finalize(struct ax_pdu *, void *);
static int agentx_session_close(struct agentx_session *,
static int agentx_session_close_finalize(struct ax_pdu *, void *);
static void agentx_session_free_finalize(struct agentx_session *);
static void agentx_session_reset(struct agentx_session *);
+static int agentx_context_retry(struct agentx_context *);
static void agentx_context_start(struct agentx_context *);
static void agentx_context_free_finalize(struct agentx_context *);
static void agentx_context_reset(struct agentx_context *);
static int agentx_agentcaps_close_finalize(struct ax_pdu *, void *);
static void agentx_agentcaps_free_finalize(struct agentx_agentcaps *);
static void agentx_agentcaps_reset(struct agentx_agentcaps *);
+static int agentx_region_retry(struct agentx_region *);
static int agentx_region_start(struct agentx_region *);
static int agentx_region_finalize(struct ax_pdu *, void *);
static int agentx_region_close(struct agentx_region *);
agentx_finalize(ax, fd);
}
+void
+agentx_retry(struct agentx *ax)
+{
+ struct agentx_session *axs;
+
+ if (ax->ax_fd == -1)
+ return;
+
+ TAILQ_FOREACH(axs, &(ax->ax_sessions), axs_ax_sessions) {
+ if (axs->axs_cstate == AX_CSTATE_OPEN) {
+ if (agentx_session_retry(axs) == -1)
+ return;
+ } else if (axs->axs_cstate == AX_CSTATE_CLOSE) {
+ if (agentx_session_start(axs) == -1)
+ return;
+ }
+ }
+}
+
static void
agentx_start(struct agentx *ax)
{
return axs;
}
+static int
+agentx_session_retry(struct agentx_session *axs)
+{
+ struct agentx_context *axc;
+
+#ifdef AX_DEBUG
+ if (axs->axs_cstate != AX_CSTATE_OPEN)
+ agentx_log_axs_fatalx(axs, "%s: unexpected retry", __func__);
+#endif
+
+ TAILQ_FOREACH(axc, &(axs->axs_contexts), axc_axs_contexts) {
+ if (axc->axc_cstate == AX_CSTATE_OPEN) {
+ if (agentx_context_retry(axc) == -1)
+ return -1;
+ } else if (axc->axc_cstate == AX_CSTATE_CLOSE)
+ agentx_context_start(axc);
+ }
+ return 0;
+}
+
static int
agentx_session_start(struct agentx_session *axs)
{
return axc;
}
+static int
+agentx_context_retry(struct agentx_context *axc)
+{
+ struct agentx_agentcaps *axa;
+ struct agentx_region *axr;
+
+#ifdef AX_DEBUG
+ if (axc->axc_cstate != AX_CSTATE_OPEN)
+ agentx_log_axc_fatalx(axc, "%s: unexpected retry", __func__);
+#endif
+
+ TAILQ_FOREACH(axa, &(axc->axc_agentcaps), axa_axc_agentcaps) {
+ if (axa->axa_cstate == AX_CSTATE_CLOSE) {
+ if (agentx_agentcaps_start(axa) == -1)
+ return -1;
+ }
+ }
+ TAILQ_FOREACH(axr, &(axc->axc_regions), axr_axc_regions) {
+ if (axr->axr_cstate == AX_CSTATE_OPEN) {
+ if (agentx_region_retry(axr) == -1)
+ return -1;
+ } else if (axr->axr_cstate == AX_CSTATE_CLOSE) {
+ if (agentx_region_start(axr) == -1)
+ return -1;
+ }
+ }
+ return 0;
+}
+
+
static void
agentx_context_start(struct agentx_context *axc)
{
return axr;
}
+static int
+agentx_region_retry(struct agentx_region *axr)
+{
+ struct agentx_index *axi;
+ struct agentx_object *axo;
+
+#ifdef AX_DEBUG
+ if (axr->axr_cstate != AX_CSTATE_OPEN)
+ agentx_log_axc_fatalx(axr->axr_axc,
+ "%s: unexpected retry", __func__);
+#endif
+
+ TAILQ_FOREACH(axi, &(axr->axr_indices), axi_axr_indices) {
+ if (axi->axi_cstate == AX_CSTATE_CLOSE) {
+ if (agentx_index_start(axi) == -1)
+ return -1;
+ }
+ }
+ TAILQ_FOREACH(axo, &(axr->axr_objects), axo_axr_objects) {
+ if (axo->axo_cstate == AX_CSTATE_CLOSE) {
+ if (agentx_object_start(axo) == -1)
+ return -1;
+ }
+ }
+ return 0;
+}
+
static int
agentx_region_start(struct agentx_region *axr)
{