diff --git a/addons/ot/include/scope.h b/addons/ot/include/scope.h index 7b3f265428..7a3a776143 100644 --- a/addons/ot/include/scope.h +++ b/addons/ot/include/scope.h @@ -40,10 +40,10 @@ FLT_OT_DBG(3, "%s%p:{ %p %d %p %p %d }", \ (f), (a), (a)->tags, (a)->num_tags, (a)->baggage, (a)->log_fields, (a)->num_log_fields) -#define FLT_OT_DBG_RUNTIME_CONTEXT(f,a) \ - FLT_OT_DBG(3, "%s%p:{ %p %p { %016" PRIx64 " %016" PRIx64 " '%s' } %hhu %hhu 0x%02hhx 0x%08x %s %s }", \ - (f), (a), (a)->stream, (a)->filter, (a)->uuid.u64[0], (a)->uuid.u64[1], (a)->uuid.s, (a)->flag_harderr, \ - (a)->flag_disabled, (a)->logging, (a)->analyzers, flt_ot_list_debug(&((a)->spans)), \ +#define FLT_OT_DBG_RUNTIME_CONTEXT(f,a) \ + FLT_OT_DBG(3, "%s%p:{ %p %p '%s' %hhu %hhu 0x%02hhx 0x%08x %s %s }", \ + (f), (a), (a)->stream, (a)->filter, (a)->uuid, (a)->flag_harderr, \ + (a)->flag_disabled, (a)->logging, (a)->analyzers, flt_ot_list_debug(&((a)->spans)), \ flt_ot_list_debug(&((a)->contexts))) #define FLT_OT_CONST_STR_HDR(a) \ @@ -82,26 +82,11 @@ struct flt_ot_scope_context { struct list list; /* Used to chain this structure. */ }; -struct flt_ot_uuid { - union { - uint64_t u64[2]; - uint8_t u8[16]; - struct { - uint32_t time_low; - uint16_t time_mid; - uint16_t time_hi_and_version; - uint16_t clock_seq; - uint64_t node : 48; - } __attribute__((packed)); - }; - char s[40]; -}; - /* The runtime filter context attached to a stream. */ struct flt_ot_runtime_context { struct stream *stream; /* The stream to which the filter is attached. */ struct filter *filter; /* The OpenTracing filter. */ - struct flt_ot_uuid uuid; /* Randomly generated UUID. */ + char uuid[40]; /* Randomly generated UUID. */ bool flag_harderr; /* [0 1] */ bool flag_disabled; /* [0 1] */ uint8_t logging; /* [0 1 3] */ diff --git a/addons/ot/src/scope.c b/addons/ot/src/scope.c index 112f9d5454..80b0bc21b0 100644 --- a/addons/ot/src/scope.c +++ b/addons/ot/src/scope.c @@ -95,6 +95,7 @@ void flt_ot_pools_info(void) struct flt_ot_runtime_context *flt_ot_runtime_context_init(struct stream *s, struct filter *f, char **err) { const struct flt_ot_conf *conf = FLT_OT_CONF(f); + struct buffer uuid; struct flt_ot_runtime_context *retptr = NULL; FLT_OT_FUNC("%p, %p, %p:%p", s, f, FLT_OT_DPTR_ARGS(err)); @@ -105,20 +106,14 @@ struct flt_ot_runtime_context *flt_ot_runtime_context_init(struct stream *s, str retptr->stream = s; retptr->filter = f; - retptr->uuid.u64[0] = ha_random64(); - retptr->uuid.u64[1] = ha_random64(); retptr->flag_harderr = conf->tracer->flag_harderr; retptr->flag_disabled = conf->tracer->flag_disabled; retptr->logging = conf->tracer->logging; LIST_INIT(&(retptr->spans)); LIST_INIT(&(retptr->contexts)); - (void)snprintf(retptr->uuid.s, sizeof(retptr->uuid.s), "%08x-%04hx-%04hx-%04hx-%012" PRIx64, - retptr->uuid.time_low, - retptr->uuid.time_mid, - (uint16_t)((retptr->uuid.time_hi_and_version & UINT16_C(0xfff)) | UINT16_C(0x4000)), - (uint16_t)(retptr->uuid.clock_seq | UINT16_C(0x8000)), - (uint64_t)retptr->uuid.node); + uuid = b_make(retptr->uuid, sizeof(retptr->uuid), 0, 0); + ha_generate_uuid(&uuid); #ifdef USE_OT_VARS /* @@ -126,7 +121,7 @@ struct flt_ot_runtime_context *flt_ot_runtime_context_init(struct stream *s, str * after which its value is set to runtime context UUID. */ if (flt_ot_var_register(FLT_OT_VAR_UUID, err) != -1) - (void)flt_ot_var_set(s, FLT_OT_VAR_UUID, retptr->uuid.s, SMP_OPT_DIR_REQ, err); + (void)flt_ot_var_set(s, FLT_OT_VAR_UUID, retptr->uuid, SMP_OPT_DIR_REQ, err); #endif FLT_OT_DBG_RUNTIME_CONTEXT("session context: ", retptr);