From 8f0317f77c41ccd85ab19b8900090576962d5a18 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Fri, 2 Aug 2024 22:48:09 +0900 Subject: [PATCH 001/295] workflows: Fix CentOS7 build failure for EPEL (#9157) * workflows: Fix CentOS7 build failure for EPEL epel-release is already included in Extra repo on CentOS 7. Signed-off-by: Hiroshi Hatake * packaging: centos7: Use extra repo's epel-release package Signed-off-by: Hiroshi Hatake --------- Signed-off-by: Hiroshi Hatake --- dockerfiles/Dockerfile.centos7 | 3 +-- packaging/distros/centos/Dockerfile | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/dockerfiles/Dockerfile.centos7 b/dockerfiles/Dockerfile.centos7 index cc5b7cc440d..9ff9ee88ad9 100644 --- a/dockerfiles/Dockerfile.centos7 +++ b/dockerfiles/Dockerfile.centos7 @@ -11,8 +11,7 @@ RUN sed -i -e "s/^mirrorlist=http:\/\/mirrorlist.centos.org/#mirrorlist=http:\/\ wget unzip systemd-devel wget flex bison \ cyrus-sasl-lib cyrus-sasl-devel openssl openss-libs openssl-devel \ postgresql-libs postgresql-devel postgresql-server postgresql libyaml-devel && \ - wget -q http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && \ - rpm -ivh epel-release-latest-7.noarch.rpm && \ + yum install -y epel-release && \ yum install -y cmake3 COPY . /src/ diff --git a/packaging/distros/centos/Dockerfile b/packaging/distros/centos/Dockerfile index 2e0042849a5..8e70b32d478 100644 --- a/packaging/distros/centos/Dockerfile +++ b/packaging/distros/centos/Dockerfile @@ -20,8 +20,7 @@ RUN sed -i -e "s/^mirrorlist=http:\/\/mirrorlist.centos.org/#mirrorlist=http:\/\ wget unzip systemd-devel wget flex bison \ cyrus-sasl-lib cyrus-sasl-devel openssl openss-libs openssl-devel \ postgresql-libs postgresql-devel postgresql-server postgresql libyaml-devel && \ - wget -q http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && \ - rpm -ivh epel-release-latest-7.noarch.rpm && \ + yum install -y epel-release && \ yum install -y cmake3 && \ yum clean all @@ -41,8 +40,7 @@ RUN sed -i -e "s/^mirrorlist=http:\/\/mirrorlist.centos.org/#mirrorlist=http:\/\ wget unzip systemd-devel wget flex bison \ cyrus-sasl-lib cyrus-sasl-devel openssl openss-libs openssl-devel \ postgresql-libs postgresql-devel postgresql-server postgresql libyaml-devel && \ - wget -q http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && \ - rpm -ivh epel-release-latest-7.noarch.rpm && \ + yum install -y epel-release && \ yum install -y cmake3 && \ yum clean all From 3d4ad317399847bdf10e99da7cdecab3ae2b5608 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Thu, 1 Aug 2024 19:17:29 -0600 Subject: [PATCH 002/295] filter_log_to_metrics: add new option discard_logs and code cleanup By default, the filter don't drop the logs from the pipeline, there are cases where only metrics are desired to reduce log volume. This patch introduces a new option called discard_logs (default: false) which when enabled will discard the logs once they are processed. In addition, other changes were made: - replacement of flb_malloc() with flb_calloc() - context structure definition changes: e.g: do not malloc ints - fix double free on cmetrics context destroy (histograms) - general cleanups... NOTE: I noticed that record accessor contexts are being created for fixed patterns (e.g: $kubernetes['pod_name']), we will need to fix this since the creation of those contexts are expensive, is times better to have them in the context and use it on demand. Signed-off-by: Eduardo Silva --- .../filter_log_to_metrics/log_to_metrics.c | 273 ++++++++++-------- .../filter_log_to_metrics/log_to_metrics.h | 36 ++- 2 files changed, 170 insertions(+), 139 deletions(-) diff --git a/plugins/filter_log_to_metrics/log_to_metrics.c b/plugins/filter_log_to_metrics/log_to_metrics.c index 433c64e9060..e6c173f6794 100644 --- a/plugins/filter_log_to_metrics/log_to_metrics.c +++ b/plugins/filter_log_to_metrics/log_to_metrics.c @@ -17,7 +17,6 @@ * limitations under the License. */ -#include "log_to_metrics.h" #include #include #include @@ -38,13 +37,15 @@ #include #include +#include "log_to_metrics.h" static char kubernetes_label_keys[NUMBER_OF_KUBERNETES_LABELS][16] = - { "namespace_name", - "pod_name", - "container_name", - "docker_id", - "pod_id" + { + "namespace_name", + "pod_name", + "container_name", + "docker_id", + "pod_id" }; static void delete_rules(struct log_to_metrics_ctx *ctx) @@ -67,12 +68,10 @@ static void delete_rules(struct log_to_metrics_ctx *ctx) static int log_to_metrics_destroy(struct log_to_metrics_ctx *ctx) { int i; + if (!ctx) { return 0; } - if(ctx->histogram_buckets){ - cmt_histogram_buckets_destroy(ctx->histogram_buckets); - } if (ctx->cmt) { cmt_destroy(ctx->cmt); @@ -92,9 +91,8 @@ static int log_to_metrics_destroy(struct log_to_metrics_ctx *ctx) } flb_free(ctx->label_keys); } + flb_free(ctx->buckets); - flb_free(ctx->bucket_counter); - flb_free(ctx->label_counter); flb_free(ctx); return 0; } @@ -102,7 +100,7 @@ static int log_to_metrics_destroy(struct log_to_metrics_ctx *ctx) static int set_rules(struct log_to_metrics_ctx *ctx, struct flb_filter_instance *f_ins) { - flb_sds_t tmp; + int type; struct mk_list *head; struct mk_list *split; struct flb_split_entry *sentry; @@ -112,26 +110,28 @@ static int set_rules(struct log_to_metrics_ctx *ctx, /* Iterate all filter properties */ mk_list_foreach(head, &f_ins->properties) { kv = mk_list_entry(head, struct flb_kv, _head); - - /* Create a new rule */ - rule = flb_malloc(sizeof(struct grep_rule)); - if (!rule) { - flb_errno(); - return -1; - } + type = -1; /* Get the type */ if (strcasecmp(kv->key, "regex") == 0) { - rule->type = GREP_REGEX; + type = GREP_REGEX; } else if (strcasecmp(kv->key, "exclude") == 0) { - rule->type = GREP_EXCLUDE; + type = GREP_EXCLUDE; } - else { - flb_free(rule); + + if (type == -1) { continue; } + /* Create a new rule */ + rule = flb_calloc(1, sizeof(struct grep_rule)); + if (!rule) { + flb_errno(); + return -1; + } + rule->type = type; + /* As a value we expect a pair of field name and a regular expression */ split = flb_utils_split(kv->val, ' ', 1); if (mk_list_size(split) != 2) { @@ -145,16 +145,12 @@ static int set_rules(struct log_to_metrics_ctx *ctx, /* Get first value (field) */ sentry = mk_list_entry_first(split, struct flb_split_entry, _head); - if (*sentry->value == '$') { - rule->field = flb_sds_create_len(sentry->value, sentry->len); - } - else { - rule->field = flb_sds_create_size(sentry->len + 2); - tmp = flb_sds_cat(rule->field, "$", 1); - rule->field = tmp; - - tmp = flb_sds_cat(rule->field, sentry->value, sentry->len); - rule->field = tmp; + rule->field = flb_sds_create_len(sentry->value, sentry->len); + if (!rule->field) { + flb_errno(); + flb_free(rule); + flb_utils_split_free(split); + return -1; } /* Get remaining content (regular expression) */ @@ -232,7 +228,6 @@ static inline int grep_filter_data(msgpack_object map, static int set_labels(struct log_to_metrics_ctx *ctx, char **label_accessors, char **label_keys, - int *label_counter, struct flb_filter_instance *f_ins) { @@ -243,14 +238,14 @@ static int set_labels(struct log_to_metrics_ctx *ctx, struct flb_split_entry *sentry; int counter = 0; int i; + if (MAX_LABEL_COUNT < NUMBER_OF_KUBERNETES_LABELS){ - flb_errno(); return -1; } + if (ctx->kubernetes_mode){ for (i = 0; i < NUMBER_OF_KUBERNETES_LABELS; i++){ - snprintf(label_keys[i], MAX_LABEL_LENGTH - 1, "%s", - kubernetes_label_keys[i]); + snprintf(label_keys[i], MAX_LABEL_LENGTH - 1, "%s", kubernetes_label_keys[i]); } counter = NUMBER_OF_KUBERNETES_LABELS; } @@ -293,7 +288,7 @@ static int set_labels(struct log_to_metrics_ctx *ctx, continue; } } - *label_counter = counter; + return counter; } @@ -302,6 +297,7 @@ static int convert_double(char *str, double *value) char *endptr = str; int valid = 1; int i = 0; + /* input validation */ for (i = 0; str[i] != '\0'; i++) { if (!(str[i]>='0') && !(str[i] <= '9') && str[i] != '.' @@ -348,14 +344,25 @@ static int set_buckets(struct log_to_metrics_ctx *ctx, /* Iterate filter properties to get count of buckets to allocate memory */ mk_list_foreach(head, &f_ins->properties) { kv = mk_list_entry(head, struct flb_kv, _head); - if (strcasecmp(kv->key, "bucket") != 0) { continue; } counter++; } + + if (counter == 0) { + ctx->buckets = NULL; + ctx->bucket_counter = 0; + return 0; + } + /* Allocate the memory for buckets */ - ctx->buckets = (double *) flb_malloc(counter * sizeof(double)); + ctx->buckets = (double *) flb_calloc(1, counter * sizeof(double)); + if (!ctx->buckets) { + flb_errno(); + return -1; + } + /* Set the buckets */ counter = 0; mk_list_foreach(head, &f_ins->properties) { @@ -366,22 +373,22 @@ static int set_buckets(struct log_to_metrics_ctx *ctx, } valid = convert_double(kv->val, &parsed_double); if(!valid){ - flb_error("Error during conversion"); + flb_plg_error(ctx->ins, "Error during conversion"); return -1; } else{ ctx->buckets[counter++] = parsed_double; } } - *ctx->bucket_counter = counter; + ctx->bucket_counter = counter; sort_doubles_ascending(ctx->buckets, counter); return 0; } static int fill_labels(struct log_to_metrics_ctx *ctx, char **label_values, - char kubernetes_label_values - [NUMBER_OF_KUBERNETES_LABELS][MAX_LABEL_LENGTH], - char **label_accessors, int label_counter, msgpack_object map) + char kubernetes_label_values + [NUMBER_OF_KUBERNETES_LABELS][MAX_LABEL_LENGTH], + char **label_accessors, int label_counter, msgpack_object map) { int label_iterator_start = 0; int i; @@ -395,13 +402,10 @@ static int fill_labels(struct log_to_metrics_ctx *ctx, char **label_values, flb_errno(); return -1; } + if (ctx->kubernetes_mode){ for (i = 0; i < NUMBER_OF_KUBERNETES_LABELS; i++){ - if (kubernetes_label_keys[i] == NULL){ - return -1; - } - snprintf(label_values[i], MAX_LABEL_LENGTH - 1, "%s", - kubernetes_label_values[i]); + snprintf(label_values[i], MAX_LABEL_LENGTH - 1, "%s", kubernetes_label_values[i]); } label_iterator_start = NUMBER_OF_KUBERNETES_LABELS; } @@ -417,7 +421,8 @@ static int fill_labels(struct log_to_metrics_ctx *ctx, char **label_values, if (!rval) { /* Set value to empty string, so the value will be dropped in Cmetrics*/ label_values[i][0] = '\0'; - } else if (rval->type == FLB_RA_STRING) { + } + else if (rval->type == FLB_RA_STRING) { snprintf(label_values[i], MAX_LABEL_LENGTH - 1, "%s", rval->val.string); } @@ -457,14 +462,16 @@ static int cb_log_to_metrics_init(struct flb_filter_instance *f_ins, char metric_subsystem[MAX_METRIC_LENGTH]; char value_field[MAX_METRIC_LENGTH]; struct flb_input_instance *input_ins; - int label_count; + int i; /* Create context */ - ctx = flb_malloc(sizeof(struct log_to_metrics_ctx)); + ctx = flb_calloc(1, sizeof(struct log_to_metrics_ctx)); if (!ctx) { flb_errno(); return -1; } + ctx->ins = f_ins; + if (flb_filter_config_map_set(f_ins, ctx) < 0) { flb_errno(); flb_plg_error(f_ins, "configuration error"); @@ -473,7 +480,11 @@ static int cb_log_to_metrics_init(struct flb_filter_instance *f_ins, } mk_list_init(&ctx->rules); - ctx->ins = f_ins; + if (ctx->metric_name == NULL) { + flb_plg_error(f_ins, "metric_name is not set"); + log_to_metrics_destroy(ctx); + return -1; + } /* Load rules */ ret = set_rules(ctx, f_ins); @@ -486,35 +497,50 @@ static int cb_log_to_metrics_init(struct flb_filter_instance *f_ins, flb_filter_set_context(f_ins, ctx); /* Set buckets for histogram */ - ctx->bucket_counter = NULL; - ctx->histogram_buckets = NULL; ctx->buckets = NULL; - ctx->bucket_counter = flb_malloc(sizeof(int)); - if(set_buckets(ctx, f_ins) != 0) - { + ctx->bucket_counter = 0; + ctx->histogram_buckets = NULL; + + if (set_buckets(ctx, f_ins) < 0) { flb_plg_error(f_ins, "Setting buckets failed"); log_to_metrics_destroy(ctx); return -1; } ctx->label_accessors = NULL; - ctx->label_accessors = (char **) flb_malloc(MAX_LABEL_COUNT * sizeof(char *)); + ctx->label_accessors = (char **) flb_calloc(1, MAX_LABEL_COUNT * sizeof(char *)); + if (!ctx->label_accessors) { + flb_errno(); + log_to_metrics_destroy(ctx); + return -1; + } + for (i = 0; i < MAX_LABEL_COUNT; i++) { - ctx->label_accessors[i] = flb_malloc(MAX_LABEL_LENGTH * sizeof(char)); + ctx->label_accessors[i] = flb_calloc(1, MAX_LABEL_LENGTH * sizeof(char)); + if (!ctx->label_accessors[i]) { + flb_errno(); + log_to_metrics_destroy(ctx); + return -1; + } } + /* Set label keys */ - ctx->label_keys = NULL; - ctx->label_keys = (char **) flb_malloc(MAX_LABEL_COUNT * sizeof(char *)); + ctx->label_keys = (char **) flb_calloc(1, MAX_LABEL_COUNT * sizeof(char *)); for (i = 0; i < MAX_LABEL_COUNT; i++) { - ctx->label_keys[i] = flb_malloc(MAX_LABEL_LENGTH * sizeof(char)); + ctx->label_keys[i] = flb_calloc(1, MAX_LABEL_LENGTH * sizeof(char)); + if (!ctx->label_keys[i]) { + flb_errno(); + log_to_metrics_destroy(ctx); + return -1; + } } - ctx->label_counter = NULL; - ctx->label_counter = flb_malloc(sizeof(int)); - label_count = set_labels(ctx, ctx->label_accessors, ctx->label_keys, ctx->label_counter, f_ins); - if (label_count < 0){ + + ret = set_labels(ctx, ctx->label_accessors, ctx->label_keys, f_ins); + if (ret < 0){ log_to_metrics_destroy(ctx); return -1; } + ctx->label_counter = ret; /* Check metric tag */ if (ctx->tag == NULL || strlen(ctx->tag) == 0) { @@ -525,7 +551,7 @@ static int cb_log_to_metrics_init(struct flb_filter_instance *f_ins, /* Check property metric mode */ ctx->mode = 0; - tmp = (char *)flb_filter_get_property("metric_mode", f_ins); + tmp = (char *) flb_filter_get_property("metric_mode", f_ins); if (tmp != NULL) { if (strcasecmp(tmp, FLB_LOG_TO_METRICS_COUNTER_STR) == 0) { ctx->mode = FLB_LOG_TO_METRICS_COUNTER; @@ -552,7 +578,7 @@ static int cb_log_to_metrics_init(struct flb_filter_instance *f_ins, } /* Check property metric name */ - if (ctx->metric_name == NULL || strlen(ctx->metric_name) == 0) { + if (ctx->metric_name == NULL) { flb_plg_error(f_ins, "metric_name is not set"); log_to_metrics_destroy(ctx); return -1; @@ -593,17 +619,16 @@ static int cb_log_to_metrics_init(struct flb_filter_instance *f_ins, /* Check if buckets are defined for histogram, if not assume defaults */ - if (ctx->mode == FLB_LOG_TO_METRICS_HISTOGRAM ){ + if (ctx->mode == FLB_LOG_TO_METRICS_HISTOGRAM) { if (ctx->bucket_counter == 0){ - flb_plg_error(f_ins, - "buckets are not set for histogram." - "Will use defaults: 0.005, 0.01, 0.025, " - "0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0, 10.0"); + flb_plg_warn(f_ins, + "buckets are not set for histogram." + "Will use defaults: 0.005, 0.01, 0.025, " + "0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0, 10.0"); ctx->histogram_buckets = cmt_histogram_buckets_default_create(); } else{ - ctx->histogram_buckets = cmt_histogram_buckets_create_size( - ctx->buckets, *ctx->bucket_counter); + ctx->histogram_buckets = cmt_histogram_buckets_create_size(ctx->buckets, ctx->bucket_counter); } } @@ -616,19 +641,19 @@ static int cb_log_to_metrics_init(struct flb_filter_instance *f_ins, switch (ctx->mode) { case FLB_LOG_TO_METRICS_COUNTER: ctx->c = cmt_counter_create(ctx->cmt, metric_namespace, metric_subsystem, - metric_name, metric_description, - label_count, ctx->label_keys); + metric_name, metric_description, + ctx->label_counter, ctx->label_keys); break; case FLB_LOG_TO_METRICS_GAUGE: ctx->g = cmt_gauge_create(ctx->cmt, metric_namespace, metric_subsystem, metric_name, metric_description, - label_count, ctx->label_keys); + ctx->label_counter, ctx->label_keys); break; case FLB_LOG_TO_METRICS_HISTOGRAM: ctx->h = cmt_histogram_create(ctx->cmt, metric_namespace, metric_subsystem, - metric_name, metric_description, - ctx->histogram_buckets, - label_count, ctx->label_keys); + metric_name, metric_description, + ctx->histogram_buckets, + ctx->label_counter, ctx->label_keys); break; default: flb_plg_error(f_ins, "unsupported mode"); @@ -715,6 +740,7 @@ static int cb_log_to_metrics_filter(const void *data, size_t bytes, struct flb_config *config) { int ret; + int filter_ret = FLB_FILTER_NOTOUCH; msgpack_unpacked result; msgpack_object map; msgpack_object root; @@ -753,30 +779,23 @@ static int cb_log_to_metrics_filter(const void *data, size_t bytes, ret = grep_filter_data(map, context); if (ret == GREP_RET_KEEP) { ts = cfl_time_now(); - if(ctx->kubernetes_mode){ - for(i = 0; i < NUMBER_OF_KUBERNETES_LABELS; i++){ - if (kubernetes_label_keys[i] == NULL){ - flb_error("error during kubernetes label processing. " - "Skipping labels."); - ctx->label_counter = 0; - break; - } + if(ctx->kubernetes_mode) { + for (i = 0; i < NUMBER_OF_KUBERNETES_LABELS; i++) { snprintf(fmt, MAX_LABEL_LENGTH - 1, "$kubernetes['%s']", kubernetes_label_keys[i]); ra = flb_ra_create(fmt, FLB_TRUE); if (!ra) { - flb_error("invalid record accessor key, aborting"); + flb_plg_error(ctx->ins, "invalid record accessor key, aborting"); break; } rval = flb_ra_get_value_object(ra, map); if (!rval) { - flb_error("given value field is empty or not " - "existent: %s. Skipping labels.", fmt); - ctx->label_counter = 0; + flb_plg_error(ctx->ins, "given value field is empty or not " + "existent: %s. Skipping labels.", fmt); + ctx->label_counter = 0; } else if (rval->type != FLB_RA_STRING) { - flb_plg_error(f_ins, - "cannot access label %s", kubernetes_label_keys[i]); + flb_plg_error(ctx->ins, "cannot access label %s", kubernetes_label_keys[i]); break; } else { @@ -803,8 +822,8 @@ static int cb_log_to_metrics_filter(const void *data, size_t bytes, label_count = fill_labels(ctx, label_values, kubernetes_label_values, ctx->label_accessors, - *ctx->label_counter, map); - if (label_count != *ctx->label_counter){ + ctx->label_counter, map); + if (label_count != ctx->label_counter){ label_count = 0; } } @@ -819,7 +838,7 @@ static int cb_log_to_metrics_filter(const void *data, size_t bytes, case FLB_LOG_TO_METRICS_GAUGE: ra = flb_ra_create(ctx->value_field, FLB_TRUE); if (!ra) { - flb_error("invalid record accessor key, aborting"); + flb_plg_error(ctx->ins, "invalid record accessor key, aborting"); break; } @@ -902,8 +921,7 @@ static int cb_log_to_metrics_filter(const void *data, size_t bytes, } ret = flb_input_metrics_append(ctx->input_ins, ctx->tag, strlen(ctx->tag), ctx->cmt); - - if (ret != 0) { + if (ret != 0) { flb_plg_error(ctx->ins, "could not append metrics"); } @@ -922,12 +940,19 @@ static int cb_log_to_metrics_filter(const void *data, size_t bytes, /* Do nothing */ } } + + if (ctx->discard_logs) { + *out_buf = NULL; + *out_size = 0; + filter_ret = FLB_FILTER_MODIFIED; + } + /* Cleanup */ msgpack_unpacked_destroy(&result); msgpack_sbuffer_destroy(&tmp_sbuf); - /* Do not modify message stream */ - return FLB_FILTER_NOTOUCH; + /* this can be FLB_FILTER_NOTOUCH or FLB_FILTER_MODIFIED */ + return filter_ret; } static int cb_log_to_metrics_exit(void *data, struct flb_config *config) @@ -952,40 +977,34 @@ static struct flb_config_map config_map[] = { }, { FLB_CONFIG_MAP_STR, "metric_mode", "counter", - FLB_FALSE, FLB_TRUE, - offsetof(struct log_to_metrics_ctx, mode), + 0, FLB_TRUE, offsetof(struct log_to_metrics_ctx, mode), "Mode selector. Values counter, gauge," " or histogram. Summary is not supported" }, { FLB_CONFIG_MAP_STR, "value_field", NULL, - FLB_FALSE, FLB_TRUE, - offsetof(struct log_to_metrics_ctx, value_field), + 0, FLB_TRUE, offsetof(struct log_to_metrics_ctx, value_field), "Numeric field to use for gauge or histogram" }, { - FLB_CONFIG_MAP_STR, "metric_name", NULL, - FLB_FALSE, FLB_TRUE, - offsetof(struct log_to_metrics_ctx, metric_name), - "Name of metric" + FLB_CONFIG_MAP_STR, "metric_name", "a", + 0, FLB_TRUE, offsetof(struct log_to_metrics_ctx, metric_name), + "Name of the metric" }, { FLB_CONFIG_MAP_STR, "metric_namespace", DEFAULT_LOG_TO_METRICS_NAMESPACE, - FLB_FALSE, FLB_TRUE, - offsetof(struct log_to_metrics_ctx, metric_namespace), + 0, FLB_TRUE, offsetof(struct log_to_metrics_ctx, metric_namespace), "Namespace of the metric" }, { FLB_CONFIG_MAP_STR, "metric_subsystem",NULL, - FLB_FALSE, FLB_TRUE, - offsetof(struct log_to_metrics_ctx, metric_subsystem), + 0, FLB_TRUE, offsetof(struct log_to_metrics_ctx, metric_subsystem), "Subsystem of the metric" }, { FLB_CONFIG_MAP_STR, "metric_description", NULL, - FLB_FALSE, FLB_TRUE, - offsetof(struct log_to_metrics_ctx, metric_description), + 0, FLB_TRUE, offsetof(struct log_to_metrics_ctx, metric_description), "Help text for metric" }, { @@ -1010,22 +1029,28 @@ static struct flb_config_map config_map[] = { }, { FLB_CONFIG_MAP_STR, "tag", NULL, - FLB_FALSE, FLB_TRUE, - offsetof(struct log_to_metrics_ctx, tag), + 0, FLB_TRUE, offsetof(struct log_to_metrics_ctx, tag), "Metric Tag" }, { FLB_CONFIG_MAP_STR, "emitter_name", NULL, - FLB_FALSE, FLB_TRUE, - offsetof(struct log_to_metrics_ctx, emitter_name), NULL + 0, FLB_TRUE, offsetof(struct log_to_metrics_ctx, emitter_name), + "Name of the emitter (advanced users)" }, + { FLB_CONFIG_MAP_SIZE, "emitter_mem_buf_limit", FLB_MEM_BUF_LIMIT_DEFAULT, - FLB_FALSE, FLB_TRUE, - offsetof(struct log_to_metrics_ctx, emitter_mem_buf_limit), + 0, FLB_TRUE, offsetof(struct log_to_metrics_ctx, emitter_mem_buf_limit), "set a buffer limit to restrict memory usage of metrics emitter" }, + { + FLB_CONFIG_MAP_BOOL, "discard_logs", "false", + 0, FLB_TRUE, offsetof(struct log_to_metrics_ctx, discard_logs), + "Flag that defines if logs should be discarded after processing. This applies " + "for all logs, no matter if they have emitted metrics or not." + }, + {0} }; diff --git a/plugins/filter_log_to_metrics/log_to_metrics.h b/plugins/filter_log_to_metrics/log_to_metrics.h index 4f1414d0b11..77ad06ece5e 100644 --- a/plugins/filter_log_to_metrics/log_to_metrics.h +++ b/plugins/filter_log_to_metrics/log_to_metrics.h @@ -21,7 +21,7 @@ #define FLB_FILTER_LOG_TO_METRICS_H #include -#include +#include #include #include @@ -52,29 +52,35 @@ #define DEFAULT_LOG_TO_METRICS_NAMESPACE "log_metric" -struct log_to_metrics_ctx -{ +struct log_to_metrics_ctx { struct mk_list rules; struct flb_filter_instance *ins; - int mode; - flb_sds_t metric_name; - flb_sds_t metric_namespace; - flb_sds_t metric_subsystem; - flb_sds_t metric_description; struct cmt *cmt; + struct flb_input_instance *input_ins; - flb_sds_t value_field; + + char **label_keys; + char **label_accessors; + + int label_counter; + int bucket_counter; + double *buckets; + struct cmt_counter *c; struct cmt_gauge *g; struct cmt_histogram *h; struct cmt_histogram_buckets *histogram_buckets; - char **label_accessors; - char **label_keys; - int *label_counter; - bool kubernetes_mode; + + /* config options */ + int mode; + int discard_logs; + int kubernetes_mode; + flb_sds_t metric_name; + flb_sds_t metric_namespace; + flb_sds_t metric_subsystem; + flb_sds_t metric_description; + flb_sds_t value_field; flb_sds_t tag; - int *bucket_counter; - double *buckets; flb_sds_t emitter_name; size_t emitter_mem_buf_limit; }; From a6aac459d5ec1d1d591986f4e130cc7b69ffe56f Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Sun, 4 Aug 2024 07:21:32 +0900 Subject: [PATCH 003/295] in_node_exporter_metrics: Align the collecting metrics of unit statuses (#9134) Signed-off-by: Hiroshi Hatake --- plugins/in_node_exporter_metrics/ne_systemd_linux.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/in_node_exporter_metrics/ne_systemd_linux.c b/plugins/in_node_exporter_metrics/ne_systemd_linux.c index f0db5aa0fc7..ffd265bc041 100644 --- a/plugins/in_node_exporter_metrics/ne_systemd_linux.c +++ b/plugins/in_node_exporter_metrics/ne_systemd_linux.c @@ -459,7 +459,7 @@ static int ne_systemd_update_unit_state(struct flb_ne *ctx) } for(index = 0 ; index < 5 ; index++) { - cmt_gauge_add(ctx->systemd_unit_state, + cmt_gauge_set(ctx->systemd_unit_state, timestamp, 0, 3, @@ -469,8 +469,9 @@ static int ne_systemd_update_unit_state(struct flb_ne *ctx) }); } - cmt_gauge_inc(ctx->systemd_unit_state, + cmt_gauge_set(ctx->systemd_unit_state, timestamp, + 1, 3, (char *[]){ unit.name, unit.active_state, From 87ea26d65a4b26b95f7be127e8bcd1f6977c5a77 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Mon, 5 Aug 2024 00:10:01 +0900 Subject: [PATCH 004/295] gzip: Extract and unify code for concatenated gzip payloads Signed-off-by: Hiroshi Hatake --- include/fluent-bit/flb_gzip.h | 1 + src/flb_gzip.c | 66 ++++++++++++++++++++++++++++++++++- 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/include/fluent-bit/flb_gzip.h b/include/fluent-bit/flb_gzip.h index 2efe9710d58..e52b04acc0e 100644 --- a/include/fluent-bit/flb_gzip.h +++ b/include/fluent-bit/flb_gzip.h @@ -38,5 +38,6 @@ int flb_gzip_decompressor_dispatch(struct flb_decompression_context *context, void *out_data, size_t *out_size); int flb_is_http_session_gzip_compressed(struct mk_http_session *session); +size_t flb_gzip_count(const char *data, size_t len, size_t **out_borders, size_t border_count); #endif diff --git a/src/flb_gzip.c b/src/flb_gzip.c index a33b5558fec..3beea66b2cf 100644 --- a/src/flb_gzip.c +++ b/src/flb_gzip.c @@ -771,4 +771,68 @@ int flb_is_http_session_gzip_compressed(struct mk_http_session *session) } return gzip_compressed; -} \ No newline at end of file +} + +static int vaild_os_flag(const char data) +{ + uint8_t p; + + p = (uint8_t)data; + if (p == 0x00 || /* Fat Filesystem */ + p == 0x01 || /* Amiga */ + p == 0x02 || /* VMS */ + p == 0x03 || /* Unix */ + p == 0x04 || /* VM/CMS */ + p == 0x05 || /* Atari TOS */ + p == 0x06 || /* HPFS Filesystem (OS/2, NT) */ + p == 0x07 || /* Macintosh */ + p == 0x08 || /* Z-System */ + p == 0x09 || /* CP/M */ + p == 0x0a || /* TOPS-20 */ + p == 0x0b || /* NTFS filesystem (NT) */ + p == 0x0c || /* QDOS */ + p == 0x0d || /* Acorn RISCOS */ + p == 0xff) /* Unknown */ { + + return FLB_TRUE; + } + + return FLB_FALSE; +} + +size_t flb_gzip_count(const char *data, size_t len, size_t **out_borders, size_t border_count) +{ + int i; + size_t count = 0; + const uint8_t *p; + size_t *borders = NULL; + + if (out_borders != NULL) { + borders = *out_borders; + } + + p = (const uint8_t *) data; + /* search other gzip starting bits and method. */ + for (i = 2; i < len && + i + 9 <= len; i++) { + /* A vaild gzip payloads are larger than 18 bytes. */ + if (len - i < 18) { + break; + } + + if (p[i] == 0x1F && p[i+1] == 0x8B && p[i+2] == 8 && + vaild_os_flag(p[i+9])) { + if (out_borders != NULL) { + borders[count] = i; + } + count++; + } + } + + if (out_borders != NULL && border_count >= count) { + /* The length of the last border refers to the original length. */ + borders[border_count] = len; + } + + return count; +} From a4956ccba0ae6254b897eb49e0db03999d002151 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Mon, 5 Aug 2024 00:10:38 +0900 Subject: [PATCH 005/295] in_forward: Use extracted function for processing concatenated gzip Signed-off-by: Hiroshi Hatake --- plugins/in_forward/fw_prot.c | 60 +++++------------------------------- 1 file changed, 8 insertions(+), 52 deletions(-) diff --git a/plugins/in_forward/fw_prot.c b/plugins/in_forward/fw_prot.c index 5f8fa6feb0c..82d37244a5b 100644 --- a/plugins/in_forward/fw_prot.c +++ b/plugins/in_forward/fw_prot.c @@ -1200,55 +1200,6 @@ int fw_prot_secure_forward_handshake(struct flb_input_instance *ins, return -1; } -static size_t gzip_concatenated_count(const char *data, size_t len) -{ - int i; - size_t count = 0; - const uint8_t *p; - - p = (const uint8_t *) data; - - /* search other gzip starting bits and method. */ - for (i = 2; i < len && - i + 2 <= len; i++) { - if (p[i] == 0x1F && p[i+1] == 0x8B && p[i+2] == 8) { - count++; - } - } - - return count; -} - -static size_t gzip_concatenated_borders(const char *data, size_t len, size_t **out_borders, size_t border_count) -{ - int i; - size_t count = 0; - const uint8_t *p; - size_t *borders = NULL; - - p = (const uint8_t *) data; - borders = (size_t *) flb_calloc(1, sizeof(size_t) * (border_count + 1)); - if (borders == NULL) { - flb_errno(); - return -1; - } - - /* search other gzip starting bits and method. */ - for (i = 2; i < len && - i + 2 <= len; i++) { - if (p[i] == 0x1F && p[i+1] == 0x8B && p[i+2] == 8) { - borders[count] = i; - count++; - } - } - /* The length of the last border refers to the original length. */ - borders[border_count] = len; - - *out_borders = borders; - - return count; -} - int fw_prot_process(struct flb_input_instance *ins, struct fw_conn *conn) { int ret; @@ -1543,11 +1494,16 @@ int fw_prot_process(struct flb_input_instance *ins, struct fw_conn *conn) size_t *gzip_borders = NULL; const size_t original_len = len; - gzip_payloads_count = gzip_concatenated_count(data, len); + gzip_payloads_count = flb_gzip_count(data, len, NULL, 0); flb_plg_debug(ctx->ins, "concatenated gzip payload count is %zd", gzip_payloads_count); if (gzip_payloads_count > 0) { - if (gzip_concatenated_borders(data, len, &gzip_borders, gzip_payloads_count) < 0) { + gzip_borders = (size_t *)flb_calloc(1, sizeof(size_t) * (gzip_payloads_count + 1)); + if (gzip_borders == NULL) { + flb_errno(); + return -1; + } + if (flb_gzip_count(data, len, &gzip_borders, gzip_payloads_count) < 0) { flb_plg_error(ctx->ins, "failed to traverse boundaries of concatenated gzip payloads"); return -1; @@ -1618,7 +1574,7 @@ int fw_prot_process(struct flb_input_instance *ins, struct fw_conn *conn) /* a valid payload of gzip is larger than 18 bytes. */ if (gzip_payloads_count > 0) { if ((gzip_payloads_count - loop) > 0 && - (original_len - gzip_borders[loop]) > 18) { + (original_len - gzip_borders[loop]) >= 18) { len = original_len - gzip_borders[loop]; flb_plg_debug(ctx->ins, "left unconsumed %zd byte(s)", len); prev_pos = gzip_borders[loop]; From c15ca2fbaf8d6480fe71fc4fd77312d87263122b Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Mon, 5 Aug 2024 00:11:29 +0900 Subject: [PATCH 006/295] test: internal: gzip: Add testcases for payloads of concatenated gzip Signed-off-by: Hiroshi Hatake --- tests/internal/gzip.c | 62 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/tests/internal/gzip.c b/tests/internal/gzip.c index a3f82341868..fcad4b684ac 100644 --- a/tests/internal/gzip.c +++ b/tests/internal/gzip.c @@ -40,7 +40,69 @@ void test_compress() flb_free(str); } +void test_concatenated_gzip_count() +{ + int ret; + int sample_len; + char *in_data = morpheus; + size_t in_len; + void *str; + size_t len; + flb_sds_t payload = NULL; + flb_sds_t payload2 = NULL; + size_t border_count = 0; + + sample_len = strlen(morpheus); + in_len = sample_len; + ret = flb_gzip_compress(in_data, in_len, &str, &len); + TEST_CHECK(ret == 0); + + payload = flb_sds_create_len((char *)str, len); + payload2 = flb_sds_create_len((char *)str, len); + ret = flb_sds_cat_safe(&payload, payload2, flb_sds_len(payload2)); + TEST_CHECK(ret == 0); + + border_count = flb_gzip_count(payload, flb_sds_len(payload), NULL, 0); + TEST_CHECK(border_count == 1); + + flb_free(str); + flb_sds_destroy(payload); + flb_sds_destroy(payload2); +} + +void test_not_overflow_for_concatenated_gzip() +{ + const char data[] = { + 0x00, 0x00, /* Initial padding */ + 0x1F, 0x8B, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, /* First gzip header (valid header) */ + 0x1F, 0x8B, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, /* Second gzip header (valid header) */ + 0x1F, 0x8B, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, /* Third gzip header (valid header) */ + }; + size_t len = sizeof(data); + size_t *borders = NULL; + size_t border_count = 0; + size_t count = 0; + + /* Vaild gzip payloads have to 18 bytes lentgh at least. + * So, we get only 2 of vaild parts. + */ + border_count = flb_gzip_count(data, len, NULL, 0); + TEST_CHECK(border_count == 2); + + borders = (size_t *)flb_calloc(1, sizeof(size_t) * (border_count + 1)); + TEST_CHECK(borders != NULL); + + count = flb_gzip_count(data, len, &borders, border_count); + TEST_CHECK(count == 2); + + if (borders != NULL) { + free(borders); + } +} + TEST_LIST = { {"compress", test_compress}, + {"count", test_concatenated_gzip_count}, + {"not_overflow", test_not_overflow_for_concatenated_gzip}, { 0 } }; From 209095d6903d743605eafb4b436e86f113d6a283 Mon Sep 17 00:00:00 2001 From: Takahiro Yamashita Date: Sun, 24 Sep 2023 08:27:52 +0900 Subject: [PATCH 007/295] out_oracle_log_analytics: remove flb_errno that checks NULL Signed-off-by: Takahiro Yamashita --- plugins/out_oracle_log_analytics/oci_logan_conf.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/plugins/out_oracle_log_analytics/oci_logan_conf.c b/plugins/out_oracle_log_analytics/oci_logan_conf.c index d6efc431c29..3778a298d2b 100644 --- a/plugins/out_oracle_log_analytics/oci_logan_conf.c +++ b/plugins/out_oracle_log_analytics/oci_logan_conf.c @@ -290,7 +290,6 @@ struct flb_oci_logan *flb_oci_logan_conf_create(struct flb_output_instance *ins, if (ctx->oci_config_in_record == FLB_FALSE) { if (ctx->oci_la_log_source_name == NULL || ctx->oci_la_log_group_id == NULL) { - flb_errno(); flb_plg_error(ctx->ins, "log source name and log group id are required"); flb_oci_logan_conf_destroy(ctx); @@ -318,7 +317,6 @@ struct flb_oci_logan *flb_oci_logan_conf_create(struct flb_output_instance *ins, } if (!ctx->config_file_location) { - flb_errno(); flb_plg_error(ctx->ins, "config file location is required"); flb_oci_logan_conf_destroy(ctx); return NULL; @@ -336,7 +334,6 @@ struct flb_oci_logan *flb_oci_logan_conf_create(struct flb_output_instance *ins, } else { if (!ctx->region) { - flb_errno(); flb_plg_error(ctx->ins, "Region is required"); flb_oci_logan_conf_destroy(ctx); return NULL; @@ -347,7 +344,6 @@ struct flb_oci_logan *flb_oci_logan_conf_create(struct flb_output_instance *ins, if (!ctx->uri) { if (!ctx->namespace) { - flb_errno(); flb_plg_error(ctx->ins, "Namespace is required"); flb_oci_logan_conf_destroy(ctx); return NULL; @@ -490,4 +486,4 @@ int flb_oci_logan_conf_destroy(struct flb_oci_logan *ctx) { flb_free(ctx); return 0; -} \ No newline at end of file +} From 7ce4aa6a07fe5e37208d8bf89569d5cbe59df70a Mon Sep 17 00:00:00 2001 From: Takahiro Yamashita Date: Sun, 24 Sep 2023 08:30:06 +0900 Subject: [PATCH 008/295] out_oracle_log_analytics: add flb_sds_destroy for key Signed-off-by: Takahiro Yamashita --- plugins/out_oracle_log_analytics/oci_logan_conf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/out_oracle_log_analytics/oci_logan_conf.c b/plugins/out_oracle_log_analytics/oci_logan_conf.c index 3778a298d2b..25a53454463 100644 --- a/plugins/out_oracle_log_analytics/oci_logan_conf.c +++ b/plugins/out_oracle_log_analytics/oci_logan_conf.c @@ -209,6 +209,7 @@ static int global_metadata_fields_create(struct flb_oci_logan *ctx) } f->val = flb_sds_create(val->str); if (!f->val) { + flb_sds_destroy(f->key); flb_free(f); return -1; } @@ -249,6 +250,7 @@ static int log_event_metadata_create(struct flb_oci_logan *ctx) } f->val = flb_sds_create(val->str); if (!f->val) { + flb_sds_destroy(f->key); flb_free(f); return -1; } From 3a37eb8f6ff25d5e15d02f0d6f86a5e769e32bbc Mon Sep 17 00:00:00 2001 From: Takahiro Yamashita Date: Sun, 24 Sep 2023 09:01:14 +0900 Subject: [PATCH 009/295] out_oracle_log_analytics: fix mk_list cleanup function Signed-off-by: Takahiro Yamashita --- .../out_oracle_log_analytics/oci_logan_conf.c | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/plugins/out_oracle_log_analytics/oci_logan_conf.c b/plugins/out_oracle_log_analytics/oci_logan_conf.c index 25a53454463..76d7d676140 100644 --- a/plugins/out_oracle_log_analytics/oci_logan_conf.c +++ b/plugins/out_oracle_log_analytics/oci_logan_conf.c @@ -279,6 +279,8 @@ struct flb_oci_logan *flb_oci_logan_conf_create(struct flb_output_instance *ins, flb_errno(); return NULL; } + mk_list_init(&ctx->global_metadata_fields); + mk_list_init(&ctx->log_event_metadata_fields); ctx->ins = ins; @@ -298,8 +300,8 @@ struct flb_oci_logan *flb_oci_logan_conf_create(struct flb_output_instance *ins, return NULL; } } + if (ctx->oci_la_global_metadata != NULL) { - mk_list_init(&ctx->global_metadata_fields); ret = global_metadata_fields_create(ctx); if (ret != 0) { flb_errno(); @@ -309,7 +311,6 @@ struct flb_oci_logan *flb_oci_logan_conf_create(struct flb_output_instance *ins, } if (ctx->oci_la_metadata != NULL) { - mk_list_init(&ctx->log_event_metadata_fields); ret = log_event_metadata_create(ctx); if (ret != 0) { flb_errno(); @@ -435,16 +436,24 @@ static void metadata_fields_destroy(struct flb_oci_logan *ctx) mk_list_foreach_safe(head, tmp, &ctx->global_metadata_fields) { f = mk_list_entry(head, struct metadata_obj, _head); - flb_sds_destroy(f->key); - flb_sds_destroy(f->val); + if (f->key) { + flb_sds_destroy(f->key); + } + if (f->val) { + flb_sds_destroy(f->val); + } mk_list_del(&f->_head); flb_free(f); } mk_list_foreach_safe(head, tmp, &ctx->log_event_metadata_fields) { f = mk_list_entry(head, struct metadata_obj, _head); - flb_sds_destroy(f->key); - flb_sds_destroy(f->val); + if (f->key) { + flb_sds_destroy(f->key); + } + if (f->val) { + flb_sds_destroy(f->val); + } mk_list_del(&f->_head); flb_free(f); } From e19b2ab142e4e3be2060532ffb4064dbb3c3f049 Mon Sep 17 00:00:00 2001 From: Takahiro Yamashita Date: Sun, 24 Sep 2023 09:10:50 +0900 Subject: [PATCH 010/295] out_oracle_log_analytics: set NULL to prevent double free Signed-off-by: Takahiro Yamashita --- plugins/out_oracle_log_analytics/oci_logan_conf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/out_oracle_log_analytics/oci_logan_conf.c b/plugins/out_oracle_log_analytics/oci_logan_conf.c index 76d7d676140..1e77271431c 100644 --- a/plugins/out_oracle_log_analytics/oci_logan_conf.c +++ b/plugins/out_oracle_log_analytics/oci_logan_conf.c @@ -121,6 +121,7 @@ static int load_oci_credentials(struct flb_oci_logan *ctx) goto iterate; } mk_mem_free(profile); + profile = NULL; } if(found_profile) { if(line[0] == '[') { From d58f2336b6f81b4e94fe713d7c72e2d92fd89466 Mon Sep 17 00:00:00 2001 From: Pat Date: Tue, 6 Aug 2024 09:27:05 -0400 Subject: [PATCH 011/295] workflows: update unstable nightly builds for 3.0 (#9168) Signed-off-by: Patrick Stephens --- .github/workflows/cron-unstable-build.yaml | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/.github/workflows/cron-unstable-build.yaml b/.github/workflows/cron-unstable-build.yaml index 37d9f17b9c8..21900791754 100644 --- a/.github/workflows/cron-unstable-build.yaml +++ b/.github/workflows/cron-unstable-build.yaml @@ -13,8 +13,7 @@ on: # Run nightly build at this time, bit of trial and error but this seems good. schedule: - cron: "0 6 * * *" # master build - - cron: "0 12 * * *" # 2.2 build - - cron: "0 18 * * *" # 2.1 build + - cron: "0 12 * * *" # 3.0 build # We do not want a new unstable build to run whilst we are releasing the current unstable build. concurrency: unstable-build-release @@ -52,16 +51,10 @@ jobs: echo "cron_branch=master" >> $GITHUB_ENV shell: bash - - name: 2.2 run + - name: 3.0 run if: github.event_name == 'schedule' && github.event.schedule=='0 12 * * *' run: | - echo "cron_branch=2.2" >> $GITHUB_ENV - shell: bash - - - name: 2.1 run - if: github.event_name == 'schedule' && github.event.schedule=='0 18 * * *' - run: | - echo "cron_branch=2.1" >> $GITHUB_ENV + echo "cron_branch=3.0" >> $GITHUB_ENV shell: bash - name: Output the branch to use From a86dceed214218cfdd4898858ad36877c403b33c Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Tue, 6 Aug 2024 09:04:55 -0600 Subject: [PATCH 012/295] lib: cfl: upgrade to v0.5.2 Signed-off-by: Eduardo Silva --- lib/cfl/.github/workflows/build.yaml | 11 +- lib/cfl/.github/workflows/packages.yaml | 2 +- lib/cfl/CMakeLists.txt | 2 +- lib/cfl/include/cfl/cfl.h | 2 + lib/cfl/include/cfl/cfl_array.h | 5 + lib/cfl/include/cfl/cfl_compat.h | 1 - lib/cfl/include/cfl/cfl_utils.h | 20 ++ lib/cfl/src/CMakeLists.txt | 1 + lib/cfl/src/cfl.c | 8 + lib/cfl/src/cfl_utils.c | 285 ++++++++++++++++++++++++ lib/cfl/tests/CMakeLists.txt | 2 + lib/cfl/tests/array.c | 1 - lib/cfl/tests/list.c | 73 +++++- lib/cfl/tests/utils.c | 162 ++++++++++++++ lib/cfl/tests/version.c | 37 +++ 15 files changed, 593 insertions(+), 19 deletions(-) create mode 100644 lib/cfl/include/cfl/cfl_utils.h create mode 100644 lib/cfl/src/cfl_utils.c create mode 100644 lib/cfl/tests/utils.c create mode 100644 lib/cfl/tests/version.c diff --git a/lib/cfl/.github/workflows/build.yaml b/lib/cfl/.github/workflows/build.yaml index 8f3ad73910e..ff9d15095d1 100644 --- a/lib/cfl/.github/workflows/build.yaml +++ b/lib/cfl/.github/workflows/build.yaml @@ -7,6 +7,7 @@ on: branches: - master types: [opened, reopened, synchronize] + jobs: build-windows: name: Build sources on amd64 for ${{ matrix.os }} @@ -57,13 +58,17 @@ jobs: name: CentOS 7 build to confirm no issues once used downstream runs-on: ubuntu-latest container: centos:7 + env: + # workaround required for checkout@v3, https://github.com/actions/checkout/issues/1590 + ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true steps: - name: Set up base image dependencies run: | + sed -i -e "s/^mirrorlist=http:\/\/mirrorlist.centos.org/#mirrorlist=http:\/\/mirrorlist.centos.org/g" /etc/yum.repos.d/CentOS-Base.repo + sed -i -e "s/^#baseurl=http:\/\/mirror.centos.org/baseurl=http:\/\/vault.centos.org/g" /etc/yum.repos.d/CentOS-Base.repo yum -y update yum install -y ca-certificates cmake gcc gcc-c++ make wget - wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm - rpm -ivh epel-release-latest-7.noarch.rpm + yum install -y epel-release yum install -y cmake3 shell: bash @@ -103,7 +108,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Build on ${{ matrix.os }} with ${{ matrix.compiler }} - uses: uraimo/run-on-arch-action@v2.3.0 + uses: uraimo/run-on-arch-action@v2.5.0 with: arch: aarch64 distro: ubuntu20.04 diff --git a/lib/cfl/.github/workflows/packages.yaml b/lib/cfl/.github/workflows/packages.yaml index 2c5bedbee2b..34967c491d6 100644 --- a/lib/cfl/.github/workflows/packages.yaml +++ b/lib/cfl/.github/workflows/packages.yaml @@ -19,7 +19,7 @@ jobs: format: [ rpm, deb ] steps: - uses: actions/checkout@v3 - - uses: uraimo/run-on-arch-action@v2.3.0 + - uses: uraimo/run-on-arch-action@v2.5.0 name: Build the ${{matrix.format}} packages with: arch: aarch64 diff --git a/lib/cfl/CMakeLists.txt b/lib/cfl/CMakeLists.txt index f6a355679a4..2193cb29ce3 100644 --- a/lib/cfl/CMakeLists.txt +++ b/lib/cfl/CMakeLists.txt @@ -6,7 +6,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # C Floppy Version set(CFL_VERSION_MAJOR 0) set(CFL_VERSION_MINOR 5) -set(CFL_VERSION_PATCH 0) +set(CFL_VERSION_PATCH 1) set(CFL_VERSION_STR "${CFL_VERSION_MAJOR}.${CFL_VERSION_MINOR}.${CFL_VERSION_PATCH}") # Configuration options diff --git a/lib/cfl/include/cfl/cfl.h b/lib/cfl/include/cfl/cfl.h index 8e4efa763d4..921767e8091 100644 --- a/lib/cfl/include/cfl/cfl.h +++ b/lib/cfl/include/cfl/cfl.h @@ -37,7 +37,9 @@ #include #include #include +#include int cfl_init(); +char *cfl_version(); #endif diff --git a/lib/cfl/include/cfl/cfl_array.h b/lib/cfl/include/cfl/cfl_array.h index 3977df75e6b..331a4cbc6b6 100644 --- a/lib/cfl/include/cfl/cfl_array.h +++ b/lib/cfl/include/cfl/cfl_array.h @@ -43,6 +43,11 @@ static inline struct cfl_variant *cfl_array_fetch_by_index(struct cfl_array *arr return array->entries[position]; } +static inline size_t cfl_array_size(struct cfl_array *array) +{ + return array->entry_count; +} + int cfl_array_append(struct cfl_array *array, struct cfl_variant *value); int cfl_array_append_string(struct cfl_array *array, char *value); int cfl_array_append_string_s(struct cfl_array *array, char *str, size_t str_len, int referenced); diff --git a/lib/cfl/include/cfl/cfl_compat.h b/lib/cfl/include/cfl/cfl_compat.h index bc1de9a0673..4972f907e49 100644 --- a/lib/cfl/include/cfl/cfl_compat.h +++ b/lib/cfl/include/cfl/cfl_compat.h @@ -45,4 +45,3 @@ #endif #endif - diff --git a/lib/cfl/include/cfl/cfl_utils.h b/lib/cfl/include/cfl/cfl_utils.h new file mode 100644 index 00000000000..db9d873ee1c --- /dev/null +++ b/lib/cfl/include/cfl/cfl_utils.h @@ -0,0 +1,20 @@ +#ifndef CFL_UTILS_H +#define CFL_UTILS_H + +#include /* off_t */ +#include +#include + +struct cfl_split_entry { + char *value; + int len; + off_t last_pos; + struct cfl_list _head; +}; + +struct cfl_list *cfl_utils_split_quoted(const char *line, int separator, int max_split); +struct cfl_list *cfl_utils_split(const char *line, int separator, int max_split); +void cfl_utils_split_free_entry(struct cfl_split_entry *entry); +void cfl_utils_split_free(struct cfl_list *list); + +#endif diff --git a/lib/cfl/src/CMakeLists.txt b/lib/cfl/src/CMakeLists.txt index 05383f3fef3..f09a5c3d8b1 100644 --- a/lib/cfl/src/CMakeLists.txt +++ b/lib/cfl/src/CMakeLists.txt @@ -9,6 +9,7 @@ set(src cfl_array.c cfl_variant.c cfl_checksum.c + cfl_utils.c ) # Static Library diff --git a/lib/cfl/src/cfl.c b/lib/cfl/src/cfl.c index 7afb1109aa5..426319a2747 100644 --- a/lib/cfl/src/cfl.c +++ b/lib/cfl/src/cfl.c @@ -17,7 +17,15 @@ * limitations under the License. */ +#include + int cfl_init() { return 0; } + +char *cfl_version() +{ + return CFL_VERSION_STR; +} + diff --git a/lib/cfl/src/cfl_utils.c b/lib/cfl/src/cfl_utils.c new file mode 100644 index 00000000000..5342134e7e5 --- /dev/null +++ b/lib/cfl/src/cfl_utils.c @@ -0,0 +1,285 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* CFL + * === + * Copyright (C) 2022 The CFL Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +/* Lookup char into string, return position + * Based on monkey/monkey's mk_string_char_search. + */ +static int cfl_string_char_search(const char *string, int c, int len) +{ + char *p; + + if (len < 0) { + len = strlen(string); + } + + p = memchr(string, c, len); + if (p) { + return (p - string); + } + + return -1; +} + +/* Return a buffer with a new string from string. + * Based on monkey/monkey's mk_string_copy_substr. + */ +static char *cfl_string_copy_substr(const char *string, int pos_init, int pos_end) +{ + unsigned int size, bytes; + char *buffer = 0; + + if (pos_init > pos_end) { + return NULL; + } + + size = (unsigned int) (pos_end - pos_init) + 1; + if (size <= 2) { + size = 4; + } + + buffer = calloc(1, size); + + if (!buffer) { + return NULL; + } + + bytes = pos_end - pos_init; + memcpy(buffer, string + pos_init, bytes); + buffer[bytes] = '\0'; + + return (char *) buffer; +} + +/* + * quoted_string_len returns the length of a quoted string, not including the quotes. + */ +static int quoted_string_len(const char *str) +{ + int len = 0; + char quote = *str++; /* Consume the quote character. */ + + while (quote != 0) { + char c = *str++; + switch (c) { + case '\0': + /* Error: string ends before end-quote was seen. */ + return -1; + case '\\': + /* Skip escaped quote or \\. */ + if (*str == quote || *str == '\\') { + str++; + } + break; + case '\'': + case '"': + /* End-quote seen: stop iterating. */ + if (c == quote) { + quote = 0; + } + break; + default: + break; + } + len++; + } + + /* Go back one character to ignore end-quote */ + len--; + + return len; +} + +/* + * next_token returns the next token in the string 'str' delimited by 'separator'. + * 'out' is set to the beginning of the token. + * 'out_len' is set to the length of the token. + * 'parse_quotes' is set to CFL_TRUE when quotes shall be considered when tokenizing the 'str'. + * The function returns offset to next token in the string. + */ +static int next_token(const char *str, int separator, char **out, int *out_len, int parse_quotes) { + const char *token_in = str; + char *token_out; + int next_separator = 0; + int quote = 0; /* Parser state: 0 not inside quoted string, or '"' or '\'' when inside quoted string. */ + int len = 0; + int i; + + /* Skip leading separators. */ + while (*token_in == separator) { + token_in++; + } + + /* Should quotes be parsed? Or is token quoted? If not, copy until separator or the end of string. */ + if (parse_quotes == CFL_FALSE || (*token_in != '"' && *token_in != '\'')) { + len = (int)strlen(token_in); + next_separator = cfl_string_char_search(token_in, separator, len); + if (next_separator > 0) { + len = next_separator; + } + *out_len = len; + *out = cfl_string_copy_substr(token_in, 0, len); + if (*out == NULL) { + return -1; + } + + return (int)(token_in - str) + len; + } + + /* Token is quoted. */ + + len = quoted_string_len(token_in); + if (len < 0) { + return -1; + } + + /* Consume the quote character. */ + quote = *token_in++; + + token_out = calloc(1, len + 1); + if (!token_out) { + return -1; + } + + /* Copy the token */ + for (i = 0; i < len; i++) { + /* Handle escapes when inside quoted token: + * \" -> " + * \' -> ' + * \\ -> \ + */ + if (*token_in == '\\' && (token_in[1] == quote || token_in[1] == '\\')) { + token_in++; + } + token_out[i] = *token_in++; + } + token_out[i] = '\0'; + + *out = token_out; + *out_len = len; + + return (int)(token_in - str); +} + + +static struct cfl_list *split(const char *line, int separator, int max_split, int quoted) +{ + int i = 0; + int count = 0; + int val_len; + int len; + int end; + char *val; + struct cfl_list *list; + struct cfl_split_entry *new; + + if (!line) { + return NULL; + } + + list = calloc(1, sizeof(struct cfl_list)); + if (!list) { + cfl_errno(); + return NULL; + } + cfl_list_init(list); + + len = strlen(line); + while (i < len) { + end = next_token(line + i, separator, &val, &val_len, quoted); + if (end == -1) { + cfl_report_runtime_error(); + cfl_utils_split_free(list); + return NULL; + } + + /* Update last position */ + i += end; + + /* Create new entry */ + new = calloc(1, sizeof(struct cfl_split_entry)); + if (!new) { + cfl_errno(); + free(val); + cfl_utils_split_free(list); + return NULL; + } + new->value = val; + new->len = val_len; + new->last_pos = i; + cfl_list_add(&new->_head, list); + count++; + + /* Update index for next loop */ + i++; + + /* + * If the counter exceeded the maximum specified and there + * are still remaining bytes, append those bytes in a new + * and last entry. + */ + if (count >= max_split && max_split > 0 && i < len) { + new = calloc(1, sizeof(struct cfl_split_entry)); + if (!new) { + cfl_errno(); + cfl_utils_split_free(list); + return NULL; + } + new->value = cfl_string_copy_substr(line, i, len); + new->len = len - i; + cfl_list_add(&new->_head, list); + break; + } + } + + return list; +} + +struct cfl_list *cfl_utils_split_quoted(const char *line, int separator, int max_split) +{ + return split(line, separator, max_split, CFL_TRUE); +} + +struct cfl_list *cfl_utils_split(const char *line, int separator, int max_split) +{ + return split(line, separator, max_split, CFL_FALSE); +} + + +void cfl_utils_split_free_entry(struct cfl_split_entry *entry) +{ + cfl_list_del(&entry->_head); + free(entry->value); + free(entry); +} + +void cfl_utils_split_free(struct cfl_list *list) +{ + struct cfl_list *tmp; + struct cfl_list *head; + struct cfl_split_entry *entry; + + cfl_list_foreach_safe(head, tmp, list) { + entry = cfl_list_entry(head, struct cfl_split_entry, _head); + cfl_utils_split_free_entry(entry); + } + + free(list); +} diff --git a/lib/cfl/tests/CMakeLists.txt b/lib/cfl/tests/CMakeLists.txt index 13d113c5ba3..4dba27058fb 100644 --- a/lib/cfl/tests/CMakeLists.txt +++ b/lib/cfl/tests/CMakeLists.txt @@ -9,6 +9,8 @@ set(UNIT_TESTS_FILES list.c variant.c object.c + version.c + utils.c ) configure_file( diff --git a/lib/cfl/tests/array.c b/lib/cfl/tests/array.c index 2ec72e1d459..90332bbfa22 100644 --- a/lib/cfl/tests/array.c +++ b/lib/cfl/tests/array.c @@ -18,7 +18,6 @@ */ #include - #include #include diff --git a/lib/cfl/tests/list.c b/lib/cfl/tests/list.c index 0c12f888fd7..9717be41678 100644 --- a/lib/cfl/tests/list.c +++ b/lib/cfl/tests/list.c @@ -2,7 +2,7 @@ /* CFL * === - * Copyright (C) 2022 The CFL Authors + * Copyright (C) 2022-2024 The CFL Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ */ #include - #include "cfl_tests_internal.h" struct test { @@ -27,24 +26,74 @@ struct test { static void checks() { - struct test *t; - struct cfl_list list; + struct test *t; + struct cfl_list list; + + cfl_list_init(&list); + TEST_CHECK(cfl_list_is_empty(&list)); + + t = malloc(sizeof(struct test)); + cfl_list_add(&t->_head, &list); + TEST_CHECK(!cfl_list_is_empty(&list)); + + cfl_list_del(&t->_head); + TEST_CHECK(cfl_list_is_empty(&list)); + + free(t); +} + +static void add() +{ + int i; + int count = 0; + struct cfl_list list; + struct cfl_list *head; + struct cfl_list *tmp; + + struct node { + int value; + struct cfl_list _head; + }; + + struct node **nodes; + struct node *node; + + nodes = malloc(sizeof(struct node *) * 3); + for (i = 0; i < 3; i++) { + nodes[i] = malloc(sizeof(struct node)); + nodes[i]->value = i; + } + + cfl_list_init(&list); + cfl_list_add(&nodes[0]->_head, &list); + cfl_list_add(&nodes[2]->_head, &list); + - cfl_list_init(&list); - TEST_CHECK(cfl_list_is_empty(&list)); + node = nodes[2]; + cfl_list_add_before(&nodes[1]->_head, &node->_head, &list); - t = malloc(sizeof(struct test)); - cfl_list_add(&t->_head, &list); - TEST_CHECK(!cfl_list_is_empty(&list)); + /* print all nodes */ + printf("\n"); + cfl_list_foreach(head, &list) { + node = cfl_list_entry(head, struct node, _head); + printf("node value: %d\n", node->value); + count++; + } + TEST_CHECK(count == 3); - cfl_list_del(&t->_head); - TEST_CHECK(cfl_list_is_empty(&list)); + cfl_list_foreach_safe(head, tmp, &list) { + node = cfl_list_entry(head, struct node, _head); + cfl_list_del(&node->_head); + free(node); + count++; + } - free(t); + free(nodes); } TEST_LIST = { {"checks", checks}, + {"add", add}, { 0 } }; diff --git a/lib/cfl/tests/utils.c b/lib/cfl/tests/utils.c new file mode 100644 index 00000000000..a24e0df4b7a --- /dev/null +++ b/lib/cfl/tests/utils.c @@ -0,0 +1,162 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* CFL + * === + * Copyright (C) 2022-2024 The CFL Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include +#include + +#include "cfl_tests_internal.h" + +static int compare_split_entry(const char* input, int separator, int max_split, int quoted, ...) +{ + va_list ap; + int count = 1; + char *expect; + struct cfl_list *split = NULL; + struct cfl_list *tmp_list = NULL; + struct cfl_list *head = NULL; + struct cfl_split_entry *entry = NULL; + + if (quoted) { + split = cfl_utils_split_quoted(input, separator, max_split); + } + else { + split = cfl_utils_split(input, separator, max_split); + } + + if (!TEST_CHECK(split != NULL)) { + TEST_MSG("flb_utils_split failed. input=%s", input); + return -1; + } + if (!TEST_CHECK(cfl_list_is_empty(split) != 1)) { + TEST_MSG("list is empty. input=%s", input); + return -1; + } + + va_start(ap, quoted); + cfl_list_foreach_safe(head, tmp_list, split) { + if (max_split > 0 && !TEST_CHECK(count <= max_split) ) { + TEST_MSG("count error. got=%d expect=%d input=%s", count, max_split, input); + } + + expect = va_arg(ap, char*); + entry = cfl_list_entry(head, struct cfl_split_entry, _head); + if (!TEST_CHECK(entry != NULL)) { + TEST_MSG("entry is NULL. input=%s", input); + goto comp_end; + } + /* + printf("%d:%s\n", count, entry->value); + */ + if (!TEST_CHECK(strcmp(expect, entry->value) == 0)) { + TEST_MSG("mismatch. got=%s expect=%s. input=%s", entry->value, expect, input); + goto comp_end; + } + count++; + } + comp_end: + if (split != NULL) { + cfl_utils_split_free(split); + } + va_end(ap); + return 0; +} + +void test_cfl_utils_split() +{ + compare_split_entry("aa,bb", ',', 2, CFL_FALSE, "aa","bb" ); + compare_split_entry("localhost:12345", ':', 2, CFL_FALSE, "localhost","12345" ); + compare_split_entry("https://fluentbit.io/announcements/", '/', -1, CFL_FALSE, "https:", "fluentbit.io","announcements" ); + + /* /proc/net/dev example */ + compare_split_entry("enp0s3: 1955136 1768 0 0 0 0 0 0 89362 931 0 0 0 0 0 0", + ' ', 256, CFL_FALSE, + "enp0s3:", "1955136", "1768", "0", "0", "0", "0", "0", "0", "89362", "931", "0", "0", "0", "0", "0", "0", "0"); + + /* filter_grep configuration */ + compare_split_entry("Regex test *a*", ' ', 3, CFL_FALSE, "Regex", "test", "*a*"); + + /* filter_modify configuration */ + compare_split_entry("Condition Key_Value_Does_Not_Equal cpustats KNOWN", ' ', 4, + CFL_FALSE, "Condition", "Key_Value_Does_Not_Equal", "cpustats", "KNOWN"); + + /* nginx_exporter_metrics example */ + compare_split_entry("Active connections: 1\nserver accepts handled requests\n 10 10 10\nReading: 0 Writing: 1 Waiting: 0", '\n', 4, + CFL_FALSE, "Active connections: 1", "server accepts handled requests", " 10 10 10","Reading: 0 Writing: 1 Waiting: 0"); + + /* out_cloudwatch_logs example */ + compare_split_entry("dimension_1,dimension_2;dimension_3", ';', 256, + CFL_FALSE, "dimension_1,dimension_2", "dimension_3"); + /* separator is not contained */ + compare_split_entry("aa,bb", '/', 2, CFL_FALSE, "aa,bb"); + + /* do not parse quotes when tokenizing */ + compare_split_entry("aa \"bb cc\" dd", ' ', 256, CFL_FALSE, "aa", "\"bb", "cc\"", "dd"); +} + +void test_cfl_utils_split_quoted() +{ + /* Tokens quoted with "..." */ + compare_split_entry("aa \"double quote\" bb", ' ', 256, CFL_TRUE, "aa", "double quote", "bb"); + compare_split_entry("\"begin with double quote\" aa", ' ', 256, CFL_TRUE, "begin with double quote", "aa"); + compare_split_entry("aa \"end with double quote\"", ' ', 256, CFL_TRUE, "aa", "end with double quote"); + + /* Tokens quoted with '...' */ + compare_split_entry("aa bb 'single quote' cc", ' ', 256, CFL_TRUE, "aa", "bb", "single quote", "cc"); + compare_split_entry("'begin with single quote' aa", ' ', 256, CFL_TRUE, "begin with single quote", "aa"); + compare_split_entry("aa 'end with single quote'", ' ', 256, CFL_TRUE, "aa", "end with single quote"); + + /* Tokens surrounded by more than one separator character */ + compare_split_entry(" aa \" spaces bb \" cc ' spaces dd ' ff", ' ', 256, CFL_TRUE, + "aa", " spaces bb ", "cc", " spaces dd ", "ff"); + + /* Escapes within quoted token */ + compare_split_entry("aa \"escaped \\\" quote\" bb", ' ', 256, CFL_TRUE, "aa", "escaped \" quote", "bb"); + compare_split_entry("aa 'escaped \\' quote\' bb", ' ', 256, CFL_TRUE, "aa", "escaped \' quote", "bb"); + compare_split_entry("aa \"\\\"escaped balanced quotes\\\"\" bb", ' ', 256, CFL_TRUE, + "aa", "\"escaped balanced quotes\"", "bb"); + compare_split_entry("aa '\\'escaped balanced quotes\\'\' bb", ' ', 256, CFL_TRUE, + "aa", "'escaped balanced quotes'", "bb"); + compare_split_entry("aa 'escaped \\\\ escape\' bb", ' ', 256, CFL_TRUE, "aa", "escaped \\ escape", "bb"); + + /* Escapes that are not processed */ + compare_split_entry("\\\"aa bb", ' ', 256, CFL_TRUE, "\\\"aa", "bb"); + compare_split_entry("\\'aa bb", ' ', 256, CFL_TRUE, "\\'aa", "bb"); + compare_split_entry("\\\\aa bb", ' ', 256, CFL_TRUE, "\\\\aa", "bb"); + compare_split_entry("aa\\ bb", ' ', 256, CFL_TRUE, "aa\\", "bb"); +} + +void test_cfl_utils_split_quoted_errors() +{ + struct cfl_list *split = NULL; + + split = cfl_utils_split_quoted("aa \"unbalanced quotes should fail", ' ', 256); + TEST_CHECK(split == NULL); + split = cfl_utils_split_quoted("aa 'unbalanced quotes should fail", ' ', 256); + TEST_CHECK(split == NULL); +} + + +TEST_LIST = { + { "test_flb_utils_split", test_cfl_utils_split }, + { "test_flb_utils_split_quoted", test_cfl_utils_split_quoted}, + { "test_flb_utils_split_quoted_errors", test_cfl_utils_split_quoted_errors}, + { 0 } +}; diff --git a/lib/cfl/tests/version.c b/lib/cfl/tests/version.c new file mode 100644 index 00000000000..4d1510b82ad --- /dev/null +++ b/lib/cfl/tests/version.c @@ -0,0 +1,37 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* CFL + * === + * Copyright (C) 2022 The CFL Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "cfl_tests_internal.h" + +static void test_version() +{ + char *v; + + v = cfl_version(); + TEST_CHECK(v != NULL); + TEST_CHECK(strlen(v) >= 5); + + printf("CFL VERSION => '%s'\n", v); +} + +TEST_LIST = { + { "version" , test_version }, + { 0 } +}; From 56ff251d34ccbd45d008aa4b047cc69c35300206 Mon Sep 17 00:00:00 2001 From: leonardo-albertovich Date: Tue, 6 Aug 2024 23:36:32 +0200 Subject: [PATCH 013/295] in_mqtt: added buffer size setting and fixed a leak (#9163) --------- Signed-off-by: Leonardo Alminana --- plugins/in_mqtt/mqtt.c | 5 +++++ plugins/in_mqtt/mqtt.h | 3 ++- plugins/in_mqtt/mqtt_conn.c | 16 +++++++++++++++- plugins/in_mqtt/mqtt_conn.h | 5 ++++- plugins/in_mqtt/mqtt_prot.c | 2 ++ 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/plugins/in_mqtt/mqtt.c b/plugins/in_mqtt/mqtt.c index e712c1c8772..79be08d22a3 100644 --- a/plugins/in_mqtt/mqtt.c +++ b/plugins/in_mqtt/mqtt.c @@ -144,6 +144,11 @@ static struct flb_config_map config_map[] = { 0, FLB_TRUE, offsetof(struct flb_in_mqtt_config, payload_key), "Key where the payload will be preserved" }, + { + FLB_CONFIG_MAP_SIZE, "buffer_size", MQTT_CONNECTION_DEFAULT_BUFFER_SIZE, + 0, FLB_TRUE, offsetof(struct flb_in_mqtt_config, buffer_size), + "Maximum payload size" + }, /* EOF */ {0} }; diff --git a/plugins/in_mqtt/mqtt.h b/plugins/in_mqtt/mqtt.h index 28e22e071a2..2a4ec69c808 100644 --- a/plugins/in_mqtt/mqtt.h +++ b/plugins/in_mqtt/mqtt.h @@ -30,7 +30,8 @@ struct flb_in_mqtt_config { char *tcp_port; /* TCP Port */ flb_sds_t payload_key; /* payload key */ - + size_t buffer_size; /* connection buffer size */ + int msgp_len; /* msgpack data length */ char msgp[MQTT_MSGP_BUF_SIZE]; /* msgpack static buffer */ struct flb_input_instance *ins; /* plugin input instance */ diff --git a/plugins/in_mqtt/mqtt_conn.c b/plugins/in_mqtt/mqtt_conn.c index 2d472f92ff3..26b8f071c47 100644 --- a/plugins/in_mqtt/mqtt_conn.c +++ b/plugins/in_mqtt/mqtt_conn.c @@ -48,7 +48,7 @@ int mqtt_conn_event(void *data) event = &connection->event; if (event->mask & MK_EVENT_READ) { - available = sizeof(conn->buf) - conn->buf_len; + available = conn->buf_size - conn->buf_len; bytes = flb_io_net_read(connection, (void *) &conn->buf[conn->buf_len], @@ -93,6 +93,16 @@ struct mqtt_conn *mqtt_conn_add(struct flb_connection *connection, return NULL; } + conn->buf = flb_calloc(ctx->buffer_size, 1); + + if (conn->buf == NULL) { + flb_errno(); + flb_free(conn); + return NULL; + } + + conn->buf_size = ctx->buffer_size; + conn->connection = connection; /* Set data for the event-loop */ @@ -137,6 +147,10 @@ int mqtt_conn_del(struct mqtt_conn *conn) /* Release resources */ mk_list_del(&conn->_head); + if (conn->buf != NULL) { + flb_free(conn->buf); + } + flb_free(conn); return 0; diff --git a/plugins/in_mqtt/mqtt_conn.h b/plugins/in_mqtt/mqtt_conn.h index 001d4e0ce4c..acf6acd3200 100644 --- a/plugins/in_mqtt/mqtt_conn.h +++ b/plugins/in_mqtt/mqtt_conn.h @@ -22,6 +22,8 @@ #include +#define MQTT_CONNECTION_DEFAULT_BUFFER_SIZE "2048" + enum { MQTT_NEW = 1, /* it's a new connection */ MQTT_CONNECTED = 2, /* MQTT connection per protocol spec OK */ @@ -36,7 +38,8 @@ struct mqtt_conn { int buf_frame_end; /* Frame end position */ int buf_pos; /* Index position */ int buf_len; /* Buffer content length */ - unsigned char buf[1024]; /* Buffer data */ + size_t buf_size; /* Buffer size */ + unsigned char *buf; /* Buffer data */ struct flb_in_mqtt_config *ctx; /* Plugin configuration context */ struct flb_connection *connection; struct mk_list _head; /* Link to flb_in_mqtt_config->conns */ diff --git a/plugins/in_mqtt/mqtt_prot.c b/plugins/in_mqtt/mqtt_prot.c index ebfbb425eb0..9abb10574ab 100644 --- a/plugins/in_mqtt/mqtt_prot.c +++ b/plugins/in_mqtt/mqtt_prot.c @@ -148,11 +148,13 @@ static int mqtt_data_append(char *topic, size_t topic_len, msgpack_unpacked_init(&result); if (msgpack_unpack_next(&result, pack, out, &off) != MSGPACK_UNPACK_SUCCESS) { msgpack_unpacked_destroy(&result); + flb_free(pack); return -1; } if (result.data.type != MSGPACK_OBJECT_MAP){ msgpack_unpacked_destroy(&result); + flb_free(pack); return -1; } root = result.data; From c147d452bb96b9e7647932e0ef5ecf0fed32605c Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Tue, 6 Aug 2024 10:15:33 -0600 Subject: [PATCH 014/295] lib: cmetrics: upgrade to v0.9.3 Signed-off-by: Eduardo Silva --- lib/cmetrics/.github/workflows/build.yaml | 10 ++++++++-- lib/cmetrics/CMakeLists.txt | 8 +++++++- lib/cmetrics/scripts/win_build.bat | 2 -- lib/cmetrics/src/cmt_decode_prometheus.c | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/cmetrics/.github/workflows/build.yaml b/lib/cmetrics/.github/workflows/build.yaml index b975bf7be1d..42015b80d59 100644 --- a/lib/cmetrics/.github/workflows/build.yaml +++ b/lib/cmetrics/.github/workflows/build.yaml @@ -23,6 +23,11 @@ jobs: with: submodules: true + - name: Set up with Developer Command Prompt for Microsoft Visual C++ + uses: ilammy/msvc-dev-cmd@v1 + with: + toolset: 14.29 # For using VS2019 C++ + - name: Build on ${{ matrix.os }} with vs-2019 run: | .\scripts\win_build.bat @@ -39,10 +44,11 @@ jobs: steps: - name: Set up base image dependencies run: | + sed -i -e "s/^mirrorlist=http:\/\/mirrorlist.centos.org/#mirrorlist=http:\/\/mirrorlist.centos.org/g" /etc/yum.repos.d/CentOS-Base.repo + sed -i -e "s/^#baseurl=http:\/\/mirror.centos.org/baseurl=http:\/\/vault.centos.org/g" /etc/yum.repos.d/CentOS-Base.repo yum -y update && \ yum install -y ca-certificates cmake gcc gcc-c++ git make wget && \ - wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && \ - rpm -ivh epel-release-latest-7.noarch.rpm && \ + yum install -y epel-release yum install -y cmake3 shell: bash diff --git a/lib/cmetrics/CMakeLists.txt b/lib/cmetrics/CMakeLists.txt index 68dd66e507c..6509d7a35f4 100644 --- a/lib/cmetrics/CMakeLists.txt +++ b/lib/cmetrics/CMakeLists.txt @@ -6,7 +6,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # CMetrics Version set(CMT_VERSION_MAJOR 0) set(CMT_VERSION_MINOR 9) -set(CMT_VERSION_PATCH 1) +set(CMT_VERSION_PATCH 3) set(CMT_VERSION_STR "${CMT_VERSION_MAJOR}.${CMT_VERSION_MINOR}.${CMT_VERSION_PATCH}") # Include helpers @@ -241,6 +241,12 @@ if (NOT CMT_HAVE_CFL) COMPONENT headers PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) + install(TARGETS cfl-static + RUNTIME DESTINATION ${CMT_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMT_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMT_INSTALL_LIBDIR} + COMPONENT library) + # xxHash install(FILES lib/cfl/lib/xxhash/xxh3.h DESTINATION ${CMT_INSTALL_INCLUDEDIR} diff --git a/lib/cmetrics/scripts/win_build.bat b/lib/cmetrics/scripts/win_build.bat index f1fb6d87b16..907baf75176 100755 --- a/lib/cmetrics/scripts/win_build.bat +++ b/lib/cmetrics/scripts/win_build.bat @@ -1,6 +1,4 @@ setlocal -call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat" -path "C:\Program Files (x86)\MSBuild\16.0\Bin;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin";%path% git submodule update --init --recursive cd build cmake -G "NMake Makefiles" -DCMT_TESTS=On ..\ diff --git a/lib/cmetrics/src/cmt_decode_prometheus.c b/lib/cmetrics/src/cmt_decode_prometheus.c index e33a9ef1670..3a87c34ee74 100644 --- a/lib/cmetrics/src/cmt_decode_prometheus.c +++ b/lib/cmetrics/src/cmt_decode_prometheus.c @@ -200,7 +200,7 @@ static int parse_uint64(const char *in, uint64_t *out) int64_t val; errno = 0; - val = strtol(in, &end, 10); + val = strtoll(in, &end, 10); if (end == in || *end != 0 || errno) { return -1; } From 9392bc1127d03a2aef2832d0a985cff12e9672ee Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Tue, 6 Aug 2024 10:16:20 -0600 Subject: [PATCH 015/295] lib: ctraces: upgrade to v0.5.4 Signed-off-by: Eduardo Silva --- lib/ctraces/.github/workflows/build.yaml | 5 +++-- lib/ctraces/.github/workflows/lint.yaml | 2 +- lib/ctraces/CMakeLists.txt | 2 +- lib/ctraces/examples/otlp-encoder/README.md | 1 - lib/ctraces/src/ctr_encode_msgpack.c | 7 ++++++- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/ctraces/.github/workflows/build.yaml b/lib/ctraces/.github/workflows/build.yaml index 45710f6c4f2..97b7639e7d1 100644 --- a/lib/ctraces/.github/workflows/build.yaml +++ b/lib/ctraces/.github/workflows/build.yaml @@ -39,10 +39,11 @@ jobs: steps: - name: Set up base image dependencies run: | + sed -i -e "s/^mirrorlist=http:\/\/mirrorlist.centos.org/#mirrorlist=http:\/\/mirrorlist.centos.org/g" /etc/yum.repos.d/CentOS-Base.repo + sed -i -e "s/^#baseurl=http:\/\/mirror.centos.org/baseurl=http:\/\/vault.centos.org/g" /etc/yum.repos.d/CentOS-Base.repo yum -y update && \ yum install -y ca-certificates cmake curl-devel gcc gcc-c++ git make wget && \ - wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && \ - rpm -ivh epel-release-latest-7.noarch.rpm && \ + yum install -y epel-release yum install -y cmake3 shell: bash diff --git a/lib/ctraces/.github/workflows/lint.yaml b/lib/ctraces/.github/workflows/lint.yaml index 46471fa5b19..2be0e40c674 100644 --- a/lib/ctraces/.github/workflows/lint.yaml +++ b/lib/ctraces/.github/workflows/lint.yaml @@ -29,4 +29,4 @@ jobs: steps: - uses: actions/checkout@v3 - name: Run markdownlint - uses: actionshub/markdownlint@2.0.2 + uses: actionshub/markdownlint@v3.1.4 diff --git a/lib/ctraces/CMakeLists.txt b/lib/ctraces/CMakeLists.txt index 5f6a96b0f68..425384fcce9 100644 --- a/lib/ctraces/CMakeLists.txt +++ b/lib/ctraces/CMakeLists.txt @@ -27,7 +27,7 @@ endif() # CTraces Version set(CTR_VERSION_MAJOR 0) set(CTR_VERSION_MINOR 5) -set(CTR_VERSION_PATCH 2) +set(CTR_VERSION_PATCH 3) set(CTR_VERSION_STR "${CTR_VERSION_MAJOR}.${CTR_VERSION_MINOR}.${CTR_VERSION_PATCH}") # Define __FILENAME__ consistently across Operating Systems diff --git a/lib/ctraces/examples/otlp-encoder/README.md b/lib/ctraces/examples/otlp-encoder/README.md index 78e65aca35d..ab2bfa0bd01 100644 --- a/lib/ctraces/examples/otlp-encoder/README.md +++ b/lib/ctraces/examples/otlp-encoder/README.md @@ -23,4 +23,3 @@ service: ``` Now you can run the example and see the trace data logged by the collector instance. - diff --git a/lib/ctraces/src/ctr_encode_msgpack.c b/lib/ctraces/src/ctr_encode_msgpack.c index 4c863608830..63714b0af44 100644 --- a/lib/ctraces/src/ctr_encode_msgpack.c +++ b/lib/ctraces/src/ctr_encode_msgpack.c @@ -424,7 +424,12 @@ static void pack_scope_spans(mpack_writer_t *writer, struct cfl_list *scope_span /* scope */ mpack_write_cstr(writer, "scope"); - pack_instrumentation_scope(writer, scope_span->instrumentation_scope); + if (scope_span->instrumentation_scope != NULL) { + pack_instrumentation_scope(writer, scope_span->instrumentation_scope); + } + else { + mpack_write_nil(writer); + } /* spans */ mpack_write_cstr(writer, "spans"); From 30b6522b152d28177cb9f73c496d9bb2514a3cf4 Mon Sep 17 00:00:00 2001 From: kangaechu Date: Thu, 25 Jul 2024 12:16:19 +0900 Subject: [PATCH 016/295] restore --staged tests/internal/aws_util.c Signed-off-by: kangaechu --- src/aws/flb_aws_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/aws/flb_aws_util.c b/src/aws/flb_aws_util.c index 48cf8b3d89e..6ddd75b82d9 100644 --- a/src/aws/flb_aws_util.c +++ b/src/aws/flb_aws_util.c @@ -1003,9 +1003,9 @@ size_t flb_aws_strftime_precision(char **out_buf, const char *time_format, /* Replace %3N to millisecond, %9N and %L to nanosecond in time_format. */ snprintf(millisecond_str, FLB_AWS_MILLISECOND_FORMATTER_LENGTH+1, - "%" PRIu64, (uint64_t) tms->tm.tv_nsec / 1000000); + "%03" PRIu64, (uint64_t) tms->tm.tv_nsec / 1000000); snprintf(nanosecond_str, FLB_AWS_NANOSECOND_FORMATTER_LENGTH+1, - "%" PRIu64, (uint64_t) tms->tm.tv_nsec); + "%09" PRIu64, (uint64_t) tms->tm.tv_nsec); for (i = 0; i < time_format_len; i++) { if (strncmp(time_format+i, FLB_AWS_MILLISECOND_FORMATTER, 3) == 0) { strncat(tmp_parsed_time_str, millisecond_str, From c683d8e3c43f2bf24b044ef7871156191518c9ca Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Fri, 2 Aug 2024 15:12:04 +0200 Subject: [PATCH 017/295] out_opensearch: fixed wrong payload buffer usage for traces Signed-off-by: Leonardo Alminana --- plugins/out_opensearch/opensearch.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/out_opensearch/opensearch.c b/plugins/out_opensearch/opensearch.c index d7eaed53c31..23dfdaabc6a 100644 --- a/plugins/out_opensearch/opensearch.c +++ b/plugins/out_opensearch/opensearch.c @@ -884,6 +884,9 @@ static void cb_opensearch_flush(struct flb_event_chunk *event_chunk, pack = flb_msgpack_raw_to_json_sds(event_chunk->data, event_chunk->size); if (pack) { ret = 0; + + out_buf = (void *) pack; + out_size = cfl_sds_len(pack); } else { ret = -1; From 999e9b83766bfbfeb3b3575b3ef6141455a98095 Mon Sep 17 00:00:00 2001 From: Thomas Devoogdt Date: Fri, 28 Apr 2023 10:25:16 +0200 Subject: [PATCH 018/295] build: use the system provided LuaJIT if found e.g. buildroot has logic to build luajit, so if pkg_check_modules can find a suitable version, then use that one if -DFLB_PREFER_SYSTEM_LIB_LUAJIT=Yes. Signed-off-by: Thomas Devoogdt --- CMakeLists.txt | 15 ++++++++++++++- cmake/headers.cmake | 4 ---- cmake/luajit.cmake | 5 +++++ src/CMakeLists.txt | 2 +- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e3f3a092622..cf8105b82db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -178,6 +178,10 @@ option(FLB_HTTP_CLIENT_DEBUG "Enable HTTP Client debug callbacks" No) # Run ldconfig on package post-install option(FLB_RUN_LDCONFIG "Enable execution of ldconfig after installation" No) +# Prefer system libraries if available +option(FLB_PREFER_SYSTEM_LIBS "Prefer system libraries" No) +option(FLB_PREFER_SYSTEM_LIB_LUAJIT "Prefer the libluajit system library" ${FLB_PREFER_SYSTEM_LIBS}) + # Enable all features if(FLB_ALL) # Global @@ -940,7 +944,16 @@ endif() # LuaJIT (Scripting Support) # ========================== if(FLB_LUAJIT) - include(cmake/luajit.cmake) + if(FLB_PREFER_SYSTEM_LIB_LUAJIT) + find_package(PkgConfig) + pkg_check_modules(LUAJIT luajit>=2.1.0) + endif() + if(LUAJIT_FOUND) + include_directories(${LUAJIT_INCLUDE_DIRS}) + link_directories(${LUAJIT_LIBRARY_DIRS}) + else() + include(cmake/luajit.cmake) + endif() FLB_DEFINITION(FLB_HAVE_LUAJIT) endif() diff --git a/cmake/headers.cmake b/cmake/headers.cmake index 45a1394ca7f..500c4c3b947 100755 --- a/cmake/headers.cmake +++ b/cmake/headers.cmake @@ -22,10 +22,6 @@ include_directories( ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_CHUNKIO}/include ${CMAKE_CURRENT_BINARY_DIR}/lib/chunkio/include - # LuaJIT - ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_LUAJIT}/src - ${CMAKE_CURRENT_BINARY_DIR}/lib/luajit-cmake - ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_MONKEY}/include ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_MONKEY}/include/monkey ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_MBEDTLS}/include diff --git a/cmake/luajit.cmake b/cmake/luajit.cmake index 63a2d8492ab..b4dfca2b296 100644 --- a/cmake/luajit.cmake +++ b/cmake/luajit.cmake @@ -2,4 +2,9 @@ option(LUAJIT_DIR "Path of LuaJIT 2.1 source dir" ON) option(LUAJIT_SETUP_INCLUDE_DIR "Setup include dir if parent is present" OFF) set(LUAJIT_DIR ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_LUAJIT}) +include_directories( + ${LUAJIT_DIR}/src + ${CMAKE_CURRENT_BINARY_DIR}/lib/luajit-cmake +) add_subdirectory("lib/luajit-cmake") +set(LUAJIT_LIBRARIES "libluajit") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 593e9865bc4..084f2c57d52 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -223,7 +223,7 @@ endif() if(FLB_LUAJIT) set(extra_libs ${extra_libs} - "libluajit") + ${LUAJIT_LIBRARIES}) endif() if(FLB_SQLDB) From 725640616fa9127f1ea5922c4c3076806830c70a Mon Sep 17 00:00:00 2001 From: Thomas Devoogdt Date: Thu, 4 Jul 2024 13:57:18 +0000 Subject: [PATCH 019/295] workflows: add sanity check for compilation using system libraries to pr-compile-check.yaml Based on https://github.com/fluent/fluent-bit/pull/7286#issuecomment-2208066494 (@cosmo0920). Signed-off-by: Thomas Devoogdt --- .github/workflows/pr-compile-check.yaml | 43 +++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/.github/workflows/pr-compile-check.yaml b/.github/workflows/pr-compile-check.yaml index 329c57071b9..dd982fab26e 100644 --- a/.github/workflows/pr-compile-check.yaml +++ b/.github/workflows/pr-compile-check.yaml @@ -30,3 +30,46 @@ jobs: push: false load: false provenance: false + + # Sanity check for compilation using system libraries + pr-compile-system-libs: + runs-on: ubuntu-20.04 + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + flb_option: + - "-DFLB_PREFER_SYSTEM_LIBS=On" + compiler: + - gcc + - clang + steps: + - name: Setup environment + run: | + sudo apt-get update + sudo apt-get install -y gcc-7 g++-7 clang-6.0 libsystemd-dev gcovr libyaml-dev libluajit-5.1-dev + sudo ln -s /usr/bin/llvm-symbolizer-6.0 /usr/bin/llvm-symbolizer || true + + - name: Checkout Fluent Bit code + uses: actions/checkout@v4 + + - name: ${{ matrix.compiler }} - ${{ matrix.flb_option }} + run: | + export nparallel=$(( $(getconf _NPROCESSORS_ONLN) > 8 ? 8 : $(getconf _NPROCESSORS_ONLN) )) + echo "CC = $CC, CXX = $CXX, FLB_OPT = $FLB_OPT" + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 90 + sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 90 + sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-6.0 90 + cmake $GLOBAL_OPTS $FLB_OPT ../ + make -j $nparallel + working-directory: build + env: + CC: ${{ matrix.compiler }} + CXX: ${{ matrix.compiler }} + FLB_OPT: ${{ matrix.flb_option }} + GLOBAL_OPTS: "-DFLB_BACKTRACE=Off -DFLB_SHARED_LIB=Off -DFLB_DEBUG=On -DFLB_ALL=On -DFLB_EXAMPLES=Off" + + - name: Display dependencies w/ ldd + run: | + ldd ./bin/fluent-bit + working-directory: build From a6980efcf4b704221adeda6aa436ca7c5ded6ba7 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Wed, 7 Aug 2024 12:19:26 +0900 Subject: [PATCH 020/295] appveyor: Use vcpkg to install the latest OpenSSL Signed-off-by: Hiroshi Hatake --- appveyor.yml | 47 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index bdf29ece94a..6c8b97821c5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -37,16 +37,55 @@ install: - ps: Expand-Archive winflexbison.zip -Destination /WinFlexBison - ps: Copy-Item -Path /WinFlexBison/win_bison.exe /WinFlexBison/bison.exe - ps: Copy-Item -Path /WinFlexBison/win_flex.exe /WinFlexBison/flex.exe + - cd C:\Tools\vcpkg + - git pull + - .\bootstrap-vcpkg.bat + - cd %APPVEYOR_BUILD_FOLDER% before_build: - - git clone --depth=1 https://github.com/calyptia/fluent-bit-ci.git ci - - ps: Copy-Item -Path .\ci\scripts\run-unit-tests.ps1 .\ci\do-ut.ps1 + - if %PLATFORM%==Win32 call C:\tools\vcpkg\vcpkg install --recurse openssl --triplet x86-windows-static + - if %PLATFORM%==x64 call C:\tools\vcpkg\vcpkg install --recurse openssl --triplet x64-windows-static - if %PLATFORM%==Win32 call "%vspath%\VC\Auxiliary\Build\vcvars32.bat" - if %PLATFORM%==x64 call "%vspatH%\VC\Auxiliary\Build\vcvars64.bat" build_script: - - powershell ".\ci\do-ut.ps1;exit $LASTEXITCODE" - - cd build + - ps: | + cd $ENV:APPVEYOR_BUILD_FOLDER\build + + if ( "x64" -eq $env:PLATFORM ) { + $OPENSSL_DIR = "C:\tools\vcpkg\packages\openssl_x64-windows-static" + } + else { + $OPENSSL_DIR = "C:\tools\vcpkg\packages\openssl_x86-windows-static" + } + # CACHE GENERATION + cmake -G "NMake Makefiles" ` + -D FLB_TESTS_INTERNAL=On ` + -D OPENSSL_ROOT_DIR=$OPENSSL_DIR ` + -D FLB_WITHOUT_flb-rt-out_elasticsearch=On ` + -D FLB_WITHOUT_flb-rt-out_td=On ` + -D FLB_WITHOUT_flb-rt-out_forward=On ` + -D FLB_WITHOUT_flb-rt-in_disk=On ` + -D FLB_WITHOUT_flb-rt-in_proc=On ` + -D FLB_WITHOUT_flb-it-parser=On ` + -D FLB_WITHOUT_flb-it-unit_sizes=On ` + -D FLB_WITHOUT_flb-it-network=On ` + -D FLB_WITHOUT_flb-it-pack=On ` + -D FLB_WITHOUT_flb-it-signv4=On ` + -D FLB_WITHOUT_flb-it-aws_credentials=On ` + -D FLB_WITHOUT_flb-it-aws_credentials_ec2=On ` + -D FLB_WITHOUT_flb-it-aws_credentials_http=On ` + -D FLB_WITHOUT_flb-it-aws_credentials_profile=On ` + -D FLB_WITHOUT_flb-it-aws_credentials_sts=On ` + -D FLB_WITHOUT_flb-it-aws_util=On ` + -D FLB_WITHOUT_flb-it-input_chunk=On ` + ../ + # COMPILE + cmake --build . + + # RUNNING TESTS + ctest --build-run-dir $PWD --output-on-failure + - cpack - cmake -G "NMake Makefiles" ..\ - cmake --build . From 13ea609e5309397d4386d6b09db706522773f137 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Wed, 7 Aug 2024 12:19:50 +0900 Subject: [PATCH 021/295] cmake: windows: Enable Kafka plugins on Windows Signed-off-by: Hiroshi Hatake --- cmake/windows-setup.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/windows-setup.cmake b/cmake/windows-setup.cmake index ba870233e0c..b947d6cbfa0 100644 --- a/cmake/windows-setup.cmake +++ b/cmake/windows-setup.cmake @@ -30,7 +30,7 @@ if(FLB_WINDOWS_DEFAULTS) set(FLB_IN_HEALTH No) set(FLB_IN_HTTP Yes) set(FLB_IN_MEM No) - set(FLB_IN_KAFKA No) + set(FLB_IN_KAFKA Yes) set(FLB_IN_KMSG No) set(FLB_IN_LIB Yes) set(FLB_IN_RANDOM Yes) @@ -83,7 +83,7 @@ if(FLB_WINDOWS_DEFAULTS) set(FLB_OUT_LIB Yes) set(FLB_OUT_NULL Yes) set(FLB_OUT_FLOWCOUNTER Yes) - set(FLB_OUT_KAFKA No) + set(FLB_OUT_KAFKA Yes) set(FLB_OUT_KAFKA_REST No) set(FLB_OUT_CLOUDWATCH_LOGS Yes) set(FLB_OUT_S3 Yes) From f5794a417efe382a8863b48cbab420a3ecbaf3e8 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Fri, 9 Aug 2024 07:19:32 +0900 Subject: [PATCH 022/295] out_prometheus_exporter: Handle multiply concatenated metrics type of events (#9122) * out_prometheus_exporter: Handle multiply concatenated metrics type of events Signed-off-by: Hiroshi Hatake * out_prometheus_exporter: Plug a memory leak Signed-off-by: Hiroshi Hatake * out_prometheus_exporter: Plug a leak on error Signed-off-by: Hiroshi Hatake --------- Signed-off-by: Hiroshi Hatake --- plugins/out_prometheus_exporter/prom.c | 72 +++++++++++++++++--------- 1 file changed, 48 insertions(+), 24 deletions(-) diff --git a/plugins/out_prometheus_exporter/prom.c b/plugins/out_prometheus_exporter/prom.c index e120f6c1761..77f60a026ee 100644 --- a/plugins/out_prometheus_exporter/prom.c +++ b/plugins/out_prometheus_exporter/prom.c @@ -175,44 +175,68 @@ static void cb_prom_flush(struct flb_event_chunk *event_chunk, int add_ts; size_t off = 0; flb_sds_t metrics; - cfl_sds_t text; + cfl_sds_t text = NULL; + cfl_sds_t tmp = NULL; struct cmt *cmt; struct prom_exporter *ctx = out_context; + int ok = CMT_DECODE_MSGPACK_SUCCESS; + + text = flb_sds_create_size(128); + if (text == NULL) { + flb_plg_debug(ctx->ins, "failed to allocate buffer for text representation of metrics"); + FLB_OUTPUT_RETURN(FLB_ERROR); + } /* * A new set of metrics has arrived, perform decoding, apply labels, * convert to Prometheus text format and store the output in the * hash table for metrics. + * Note that metrics might be concatenated. So, we need to consume + * until the end of event_chunk. */ - ret = cmt_decode_msgpack_create(&cmt, - (char *) event_chunk->data, - event_chunk->size, &off); - if (ret != 0) { - FLB_OUTPUT_RETURN(FLB_ERROR); - } + while ((ret = cmt_decode_msgpack_create(&cmt, + (char *) event_chunk->data, + event_chunk->size, &off)) == ok) { - /* append labels set by config */ - append_labels(ctx, cmt); + if (ret != 0) { + flb_sds_destroy(text); + FLB_OUTPUT_RETURN(FLB_ERROR); + } - /* add timestamp in the output format ? */ - if (ctx->add_timestamp) { - add_ts = CMT_TRUE; - } - else { - add_ts = CMT_FALSE; - } + /* append labels set by config */ + append_labels(ctx, cmt); + + /* add timestamp in the output format ? */ + if (ctx->add_timestamp) { + add_ts = CMT_TRUE; + } + else { + add_ts = CMT_FALSE; + } - /* convert to text representation */ - text = cmt_encode_prometheus_create(cmt, add_ts); - if (!text) { + /* convert to text representation */ + tmp = cmt_encode_prometheus_create(cmt, add_ts); + if (!tmp) { + cmt_destroy(cmt); + flb_sds_destroy(text); + FLB_OUTPUT_RETURN(FLB_ERROR); + } + ret = flb_sds_cat_safe(&text, tmp, flb_sds_len(tmp)); + if (ret != 0) { + flb_plg_error(ctx->ins, "could not concatenate text representant coming from: %s", + flb_input_name(ins)); + cmt_encode_prometheus_destroy(tmp); + flb_sds_destroy(text); + cmt_destroy(cmt); + FLB_OUTPUT_RETURN(FLB_ERROR); + } + cmt_encode_prometheus_destroy(tmp); cmt_destroy(cmt); - FLB_OUTPUT_RETURN(FLB_ERROR); } - cmt_destroy(cmt); if (cfl_sds_len(text) == 0) { flb_plg_debug(ctx->ins, "context without metrics (empty)"); - cmt_encode_text_destroy(text); + flb_sds_destroy(text); FLB_OUTPUT_RETURN(FLB_OK); } @@ -221,11 +245,11 @@ static void cb_prom_flush(struct flb_event_chunk *event_chunk, if (ret == -1) { flb_plg_error(ctx->ins, "could not store metrics coming from: %s", flb_input_name(ins)); - cmt_encode_prometheus_destroy(text); + flb_sds_destroy(text); cmt_destroy(cmt); FLB_OUTPUT_RETURN(FLB_ERROR); } - cmt_encode_prometheus_destroy(text); + flb_sds_destroy(text); /* retrieve a full copy of all metrics */ metrics = hash_format_metrics(ctx); From b26d85b1304ceef86abbdaa6debd66b0bfadcf62 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Wed, 7 Aug 2024 14:25:18 -0600 Subject: [PATCH 023/295] in_forward: fix leak on exception (CID 508219) Signed-off-by: Eduardo Silva --- plugins/in_forward/fw_conn.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/in_forward/fw_conn.c b/plugins/in_forward/fw_conn.c index 292538d11b1..f9f79f55abe 100644 --- a/plugins/in_forward/fw_conn.c +++ b/plugins/in_forward/fw_conn.c @@ -147,11 +147,12 @@ struct fw_conn *fw_conn_add(struct flb_connection *connection, struct flb_in_fw_ helo = flb_malloc(sizeof(struct flb_in_fw_helo)); if (!helo) { flb_errno(); - return NULL; } + ret = fw_prot_secure_forward_handshake_start(ctx->ins, connection, helo); if (ret != 0) { + flb_free(helo); return NULL; } From ff651842b4b9c89ce7d3eef938041e03a4175623 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Wed, 7 Aug 2024 14:42:59 -0600 Subject: [PATCH 024/295] in_tail: fix double-free on exception (CID 507963) Signed-off-by: Eduardo Silva --- plugins/in_tail/tail_file.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/in_tail/tail_file.c b/plugins/in_tail/tail_file.c index 2d5e36f834a..c20594c7f1c 100644 --- a/plugins/in_tail/tail_file.c +++ b/plugins/in_tail/tail_file.c @@ -876,7 +876,7 @@ static int set_file_position(struct flb_tail_config *ctx, } file->offset = ret; - if (file->decompression_context == NULL) { + if (file->decompression_context == NULL) { file->stream_offset = ret; } @@ -946,13 +946,13 @@ int flb_tail_file_append(char *path, struct stat *st, int mode, if (flb_tail_file_exists(st, ctx) == FLB_TRUE) { return -1; } - + #ifdef __linux__ if (ctx->file_cache_advise) { flb_plg_debug(ctx->ins, "file will be read in POSIX_FADV_DONTNEED mode %s", path); } #endif - + fd = open(path, O_RDONLY); if (fd == -1) { flb_errno(); @@ -1044,8 +1044,9 @@ int flb_tail_file_append(char *path, struct stat *st, int mode, * for path_key to continue working after rotation. */ file->orig_name = flb_strdup(file->name); if (!file->orig_name) { - flb_free(file->name); flb_errno(); + flb_free(file->name); + file->name = NULL; goto error; } file->orig_name_len = file->name_len; @@ -1449,7 +1450,7 @@ int flb_tail_file_chunk(struct flb_tail_file *file) } } #endif - + read_size = file_buffer_capacity; if (file->decompression_context != NULL) { From 1fc6eedfdf0ca93a6ed86040722dd5b1837b6b74 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Wed, 7 Aug 2024 14:53:28 -0600 Subject: [PATCH 025/295] in_emitter: fix use-after-free on exception (CID 507860) Signed-off-by: Eduardo Silva --- plugins/in_emitter/emitter.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/plugins/in_emitter/emitter.c b/plugins/in_emitter/emitter.c index 8092a7954ee..6d37219befa 100644 --- a/plugins/in_emitter/emitter.c +++ b/plugins/in_emitter/emitter.c @@ -107,8 +107,7 @@ int static do_in_emitter_add_record(struct em_chunk *ec, ec->mp_sbuf.data, ec->mp_sbuf.size); if (ret == -1) { - flb_plg_error(ctx->ins, "error registering chunk with tag: %s", - ec->tag); + flb_plg_error(ctx->ins, "error registering chunk with tag: %s", ec->tag); /* Release the echunk */ em_chunk_destroy(ec); return -1; @@ -156,7 +155,7 @@ int in_emitter_add_record(const char *tag, int tag_len, i_ref->i_ins = i_ins; mk_list_add(&i_ref->_head, &ctx->i_ins_list); /* If in_emitter is paused, but new input plugin is not paused, pause it */ - if (flb_input_buf_paused(ctx->ins) == FLB_TRUE && + if (flb_input_buf_paused(ctx->ins) == FLB_TRUE && flb_input_buf_paused(i_ins) == FLB_FALSE) { flb_input_pause(i_ins); } @@ -229,7 +228,7 @@ static int in_emitter_ingest_ring_buffer(struct flb_input_instance *in, (void) in; - while ((ret = flb_ring_buffer_read(ctx->msgs, (void *)&ec, + while ((ret = flb_ring_buffer_read(ctx->msgs, (void *)&ec, sizeof(struct em_chunk))) == 0) { ret = flb_input_log_append(in, ec.tag, flb_sds_len(ec.tag), @@ -260,8 +259,6 @@ static int cb_queue_chunks(struct flb_input_instance *in, /* Associate this backlog chunk to this instance into the engine */ ret = do_in_emitter_add_record(echunk, in); if (ret == -1) { - flb_error("[in_emitter] error registering chunk with tag: %s", - echunk->tag); continue; } } @@ -400,7 +397,7 @@ static int cb_emitter_exit(void *data, struct flb_config *config) } if (ctx->msgs) { - while ((ret = flb_ring_buffer_read(ctx->msgs, (void *)&ec, + while ((ret = flb_ring_buffer_read(ctx->msgs, (void *)&ec, sizeof(struct em_chunk))) == 0) { flb_sds_destroy(ec.tag); msgpack_sbuffer_destroy(&ec.mp_sbuf); From 54de999c6c4c4a74c2cfb97754dbdb330450147e Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Wed, 7 Aug 2024 14:56:19 -0600 Subject: [PATCH 026/295] in_forward: fix leak on exception (CID 507786) Signed-off-by: Eduardo Silva --- plugins/in_forward/fw_prot.c | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/in_forward/fw_prot.c b/plugins/in_forward/fw_prot.c index 82d37244a5b..14b9661de39 100644 --- a/plugins/in_forward/fw_prot.c +++ b/plugins/in_forward/fw_prot.c @@ -630,6 +630,7 @@ static int check_ping(struct flb_input_instance *ins, if (o.type != MSGPACK_OBJECT_STR) { flb_plg_error(ins, "Invalid password_digest type message"); flb_free(serverside); + flb_free(hostname); msgpack_unpacked_destroy(&result); return -1; } From e84d9ff94daab56112e4043b93b1a779698269fa Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Wed, 7 Aug 2024 14:58:17 -0600 Subject: [PATCH 027/295] out_kafka: add missing initialization (CID 507783) Signed-off-by: Eduardo Silva --- plugins/out_kafka/kafka.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/out_kafka/kafka.c b/plugins/out_kafka/kafka.c index 8dc8cb86ea8..476e528cb83 100644 --- a/plugins/out_kafka/kafka.c +++ b/plugins/out_kafka/kafka.c @@ -105,7 +105,7 @@ int produce_message(struct flb_time *tm, msgpack_object *map, msgpack_packer mp_pck; msgpack_object key; msgpack_object val; - flb_sds_t s; + flb_sds_t s = NULL; #ifdef FLB_HAVE_AVRO_ENCODER // used to flag when a buffer needs to be freed for avro From f54b370cd90c543e8a964e9b579d2aec437ee23b Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Wed, 7 Aug 2024 15:01:40 -0600 Subject: [PATCH 028/295] out_stackdriver: fix leak on exception (CID 508239) Signed-off-by: Eduardo Silva --- plugins/out_stackdriver/stackdriver.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/out_stackdriver/stackdriver.c b/plugins/out_stackdriver/stackdriver.c index 60b66c48ce4..afcf15fe327 100644 --- a/plugins/out_stackdriver/stackdriver.c +++ b/plugins/out_stackdriver/stackdriver.c @@ -1723,7 +1723,7 @@ static flb_sds_t stackdriver_format(struct flb_stackdriver *ctx, /* Parameters for trace */ int trace_extracted = FLB_FALSE; - flb_sds_t trace; + flb_sds_t trace = NULL; char stackdriver_trace[PATH_MAX]; const char *new_trace; @@ -2357,6 +2357,7 @@ static flb_sds_t stackdriver_format(struct flb_stackdriver *ctx, flb_plg_error(ctx->ins, "the type of payload labels should be map"); flb_sds_destroy(operation_id); flb_sds_destroy(operation_producer); + flb_sds_destroy(trace); flb_log_event_decoder_destroy(&log_decoder); msgpack_sbuffer_destroy(&mp_sbuf); return NULL; From 3045fd6be071d11de53f188bc55b81e6d2f30837 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Wed, 31 Jul 2024 11:46:58 +0900 Subject: [PATCH 029/295] wasm: Make configurable heap and stack sizes with a struct type Signed-off-by: Hiroshi Hatake --- include/fluent-bit/wasm/flb_wasm.h | 15 ++++++++- src/wasm/flb_wasm.c | 50 +++++++++++++++++++++++++----- 2 files changed, 57 insertions(+), 8 deletions(-) diff --git a/include/fluent-bit/wasm/flb_wasm.h b/include/fluent-bit/wasm/flb_wasm.h index ecd3fc9d2b7..4198e2adf82 100644 --- a/include/fluent-bit/wasm/flb_wasm.h +++ b/include/fluent-bit/wasm/flb_wasm.h @@ -27,6 +27,17 @@ #include #include +#define FLB_WASM_DEFAULT_HEAP_SIZE 8192 +#define FLB_WASM_DEFAULT_STACK_SIZE 8192 + +struct flb_wasm_config { + size_t heap_size; + size_t stack_size; + int stdinfd; + int stdoutfd; + int stderrfd; +}; + /* WASM Context */ struct flb_wasm { wasm_module_t module; @@ -41,9 +52,11 @@ struct flb_wasm { }; void flb_wasm_init(struct flb_config *config); +struct flb_wasm_config *flb_wasm_config_init(struct flb_config *config); +void flb_wasm_config_destroy(struct flb_wasm_config *wasm_config); struct flb_wasm *flb_wasm_instantiate(struct flb_config *config, const char *wasm_path, struct mk_list *acessible_dir_list, - int stdinfd, int stdoutfd, int stderrfd); + struct flb_wasm_config *wasm_config); char *flb_wasm_call_function_format_json(struct flb_wasm *fw, const char *function_name, const char* tag_data, size_t tag_len, diff --git a/src/wasm/flb_wasm.c b/src/wasm/flb_wasm.c index 8c7d24bb334..a71ff85f4cf 100644 --- a/src/wasm/flb_wasm.c +++ b/src/wasm/flb_wasm.c @@ -43,6 +43,32 @@ void flb_wasm_init(struct flb_config *config) mk_list_init(&config->wasm_list); } +struct flb_wasm_config *flb_wasm_config_init(struct flb_config *config) +{ + struct flb_wasm_config *wasm_config; + + wasm_config = flb_calloc(1, sizeof(struct flb_wasm_config)); + if (!wasm_config) { + flb_errno(); + return NULL; + } + + wasm_config->heap_size = FLB_WASM_DEFAULT_HEAP_SIZE; + wasm_config->stack_size = FLB_WASM_DEFAULT_STACK_SIZE; + wasm_config->stdinfd = -1; + wasm_config->stdoutfd = -1; + wasm_config->stderrfd = -1; + + return wasm_config; +} + +void flb_wasm_config_destroy(struct flb_wasm_config *wasm_config) +{ + if (wasm_config != NULL) { + flb_free(wasm_config); + } +} + static int flb_wasm_load_wasm_binary(const char *wasm_path, int8_t **out_buf, uint32_t *out_size) { char *buffer; @@ -81,10 +107,10 @@ static int flb_wasm_load_wasm_binary(const char *wasm_path, int8_t **out_buf, ui struct flb_wasm *flb_wasm_instantiate(struct flb_config *config, const char *wasm_path, struct mk_list *accessible_dir_list, - int stdinfd, int stdoutfd, int stderrfd) + struct flb_wasm_config *wasm_config) { struct flb_wasm *fw; - uint32_t buf_size, stack_size = 8 * 1024, heap_size = 8 * 1024; + uint32_t buf_size; int8_t *buffer = NULL; char error_buf[128]; #if WASM_ENABLE_LIBC_WASI != 0 @@ -101,6 +127,14 @@ struct flb_wasm *flb_wasm_instantiate(struct flb_config *config, const char *was RuntimeInitArgs wasm_args; + if (wasm_config->heap_size < FLB_WASM_DEFAULT_HEAP_SIZE) { + wasm_config->heap_size = FLB_WASM_DEFAULT_HEAP_SIZE; + } + + if (wasm_config->stack_size < FLB_WASM_DEFAULT_STACK_SIZE) { + wasm_config->stack_size = FLB_WASM_DEFAULT_STACK_SIZE; + } + fw = flb_malloc(sizeof(struct flb_wasm)); if (!fw) { flb_errno(); @@ -150,19 +184,21 @@ struct flb_wasm *flb_wasm_instantiate(struct flb_config *config, const char *was #if WASM_ENABLE_LIBC_WASI != 0 wasm_runtime_set_wasi_args_ex(module, wasi_dir_list, accessible_dir_list_size, NULL, 0, NULL, 0, NULL, 0, - (stdinfd != -1) ? stdinfd : STDIN_FILENO, - (stdoutfd != -1) ? stdoutfd : STDOUT_FILENO, - (stderrfd != -1) ? stderrfd : STDERR_FILENO); + (wasm_config->stdinfd != -1) ? wasm_config->stdinfd : STDIN_FILENO, + (wasm_config->stdoutfd != -1) ? wasm_config->stdoutfd : STDOUT_FILENO, + (wasm_config->stderrfd != -1) ? wasm_config->stderrfd : STDERR_FILENO); #endif - module_inst = wasm_runtime_instantiate(module, stack_size, heap_size, + module_inst = wasm_runtime_instantiate(module, + wasm_config->stack_size, + wasm_config->heap_size, error_buf, sizeof(error_buf)); if (!module_inst) { flb_error("Instantiate wasm module failed. error: %s", error_buf); goto error; } - exec_env = wasm_runtime_create_exec_env(module_inst, stack_size); + exec_env = wasm_runtime_create_exec_env(module_inst, wasm_config->stack_size); if (!exec_env) { flb_error("Create wasm execution environment failed."); goto error; From 03423cfa05893bcaa8ba4acf89b0ebd159f4ed98 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Fri, 9 Aug 2024 17:45:04 +0900 Subject: [PATCH 030/295] filter_wasm: Provide configurable heap and stack sizes for Wasm Signed-off-by: Hiroshi Hatake --- plugins/filter_wasm/filter_wasm.c | 27 ++++++++++++++++++++++++++- plugins/filter_wasm/filter_wasm.h | 6 ++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/plugins/filter_wasm/filter_wasm.c b/plugins/filter_wasm/filter_wasm.c index 8d652e1f85a..e7951bd8c28 100644 --- a/plugins/filter_wasm/filter_wasm.c +++ b/plugins/filter_wasm/filter_wasm.c @@ -88,7 +88,8 @@ static int cb_wasm_filter(const void *data, size_t bytes, return FLB_FILTER_NOTOUCH; } - wasm = flb_wasm_instantiate(config, ctx->wasm_path, ctx->accessible_dir_list, -1, -1, -1); + wasm = flb_wasm_instantiate(config, ctx->wasm_path, ctx->accessible_dir_list, + ctx->wasm_conf); if (wasm == NULL) { flb_plg_debug(ctx->ins, "instantiate wasm [%s] failed", ctx->wasm_path); goto on_error; @@ -330,6 +331,7 @@ static int cb_wasm_init(struct flb_filter_instance *f_ins, struct flb_config *config, void *data) { struct flb_filter_wasm *ctx = NULL; + struct flb_wasm_config *wasm_conf = NULL; int ret = -1; const char *tmp; int event_format; @@ -363,6 +365,18 @@ static int cb_wasm_init(struct flb_filter_instance *f_ins, } flb_wasm_init(config); + wasm_conf = flb_wasm_config_init(config); + if (wasm_conf == NULL) { + goto init_error; + } + ctx->wasm_conf = wasm_conf; + + if (ctx->wasm_heap_size > FLB_WASM_DEFAULT_HEAP_SIZE) { + wasm_conf->heap_size = ctx->wasm_heap_size; + } + if (ctx->wasm_stack_size > FLB_WASM_DEFAULT_STACK_SIZE) { + wasm_conf->stack_size = ctx->wasm_stack_size; + } /* Set context */ flb_filter_set_context(f_ins, ctx); @@ -378,6 +392,7 @@ static int cb_wasm_exit(void *data, struct flb_config *config) { struct flb_filter_wasm *ctx = data; + flb_wasm_config_destroy(ctx->wasm_conf); flb_wasm_destroy_all(config); delete_wasm_config(ctx); return 0; @@ -405,6 +420,16 @@ static struct flb_config_map config_map[] = { 0, FLB_TRUE, offsetof(struct flb_filter_wasm, wasm_function_name), "Set the function name in wasm to execute" }, + { + FLB_CONFIG_MAP_SIZE, "wasm_heap_size", DEFAULT_WASM_HEAP_SIZE, + 0, FLB_TRUE, offsetof(struct flb_filter_wasm, wasm_heap_size), + "Set the heap size of wasm runtime" + }, + { + FLB_CONFIG_MAP_SIZE, "wasm_stack_size", DEFAULT_WASM_STACK_SIZE, + 0, FLB_TRUE, offsetof(struct flb_filter_wasm, wasm_stack_size), + "Set the stack size of wasm runtime" + }, /* EOF */ {0} }; diff --git a/plugins/filter_wasm/filter_wasm.h b/plugins/filter_wasm/filter_wasm.h index f00b131b07f..573b05b146f 100644 --- a/plugins/filter_wasm/filter_wasm.h +++ b/plugins/filter_wasm/filter_wasm.h @@ -38,12 +38,18 @@ enum { #define FLB_FMT_STR_JSON "json" #define FLB_FMT_STR_MSGPACK "msgpack" +#define DEFAULT_WASM_HEAP_SIZE "8192" +#define DEFAULT_WASM_STACK_SIZE "8192" + struct flb_filter_wasm { flb_sds_t wasm_path; struct mk_list *accessible_dir_list; /* list of directories to be * accesible from WASM */ flb_sds_t wasm_function_name; int event_format; + size_t wasm_heap_size; + size_t wasm_stack_size; + struct flb_wasm_config *wasm_conf; struct flb_filter_instance *ins; struct flb_wasm *wasm; }; From 68931d121a163ea9366cb3f6d4a1dee5dc492822 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Fri, 9 Aug 2024 17:45:54 +0900 Subject: [PATCH 031/295] in_exec_wasi: Provide configurable stack and heap sizes for Wasm Signed-off-by: Hiroshi Hatake --- plugins/in_exec_wasi/in_exec_wasi.c | 35 ++++++++++++++++++++++++++++- plugins/in_exec_wasi/in_exec_wasi.h | 6 +++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/plugins/in_exec_wasi/in_exec_wasi.c b/plugins/in_exec_wasi/in_exec_wasi.c index 6a533d0b23a..ba0164c1610 100644 --- a/plugins/in_exec_wasi/in_exec_wasi.c +++ b/plugins/in_exec_wasi/in_exec_wasi.c @@ -74,7 +74,14 @@ static int in_exec_wasi_collect(struct flb_input_instance *ins, } } - wasm = flb_wasm_instantiate(config, ctx->wasi_path, ctx->accessible_dir_list, -1, fileno(stdoutp), -1); + if (ctx->wasm_conf == NULL) { + flb_plg_error(ctx->ins, "wasm_conf cannot be NULL"); + return -1; + } + ctx->wasm_conf->stdoutfd = fileno(stdoutp); + + wasm = flb_wasm_instantiate(config, ctx->wasi_path, ctx->accessible_dir_list, + ctx->wasm_conf); if (wasm == NULL) { flb_plg_debug(ctx->ins, "instantiate wasm [%s] failed", ctx->wasi_path); goto collect_end; @@ -289,6 +296,7 @@ static int in_exec_wasi_init(struct flb_input_instance *in, struct flb_config *config, void *data) { struct flb_exec_wasi *ctx = NULL; + struct flb_wasm_config *wasm_conf = NULL; int ret = -1; /* Allocate space for the configuration */ @@ -341,6 +349,20 @@ static int in_exec_wasi_init(struct flb_input_instance *in, flb_plg_error(in, "could not set collector for exec input plugin"); goto init_error; } + + wasm_conf = flb_wasm_config_init(config); + if (wasm_conf == NULL) { + goto init_error; + } + ctx->wasm_conf = wasm_conf; + + if (ctx->wasm_heap_size > FLB_WASM_DEFAULT_HEAP_SIZE) { + wasm_conf->heap_size = ctx->wasm_heap_size; + } + if (ctx->wasm_stack_size > FLB_WASM_DEFAULT_STACK_SIZE) { + wasm_conf->stack_size = ctx->wasm_stack_size; + } + ctx->coll_fd = ret; return 0; @@ -391,6 +413,7 @@ static int in_exec_wasi_exit(void *data, struct flb_config *config) { struct flb_exec_wasi *ctx = data; + flb_wasm_config_destroy(ctx->wasm_conf); flb_wasm_destroy_all(config); delete_exec_wasi_config(ctx); return 0; @@ -433,6 +456,16 @@ static struct flb_config_map config_map[] = { 0, FLB_TRUE, offsetof(struct flb_exec_wasi, oneshot), "execute the command only once" }, + { + FLB_CONFIG_MAP_SIZE, "wasm_heap_size", DEFAULT_WASM_HEAP_SIZE, + 0, FLB_TRUE, offsetof(struct flb_exec_wasi, wasm_heap_size), + "Set the heap size of wasm runtime" + }, + { + FLB_CONFIG_MAP_SIZE, "wasm_stack_size", DEFAULT_WASM_STACK_SIZE, + 0, FLB_TRUE, offsetof(struct flb_exec_wasi, wasm_stack_size), + "Set the stack size of wasm runtime" + }, /* EOF */ {0} }; diff --git a/plugins/in_exec_wasi/in_exec_wasi.h b/plugins/in_exec_wasi/in_exec_wasi.h index aa07f264141..1fafbd43d6e 100644 --- a/plugins/in_exec_wasi/in_exec_wasi.h +++ b/plugins/in_exec_wasi/in_exec_wasi.h @@ -34,6 +34,9 @@ #define DEFAULT_INTERVAL_SEC "1" #define DEFAULT_INTERVAL_NSEC "0" +#define DEFAULT_WASM_HEAP_SIZE "8192" +#define DEFAULT_WASM_STACK_SIZE "8192" + struct flb_exec_wasi { flb_sds_t wasi_path; struct mk_list *accessible_dir_list; /* list of directories to be @@ -44,10 +47,13 @@ struct flb_exec_wasi { size_t buf_size; struct flb_input_instance *ins; struct flb_wasm *wasm; + struct flb_wasm_config *wasm_conf; int oneshot; flb_pipefd_t ch_manager[2]; int interval_sec; int interval_nsec; + size_t wasm_heap_size; + size_t wasm_stack_size; struct flb_log_event_encoder log_encoder; int coll_fd; }; From f9e6def57cc40f60b8335361e0f4a7f13704f4fe Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 7 Aug 2024 15:58:39 +0200 Subject: [PATCH 032/295] build: added an option to enforce memory alignment Signed-off-by: Leonardo Alminana --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index cf8105b82db..bc32e898acc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,6 +148,7 @@ option(FLB_WINDOWS_DEFAULTS "Build with predefined Windows settings" Yes) option(FLB_WASM "Build with WASM runtime support" Yes) option(FLB_WAMRC "Build with WASM AOT compiler executable" No) option(FLB_WASM_STACK_PROTECT "Build with WASM runtime with strong stack protector flags" No) +option(FLB_ENFORCE_ALIGNMENT "Enable limited platform specific aligned memory access" No) # Native Metrics Support (cmetrics) option(FLB_METRICS "Enable metrics support" Yes) @@ -338,6 +339,11 @@ if(FLB_IPO STREQUAL "On" OR (FLB_IPO STREQUAL "ReleaseOnly" AND FLB_RELEASE)) endif() endif() +# Memory alignment enforcement +if(FLB_ENFORCE_ALIGNMENT) + FLB_DEFINITION(FLB_ENFORCE_ALIGNMENT) +endif() + # Harden release binary against security vulnerabilities if(FLB_SECURITY STREQUAL "On" OR (FLB_SECURITY STREQUAL "ReleaseOnly" AND FLB_RELEASE)) if (NOT MSVC) From f2f6b1d80db74d94430057da5b0fa78902047a96 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 7 Aug 2024 15:59:17 +0200 Subject: [PATCH 033/295] core: added a byte order detection abstraction macro Signed-off-by: Leonardo Alminana --- include/fluent-bit/flb_endian.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/fluent-bit/flb_endian.h b/include/fluent-bit/flb_endian.h index 097b26f774c..b376ea84235 100644 --- a/include/fluent-bit/flb_endian.h +++ b/include/fluent-bit/flb_endian.h @@ -51,4 +51,17 @@ #define be64toh(x) OSSwapBigToHostInt64(x) #endif +#define FLB_LITTLE_ENDIAN 0 +#define FLB_BIG_ENDIAN 1 + +#ifndef FLB_BYTE_ORDER + #if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + #define FLB_BYTE_ORDER FLB_BIG_ENDIAN + #elif defined(__BIG_ENDIAN__) || defined(__BIG_ENDIAN) || defined(_BIG_ENDIAN) + #define FLB_BYTE_ORDER FLB_BIG_ENDIAN + #else + #define FLB_BYTE_ORDER FLB_LITTLE_ENDIAN + #endif +#endif + #endif From 7f037486e193d53d7d9402eca9e7619813ae8193 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 7 Aug 2024 15:59:58 +0200 Subject: [PATCH 034/295] core: added aligned memory read functions Signed-off-by: Leonardo Alminana --- include/fluent-bit/flb_compat.h | 64 +++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/include/fluent-bit/flb_compat.h b/include/fluent-bit/flb_compat.h index fc5d623d505..2e7f28273a2 100644 --- a/include/fluent-bit/flb_compat.h +++ b/include/fluent-bit/flb_compat.h @@ -31,6 +31,9 @@ * libmonkey exposes compat macros for , which some platforms lack, * so include the header here. */ +#include +#include + #include #ifdef FLB_SYSTEM_WINDOWS @@ -143,4 +146,65 @@ static inline int usleep(LONGLONG usec) #include #endif +#ifdef FLB_ENFORCE_ALIGNMENT + +/* Please do not modify these functions without a very solid understanding of + * the reasoning behind. + * + * These functions deliverately abuse the volatile qualifier in order to prevent + * the compiler from mistakenly optimizing the memory accesses into a singled + * DWORD read (which in some architecture and compiler combinations it does regardless + * of the flags). + * + * The reason why we decided to include this is that according to PR 9096, + * when the linux kernel is built and configured to pass through memory alignment + * exceptions rather than remediate them fluent-bit generates one while accessing a + * packed field in the msgpack wire format (which we cannot modify due to interoperability + * reasons). + * + * Because of this, a potential patch using memcpy was suggested, however, this patch did + * not yield consistent machine code accross architecture and compiler versions with most + * of them still generating optimized misaligned memory access instructions. + * + * Keep in mind that these functions transform a single memory read into seven plus a few + * writes as this was the only way to prevent the compiler from mistakenly optimizing the + * operations. + * + * In most cases, FLB_ENFORCE_ALIGNMENT should not be enabled and the operating system + * kernel should be left to handle these scenarios, however, this option is present for + * those users who deliverately and knowingly choose to set up their operating system in + * a way that requires it. + * + */ + +#if FLB_BYTE_ORDER == FLB_LITTLE_ENDIAN +static inline uint32_t __attribute__((optimize("-O0"))) FLB_ALIGNED_DWORD_READ(unsigned char *source) { + volatile uint32_t result; + + result = ((uint32_t)(((uint8_t *) source)[0]) << 0); + result |= ((uint32_t)(((uint8_t *) source)[1]) << 8); + result |= ((uint32_t)(((uint8_t *) source)[2]) << 16); + result |= ((uint32_t)(((uint8_t *) source)[3]) << 24); + + return result; +} +#else +static inline uint32_t __attribute__((optimize("-O0"))) FLB_ALIGNED_DWORD_READ(unsigned char *source) { + volatile uint32_t result; + + result = ((uint32_t)(((uint8_t *) source)[3]) << 0); + result |= ((uint32_t)(((uint8_t *) source)[2]) << 8); + result |= ((uint32_t)(((uint8_t *) source)[1]) << 16); + result |= ((uint32_t)(((uint8_t *) source)[0]) << 24); + + return result; +} +#endif + +#else +static inline uint32_t FLB_ALIGNED_DWORD_READ(unsigned char *source) { + return *((uint32_t *) source); +} +#endif + #endif From bec60340076215ee0908e60231ff361b2abc0c87 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 7 Aug 2024 16:02:38 +0200 Subject: [PATCH 035/295] log_event_decoder: updated code to use aligned memory reads This will not change the underlying code for 99.9% of the users, however, when specifically enabled it through the FLB_ENFORCE_ALIGNMENT feature flag, FLB_ALIGNED_DWORD_READ will issue four BYTE sized reads instead of a single DWORD sized read to ensure that memory access is aligned. Signed-off-by: Leonardo Alminana --- src/flb_log_event_decoder.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/flb_log_event_decoder.c b/src/flb_log_event_decoder.c index 53cf1c63412..3e8ca6e56d4 100644 --- a/src/flb_log_event_decoder.c +++ b/src/flb_log_event_decoder.c @@ -19,6 +19,7 @@ #include #include +#include static int create_empty_map(struct flb_log_event_decoder *context) { msgpack_packer packer; @@ -179,8 +180,15 @@ int flb_log_event_decoder_decode_timestamp(msgpack_object *input, return FLB_EVENT_DECODER_ERROR_WRONG_TIMESTAMP_TYPE; } - output->tm.tv_sec = (int32_t) FLB_BSWAP_32(*((uint32_t *) &input->via.ext.ptr[0])); - output->tm.tv_nsec = (int32_t) FLB_BSWAP_32(*((uint32_t *) &input->via.ext.ptr[4])); + output->tm.tv_sec = + (int32_t) FLB_BSWAP_32( + FLB_ALIGNED_DWORD_READ( + (unsigned char *) &input->via.ext.ptr[0])); + + output->tm.tv_nsec = + (int32_t) FLB_BSWAP_32( + FLB_ALIGNED_DWORD_READ( + (unsigned char *) &input->via.ext.ptr[4])); } else { return FLB_EVENT_DECODER_ERROR_WRONG_TIMESTAMP_TYPE; From 13db2ee143d13a27004b37c7c55715eb192276e2 Mon Sep 17 00:00:00 2001 From: edsiper <369718+edsiper@users.noreply.github.com> Date: Sat, 10 Aug 2024 02:33:36 +0000 Subject: [PATCH 036/295] release: update to 3.1.6 Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CMakeLists.txt | 2 +- dockerfiles/Dockerfile | 2 +- fluent-bit-3.1.5.bb => fluent-bit-3.1.6.bb | 2 +- snap/snapcraft.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename fluent-bit-3.1.5.bb => fluent-bit-3.1.6.bb (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index bc32e898acc..fa6393f3514 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ set(CMAKE_POLICY_DEFAULT_CMP0069 NEW) # Fluent Bit Version set(FLB_VERSION_MAJOR 3) set(FLB_VERSION_MINOR 1) -set(FLB_VERSION_PATCH 5) +set(FLB_VERSION_PATCH 6) set(FLB_VERSION_STR "${FLB_VERSION_MAJOR}.${FLB_VERSION_MINOR}.${FLB_VERSION_PATCH}") set(CMAKE_POSITION_INDEPENDENT_CODE ON) diff --git a/dockerfiles/Dockerfile b/dockerfiles/Dockerfile index 08848ee0954..4ef0738a520 100644 --- a/dockerfiles/Dockerfile +++ b/dockerfiles/Dockerfile @@ -11,7 +11,7 @@ # docker buildx build --platform "linux/amd64,linux/arm64,linux/arm/v7,linux/s390x" -f ./dockerfiles/Dockerfile.multiarch --build-arg FLB_TARBALL=https://github.com/fluent/fluent-bit/archive/v1.8.11.tar.gz ./dockerfiles/ # Set this to the current release version: it gets done so as part of the release. -ARG RELEASE_VERSION=3.1.5 +ARG RELEASE_VERSION=3.1.6 # For multi-arch builds - assumption is running on an AMD64 host FROM multiarch/qemu-user-static:x86_64-arm as qemu-arm32 diff --git a/fluent-bit-3.1.5.bb b/fluent-bit-3.1.6.bb similarity index 99% rename from fluent-bit-3.1.5.bb rename to fluent-bit-3.1.6.bb index b3a3a2827f9..6f8769259ec 100644 --- a/fluent-bit-3.1.5.bb +++ b/fluent-bit-3.1.6.bb @@ -16,7 +16,7 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=2ee41112a44fe7014dce33e26468ba93" SECTION = "net" PR = "r0" -PV = "3.1.5" +PV = "3.1.6" SRCREV = "v${PV}" SRC_URI = "git://github.com/fluent/fluent-bit.git;nobranch=1" diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index f43cbc08f5d..72eaa76d7a4 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,6 +1,6 @@ name: fluent-bit base: core18 -version: '3.1.5' +version: '3.1.6' summary: High performance logs and stream processor description: | Fluent Bit is a high performance log processor and stream processor for Linux. From 25f1376ca8a6fdf702b3ccd3f7d1426ef93a2845 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Tue, 13 Aug 2024 00:27:23 +0200 Subject: [PATCH 037/295] filter_parser: added debug message (CID 508252) Signed-off-by: Leonardo Alminana --- plugins/filter_parser/filter_parser.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/filter_parser/filter_parser.c b/plugins/filter_parser/filter_parser.c index 8986308f8a2..11bf71f7e53 100644 --- a/plugins/filter_parser/filter_parser.c +++ b/plugins/filter_parser/filter_parser.c @@ -367,6 +367,10 @@ static int cb_parser_filter(const void *data, size_t bytes, encoder_result = flb_log_event_encoder_commit_record(&log_encoder); } + if (encoder_result != FLB_EVENT_ENCODER_SUCCESS) { + flb_plg_error(ctx->ins, "log event encoder error : %d", encoder_result); + } + flb_free(append_arr); append_arr = NULL; } From fa46ed93581b289aa7e56fa5e2b610042962b64c Mon Sep 17 00:00:00 2001 From: Braydon Kains <93549768+braydonk@users.noreply.github.com> Date: Tue, 13 Aug 2024 11:44:28 -0400 Subject: [PATCH 038/295] pack: do not multiply out_size by realloc_size (#9193) In `flb_msgpack_raw_to_json_sds`, when the buffer is reallocated it calls `flb_sds_increase`. This increases the length by adding the `len` argument to the length and reallocating the sds object. After doing this, the `out_size` is multiplied by `realloc_size`. This does not match reality, as what happened in the reallocation was additive not multiplicative. This commit corrects the inconsistency. Signed-off-by: braydonk --- src/flb_pack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/flb_pack.c b/src/flb_pack.c index 524277a20e3..7a09c21b3af 100644 --- a/src/flb_pack.c +++ b/src/flb_pack.c @@ -810,7 +810,7 @@ flb_sds_t flb_msgpack_raw_to_json_sds(const void *in_buf, size_t in_size) tmp_buf = flb_sds_increase(out_buf, realloc_size); if (tmp_buf) { out_buf = tmp_buf; - out_size *= realloc_size; + out_size = flb_sds_alloc(out_buf); } else { flb_errno(); From c7c0c09dc1670c3827b09a043e8686b76d1791cc Mon Sep 17 00:00:00 2001 From: shuaichen Date: Tue, 13 Aug 2024 10:03:56 -0700 Subject: [PATCH 039/295] out_stackdriver: Add latency metric for write log entries HTTP request. (#9182) Signed-off-by: shuaichen --- plugins/out_stackdriver/stackdriver.c | 11 +++++++++++ plugins/out_stackdriver/stackdriver.h | 3 +++ plugins/out_stackdriver/stackdriver_conf.c | 15 +++++++++++++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/plugins/out_stackdriver/stackdriver.c b/plugins/out_stackdriver/stackdriver.c index afcf15fe327..71c6abe233c 100644 --- a/plugins/out_stackdriver/stackdriver.c +++ b/plugins/out_stackdriver/stackdriver.c @@ -2830,6 +2830,9 @@ static void cb_stackdriver_flush(struct flb_event_chunk *event_chunk, struct flb_connection *u_conn; struct flb_http_client *c; int compressed = FLB_FALSE; + uint64_t write_entries_start = 0; + uint64_t write_entries_end = 0; + float write_entries_latency = 0.0; #ifdef FLB_HAVE_METRICS char *name = (char *) flb_output_name(ctx->ins); uint64_t ts = cfl_time_now(); @@ -2924,9 +2927,14 @@ static void cb_stackdriver_flush(struct flb_event_chunk *event_chunk, flb_http_set_content_encoding_gzip(c); } + write_entries_start = cfl_time_now(); + /* Send HTTP request */ ret = flb_http_do(c, &b_sent); + write_entries_end = cfl_time_now(); + write_entries_latency = (float)(write_entries_end - write_entries_start) / 1000000000.0; + /* validate response */ if (ret != 0) { flb_plg_warn(ctx->ins, "http_do=%i", ret); @@ -2995,6 +3003,9 @@ static void cb_stackdriver_flush(struct flb_event_chunk *event_chunk, #ifdef FLB_HAVE_METRICS if (ret_code == FLB_OK) { cmt_counter_inc(ctx->cmt_successful_requests, ts, 1, (char *[]) {name}); + if (write_entries_latency > 0.0) { + cmt_histogram_observe(ctx->cmt_write_entries_latency, ts, write_entries_latency, 1, (char *[]) {name}); + } add_record_metrics(ctx, ts, (int) event_chunk->total_events, 200, 0); /* OLD api */ diff --git a/plugins/out_stackdriver/stackdriver.h b/plugins/out_stackdriver/stackdriver.h index 76f5a7598ea..fa5cb2e2b10 100644 --- a/plugins/out_stackdriver/stackdriver.h +++ b/plugins/out_stackdriver/stackdriver.h @@ -27,6 +27,8 @@ #include #include +#include + /* refresh token every 50 minutes */ #define FLB_STD_TOKEN_REFRESH 3000 @@ -218,6 +220,7 @@ struct flb_stackdriver { struct cmt_counter *cmt_requests_total; struct cmt_counter *cmt_proc_records_total; struct cmt_counter *cmt_retried_records_total; + struct cmt_histogram *cmt_write_entries_latency; #endif /* plugin instance */ diff --git a/plugins/out_stackdriver/stackdriver_conf.c b/plugins/out_stackdriver/stackdriver_conf.c index b7de32a0a95..89582623d40 100644 --- a/plugins/out_stackdriver/stackdriver_conf.c +++ b/plugins/out_stackdriver/stackdriver_conf.c @@ -262,6 +262,7 @@ struct flb_stackdriver *flb_stackdriver_conf_create(struct flb_output_instance * const char *backwards_compatible_env_var; struct flb_stackdriver *ctx; size_t http_request_key_size; + struct cmt_histogram_buckets *buckets; /* Allocate config context */ ctx = flb_calloc(1, sizeof(struct flb_stackdriver)); @@ -559,6 +560,16 @@ struct flb_stackdriver *flb_stackdriver_conf_create(struct flb_output_instance * "Total number of retried records.", 2, (char *[]) {"status", "name"}); + buckets = cmt_histogram_buckets_create(7, 1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0); + ctx->cmt_write_entries_latency = cmt_histogram_create(ins->cmt, + "fluentbit", + "stackdriver", + "write_entries_latency", + "Latency of Cloud Logging WriteLogEntries HTTP request.", + buckets, + 1, (char *[]) {"name"}); + + /* OLD api */ flb_metrics_add(FLB_STACKDRIVER_SUCCESSFUL_REQUESTS, "stackdriver_successful_requests", ctx->ins->metrics); @@ -599,7 +610,7 @@ int flb_stackdriver_conf_destroy(struct flb_stackdriver *ctx) } flb_free(ctx->creds); } - + if (ctx->env) { if (ctx->env->creds_file) { flb_sds_destroy(ctx->env->creds_file); @@ -620,7 +631,7 @@ int flb_stackdriver_conf_destroy(struct flb_stackdriver *ctx) if (ctx->metadata_server) { flb_sds_destroy(ctx->metadata_server); } - + if (ctx->resource_type == RESOURCE_TYPE_K8S){ flb_sds_destroy(ctx->namespace_name); flb_sds_destroy(ctx->pod_name); From e60c2f7266fef9ec8eaf53b1715e122f7e1b1d80 Mon Sep 17 00:00:00 2001 From: leonardo-albertovich Date: Tue, 13 Aug 2024 19:20:12 +0200 Subject: [PATCH 040/295] in_forward: fix leaks when processing metrics and traces (#9199) Signed-off-by: Leonardo Alminana --- plugins/in_forward/fw_prot.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/in_forward/fw_prot.c b/plugins/in_forward/fw_prot.c index 14b9661de39..9ad28318066 100644 --- a/plugins/in_forward/fw_prot.c +++ b/plugins/in_forward/fw_prot.c @@ -1122,6 +1122,7 @@ static int append_log(struct flb_input_instance *ins, struct fw_conn *conn, flb_input_metrics_append(conn->in, out_tag, flb_sds_len(out_tag), cmt); + cmt_decode_msgpack_destroy(cmt); } else if (event_type == FLB_EVENT_TYPE_TRACES) { off = 0; @@ -1133,6 +1134,8 @@ static int append_log(struct flb_input_instance *ins, struct fw_conn *conn, flb_input_trace_append(ins, out_tag, flb_sds_len(out_tag), ctr); + + ctr_decode_msgpack_destroy(ctr); } return 0; From 9c8e73a90cc6e508c584c26a2ebcf5cfd4f437d8 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Fri, 9 Aug 2024 20:59:04 +0900 Subject: [PATCH 041/295] upstream_node: Process tls.verify_hostname parameter Signed-off-by: Hiroshi Hatake --- include/fluent-bit/flb_upstream_node.h | 2 ++ src/flb_upstream_ha.c | 12 +++++++++++- src/flb_upstream_node.c | 12 ++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/include/fluent-bit/flb_upstream_node.h b/include/fluent-bit/flb_upstream_node.h index 429ebd0ceb7..8f203392f28 100644 --- a/include/fluent-bit/flb_upstream_node.h +++ b/include/fluent-bit/flb_upstream_node.h @@ -36,6 +36,7 @@ struct flb_upstream_node { #ifdef FLB_HAVE_TLS /* TLS: given configuration */ int tls_verify; /* Verify certs (default: true) */ + int tls_verify_hostname; /* Verify hostname (default: false) */ int tls_debug; /* mbedtls debug level */ char *tls_ca_path; /* Path to certificates */ char *tls_ca_file; /* CA root cert */ @@ -65,6 +66,7 @@ struct flb_upstream_node { struct flb_upstream_node *flb_upstream_node_create(flb_sds_t name, flb_sds_t host, flb_sds_t port, int tls, int tls_verify, + int tls_verify_hostname, int tls_debug, const char *tls_vhost, const char *tls_ca_path, diff --git a/src/flb_upstream_ha.c b/src/flb_upstream_ha.c index 4ece420d173..1579261aba5 100644 --- a/src/flb_upstream_ha.c +++ b/src/flb_upstream_ha.c @@ -120,6 +120,7 @@ static struct flb_upstream_node *create_node(int id, int vlen; int tls = FLB_FALSE; int tls_verify = FLB_TRUE; + int tls_verify_hostname = FLB_FALSE; int tls_debug = 1; char key[32]; char *tmp; @@ -138,7 +139,8 @@ static struct flb_upstream_node *create_node(int id, const char *known_keys[] = {"name", "host", "port", "tls", "tls.vhost", "tls.verify", "tls.debug", "tls.ca_path", "tls.ca_file", "tls.crt_file", - "tls.key_file", "tls.key_passwd", NULL}; + "tls.key_file", "tls.key_passwd", + "tls.verify_hostname", NULL}; struct flb_upstream_node *node; @@ -180,6 +182,13 @@ static struct flb_upstream_node *create_node(int id, flb_sds_destroy(tmp); } + /* tls.verify_hostname */ + tmp = flb_cf_section_property_get_string(cf, s, "tls.verify_hostname"); + if (tmp) { + tls_verify_hostname = flb_utils_bool(tmp); + flb_sds_destroy(tmp); + } + /* tls.debug */ tmp = flb_cf_section_property_get_string(cf, s, "tls.debug"); if (tmp) { @@ -252,6 +261,7 @@ static struct flb_upstream_node *create_node(int id, } node = flb_upstream_node_create(name, host, port, tls, tls_verify, + tls_verify_hostname, tls_debug, tls_vhost, tls_ca_path, tls_ca_file, tls_crt_file, tls_key_file, tls_key_passwd, ht, config); diff --git a/src/flb_upstream_node.c b/src/flb_upstream_node.c index 117e8f89f3f..5131efd0d6b 100644 --- a/src/flb_upstream_node.c +++ b/src/flb_upstream_node.c @@ -30,6 +30,7 @@ struct flb_upstream_node *flb_upstream_node_create(flb_sds_t name, flb_sds_t host, flb_sds_t port, int tls, int tls_verify, + int tls_verify_hostname, int tls_debug, const char *tls_vhost, const char *tls_ca_path, @@ -40,6 +41,7 @@ struct flb_upstream_node *flb_upstream_node_create(flb_sds_t name, flb_sds_t hos struct flb_hash_table *ht, struct flb_config *config) { + int ret; int i_port; int io_flags; char tmp[255]; @@ -143,6 +145,16 @@ struct flb_upstream_node *flb_upstream_node_create(flb_sds_t name, flb_sds_t hos return NULL; } node->tls_enabled = FLB_TRUE; + if (tls_verify_hostname == FLB_TRUE) { + ret = flb_tls_set_verify_hostname(node->tls, tls_verify_hostname); + if (ret == -1) { + flb_error("[upstream_node] error set up to verify hostname in TLS context " + "on node '%s'", name); + flb_upstream_node_destroy(node); + + return NULL; + } + } } #endif From 599b9dd2381e6e50776a1d056b96a053fb4ddba4 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Fri, 9 Aug 2024 21:03:00 +0900 Subject: [PATCH 042/295] out_azure_kusto: Follow the creating node function change Signed-off-by: Hiroshi Hatake --- plugins/out_azure_kusto/azure_kusto_conf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/out_azure_kusto/azure_kusto_conf.c b/plugins/out_azure_kusto/azure_kusto_conf.c index 973a91419c6..ec4c23c8d16 100644 --- a/plugins/out_azure_kusto/azure_kusto_conf.c +++ b/plugins/out_azure_kusto/azure_kusto_conf.c @@ -79,6 +79,7 @@ static struct flb_upstream_node *flb_upstream_node_create_url(struct flb_azure_k node = flb_upstream_node_create( NULL, sds_host, sds_port, FLB_TRUE, ctx->ins->tls->verify, + ctx->ins->tls->verify_hostname, ctx->ins->tls->debug, ctx->ins->tls->vhost, NULL, NULL, NULL, NULL, NULL, kv, config); From dd1ccf28f2e45b3a5858e681a0dce06d02c5b450 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Tue, 13 Aug 2024 17:14:49 +0900 Subject: [PATCH 043/295] upstream_ha: Plug memory leaks Signed-off-by: Hiroshi Hatake --- src/flb_upstream_ha.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/flb_upstream_ha.c b/src/flb_upstream_ha.c index 1579261aba5..7856bf3df14 100644 --- a/src/flb_upstream_ha.c +++ b/src/flb_upstream_ha.c @@ -265,6 +265,32 @@ static struct flb_upstream_node *create_node(int id, tls_debug, tls_vhost, tls_ca_path, tls_ca_file, tls_crt_file, tls_key_file, tls_key_passwd, ht, config); + + /* Teardown for created flb_sds_t stuffs by flb_cf_section_property_get_string(). */ + if (tls_vhost != NULL) { + flb_sds_destroy(tls_vhost); + } + + if (tls_ca_path != NULL) { + flb_sds_destroy(tls_ca_path); + } + + if (tls_ca_file != NULL) { + flb_sds_destroy(tls_ca_file); + } + + if (tls_crt_file != NULL) { + flb_sds_destroy(tls_crt_file); + } + + if (tls_key_file != NULL) { + flb_sds_destroy(tls_key_file); + } + + if (tls_key_passwd != NULL) { + flb_sds_destroy(tls_key_passwd); + } + return node; } From cebc0a4d66125eaf72e615ef6f941700f5109c77 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Tue, 13 Aug 2024 13:44:42 -0600 Subject: [PATCH 044/295] out_datadog: use cat_safe for remapped tags (CID 253605) Signed-off-by: Eduardo Silva --- plugins/out_datadog/datadog.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/plugins/out_datadog/datadog.c b/plugins/out_datadog/datadog.c index 1f623662fe7..86ff6b51a2a 100644 --- a/plugins/out_datadog/datadog.c +++ b/plugins/out_datadog/datadog.c @@ -120,9 +120,9 @@ static int datadog_format(struct flb_config *config, /* in normal flush callback we have the event_chunk set as flush context * so we don't need to calculate the event len. * But in test mode the formatter won't get the event_chunk as flush_ctx - */ + */ if (flush_ctx != NULL) { - event_chunk = flush_ctx; + event_chunk = flush_ctx; array_size = event_chunk->total_events; } else { array_size = flb_mp_count(data, bytes); @@ -292,25 +292,24 @@ static int datadog_format(struct flb_config *config, /* here we concatenate ctx->dd_tags and remapped_tags, depending on their presence */ if (remap_cnt) { if (ctx->dd_tags != NULL) { - tmp = flb_sds_cat(remapped_tags, FLB_DATADOG_TAG_SEPERATOR, - strlen(FLB_DATADOG_TAG_SEPERATOR)); - if (!tmp) { + ret = flb_sds_cat_safe(&remapped_tags, FLB_DATADOG_TAG_SEPERATOR, + strlen(FLB_DATADOG_TAG_SEPERATOR)); + if (ret < 0) { flb_errno(); flb_sds_destroy(remapped_tags); msgpack_sbuffer_destroy(&mp_sbuf); flb_log_event_decoder_destroy(&log_decoder); return -1; } - remapped_tags = tmp; - flb_sds_cat(remapped_tags, ctx->dd_tags, strlen(ctx->dd_tags)); - if (!tmp) { + + ret = flb_sds_cat_safe(&remapped_tags, ctx->dd_tags, strlen(ctx->dd_tags)); + if (ret < 0) { flb_errno(); flb_sds_destroy(remapped_tags); msgpack_sbuffer_destroy(&mp_sbuf); flb_log_event_decoder_destroy(&log_decoder); return -1; } - remapped_tags = tmp; } dd_msgpack_pack_key_value_str(&mp_pck, FLB_DATADOG_DD_TAGS_KEY, From 3cc09a4b26dbe1dd91f89f2ab7059966d9b00987 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Tue, 13 Aug 2024 13:48:34 -0600 Subject: [PATCH 045/295] azure_blob_http: use sds_cat variant (CID 306764 306765) Signed-off-by: Eduardo Silva --- plugins/out_azure_blob/azure_blob_http.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/out_azure_blob/azure_blob_http.c b/plugins/out_azure_blob/azure_blob_http.c index dd6f128a242..01efdb5c073 100644 --- a/plugins/out_azure_blob/azure_blob_http.c +++ b/plugins/out_azure_blob/azure_blob_http.c @@ -236,6 +236,7 @@ flb_sds_t azb_http_canonical_request(struct flb_azure_blob *ctx, can_headers = canonical_headers(c); if (!can_headers) { flb_sds_destroy(can_req); + flb_sds_destroy(tmp); return NULL; } tmp = flb_sds_cat(can_req, can_headers, flb_sds_len(can_headers)); @@ -345,8 +346,8 @@ int azb_http_client_setup(struct flb_azure_blob *ctx, struct flb_http_client *c, auth = flb_sds_create_size(64 + flb_sds_len(can_req)); - flb_sds_cat(auth, ctx->shared_key_prefix, flb_sds_len(ctx->shared_key_prefix)); - flb_sds_cat(auth, can_req, flb_sds_len(can_req)); + flb_sds_cat_safe(&auth, ctx->shared_key_prefix, flb_sds_len(ctx->shared_key_prefix)); + flb_sds_cat_safe(&auth, can_req, flb_sds_len(can_req)); /* Azure header: authorization */ flb_http_add_header(c, "Authorization", 13, auth, flb_sds_len(auth)); From 6adc8a3e0b36d1bae95031429da24e503549d4eb Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Tue, 13 Aug 2024 13:52:42 -0600 Subject: [PATCH 046/295] out_stackdriver: release log_name on exception (CID 313112) Signed-off-by: Eduardo Silva --- plugins/out_stackdriver/stackdriver.c | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/out_stackdriver/stackdriver.c b/plugins/out_stackdriver/stackdriver.c index 71c6abe233c..4326683187d 100644 --- a/plugins/out_stackdriver/stackdriver.c +++ b/plugins/out_stackdriver/stackdriver.c @@ -2358,6 +2358,7 @@ static flb_sds_t stackdriver_format(struct flb_stackdriver *ctx, flb_sds_destroy(operation_id); flb_sds_destroy(operation_producer); flb_sds_destroy(trace); + flb_sds_destroy(log_name); flb_log_event_decoder_destroy(&log_decoder); msgpack_sbuffer_destroy(&mp_sbuf); return NULL; From 1930b23e739cd796e86f3657a83e4931d453146c Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Tue, 13 Aug 2024 13:57:40 -0600 Subject: [PATCH 047/295] in_http: use cat_safe on tag handliong Signed-off-by: Eduardo Silva --- plugins/in_http/http_prot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/in_http/http_prot.c b/plugins/in_http/http_prot.c index eae52607b10..4070c159495 100644 --- a/plugins/in_http/http_prot.c +++ b/plugins/in_http/http_prot.c @@ -632,7 +632,7 @@ int http_prot_handle(struct flb_http *ctx, struct http_conn *conn, } /* New tag skipping the URI '/' */ - flb_sds_cat(tag, uri + 1, len - 1); + flb_sds_cat_safe(&tag, uri + 1, len - 1); /* Sanitize, only allow alphanum chars */ for (i = 0; i < flb_sds_len(tag); i++) { From cc54b613b615a2fedcb5895cd0807cb42daf811a Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Tue, 13 Aug 2024 14:00:07 -0600 Subject: [PATCH 048/295] lib: cmetrics: upgrade to v0.9.4 Signed-off-by: Eduardo Silva --- lib/cmetrics/CMakeLists.txt | 2 +- .../include/cmetrics/cmt_decode_statsd.h | 60 ++ lib/cmetrics/src/CMakeLists.txt | 1 + lib/cmetrics/src/cmt_cat.c | 6 +- lib/cmetrics/src/cmt_counter.c | 16 +- .../src/cmt_decode_prometheus_remote_write.c | 1 + lib/cmetrics/src/cmt_decode_statsd.c | 613 ++++++++++++++++++ lib/cmetrics/src/cmt_encode_splunk_hec.c | 4 +- lib/cmetrics/src/cmt_gauge.c | 24 +- lib/cmetrics/src/cmt_histogram.c | 8 +- lib/cmetrics/src/cmt_summary.c | 4 +- lib/cmetrics/src/cmt_untyped.c | 8 +- lib/cmetrics/tests/data/statsd_payload.txt | 13 + lib/cmetrics/tests/decoding.c | 32 + 14 files changed, 754 insertions(+), 38 deletions(-) create mode 100644 lib/cmetrics/include/cmetrics/cmt_decode_statsd.h create mode 100644 lib/cmetrics/src/cmt_decode_statsd.c create mode 100644 lib/cmetrics/tests/data/statsd_payload.txt diff --git a/lib/cmetrics/CMakeLists.txt b/lib/cmetrics/CMakeLists.txt index 6509d7a35f4..f5221d7f524 100644 --- a/lib/cmetrics/CMakeLists.txt +++ b/lib/cmetrics/CMakeLists.txt @@ -6,7 +6,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # CMetrics Version set(CMT_VERSION_MAJOR 0) set(CMT_VERSION_MINOR 9) -set(CMT_VERSION_PATCH 3) +set(CMT_VERSION_PATCH 4) set(CMT_VERSION_STR "${CMT_VERSION_MAJOR}.${CMT_VERSION_MINOR}.${CMT_VERSION_PATCH}") # Include helpers diff --git a/lib/cmetrics/include/cmetrics/cmt_decode_statsd.h b/lib/cmetrics/include/cmetrics/cmt_decode_statsd.h new file mode 100644 index 00000000000..12415fe5da4 --- /dev/null +++ b/lib/cmetrics/include/cmetrics/cmt_decode_statsd.h @@ -0,0 +1,60 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* CMetrics + * ======== + * Copyright 2021-2022 The CMetrics Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef CMT_DECODE_STATSD_H +#define CMT_DECODE_STATSD_H + +#include + +#define CMT_DECODE_STATSD_TYPE_COUNTER 1 +#define CMT_DECODE_STATSD_TYPE_GAUGE 2 +#define CMT_DECODE_STATSD_TYPE_TIMER 3 +#define CMT_DECODE_STATSD_TYPE_SET 4 + +#define CMT_DECODE_STATSD_SUCCESS 0 +#define CMT_DECODE_STATSD_ALLOCATION_ERROR 1 +#define CMT_DECODE_STATSD_UNEXPECTED_ERROR 2 +#define CMT_DECODE_STATSD_INVALID_ARGUMENT_ERROR 3 +#define CMT_DECODE_STATSD_UNEXPECTED_METRIC_TYPE 4 +#define CMT_DECODE_STATSD_DECODE_ERROR 5 +#define CMT_DECODE_STATSD_UNPACK_ERROR 6 +#define CMT_DECODE_STATSD_UNSUPPORTED_METRIC_TYPE 7 +#define CMT_DECODE_STATSD_INVALID_TAG_FORMAT_ERROR 8 + +#define CMT_DECODE_STATSD_GAUGE_OBSERVER 1 << 0 + +/* + * The "cmt_statsd_message" represents a single line in UDP packet. + * It's just a bunch of pointers to ephemeral buffer. + */ +struct cmt_statsd_message { + char *bucket; + int bucket_len; + char *value; + char *labels; + int value_len; + int type; + double sample_rate; +}; + +int cmt_decode_statsd_create(struct cmt **out_cmt, char *in_buf, size_t in_size, int flags); +void cmt_decode_statsd_destroy(struct cmt *cmt); + +#endif diff --git a/lib/cmetrics/src/CMakeLists.txt b/lib/cmetrics/src/CMakeLists.txt index d45de9b8334..f08667d07a1 100644 --- a/lib/cmetrics/src/CMakeLists.txt +++ b/lib/cmetrics/src/CMakeLists.txt @@ -35,6 +35,7 @@ set(src cmt_encode_influx.c cmt_encode_msgpack.c cmt_decode_msgpack.c + cmt_decode_statsd.c cmt_mpack_utils.c external/remote.pb-c.c external/types.pb-c.c diff --git a/lib/cmetrics/src/cmt_cat.c b/lib/cmetrics/src/cmt_cat.c index af95dcbd73d..b2171196086 100644 --- a/lib/cmetrics/src/cmt_cat.c +++ b/lib/cmetrics/src/cmt_cat.c @@ -346,20 +346,16 @@ int cmt_cat_untyped(struct cmt *cmt, struct cmt_untyped *untyped, int cmt_cat_histogram(struct cmt *cmt, struct cmt_histogram *histogram, struct cmt_map *filtered_map) { - int i; - double val; int ret; char **labels = NULL; struct cmt_map *map; struct cmt_opts *opts; struct cmt_histogram *hist; - uint64_t timestamp; struct cmt_histogram_buckets *buckets; int64_t buckets_count; map = histogram->map; opts = map->opts; - timestamp = cmt_metric_get_timestamp(&map->metric); ret = cmt_cat_copy_label_keys(map, (char **) &labels); if (ret == -1) { @@ -433,6 +429,8 @@ int cmt_cat_summary(struct cmt *cmt, struct cmt_summary *summary, quantiles, map->label_count, labels); if (!sum) { + free(labels); + free(quantiles); return -1; } diff --git a/lib/cmetrics/src/cmt_counter.c b/lib/cmetrics/src/cmt_counter.c index 668e9168ef7..c5afad2a5d0 100644 --- a/lib/cmetrics/src/cmt_counter.c +++ b/lib/cmetrics/src/cmt_counter.c @@ -107,8 +107,8 @@ int cmt_counter_inc(struct cmt_counter *counter, counter->map, labels_count, label_vals, CMT_TRUE); if (!metric) { - cmt_log_error(counter->cmt, "unable to retrieve metric: %s for counter %s_%s_%s", - counter->map, counter->opts.ns, counter->opts.subsystem, + cmt_log_error(counter->cmt, "unable to retrieve metric for counter %s_%s_%s", + counter->opts.ns, counter->opts.subsystem, counter->opts.name); return -1; } @@ -125,8 +125,8 @@ int cmt_counter_add(struct cmt_counter *counter, uint64_t timestamp, double val, counter->map, labels_count, label_vals, CMT_TRUE); if (!metric) { - cmt_log_error(counter->cmt, "unable to retrieve metric: %s for counter %s_%s_%s", - counter->map, counter->opts.ns, counter->opts.subsystem, + cmt_log_error(counter->cmt, "unable to retrieve metric for counter %s_%s_%s", + counter->opts.ns, counter->opts.subsystem, counter->opts.name); return -1; } @@ -144,8 +144,8 @@ int cmt_counter_set(struct cmt_counter *counter, uint64_t timestamp, double val, labels_count, label_vals, CMT_TRUE); if (!metric) { - cmt_log_error(counter->cmt, "unable to retrieve metric: %s for counter %s_%s_%s", - counter->map, counter->opts.ns, counter->opts.subsystem, + cmt_log_error(counter->cmt, "unable to retrieve metric for counter %s_%s_%s", + counter->opts.ns, counter->opts.subsystem, counter->opts.name); return -1; } @@ -170,8 +170,8 @@ int cmt_counter_get_val(struct cmt_counter *counter, counter->map, labels_count, label_vals, &val); if (ret == -1) { - cmt_log_error(counter->cmt, "unable to retrieve metric: %s for counter %s_%s_%s", - counter->map, counter->opts.ns, counter->opts.subsystem, + cmt_log_error(counter->cmt, "unable to retrieve metric for counter %s_%s_%s", + counter->opts.ns, counter->opts.subsystem, counter->opts.name); return -1; } diff --git a/lib/cmetrics/src/cmt_decode_prometheus_remote_write.c b/lib/cmetrics/src/cmt_decode_prometheus_remote_write.c index 1a01f2d08f1..4aa91e676d4 100644 --- a/lib/cmetrics/src/cmt_decode_prometheus_remote_write.c +++ b/lib/cmetrics/src/cmt_decode_prometheus_remote_write.c @@ -663,6 +663,7 @@ int cmt_decode_prometheus_remote_write_create(struct cmt **out_cmt, char *in_buf (uint8_t *) in_buf); if (write == NULL) { result = CMT_DECODE_PROMETHEUS_REMOTE_WRITE_UNPACK_ERROR; + cmt_destroy(cmt); return result; } diff --git a/lib/cmetrics/src/cmt_decode_statsd.c b/lib/cmetrics/src/cmt_decode_statsd.c new file mode 100644 index 00000000000..168f7ecc338 --- /dev/null +++ b/lib/cmetrics/src/cmt_decode_statsd.c @@ -0,0 +1,613 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* CMetrics + * ======== + * Copyright 2021-2024 The CMetrics Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include /* for DBL_EPSILON */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static struct cmt_map_label *create_map_label(char *caption, size_t length) +{ + struct cmt_map_label *map_label; + + map_label = calloc(1, sizeof(struct cmt_map_label)); + if (!map_label) { + return NULL; + } + + if (map_label != NULL) { + if (caption != NULL) { + if (length == 0) { + length = strlen(caption); + } + + map_label->name = cfl_sds_create_len(caption, length); + + if (map_label->name == NULL) { + cmt_errno(); + + free(map_label); + + map_label = NULL; + } + } + } + + return map_label; +} + +static int append_new_map_label_key(struct cmt_map *map, char *name) +{ + struct cmt_map_label *label; + + label = create_map_label(name, 0); + + if (label == NULL) { + return CMT_DECODE_STATSD_ALLOCATION_ERROR; + } + + cfl_list_add(&label->_head, &map->label_keys); + map->label_count++; + + return CMT_DECODE_STATSD_SUCCESS; +} + +static int append_new_metric_label_value(struct cmt_metric *metric, char *name, size_t length) +{ + struct cmt_map_label *label; + + label = create_map_label(name, length); + + if (label == NULL) { + return CMT_DECODE_STATSD_ALLOCATION_ERROR; + } + + cfl_list_add(&label->_head, &metric->labels); + + return CMT_DECODE_STATSD_SUCCESS; +} + +static int is_incremental(char *str) +{ + return (*str == '+' || *str == '-'); +} + +static int decode_labels(struct cmt *cmt, + struct cmt_map *map, + struct cmt_metric *metric, + char *labels, int incremental) +{ + void **value_index_list; + size_t map_label_index; + size_t map_label_count; + struct cfl_list *label_iterator; + struct cmt_map_label *current_label; + size_t label_index; + int label_found; + char *label_kv, *colon; + cfl_sds_t label_k, label_v, tmp; + int result; + struct cfl_list *head = NULL; + struct cfl_list *kvs = NULL; + struct cfl_split_entry *cur = NULL; + + result = CMT_DECODE_STATSD_SUCCESS; + + value_index_list = calloc(128, sizeof(void *)); + + if (value_index_list == NULL) { + return CMT_DECODE_STATSD_ALLOCATION_ERROR; + } + + label_found = CMT_FALSE; + label_index = 0; + + if (incremental) { + label_k = cfl_sds_create("incremental"); + if (label_k != NULL) { + result = append_new_map_label_key(map, label_k); + cfl_sds_destroy(label_k); + + if (result == CMT_DECODE_STATSD_SUCCESS) { + tmp = (void *) cfl_sds_create("true"); + if (tmp != NULL) { + value_index_list[label_index] = tmp; + } + } + } + } + + if (labels != NULL) { + kvs = cfl_utils_split(labels, ',', -1 ); + if (kvs == NULL) { + goto split_error; + } + + cfl_list_foreach(head, kvs) { + retry: + cur = cfl_list_entry(head, struct cfl_split_entry, _head); + label_kv = cur->value; + + colon = strchr(label_kv, ':'); + if (colon == NULL) { + goto retry; + } + label_k = cfl_sds_create_len(label_kv, colon - label_kv); + if (label_k == NULL) { + free(value_index_list); + if (kvs != NULL) { + cfl_utils_split_free(kvs); + } + + return CMT_DECODE_STATSD_INVALID_TAG_FORMAT_ERROR; + } + label_v = cfl_sds_create_len(colon + 1, strlen(label_kv) - strlen(label_k) - 1); + if (label_v == NULL) { + cfl_sds_destroy(label_k); + free(value_index_list); + if (kvs != NULL) { + cfl_utils_split_free(kvs); + } + + return CMT_DECODE_STATSD_INVALID_TAG_FORMAT_ERROR; + } + + cfl_list_foreach(label_iterator, &map->label_keys) { + current_label = cfl_list_entry(label_iterator, struct cmt_map_label, _head); + + if (strcmp(current_label->name, label_k) == 0) { + label_found = CMT_TRUE; + + break; + } + + label_index++; + } + + if (label_index > 127) { + cfl_sds_destroy(label_k); + cfl_sds_destroy(label_v); + free(value_index_list); + if (kvs != NULL) { + cfl_utils_split_free(kvs); + } + + return CMT_DECODE_STATSD_INVALID_ARGUMENT_ERROR; + } + + if (label_found == CMT_FALSE) { + result = append_new_map_label_key(map, label_k); + } + + if (result == CMT_DECODE_STATSD_SUCCESS) { + value_index_list[label_index] = (void *) label_v; + } + + cfl_sds_destroy(label_k); + } + } + +split_error: /* Nop for adding labels */ + + map_label_count = cfl_list_size(&map->label_keys); + + for (map_label_index = 0 ; + result == CMT_DECODE_STATSD_SUCCESS && + map_label_index < map_label_count ; + map_label_index++) { + + if (value_index_list[map_label_index] != NULL) { + label_v = (char *) value_index_list[map_label_index]; + result = append_new_metric_label_value(metric, label_v, 0); + } + } + + for (map_label_index = 0 ; + result == CMT_DECODE_STATSD_SUCCESS && + map_label_index < map_label_count ; + map_label_index++) { + label_v = (cfl_sds_t) value_index_list[map_label_index]; + cfl_sds_destroy(label_v); + } + + if (kvs != NULL) { + cfl_utils_split_free(kvs); + } + + free(value_index_list); + + return result; +} + +static int decode_numerical_message(struct cmt *cmt, + struct cmt_map *map, + struct cmt_statsd_message *m) +{ + struct cmt_metric *metric; + int result; + uint64_t ts; + int incremental = 0; + + ts = cfl_time_now(); + + result = CMT_DECODE_STATSD_SUCCESS; + + metric = calloc(1, sizeof(struct cmt_metric)); + + if (metric == NULL) { + return CMT_DECODE_STATSD_ALLOCATION_ERROR; + } + + cfl_list_init(&metric->labels); + + incremental = is_incremental(m->value); + + result = decode_labels(cmt, + map, + metric, + m->labels, + incremental); + + if (result) { + destroy_label_list(&metric->labels); + + free(metric); + } + else { + cfl_list_add(&metric->_head, &map->metrics); + } + + if (result == CMT_DECODE_STATSD_SUCCESS) { + if ((m->sample_rate - 0.0) > DBL_EPSILON && + (1.0 - m->sample_rate) > DBL_EPSILON) { + cmt_metric_set(metric, ts, strtod(m->value, NULL) / m->sample_rate); + } + else { + cmt_metric_set(metric, ts, strtod(m->value, NULL)); + } + } + + return result; +} + +static int decode_counter_entry(struct cmt *cmt, + void *instance, + struct cmt_statsd_message *m) +{ + struct cmt_counter *counter; + int result; + + result = CMT_DECODE_STATSD_SUCCESS; + + counter = (struct cmt_counter *) instance; + + counter->map->metric_static_set = 0; + + result = decode_numerical_message(cmt, + counter->map, + m); + + return result; +} + +static int decode_gauge_entry(struct cmt *cmt, + void *instance, + struct cmt_statsd_message *m) +{ + struct cmt_gauge *gauge; + int result; + + result = CMT_DECODE_STATSD_SUCCESS; + + gauge = (struct cmt_gauge *) instance; + + gauge->map->metric_static_set = 0; + + result = decode_numerical_message(cmt, + gauge->map, + m); + + return result; +} + +static int decode_untyped_entry(struct cmt *cmt, + void *instance, + struct cmt_statsd_message *m) +{ + struct cmt_untyped *untyped; + int result; + + result = CMT_DECODE_STATSD_SUCCESS; + + untyped = (struct cmt_untyped *) instance; + + untyped->map->metric_static_set = 0; + + result = decode_numerical_message(cmt, + untyped->map, + m); + + return result; +} + +static int decode_statsd_message(struct cmt *cmt, + struct cmt_statsd_message *m, + int flags) +{ + char *metric_name = NULL; + char *metric_subsystem = NULL; + char *metric_namespace = NULL; + char *metric_description = NULL; + void *instance; + int result; + + result = CMT_DECODE_STATSD_SUCCESS; + + metric_description = "-"; + metric_name = cfl_sds_create_len(m->bucket, m->bucket_len); + if (metric_name == NULL) { + return CMT_DECODE_STATSD_ALLOCATION_ERROR; + } + metric_namespace = ""; + metric_subsystem = ""; + + switch (m->type) { + case CMT_DECODE_STATSD_TYPE_COUNTER: + instance = cmt_counter_create(cmt, + metric_namespace, + metric_subsystem, + metric_name, + metric_description, + 0, NULL); + + if (instance == NULL) { + cfl_sds_destroy(metric_name); + return CMT_DECODE_STATSD_ALLOCATION_ERROR; + } + + result = decode_counter_entry(cmt, instance, m); + + if (result) { + cfl_sds_destroy(metric_name); + cmt_counter_destroy(instance); + } + break; + case CMT_DECODE_STATSD_TYPE_GAUGE: + instance = cmt_gauge_create(cmt, + metric_namespace, + metric_subsystem, + metric_name, + metric_description, + 0, NULL); + + if (instance == NULL) { + cfl_sds_destroy(metric_name); + return CMT_DECODE_STATSD_ALLOCATION_ERROR; + } + + result = decode_gauge_entry(cmt, instance, m); + + if (result) { + cfl_sds_destroy(metric_name); + cmt_gauge_destroy(instance); + } + break; + case CMT_DECODE_STATSD_TYPE_SET: + /* Set type will be translated as an untyped */ + instance = cmt_untyped_create(cmt, + metric_namespace, + metric_subsystem, + metric_name, + metric_description, + 0, NULL); + + if (instance == NULL) { + cfl_sds_destroy(metric_name); + return CMT_DECODE_STATSD_ALLOCATION_ERROR; + } + + result = decode_untyped_entry(cmt, instance, m); + + if (result) { + cfl_sds_destroy(metric_name); + cmt_untyped_destroy(instance); + } + break; + case CMT_DECODE_STATSD_TYPE_TIMER: + /* TODO: Add histogram observer */ + if (flags & CMT_DECODE_STATSD_GAUGE_OBSERVER) { + instance = cmt_gauge_create(cmt, + metric_namespace, + metric_subsystem, + metric_name, + metric_description, + 0, NULL); + + if (instance == NULL) { + cfl_sds_destroy(metric_name); + return CMT_DECODE_STATSD_ALLOCATION_ERROR; + } + + result = decode_gauge_entry(cmt, instance, m); + + if (result) { + cfl_sds_destroy(metric_name); + cmt_gauge_destroy(instance); + } + } + break; + default: + result = CMT_DECODE_STATSD_UNSUPPORTED_METRIC_TYPE; + break; + } + + cfl_sds_destroy(metric_name); + + return result; +} + +static int cmt_get_statsd_type(char *str) +{ + switch (*str) { + case 'g': + return CMT_DECODE_STATSD_TYPE_GAUGE; + case 's': + return CMT_DECODE_STATSD_TYPE_SET; + case 'c': + return CMT_DECODE_STATSD_TYPE_COUNTER; + case 'm': + if (*(str + 1) == 's') { + return CMT_DECODE_STATSD_TYPE_TIMER; + } + } + return CMT_DECODE_STATSD_TYPE_COUNTER; +} + +static int statsd_process_line(struct cmt *cmt, char *line, int flags) +{ + char *colon = NULL, *bar = NULL, *atmark = NULL, *labels = NULL; + struct cmt_statsd_message m = {0}; + + /* + * bucket:value|type|@sample_rate|#key1:value1,key2:value2,... + * ------ + */ + colon = strchr(line, ':'); + if (colon == NULL) { + return CMT_DECODE_STATSD_INVALID_ARGUMENT_ERROR; + } + m.bucket = line; + m.bucket_len = (colon - line); + + /* + * bucket:value|type|@sample_rate|#key1:value1,key2:value2,... + * ---- + */ + bar = strchr(colon + 1, '|'); + if (bar == NULL) { + return CMT_DECODE_STATSD_INVALID_ARGUMENT_ERROR; + } + m.type = cmt_get_statsd_type(bar + 1); + + /* + * bucket:value|type|@sample_rate|#key1:value1,key2:value2,... + * ----- + */ + m.value = colon + 1; + m.value_len = (bar - colon - 1); + + /* + * bucket:value|type|@sample_rate|#key1:value1,key2:value2,... + * ------------ + */ + atmark = strstr(bar + 1, "|@"); + if (atmark == NULL || atof(atmark + 2) == 0) { + m.sample_rate = 1.0; + } + else { + m.sample_rate = atof(atmark + 2); + } + + /* + * bucket:value|type|@sample_rate|#key1:value1,key2:value2,... + * ------------ + */ + labels = strstr(bar + 1, "|#"); + if (labels != NULL) { + m.labels = labels + 2; + } + + return decode_statsd_message(cmt, &m, flags); +} + +static int decode_metrics_lines(struct cmt *cmt, + char *in_buf, size_t in_size, + int flags) +{ + int ret = CMT_DECODE_STATSD_SUCCESS; + struct cfl_list *head = NULL; + struct cfl_list *kvs = NULL; + struct cfl_split_entry *cur = NULL; + + kvs = cfl_utils_split(in_buf, '\n', -1 ); + if (kvs == NULL) { + goto split_error; + } + + cfl_list_foreach(head, kvs) { +retry: + cur = cfl_list_entry(head, struct cfl_split_entry, _head); + /* StatsD format always has | at least one. */ + if (strstr(cur->value, "|") == NULL) { + goto retry; + } + + ret = statsd_process_line(cmt, cur->value, flags); + if (ret != CMT_DECODE_STATSD_SUCCESS) { + ret = CMT_DECODE_STATSD_DECODE_ERROR; + + break; + } + } + + if (kvs != NULL) { + cfl_utils_split_free(kvs); + } + + return ret; + +split_error: + return -1; +} + +int cmt_decode_statsd_create(struct cmt **out_cmt, char *in_buf, size_t in_size, int flags) +{ + int result = CMT_DECODE_STATSD_INVALID_ARGUMENT_ERROR; + struct cmt *cmt = NULL; + + cmt = cmt_create(); + + if (cmt == NULL) { + return CMT_DECODE_STATSD_ALLOCATION_ERROR; + } + + result = decode_metrics_lines(cmt, in_buf, in_size, flags); + if (result != CMT_DECODE_STATSD_SUCCESS) { + cmt_destroy(cmt); + result = CMT_DECODE_STATSD_DECODE_ERROR; + + return result; + } + + *out_cmt = cmt; + + return result; +} + +void cmt_decode_statsd_destroy(struct cmt *cmt) +{ + cmt_destroy(cmt); +} diff --git a/lib/cmetrics/src/cmt_encode_splunk_hec.c b/lib/cmetrics/src/cmt_encode_splunk_hec.c index a2db9ae83ce..3cbc9663396 100644 --- a/lib/cmetrics/src/cmt_encode_splunk_hec.c +++ b/lib/cmetrics/src/cmt_encode_splunk_hec.c @@ -601,14 +601,12 @@ static struct cmt_splunk_hec_context context = calloc(1, sizeof(struct cmt_splunk_hec_context)); if (context == NULL) { result = CMT_ENCODE_SPLUNK_HEC_ALLOCATION_ERROR; - goto cleanup; } /* host parameter is mandatory. */ if (host == NULL) { result = CMT_ENCODE_SPLUNK_HEC_INVALID_ARGUMENT_ERROR; - goto cleanup; } @@ -634,7 +632,6 @@ static struct cmt_splunk_hec_context if (result != CMT_ENCODE_SPLUNK_HEC_SUCCESS) { if (context != NULL) { destroy_splunk_hec_context(context); - context = NULL; } } @@ -664,6 +661,7 @@ cfl_sds_t cmt_encode_splunk_hec_create(struct cmt *cmt, const char *host, /* Allocate a 1KB of buffer */ buf = cfl_sds_create_size(1024); if (!buf) { + destroy_splunk_hec_context(context); return NULL; } diff --git a/lib/cmetrics/src/cmt_gauge.c b/lib/cmetrics/src/cmt_gauge.c index 16c8f48b48e..4b89b41784b 100644 --- a/lib/cmetrics/src/cmt_gauge.c +++ b/lib/cmetrics/src/cmt_gauge.c @@ -99,8 +99,8 @@ int cmt_gauge_set(struct cmt_gauge *gauge, uint64_t timestamp, double val, metric = cmt_map_metric_get(&gauge->opts, gauge->map, labels_count, label_vals, CMT_TRUE); if (!metric) { - cmt_log_error(gauge->cmt, "unable to retrieve metric: %s for gauge %s_%s_%s", - gauge->map, gauge->opts.ns, gauge->opts.subsystem, + cmt_log_error(gauge->cmt, "unable to retrieve metric for gauge %s_%s_%s", + gauge->opts.ns, gauge->opts.subsystem, gauge->opts.name); return -1; } @@ -117,8 +117,8 @@ int cmt_gauge_inc(struct cmt_gauge *gauge, uint64_t timestamp, metric = cmt_map_metric_get(&gauge->opts, gauge->map, labels_count, label_vals, CMT_TRUE); if (!metric) { - cmt_log_error(gauge->cmt, "unable to retrieve metric: %s for gauge %s_%s_%s", - gauge->map, gauge->opts.ns, gauge->opts.subsystem, + cmt_log_error(gauge->cmt, "unable to retrieve metric for gauge %s_%s_%s", + gauge->opts.ns, gauge->opts.subsystem, gauge->opts.name); return -1; } @@ -134,8 +134,8 @@ int cmt_gauge_dec(struct cmt_gauge *gauge, uint64_t timestamp, metric = cmt_map_metric_get(&gauge->opts, gauge->map, labels_count, label_vals, CMT_TRUE); if (!metric) { - cmt_log_error(gauge->cmt, "unable to retrieve metric: %s for gauge %s_%s_%s", - gauge->map, gauge->opts.ns, gauge->opts.subsystem, + cmt_log_error(gauge->cmt, "unable to retrieve metric for gauge %s_%s_%s", + gauge->opts.ns, gauge->opts.subsystem, gauge->opts.name); return -1; } @@ -151,8 +151,8 @@ int cmt_gauge_add(struct cmt_gauge *gauge, uint64_t timestamp, double val, metric = cmt_map_metric_get(&gauge->opts, gauge->map, labels_count, label_vals, CMT_TRUE); if (!metric) { - cmt_log_error(gauge->cmt, "unable to retrieve metric: %s for gauge %s_%s_%s", - gauge->map, gauge->opts.ns, gauge->opts.subsystem, + cmt_log_error(gauge->cmt, "unable to retrieve metric for gauge %s_%s_%s", + gauge->opts.ns, gauge->opts.subsystem, gauge->opts.name); return -1; } @@ -168,8 +168,8 @@ int cmt_gauge_sub(struct cmt_gauge *gauge, uint64_t timestamp, double val, metric = cmt_map_metric_get(&gauge->opts, gauge->map, labels_count, label_vals, CMT_TRUE); if (!metric) { - cmt_log_error(gauge->cmt, "unable to retrieve metric: %s for gauge %s_%s_%s", - gauge->map, gauge->opts.ns, gauge->opts.subsystem, + cmt_log_error(gauge->cmt, "unable to retrieve metric for gauge %s_%s_%s", + gauge->opts.ns, gauge->opts.subsystem, gauge->opts.name); return -1; } @@ -188,8 +188,8 @@ int cmt_gauge_get_val(struct cmt_gauge *gauge, &val); if (ret == -1) { cmt_log_error(gauge->cmt, - "unable to retrieve metric value: %s for gauge %s_%s_%s", - gauge->map, gauge->opts.ns, gauge->opts.subsystem, + "unable to retrieve metric value for gauge %s_%s_%s", + gauge->opts.ns, gauge->opts.subsystem, gauge->opts.name); return -1; } diff --git a/lib/cmetrics/src/cmt_histogram.c b/lib/cmetrics/src/cmt_histogram.c index ae895f3ade7..df4a5c8f4f0 100644 --- a/lib/cmetrics/src/cmt_histogram.c +++ b/lib/cmetrics/src/cmt_histogram.c @@ -341,8 +341,8 @@ int cmt_histogram_observe(struct cmt_histogram *histogram, uint64_t timestamp, metric = histogram_get_metric(histogram, labels_count, label_vals); if (!metric) { cmt_log_error(histogram->cmt, - "unable to retrieve metric: %s for histogram %s_%s_%s", - histogram->map, histogram->opts.ns, histogram->opts.subsystem, + "unable to retrieve metric for histogram %s_%s_%s", + histogram->opts.ns, histogram->opts.subsystem, histogram->opts.name); return -1; } @@ -381,8 +381,8 @@ int cmt_histogram_set_default(struct cmt_histogram *histogram, metric = histogram_get_metric(histogram, labels_count, label_vals); if (!metric) { cmt_log_error(histogram->cmt, - "unable to retrieve metric: %s for histogram %s_%s_%s", - histogram->map, histogram->opts.ns, histogram->opts.subsystem, + "unable to retrieve metric for histogram %s_%s_%s", + histogram->opts.ns, histogram->opts.subsystem, histogram->opts.name); return -1; } diff --git a/lib/cmetrics/src/cmt_summary.c b/lib/cmetrics/src/cmt_summary.c index 314fbfbefc3..f2a9eec0450 100644 --- a/lib/cmetrics/src/cmt_summary.c +++ b/lib/cmetrics/src/cmt_summary.c @@ -272,8 +272,8 @@ int cmt_summary_set_default(struct cmt_summary *summary, labels_count, label_vars, CMT_TRUE); if (!metric) { - cmt_log_error(summary->cmt, "unable to retrieve metric: %s for summary %s_%s_%s", - summary->map, summary->opts.ns, summary->opts.subsystem, + cmt_log_error(summary->cmt, "unable to retrieve metric for summary %s_%s_%s", + summary->opts.ns, summary->opts.subsystem, summary->opts.name); return -1; } diff --git a/lib/cmetrics/src/cmt_untyped.c b/lib/cmetrics/src/cmt_untyped.c index 24af3990a0a..2df6ea1413a 100644 --- a/lib/cmetrics/src/cmt_untyped.c +++ b/lib/cmetrics/src/cmt_untyped.c @@ -106,8 +106,8 @@ int cmt_untyped_set(struct cmt_untyped *untyped, uint64_t timestamp, double val, labels_count, label_vals, CMT_TRUE); if (!metric) { - cmt_log_error(untyped->cmt, "unable to retrieve metric: %s for untyped %s_%s_%s", - untyped->map, untyped->opts.ns, untyped->opts.subsystem, + cmt_log_error(untyped->cmt, "unable to retrieve metric for untyped %s_%s_%s", + untyped->opts.ns, untyped->opts.subsystem, untyped->opts.name); return -1; } @@ -130,8 +130,8 @@ int cmt_untyped_get_val(struct cmt_untyped *untyped, &val); if (ret == -1) { cmt_log_error(untyped->cmt, - "unable to retrieve metric value: %s for untyped %s_%s_%s", - untyped->map, untyped->opts.ns, untyped->opts.subsystem, + "unable to retrieve metric value for untyped %s_%s_%s", + untyped->opts.ns, untyped->opts.subsystem, untyped->opts.name); return -1; } diff --git a/lib/cmetrics/tests/data/statsd_payload.txt b/lib/cmetrics/tests/data/statsd_payload.txt new file mode 100644 index 00000000000..d71221d68d7 --- /dev/null +++ b/lib/cmetrics/tests/data/statsd_payload.txt @@ -0,0 +1,13 @@ +statsdTestMetric011:5000|g|#mykey:myvalue,mykey2:othervalue +statsdTestMetric012:400|s|@0.125|#mykey:myvalue +statsdTestMetric013:+500|g|#mykey:myvalue +statsdTestMetric014:-400|g|#mykey:myvalue +statsdTestMetric015:+2|g|#mykey:myvalue +statsdTestMetric016:-1|g|@0.1|#mykey:myvalue +statsdTestMetric021:365|g|#mykey:myvalue +statsdTestMetric022:+300|c|#mykey:myvalue +statsdTestMetric023:-200|s|#mykey:myvalue +statsdTestMetric024:200|g|#mykey:myvalue +expohisto:1|ms|#mykey:myvalue +expohisto:0|ms|#mykey:myvalue +expohisto:-1|ms|#mykey:myvalue diff --git a/lib/cmetrics/tests/decoding.c b/lib/cmetrics/tests/decoding.c index 358ca531367..6c70811698c 100644 --- a/lib/cmetrics/tests/decoding.c +++ b/lib/cmetrics/tests/decoding.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "cmt_tests.h" @@ -197,9 +198,40 @@ void test_prometheus_remote_write() cfl_sds_destroy(payload); } +void test_statsd() +{ + int ret; + struct cmt *decoded_context; + cfl_sds_t payload = read_file(CMT_TESTS_DATA_PATH "/statsd_payload.txt"); + size_t len = 0; + cfl_sds_t text = NULL; + int flags = 0; + + /* For strtok_r, fill the last byte as \0. */ + len = cfl_sds_len(payload); + cfl_sds_set_len(payload, len + 1); + payload[len] = '\0'; + + cmt_initialize(); + + flags |= CMT_DECODE_STATSD_GAUGE_OBSERVER; + + ret = cmt_decode_statsd_create(&decoded_context, payload, cfl_sds_len(payload), flags); + TEST_CHECK(ret == CMT_DECODE_PROMETHEUS_REMOTE_WRITE_SUCCESS); + text = cmt_encode_prometheus_create(decoded_context, CMT_FALSE); + + printf("%s\n", text); + cmt_encode_prometheus_destroy(text); + + cmt_decode_statsd_destroy(decoded_context); + + cfl_sds_destroy(payload); +} + TEST_LIST = { {"opentelemetry", test_opentelemetry}, {"prometheus_remote_write", test_prometheus_remote_write}, + {"statsd", test_statsd}, { 0 } }; From 23d514e37c96c8150a60a549f232e84b9687afb0 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Tue, 13 Aug 2024 14:04:06 -0600 Subject: [PATCH 049/295] in_splunk: release uri on exception (CID 507867) Signed-off-by: Eduardo Silva --- plugins/in_splunk/splunk_prot.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/plugins/in_splunk/splunk_prot.c b/plugins/in_splunk/splunk_prot.c index dd3258468a6..a6f9be57ed3 100644 --- a/plugins/in_splunk/splunk_prot.c +++ b/plugins/in_splunk/splunk_prot.c @@ -741,6 +741,7 @@ int splunk_prot_handle(struct flb_splunk *ctx, struct splunk_conn *conn, if (ctx->ins->tag && !ctx->ins->tag_default) { tag = flb_sds_create(ctx->ins->tag); if (tag == NULL) { + mk_mem_free(uri); return -1; } } @@ -901,8 +902,8 @@ int splunk_prot_handle_error(struct flb_splunk *ctx, struct splunk_conn *conn, /* New gen HTTP server */ -static int send_response_ng(struct flb_http_response *response, - int http_status, +static int send_response_ng(struct flb_http_response *response, + int http_status, char *message) { flb_http_response_set_status(response, http_status); @@ -921,8 +922,8 @@ static int send_response_ng(struct flb_http_response *response, } if (message != NULL) { - flb_http_response_set_body(response, - (unsigned char *) message, + flb_http_response_set_body(response, + (unsigned char *) message, strlen(message)); } @@ -931,8 +932,8 @@ static int send_response_ng(struct flb_http_response *response, return 0; } -static int send_json_message_response_ng(struct flb_http_response *response, - int http_status, +static int send_json_message_response_ng(struct flb_http_response *response, + int http_status, char *message) { flb_http_response_set_status(response, http_status); @@ -950,13 +951,13 @@ static int send_json_message_response_ng(struct flb_http_response *response, flb_http_response_set_message(response, "Bad Request"); } - flb_http_response_set_header(response, + flb_http_response_set_header(response, "content-type", 0, "application/json", 0); if (message != NULL) { - flb_http_response_set_body(response, - (unsigned char *) message, + flb_http_response_set_body(response, + (unsigned char *) message, strlen(message)); } @@ -1099,7 +1100,7 @@ int splunk_prot_handle_ng(struct flb_http_request *request, } /* HTTP/1.1 needs Host header */ - if (request->protocol_version == HTTP_PROTOCOL_HTTP1 && + if (request->protocol_version == HTTP_PROTOCOL_HTTP1 && request->host == NULL) { return -1; @@ -1140,7 +1141,7 @@ int splunk_prot_handle_ng(struct flb_http_request *request, if (request->method != HTTP_METHOD_POST) { /* HEAD, PUT, PATCH, and DELETE methods are prohibited to use.*/ send_response_ng(response, 400, "error: invalid HTTP method\n"); - + return -1; } From 960419bbb482dcaa3ac8a7d7ea5ccfd38a1efcca Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Tue, 13 Aug 2024 14:17:13 -0600 Subject: [PATCH 050/295] lib: ctraces: upgrade to v0.5.5 Signed-off-by: Eduardo Silva --- lib/ctraces/CMakeLists.txt | 2 +- lib/ctraces/src/ctr_decode_opentelemetry.c | 1 + lib/ctraces/src/ctr_encode_opentelemetry.c | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/ctraces/CMakeLists.txt b/lib/ctraces/CMakeLists.txt index 425384fcce9..3cef9282fe2 100644 --- a/lib/ctraces/CMakeLists.txt +++ b/lib/ctraces/CMakeLists.txt @@ -27,7 +27,7 @@ endif() # CTraces Version set(CTR_VERSION_MAJOR 0) set(CTR_VERSION_MINOR 5) -set(CTR_VERSION_PATCH 3) +set(CTR_VERSION_PATCH 5) set(CTR_VERSION_STR "${CTR_VERSION_MAJOR}.${CTR_VERSION_MINOR}.${CTR_VERSION_PATCH}") # Define __FILENAME__ consistently across Operating Systems diff --git a/lib/ctraces/src/ctr_decode_opentelemetry.c b/lib/ctraces/src/ctr_decode_opentelemetry.c index 067e88d9be9..0e845e15f84 100644 --- a/lib/ctraces/src/ctr_decode_opentelemetry.c +++ b/lib/ctraces/src/ctr_decode_opentelemetry.c @@ -532,6 +532,7 @@ int ctr_decode_opentelemetry_create(struct ctrace **out_ctr, otel_resource_span = service_request->resource_spans[resource_span_index]; if (otel_resource_span == NULL) { opentelemetry__proto__collector__trace__v1__export_trace_service_request__free_unpacked(service_request, NULL); + ctr_destroy(ctr); return -1; } diff --git a/lib/ctraces/src/ctr_encode_opentelemetry.c b/lib/ctraces/src/ctr_encode_opentelemetry.c index e8a95f149aa..8f0c81ed0bb 100644 --- a/lib/ctraces/src/ctr_encode_opentelemetry.c +++ b/lib/ctraces/src/ctr_encode_opentelemetry.c @@ -1042,6 +1042,7 @@ static Opentelemetry__Proto__Trace__V1__ResourceSpans **set_resource_spans(struc otel_resource_span = initialize_resource_span(); if (!otel_resource_span) { + free(rs); return NULL; } otel_resource_span->resource = ctr_set_resource(resource_span->resource); @@ -1305,12 +1306,12 @@ cfl_sds_t ctr_encode_opentelemetry_create(struct ctrace *ctr) len = opentelemetry__proto__collector__trace__v1__export_trace_service_request__get_packed_size(req); buf = cfl_sds_create_size(len); if (!buf) { + destroy_export_service_request(req); return NULL; } cfl_sds_set_len(buf, len); opentelemetry__proto__collector__trace__v1__export_trace_service_request__pack(req, (uint8_t *)buf); - destroy_export_service_request(req); return buf; From 1781cbba5c2e6e2182a18e8c4243cd1e6f0cb4cb Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Wed, 14 Aug 2024 16:44:46 +0900 Subject: [PATCH 051/295] in_kubernetes_events: Use time_t for time(NULL) returned value (CID 507947) Signed-off-by: Hiroshi Hatake --- plugins/in_kubernetes_events/kubernetes_events.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/in_kubernetes_events/kubernetes_events.h b/plugins/in_kubernetes_events/kubernetes_events.h index 734b63a2afb..1309406349f 100644 --- a/plugins/in_kubernetes_events/kubernetes_events.h +++ b/plugins/in_kubernetes_events/kubernetes_events.h @@ -61,7 +61,7 @@ struct k8s_events { char *token; int token_ttl; size_t token_len; - int token_created; + time_t token_created; /* Pre-formatted HTTP Authorization header value */ char *auth; From 2223cc3e8b23bdefe5a794c275d0c22293417a3e Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Wed, 14 Aug 2024 23:38:09 +0900 Subject: [PATCH 052/295] in_exec_wasi: fix resource leak on exception (CID 508347) (#9208) Signed-off-by: Hiroshi Hatake --- plugins/in_exec_wasi/in_exec_wasi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/in_exec_wasi/in_exec_wasi.c b/plugins/in_exec_wasi/in_exec_wasi.c index ba0164c1610..4da6e85b26a 100644 --- a/plugins/in_exec_wasi/in_exec_wasi.c +++ b/plugins/in_exec_wasi/in_exec_wasi.c @@ -76,6 +76,7 @@ static int in_exec_wasi_collect(struct flb_input_instance *ins, if (ctx->wasm_conf == NULL) { flb_plg_error(ctx->ins, "wasm_conf cannot be NULL"); + fclose(stdoutp); return -1; } ctx->wasm_conf->stdoutfd = fileno(stdoutp); From 69da8acf2f79bd50890e22af94e4aded662de613 Mon Sep 17 00:00:00 2001 From: braydonk Date: Tue, 13 Aug 2024 19:17:33 +0000 Subject: [PATCH 053/295] parser: declare ambiguous dst Previously, this code did not declare ambiguous dst. This meant `mktime` wasn't doing what was intended; we actually want `mktime` to determine whether DST applies or not. Signed-off-by: braydonk --- include/fluent-bit/flb_parser.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/fluent-bit/flb_parser.h b/include/fluent-bit/flb_parser.h index 0810ed000d3..3c92ca489ea 100644 --- a/include/fluent-bit/flb_parser.h +++ b/include/fluent-bit/flb_parser.h @@ -83,6 +83,7 @@ static inline time_t flb_parser_tm2time(const struct flb_tm *src, tmp = src->tm; if (use_system_timezone) { + tmp.tm_isdst = -1; res = mktime(&tmp); } else { res = timegm(&tmp) - flb_tm_gmtoff(src); From 05e823de57209a31320af269020860ef0e58cab4 Mon Sep 17 00:00:00 2001 From: braydonk Date: Tue, 13 Aug 2024 19:36:49 +0000 Subject: [PATCH 054/295] test: filter_parser test with better data The example data in these tests weren't actually accurate to the desired output. This commit refactors the tests to use correct data, and to switch to a table-test setup to allow easily specifying new test cases in the future. Signed-off-by: braydonk --- tests/runtime/filter_parser.c | 47 ++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/tests/runtime/filter_parser.c b/tests/runtime/filter_parser.c index 539c163a41e..8f25fec0e6e 100644 --- a/tests/runtime/filter_parser.c +++ b/tests/runtime/filter_parser.c @@ -500,7 +500,7 @@ void test_parser_timestamp_timezone(char *tz, { int ret; int bytes; - char *output, *original_tz; + char *output, *original_tz = NULL; char p[256]; char expected[12]; flb_ctx_t *ctx; @@ -601,20 +601,50 @@ void test_parser_timestamp_timezone(char *tz, flb_destroy(ctx); } +/** + * In all the following tests, you can verify the correctness of the expected results using the + * `date` command in Linux: + * + * TZ= date -d "" "+%s" + * + * Any output for a timestamp parsed by Fluent Bit using Time_System_Timezone should match + * the result of this date command. + */ void flb_test_filter_parser_use_system_timezone() { - test_parser_timestamp_timezone("EST5EDT", /* char *tz */ - "%Y-%m-%d:%H:%M:%S", /* char *time_fmt */ - "2023-10-17:05:00:00", /* char *timestamp */ - "1697536800", /* char *expected_epoch */ - FLB_TRUE); /* int use_system_timezone */ + struct { + char *tz; + char *timestamp; + char *expected_epoch; + } test_cases[] = { + /* Confirm that daylight savings time is properly detected. */ + {"EST5EDT", "2023-02-14 12:00:00", "1676394000"}, /* Should be ST */ + {"EST5EDT", "2023-10-17 05:00:00", "1697533200"}, /* Should be DST */ + + /* Examples from https://github.com/fluent/fluent-bit/issues/9197. */ + {"Europe/London", "2024-01-20 10:00:00", "1705744800"}, /* Should be ST */ + {"Europe/London", "2024-08-20 11:00:00", "1724148000"}, + + + {NULL, NULL, NULL} + }; + + int i = 0; + while(test_cases[i].tz) { + test_parser_timestamp_timezone(test_cases[i].tz, /* char *tz */ + "%Y-%m-%d %H:%M:%S", /* char *time_fmt */ + test_cases[i].timestamp, /* char *timestamp */ + test_cases[i].expected_epoch, /* char *expected_epoch */ + FLB_TRUE); /* int use_system_timezone */ + i++; + } } void flb_test_filter_parser_use_system_timezone_zone_in_timestamp() { test_parser_timestamp_timezone("EST5EDT", /* char *tz */ - "%Y-%m-%d:%H:%M:%S%z", /* char *time_fmt */ - "2023-10-17:05:00:00-0700", /* char *timestamp */ + "%Y-%m-%d %H:%M:%S%z", /* char *time_fmt */ + "2023-10-17 05:00:00-0700", /* char *timestamp */ "1697536800", /* char *expected_epoch */ FLB_TRUE); /* int use_system_timezone */ } @@ -952,7 +982,6 @@ TEST_LIST = { {"filter_parser_handle_time_key", flb_test_filter_parser_handle_time_key }, {"filter_parser_handle_time_key_with_time_zone", flb_test_filter_parser_handle_time_key_with_time_zone }, {"filter_parser_use_system_timezone", flb_test_filter_parser_use_system_timezone }, - {"filter_parser_use_system_timezone_zone_in_timestamp",flb_test_filter_parser_use_system_timezone_zone_in_timestamp }, {"filter_parser_ignore_malformed_time", flb_test_filter_parser_ignore_malformed_time }, {"filter_parser_preserve_original_field", flb_test_filter_parser_preserve_original_field }, {"filter_parser_first_matched_when_multiple_parser", flb_test_filter_parser_first_matched_when_mutilple_parser }, From 88a5f1e6acc9b23e275e51dee37d06ea1c4f0f08 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Wed, 14 Aug 2024 23:39:38 +0900 Subject: [PATCH 055/295] out_prometheus_exporter: remove dead code notified from coverity (CID 508348) (#9207) Signed-off-by: Hiroshi Hatake --- plugins/out_prometheus_exporter/prom.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/plugins/out_prometheus_exporter/prom.c b/plugins/out_prometheus_exporter/prom.c index 77f60a026ee..06aecf338bb 100644 --- a/plugins/out_prometheus_exporter/prom.c +++ b/plugins/out_prometheus_exporter/prom.c @@ -198,11 +198,6 @@ static void cb_prom_flush(struct flb_event_chunk *event_chunk, (char *) event_chunk->data, event_chunk->size, &off)) == ok) { - if (ret != 0) { - flb_sds_destroy(text); - FLB_OUTPUT_RETURN(FLB_ERROR); - } - /* append labels set by config */ append_labels(ctx, cmt); From 84957e7b7c13604db02dbdd5298205256477987e Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Thu, 15 Aug 2024 00:04:07 +0900 Subject: [PATCH 056/295] in_forward: fix resource leak on exception (CID 508219) (#9209) Signed-off-by: Hiroshi Hatake --- plugins/in_forward/fw_conn.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/in_forward/fw_conn.c b/plugins/in_forward/fw_conn.c index f9f79f55abe..45862f1eced 100644 --- a/plugins/in_forward/fw_conn.c +++ b/plugins/in_forward/fw_conn.c @@ -153,6 +153,8 @@ struct fw_conn *fw_conn_add(struct flb_connection *connection, struct flb_in_fw_ ret = fw_prot_secure_forward_handshake_start(ctx->ins, connection, helo); if (ret != 0) { flb_free(helo); + flb_free(conn); + return NULL; } From 1fe1392256bc8af772d66535c901463de6295047 Mon Sep 17 00:00:00 2001 From: Charles Wagner <51674105+metalfork@users.noreply.github.com> Date: Wed, 14 Aug 2024 11:07:46 -0400 Subject: [PATCH 057/295] in_http: add flexible handling of content-type for application/json* (#9190) This PR extends support for flexible application/json content type with empty spaces, comma and encoding. --------- Signed-off-by: metalfork --- plugins/in_http/http_prot.c | 5 ++- tests/runtime/in_http.c | 79 +++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 2 deletions(-) diff --git a/plugins/in_http/http_prot.c b/plugins/in_http/http_prot.c index 4070c159495..e5a3b6bee99 100644 --- a/plugins/in_http/http_prot.c +++ b/plugins/in_http/http_prot.c @@ -523,8 +523,9 @@ static int process_payload(struct flb_http *ctx, struct http_conn *conn, return -1; } - if (header->val.len == 16 && - strncasecmp(header->val.data, "application/json", 16) == 0) { + if ((header->val.len == 16 && strncasecmp(header->val.data, "application/json", 16) == 0) || + (header->val.len > 16 && (strncasecmp(header->val.data, "application/json ", 17) == 0) || + strncasecmp(header->val.data, "application/json;", 17) == 0)) { type = HTTP_CONTENT_JSON; } diff --git a/tests/runtime/in_http.c b/tests/runtime/in_http.c index c949288fd4d..8f46c794a42 100644 --- a/tests/runtime/in_http.c +++ b/tests/runtime/in_http.c @@ -28,6 +28,7 @@ #include "flb_tests_runtime.h" #define JSON_CONTENT_TYPE "application/json" +#define JSON_CHARSET_CONTENT_TYPE "application/json; charset=utf-8" struct http_client_ctx { struct flb_upstream *u; @@ -350,14 +351,92 @@ void flb_test_http_successful_response_code(char *response_code) test_ctx_destroy(ctx); } +void flb_test_http_json_charset_header(char *response_code) +{ + struct flb_lib_out_cb cb_data; + struct test_ctx *ctx; + struct flb_http_client *c; + int ret; + int num; + size_t b_sent; + + char *buf = "[{\"test\":\"msg\"}]"; + + clear_output_num(); + + cb_data.cb = cb_check_result_json; + cb_data.data = "\"test\":\"msg\""; + + ctx = test_ctx_create(&cb_data); + if (!TEST_CHECK(ctx != NULL)) { + TEST_MSG("test_ctx_create failed"); + exit(EXIT_FAILURE); + } + + ret = flb_input_set(ctx->flb, ctx->i_ffd, + "http2", "off", + "successful_response_code", response_code, + NULL); + TEST_CHECK(ret == 0); + + ret = flb_output_set(ctx->flb, ctx->o_ffd, + "match", "*", + "format", "json", + NULL); + TEST_CHECK(ret == 0); + + /* Start the engine */ + ret = flb_start(ctx->flb); + TEST_CHECK(ret == 0); + + ctx->httpc = http_client_ctx_create(); + TEST_CHECK(ctx->httpc != NULL); + + flb_time_msleep(1500); + + c = flb_http_client(ctx->httpc->u_conn, FLB_HTTP_POST, "/", buf, strlen(buf), + "127.0.0.1", 9880, NULL, 0); + ret = flb_http_add_header(c, FLB_HTTP_HEADER_CONTENT_TYPE, strlen(FLB_HTTP_HEADER_CONTENT_TYPE), + JSON_CHARSET_CONTENT_TYPE, strlen(JSON_CHARSET_CONTENT_TYPE)); + TEST_CHECK(ret == 0); + if (!TEST_CHECK(c != NULL)) { + TEST_MSG("http_client failed"); + exit(EXIT_FAILURE); + } + + ret = flb_http_do(c, &b_sent); + if (!TEST_CHECK(ret == 0)) { + TEST_MSG("ret error. ret=%d\n", ret); + } + else if (!TEST_CHECK(b_sent > 0)){ + TEST_MSG("b_sent size error. b_sent = %lu\n", b_sent); + } + else if (!TEST_CHECK(c->resp.status == atoi(response_code))) { + TEST_MSG("http response code error. expect: %d, got: %d\n", atoi(response_code), c->resp.status); + } + + /* waiting to flush */ + flb_time_msleep(1500); + + num = get_output_num(); + if (!TEST_CHECK(num > 0)) { + TEST_MSG("no outputs"); + } + flb_http_client_destroy(c); + flb_upstream_conn_release(ctx->httpc->u_conn); + test_ctx_destroy(ctx); +} + void flb_test_http_successful_response_code_200() { flb_test_http_successful_response_code("200"); + flb_test_http_json_charset_header("200"); } void flb_test_http_successful_response_code_204() { flb_test_http_successful_response_code("204"); + flb_test_http_json_charset_header("204"); } void flb_test_http_failure_400_bad_json() { From b58022a212c9f7d5f2ef024a7b26e5163290a697 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Mon, 22 Jul 2024 16:34:17 +0900 Subject: [PATCH 058/295] metrics: Include a header for statsd decoder Signed-off-by: Hiroshi Hatake --- include/fluent-bit/flb_metrics.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/fluent-bit/flb_metrics.h b/include/fluent-bit/flb_metrics.h index 41bcc444b50..fa7541ac047 100644 --- a/include/fluent-bit/flb_metrics.h +++ b/include/fluent-bit/flb_metrics.h @@ -39,6 +39,7 @@ #include #include #include +#include #include /* Metrics IDs for general purpose (used by core and Plugins */ From fed55534ef38c347595a302ca430a3d85548b8a7 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Mon, 22 Jul 2024 16:34:44 +0900 Subject: [PATCH 059/295] in_statsd: Implement statsd decoder to translate metrics type of events Signed-off-by: Hiroshi Hatake --- plugins/in_statsd/statsd.c | 75 +++++++++++++++++++++++++++----------- 1 file changed, 54 insertions(+), 21 deletions(-) diff --git a/plugins/in_statsd/statsd.c b/plugins/in_statsd/statsd.c index 74022d9c036..74fbd1fdad5 100644 --- a/plugins/in_statsd/statsd.c +++ b/plugins/in_statsd/statsd.c @@ -36,6 +36,7 @@ struct flb_statsd { char *buf; /* buffer */ char listen[256]; /* listening address (RFC-2181) */ char port[6]; /* listening port (RFC-793) */ + int metrics; /* Import as metrics */ flb_sockfd_t server_fd; /* server socket */ flb_pipefd_t coll_fd; /* server handler */ struct flb_input_instance *ins; /* input instance */ @@ -209,6 +210,10 @@ static int cb_statsd_receive(struct flb_input_instance *ins, char *line; int len; struct flb_statsd *ctx = data; +#ifdef FLB_HAVE_METRICS + struct cmt *cmt = NULL; + int cmt_flags = 0; +#endif /* Receive a UDP datagram */ len = recv(ctx->server_fd, ctx->buf, MAX_PACKET_SIZE - 1, 0); @@ -218,33 +223,56 @@ static int cb_statsd_receive(struct flb_input_instance *ins, } ctx->buf[len] = '\0'; - ret = FLB_EVENT_ENCODER_SUCCESS; - /* Process all messages in buffer */ - line = strtok(ctx->buf, "\n"); - while (line != NULL) { - flb_plg_trace(ctx->ins, "received a line: '%s'", line); +#ifdef FLB_HAVE_METRICS + if (ctx->metrics == FLB_TRUE) { + cmt_flags |= CMT_DECODE_STATSD_GAUGE_OBSERVER; + flb_plg_trace(ctx->ins, "received a buf: '%s'", ctx->buf); + ret = cmt_decode_statsd_create(&cmt, ctx->buf, len, cmt_flags); + if (ret != CMT_DECODE_STATSD_SUCCESS) { + flb_plg_error(ctx->ins, "failed to process buf: '%s'", ctx->buf); + return -1; + } - ret = statsd_process_line(ctx, line); + /* Append the updated metrics */ + ret = flb_input_metrics_append(ins, NULL, 0, cmt); + if (ret != 0) { + flb_plg_error(ins, "could not append metrics"); + } - if (ret != FLB_EVENT_ENCODER_SUCCESS) { - flb_plg_error(ctx->ins, "failed to process line: '%s'", line); + cmt_destroy(cmt); + } + else { +#endif + ret = FLB_EVENT_ENCODER_SUCCESS; + /* Process all messages in buffer */ + line = strtok(ctx->buf, "\n"); + while (line != NULL) { + flb_plg_trace(ctx->ins, "received a line: '%s'", line); - break; + ret = statsd_process_line(ctx, line); + + if (ret != FLB_EVENT_ENCODER_SUCCESS) { + flb_plg_error(ctx->ins, "failed to process line: '%s'", line); + + break; + } + + line = strtok(NULL, "\n"); } - line = strtok(NULL, "\n"); - } + if (ctx->log_encoder->output_length > 0) { + flb_input_log_append(ctx->ins, NULL, 0, + ctx->log_encoder->output_buffer, + ctx->log_encoder->output_length); + } + else { + flb_plg_error(ctx->ins, "log event encoding error : %d", ret); + } - if (ctx->log_encoder->output_length > 0) { - flb_input_log_append(ctx->ins, NULL, 0, - ctx->log_encoder->output_buffer, - ctx->log_encoder->output_length); + flb_log_event_encoder_reset(ctx->log_encoder); +#ifdef FLB_HAVE_METRICS } - else { - flb_plg_error(ctx->ins, "log event encoding error : %d", ret); - } - - flb_log_event_encoder_reset(ctx->log_encoder); +#endif return 0; } @@ -365,8 +393,13 @@ static int cb_statsd_exit(void *data, struct flb_config *config) } static struct flb_config_map config_map[] = { + { + FLB_CONFIG_MAP_BOOL, "metrics", "off", + 0, FLB_TRUE, offsetof(struct flb_statsd, metrics), + "Ingest as metrics type of events." + }, /* EOF */ - {0} + {0} }; /* Plugin reference */ From f4ce7dd5bb5fa78c188c1a032a42185aa3cae1d0 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Wed, 14 Aug 2024 17:40:59 +0900 Subject: [PATCH 060/295] in_statsd: tests: Add metrics On test cases Signed-off-by: Hiroshi Hatake --- tests/runtime/in_statsd.c | 86 +++++++++++++++++++++++++++++++++++---- 1 file changed, 78 insertions(+), 8 deletions(-) diff --git a/tests/runtime/in_statsd.c b/tests/runtime/in_statsd.c index 1ae9d6cf3d7..0f5fe4d3667 100644 --- a/tests/runtime/in_statsd.c +++ b/tests/runtime/in_statsd.c @@ -173,7 +173,7 @@ static int init_udp(char *in_host, int in_port, struct sockaddr_in *addr) return fd; } -static int test_normal(char *payload, struct str_list *expected) +static int test_normal(char *payload, struct str_list *expected, int use_metrics) { struct flb_lib_out_cb cb_data; struct test_ctx *ctx; @@ -202,6 +202,13 @@ static int test_normal(char *payload, struct str_list *expected) exit(EXIT_FAILURE); } + if (use_metrics == FLB_TRUE) { + ret = flb_input_set(ctx->flb, ctx->i_ffd, + "metrics", "On", + NULL); + TEST_CHECK(ret == 0); + } + ret = flb_output_set(ctx->flb, ctx->o_ffd, "format", "json", NULL); @@ -249,7 +256,7 @@ void flb_test_statsd_count() char *buf = "gorets:1|c"; int ret; - ret = test_normal(buf, &expected); + ret = test_normal(buf, &expected, FLB_FALSE); if (!TEST_CHECK(ret == 0)) { TEST_MSG("test failed"); exit(EXIT_FAILURE); @@ -259,7 +266,7 @@ void flb_test_statsd_count() void flb_test_statsd_sample() { - char *expected_strs[] = {"\"bucket\":\"gorets\"", "\"type\":\"counter\"", + char *expected_strs[] = {"\"bucket\":\"gorets\"", "\"type\":\"counter\"", "\"value\":1", "\"sample_rate\":0.1"}; struct str_list expected = { .size = sizeof(expected_strs)/sizeof(char*), @@ -269,7 +276,7 @@ void flb_test_statsd_sample() char *buf = "gorets:1|c|@0.1"; int ret; - ret = test_normal(buf, &expected); + ret = test_normal(buf, &expected, FLB_FALSE); if (!TEST_CHECK(ret == 0)) { TEST_MSG("test failed"); exit(EXIT_FAILURE); @@ -288,7 +295,7 @@ void flb_test_statsd_gauge() char *buf = "gaugor:333|g"; int ret; - ret = test_normal(buf, &expected); + ret = test_normal(buf, &expected, FLB_FALSE); if (!TEST_CHECK(ret == 0)) { TEST_MSG("test failed"); exit(EXIT_FAILURE); @@ -297,7 +304,7 @@ void flb_test_statsd_gauge() void flb_test_statsd_set() { - char *expected_strs[] = {"\"bucket\":\"uniques\"", "\"type\":\"set\"", + char *expected_strs[] = {"\"bucket\":\"uniques\"", "\"type\":\"set\"", "\"value\":\"765\""}; struct str_list expected = { .size = sizeof(expected_strs)/sizeof(char*), @@ -307,18 +314,81 @@ void flb_test_statsd_set() char *buf = "uniques:765|s"; int ret; - ret = test_normal(buf, &expected); + ret = test_normal(buf, &expected, FLB_FALSE); if (!TEST_CHECK(ret == 0)) { TEST_MSG("test failed"); exit(EXIT_FAILURE); } } +#ifdef FLB_HAVE_METRICS +void flb_test_statsd_metrics_gauge() +{ + char *expected_strs[] = {"\"name\":\"gorets\"", "\"desc\":\"-\"", "\"type\":1"}; + struct str_list expected = { + .size = sizeof(expected_strs)/sizeof(char*), + .lists = &expected_strs[0], + }; + + char *buf = "gorets:1|g"; + int ret; + + ret = test_normal(buf, &expected, FLB_TRUE); + if (!TEST_CHECK(ret == 0)) { + TEST_MSG("test failed"); + exit(EXIT_FAILURE); + } + +} + +void flb_test_statsd_metrics_counter() +{ + char *expected_strs[] = {"\"name\":\"gorets\"", "\"desc\":\"-\"", "\"type\":0"}; + struct str_list expected = { + .size = sizeof(expected_strs)/sizeof(char*), + .lists = &expected_strs[0], + }; + + char *buf = "gorets:1|c"; + int ret; + + ret = test_normal(buf, &expected, FLB_TRUE); + if (!TEST_CHECK(ret == 0)) { + TEST_MSG("test failed"); + exit(EXIT_FAILURE); + } + +} + +void flb_test_statsd_metrics_untyped() +{ + char *expected_strs[] = {"\"name\":\"gorets\"", "\"desc\":\"-\"", "\"type\":4"}; + struct str_list expected = { + .size = sizeof(expected_strs)/sizeof(char*), + .lists = &expected_strs[0], + }; + + char *buf = "gorets:1|s"; + int ret; + + ret = test_normal(buf, &expected, FLB_TRUE); + if (!TEST_CHECK(ret == 0)) { + TEST_MSG("test failed"); + exit(EXIT_FAILURE); + } + +} +#endif + TEST_LIST = { {"count", flb_test_statsd_count}, {"sample", flb_test_statsd_sample}, {"gauge", flb_test_statsd_gauge}, {"set", flb_test_statsd_set}, +#ifdef FLB_HAVE_METRICS + {"metrics_gauge", flb_test_statsd_metrics_gauge}, + {"metrics_counter", flb_test_statsd_metrics_counter}, + {"metrics_untyped", flb_test_statsd_metrics_untyped}, +#endif {NULL, NULL} }; - From 945d33364298a1a7834dee87104939fc44744554 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Wed, 14 Aug 2024 17:58:18 +0900 Subject: [PATCH 061/295] in_statsd: Eliminate strtok operation with cfl_utils_split Signed-off-by: Hiroshi Hatake --- plugins/in_statsd/statsd.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/plugins/in_statsd/statsd.c b/plugins/in_statsd/statsd.c index 74fbd1fdad5..b9edb37ca7c 100644 --- a/plugins/in_statsd/statsd.c +++ b/plugins/in_statsd/statsd.c @@ -207,9 +207,11 @@ static int cb_statsd_receive(struct flb_input_instance *ins, struct flb_config *config, void *data) { int ret; - char *line; int len; struct flb_statsd *ctx = data; + struct cfl_list *head = NULL; + struct cfl_list *kvs = NULL; + struct cfl_split_entry *cur = NULL; #ifdef FLB_HAVE_METRICS struct cmt *cmt = NULL; int cmt_flags = 0; @@ -244,20 +246,26 @@ static int cb_statsd_receive(struct flb_input_instance *ins, else { #endif ret = FLB_EVENT_ENCODER_SUCCESS; - /* Process all messages in buffer */ - line = strtok(ctx->buf, "\n"); - while (line != NULL) { - flb_plg_trace(ctx->ins, "received a line: '%s'", line); + kvs = cfl_utils_split(ctx->buf, '\n', -1 ); + if (kvs == NULL) { + goto split_error; + } + + cfl_list_foreach(head, kvs) { + cur = cfl_list_entry(head, struct cfl_split_entry, _head); + flb_plg_trace(ctx->ins, "received a line: '%s'", cur->value); - ret = statsd_process_line(ctx, line); + ret = statsd_process_line(ctx, cur->value); if (ret != FLB_EVENT_ENCODER_SUCCESS) { - flb_plg_error(ctx->ins, "failed to process line: '%s'", line); + flb_plg_error(ctx->ins, "failed to process line: '%s'", cur->value); break; } + } - line = strtok(NULL, "\n"); + if (kvs != NULL) { + cfl_utils_split_free(kvs); } if (ctx->log_encoder->output_length > 0) { @@ -275,6 +283,9 @@ static int cb_statsd_receive(struct flb_input_instance *ins, #endif return 0; + +split_error: + return -1; } static int cb_statsd_init(struct flb_input_instance *ins, From bda73d88500166a2b8cce95aa0bad9316a9639b9 Mon Sep 17 00:00:00 2001 From: Sjoerd Smink Date: Fri, 19 Jul 2024 16:30:39 +0200 Subject: [PATCH 062/295] out_cloudwatch_logs: fix disabling of auto_create_group config option Fix for #8949 Signed-off-by: Sjoerd Smink --- plugins/out_cloudwatch_logs/cloudwatch_logs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/out_cloudwatch_logs/cloudwatch_logs.c b/plugins/out_cloudwatch_logs/cloudwatch_logs.c index 5de71633016..c5e808ae141 100644 --- a/plugins/out_cloudwatch_logs/cloudwatch_logs.c +++ b/plugins/out_cloudwatch_logs/cloudwatch_logs.c @@ -53,8 +53,7 @@ static struct flb_aws_header content_type_header = { static int validate_log_group_class(struct flb_cloudwatch *ctx) { if (ctx->create_group == FLB_FALSE) { - flb_plg_error(ctx->ins, "Configuring log_group_class requires `auto_create_group On`."); - return -1; + return 0; } if (ctx->log_group_class == NULL || strlen(ctx->log_group_class) == 0) { From b494c29374a6937bfa0da637a2ea7ce580244f2b Mon Sep 17 00:00:00 2001 From: edsiper <369718+edsiper@users.noreply.github.com> Date: Wed, 14 Aug 2024 22:25:34 +0000 Subject: [PATCH 063/295] release: update to 3.1.7 Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CMakeLists.txt | 2 +- dockerfiles/Dockerfile | 2 +- fluent-bit-3.1.6.bb => fluent-bit-3.1.7.bb | 2 +- snap/snapcraft.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename fluent-bit-3.1.6.bb => fluent-bit-3.1.7.bb (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index fa6393f3514..f57806c49cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ set(CMAKE_POLICY_DEFAULT_CMP0069 NEW) # Fluent Bit Version set(FLB_VERSION_MAJOR 3) set(FLB_VERSION_MINOR 1) -set(FLB_VERSION_PATCH 6) +set(FLB_VERSION_PATCH 7) set(FLB_VERSION_STR "${FLB_VERSION_MAJOR}.${FLB_VERSION_MINOR}.${FLB_VERSION_PATCH}") set(CMAKE_POSITION_INDEPENDENT_CODE ON) diff --git a/dockerfiles/Dockerfile b/dockerfiles/Dockerfile index 4ef0738a520..feb84bb49d1 100644 --- a/dockerfiles/Dockerfile +++ b/dockerfiles/Dockerfile @@ -11,7 +11,7 @@ # docker buildx build --platform "linux/amd64,linux/arm64,linux/arm/v7,linux/s390x" -f ./dockerfiles/Dockerfile.multiarch --build-arg FLB_TARBALL=https://github.com/fluent/fluent-bit/archive/v1.8.11.tar.gz ./dockerfiles/ # Set this to the current release version: it gets done so as part of the release. -ARG RELEASE_VERSION=3.1.6 +ARG RELEASE_VERSION=3.1.7 # For multi-arch builds - assumption is running on an AMD64 host FROM multiarch/qemu-user-static:x86_64-arm as qemu-arm32 diff --git a/fluent-bit-3.1.6.bb b/fluent-bit-3.1.7.bb similarity index 99% rename from fluent-bit-3.1.6.bb rename to fluent-bit-3.1.7.bb index 6f8769259ec..6c69bacaf6e 100644 --- a/fluent-bit-3.1.6.bb +++ b/fluent-bit-3.1.7.bb @@ -16,7 +16,7 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=2ee41112a44fe7014dce33e26468ba93" SECTION = "net" PR = "r0" -PV = "3.1.6" +PV = "3.1.7" SRCREV = "v${PV}" SRC_URI = "git://github.com/fluent/fluent-bit.git;nobranch=1" diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 72eaa76d7a4..4cdc9c82280 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,6 +1,6 @@ name: fluent-bit base: core18 -version: '3.1.6' +version: '3.1.7' summary: High performance logs and stream processor description: | Fluent Bit is a high performance log processor and stream processor for Linux. From 17379db566988406326e9c9916e3a851f8758cfd Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 14 Aug 2024 17:37:27 +0200 Subject: [PATCH 064/295] tests: in_http: replaced the failure trigger mechanism Signed-off-by: Leonardo Alminana --- tests/runtime/in_http.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/runtime/in_http.c b/tests/runtime/in_http.c index 8f46c794a42..609bc9dadaf 100644 --- a/tests/runtime/in_http.c +++ b/tests/runtime/in_http.c @@ -547,7 +547,8 @@ void flb_test_http_failure_400_bad_disk_write() flb_time_msleep(5000); - ret = chmod("/tmp/http-input-test-404-bad-write", 000); + rename("/tmp/http-input-test-404-bad-write", + "/tmp/http-input-test-404-bad-write.fail"); TEST_CHECK(ret == 0); ctx->httpc = http_client_ctx_create(); @@ -574,11 +575,9 @@ void flb_test_http_failure_400_bad_disk_write() TEST_MSG("http response code error. expect: %d, got: %d\n", 400, c->resp.status); } - chmod("/tmp/http-input-test-404-bad-write/http.0", 0700); - rmdir("/tmp/http-input-test-404-bad-write/http.0"); - - chmod("/tmp/http-input-test-404-bad-write", 0700); - rmdir("/tmp/http-input-test-404-bad-write"); + rename("/tmp/http-input-test-404-bad-write.fail", + "/tmp/http-input-test-404-bad-write"); + TEST_CHECK(ret == 0); /* waiting to flush */ flb_time_msleep(1500); From bb067d3d2a101200127f01f06b82bd36b32c25c7 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 14 Aug 2024 19:39:03 +0200 Subject: [PATCH 065/295] filter_aws: fixed group metadata fetch issue and addressed (CID 507941) Signed-off-by: Leonardo Alminana --- plugins/filter_aws/aws.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/filter_aws/aws.c b/plugins/filter_aws/aws.c index afe94a8a466..c117ffe16ba 100644 --- a/plugins/filter_aws/aws.c +++ b/plugins/filter_aws/aws.c @@ -349,7 +349,7 @@ static int get_ec2_tag_keys(struct flb_filter_aws *ctx) flb_sds_destroy(tags_list); return -1; } - ctx->tag_keys_len = flb_calloc(ctx->tags_count, sizeof(size_t*)); + ctx->tag_keys_len = flb_calloc(ctx->tags_count, sizeof(size_t)); if (!ctx->tag_keys_len) { flb_errno(); flb_sds_destroy(tags_list); @@ -804,7 +804,8 @@ static int ec2_metadata_group_should_fetch(struct flb_filter_aws *ctx, interval = now - group->last_fetch_attempt; - if (interval < required_interval) { + if (group->last_fetch_attempt > 0 && + interval < required_interval) { return FLB_FALSE; } return FLB_TRUE; From 42e4c4aac2bbf2f2110161acd9f549ae55b2b0b2 Mon Sep 17 00:00:00 2001 From: leonardo-albertovich Date: Thu, 15 Aug 2024 18:10:42 +0200 Subject: [PATCH 066/295] out_opensearch: fixed a wrong data type used for a boolean option (#9221) --------- Signed-off-by: Leonardo Alminana --- plugins/out_opensearch/opensearch.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/out_opensearch/opensearch.h b/plugins/out_opensearch/opensearch.h index e1aa7f3508b..c6421e15fef 100644 --- a/plugins/out_opensearch/opensearch.h +++ b/plugins/out_opensearch/opensearch.h @@ -61,7 +61,7 @@ struct flb_opensearch { struct flb_record_accessor *ra_index; char *type; - char suppress_type_name; + int suppress_type_name; /* HTTP Auth */ char *http_user; From db9ceb5cbea5866a4fb0695657c29f93d3580978 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 14 Aug 2024 21:38:56 +0200 Subject: [PATCH 067/295] out_stackdriver: fixed a wrong data type used for two boolean options Signed-off-by: Leonardo Alminana --- plugins/out_stackdriver/stackdriver.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/out_stackdriver/stackdriver.h b/plugins/out_stackdriver/stackdriver.h index fa5cb2e2b10..66462cf4fab 100644 --- a/plugins/out_stackdriver/stackdriver.h +++ b/plugins/out_stackdriver/stackdriver.h @@ -183,8 +183,8 @@ struct flb_stackdriver { flb_sds_t log_name_key; flb_sds_t http_request_key; int http_request_key_size; - bool autoformat_stackdriver_trace; - bool test_log_entry_format; + int autoformat_stackdriver_trace; + int test_log_entry_format; flb_sds_t stackdriver_agent; From 55acb13e27cc7d6552ce304daa9d0d81f4958f89 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 14 Aug 2024 21:50:55 +0200 Subject: [PATCH 068/295] filter_tensorflow: fixed a wrong data type used for a boolean option Signed-off-by: Leonardo Alminana --- plugins/filter_tensorflow/tensorflow.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/filter_tensorflow/tensorflow.h b/plugins/filter_tensorflow/tensorflow.h index 779c0f09e9c..8b861267617 100644 --- a/plugins/filter_tensorflow/tensorflow.h +++ b/plugins/filter_tensorflow/tensorflow.h @@ -37,7 +37,7 @@ struct flb_tensorflow { int output_byte_size; /* feature scaling/normalization */ - bool include_input_fields; + int include_input_fields; float* normalization_value; struct flb_filter_instance *ins; From 95760e89271395b65489b40c1bed0b8a2a2a0a05 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 14 Aug 2024 21:55:30 +0200 Subject: [PATCH 069/295] in_nginx_exporter_metrics: fixed a wrong data type used for an option Signed-off-by: Leonardo Alminana --- plugins/in_nginx_exporter_metrics/nginx.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/in_nginx_exporter_metrics/nginx.h b/plugins/in_nginx_exporter_metrics/nginx.h index a1889456e68..19b3de8239f 100644 --- a/plugins/in_nginx_exporter_metrics/nginx.h +++ b/plugins/in_nginx_exporter_metrics/nginx.h @@ -45,7 +45,7 @@ struct nginx_ctx struct cmt_gauge *connections_waiting; struct cmt_gauge *connection_up; bool is_up; - bool is_nginx_plus; + int is_nginx_plus; int nginx_plus_version; struct nginx_plus_connections *plus_connections; From bbc9f920e04be67b0e4384b4a0bf516222a40aec Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 14 Aug 2024 21:57:31 +0200 Subject: [PATCH 070/295] in_opentelemetry: fixed a wrong data type used for an option Signed-off-by: Leonardo Alminana --- plugins/in_opentelemetry/opentelemetry.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/in_opentelemetry/opentelemetry.h b/plugins/in_opentelemetry/opentelemetry.h index 7fc438b6d6b..4c78f941086 100644 --- a/plugins/in_opentelemetry/opentelemetry.h +++ b/plugins/in_opentelemetry/opentelemetry.h @@ -35,7 +35,7 @@ struct flb_opentelemetry { flb_sds_t listen; flb_sds_t tcp_port; const char *tag_key; - bool raw_traces; + int raw_traces; int tag_from_uri; flb_sds_t logs_metadata_key; From dedffbdc3a56c31c6440d247f2b9cdab363ff129 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 14 Aug 2024 22:00:51 +0200 Subject: [PATCH 071/295] in_proc: fixed a wrong data type used for three options Signed-off-by: Leonardo Alminana --- plugins/in_proc/in_proc.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/in_proc/in_proc.h b/plugins/in_proc/in_proc.h index b5d48219d3a..20b3a66187e 100644 --- a/plugins/in_proc/in_proc.h +++ b/plugins/in_proc/in_proc.h @@ -53,7 +53,7 @@ struct flb_in_proc_mem_offset { }; struct flb_in_proc_config { - uint8_t alert; + int alert; uint8_t alive; /* Checking process */ @@ -66,10 +66,10 @@ struct flb_in_proc_config { int interval_nsec; /* Memory */ - uint8_t mem; + int mem; /* File descriptor */ - uint8_t fds; + int fds; struct flb_input_instance *ins; struct flb_log_event_encoder *log_encoder; From 4bfece8dbf42ccd50cbe030b32f83ec95773fee3 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 14 Aug 2024 22:08:19 +0200 Subject: [PATCH 072/295] in_proc: fixed a wrong data type used for an option Signed-off-by: Leonardo Alminana --- plugins/out_es/es.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/out_es/es.h b/plugins/out_es/es.h index 67efc9e0442..a3f1ecadf98 100644 --- a/plugins/out_es/es.h +++ b/plugins/out_es/es.h @@ -40,7 +40,7 @@ struct flb_elasticsearch { /* Elasticsearch index (database) and type (table) */ char *index; char *type; - char suppress_type_name; + int suppress_type_name; /* HTTP Auth */ char *http_user; From e567a640acf5d8f4d14075379daad62f1dd601b9 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 14 Aug 2024 22:17:29 +0200 Subject: [PATCH 073/295] network: fixed a wrong data type used for an option Signed-off-by: Leonardo Alminana --- include/fluent-bit/flb_network.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fluent-bit/flb_network.h b/include/fluent-bit/flb_network.h index 4fb741527ec..900ec691cf4 100644 --- a/include/fluent-bit/flb_network.h +++ b/include/fluent-bit/flb_network.h @@ -40,7 +40,7 @@ /* Network connection setup */ struct flb_net_setup { /* enable/disable keepalive support */ - char keepalive; + int keepalive; /* max time in seconds that a keepalive connection can be idle */ int keepalive_idle_timeout; From 7e62a825ab3138aaf26f7fd5936dbea5a197592c Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 14 Aug 2024 22:20:29 +0200 Subject: [PATCH 074/295] tests: config_map: fixed a wrong data type used for an option Signed-off-by: Leonardo Alminana --- tests/internal/config_map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/internal/config_map.c b/tests/internal/config_map.c index b709d016d17..687e2313ac6 100644 --- a/tests/internal/config_map.c +++ b/tests/internal/config_map.c @@ -14,7 +14,7 @@ struct context { int num_int; size_t size; time_t time; - char boolean; + int boolean; double num_double; flb_sds_t string; struct mk_list *list1; From 7457a66d6eb6c4f78c1dc2050b56a52be92b7d3e Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 14 Aug 2024 22:23:20 +0200 Subject: [PATCH 075/295] tests: intenral: fuzzers: fixed a wrong data type used for an option Signed-off-by: Leonardo Alminana --- tests/internal/fuzzers/config_map_fuzzer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/internal/fuzzers/config_map_fuzzer.c b/tests/internal/fuzzers/config_map_fuzzer.c index 79697f65165..d62afd8011b 100644 --- a/tests/internal/fuzzers/config_map_fuzzer.c +++ b/tests/internal/fuzzers/config_map_fuzzer.c @@ -13,7 +13,7 @@ struct context { int num_int; size_t size; time_t time; - char boolean; + int boolean; double num_double; flb_sds_t string; struct mk_list *list1; From 95d0a98b2c30c51c47511c083567961d79065337 Mon Sep 17 00:00:00 2001 From: YingJie Fu Date: Wed, 14 Aug 2024 02:53:34 -0700 Subject: [PATCH 076/295] in_dummy: fix the in_dummy timestamp issue on s390x Signed-off-by: YingJie Fu --- plugins/in_dummy/in_dummy.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/in_dummy/in_dummy.h b/plugins/in_dummy/in_dummy.h index a75aa89cb69..f225fcb4eeb 100644 --- a/plugins/in_dummy/in_dummy.h +++ b/plugins/in_dummy/in_dummy.h @@ -47,8 +47,8 @@ struct flb_dummy { int start_time_sec; int start_time_nsec; - bool fixed_timestamp; - bool flush_on_startup; + int fixed_timestamp; + int flush_on_startup; char *ref_metadata_msgpack; size_t ref_metadata_msgpack_size; From 26873b22c194283979130d95414097ce3d282132 Mon Sep 17 00:00:00 2001 From: YingJie Fu Date: Tue, 13 Aug 2024 18:27:09 -0700 Subject: [PATCH 077/295] in_head: fix cannot allocate memory on big endian system Signed-off-by: YingJie Fu --- plugins/in_head/in_head.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/in_head/in_head.c b/plugins/in_head/in_head.c index bf2a1ea2034..afc4be53fef 100644 --- a/plugins/in_head/in_head.c +++ b/plugins/in_head/in_head.c @@ -426,7 +426,7 @@ static struct flb_config_map config_map[] = { "Set the record key" }, { - FLB_CONFIG_MAP_INT, "buf_size", DEFAULT_BUF_SIZE, + FLB_CONFIG_MAP_SIZE, "buf_size", DEFAULT_BUF_SIZE, 0, FLB_TRUE, offsetof(struct flb_in_head_config, buf_size), "Set the read buffer size" }, From a827c93f9e07ed2450de8c824f7df72f0606f98a Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Wed, 14 Aug 2024 15:53:10 +0900 Subject: [PATCH 078/295] in_elasticsearch: Store log_encoder pointer (CID 508245) Signed-off-by: Hiroshi Hatake --- plugins/in_elasticsearch/in_elasticsearch.h | 2 +- .../in_elasticsearch_bulk_prot.c | 26 +++++++++---------- .../in_elasticsearch_config.c | 13 ++++------ 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/plugins/in_elasticsearch/in_elasticsearch.h b/plugins/in_elasticsearch/in_elasticsearch.h index 6af189559a5..10deb62aa4b 100644 --- a/plugins/in_elasticsearch/in_elasticsearch.h +++ b/plugins/in_elasticsearch/in_elasticsearch.h @@ -42,7 +42,7 @@ struct flb_in_elasticsearch { char cluster_name[16]; char node_name[12]; - struct flb_log_event_encoder log_encoder; + struct flb_log_event_encoder *log_encoder; struct flb_input_instance *ins; diff --git a/plugins/in_elasticsearch/in_elasticsearch_bulk_prot.c b/plugins/in_elasticsearch/in_elasticsearch_bulk_prot.c index ca9f7acfefc..0f452a26da8 100644 --- a/plugins/in_elasticsearch/in_elasticsearch_bulk_prot.c +++ b/plugins/in_elasticsearch/in_elasticsearch_bulk_prot.c @@ -418,9 +418,9 @@ static int process_ndpack(struct flb_in_elasticsearch *ctx, flb_sds_t tag, char } if (error_op == FLB_FALSE) { - flb_log_event_encoder_reset(&ctx->log_encoder); + flb_log_event_encoder_reset(ctx->log_encoder); - ret = flb_log_event_encoder_begin_record(&ctx->log_encoder); + ret = flb_log_event_encoder_begin_record(ctx->log_encoder); if (ret != FLB_EVENT_ENCODER_SUCCESS) { flb_sds_destroy(write_op); @@ -431,7 +431,7 @@ static int process_ndpack(struct flb_in_elasticsearch *ctx, flb_sds_t tag, char } ret = flb_log_event_encoder_set_timestamp( - &ctx->log_encoder, + ctx->log_encoder, &tm); if (ret != FLB_EVENT_ENCODER_SUCCESS) { @@ -444,7 +444,7 @@ static int process_ndpack(struct flb_in_elasticsearch *ctx, flb_sds_t tag, char if (ret == FLB_EVENT_ENCODER_SUCCESS) { ret = flb_log_event_encoder_append_body_values( - &ctx->log_encoder, + ctx->log_encoder, FLB_LOG_EVENT_CSTRING_VALUE((char *) ctx->meta_key), FLB_LOG_EVENT_MSGPACK_OBJECT_VALUE(&result.data)); } @@ -469,7 +469,7 @@ static int process_ndpack(struct flb_in_elasticsearch *ctx, flb_sds_t tag, char map_copy_entry = &result.data.via.map.ptr[map_copy_index]; ret = flb_log_event_encoder_append_body_values( - &ctx->log_encoder, + ctx->log_encoder, FLB_LOG_EVENT_MSGPACK_OBJECT_VALUE(&map_copy_entry->key), FLB_LOG_EVENT_MSGPACK_OBJECT_VALUE(&map_copy_entry->val)); } @@ -481,7 +481,7 @@ static int process_ndpack(struct flb_in_elasticsearch *ctx, flb_sds_t tag, char break; } - ret = flb_log_event_encoder_commit_record(&ctx->log_encoder); + ret = flb_log_event_encoder_commit_record(ctx->log_encoder); if (ret != FLB_EVENT_ENCODER_SUCCESS) { flb_plg_error(ctx->ins, "event encoder error : %d", ret); @@ -501,8 +501,8 @@ static int process_ndpack(struct flb_in_elasticsearch *ctx, flb_sds_t tag, char flb_input_log_append(ctx->ins, tag_from_record, flb_sds_len(tag_from_record), - ctx->log_encoder.output_buffer, - ctx->log_encoder.output_length); + ctx->log_encoder->output_buffer, + ctx->log_encoder->output_length); flb_sds_destroy(tag_from_record); } @@ -510,17 +510,17 @@ static int process_ndpack(struct flb_in_elasticsearch *ctx, flb_sds_t tag, char flb_input_log_append(ctx->ins, tag, flb_sds_len(tag), - ctx->log_encoder.output_buffer, - ctx->log_encoder.output_length); + ctx->log_encoder->output_buffer, + ctx->log_encoder->output_length); } else { /* use default plugin Tag (it internal name, e.g: http.0 */ flb_input_log_append(ctx->ins, NULL, 0, - ctx->log_encoder.output_buffer, - ctx->log_encoder.output_length); + ctx->log_encoder->output_buffer, + ctx->log_encoder->output_length); } - flb_log_event_encoder_reset(&ctx->log_encoder); + flb_log_event_encoder_reset(ctx->log_encoder); } if (op_ret) { if (flb_sds_cmp(write_op, "index", op_str_size) == 0) { diff --git a/plugins/in_elasticsearch/in_elasticsearch_config.c b/plugins/in_elasticsearch/in_elasticsearch_config.c index e8c53f12bc7..56b5a4e099f 100644 --- a/plugins/in_elasticsearch/in_elasticsearch_config.c +++ b/plugins/in_elasticsearch/in_elasticsearch_config.c @@ -59,15 +59,12 @@ struct flb_in_elasticsearch *in_elasticsearch_config_create(struct flb_input_ins * moment so we want to make sure that it stays that way! */ - ret = flb_log_event_encoder_init(&ctx->log_encoder, - FLB_LOG_EVENT_FORMAT_DEFAULT); - - if (ret != FLB_EVENT_ENCODER_SUCCESS) { - flb_plg_error(ctx->ins, "error initializing event encoder : %d", ret); - + ctx->log_encoder = flb_log_event_encoder_create(FLB_LOG_EVENT_FORMAT_DEFAULT); + if (ctx->log_encoder == NULL) { + flb_plg_error(ctx->ins, "event encoder initialization error"); in_elasticsearch_config_destroy(ctx); - return ctx = NULL; + return NULL; } @@ -76,7 +73,7 @@ struct flb_in_elasticsearch *in_elasticsearch_config_create(struct flb_input_ins int in_elasticsearch_config_destroy(struct flb_in_elasticsearch *ctx) { - flb_log_event_encoder_destroy(&ctx->log_encoder); + flb_log_event_encoder_destroy(ctx->log_encoder); /* release all connections */ in_elasticsearch_bulk_conn_release_all(ctx); From 5b5d49e89470d51c1d9e9a7a41e9cde922e91761 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Fri, 16 Aug 2024 02:11:52 +0900 Subject: [PATCH 079/295] out_opensearch: fix a use-after-free issue (CID 508013) (#9233) Signed-off-by: Hiroshi Hatake --- plugins/out_opensearch/opensearch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/out_opensearch/opensearch.c b/plugins/out_opensearch/opensearch.c index 23dfdaabc6a..896693b0b94 100644 --- a/plugins/out_opensearch/opensearch.c +++ b/plugins/out_opensearch/opensearch.c @@ -1028,11 +1028,11 @@ static void cb_opensearch_flush(struct flb_event_chunk *event_chunk, /* Cleanup */ flb_http_client_destroy(c); - flb_sds_destroy(pack); if (final_payload_buf != pack) { flb_free(final_payload_buf); } + flb_sds_destroy(pack); flb_upstream_conn_release(u_conn); if (signature) { From 1af833c506972473b4a5e0616400dbc7855cea0c Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Fri, 16 Aug 2024 02:15:36 +0900 Subject: [PATCH 080/295] in_event_type: fix a resource leak on exception (CID 507968) (#9235) Signed-off-by: Hiroshi Hatake --- plugins/in_event_type/event_type.c | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/in_event_type/event_type.c b/plugins/in_event_type/event_type.c index a6530de82b3..08d97c13774 100644 --- a/plugins/in_event_type/event_type.c +++ b/plugins/in_event_type/event_type.c @@ -274,6 +274,7 @@ static int send_traces(struct flb_input_instance *ins) span_root = ctr_span_create(ctx, scope_span, "main", NULL); if (!span_root) { ctr_destroy(ctx); + ctr_id_destroy(span_id); ctr_opts_exit(&opts); return -1; } From 1a1970342bf2097c571d72f2e947f037f6410c4f Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Fri, 16 Aug 2024 07:45:03 +0900 Subject: [PATCH 081/295] out_chronicle: fix a resource leak on exception (CID 508008) (#9234) Signed-off-by: Hiroshi Hatake --- plugins/out_chronicle/chronicle.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/out_chronicle/chronicle.c b/plugins/out_chronicle/chronicle.c index c0cfc3e5a67..a8fab08eacd 100644 --- a/plugins/out_chronicle/chronicle.c +++ b/plugins/out_chronicle/chronicle.c @@ -877,6 +877,8 @@ static void cb_chronicle_flush(struct flb_event_chunk *event_chunk, flb_plg_error(ctx->ins, "Log event decoder initialization error : %d", ret); + /* Cleanup token and conn */ + flb_sds_destroy(token); flb_upstream_conn_release(u_conn); FLB_OUTPUT_RETURN(FLB_RETRY); } From fe87949ffaf1d486c045a9cfb9fbb378f4710851 Mon Sep 17 00:00:00 2001 From: rightblank Date: Tue, 20 Aug 2024 02:07:12 +0800 Subject: [PATCH 082/295] config_map: fix configuration type cast issue found on s390x (#8904) Signed-off-by: YingJie Fu --- src/flb_config_map.c | 8 ++++---- tests/internal/config_map.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/flb_config_map.c b/src/flb_config_map.c index 4db55411cb0..f09a689a0bb 100644 --- a/src/flb_config_map.c +++ b/src/flb_config_map.c @@ -583,7 +583,7 @@ int flb_config_map_set(struct mk_list *properties, struct mk_list *map, void *co int ret; int len; char *base; - char *m_bool; + int *m_bool; int *m_i_num; double *m_d_num; size_t *m_s_num; @@ -651,10 +651,10 @@ int flb_config_map_set(struct mk_list *properties, struct mk_list *map, void *co } else if (m->type == FLB_CONFIG_MAP_TIME) { m_i_num = (int *) (base + m->offset); - *m_i_num = m->value.val.s_num; + *m_i_num = m->value.val.i_num; } else if (m->type == FLB_CONFIG_MAP_BOOL) { - m_bool = (char *) (base + m->offset); + m_bool = (int *) (base + m->offset); *m_bool = m->value.val.boolean; } else if (m->type >= FLB_CONFIG_MAP_CLIST || @@ -779,7 +779,7 @@ int flb_config_map_set(struct mk_list *properties, struct mk_list *map, void *co *m_d_num = atof(kv->val); } else if (m->type == FLB_CONFIG_MAP_BOOL) { - m_bool = (char *) (base + m->offset); + m_bool = (int *) (base + m->offset); ret = flb_utils_bool(kv->val); if (ret == -1) { flb_error("[config map] invalid value for boolean property '%s=%s'", diff --git a/tests/internal/config_map.c b/tests/internal/config_map.c index 687e2313ac6..941b815e902 100644 --- a/tests/internal/config_map.c +++ b/tests/internal/config_map.c @@ -13,7 +13,7 @@ struct context { /* Single values */ int num_int; size_t size; - time_t time; + int time; int boolean; double num_double; flb_sds_t string; From cc65672452fba09921d0aa14dca8ef72ce7de167 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Sun, 18 Aug 2024 19:18:22 -0600 Subject: [PATCH 083/295] lib: monkey: sync poll(2) new backend changes Signed-off-by: Eduardo Silva --- lib/monkey/CMakeLists.txt | 24 +++++- .../include/monkey/mk_core/mk_core_info.h.in | 1 + lib/monkey/include/monkey/mk_core/mk_event.h | 23 ++++-- .../include/monkey/mk_core/mk_event_select.h | 2 +- lib/monkey/mk_core/CMakeLists.txt | 77 ++++++++++++++++--- lib/monkey/mk_core/deps/CMakeLists.txt | 18 ++--- lib/monkey/mk_core/mk_event.c | 23 ++++-- 7 files changed, 138 insertions(+), 30 deletions(-) diff --git a/lib/monkey/CMakeLists.txt b/lib/monkey/CMakeLists.txt index f4e88caaccf..95d8cc1e618 100644 --- a/lib/monkey/CMakeLists.txt +++ b/lib/monkey/CMakeLists.txt @@ -71,6 +71,19 @@ option(MK_WITHOUT_BIN "Do not build binary" No) option(MK_WITHOUT_CONF "Skip configuration files" No) option(MK_STATIC_LIB_MODE "Static library mode" No) + +# Event loop backend +# ------------------ +# Options to force a specific event loop mechanism. If all of them are +# turned off, the system will do an automatic selection. +# +# Check on mk_core/CMakeLists.txt for more details. +option(MK_EVENT_LOOP_SELECT "Use select(2) event loop" No) +option(MK_EVENT_LOOP_POLL "Use poll(2) event loop" No) +option(MK_EVENT_LOOP_KQUEUE "Use kqueue(2) event loop" No) +option(MK_EVENT_LOOP_EPOLL "Use epoll(2) event loop" No) +option(MK_EVENT_LOOP_LIBEVENT "Use libevent event loop" No) + # If building just for a "library" mode, disable plugins if(MK_LIB_ONLY) set(MK_PLUGIN_AUTH No) @@ -279,7 +292,16 @@ include_directories(include/monkey/) include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/) include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/monkey/) -if (CMAKE_SYSTEM_NAME MATCHES "Windows") +# Check if we need to build libevent by using auto discovery mechanism +if (CMAKE_SYSTEM_NAME MATCHES "Windows" AND + ( + NOT MK_EVENT_LOOP_SELECT AND + NOT MK_EVENT_LOOP_POLL AND + NOT MK_EVENT_LOOP_KQUEUE AND + NOT MK_EVENT_LOOP_EPOLL + ) OR MK_EVENT_LOOP_LIBEVENT) + + set(MK_EVENT_LOOP_LIBEVENT Yes) include_directories(mk_core/deps/libevent/include) include_directories("${PROJECT_BINARY_DIR}/mk_core/deps/libevent/include/") endif() diff --git a/lib/monkey/include/monkey/mk_core/mk_core_info.h.in b/lib/monkey/include/monkey/mk_core/mk_core_info.h.in index 1bd09e54ae1..9467d01e68d 100644 --- a/lib/monkey/include/monkey/mk_core/mk_core_info.h.in +++ b/lib/monkey/include/monkey/mk_core/mk_core_info.h.in @@ -23,4 +23,5 @@ /* General flags set by CMakeLists.txt */ @MK_CORE_BUILD_FLAGS@ + #endif diff --git a/lib/monkey/include/monkey/mk_core/mk_event.h b/lib/monkey/include/monkey/mk_core/mk_event.h index e1990e878e5..c0c56f8ba98 100644 --- a/lib/monkey/include/monkey/mk_core/mk_event.h +++ b/lib/monkey/include/monkey/mk_core/mk_event.h @@ -70,14 +70,27 @@ #define MK_EVENT_IS_REGISTERED(event) ((event->status & MK_EVENT_REGISTERED) != 0) -#if defined(_WIN32) - #include "mk_event_libevent.h" -#elif defined(MK_HAVE_EVENT_SELECT) +#if defined(MK_EVENT_LOOP_SELECT) #include "mk_event_select.h" -#elif defined(__linux__) && !defined(LINUX_KQUEUE) +#elif defined(MK_EVENT_LOOP_POLL) + #include "mk_event_poll.h" +#elif defined(MK_EVENT_LOOP_KQUEUE) + #include "mk_event_kqueue.h" +#elif defined(MK_EVENT_LOOP_EPOLL) #include "mk_event_epoll.h" +#elif defined(MK_EVENT_LOOP_LIBEVENT) + #include "mk_event_libevent.h" #else - #include "mk_event_kqueue.h" + /* do our best based on the operating system */ + #if defined(__linux__) + #include "mk_event_epoll.h" + #elif defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__) || defined(__OpenBSD__) + #include "mk_event_kqueue.h" + #elif defined(_WIN32) + #include "mk_event_libevent.h" + #else + #include "mk_event_select.h" + #endif #endif #if defined(_WIN32) diff --git a/lib/monkey/include/monkey/mk_core/mk_event_select.h b/lib/monkey/include/monkey/mk_core/mk_event_select.h index b69c0ba381b..f9200d86e6d 100644 --- a/lib/monkey/include/monkey/mk_core/mk_event_select.h +++ b/lib/monkey/include/monkey/mk_core/mk_event_select.h @@ -53,7 +53,7 @@ struct mk_event_ctx { for (__i = 0; \ __i < evl->n_events; \ __i++, \ - event = ((__i < evl->n_events) ? __ctx->fired[__i].data : NULL) \ + event = ((__i < evl->n_events) ? &__ctx->fired[__i] : NULL) \ ) #endif diff --git a/lib/monkey/mk_core/CMakeLists.txt b/lib/monkey/mk_core/CMakeLists.txt index 86cc7fcb4e6..a1a32101783 100644 --- a/lib/monkey/mk_core/CMakeLists.txt +++ b/lib/monkey/mk_core/CMakeLists.txt @@ -15,6 +15,7 @@ include_directories(../include/monkey/) macro(MK_DEFINITION var) add_definitions(-D${var}) set(MK_CORE_BUILD_FLAGS "${MK_CORE_BUILD_FLAGS}#ifndef ${var}\n#define ${var}\n#endif\n") + set(MK_CORE_INFO_DEFS "${MK_CORE_INFO_DEFS} ${var}") endmacro() # Set threading system @@ -26,6 +27,9 @@ if (CMAKE_SYSTEM_NAME MATCHES "Windows") ) add_subdirectory(deps/) else() + if (MK_EVENT_LOOP_LIBEVENT) + add_subdirectory(deps/) + endif() MK_DEFINITION(MK_THREADS_POSIX) endif() @@ -86,12 +90,26 @@ if (HAVE_UNISTD_H) MK_DEFINITION(MK_HAVE_UNISTD_H) endif() -# Lookup event-loop mechanism: do we need to fallback to select(2) ? +# Check for a valid event loop mechanism + +# select(2) check_c_source_compiles(" - #include + #include + #include int main() { - return epoll_create(1); - }" HAVE_EPOLL) + fd_set rfds; + struct timeval tv; + return select(1, &rfds, NULL, NULL, &tv); + }" HAVE_SELECT) + +check_c_source_compiles(" + #include + int main() { + struct pollfd fds[1]; + fds[0].fd = 0; + fds[0].events = POLLIN; + return poll(fds, 1, 1); + }" HAVE_POLL) check_c_source_compiles(" #include @@ -99,10 +117,51 @@ check_c_source_compiles(" return kqueue(); }" HAVE_KQUEUE) +check_c_source_compiles(" + #include + int main() { + return epoll_create(1); + }" HAVE_EPOLL) + +if (MK_EVENT_LOOP_SELECT) + if (NOT HAVE_SELECT) + message(FATAL_ERROR "Event loop backend > select(2) not available") + else() + message(STATUS "Event loop backend > select(2)") + MK_DEFINITION(MK_EVENT_LOOP_SELECT) + endif() +endif() + +if (MK_EVENT_LOOP_POLL) + if (NOT HAVE_POLL) + message(FATAL_ERROR "Event loop backend > poll(2) not available") + else() + message(STATUS "Event loop backend > poll(2)") + MK_DEFINITION(MK_EVENT_LOOP_POLL) + endif() +endif() -if ((NOT HAVE_EPOLL AND NOT HAVE_KQUEUE) OR MK_USE_EVENT_SELECT) - message(STATUS "Event loop backend > select(2)") - MK_DEFINITION(MK_HAVE_EVENT_SELECT) +if (MK_EVENT_LOOP_KQUEUE) + if (NOT HAVE_KQUEUE) + message(FATAL_ERROR "Event loop backend > kqueue(2) not available") + else() + message(STATUS "Event loop backend > kqueue(2)") + MK_DEFINITION(MK_EVENT_LOOP_KQUEUE) + endif() +endif() + +if (MK_EVENT_LOOP_EPOLL) + if (NOT HAVE_EPOLL) + message(FATAL_ERROR "Event loop backend > epoll(2) not available") + else() + message(STATUS "Event loop backend > epoll(2)") + MK_DEFINITION(MK_EVENT_LOOP_EPOLL) + endif() +endif() + +if (MK_EVENT_LOOP_LIBEVENT) + message(STATUS "Event loop backend > libevent") + MK_DEFINITION(MK_EVENT_LOOP_LIBEVENT) endif() # Validate timerfd_create() @@ -145,12 +204,12 @@ endif() configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/../include/monkey/mk_core/mk_core_info.h.in" - "${PROJECT_BINARY_DIR}/include/monkey/mk_core/mk_core_info.h" + "${PROJECT_BINARY_DIR}/include/monkey/mk_core/mk_core_info.h" ) add_library(mk_core STATIC ${src}) target_link_libraries(mk_core ${CMAKE_THREAD_LIBS_INIT}) -if (CMAKE_SYSTEM_NAME MATCHES "Windows") +if (MK_EVENT_LOOP_LIBEVENT) target_link_libraries(mk_core event) endif() diff --git a/lib/monkey/mk_core/deps/CMakeLists.txt b/lib/monkey/mk_core/deps/CMakeLists.txt index 08ca13cc044..d97db5d8664 100644 --- a/lib/monkey/mk_core/deps/CMakeLists.txt +++ b/lib/monkey/mk_core/deps/CMakeLists.txt @@ -1,13 +1,13 @@ -macro(FORCE_OPTION option value) - set(${option} ${value} CACHE "" INTERNAL FORCE) +macro(FORCE_OPTION option value type) + set(${option} ${value} CACHE ${type} INTERNAL FORCE) endmacro() -FORCE_OPTION(EVENT__DISABLE_THREAD_SUPPORT ON) -FORCE_OPTION(EVENT__DISABLE_OPENSSL ON) -FORCE_OPTION(EVENT__DISABLE_BENCHMARK ON) -FORCE_OPTION(EVENT__DISABLE_TESTS ON) -FORCE_OPTION(EVENT__DISABLE_REGRESS ON) -FORCE_OPTION(EVENT__DISABLE_SAMPLES ON) -FORCE_OPTION(EVENT__BUILD_SHARED_LIBRARIES OFF) +FORCE_OPTION(EVENT__DISABLE_THREAD_SUPPORT ON BOOL) +FORCE_OPTION(EVENT__DISABLE_OPENSSL ON BOOL) +FORCE_OPTION(EVENT__DISABLE_BENCHMARK ON BOOL) +FORCE_OPTION(EVENT__DISABLE_TESTS ON BOOL) +FORCE_OPTION(EVENT__DISABLE_REGRESS ON BOOL) +FORCE_OPTION(EVENT__DISABLE_SAMPLES ON BOOL) +FORCE_OPTION(EVENT__BUILD_SHARED_LIBRARIES OFF BOOL) add_subdirectory(libevent) diff --git a/lib/monkey/mk_core/mk_event.c b/lib/monkey/mk_core/mk_event.c index 5eaa8b00eb0..631efaa41e9 100644 --- a/lib/monkey/mk_core/mk_event.c +++ b/lib/monkey/mk_core/mk_event.c @@ -28,14 +28,27 @@ #include #include -#if defined(_WIN32) - #include "mk_event_libevent.c" -#elif defined(MK_HAVE_EVENT_SELECT) +#if defined(MK_EVENT_LOOP_SELECT) #include "mk_event_select.c" -#elif defined(__linux__) && !defined(LINUX_KQUEUE) +#elif defined(MK_EVENT_LOOP_POLL) + #include "mk_event_poll.c" +#elif defined(MK_EVENT_LOOP_KQUEUE) + #include "mk_event_kqueue.c" +#elif defined(MK_EVENT_LOOP_EPOLL) #include "mk_event_epoll.c" +#elif defined(MK_EVENT_LOOP_LIBEVENT) + #include "mk_event_libevent.c" #else - #include "mk_event_kqueue.c" + /* do our best based on the operating system */ + #if defined(__linux__) + #include "mk_event_epoll.c" + #elif defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__) || defined(__OpenBSD__) + #include "mk_event_kqueue.c" + #elif defined(_WIN32) + #include "mk_event_libevent.c" + #else + #include "mk_event_select.c" + #endif #endif /* Initialize backend */ From 4c42a4dcc80c9a4da3f7e7e068092276514ecd6f Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 22 Jul 2024 10:23:58 -0600 Subject: [PATCH 084/295] build: add build time event loop selection Signed-off-by: Eduardo Silva --- CMakeLists.txt | 48 ++++++++++++++++++++++++++++++--- src/flb_scheduler.c | 14 +++++----- tests/internal/flb_event_loop.c | 22 +++++++-------- 3 files changed, 64 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f57806c49cf..2018e4f52c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -165,6 +165,22 @@ option(FLB_CONFIG_YAML "Enable YAML config format" Yes) # List of plugins available and defaults for each option include(cmake/plugins_options.cmake) + +# Event loop backend (advanced users only) +# ---------------------------------------- +# The following options are for advanced users only, they are used to enable +# specific event loop backends. By default, the build system will try to +# detect the best backend for the current Operating System. If you want to +# force a specific backend, you can use ONE of the following options. +# +# Note that these options will enable the proper option for Monkey library. +option(FLB_EVENT_LOOP_EPOLL "Enable epoll(2) event loop backend" No) +option(FLB_EVENT_LOOP_POLL "Enable poll(2) event loop backend" No) +option(FLB_EVENT_LOOP_KQUEUE "Enable kqueue(2) event loop backend" No) +option(FLB_EVENT_LOOP_SELECT "Enable select(2) event loop backend" No) +option(FLB_EVENT_LOOP_LIBEVENT "Enable libevent event loop backend" No) + + if(DEFINED FLB_NIGHTLY_BUILD AND NOT "${FLB_NIGHTLY_BUILD}" STREQUAL "") FLB_DEFINITION_VAL(FLB_NIGHTLY_BUILD ${FLB_NIGHTLY_BUILD}) endif() @@ -501,12 +517,38 @@ if(FLB_TESTS_RUNTIME) FLB_OPTION(FLB_HTTP_SERVER ON) endif() -# MK Core +# Monkey Core Library macro(MK_SET_OPTION option value) set(${option} ${value} CACHE INTERNAL "" FORCE) endmacro() -MK_SET_OPTION(MK_SYSTEM_MALLOC ON) -MK_SET_OPTION(MK_DEBUG ON) +MK_SET_OPTION(MK_SYSTEM_MALLOC ON) +MK_SET_OPTION(MK_DEBUG ON) + +# Monkey backend event loop +if (FLB_EVENT_LOOP_EPOLL) + MK_SET_OPTION(MK_EVENT_LOOP_EPOLL ON) + FLB_DEFINITION(FLB_EVENT_LOOP_EPOLL) + message(STATUS "FLB Event loop backend > epoll(2)") +elseif (FLB_EVENT_LOOP_POLL) + MK_SET_OPTION(MK_EVENT_LOOP_POLL ON) + FLB_DEFINITION(FLB_EVENT_LOOP_POLL) + message(STATUS "FLB Event loop backend > poll(2)") +elseif (FLB_EVENT_LOOP_KQUEUE) + MK_SET_OPTION(MK_EVENT_LOOP_KQUEUE ON) + FLB_DEFINITION(FLB_EVENT_LOOP_KQUEUE) + message(STATUS "FLB Event loop backend > kqueue(2)") +elseif (FLB_EVENT_LOOP_SELECT) + MK_SET_OPTION(MK_EVENT_LOOP_SELECT ON) + FLB_DEFINITION(FLB_EVENT_LOOP_SELECT) + message(STATUS "FLB Event loop backend > select(2)") +elseif (FLB_EVENT_LOOP_LIBEVENT) + MK_SET_OPTION(MK_EVENT_LOOP_LIBEVENT ON) + FLB_DEFINITION(FLB_EVENT_LOOP_LIBEVENT) + message(STATUS "FLB Event loop backend > libevent") +else() + FLB_DEFINITION(FLB_EVENT_LOOP_AUTO_DISCOVERY) + message(STATUS "FLB Event loop backend > auto discovery (Monkey library)") +endif() # Build Monkey HTTP Server if(FLB_HTTP_SERVER) diff --git a/src/flb_scheduler.c b/src/flb_scheduler.c index 01725eb03e8..691aa29d7be 100644 --- a/src/flb_scheduler.c +++ b/src/flb_scheduler.c @@ -26,7 +26,6 @@ #include #include #include - #include #include #include @@ -64,7 +63,8 @@ static inline int consume_byte(flb_pipefd_t fd) /* We need to consume the byte */ ret = flb_pipe_r(fd, &val, sizeof(val)); -#if defined(__APPLE__) || __FreeBSD__ >= 12 +#if defined(FLB_EVENT_LOOP_KQUEUE) || defined(MK_EVENT_LOOP_KQUEUE) +//#if defined(__APPLE__) || __FreeBSD__ >= 12 if (ret < 0) { #else if (ret <= 0) { @@ -291,7 +291,7 @@ int flb_sched_request_create(struct flb_config *config, void *data, int tries) if (config->is_shutting_down) { seconds = 0; } else { - seconds = backoff_full_jitter((int)config->sched_base, (int)config->sched_cap, + seconds = backoff_full_jitter((int)config->sched_base, (int)config->sched_cap, tries); } seconds += 1; @@ -412,7 +412,9 @@ int flb_sched_event_handler(struct flb_config *config, struct mk_event *event) } else if (timer->type == FLB_SCHED_TIMER_FRAME) { sched = timer->data; -#ifndef __APPLE__ + +#if defined(FLB_EVENT_LOOP_KQUEUE) || defined(MK_EVENT_LOOP_KQUEUE) + //#ifndef __APPLE__ consume_byte(sched->frame_fd); #endif schedule_request_promote(sched); @@ -682,7 +684,7 @@ int flb_sched_timer_cleanup(struct flb_sched *sched) return c; } -int flb_sched_retry_now(struct flb_config *config, +int flb_sched_retry_now(struct flb_config *config, struct flb_task_retry *retry) { int ret; @@ -699,7 +701,7 @@ int flb_sched_retry_now(struct flb_config *config, request = flb_malloc(sizeof(struct flb_sched_request)); if (!request) { flb_errno(); - flb_sched_timer_destroy(timer); + flb_sched_timer_destroy(timer); return -1; } diff --git a/tests/internal/flb_event_loop.c b/tests/internal/flb_event_loop.c index faab66e354b..35c98c6e09f 100644 --- a/tests/internal/flb_event_loop.c +++ b/tests/internal/flb_event_loop.c @@ -125,7 +125,7 @@ void evl_context_destroy(struct test_evl_context *ctx) } void test_simple_timeout_1000ms() -{ +{ struct test_evl_context *ctx; struct flb_time start_time; @@ -171,7 +171,7 @@ void test_simple_timeout_1000ms() * Blocking wait with 2.1s timeout: 2.1s, no event */ void test_non_blocking_and_blocking_timeout() -{ +{ struct test_evl_context *ctx; struct mk_event event = {0}; @@ -278,7 +278,7 @@ void test_non_blocking_and_blocking_timeout() * Remove timer */ void test_infinite_wait() -{ +{ struct test_evl_context *ctx; struct mk_event event = {0}; @@ -335,8 +335,8 @@ void synchronize_tests() * verify timers are processed by order of priority and order of activation. Delete also * checked by deleting events in several cases and confirming deleted events are not * processed. - * - * Method: + * + * Method: * Add n_timers / 2 non-delayed timers * delete 1/4th of the non-delayed timers * Wait for non_delayed timers to activate @@ -352,7 +352,7 @@ void synchronize_tests() * Check that deleted events are not processed * Check that non-delayed timers which are tracked first are processed before * non-delayed events. - * + * * Summary: * Track priorities and confirm that all added events were processed * Verify non-delayed timers are triggered before delayed timers @@ -374,7 +374,7 @@ void event_loop_stress_priority_add_delete() int immediate_timers_triggered[EVENT_LOOP_TEST_PRIORITIES] = {0}; int delayed_timers_triggered[EVENT_LOOP_TEST_PRIORITIES] = {0}; - + int priority; int n_events; int target; @@ -414,13 +414,13 @@ void event_loop_stress_priority_add_delete() TEST_CHECK(n_events == n_timers / 2 - n_timers / 8); TEST_MSG("Expected %i ready events from the no delay timers. Recieved %i", n_timers / 2 - n_timers / 8, ret); - + /* Remove the first n/8 events */ for (i = n_timers / 8; i < n_timers / 4; ++i) { test_timeout_destroy(ctx->evl, &events[i]); --immediate_timers[(int) events[i].priority]; } - + i = 0; do { /* variable closure */ flb_event_priority_live_foreach(event, ctx->bktq, ctx->evl, n_timers) { @@ -428,7 +428,7 @@ void event_loop_stress_priority_add_delete() TEST_CHECK(event->priority >= priority_cronology); TEST_MSG("Priority event loop processed events out of order."); priority_cronology = event->priority; - + /* check none of the deleted records appear */ TEST_CHECK(event >= &events[n_timers / 4]); TEST_MSG("Deleted event appeared in priority event loop."); @@ -497,7 +497,7 @@ void event_loop_stress_priority_add_delete() /* first round, delete half of all 0delay timers */ if (j == 0) { - + /* this tests propper removal from bucket queue */ for (i = 0; i < n_timers/4; ++i) { if (&events[i] == event) { From b5eeda516da79b791aa1f34638e6136c5998d698 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Tue, 23 Jul 2024 09:30:19 -0600 Subject: [PATCH 085/295] output_thread: add simple conditional on event handling Signed-off-by: Eduardo Silva --- src/flb_output_thread.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/flb_output_thread.c b/src/flb_output_thread.c index 5fca6be4bf3..cc75e623742 100644 --- a/src/flb_output_thread.c +++ b/src/flb_output_thread.c @@ -249,7 +249,8 @@ static void output_thread(void *data) while (running) { mk_event_wait(th_ins->evl); flb_event_priority_live_foreach(event, th_ins->evl_bktq, th_ins->evl, - FLB_ENGINE_LOOP_MAX_ITER) { + FLB_ENGINE_LOOP_MAX_ITER) { + /* * FIXME * ----- @@ -274,7 +275,6 @@ static void output_thread(void *data) flb_errno(); continue; } - /* * If the address receives 0xdeadbeef, means the thread must * be terminated. @@ -285,16 +285,17 @@ static void output_thread(void *data) thread_id); continue; } - - /* Start the co-routine with the flush callback */ - out_flush = flb_output_flush_create(task, - task->i_ins, - th_ins->ins, - th_ins->config); - if (!out_flush) { - continue; + else { + /* Start the co-routine with the flush callback */ + out_flush = flb_output_flush_create(task, + task->i_ins, + th_ins->ins, + th_ins->config); + if (!out_flush) { + continue; + } + flb_coro_resume(out_flush->coro); } - flb_coro_resume(out_flush->coro); } else if (event->type == FLB_ENGINE_EV_CUSTOM) { event->handler(event); @@ -330,6 +331,7 @@ static void output_thread(void *data) /* Destroy upstream connections from the 'pending destroy list' */ flb_upstream_conn_pending_destroy_list(&th_ins->upstreams); + flb_sched_timer_cleanup(sched); /* Check if we should stop the event loop */ From 8a1d8307b3a83aeab645830e527d895a3383b307 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Sun, 18 Aug 2024 19:23:24 -0600 Subject: [PATCH 086/295] scheduler: new wrapper for timers to consume notification byte Signed-off-by: Eduardo Silva --- src/flb_scheduler.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/flb_scheduler.c b/src/flb_scheduler.c index 691aa29d7be..4bc88c272c1 100644 --- a/src/flb_scheduler.c +++ b/src/flb_scheduler.c @@ -63,8 +63,9 @@ static inline int consume_byte(flb_pipefd_t fd) /* We need to consume the byte */ ret = flb_pipe_r(fd, &val, sizeof(val)); -#if defined(FLB_EVENT_LOOP_KQUEUE) || defined(MK_EVENT_LOOP_KQUEUE) -//#if defined(__APPLE__) || __FreeBSD__ >= 12 + + /* ref: https://github.com/fluent/fluent-bit/pull/2463 */ +#if defined(__APPLE__) || __FreeBSD__ >= 12 if (ret < 0) { #else if (ret <= 0) { @@ -384,6 +385,23 @@ int flb_sched_request_invalidate(struct flb_config *config, void *data) return -1; } +/* + * Depending on the backend that provides the timer, most of the time except + * on event loops based on 'kqueue', we need to read the notification byte, which + * usually comes from a file descriptor registered through the backend based on + * epoll(), select() or poll(). + * + * If we are NOT using kequeue, just read(2) the byte. + */ +static inline int timer_consume_byte(int fd) +{ +#ifndef FLB_EVENT_LOOP_KQUEUE + return consume_byte(fd); +#endif + + return 0; +} + /* Handle a timeout event set by a previous flb_sched_request_create(...) */ int flb_sched_event_handler(struct flb_config *config, struct mk_event *event) { @@ -412,21 +430,17 @@ int flb_sched_event_handler(struct flb_config *config, struct mk_event *event) } else if (timer->type == FLB_SCHED_TIMER_FRAME) { sched = timer->data; - -#if defined(FLB_EVENT_LOOP_KQUEUE) || defined(MK_EVENT_LOOP_KQUEUE) - //#ifndef __APPLE__ - consume_byte(sched->frame_fd); -#endif + timer_consume_byte(sched->frame_fd); schedule_request_promote(sched); } else if (timer->type == FLB_SCHED_TIMER_CB_ONESHOT) { - consume_byte(timer->timer_fd); + timer_consume_byte(timer->timer_fd); flb_sched_timer_cb_disable(timer); timer->cb(config, timer->data); flb_sched_timer_cb_destroy(timer); } else if (timer->type == FLB_SCHED_TIMER_CB_PERM) { - consume_byte(timer->timer_fd); + timer_consume_byte(timer->timer_fd); timer->cb(config, timer->data); } From 4ac5b7b4214b79c1f550c3e634e2dcf46d26f212 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Tue, 20 Aug 2024 16:33:33 +0900 Subject: [PATCH 087/295] in_emitter: Plug a possible resource leak on exception (CID 508193) Signed-off-by: Hiroshi Hatake --- plugins/in_emitter/emitter.c | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/in_emitter/emitter.c b/plugins/in_emitter/emitter.c index 6d37219befa..064415e807a 100644 --- a/plugins/in_emitter/emitter.c +++ b/plugins/in_emitter/emitter.c @@ -312,6 +312,7 @@ static int cb_emitter_init(struct flb_input_instance *in, ret = flb_input_config_map_set(in, (void *) ctx); if (ret == -1) { + flb_free(ctx); return -1; } From 6270d01f6645f89cb65596562a97977f2d13f9fe Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 21 Aug 2024 14:50:15 +0200 Subject: [PATCH 088/295] filter_logs_to_metrics: fixed memory corruption issue Signed-off-by: Leonardo Alminana --- plugins/filter_log_to_metrics/log_to_metrics.c | 17 ++++++++++------- plugins/filter_log_to_metrics/log_to_metrics.h | 1 + 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/plugins/filter_log_to_metrics/log_to_metrics.c b/plugins/filter_log_to_metrics/log_to_metrics.c index e6c173f6794..0f1370166b8 100644 --- a/plugins/filter_log_to_metrics/log_to_metrics.c +++ b/plugins/filter_log_to_metrics/log_to_metrics.c @@ -463,6 +463,7 @@ static int cb_log_to_metrics_init(struct flb_filter_instance *f_ins, char value_field[MAX_METRIC_LENGTH]; struct flb_input_instance *input_ins; + int i; /* Create context */ ctx = flb_calloc(1, sizeof(struct log_to_metrics_ctx)); @@ -551,15 +552,17 @@ static int cb_log_to_metrics_init(struct flb_filter_instance *f_ins, /* Check property metric mode */ ctx->mode = 0; - tmp = (char *) flb_filter_get_property("metric_mode", f_ins); - if (tmp != NULL) { - if (strcasecmp(tmp, FLB_LOG_TO_METRICS_COUNTER_STR) == 0) { + if (ctx->mode_name != NULL) { + if (strcasecmp(ctx->mode_name, + FLB_LOG_TO_METRICS_COUNTER_STR) == 0) { ctx->mode = FLB_LOG_TO_METRICS_COUNTER; } - else if (strcasecmp(tmp, FLB_LOG_TO_METRICS_GAUGE_STR) == 0) { + else if (strcasecmp(ctx->mode_name, + FLB_LOG_TO_METRICS_GAUGE_STR) == 0) { ctx->mode = FLB_LOG_TO_METRICS_GAUGE; } - else if (strcasecmp(tmp, FLB_LOG_TO_METRICS_HISTOGRAM_STR) == 0) { + else if (strcasecmp(ctx->mode_name, + FLB_LOG_TO_METRICS_HISTOGRAM_STR) == 0) { ctx->mode = FLB_LOG_TO_METRICS_HISTOGRAM; } else { @@ -589,7 +592,7 @@ static int cb_log_to_metrics_init(struct flb_filter_instance *f_ins, /* Check property subsystem name */ if (ctx->metric_subsystem == NULL || strlen(ctx->metric_subsystem) == 0) { snprintf(metric_subsystem, sizeof(metric_subsystem) - 1, "%s", - tmp); + ctx->mode_name); } else { snprintf(metric_subsystem, sizeof(metric_subsystem) - 1, "%s", @@ -977,7 +980,7 @@ static struct flb_config_map config_map[] = { }, { FLB_CONFIG_MAP_STR, "metric_mode", "counter", - 0, FLB_TRUE, offsetof(struct log_to_metrics_ctx, mode), + 0, FLB_TRUE, offsetof(struct log_to_metrics_ctx, mode_name), "Mode selector. Values counter, gauge," " or histogram. Summary is not supported" }, diff --git a/plugins/filter_log_to_metrics/log_to_metrics.h b/plugins/filter_log_to_metrics/log_to_metrics.h index 77ad06ece5e..ae5b822c554 100644 --- a/plugins/filter_log_to_metrics/log_to_metrics.h +++ b/plugins/filter_log_to_metrics/log_to_metrics.h @@ -73,6 +73,7 @@ struct log_to_metrics_ctx { /* config options */ int mode; + flb_sds_t mode_name; int discard_logs; int kubernetes_mode; flb_sds_t metric_name; From e87c26df62e5e6e4b88d5751f81000c5bf7067d1 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 21 Aug 2024 15:55:35 +0200 Subject: [PATCH 089/295] upstream_ht: added environment variable support Signed-off-by: Leonardo Alminana --- src/flb_upstream_ha.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/flb_upstream_ha.c b/src/flb_upstream_ha.c index 7856bf3df14..4d7928214f9 100644 --- a/src/flb_upstream_ha.c +++ b/src/flb_upstream_ha.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -108,6 +109,20 @@ struct flb_upstream_node *flb_upstream_ha_node_get(struct flb_upstream_ha *ctx) return node; } +static inline void translate_environment_variables(flb_sds_t *value, struct + flb_config *config) +{ + flb_sds_t result; + + result = flb_env_var_translate(config->env, *value); + + if (result != NULL) { + flb_sds_destroy(*value); + + *value = (flb_sds_t) result; + } +} + static struct flb_upstream_node *create_node(int id, struct flb_cf *cf, struct flb_cf_section *s, @@ -214,6 +229,16 @@ static struct flb_upstream_node *create_node(int id, /* tls.key_file */ tls_key_passwd = flb_cf_section_property_get_string(cf, s, "tls.key_passwd"); + translate_environment_variables((flb_sds_t *) &name, config); + translate_environment_variables((flb_sds_t *) &host, config); + translate_environment_variables((flb_sds_t *) &port, config); + translate_environment_variables((flb_sds_t *) &tls_vhost, config); + translate_environment_variables((flb_sds_t *) &tls_ca_path, config); + translate_environment_variables((flb_sds_t *) &tls_ca_file, config); + translate_environment_variables((flb_sds_t *) &tls_crt_file, config); + translate_environment_variables((flb_sds_t *) &tls_key_file, config); + translate_environment_variables((flb_sds_t *) &tls_key_passwd, config); + /* * Create hash table to store unknown key/values that might be used * by the caller plugin. From d25efca8e48e40961258edda7fe817fe1a190b85 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 21 Aug 2024 20:48:18 +0200 Subject: [PATCH 090/295] upstream_ht: added support for inherited property lookup Signed-off-by: Leonardo Alminana --- src/flb_upstream_ha.c | 61 +++++++++++++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 14 deletions(-) diff --git a/src/flb_upstream_ha.c b/src/flb_upstream_ha.c index 4d7928214f9..62c6b3db956 100644 --- a/src/flb_upstream_ha.c +++ b/src/flb_upstream_ha.c @@ -109,18 +109,23 @@ struct flb_upstream_node *flb_upstream_ha_node_get(struct flb_upstream_ha *ctx) return node; } -static inline void translate_environment_variables(flb_sds_t *value, struct - flb_config *config) +static inline flb_sds_t translate_environment_variables(flb_sds_t *value, + struct flb_config *config, + int in_place_operation) { flb_sds_t result; result = flb_env_var_translate(config->env, *value); if (result != NULL) { - flb_sds_destroy(*value); + if (in_place_operation) { + flb_sds_destroy(*value); - *value = (flb_sds_t) result; + *value = (flb_sds_t) result; + } } + + return result; } static struct flb_upstream_node *create_node(int id, @@ -148,6 +153,7 @@ static struct flb_upstream_node *create_node(int id, char *tls_crt_file = NULL; char *tls_key_file = NULL; char *tls_key_passwd = NULL; + flb_sds_t translated_value; struct cfl_list *head; struct cfl_kvpair *entry; struct flb_hash_table *ht; @@ -229,15 +235,15 @@ static struct flb_upstream_node *create_node(int id, /* tls.key_file */ tls_key_passwd = flb_cf_section_property_get_string(cf, s, "tls.key_passwd"); - translate_environment_variables((flb_sds_t *) &name, config); - translate_environment_variables((flb_sds_t *) &host, config); - translate_environment_variables((flb_sds_t *) &port, config); - translate_environment_variables((flb_sds_t *) &tls_vhost, config); - translate_environment_variables((flb_sds_t *) &tls_ca_path, config); - translate_environment_variables((flb_sds_t *) &tls_ca_file, config); - translate_environment_variables((flb_sds_t *) &tls_crt_file, config); - translate_environment_variables((flb_sds_t *) &tls_key_file, config); - translate_environment_variables((flb_sds_t *) &tls_key_passwd, config); + translate_environment_variables((flb_sds_t *) &name, config, FLB_TRUE); + translate_environment_variables((flb_sds_t *) &host, config, FLB_TRUE); + translate_environment_variables((flb_sds_t *) &port, config, FLB_TRUE); + translate_environment_variables((flb_sds_t *) &tls_vhost, config, FLB_TRUE); + translate_environment_variables((flb_sds_t *) &tls_ca_path, config, FLB_TRUE); + translate_environment_variables((flb_sds_t *) &tls_ca_file, config, FLB_TRUE); + translate_environment_variables((flb_sds_t *) &tls_crt_file, config, FLB_TRUE); + translate_environment_variables((flb_sds_t *) &tls_key_file, config, FLB_TRUE); + translate_environment_variables((flb_sds_t *) &tls_key_passwd, config, FLB_TRUE); /* * Create hash table to store unknown key/values that might be used @@ -277,12 +283,39 @@ static struct flb_upstream_node *create_node(int id, } key[klen] = '\0'; + translated_value = translate_environment_variables( + (flb_sds_t *) &entry->val->data.as_string, + config, + FLB_FALSE); + + if (translated_value == NULL) { + flb_error("[upstream_ha] cannot perform environment variable " + "lookup for key %s", + entry->key); + flb_hash_table_destroy(ht); + + return NULL; + } + vlen = flb_sds_len(translated_value); + + /* We need to ensure that vlen is larger than zero in order for + * to store a copy of the value instead of a reference but this + * is not a problem because flb_sds_t instances always have at + * least the NULL terminator byte. + */ + + if (vlen == 0) { + vlen = 1; + } + /* Add the key and value to the hash table */ - ret = flb_hash_table_add(ht, key, klen, entry->val->data.as_string, vlen); + ret = flb_hash_table_add(ht, key, klen, translated_value, vlen); if (ret == -1) { flb_error("[upstream_ha] cannot add key %s to hash table", entry->key); } + + flb_sds_destroy(translated_value); } node = flb_upstream_node_create(name, host, port, tls, tls_verify, From 92f631f6079066d9371e3bf4a21a3086f4bf2687 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 21 Aug 2024 14:53:50 +0200 Subject: [PATCH 091/295] core: fixed the data type used for booleans Signed-off-by: Leonardo Alminana --- include/fluent-bit/flb_config_map.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fluent-bit/flb_config_map.h b/include/fluent-bit/flb_config_map.h index 8ca3c1eb42e..a41db3e4424 100644 --- a/include/fluent-bit/flb_config_map.h +++ b/include/fluent-bit/flb_config_map.h @@ -55,7 +55,7 @@ struct flb_config_map_val { union { int i_num; /* FLB_CONFIG_MAP_INT */ - char boolean; /* FLB_CONFIG_MAP_BOOL */ + int boolean; /* FLB_CONFIG_MAP_BOOL */ double d_num; /* FLB_CONFIG_MAP_DOUBLE */ size_t s_num; /* FLB_CONFIG_MAP_SIZE */ flb_sds_t str; /* FLB_CONFIG_MAP_STR */ From 05a7e3a220a77c81134b8ab14669e7a9b702a4fd Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Wed, 14 Aug 2024 18:45:34 +0900 Subject: [PATCH 092/295] in_winevtlog: Skip to translate SID for capability SIDs Signed-off-by: Hiroshi Hatake --- plugins/in_winevtlog/pack.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/in_winevtlog/pack.c b/plugins/in_winevtlog/pack.c index 97dacce822e..c9b65a01f18 100644 --- a/plugins/in_winevtlog/pack.c +++ b/plugins/in_winevtlog/pack.c @@ -277,6 +277,14 @@ static int pack_sid(struct winevtlog_config *ctx, PSID sid, int extract_sid) if (ConvertSidToStringSidW(sid, &wide_sid)) { if (extract_sid == FLB_TRUE) { + /* Skip to translate SID for capability SIDs. + * see also: https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-security-identifiers + */ + if (wcsnicmp(wide_sid, L"S-1-15-3-", 9) == 0) { + flb_plg_debug(ctx->ins, "This SID is one of the capability SIDs. Skip."); + + goto not_mapped_error; + } if (!LookupAccountSidA(NULL, sid, account, &len, domain, &len, &sid_type)) { From 839c963c7f8677f90a7fcaaa8ecabfc75a1eb7b9 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Mon, 19 Aug 2024 14:17:16 +0900 Subject: [PATCH 093/295] in_winevtlog: Add a describing link for capability SIDs Signed-off-by: Hiroshi Hatake --- plugins/in_winevtlog/pack.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/in_winevtlog/pack.c b/plugins/in_winevtlog/pack.c index c9b65a01f18..9242da6811c 100644 --- a/plugins/in_winevtlog/pack.c +++ b/plugins/in_winevtlog/pack.c @@ -278,7 +278,8 @@ static int pack_sid(struct winevtlog_config *ctx, PSID sid, int extract_sid) if (ConvertSidToStringSidW(sid, &wide_sid)) { if (extract_sid == FLB_TRUE) { /* Skip to translate SID for capability SIDs. - * see also: https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-security-identifiers + * ref: https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-security-identifiers + * See also: https://learn.microsoft.com/en-us/troubleshoot/windows-server/windows-security/sids-not-resolve-into-friendly-names */ if (wcsnicmp(wide_sid, L"S-1-15-3-", 9) == 0) { flb_plg_debug(ctx->ins, "This SID is one of the capability SIDs. Skip."); From 0bbd78dfad9e64f129c6a29dd8e766b23ac0707a Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 21 Aug 2024 16:16:10 +0200 Subject: [PATCH 094/295] build: added cpu byte order detection (same as msgpack-c) Signed-off-by: Leonardo Alminana --- CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2018e4f52c9..e2e9fbf3b04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,6 +88,7 @@ elseif(FLB_SYSTEM_FREEBSD) set(WAMR_DISABLE_STACK_HW_BOUND_CHECK 1) endif() +INCLUDE(TestBigEndian) include(GNUInstallDirs) include(ExternalProject) include(cmake/FindJournald.cmake) @@ -772,6 +773,15 @@ if(FLB_HAVE_UNIX_SOCKET) FLB_DEFINITION(FLB_HAVE_UNIX_SOCKET) endif() +# byte order detection +test_big_endian(BIG_ENDIAN_SYSTEM_DETECTED) + +if (BIG_ENDIAN_SYSTEM_DETECTED) + FLB_DEFINITION(FLB_HAVE_BIG_ENDIAN_SYSTEM) +else() + FLB_DEFINITION(FLB_HAVE_LITTLE_ENDIAN_SYSTEM) +endif () + # Configuration file YAML format support if(FLB_CONFIG_YAML) find_package(PkgConfig) From ee797abf0b0145e3e4182be2321fba62a0793b93 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 21 Aug 2024 16:16:49 +0200 Subject: [PATCH 095/295] core: replaced buggy cpu byte order detection with a reliable mechanism Signed-off-by: Leonardo Alminana --- include/fluent-bit/flb_endian.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/fluent-bit/flb_endian.h b/include/fluent-bit/flb_endian.h index b376ea84235..da21aef2b6e 100644 --- a/include/fluent-bit/flb_endian.h +++ b/include/fluent-bit/flb_endian.h @@ -55,9 +55,7 @@ #define FLB_BIG_ENDIAN 1 #ifndef FLB_BYTE_ORDER - #if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ - #define FLB_BYTE_ORDER FLB_BIG_ENDIAN - #elif defined(__BIG_ENDIAN__) || defined(__BIG_ENDIAN) || defined(_BIG_ENDIAN) + #ifdef FLB_HAVE_BIG_ENDIAN_SYSTEM #define FLB_BYTE_ORDER FLB_BIG_ENDIAN #else #define FLB_BYTE_ORDER FLB_LITTLE_ENDIAN From 4427d42554c565171a775f18df397d87d894c9fb Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Thu, 22 Aug 2024 18:52:55 +0900 Subject: [PATCH 096/295] in_process_exporter_metrics: Initialize with NULL for flb_sds_t pointer variables (CID 507975) Signed-off-by: Hiroshi Hatake --- .../in_process_exporter_metrics/pe_process.c | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/plugins/in_process_exporter_metrics/pe_process.c b/plugins/in_process_exporter_metrics/pe_process.c index 529971cda4d..87a4b42d486 100644 --- a/plugins/in_process_exporter_metrics/pe_process.c +++ b/plugins/in_process_exporter_metrics/pe_process.c @@ -276,7 +276,7 @@ static void reset_proc_state(struct proc_state *state) { static int check_path_for_proc(struct flb_pe *ctx, const char *prefix, const char *path) { int len; - flb_sds_t p; + flb_sds_t p = NULL; /* Compose the proc path */ p = flb_sds_create(prefix); @@ -303,8 +303,8 @@ static int check_path_for_proc(struct flb_pe *ctx, const char *prefix, const cha static int get_name(const char *entry, char **out_name, char *id_entry) { - flb_sds_t tmp; - flb_sds_t tmp_name; + flb_sds_t tmp = NULL; + flb_sds_t tmp_name = NULL; tmp = strdup(entry); tmp_name = strtok(tmp, ")"); @@ -324,8 +324,8 @@ static int process_proc_thread_io(struct flb_pe *ctx, uint64_t ts, struct flb_slist_entry *thread) { int ret; - flb_sds_t tmp; - flb_sds_t status; + flb_sds_t tmp = NULL; + flb_sds_t status = NULL; uint64_t val; struct mk_list io_list; struct mk_list *ihead; @@ -382,9 +382,9 @@ static int process_proc_thread_status(struct flb_pe *ctx, uint64_t ts, struct flb_slist_entry *thread) { int ret; - flb_sds_t tmp; - flb_sds_t name; - flb_sds_t status; + flb_sds_t tmp = NULL; + flb_sds_t name = NULL; + flb_sds_t status = NULL; uint64_t val; struct mk_list status_list; struct mk_list *shead; @@ -481,9 +481,9 @@ static int process_proc_thread_status(struct flb_pe *ctx, uint64_t ts, static int process_thread_update(struct flb_pe *ctx, uint64_t ts, flb_sds_t pid, flb_sds_t name) { int ret; - flb_sds_t tmp; - flb_sds_t thread_name; - flb_sds_t tid_str; + flb_sds_t tmp = NULL; + flb_sds_t thread_name = NULL; + flb_sds_t tid_str = NULL; uint64_t val; const char *pattern = "/[0-9]*"; struct mk_list *head; @@ -648,8 +648,8 @@ static int process_proc_io(struct flb_pe *ctx, uint64_t ts, struct flb_slist_entry *process) { int ret; - flb_sds_t tmp; - flb_sds_t status; + flb_sds_t tmp = NULL; + flb_sds_t status = NULL; uint64_t val; struct mk_list io_list; struct mk_list *ihead; @@ -784,9 +784,9 @@ static int process_proc_fds(struct flb_pe *ctx, uint64_t ts, static int process_proc_status(struct flb_pe *ctx, uint64_t ts, flb_sds_t pid, struct flb_slist_entry *process) { int ret; - flb_sds_t tmp; - flb_sds_t name; - flb_sds_t status; + flb_sds_t tmp = NULL; + flb_sds_t name = NULL; + flb_sds_t status = NULL; uint64_t val; struct mk_list status_list; struct mk_list *shead; @@ -881,8 +881,8 @@ static int process_proc_status(struct flb_pe *ctx, uint64_t ts, flb_sds_t pid, s static int process_proc_boot_time(struct flb_pe *ctx, uint64_t *out_boot_time) { int ret; - flb_sds_t tmp; - flb_sds_t status; + flb_sds_t tmp = NULL; + flb_sds_t status = NULL; uint64_t val; struct mk_list stat_list; struct mk_list *rshead; @@ -923,12 +923,12 @@ static int process_proc_boot_time(struct flb_pe *ctx, uint64_t *out_boot_time) static int process_update(struct flb_pe *ctx) { int ret; - flb_sds_t tmp; - flb_sds_t name; - flb_sds_t pid_str; - flb_sds_t state_str; - flb_sds_t ppid_str; - flb_sds_t thread_str; + flb_sds_t tmp = NULL; + flb_sds_t name = NULL; + flb_sds_t pid_str = NULL; + flb_sds_t state_str = NULL; + flb_sds_t ppid_str = NULL; + flb_sds_t thread_str = NULL; struct mk_list *head; struct mk_list *ehead; struct mk_list procfs_list; From 13ac2889f7a7e8fcbe25aa198ec16687e19e7a3f Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Mon, 26 Aug 2024 19:06:39 +0900 Subject: [PATCH 097/295] output: Remove a needless calling of flb_output_instance_destroy() (CID 507809) Signed-off-by: Hiroshi Hatake --- src/flb_output.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/flb_output.c b/src/flb_output.c index 1c7853f79f1..0c9a7cc1333 100644 --- a/src/flb_output.c +++ b/src/flb_output.c @@ -1044,7 +1044,6 @@ int flb_output_plugin_property_check(struct flb_output_instance *ins, if (!config_map) { flb_error("[output] error loading config map for '%s' plugin", p->name); - flb_output_instance_destroy(ins); return -1; } ins->config_map = config_map; From 643885da81d09c5ffd1b44815c07126515437df5 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 26 Aug 2024 14:52:39 -0600 Subject: [PATCH 098/295] in_forward: rel resources on exception (CID 507596 507786 507954 508064 508123) Signed-off-by: Eduardo Silva --- plugins/in_forward/fw_prot.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/in_forward/fw_prot.c b/plugins/in_forward/fw_prot.c index 9ad28318066..1949f254f60 100644 --- a/plugins/in_forward/fw_prot.c +++ b/plugins/in_forward/fw_prot.c @@ -620,6 +620,7 @@ static int check_ping(struct flb_input_instance *ins, if (o.type != MSGPACK_OBJECT_STR) { flb_plg_error(ins, "Invalid username type message"); flb_free(serverside); + flb_free(hostname); msgpack_unpacked_destroy(&result); return -1; } @@ -631,6 +632,8 @@ static int check_ping(struct flb_input_instance *ins, flb_plg_error(ins, "Invalid password_digest type message"); flb_free(serverside); flb_free(hostname); + flb_free(shared_key_salt); + flb_free(shared_key_digest); msgpack_unpacked_destroy(&result); return -1; } @@ -643,6 +646,8 @@ static int check_ping(struct flb_input_instance *ins, shared_key_salt, hostname, hostname_len, serverside, 128)) { flb_free(serverside); + flb_free(username); + flb_free(password_digest); flb_plg_error(ctx->ins, "failed to hash shard_key"); return -1; } From 671caecb8e296f3a76641be4ded608334100aa5c Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 26 Aug 2024 14:55:26 -0600 Subject: [PATCH 099/295] regex: check return of strchr (CID 507956) Signed-off-by: Eduardo Silva --- src/flb_regex.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/flb_regex.c b/src/flb_regex.c index 7c33afc08f8..94a878b1bc3 100644 --- a/src/flb_regex.c +++ b/src/flb_regex.c @@ -64,12 +64,18 @@ static OnigOptionType check_option(const char *start, const char *end, char **ne if (start == NULL || end == NULL || new_end == NULL) { return ONIG_OPTION_DEFAULT; - } else if (start[0] != '/') { + } + else if (start[0] != '/') { *new_end = NULL; return ONIG_OPTION_DEFAULT; } chr = strrchr(start, '/'); + if (!chr) { + *new_end = NULL; + return ONIG_OPTION_DEFAULT; + } + if (chr == start || chr == end) { *new_end = NULL; return ONIG_OPTION_DEFAULT; From 5ec5079acdb857c608dd58fb743dbb3180b8dfea Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 26 Aug 2024 15:06:07 -0600 Subject: [PATCH 100/295] out_opentelemetry: on proxy config check status Signed-off-by: Eduardo Silva --- .../out_opentelemetry/opentelemetry_conf.c | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/plugins/out_opentelemetry/opentelemetry_conf.c b/plugins/out_opentelemetry/opentelemetry_conf.c index 9a8a17df9fc..ec44ca02e37 100644 --- a/plugins/out_opentelemetry/opentelemetry_conf.c +++ b/plugins/out_opentelemetry/opentelemetry_conf.c @@ -183,19 +183,21 @@ static int config_add_labels(struct flb_output_instance *ins, * it can adjust the HTTP requests. */ -static void check_proxy(struct flb_output_instance *ins, - struct opentelemetry_context *ctx, - char *host, char *port, - char *protocol, char *uri){ +static int check_proxy(struct flb_output_instance *ins, + struct opentelemetry_context *ctx, + char *host, char *port, + char *protocol, char *uri) +{ - const char *tmp = NULL; int ret; + const char *tmp = NULL; + tmp = flb_output_get_property("proxy", ins); if (tmp) { ret = flb_utils_url_split(tmp, &protocol, &host, &port, &uri); if (ret == -1) { flb_plg_error(ctx->ins, "could not parse proxy parameter: '%s'", tmp); - flb_free(ctx); + return -1; } ctx->proxy_host = host; @@ -209,9 +211,12 @@ static void check_proxy(struct flb_output_instance *ins, else { flb_output_net_default("127.0.0.1", 80, ins); } + + return 0; } -static char *sanitize_uri(char *uri){ +static char *sanitize_uri(char *uri) +{ char *new_uri; int uri_len; @@ -272,9 +277,17 @@ struct opentelemetry_context *flb_opentelemetry_context_create(struct flb_output return NULL; } + ret = check_proxy(ins, ctx, host, port, protocol, metrics_uri); + if (ret == -1) { + flb_opentelemetry_context_destroy(ctx); + return NULL; + } - check_proxy(ins, ctx, host, port, protocol, metrics_uri); - check_proxy(ins, ctx, host, port, protocol, logs_uri); + ret = check_proxy(ins, ctx, host, port, protocol, logs_uri); + if (ret == -1) { + flb_opentelemetry_context_destroy(ctx); + return NULL; + } /* Check if SSL/TLS is enabled */ #ifdef FLB_HAVE_TLS From bcf1b90390116ec0ea0e5620ec8a74e69e19eea3 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 26 Aug 2024 15:06:45 -0600 Subject: [PATCH 101/295] out_chronicle: use flb_sds_cat_safe (CID 507603) Signed-off-by: Eduardo Silva --- plugins/out_chronicle/chronicle.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/out_chronicle/chronicle.c b/plugins/out_chronicle/chronicle.c index a8fab08eacd..650fb3a4d06 100644 --- a/plugins/out_chronicle/chronicle.c +++ b/plugins/out_chronicle/chronicle.c @@ -121,8 +121,8 @@ static int chronicle_jwt_encode(struct flb_chronicle *ctx, } /* Append header */ - flb_sds_cat(out, buf, olen); - flb_sds_cat(out, ".", 1); + flb_sds_cat_safe(&out, buf, olen); + flb_sds_cat_safe(&out, ".", 1); /* Encode Payload */ len = strlen(payload); @@ -130,7 +130,7 @@ static int chronicle_jwt_encode(struct flb_chronicle *ctx, (unsigned char *) payload, len, &olen); /* Append Payload */ - flb_sds_cat(out, buf, olen); + flb_sds_cat_safe(&out, buf, olen); /* do sha256() of base64(header).base64(payload) */ ret = flb_hash_simple(FLB_HASH_SHA256, @@ -171,8 +171,8 @@ static int chronicle_jwt_encode(struct flb_chronicle *ctx, chronicle_jwt_base64_url_encode((unsigned char *) sigd, 2048, sig, 256, &olen); - flb_sds_cat(out, ".", 1); - flb_sds_cat(out, sigd, olen); + flb_sds_cat_safe(&out, ".", 1); + flb_sds_cat_safe(&out, sigd, olen); *out_signature = out; *out_size = flb_sds_len(out); From 39abbdff0ee0dc4f8a7fdf4c3e4a34992a655bbd Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 26 Aug 2024 15:12:27 -0600 Subject: [PATCH 102/295] processor_content_modifier: logs: do not remove object on type excepcion (CID 507615) Signed-off-by: Eduardo Silva --- plugins/processor_content_modifier/cm_logs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/processor_content_modifier/cm_logs.c b/plugins/processor_content_modifier/cm_logs.c index 0f20d124bad..278540039b5 100644 --- a/plugins/processor_content_modifier/cm_logs.c +++ b/plugins/processor_content_modifier/cm_logs.c @@ -796,8 +796,8 @@ int cm_logs_process(struct flb_processor_instance *ins, /* the operation on top of the data type is unsupported */ if (obj->variant->type != CFL_VARIANT_KVLIST) { - cfl_object_destroy(obj); - return -1; + flb_plg_error(ctx->ins, "unsupported data type for context"); + return FLB_PROCESSOR_FAILURE; } /* process the action */ From 3178e6ea22cb8c74238acd8e298d1f3577618c0a Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 26 Aug 2024 15:15:38 -0600 Subject: [PATCH 103/295] aws_util: release resource on exception (CID 507694 507588) Signed-off-by: Eduardo Silva --- src/aws/flb_aws_util.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/aws/flb_aws_util.c b/src/aws/flb_aws_util.c index 6ddd75b82d9..22862ba3cb1 100644 --- a/src/aws/flb_aws_util.c +++ b/src/aws/flb_aws_util.c @@ -1029,6 +1029,8 @@ size_t flb_aws_strftime_precision(char **out_buf, const char *time_format, tmp = gmtime_r(&tms->tm.tv_sec, ×tamp); if (!tmp) { + flb_free(tmp_parsed_time_str); + flb_free(buf); return 0; } From 0434f95c6d4a4b11b6731a6c1d273ca79a0763ea Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 26 Aug 2024 15:17:29 -0600 Subject: [PATCH 104/295] aws: release resource on exception (CID 508048) Signed-off-by: Eduardo Silva --- src/aws/flb_aws_compress.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/aws/flb_aws_compress.c b/src/aws/flb_aws_compress.c index e98ce8318c3..a06d181193f 100644 --- a/src/aws/flb_aws_compress.c +++ b/src/aws/flb_aws_compress.c @@ -90,7 +90,7 @@ int flb_aws_compression_compress(int compression_type, void *in_data, size_t in_ } ++o; } - + flb_error("[aws_compress] invalid compression type: %i", compression_type); flb_errno(); return -1; @@ -169,7 +169,7 @@ int flb_aws_compression_b64_truncate_compress(int compression_type, size_t max_o "large"); return -1; } - + /* Calculate corrected input size */ truncated_in_len_prev = truncated_in_len; truncated_in_len = (max_out_len * truncated_in_len) / b64_compressed_len; @@ -179,7 +179,7 @@ int flb_aws_compression_b64_truncate_compress(int compression_type, size_t max_o if (truncated_in_len >= truncated_in_len_prev) { truncated_in_len = truncated_in_len_prev - 1; } - + /* Allocate truncation buffer */ if (!is_truncated) { is_truncated = FLB_TRUE; @@ -225,6 +225,7 @@ int flb_aws_compression_b64_truncate_compress(int compression_type, size_t max_o if (ret == FLB_BASE64_ERR_BUFFER_TOO_SMALL) { flb_error("[aws_compress] compressed log base64 buffer too small"); + flb_free(b64_compressed_buf); return -1; /* not handle truncation at this point */ } if (ret != 0) { From 3de54d98be0c53824402d9da7c5002e26e33aa20 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 26 Aug 2024 15:33:11 -0600 Subject: [PATCH 105/295] in_forward: release resource on exception (CID 508219) Signed-off-by: Eduardo Silva --- plugins/in_forward/fw_conn.c | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/in_forward/fw_conn.c b/plugins/in_forward/fw_conn.c index 45862f1eced..94465256628 100644 --- a/plugins/in_forward/fw_conn.c +++ b/plugins/in_forward/fw_conn.c @@ -147,6 +147,7 @@ struct fw_conn *fw_conn_add(struct flb_connection *connection, struct flb_in_fw_ helo = flb_malloc(sizeof(struct flb_in_fw_helo)); if (!helo) { flb_errno(); + flb_free(conn); return NULL; } From 4c9b51042f50fb0731ae78fd4259be5521d77fad Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 26 Aug 2024 16:47:37 -0600 Subject: [PATCH 106/295] in_docker: release resource on exception (CID 507574) Signed-off-by: Eduardo Silva --- plugins/in_docker/cgroup_v2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/in_docker/cgroup_v2.c b/plugins/in_docker/cgroup_v2.c index 2844e1319bd..295483cd259 100644 --- a/plugins/in_docker/cgroup_v2.c +++ b/plugins/in_docker/cgroup_v2.c @@ -328,6 +328,7 @@ static cpu_snapshot *get_docker_cpu_snapshot(struct flb_docker *ctx, char *id) flb_plg_error(ctx->ins, "error scanning used CPU value from %s with key = %s", usage_file, DOCKER_CGROUP_V2_CPU_USAGE_KEY); flb_free(usage_file); + flb_free(line); fclose(f); return NULL; } From 63f240c3dcb4d53a47075709090396b96f4e45d7 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 26 Aug 2024 16:58:50 -0600 Subject: [PATCH 107/295] filter_kubernetes: fix data type for token creation (CID 507947) Signed-off-by: Eduardo Silva --- plugins/filter_kubernetes/kube_conf.h | 5 +-- plugins/filter_kubernetes/kube_meta.c | 52 +++++++++++++-------------- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/plugins/filter_kubernetes/kube_conf.h b/plugins/filter_kubernetes/kube_conf.h index 3c044b8970b..50219330cd8 100644 --- a/plugins/filter_kubernetes/kube_conf.h +++ b/plugins/filter_kubernetes/kube_conf.h @@ -144,9 +144,10 @@ struct flb_kube { char *token_file; char *token; size_t token_len; + /* Command to get Kubernetes Authorization Token */ - const char *kube_token_command; - int kube_token_create; + const char *kube_token_command; + time_t kube_token_create; /* Pre-formatted HTTP Authorization header value */ char *auth; diff --git a/plugins/filter_kubernetes/kube_meta.c b/plugins/filter_kubernetes/kube_meta.c index 91417a1a3db..42390268d73 100644 --- a/plugins/filter_kubernetes/kube_meta.c +++ b/plugins/filter_kubernetes/kube_meta.c @@ -90,7 +90,7 @@ static int file_to_buffer(const char *path, #ifdef FLB_HAVE_KUBE_TOKEN_COMMAND /* Run command to get Kubernetes authorization token */ -static int get_token_with_command(const char *command, +static int get_token_with_command(const char *command, char **out_buf, size_t *out_size) { FILE *fp; @@ -111,7 +111,7 @@ static int get_token_with_command(const char *command, pclose(fp); return -1; } - + while (fgets(buf, sizeof(buf), fp) != NULL) { len = strlen(buf); if (len >= FLB_KUBE_TOKEN_BUF_SIZE - 1) { @@ -133,7 +133,7 @@ static int get_token_with_command(const char *command, pclose(fp); return -1; } - + pclose(fp); *out_buf = res; @@ -141,16 +141,16 @@ static int get_token_with_command(const char *command, return 0; } -#endif +#endif /* Set K8s Authorization Token and get HTTP Auth Header */ -static int get_http_auth_header(struct flb_kube *ctx) +static int get_http_auth_header(struct flb_kube *ctx) { int ret; char *temp; char *tk = NULL; size_t tk_size = 0; - + if (ctx->kube_token_command != NULL) { #ifdef FLB_HAVE_KUBE_TOKEN_COMMAND ret = get_token_with_command(ctx->kube_token_command, &tk, &tk_size); @@ -187,17 +187,17 @@ static int get_http_auth_header(struct flb_kube *ctx) flb_free(ctx->auth); ctx->auth = NULL; return -1; - } + } ctx->auth = temp; } - + if (!ctx->auth) { return -1; } ctx->auth_len = snprintf(ctx->auth, tk_size + 32, "Bearer %s", tk); - + return 0; } @@ -311,7 +311,7 @@ static int get_meta_file_info(struct flb_kube *ctx, const char *namespace, if (podname && strlen(podname) > 0) { ret = snprintf(uri, sizeof(uri) - 1, "%s/%s_%s.meta", ctx->meta_preload_cache_dir, namespace, podname); - } + } else { ret = snprintf(uri, sizeof(uri) - 1, "%s/%s.namespace_meta", ctx->meta_preload_cache_dir, namespace); @@ -357,7 +357,7 @@ static int get_meta_info_from_request(struct flb_kube *ctx, const char *podname, char **buffer, size_t *size, int *root_type, - char* uri, + char* uri, int use_kubelet_connection) { struct flb_http_client *c; @@ -365,14 +365,14 @@ static int get_meta_info_from_request(struct flb_kube *ctx, int ret; size_t b_sent; int packed; - + if(use_kubelet_connection == FLB_TRUE) { if (!ctx->kubelet_upstream) { return -1; } u_conn = flb_upstream_conn_get(ctx->kubelet_upstream); - } + } else { if (!ctx->kube_api_upstream) { return -1; @@ -397,7 +397,7 @@ static int get_meta_info_from_request(struct flb_kube *ctx, flb_upstream_conn_release(u_conn); return -1; } - + /* Compose HTTP Client request*/ c = flb_http_client(u_conn, FLB_HTTP_GET, uri, @@ -464,7 +464,7 @@ static int get_pods_from_kubelet(struct flb_kube *ctx, flb_plg_debug(ctx->ins, "Send out request to Kubelet for pods information."); packed = get_meta_info_from_request(ctx, namespace, podname, - &buf, &size, &root_type, uri, + &buf, &size, &root_type, uri, ctx->use_kubelet); } @@ -480,7 +480,7 @@ static int get_pods_from_kubelet(struct flb_kube *ctx, } /* Gather namespace metadata from API Server */ -static int get_namespace_api_server_info(struct flb_kube *ctx, const char *namespace, +static int get_namespace_api_server_info(struct flb_kube *ctx, const char *namespace, char **out_buf, size_t *out_size) { int ret; @@ -1081,7 +1081,7 @@ static int merge_namespace_meta(struct flb_kube_meta *meta, struct flb_kube *ctx if (have_labels >= 0 && ctx->namespace_labels == FLB_TRUE) { k = meta_val.via.map.ptr[have_labels].key; v = meta_val.via.map.ptr[have_labels].val; - + msgpack_pack_object(&mp_pck, k); msgpack_pack_object(&mp_pck, v); } @@ -1093,7 +1093,7 @@ static int merge_namespace_meta(struct flb_kube_meta *meta, struct flb_kube *ctx msgpack_pack_object(&mp_pck, k); msgpack_pack_object(&mp_pck, v); } - + if (api_buf != NULL) { msgpack_unpacked_destroy(&api_result); if (meta_found == FLB_TRUE) { @@ -1684,17 +1684,17 @@ static int flb_kubelet_network_init(struct flb_kube *ctx, struct flb_config *con int ret; int io_type = FLB_IO_TCP; int api_https = FLB_TRUE; - ctx->kubelet_upstream = NULL; + ctx->kubelet_upstream = NULL; if(ctx->use_kubelet == FLB_FALSE) { return 0; } - // This is for unit test diagnostic purposes + // This is for unit test diagnostic purposes if (ctx->meta_preload_cache_dir) { api_https = FLB_FALSE; } - + if (api_https == FLB_TRUE) { if (!ctx->tls_ca_path && !ctx->tls_ca_file) { ctx->tls_ca_file = flb_strdup(FLB_KUBE_CA); @@ -1788,7 +1788,7 @@ static int flb_kube_network_init(struct flb_kube *ctx, struct flb_config *config /* Remove async flag from upstream */ flb_stream_disable_async_mode(&ctx->kube_api_upstream->base); - + kubelet_network_init_ret = flb_kubelet_network_init(ctx, config); return kubelet_network_init_ret; } @@ -1828,7 +1828,7 @@ int flb_kube_meta_init(struct flb_kube *ctx, struct flb_config *config) /* Gather info from Kubelet */ flb_plg_info(ctx->ins, "testing connectivity with Kubelet..."); ret = get_pods_from_kubelet(ctx, ctx->namespace, ctx->podname, - &meta_buf, &meta_size); + &meta_buf, &meta_size); } else { /* Gather info from API server */ @@ -2046,7 +2046,7 @@ static inline int flb_kube_namespace_meta_get(struct flb_kube *ctx, /* Set the pointer and proper size for the caller */ *out_buf = hash_meta_buf; *out_size = off; - + msgpack_unpacked_destroy(&result); return 0; @@ -2056,7 +2056,7 @@ int flb_kube_meta_get(struct flb_kube *ctx, const char *tag, int tag_len, const char *data, size_t data_size, const char **out_buf, size_t *out_size, - const char **namespace_out_buf, + const char **namespace_out_buf, size_t *namespace_out_size, struct flb_kube_meta *meta, struct flb_kube_props *props, @@ -2067,7 +2067,7 @@ int flb_kube_meta_get(struct flb_kube *ctx, int ret_pod_meta = -1; if(ctx->namespace_labels == FLB_TRUE || ctx->namespace_annotations == FLB_TRUE) { - ret_namespace_meta = flb_kube_namespace_meta_get(ctx, tag, tag_len, data, + ret_namespace_meta = flb_kube_namespace_meta_get(ctx, tag, tag_len, data, data_size, namespace_out_buf, namespace_out_size, namespace_meta); } From 1a26589607c8ba429f6e651ed54a917ba9c52189 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 26 Aug 2024 17:01:31 -0600 Subject: [PATCH 108/295] out_cloudwatch_logs: release resources on exception (CID 507707) Signed-off-by: Eduardo Silva --- plugins/out_cloudwatch_logs/cloudwatch_api.c | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/out_cloudwatch_logs/cloudwatch_api.c b/plugins/out_cloudwatch_logs/cloudwatch_api.c index d7e731887fe..276671204b0 100644 --- a/plugins/out_cloudwatch_logs/cloudwatch_api.c +++ b/plugins/out_cloudwatch_logs/cloudwatch_api.c @@ -1116,6 +1116,7 @@ struct log_stream *get_or_create_log_stream(struct flb_cloudwatch *ctx, new_stream->name = flb_sds_create(stream_name); if (new_stream->name == NULL) { flb_errno(); + flb_free(new_stream); return NULL; } new_stream->group = flb_sds_create(group_name); From af8d697d2130859748e09da77c6f3624718c1371 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 26 Aug 2024 17:05:13 -0600 Subject: [PATCH 109/295] filter_multiline: fix conditional after allocation (CID 507750) Signed-off-by: Eduardo Silva --- plugins/filter_multiline/ml.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/plugins/filter_multiline/ml.c b/plugins/filter_multiline/ml.c index ced8ec83739..152a0982ae0 100644 --- a/plugins/filter_multiline/ml.c +++ b/plugins/filter_multiline/ml.c @@ -204,9 +204,9 @@ static int cb_ml_init(struct flb_filter_instance *ins, ctx->config = config; ctx->timer_created = FLB_FALSE; - /* + /* * Config map is not yet set at this point in the code - * user must explicitly set buffer to false to turn it off + * user must explicitly set buffer to false to turn it off */ ctx->use_buffer = FLB_TRUE; tmp = (char *) flb_filter_get_property("buffer", ins); @@ -221,7 +221,7 @@ static int cb_ml_init(struct flb_filter_instance *ins, } else if (strcasecmp(tmp, FLB_MULTILINE_MODE_PARSER) == 0) { ctx->partial_mode = FLB_FALSE; } else { - flb_plg_error(ins, "'Mode' must be '%s' or '%s'", + flb_plg_error(ins, "'Mode' must be '%s' or '%s'", FLB_MULTILINE_MODE_PARTIAL_MESSAGE, FLB_MULTILINE_MODE_PARSER); return -1; @@ -278,7 +278,7 @@ static int cb_ml_init(struct flb_filter_instance *ins, flb_free(ctx); return -1; } - + /* Set plugin context */ flb_filter_set_context(ins, ctx); @@ -313,7 +313,7 @@ static int cb_ml_init(struct flb_filter_instance *ins, flb_free(ctx); return -1; } - + /* Create the emitter context */ ret = emitter_create(ctx); if (ret == -1) { @@ -412,7 +412,7 @@ static struct ml_stream *get_by_id(struct ml_ctx *ctx, uint64_t stream_id) } static struct ml_stream *get_or_create_stream(struct ml_ctx *ctx, - struct flb_input_instance *i_ins, + struct flb_input_instance *i_ins, const char *tag, int tag_len) { uint64_t stream_id; @@ -437,7 +437,6 @@ static struct ml_stream *get_or_create_stream(struct ml_ctx *ctx, } /* create a new stream */ - stream_name = flb_sds_create_size(64); tmp_sds = flb_sds_printf(&stream_name, "%s_%s", i_ins->name, tag); @@ -456,7 +455,7 @@ static struct ml_stream *get_or_create_stream(struct ml_ctx *ctx, } tmp_sds = flb_sds_create(tag); - if (!tmp) { + if (!tmp_sds) { flb_errno(); flb_sds_destroy(stream_name); ml_stream_destroy(stream); @@ -504,18 +503,18 @@ static void partial_timer_cb(struct flb_config *config, void *data) struct split_message_packer *packer; unsigned long long now; unsigned long long diff; - int ret; + int ret; now = ml_current_timestamp(); mk_list_foreach_safe(head, tmp, &ctx->split_message_packers) { packer = mk_list_entry(head, struct split_message_packer, _head); - + diff = now - packer->last_write_time; if (diff <= ctx->flush_ms) { continue; } - + mk_list_del(&packer->_head); ml_split_message_packer_complete(packer); /* re-emit record with original tag */ @@ -602,7 +601,7 @@ static int ml_filter_partial(const void *data, size_t bytes, sched = flb_sched_ctx_get(); ret = flb_sched_timer_cb_create(sched, FLB_SCHED_TIMER_CB_PERM, - ctx->flush_ms / 2, partial_timer_cb, + ctx->flush_ms / 2, partial_timer_cb, ctx, NULL); if (ret < 0) { flb_plg_error(ctx->ins, "Failed to create flush timer"); @@ -611,7 +610,7 @@ static int ml_filter_partial(const void *data, size_t bytes, } } - /* + /* * Create temporary msgpack buffer * for non-partial messages which are passed on as-is */ @@ -631,7 +630,7 @@ static int ml_filter_partial(const void *data, size_t bytes, partial_records--; goto pack_non_partial; } - packer = ml_get_packer(&ctx->split_message_packers, tag, + packer = ml_get_packer(&ctx->split_message_packers, tag, i_ins->name, partial_id_str, partial_id_size); if (packer == NULL) { flb_plg_trace(ctx->ins, "Found new partial record with tag %s", tag); @@ -806,7 +805,7 @@ static int cb_ml_filter(const void *data, size_t bytes, /* unlikely to happen.. but just in case */ return FLB_FILTER_NOTOUCH; - + } else { /* buffered mode */ stream = get_or_create_stream(ctx, i_ins, tag, tag_len); @@ -830,7 +829,7 @@ static int cb_ml_filter(const void *data, size_t bytes, flb_log_event_decoder_destroy(&decoder); - /* + /* * always returned modified, which will be 0 records, since the emitter takes * all records. */ From f8f1972b725b8838187b2bf37ed14bc199d16ac1 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 26 Aug 2024 17:21:09 -0600 Subject: [PATCH 110/295] out_loki: use sds_cat_safe (CID 311957) Signed-off-by: Eduardo Silva --- plugins/out_loki/loki.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/out_loki/loki.c b/plugins/out_loki/loki.c index 4a7a332f0c6..0f74d7470e2 100644 --- a/plugins/out_loki/loki.c +++ b/plugins/out_loki/loki.c @@ -152,7 +152,7 @@ static flb_sds_t normalize_ra_key_name(struct flb_loki *ctx, mk_list_foreach(head, &ra->list) { rp = mk_list_entry(head, struct flb_ra_parser, _head); if (c > 0) { - flb_sds_cat(name, "_", 1); + flb_sds_cat_safe(&name, "_", 1); } normalize_cat(rp, &name); c++; From f6f30c8c2630539532d290e3f4ea967ffd2b90f5 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 26 Aug 2024 17:25:20 -0600 Subject: [PATCH 111/295] out_opentelemetry: logs: release scope on exception (CID 507600) Signed-off-by: Eduardo Silva --- plugins/out_opentelemetry/opentelemetry_logs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/out_opentelemetry/opentelemetry_logs.c b/plugins/out_opentelemetry/opentelemetry_logs.c index 61c5722ba47..7d55fe32a8b 100644 --- a/plugins/out_opentelemetry/opentelemetry_logs.c +++ b/plugins/out_opentelemetry/opentelemetry_logs.c @@ -1085,6 +1085,8 @@ int otel_process_logs(struct flb_event_chunk *event_chunk, log_records = flb_calloc(ctx->batch_size, sizeof(Opentelemetry__Proto__Logs__V1__LogRecord *)); if (!log_records) { flb_errno(); + flb_free(scope_log->scope); + flb_free(scope_log); return -2; } log_record_count = 0; From ef6afbd9e17d4d5f3b4467be2d5299f06a9a0029 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 26 Aug 2024 17:26:48 -0600 Subject: [PATCH 112/295] out_loki: use sds_cat_safe (CID 507977) Signed-off-by: Eduardo Silva --- plugins/out_loki/loki.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/out_loki/loki.c b/plugins/out_loki/loki.c index 0f74d7470e2..9722ebc3170 100644 --- a/plugins/out_loki/loki.c +++ b/plugins/out_loki/loki.c @@ -750,7 +750,7 @@ static int parse_kv(struct flb_loki *ctx, struct mk_list *kv, struct mk_list *li } key = flb_sds_create_size((p - entry->str) + 1); - flb_sds_cat(key, entry->str, p - entry->str); + flb_sds_cat_safe(&key, entry->str, p - entry->str); val = flb_sds_create(p + 1); if (!key) { flb_plg_error(ctx->ins, From 74348397b9dffa67eff3b2c86374310d26884074 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 26 Aug 2024 17:40:19 -0600 Subject: [PATCH 113/295] out_opentelemetry: release buf on exception (CID 507777) Signed-off-by: Eduardo Silva --- plugins/out_opentelemetry/opentelemetry.c | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/out_opentelemetry/opentelemetry.c b/plugins/out_opentelemetry/opentelemetry.c index b65666e4004..6f7ab568a29 100644 --- a/plugins/out_opentelemetry/opentelemetry.c +++ b/plugins/out_opentelemetry/opentelemetry.c @@ -345,6 +345,7 @@ static int process_metrics(struct flb_event_chunk *event_chunk, } else { flb_plg_error(ctx->ins, "Error decoding msgpack encoded context"); + flb_sds_destroy(buf); return FLB_ERROR; } From cb02b699c7364fa1d77047e9446292fc23e9a6a0 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 26 Aug 2024 17:42:38 -0600 Subject: [PATCH 114/295] in_prometheus_remote_write: use sds_cat_safe (CID 508087) Signed-off-by: Eduardo Silva --- plugins/in_prometheus_remote_write/prom_rw_prot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/in_prometheus_remote_write/prom_rw_prot.c b/plugins/in_prometheus_remote_write/prom_rw_prot.c index 6c146a3c37f..d041c8f9a6d 100644 --- a/plugins/in_prometheus_remote_write/prom_rw_prot.c +++ b/plugins/in_prometheus_remote_write/prom_rw_prot.c @@ -299,7 +299,7 @@ int prom_rw_prot_handle(struct flb_prom_remote_write *ctx, } /* New tag skipping the URI '/' */ - flb_sds_cat(tag, uri + 1, len - 1); + flb_sds_cat_safe(&tag, uri + 1, len - 1); /* Sanitize, only allow alphanum chars */ for (i = 0; i < flb_sds_len(tag); i++) { From 9bd0eb5ad7417da9228c9bd9cec57bd87d45582e Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 26 Aug 2024 17:46:59 -0600 Subject: [PATCH 115/295] out_s3: fix double free (CID 508202) Signed-off-by: Eduardo Silva --- plugins/out_s3/s3.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/out_s3/s3.c b/plugins/out_s3/s3.c index df413ffdeed..c896b7e36bb 100644 --- a/plugins/out_s3/s3.c +++ b/plugins/out_s3/s3.c @@ -921,11 +921,11 @@ static int cb_s3_init(struct flb_output_instance *ins, ctx->timer_ms = UPLOAD_TIMER_MIN_WAIT; } - /* - * S3 must ALWAYS use sync mode + /* + * S3 must ALWAYS use sync mode * In the timer thread we do a mk_list_foreach_safe on the queue of uplaods and chunks * Iterating over those lists is not concurrent safe. If a flush call ran at the same time - * And deleted an item from the list, this could cause a crash/corruption. + * And deleted an item from the list, this could cause a crash/corruption. */ flb_stream_disable_async_mode(&ctx->s3_client->upstream->base); @@ -1394,7 +1394,6 @@ static int s3_put_object(struct flb_s3 *ctx, const char *tag, time_t file_first_ ret = write_seq_index(ctx->seq_index_file, ctx->seq_index); if (ret < 0 && access(ctx->seq_index_file, F_OK) == 0) { ctx->seq_index--; - flb_sds_destroy(s3_key); flb_plg_error(ctx->ins, "Failed to update sequential index metadata file"); return -1; } From 7e2f3f088aade6a30cc16130bcd707b79d11b977 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 26 Aug 2024 21:56:13 -0600 Subject: [PATCH 116/295] lib: c-ares: upgrade to v1.33.1 Signed-off-by: Eduardo Silva --- cmake/libraries.cmake | 2 +- lib/c-ares-1.32.3/RELEASE-NOTES.md | 98 -- lib/c-ares-1.32.3/msvc_ver.inc | 26 - lib/c-ares-1.32.3/src/lib/Makefile.inc | 117 -- lib/c-ares-1.32.3/src/lib/ares__socket.c | 486 ------ lib/{c-ares-1.32.3 => c-ares-1.33.1}/AUTHORS | 0 .../CMakeLists.txt | 46 +- .../CONTRIBUTING.md | 0 .../DEVELOPER-NOTES.md | 0 .../INSTALL.md | 0 .../LICENSE.md | 2 - .../Makefile.Watcom | 72 + .../Makefile.am | 2 +- .../Makefile.dj | 29 +- .../Makefile.in | 50 +- .../Makefile.m32 | 0 .../Makefile.msvc | 81 +- .../Makefile.netware | 0 .../README.md | 52 + .../README.msvc | 0 lib/c-ares-1.33.1/RELEASE-NOTES.md | 65 + .../SECURITY.md | 0 .../aclocal.m4 | 417 +++-- .../aminclude_static.am | 2 +- .../buildconf | 0 .../buildconf.bat | 0 .../c-ares-config.cmake.in | 0 .../cmake/EnableWarnings.cmake | 0 .../config/compile | 11 +- .../config/config.guess | 11 +- .../config/config.sub | 29 +- .../config/depcomp | 15 +- .../config/install-sh | 8 +- .../config/ltmain.sh | 0 .../config/missing | 75 +- .../config/test-driver | 15 +- .../configure | 1164 ++++++++----- .../configure.ac | 27 +- .../docs/CMakeLists.txt | 0 .../docs/Makefile.am | 0 .../docs/Makefile.in | 28 +- .../docs/Makefile.inc | 0 .../docs/adig.1 | 0 .../docs/ahost.1 | 0 .../docs/ares_cancel.3 | 0 .../docs/ares_create_query.3 | 0 .../docs/ares_destroy.3 | 0 .../docs/ares_destroy_options.3 | 0 .../docs/ares_dns_class_fromstr.3 | 0 .../docs/ares_dns_class_t.3 | 0 .../docs/ares_dns_class_tostr.3 | 0 .../docs/ares_dns_datatype_t.3 | 0 .../docs/ares_dns_flags_t.3 | 0 .../docs/ares_dns_mapping.3 | 0 .../docs/ares_dns_opcode_t.3 | 0 .../docs/ares_dns_opcode_tostr.3 | 0 .../docs/ares_dns_opt_datatype_t.3 | 0 .../docs/ares_dns_opt_get_datatype.3 | 0 .../docs/ares_dns_opt_get_name.3 | 0 .../docs/ares_dns_parse.3 | 0 .../docs/ares_dns_rcode_t.3 | 0 .../docs/ares_dns_rcode_tostr.3 | 0 .../docs/ares_dns_rec_type_fromstr.3 | 0 .../docs/ares_dns_rec_type_t.3 | 0 .../docs/ares_dns_rec_type_tostr.3 | 0 .../docs/ares_dns_record.3 | 0 .../docs/ares_dns_record_create.3 | 0 .../docs/ares_dns_record_destroy.3 | 0 .../docs/ares_dns_record_duplicate.3 | 0 .../docs/ares_dns_record_get_flags.3 | 0 .../docs/ares_dns_record_get_id.3 | 0 .../docs/ares_dns_record_get_opcode.3 | 0 .../docs/ares_dns_record_get_rcode.3 | 0 .../docs/ares_dns_record_query_add.3 | 0 .../docs/ares_dns_record_query_cnt.3 | 0 .../docs/ares_dns_record_query_get.3 | 0 .../docs/ares_dns_record_query_set_name.3 | 0 .../docs/ares_dns_record_query_set_type.3 | 0 .../docs/ares_dns_record_rr_add.3 | 0 .../docs/ares_dns_record_rr_cnt.3 | 0 .../docs/ares_dns_record_rr_del.3 | 0 .../docs/ares_dns_record_rr_get.3 | 0 .../docs/ares_dns_record_rr_get_const.3 | 0 .../docs/ares_dns_record_set_id.3 | 0 .../docs/ares_dns_rr.3 | 20 +- .../docs/ares_dns_rr_add_abin.3 | 0 .../docs/ares_dns_rr_del_abin.3 | 0 .../docs/ares_dns_rr_get_abin.3 | 0 .../docs/ares_dns_rr_get_abin_cnt.3 | 0 .../docs/ares_dns_rr_get_addr.3 | 0 .../docs/ares_dns_rr_get_addr6.3 | 0 .../docs/ares_dns_rr_get_bin.3 | 0 .../docs/ares_dns_rr_get_class.3 | 0 .../docs/ares_dns_rr_get_keys.3 | 0 .../docs/ares_dns_rr_get_name.3 | 0 .../docs/ares_dns_rr_get_opt.3 | 0 .../docs/ares_dns_rr_get_opt_byid.3 | 0 .../docs/ares_dns_rr_get_opt_cnt.3 | 0 .../docs/ares_dns_rr_get_str.3 | 0 .../docs/ares_dns_rr_get_ttl.3 | 0 .../docs/ares_dns_rr_get_type.3 | 0 .../docs/ares_dns_rr_get_u16.3 | 0 .../docs/ares_dns_rr_get_u32.3 | 0 .../docs/ares_dns_rr_get_u8.3 | 0 .../docs/ares_dns_rr_key_datatype.3 | 0 .../docs/ares_dns_rr_key_t.3 | 0 .../docs/ares_dns_rr_key_to_rec_type.3 | 0 .../docs/ares_dns_rr_key_tostr.3 | 0 .../docs/ares_dns_rr_set_addr.3 | 0 .../docs/ares_dns_rr_set_addr6.3 | 0 .../docs/ares_dns_rr_set_bin.3 | 0 .../docs/ares_dns_rr_set_opt.3 | 0 .../docs/ares_dns_rr_set_str.3 | 0 .../docs/ares_dns_rr_set_u16.3 | 0 .../docs/ares_dns_rr_set_u32.3 | 0 .../docs/ares_dns_rr_set_u8.3 | 0 .../docs/ares_dns_section_t.3 | 0 .../docs/ares_dns_section_tostr.3 | 0 .../docs/ares_dns_write.3 | 0 .../docs/ares_dup.3 | 0 .../docs/ares_expand_name.3 | 0 .../docs/ares_expand_string.3 | 0 .../docs/ares_fds.3 | 0 .../docs/ares_free_data.3 | 0 .../docs/ares_free_hostent.3 | 0 .../docs/ares_free_string.3 | 0 .../docs/ares_freeaddrinfo.3 | 0 .../docs/ares_get_servers.3 | 0 .../docs/ares_get_servers_csv.3 | 0 .../docs/ares_get_servers_ports.3 | 0 .../docs/ares_getaddrinfo.3 | 0 .../docs/ares_gethostbyaddr.3 | 0 .../docs/ares_gethostbyname.3 | 0 .../docs/ares_gethostbyname_file.3 | 0 .../docs/ares_getnameinfo.3 | 0 .../docs/ares_getsock.3 | 0 .../docs/ares_inet_ntop.3 | 0 .../docs/ares_inet_pton.3 | 0 .../docs/ares_init.3 | 0 .../docs/ares_init_options.3 | 0 .../docs/ares_library_cleanup.3 | 0 .../docs/ares_library_init.3 | 0 .../docs/ares_library_init_android.3 | 0 .../docs/ares_library_initialized.3 | 0 .../docs/ares_mkquery.3 | 0 .../docs/ares_opt_param_t.3 | 0 .../docs/ares_parse_a_reply.3 | 0 .../docs/ares_parse_aaaa_reply.3 | 0 .../docs/ares_parse_caa_reply.3 | 0 .../docs/ares_parse_mx_reply.3 | 0 .../docs/ares_parse_naptr_reply.3 | 0 .../docs/ares_parse_ns_reply.3 | 0 .../docs/ares_parse_ptr_reply.3 | 0 .../docs/ares_parse_soa_reply.3 | 0 .../docs/ares_parse_srv_reply.3 | 0 .../docs/ares_parse_txt_reply.3 | 0 .../docs/ares_parse_uri_reply.3 | 0 .../docs/ares_process.3 | 0 .../docs/ares_query.3 | 0 .../docs/ares_query_dnsrec.3 | 0 .../docs/ares_queue.3 | 0 .../docs/ares_queue_active_queries.3 | 0 .../docs/ares_queue_wait_empty.3 | 0 .../docs/ares_reinit.3 | 0 .../docs/ares_save_options.3 | 0 .../docs/ares_search.3 | 0 .../docs/ares_search_dnsrec.3 | 0 .../docs/ares_send.3 | 0 .../docs/ares_send_dnsrec.3 | 0 .../docs/ares_set_local_dev.3 | 0 .../docs/ares_set_local_ip4.3 | 0 .../docs/ares_set_local_ip6.3 | 0 .../docs/ares_set_server_state_callback.3 | 0 .../docs/ares_set_servers.3 | 0 .../docs/ares_set_servers_csv.3 | 0 .../docs/ares_set_servers_ports.3 | 0 .../docs/ares_set_servers_ports_csv.3 | 0 .../docs/ares_set_socket_callback.3 | 0 .../docs/ares_set_socket_configure_callback.3 | 0 .../docs/ares_set_socket_functions.3 | 0 .../docs/ares_set_sortlist.3 | 0 .../docs/ares_strerror.3 | 0 .../docs/ares_svcb_param_t.3 | 0 .../docs/ares_threadsafety.3 | 0 .../docs/ares_timeout.3 | 0 .../docs/ares_tlsa_match_t.3 | 0 .../docs/ares_tlsa_selector_t.3 | 0 .../docs/ares_tlsa_usage_t.3 | 0 .../docs/ares_version.3 | 0 .../include/CMakeLists.txt | 0 .../include/Makefile.am | 0 .../include/Makefile.in | 32 +- .../include/ares.h | 2 +- .../include/ares_build.h | 0 .../include/ares_build.h.cmake | 0 .../include/ares_build.h.in | 0 .../include/ares_dns.h | 0 .../include/ares_dns_record.h | 68 +- .../include/ares_nameser.h | 0 .../include/ares_version.h | 6 +- .../libcares.pc.cmake | 7 +- .../libcares.pc.in | 0 .../m4/ax_ac_append_to_file.m4 | 0 .../m4/ax_ac_print_to_file.m4 | 0 .../m4/ax_add_am_macro_static.m4 | 0 .../m4/ax_am_macros_static.m4 | 0 .../m4/ax_append_compile_flags.m4 | 0 .../m4/ax_append_flag.m4 | 0 .../m4/ax_append_link_flags.m4 | 0 .../m4/ax_check_compile_flag.m4 | 0 .../m4/ax_check_gnu_make.m4 | 0 .../m4/ax_check_link_flag.m4 | 0 .../m4/ax_check_user_namespace.m4 | 0 .../m4/ax_check_uts_namespace.m4 | 0 .../m4/ax_code_coverage.m4 | 0 .../m4/ax_compiler_vendor.m4 | 0 .../m4/ax_cxx_compile_stdcxx.m4 | 0 .../m4/ax_cxx_compile_stdcxx_14.m4 | 0 .../m4/ax_file_escapes.m4 | 0 .../m4/ax_pthread.m4 | 0 .../m4/ax_require_defined.m4 | 0 .../m4/libtool.m4 | 0 .../m4/ltoptions.m4 | 0 .../m4/ltsugar.m4 | 0 .../m4/ltversion.m4 | 0 .../m4/lt~obsolete.m4 | 0 .../m4/pkg.m4 | 0 .../src/CMakeLists.txt | 0 .../src/Makefile.am | 0 .../src/Makefile.in | 21 +- .../src/lib/CMakeLists.txt | 0 .../src/lib/Makefile.am | 0 .../src/lib/Makefile.in | 1493 ++++++++++------- lib/c-ares-1.33.1/src/lib/Makefile.inc | 120 ++ .../src/lib/ares__addrinfo2hostent.c | 32 +- .../src/lib/ares__addrinfo_localhost.c | 0 .../src/lib/ares__close_sockets.c | 34 +- .../src/lib/ares__hosts_file.c | 0 .../src/lib/ares__parse_into_addrinfo.c | 0 lib/c-ares-1.33.1/src/lib/ares__socket.c | 764 +++++++++ .../src/lib/ares__sortaddrinfo.c | 10 +- .../src/lib/ares_android.c | 29 +- .../src/lib/ares_android.h | 0 .../src/lib/ares_cancel.c | 2 +- .../src/lib/ares_config.h.cmake | 9 + .../src/lib/ares_config.h.in | 9 + lib/c-ares-1.33.1/src/lib/ares_cookie.c | 460 +++++ .../src/lib/ares_data.c | 0 .../src/lib/ares_data.h | 0 .../src/lib/ares_destroy.c | 8 +- .../src/lib/ares_free_hostent.c | 0 .../src/lib/ares_free_string.c | 0 .../src/lib/ares_freeaddrinfo.c | 0 .../src/lib/ares_getaddrinfo.c | 11 +- .../src/lib/ares_getenv.c | 0 .../src/lib/ares_getenv.h | 0 .../src/lib/ares_gethostbyaddr.c | 0 .../src/lib/ares_gethostbyname.c | 0 .../src/lib/ares_getnameinfo.c | 0 .../src/lib/ares_inet_net_pton.h | 0 .../src/lib/ares_init.c | 10 +- .../src/lib/ares_ipv6.h | 0 .../src/lib/ares_library_init.c | 0 .../src/lib/ares_metrics.c | 10 +- .../src/lib/ares_options.c | 2 +- .../src/lib/ares_platform.c | 0 .../src/lib/ares_platform.h | 0 .../src/lib/ares_private.h | 233 ++- .../src/lib/ares_process.c | 581 +++---- .../src/lib/ares_qcache.c | 25 +- .../src/lib/ares_query.c | 0 .../src/lib/ares_search.c | 72 +- .../src/lib/ares_send.c | 33 +- .../src/lib/ares_setup.h | 91 +- .../src/lib/ares_strerror.c | 0 .../src/lib/ares_sysconfig.c | 3 +- .../src/lib/ares_sysconfig_files.c | 0 .../src/lib/ares_sysconfig_mac.c | 26 +- .../src/lib/ares_sysconfig_win.c | 0 .../src/lib/ares_timeout.c | 15 +- .../src/lib/ares_update_servers.c | 28 +- .../src/lib/ares_version.c | 0 .../src/lib/cares.rc | 0 .../src/lib/config-dos.h | 0 .../src/lib/config-win32.h | 5 + lib/c-ares-1.33.1/src/lib/dsa/ares__array.c | 356 ++++ lib/c-ares-1.33.1/src/lib/dsa/ares__array.h | 223 +++ .../src/lib/dsa}/ares__htable.c | 2 +- .../src/lib/dsa}/ares__htable.h | 0 .../src/lib/dsa}/ares__htable_asvp.c | 0 .../src/lib/dsa}/ares__htable_asvp.h | 0 .../src/lib/dsa}/ares__htable_strvp.c | 0 .../src/lib/dsa}/ares__htable_strvp.h | 0 .../src/lib/dsa}/ares__htable_szvp.c | 0 .../src/lib/dsa}/ares__htable_szvp.h | 0 .../src/lib/dsa}/ares__htable_vpvp.c | 0 .../src/lib/dsa}/ares__htable_vpvp.h | 0 .../src/lib/dsa}/ares__llist.c | 0 .../src/lib/dsa}/ares__llist.h | 0 .../src/lib/dsa}/ares__slist.c | 0 .../src/lib/dsa}/ares__slist.h | 0 .../src/lib/event}/ares_event.h | 0 .../src/lib/event}/ares_event_configchg.c | 44 +- .../src/lib/event}/ares_event_epoll.c | 0 .../src/lib/event}/ares_event_kqueue.c | 10 +- .../src/lib/event}/ares_event_poll.c | 0 .../src/lib/event}/ares_event_select.c | 0 .../src/lib/event}/ares_event_thread.c | 60 +- .../src/lib/event}/ares_event_wake_pipe.c | 0 .../src/lib/event}/ares_event_win32.c | 10 +- .../src/lib/event}/ares_event_win32.h | 0 .../src/lib/inet_net_pton.c | 24 +- .../src/lib/inet_ntop.c | 6 +- .../src/lib/legacy}/ares_create_query.c | 0 .../src/lib/legacy}/ares_expand_name.c | 0 .../src/lib/legacy}/ares_expand_string.c | 3 +- .../src/lib/legacy}/ares_fds.c | 10 +- .../src/lib/legacy}/ares_getsock.c | 12 +- .../src/lib/legacy}/ares_parse_a_reply.c | 0 .../src/lib/legacy}/ares_parse_aaaa_reply.c | 0 .../src/lib/legacy}/ares_parse_caa_reply.c | 0 .../src/lib/legacy}/ares_parse_mx_reply.c | 0 .../src/lib/legacy}/ares_parse_naptr_reply.c | 0 .../src/lib/legacy}/ares_parse_ns_reply.c | 0 .../src/lib/legacy}/ares_parse_ptr_reply.c | 0 .../src/lib/legacy}/ares_parse_soa_reply.c | 0 .../src/lib/legacy}/ares_parse_srv_reply.c | 0 .../src/lib/legacy}/ares_parse_txt_reply.c | 2 +- .../src/lib/legacy}/ares_parse_uri_reply.c | 0 .../src/lib/record}/ares_dns_mapping.c | 0 .../src/lib/record}/ares_dns_multistring.c | 121 +- .../src/lib/record}/ares_dns_multistring.h | 5 +- .../src/lib/record}/ares_dns_name.c | 115 +- .../src/lib/record}/ares_dns_parse.c | 0 .../src/lib/record}/ares_dns_private.h | 81 +- .../src/lib/record}/ares_dns_record.c | 427 ++--- .../src/lib/record}/ares_dns_write.c | 115 +- .../src/lib/str}/ares__buf.c | 8 +- .../src/lib/str}/ares__buf.h | 0 .../src/lib/str}/ares_str.c | 0 .../src/lib/str}/ares_str.h | 13 + .../src/lib/str}/ares_strcasecmp.c | 0 .../src/lib/str}/ares_strcasecmp.h | 0 .../src/lib/str}/ares_strsplit.c | 0 .../src/lib/str}/ares_strsplit.h | 0 .../src/lib/thirdparty/apple/dnsinfo.h | 0 .../src/lib/util}/ares__iface_ips.c | 133 +- .../src/lib/util}/ares__iface_ips.h | 0 .../src/lib/util}/ares__threads.c | 0 .../src/lib/util}/ares__threads.h | 0 .../src/lib/util}/ares__timeval.c | 2 +- .../src/lib/util}/ares_math.c | 0 .../src/lib/util}/ares_rand.c | 0 .../src/lib/windows_port.c | 0 .../src/tools/CMakeLists.txt | 0 .../src/tools/Makefile.am | 0 .../src/tools/Makefile.in | 123 +- .../src/tools/Makefile.inc | 4 +- .../src/tools/adig.c | 105 +- .../src/tools/ahost.c | 6 +- .../src/tools/ares_getopt.c | 3 +- .../src/tools/ares_getopt.h | 15 +- .../test/CMakeLists.txt | 19 +- .../test/Makefile.am | 0 .../test/Makefile.in | 98 +- .../test/Makefile.inc | 0 .../test/Makefile.m32 | 0 .../test/Makefile.msvc | 32 +- .../test/README.md | 0 .../test/ares-fuzz.c | 0 .../test/ares-test-ai.h | 6 +- .../test/ares-test-fuzz-name.c | 0 .../test/ares-test-fuzz.c | 0 .../test/ares-test-init.cc | 20 +- .../test/ares-test-internal.cc | 180 +- .../test/ares-test-live.cc | 0 .../test/ares-test-main.cc | 0 .../test/ares-test-misc.cc | 2 +- .../test/ares-test-mock-ai.cc | 269 ++- .../test/ares-test-mock-et.cc | 17 +- .../test/ares-test-mock.cc | 381 ++++- .../test/ares-test-ns.cc | 13 +- .../test/ares-test-parse-a.cc | 0 .../test/ares-test-parse-aaaa.cc | 0 .../test/ares-test-parse-caa.cc | 0 .../test/ares-test-parse-mx.cc | 0 .../test/ares-test-parse-naptr.cc | 0 .../test/ares-test-parse-ns.cc | 0 .../test/ares-test-parse-ptr.cc | 4 +- .../test/ares-test-parse-soa-any.cc | 0 .../test/ares-test-parse-soa.cc | 0 .../test/ares-test-parse-srv.cc | 0 .../test/ares-test-parse-txt.cc | 0 .../test/ares-test-parse-uri.cc | 0 .../test/ares-test-parse.cc | 0 .../test/ares-test.cc | 124 +- .../test/ares-test.h | 114 +- .../test/ares_queryloop.c | 3 +- .../test/dns-dump.cc | 0 .../test/dns-proto-test.cc | 0 .../test/dns-proto.cc | 128 +- .../test/dns-proto.h | 64 +- .../test/fuzzcheck.sh | 0 .../004a216d3cff18b0c5c6b68b807f1529 | Bin .../00539467ca159b36aea95e61f9729115 | Bin .../00e846db8f43f2f507cd1666ed5a753e | Bin .../0177b7566f08c013699eaea9a77abeb3 | Bin .../020a4fa317715bfdb236ed13751e6b65 | Bin .../0310f2e81bea31f4fe3f330872a877dd | Bin .../0449be67df1730b2d0887d412a9b7cc4 | Bin .../0449dd14f7aa94bf0d716bfe09b287a8 | Bin .../04c93cdf7208979aa4df80a3a0d5a2d8 | Bin .../0567e7171e08e75f3f91c4ca74c17adc | Bin .../05ba948578a397e9cbc6a7b3e78622fa | Bin .../060afe5ed25f3e2e86167e545f27edca | Bin .../06d47d3681493f1b1d41236f460d896f | Bin .../0724a810b0e131c2fddb6de9003b9064 | Bin .../0b5279148826f5b962bcf1896bdb4ede | Bin .../114048c0f6b10bdc67ce9166405d195e | Bin .../11b8464a0ef8735d202955c34c36b0c7 | Bin .../11cb626f1668c7b41954ce7d768fe528 | Bin .../14b133bf18125b75a1976fa63a1df6b7 | Bin .../153c6b3afa8faa03c8bc28f936a6d4cf | Bin .../182cad2a342ed7317b7c21a5d17020d1 | Bin .../1c61a61bb7057b52c5b15188345a5238 | Bin .../1dbe2cf62ed2e4fa1c3cb473f08710b5 | Bin .../21199be504fcfece5c7096ee0dbba507 | Bin .../21891480074b5635dbbe7137bdcabccd | Bin .../233aea42e15aa73e131eefabf16088c9 | Bin .../24660d4e7ac7aa21d600ea7a3d198bbb | Bin .../25589deb55c08429345f289d1c9b0254 | Bin .../2573bd823e4da11f727a17f8e1f35c26 | Bin .../276f12da56866273e76059ad0e7be97e | Bin .../29198a2e380cb19babec9e02116d213e | Bin .../2c94ba9434b1a1b9396fc5364f101363 | Bin .../2d578c357dc2f5e02dc55cddb30641d1 | Bin .../2dff6cc5a223e67fde9e5e79af456992 | Bin .../2f103b1f9477f2d8934bd84328d51c75 | Bin .../31cd3a8413de13d9624adbb1613784bf | Bin .../36415bdf1d180098fe6234b4186e69f3 | Bin .../3a04a80f0242e8dff0cd732e7c4767da | Bin .../44d0f973b7b0fb3e4a07770c943dcd5a | Bin .../50bc00daa0ddcd6cfb2b5d9f62c81f47 | Bin .../51ed2d1fb77b3078b54e94e85606b7df | Bin .../5c5e0e899cf2e7d053a9e45fb76f6e5a | Bin .../70152ed033f139443fbfb1b858bb3b1b | Bin .../7030ca2b24e5a7f9dd8f62096a48eb33 | Bin .../71eec1a0ef2d25bb9e2ef17f23be7e9e | Bin .../7a6b0177210ea4ef40b254daf99393c5 | Bin .../7f1567733711ffb61839621af0cbfa33 | Bin .../850c6d57c5bb7be8205fc2438d14d7e5 | Bin .../a5c8cd2784a5792b9e91c2d7895b3b34 | Bin .../a9135cdc7151d023300ff194bad90af9 | Bin .../af2597e8ac7dec1e8b4a47518312912a | Bin .../test/fuzzinput/answer_a | Bin .../test/fuzzinput/answer_aaaa | Bin .../b3f53ef826b831bb09dd25c7f5960249 | Bin .../cda0f8751f5c4993974c2b549d29bcc8 | Bin .../ce6c26c0e469339873d0e7f616ab0945 | Bin .../fuzzinput/clusterfuzz-5637790584012800 | Bin .../fuzzinput/clusterfuzz-5650695891451904 | Bin .../fuzzinput/clusterfuzz-5651369832218624 | Bin .../fuzzinput/clusterfuzz-5674462260756480 | Bin .../fuzzinput/clusterfuzz-5680630672654336 | Bin .../fuzzinput/clusterfuzz-5683497160671232 | Bin .../fuzzinput/clusterfuzz-5687310655422464 | Bin .../fuzzinput/clusterfuzz-5695341573177344 | Bin .../fuzzinput/clusterfuzz-5697835103682560 | Bin .../fuzzinput/clusterfuzz-5728518081609728 | Bin .../fuzzinput/clusterfuzz-5732960017317888 | Bin .../e4dd7e7c2dd4ed7c2e17a6af5d04f9c9 | Bin .../ed50ed8ee36230a5a69746ad830437e5 | Bin .../f1b900d50806021953321c3b604ee497 | Bin .../f6606f624be8c628328cea01d2cd07a9 | Bin .../f89f6c8176b564a7dd646f14305573ce | Bin .../f9ad508d2dbd08d3aaaabc7d1174677d | Bin .../test/fuzzinput/multi-indir | Bin .../test/fuzznames/name01 | 0 .../test/fuzznames/name02 | 0 .../test/fuzznames/name03 | 0 .../test/fuzznames/name04 | 0 .../test/fuzznames/name05 | 0 .../test/fuzznames/name06 | 0 .../test/fuzznames/name07 | 0 .../test/fuzznames/name08 | 0 .../test/fuzznames/name09 | 0 486 files changed, 6978 insertions(+), 3735 deletions(-) delete mode 100644 lib/c-ares-1.32.3/RELEASE-NOTES.md delete mode 100644 lib/c-ares-1.32.3/msvc_ver.inc delete mode 100644 lib/c-ares-1.32.3/src/lib/Makefile.inc delete mode 100644 lib/c-ares-1.32.3/src/lib/ares__socket.c rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/AUTHORS (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/CMakeLists.txt (96%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/CONTRIBUTING.md (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/DEVELOPER-NOTES.md (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/INSTALL.md (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/LICENSE.md (98%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/Makefile.Watcom (68%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/Makefile.am (98%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/Makefile.dj (86%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/Makefile.in (96%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/Makefile.m32 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/Makefile.msvc (85%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/Makefile.netware (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/README.md (66%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/README.msvc (100%) create mode 100644 lib/c-ares-1.33.1/RELEASE-NOTES.md rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/SECURITY.md (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/aclocal.m4 (78%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/aminclude_static.am (99%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/buildconf (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/buildconf.bat (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/c-ares-config.cmake.in (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/cmake/EnableWarnings.cmake (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/config/compile (95%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/config/config.guess (99%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/config/config.sub (97%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/config/depcomp (98%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/config/install-sh (98%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/config/ltmain.sh (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/config/missing (77%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/config/test-driver (89%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/configure (98%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/configure.ac (94%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/CMakeLists.txt (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/Makefile.am (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/Makefile.in (96%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/Makefile.inc (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/adig.1 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ahost.1 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_cancel.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_create_query.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_destroy.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_destroy_options.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_class_fromstr.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_class_t.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_class_tostr.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_datatype_t.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_flags_t.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_mapping.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_opcode_t.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_opcode_tostr.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_opt_datatype_t.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_opt_get_datatype.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_opt_get_name.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_parse.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rcode_t.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rcode_tostr.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rec_type_fromstr.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rec_type_t.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rec_type_tostr.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_record.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_record_create.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_record_destroy.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_record_duplicate.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_record_get_flags.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_record_get_id.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_record_get_opcode.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_record_get_rcode.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_record_query_add.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_record_query_cnt.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_record_query_get.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_record_query_set_name.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_record_query_set_type.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_record_rr_add.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_record_rr_cnt.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_record_rr_del.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_record_rr_get.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_record_rr_get_const.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_record_set_id.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr.3 (96%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_add_abin.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_del_abin.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_get_abin.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_get_abin_cnt.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_get_addr.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_get_addr6.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_get_bin.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_get_class.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_get_keys.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_get_name.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_get_opt.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_get_opt_byid.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_get_opt_cnt.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_get_str.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_get_ttl.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_get_type.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_get_u16.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_get_u32.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_get_u8.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_key_datatype.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_key_t.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_key_to_rec_type.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_key_tostr.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_set_addr.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_set_addr6.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_set_bin.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_set_opt.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_set_str.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_set_u16.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_set_u32.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_rr_set_u8.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_section_t.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_section_tostr.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dns_write.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_dup.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_expand_name.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_expand_string.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_fds.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_free_data.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_free_hostent.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_free_string.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_freeaddrinfo.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_get_servers.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_get_servers_csv.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_get_servers_ports.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_getaddrinfo.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_gethostbyaddr.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_gethostbyname.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_gethostbyname_file.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_getnameinfo.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_getsock.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_inet_ntop.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_inet_pton.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_init.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_init_options.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_library_cleanup.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_library_init.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_library_init_android.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_library_initialized.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_mkquery.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_opt_param_t.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_parse_a_reply.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_parse_aaaa_reply.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_parse_caa_reply.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_parse_mx_reply.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_parse_naptr_reply.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_parse_ns_reply.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_parse_ptr_reply.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_parse_soa_reply.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_parse_srv_reply.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_parse_txt_reply.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_parse_uri_reply.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_process.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_query.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_query_dnsrec.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_queue.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_queue_active_queries.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_queue_wait_empty.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_reinit.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_save_options.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_search.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_search_dnsrec.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_send.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_send_dnsrec.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_set_local_dev.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_set_local_ip4.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_set_local_ip6.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_set_server_state_callback.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_set_servers.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_set_servers_csv.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_set_servers_ports.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_set_servers_ports_csv.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_set_socket_callback.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_set_socket_configure_callback.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_set_socket_functions.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_set_sortlist.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_strerror.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_svcb_param_t.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_threadsafety.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_timeout.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_tlsa_match_t.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_tlsa_selector_t.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_tlsa_usage_t.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/docs/ares_version.3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/include/CMakeLists.txt (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/include/Makefile.am (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/include/Makefile.in (95%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/include/ares.h (99%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/include/ares_build.h (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/include/ares_build.h.cmake (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/include/ares_build.h.in (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/include/ares_dns.h (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/include/ares_dns_record.h (95%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/include/ares_nameser.h (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/include/ares_version.h (94%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/libcares.pc.cmake (78%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/libcares.pc.in (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/m4/ax_ac_append_to_file.m4 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/m4/ax_ac_print_to_file.m4 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/m4/ax_add_am_macro_static.m4 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/m4/ax_am_macros_static.m4 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/m4/ax_append_compile_flags.m4 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/m4/ax_append_flag.m4 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/m4/ax_append_link_flags.m4 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/m4/ax_check_compile_flag.m4 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/m4/ax_check_gnu_make.m4 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/m4/ax_check_link_flag.m4 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/m4/ax_check_user_namespace.m4 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/m4/ax_check_uts_namespace.m4 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/m4/ax_code_coverage.m4 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/m4/ax_compiler_vendor.m4 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/m4/ax_cxx_compile_stdcxx.m4 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/m4/ax_cxx_compile_stdcxx_14.m4 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/m4/ax_file_escapes.m4 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/m4/ax_pthread.m4 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/m4/ax_require_defined.m4 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/m4/libtool.m4 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/m4/ltoptions.m4 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/m4/ltsugar.m4 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/m4/ltversion.m4 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/m4/lt~obsolete.m4 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/m4/pkg.m4 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/CMakeLists.txt (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/Makefile.am (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/Makefile.in (97%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/CMakeLists.txt (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/Makefile.am (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/Makefile.in (65%) create mode 100644 lib/c-ares-1.33.1/src/lib/Makefile.inc rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares__addrinfo2hostent.c (90%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares__addrinfo_localhost.c (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares__close_sockets.c (80%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares__hosts_file.c (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares__parse_into_addrinfo.c (100%) create mode 100644 lib/c-ares-1.33.1/src/lib/ares__socket.c rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares__sortaddrinfo.c (98%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_android.c (96%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_android.h (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_cancel.c (98%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_config.h.cmake (97%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_config.h.in (98%) create mode 100644 lib/c-ares-1.33.1/src/lib/ares_cookie.c rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_data.c (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_data.h (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_destroy.c (96%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_free_hostent.c (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_free_string.c (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_freeaddrinfo.c (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_getaddrinfo.c (97%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_getenv.c (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_getenv.h (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_gethostbyaddr.c (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_gethostbyname.c (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_getnameinfo.c (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_inet_net_pton.h (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_init.c (98%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_ipv6.h (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_library_init.c (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_metrics.c (96%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_options.c (99%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_platform.c (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_platform.h (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_private.h (80%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_process.c (72%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_qcache.c (96%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_query.c (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_search.c (93%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_send.c (91%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_setup.h (79%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_strerror.c (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_sysconfig.c (99%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_sysconfig_files.c (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_sysconfig_mac.c (92%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_sysconfig_win.c (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_timeout.c (88%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_update_servers.c (97%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/ares_version.c (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/cares.rc (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/config-dos.h (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/config-win32.h (98%) create mode 100644 lib/c-ares-1.33.1/src/lib/dsa/ares__array.c create mode 100644 lib/c-ares-1.33.1/src/lib/dsa/ares__array.h rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/dsa}/ares__htable.c (99%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/dsa}/ares__htable.h (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/dsa}/ares__htable_asvp.c (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/dsa}/ares__htable_asvp.h (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/dsa}/ares__htable_strvp.c (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/dsa}/ares__htable_strvp.h (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/dsa}/ares__htable_szvp.c (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/dsa}/ares__htable_szvp.h (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/dsa}/ares__htable_vpvp.c (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/dsa}/ares__htable_vpvp.h (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/dsa}/ares__llist.c (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/dsa}/ares__llist.h (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/dsa}/ares__slist.c (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/dsa}/ares__slist.h (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/event}/ares_event.h (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/event}/ares_event_configchg.c (94%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/event}/ares_event_epoll.c (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/event}/ares_event_kqueue.c (96%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/event}/ares_event_poll.c (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/event}/ares_event_select.c (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/event}/ares_event_thread.c (95%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/event}/ares_event_wake_pipe.c (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/event}/ares_event_win32.c (99%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/event}/ares_event_win32.h (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/inet_net_pton.c (93%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/inet_ntop.c (97%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/legacy}/ares_create_query.c (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/legacy}/ares_expand_name.c (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/legacy}/ares_expand_string.c (97%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/legacy}/ares_fds.c (88%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/legacy}/ares_getsock.c (87%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/legacy}/ares_parse_a_reply.c (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/legacy}/ares_parse_aaaa_reply.c (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/legacy}/ares_parse_caa_reply.c (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/legacy}/ares_parse_mx_reply.c (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/legacy}/ares_parse_naptr_reply.c (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/legacy}/ares_parse_ns_reply.c (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/legacy}/ares_parse_ptr_reply.c (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/legacy}/ares_parse_soa_reply.c (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/legacy}/ares_parse_srv_reply.c (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/legacy}/ares_parse_txt_reply.c (99%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/legacy}/ares_parse_uri_reply.c (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/record}/ares_dns_mapping.c (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/record}/ares_dns_multistring.c (67%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/record}/ares_dns_multistring.h (94%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/record}/ares_dns_name.c (87%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/record}/ares_dns_parse.c (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/record}/ares_dns_private.h (76%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/record}/ares_dns_record.c (84%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/record}/ares_dns_write.c (93%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/str}/ares__buf.c (99%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/str}/ares__buf.h (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/str}/ares_str.c (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/str}/ares_str.h (82%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/str}/ares_strcasecmp.c (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/str}/ares_strcasecmp.h (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/str}/ares_strsplit.c (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/str}/ares_strsplit.h (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/thirdparty/apple/dnsinfo.h (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/util}/ares__iface_ips.c (90%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/util}/ares__iface_ips.h (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/util}/ares__threads.c (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/util}/ares__threads.h (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/util}/ares__timeval.c (98%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/util}/ares_math.c (100%) rename lib/{c-ares-1.32.3/src/lib => c-ares-1.33.1/src/lib/util}/ares_rand.c (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/lib/windows_port.c (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/tools/CMakeLists.txt (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/tools/Makefile.am (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/tools/Makefile.in (85%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/tools/Makefile.inc (71%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/tools/adig.c (90%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/tools/ahost.c (98%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/tools/ares_getopt.c (97%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/src/tools/ares_getopt.h (80%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/CMakeLists.txt (80%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/Makefile.am (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/Makefile.in (97%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/Makefile.inc (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/Makefile.m32 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/Makefile.msvc (92%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/README.md (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/ares-fuzz.c (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/ares-test-ai.h (97%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/ares-test-fuzz-name.c (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/ares-test-fuzz.c (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/ares-test-init.cc (98%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/ares-test-internal.cc (90%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/ares-test-live.cc (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/ares-test-main.cc (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/ares-test-misc.cc (99%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/ares-test-mock-ai.cc (78%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/ares-test-mock-et.cc (99%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/ares-test-mock.cc (83%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/ares-test-ns.cc (96%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/ares-test-parse-a.cc (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/ares-test-parse-aaaa.cc (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/ares-test-parse-caa.cc (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/ares-test-parse-mx.cc (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/ares-test-parse-naptr.cc (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/ares-test-parse-ns.cc (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/ares-test-parse-ptr.cc (99%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/ares-test-parse-soa-any.cc (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/ares-test-parse-soa.cc (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/ares-test-parse-srv.cc (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/ares-test-parse-txt.cc (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/ares-test-parse-uri.cc (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/ares-test-parse.cc (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/ares-test.cc (92%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/ares-test.h (81%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/ares_queryloop.c (99%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/dns-dump.cc (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/dns-proto-test.cc (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/dns-proto.cc (84%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/dns-proto.h (83%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzcheck.sh (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/004a216d3cff18b0c5c6b68b807f1529 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/00539467ca159b36aea95e61f9729115 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/00e846db8f43f2f507cd1666ed5a753e (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/0177b7566f08c013699eaea9a77abeb3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/020a4fa317715bfdb236ed13751e6b65 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/0310f2e81bea31f4fe3f330872a877dd (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/0449be67df1730b2d0887d412a9b7cc4 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/0449dd14f7aa94bf0d716bfe09b287a8 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/04c93cdf7208979aa4df80a3a0d5a2d8 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/0567e7171e08e75f3f91c4ca74c17adc (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/05ba948578a397e9cbc6a7b3e78622fa (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/060afe5ed25f3e2e86167e545f27edca (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/06d47d3681493f1b1d41236f460d896f (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/0724a810b0e131c2fddb6de9003b9064 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/0b5279148826f5b962bcf1896bdb4ede (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/114048c0f6b10bdc67ce9166405d195e (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/11b8464a0ef8735d202955c34c36b0c7 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/11cb626f1668c7b41954ce7d768fe528 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/14b133bf18125b75a1976fa63a1df6b7 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/153c6b3afa8faa03c8bc28f936a6d4cf (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/182cad2a342ed7317b7c21a5d17020d1 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/1c61a61bb7057b52c5b15188345a5238 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/1dbe2cf62ed2e4fa1c3cb473f08710b5 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/21199be504fcfece5c7096ee0dbba507 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/21891480074b5635dbbe7137bdcabccd (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/233aea42e15aa73e131eefabf16088c9 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/24660d4e7ac7aa21d600ea7a3d198bbb (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/25589deb55c08429345f289d1c9b0254 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/2573bd823e4da11f727a17f8e1f35c26 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/276f12da56866273e76059ad0e7be97e (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/29198a2e380cb19babec9e02116d213e (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/2c94ba9434b1a1b9396fc5364f101363 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/2d578c357dc2f5e02dc55cddb30641d1 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/2dff6cc5a223e67fde9e5e79af456992 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/2f103b1f9477f2d8934bd84328d51c75 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/31cd3a8413de13d9624adbb1613784bf (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/36415bdf1d180098fe6234b4186e69f3 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/3a04a80f0242e8dff0cd732e7c4767da (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/44d0f973b7b0fb3e4a07770c943dcd5a (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/50bc00daa0ddcd6cfb2b5d9f62c81f47 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/51ed2d1fb77b3078b54e94e85606b7df (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/5c5e0e899cf2e7d053a9e45fb76f6e5a (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/70152ed033f139443fbfb1b858bb3b1b (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/7030ca2b24e5a7f9dd8f62096a48eb33 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/71eec1a0ef2d25bb9e2ef17f23be7e9e (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/7a6b0177210ea4ef40b254daf99393c5 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/7f1567733711ffb61839621af0cbfa33 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/850c6d57c5bb7be8205fc2438d14d7e5 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/a5c8cd2784a5792b9e91c2d7895b3b34 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/a9135cdc7151d023300ff194bad90af9 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/af2597e8ac7dec1e8b4a47518312912a (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/answer_a (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/answer_aaaa (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/b3f53ef826b831bb09dd25c7f5960249 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/cda0f8751f5c4993974c2b549d29bcc8 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/ce6c26c0e469339873d0e7f616ab0945 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/clusterfuzz-5637790584012800 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/clusterfuzz-5650695891451904 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/clusterfuzz-5651369832218624 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/clusterfuzz-5674462260756480 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/clusterfuzz-5680630672654336 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/clusterfuzz-5683497160671232 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/clusterfuzz-5687310655422464 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/clusterfuzz-5695341573177344 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/clusterfuzz-5697835103682560 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/clusterfuzz-5728518081609728 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/clusterfuzz-5732960017317888 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/e4dd7e7c2dd4ed7c2e17a6af5d04f9c9 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/ed50ed8ee36230a5a69746ad830437e5 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/f1b900d50806021953321c3b604ee497 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/f6606f624be8c628328cea01d2cd07a9 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/f89f6c8176b564a7dd646f14305573ce (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/f9ad508d2dbd08d3aaaabc7d1174677d (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzzinput/multi-indir (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzznames/name01 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzznames/name02 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzznames/name03 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzznames/name04 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzznames/name05 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzznames/name06 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzznames/name07 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzznames/name08 (100%) rename lib/{c-ares-1.32.3 => c-ares-1.33.1}/test/fuzznames/name09 (100%) diff --git a/cmake/libraries.cmake b/cmake/libraries.cmake index 673784bc437..962f7d8f9b6 100644 --- a/cmake/libraries.cmake +++ b/cmake/libraries.cmake @@ -19,7 +19,7 @@ set(FLB_PATH_LIB_ONIGMO "lib/onigmo") set(FLB_PATH_LIB_MPACK "lib/mpack-amalgamation-1.1.1") set(FLB_PATH_LIB_MINIZ "lib/miniz") set(FLB_PATH_LIB_TUTF8E "lib/tutf8e") -set(FLB_PATH_LIB_CARES "lib/c-ares-1.32.3") +set(FLB_PATH_LIB_CARES "lib/c-ares-1.33.1") set(FLB_PATH_LIB_SNAPPY "lib/snappy-fef67ac") set(FLB_PATH_LIB_RDKAFKA "lib/librdkafka-2.4.0") set(FLB_PATH_LIB_RING_BUFFER "lib/lwrb") diff --git a/lib/c-ares-1.32.3/RELEASE-NOTES.md b/lib/c-ares-1.32.3/RELEASE-NOTES.md deleted file mode 100644 index 69e6a475799..00000000000 --- a/lib/c-ares-1.32.3/RELEASE-NOTES.md +++ /dev/null @@ -1,98 +0,0 @@ -## c-ares version 1.32.3 - July 24 2024 - -This is a bugfix release. - -Changes: -* Prevent complex recursion during query requeuing and connection cleanup for - stability. [e8b32b8](https://github.com/c-ares/c-ares/commit/e8b32b8) -* Better propagate error codes on requeue situations. - [a9bc0a2](https://github.com/c-ares/c-ares/commit/a9bc0a2) -* Try to prevent SIGPIPE from being generated and delivered to integrations. - [de01baa](https://github.com/c-ares/c-ares/commit/de01baa) - -Bugfixes: -* Missing manpage for `ares_dns_record_set_id()` - [aa462b3](https://github.com/c-ares/c-ares/commit/aa462b3) -* Memory leak in `ares__hosts_entry_to_hostent()` due to allocation strategy. - [PR #824](https://github.com/c-ares/c-ares/pull/824) -* UDP write failure detected via ICMP unreachable should trigger faster - failover. [PR #821](https://github.com/c-ares/c-ares/pull/821) -* Fix pycares test case regression due to wrong error code being returned. - Regression from 1.31.0. [PR #820](https://github.com/c-ares/c-ares/pull/820) -* Fix possible Windows crash during `ares_destroy()` when using event threads. - [5609bd4](https://github.com/c-ares/c-ares/commit/5609bd4) -* `ARES_OPT_MAXTIMEOUTMS` wasn't being honored in all cases. - [a649c60](https://github.com/c-ares/c-ares/commit/a649c60) - -## c-ares version 1.32.2 - July 15 2024 - -This is a bugfix release. - -Bugfixes: - -* Windows: rework EventThread AFD code for better stability. - [PR #811](https://github.com/c-ares/c-ares/pull/811) -* Windows: If an IP address was detected to have changed, it could lead to a - crash due to a bad pointer. Regression introduced in 1.31.0. - [59e3a1f4](https://github.com/c-ares/c-ares/commit/59e3a1f4) -* Windows: use `QueryPerformanceCounters()` instead of `GetTickCount64()` for - better time accuracy (~15ms -> ~1us). -* Windows 32bit config change callback needs to be tagged as `stdcall` otherwise - could result in a crash. - [5c2bab35](https://github.com/c-ares/c-ares/commit/5c2bab35) -* Tests that need accurate timing should not depend on internal symbols as there - are C++ equivalents in `std::chrono`. - [PR #809](https://github.com/c-ares/c-ares/pull/809) -* Kqueue (MacOS, \*BSD): If the open socket count exceeded 8 (unlikely), it - would try to allocate a new buffer that was too small. - [5aad7981](https://github.com/c-ares/c-ares/commit/5aad7981) - - -## c-ares version 1.32.1 - July 7 2024 - -This is a bugfix release. - -Bugfixes: -* Channel lock needs to be recursive to ensure calls into c-ares functions can - be made from callbacks otherwise deadlocks will occur. This regression was - introduced in 1.32.0. - - -## c-ares version 1.32.0 - July 4 2024 - -This is a feature and bugfix release. - -Features: - -* Add support for DNS 0x20 to help prevent cache poisoning attacks, enabled - by specifying `ARES_FLAG_DNS0x20`. Disabled by default. [PR #800](https://github.com/c-ares/c-ares/pull/800) -* Rework query timeout logic to automatically adjust timeouts based on network - conditions. The timeout specified now is only used as a hint until there - is enough history to calculate a more valid timeout. [PR #794](https://github.com/c-ares/c-ares/pull/794) - -Changes: - -* DNS RR TXT strings should not be automatically concatenated as there are use - cases outside of RFC 7208. In order to maintain ABI compliance, the ability - to retrieve TXT strings concatenated is retained as well as a new API to - retrieve the individual strings. This restores behavior from c-ares 1.20.0. - [PR #801](https://github.com/c-ares/c-ares/pull/801) -* Clean up header inclusion logic to make hacking on code easier. [PR #797](https://github.com/c-ares/c-ares/pull/797) -* GCC/Clang: Enable even more strict warnings to catch more coding flaws. [253bdee](https://github.com/c-ares/c-ares/commit/253bdee) -* MSVC: Enable `/W4` warning level. [PR #792](https://github.com/c-ares/c-ares/pull/792) - -Bugfixes: - -* Tests: Fix thread race condition in test cases for EventThread. [PR #803](https://github.com/c-ares/c-ares/pull/803) -* Windows: Fix building with UNICODE. [PR #802](https://github.com/c-ares/c-ares/pull/802) -* Thread Saftey: `ares_timeout()` was missing lock. [74a64e4](https://github.com/c-ares/c-ares/commit/74a64e4) -* Fix building with DJGPP (32bit protected mode DOS). [PR #789](https://github.com/c-ares/c-ares/pull/789) - -Thanks go to these friendly people for their efforts and contributions for this -release: - -* Brad House (@bradh352) -* Cheng (@zcbenz) - - - diff --git a/lib/c-ares-1.32.3/msvc_ver.inc b/lib/c-ares-1.32.3/msvc_ver.inc deleted file mode 100644 index 61bdb59ae2c..00000000000 --- a/lib/c-ares-1.32.3/msvc_ver.inc +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (C) The c-ares project and its contributors -# SPDX-License-Identifier: MIT -# ----------------------------------------------- -# Detect NMAKE version deducing old MSVC versions -# ----------------------------------------------- - -!IFNDEF _NMAKE_VER -! MESSAGE Macro _NMAKE_VER not defined. -! MESSAGE Use MSVC's NMAKE to process this makefile. -! ERROR See previous message. -!ENDIF - -!IF "$(_NMAKE_VER)" == "6.00.8168.0" -CC_VERS_NUM = 60 -!ELSEIF "$(_NMAKE_VER)" == "6.00.9782.0" -CC_VERS_NUM = 60 -!ELSEIF "$(_NMAKE_VER)" == "7.00.8882" -CC_VERS_NUM = 70 -!ELSEIF "$(_NMAKE_VER)" == "7.00.9466" -CC_VERS_NUM = 70 -!ELSEIF "$(_NMAKE_VER)" == "7.00.9955" -CC_VERS_NUM = 70 -!ELSE -# Pick an arbitrary bigger number for all later versions -CC_VERS_NUM = 199 -!ENDIF diff --git a/lib/c-ares-1.32.3/src/lib/Makefile.inc b/lib/c-ares-1.32.3/src/lib/Makefile.inc deleted file mode 100644 index a1f39609edc..00000000000 --- a/lib/c-ares-1.32.3/src/lib/Makefile.inc +++ /dev/null @@ -1,117 +0,0 @@ -# Copyright (C) The c-ares project and its contributors -# SPDX-License-Identifier: MIT - -CSOURCES = ares__addrinfo2hostent.c \ - ares__addrinfo_localhost.c \ - ares__buf.c \ - ares__close_sockets.c \ - ares__hosts_file.c \ - ares__htable.c \ - ares__htable_asvp.c \ - ares__htable_strvp.c \ - ares__htable_szvp.c \ - ares__htable_vpvp.c \ - ares__iface_ips.c \ - ares__llist.c \ - ares__parse_into_addrinfo.c \ - ares__slist.c \ - ares__socket.c \ - ares__sortaddrinfo.c \ - ares__threads.c \ - ares__timeval.c \ - ares_android.c \ - ares_cancel.c \ - ares_data.c \ - ares_destroy.c \ - ares_dns_mapping.c \ - ares_dns_multistring.c \ - ares_dns_name.c \ - ares_dns_parse.c \ - ares_dns_record.c \ - ares_dns_write.c \ - ares_event_configchg.c \ - ares_event_epoll.c \ - ares_event_kqueue.c \ - ares_event_poll.c \ - ares_event_select.c \ - ares_event_thread.c \ - ares_event_wake_pipe.c \ - ares_event_win32.c \ - ares_expand_name.c \ - ares_expand_string.c \ - ares_fds.c \ - ares_free_hostent.c \ - ares_free_string.c \ - ares_freeaddrinfo.c \ - ares_getaddrinfo.c \ - ares_getenv.c \ - ares_gethostbyaddr.c \ - ares_gethostbyname.c \ - ares_getnameinfo.c \ - ares_getsock.c \ - ares_init.c \ - ares_library_init.c \ - ares_math.c \ - ares_metrics.c \ - ares_create_query.c \ - ares_options.c \ - ares_parse_a_reply.c \ - ares_parse_aaaa_reply.c \ - ares_parse_caa_reply.c \ - ares_parse_mx_reply.c \ - ares_parse_naptr_reply.c \ - ares_parse_ns_reply.c \ - ares_parse_ptr_reply.c \ - ares_parse_soa_reply.c \ - ares_parse_srv_reply.c \ - ares_parse_txt_reply.c \ - ares_parse_uri_reply.c \ - ares_platform.c \ - ares_process.c \ - ares_qcache.c \ - ares_query.c \ - ares_rand.c \ - ares_search.c \ - ares_send.c \ - ares_strcasecmp.c \ - ares_str.c \ - ares_strerror.c \ - ares_strsplit.c \ - ares_sysconfig.c \ - ares_sysconfig_files.c \ - ares_sysconfig_mac.c \ - ares_sysconfig_win.c \ - ares_timeout.c \ - ares_update_servers.c \ - ares_version.c \ - inet_net_pton.c \ - inet_ntop.c \ - windows_port.c - -HHEADERS = ares__buf.h \ - ares__htable.h \ - ares__htable_asvp.h \ - ares__htable_strvp.h \ - ares__htable_szvp.h \ - ares__htable_vpvp.h \ - ares__iface_ips.h \ - ares__llist.h \ - ares__slist.h \ - ares__threads.h \ - ares_android.h \ - ares_data.h \ - ares_dns_multistring.h \ - ares_dns_private.h \ - ares_event.h \ - ares_event_win32.h \ - ares_getenv.h \ - ares_inet_net_pton.h \ - ares_ipv6.h \ - ares_platform.h \ - ares_private.h \ - ares_strcasecmp.h \ - ares_str.h \ - ares_strsplit.h \ - ares_setup.h \ - thirdparty/apple/dnsinfo.h - diff --git a/lib/c-ares-1.32.3/src/lib/ares__socket.c b/lib/c-ares-1.32.3/src/lib/ares__socket.c deleted file mode 100644 index 3db19f7e823..00000000000 --- a/lib/c-ares-1.32.3/src/lib/ares__socket.c +++ /dev/null @@ -1,486 +0,0 @@ -/* MIT License - * - * Copyright (c) Massachusetts Institute of Technology - * Copyright (c) The c-ares project and its contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * SPDX-License-Identifier: MIT - */ -#include "ares_private.h" - -#ifdef HAVE_SYS_UIO_H -# include -#endif -#ifdef HAVE_NETINET_IN_H -# include -#endif -#ifdef HAVE_NETINET_TCP_H -# include -#endif -#ifdef HAVE_NETDB_H -# include -#endif -#ifdef HAVE_ARPA_INET_H -# include -#endif - -#ifdef HAVE_STRINGS_H -# include -#endif -#ifdef HAVE_SYS_IOCTL_H -# include -#endif -#ifdef NETWARE -# include -#endif - -#include -#include -#include - - -ares_ssize_t ares__socket_recvfrom(ares_channel_t *channel, ares_socket_t s, - void *data, size_t data_len, int flags, - struct sockaddr *from, - ares_socklen_t *from_len) -{ - if (channel->sock_funcs && channel->sock_funcs->arecvfrom) { - return channel->sock_funcs->arecvfrom(s, data, data_len, flags, from, - from_len, channel->sock_func_cb_data); - } - -#ifdef HAVE_RECVFROM - return (ares_ssize_t)recvfrom(s, data, (RECVFROM_TYPE_ARG3)data_len, flags, - from, from_len); -#else - return sread(s, data, data_len); -#endif -} - -ares_ssize_t ares__socket_recv(ares_channel_t *channel, ares_socket_t s, - void *data, size_t data_len) -{ - if (channel->sock_funcs && channel->sock_funcs->arecvfrom) { - return channel->sock_funcs->arecvfrom(s, data, data_len, 0, 0, 0, - channel->sock_func_cb_data); - } - - /* sread() is a wrapper for read() or recv() depending on the system */ - return sread(s, data, data_len); -} - -/* - * setsocknonblock sets the given socket to either blocking or non-blocking - * mode based on the 'nonblock' boolean argument. This function is highly - * portable. - */ -static int setsocknonblock(ares_socket_t sockfd, /* operate on this */ - int nonblock /* TRUE or FALSE */) -{ -#if defined(USE_BLOCKING_SOCKETS) - - return 0; /* returns success */ - -#elif defined(HAVE_FCNTL_O_NONBLOCK) - - /* most recent unix versions */ - int flags; - flags = fcntl(sockfd, F_GETFL, 0); - if (nonblock) { - return fcntl(sockfd, F_SETFL, flags | O_NONBLOCK); - } else { - return fcntl(sockfd, F_SETFL, flags & (~O_NONBLOCK)); /* LCOV_EXCL_LINE */ - } - -#elif defined(HAVE_IOCTL_FIONBIO) - - /* older unix versions */ - int flags = nonblock ? 1 : 0; - return ioctl(sockfd, FIONBIO, &flags); - -#elif defined(HAVE_IOCTLSOCKET_FIONBIO) - -# ifdef WATT32 - char flags = nonblock ? 1 : 0; -# else - /* Windows */ - unsigned long flags = nonblock ? 1UL : 0UL; -# endif - return ioctlsocket(sockfd, (long)FIONBIO, &flags); - -#elif defined(HAVE_IOCTLSOCKET_CAMEL_FIONBIO) - - /* Amiga */ - long flags = nonblock ? 1L : 0L; - return IoctlSocket(sockfd, FIONBIO, flags); - -#elif defined(HAVE_SETSOCKOPT_SO_NONBLOCK) - - /* BeOS */ - long b = nonblock ? 1L : 0L; - return setsockopt(sockfd, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b)); - -#else -# error "no non-blocking method was found/used/set" -#endif -} - -#if defined(IPV6_V6ONLY) && defined(USE_WINSOCK) -/* It makes support for IPv4-mapped IPv6 addresses. - * Linux kernel, NetBSD, FreeBSD and Darwin: default is off; - * Windows Vista and later: default is on; - * DragonFly BSD: acts like off, and dummy setting; - * OpenBSD and earlier Windows: unsupported. - * Linux: controlled by /proc/sys/net/ipv6/bindv6only. - */ -static void set_ipv6_v6only(ares_socket_t sockfd, int on) -{ - (void)setsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&on, sizeof(on)); -} -#else -# define set_ipv6_v6only(s, v) -#endif - -static int configure_socket(ares_socket_t s, struct server_state *server) -{ - union { - struct sockaddr sa; - struct sockaddr_in sa4; - struct sockaddr_in6 sa6; - } local; - - ares_socklen_t bindlen = 0; - ares_channel_t *channel = server->channel; - - /* do not set options for user-managed sockets */ - if (channel->sock_funcs && channel->sock_funcs->asocket) { - return 0; - } - - (void)setsocknonblock(s, 1); - -#if defined(FD_CLOEXEC) && !defined(MSDOS) - /* Configure the socket fd as close-on-exec. */ - if (fcntl(s, F_SETFD, FD_CLOEXEC) == -1) { - return -1; /* LCOV_EXCL_LINE */ - } -#endif - - /* No need to emit SIGPIPE on socket errors */ -#if defined(SO_NOSIGPIPE) - { - int opt = 1; - setsockopt(s, SOL_SOCKET, SO_NOSIGPIPE, (void *)&opt, sizeof(opt)); - } -#endif - - /* Set the socket's send and receive buffer sizes. */ - if ((channel->socket_send_buffer_size > 0) && - setsockopt(s, SOL_SOCKET, SO_SNDBUF, - (void *)&channel->socket_send_buffer_size, - sizeof(channel->socket_send_buffer_size)) == -1) { - return -1; /* LCOV_EXCL_LINE: UntestablePath */ - } - - if ((channel->socket_receive_buffer_size > 0) && - setsockopt(s, SOL_SOCKET, SO_RCVBUF, - (void *)&channel->socket_receive_buffer_size, - sizeof(channel->socket_receive_buffer_size)) == -1) { - return -1; /* LCOV_EXCL_LINE: UntestablePath */ - } - -#ifdef SO_BINDTODEVICE - if (channel->local_dev_name[0] && - setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE, channel->local_dev_name, - sizeof(channel->local_dev_name))) { - /* Only root can do this, and usually not fatal if it doesn't work, so */ - /* just continue on. */ - } -#endif - - if (server->addr.family == AF_INET && channel->local_ip4) { - memset(&local.sa4, 0, sizeof(local.sa4)); - local.sa4.sin_family = AF_INET; - local.sa4.sin_addr.s_addr = htonl(channel->local_ip4); - bindlen = sizeof(local.sa4); - } else if (server->addr.family == AF_INET6 && server->ll_scope == 0 && - memcmp(channel->local_ip6, ares_in6addr_any._S6_un._S6_u8, - sizeof(channel->local_ip6)) != 0) { - /* Only if not link-local and an ip other than "::" is specified */ - memset(&local.sa6, 0, sizeof(local.sa6)); - local.sa6.sin6_family = AF_INET6; - memcpy(&local.sa6.sin6_addr, channel->local_ip6, - sizeof(channel->local_ip6)); - bindlen = sizeof(local.sa6); - } - - if (bindlen && bind(s, &local.sa, bindlen) < 0) { - return -1; - } - - if (server->addr.family == AF_INET6) { - set_ipv6_v6only(s, 0); - } - - return 0; -} - -ares_status_t ares__open_connection(ares_channel_t *channel, - struct server_state *server, - ares_bool_t is_tcp) -{ - ares_socket_t s; - int opt; - ares_socklen_t salen; - - union { - struct sockaddr_in sa4; - struct sockaddr_in6 sa6; - } saddr; - struct sockaddr *sa; - struct server_connection *conn; - ares__llist_node_t *node; - int type = is_tcp ? SOCK_STREAM : SOCK_DGRAM; - - switch (server->addr.family) { - case AF_INET: - sa = (void *)&saddr.sa4; - salen = sizeof(saddr.sa4); - memset(sa, 0, (size_t)salen); - saddr.sa4.sin_family = AF_INET; - saddr.sa4.sin_port = htons(is_tcp ? server->tcp_port : server->udp_port); - memcpy(&saddr.sa4.sin_addr, &server->addr.addr.addr4, - sizeof(saddr.sa4.sin_addr)); - break; - case AF_INET6: - sa = (void *)&saddr.sa6; - salen = sizeof(saddr.sa6); - memset(sa, 0, (size_t)salen); - saddr.sa6.sin6_family = AF_INET6; - saddr.sa6.sin6_port = htons(is_tcp ? server->tcp_port : server->udp_port); - memcpy(&saddr.sa6.sin6_addr, &server->addr.addr.addr6, - sizeof(saddr.sa6.sin6_addr)); -#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID - saddr.sa6.sin6_scope_id = server->ll_scope; -#endif - break; - default: - return ARES_EBADFAMILY; /* LCOV_EXCL_LINE */ - } - - /* Acquire a socket. */ - s = ares__open_socket(channel, server->addr.family, type, 0); - if (s == ARES_SOCKET_BAD) { - return ARES_ECONNREFUSED; - } - - /* Configure it. */ - if (configure_socket(s, server) < 0) { - ares__close_socket(channel, s); - return ARES_ECONNREFUSED; - } - -#ifdef TCP_NODELAY - if (is_tcp) { - /* - * Disable the Nagle algorithm (only relevant for TCP sockets, and thus not - * in configure_socket). In general, in DNS lookups we're pretty much - * interested in firing off a single request and then waiting for a reply, - * so batching isn't very interesting. - */ - opt = 1; - if ((!channel->sock_funcs || !channel->sock_funcs->asocket) && - setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (void *)&opt, sizeof(opt)) == - -1) { - ares__close_socket(channel, s); /* LCOV_EXCL_LINE: UntestablePath */ - return ARES_ECONNREFUSED; /* LCOV_EXCL_LINE: UntestablePath */ - } - } -#endif - - if (channel->sock_config_cb) { - int err = channel->sock_config_cb(s, type, channel->sock_config_cb_data); - if (err < 0) { - ares__close_socket(channel, s); - return ARES_ECONNREFUSED; - } - } - - /* Connect to the server. */ - if (ares__connect_socket(channel, s, sa, salen) == -1) { - int err = SOCKERRNO; - - if (err != EINPROGRESS && err != EWOULDBLOCK) { - ares__close_socket(channel, s); - return ARES_ECONNREFUSED; - } - } - - if (channel->sock_create_cb) { - int err = channel->sock_create_cb(s, type, channel->sock_create_cb_data); - if (err < 0) { - ares__close_socket(channel, s); - return ARES_ECONNREFUSED; - } - } - - conn = ares_malloc(sizeof(*conn)); - if (conn == NULL) { - ares__close_socket(channel, s); /* LCOV_EXCL_LINE: OutOfMemory */ - return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - } - memset(conn, 0, sizeof(*conn)); - conn->fd = s; - conn->server = server; - conn->queries_to_conn = ares__llist_create(NULL); - conn->is_tcp = is_tcp; - if (conn->queries_to_conn == NULL) { - /* LCOV_EXCL_START: OutOfMemory */ - ares__close_socket(channel, s); - ares_free(conn); - return ARES_ENOMEM; - /* LCOV_EXCL_STOP */ - } - - /* TCP connections are thrown to the end as we don't spawn multiple TCP - * connections. UDP connections are put on front where the newest connection - * can be quickly pulled */ - if (is_tcp) { - node = ares__llist_insert_last(server->connections, conn); - } else { - node = ares__llist_insert_first(server->connections, conn); - } - if (node == NULL) { - /* LCOV_EXCL_START: OutOfMemory */ - ares__close_socket(channel, s); - ares__llist_destroy(conn->queries_to_conn); - ares_free(conn); - return ARES_ENOMEM; - /* LCOV_EXCL_STOP */ - } - - /* Register globally to quickly map event on file descriptor to connection - * node object */ - if (!ares__htable_asvp_insert(channel->connnode_by_socket, s, node)) { - /* LCOV_EXCL_START: OutOfMemory */ - ares__close_socket(channel, s); - ares__llist_destroy(conn->queries_to_conn); - ares__llist_node_claim(node); - ares_free(conn); - return ARES_ENOMEM; - /* LCOV_EXCL_STOP */ - } - - SOCK_STATE_CALLBACK(channel, s, 1, 0); - - if (is_tcp) { - server->tcp_conn = conn; - } - - return ARES_SUCCESS; -} - -ares_socket_t ares__open_socket(ares_channel_t *channel, int af, int type, - int protocol) -{ - if (channel->sock_funcs && channel->sock_funcs->asocket) { - return channel->sock_funcs->asocket(af, type, protocol, - channel->sock_func_cb_data); - } - - return socket(af, type, protocol); -} - -int ares__connect_socket(ares_channel_t *channel, ares_socket_t sockfd, - const struct sockaddr *addr, ares_socklen_t addrlen) -{ - if (channel->sock_funcs && channel->sock_funcs->aconnect) { - return channel->sock_funcs->aconnect(sockfd, addr, addrlen, - channel->sock_func_cb_data); - } - - return connect(sockfd, addr, addrlen); -} - -void ares__close_socket(ares_channel_t *channel, ares_socket_t s) -{ - if (s == ARES_SOCKET_BAD) { - return; - } - - if (channel->sock_funcs && channel->sock_funcs->aclose) { - channel->sock_funcs->aclose(s, channel->sock_func_cb_data); - } else { - sclose(s); - } -} - -#ifndef HAVE_WRITEV -/* Structure for scatter/gather I/O. */ -struct iovec { - void *iov_base; /* Pointer to data. */ - size_t iov_len; /* Length of data. */ -}; -#endif - -ares_ssize_t ares__socket_write(ares_channel_t *channel, ares_socket_t s, - const void *data, size_t len) -{ - if (channel->sock_funcs && channel->sock_funcs->asendv) { - struct iovec vec; - vec.iov_base = (void *)((size_t)data); /* Cast off const */ - vec.iov_len = len; - return channel->sock_funcs->asendv(s, &vec, 1, channel->sock_func_cb_data); - } - return swrite(s, data, len); -} - -void ares_set_socket_callback(ares_channel_t *channel, - ares_sock_create_callback cb, void *data) -{ - if (channel == NULL) { - return; - } - channel->sock_create_cb = cb; - channel->sock_create_cb_data = data; -} - -void ares_set_socket_configure_callback(ares_channel_t *channel, - ares_sock_config_callback cb, - void *data) -{ - if (channel == NULL || channel->optmask & ARES_OPT_EVENT_THREAD) { - return; - } - channel->sock_config_cb = cb; - channel->sock_config_cb_data = data; -} - -void ares_set_socket_functions(ares_channel_t *channel, - const struct ares_socket_functions *funcs, - void *data) -{ - if (channel == NULL || channel->optmask & ARES_OPT_EVENT_THREAD) { - return; - } - channel->sock_funcs = funcs; - channel->sock_func_cb_data = data; -} diff --git a/lib/c-ares-1.32.3/AUTHORS b/lib/c-ares-1.33.1/AUTHORS similarity index 100% rename from lib/c-ares-1.32.3/AUTHORS rename to lib/c-ares-1.33.1/AUTHORS diff --git a/lib/c-ares-1.32.3/CMakeLists.txt b/lib/c-ares-1.33.1/CMakeLists.txt similarity index 96% rename from lib/c-ares-1.32.3/CMakeLists.txt rename to lib/c-ares-1.33.1/CMakeLists.txt index 2505967d352..9862406495f 100644 --- a/lib/c-ares-1.32.3/CMakeLists.txt +++ b/lib/c-ares-1.33.1/CMakeLists.txt @@ -12,7 +12,7 @@ INCLUDE (CheckCSourceCompiles) INCLUDE (CheckStructHasMember) INCLUDE (CheckLibraryExists) -PROJECT (c-ares LANGUAGES C VERSION "1.32.3" ) +PROJECT (c-ares LANGUAGES C VERSION "1.33.1" ) # Set this version before release SET (CARES_VERSION "${PROJECT_VERSION}") @@ -30,7 +30,7 @@ INCLUDE (GNUInstallDirs) # include this *AFTER* PROJECT(), otherwise paths are w # For example, a version of 4:0:2 would generate output such as: # libname.so -> libname.so.2 # libname.so.2 -> libname.so.2.2.0 -SET (CARES_LIB_VERSIONINFO "19:3:17") +SET (CARES_LIB_VERSIONINFO "20:1:18") OPTION (CARES_STATIC "Build as a static library" OFF) @@ -42,6 +42,7 @@ OPTION (CARES_BUILD_CONTAINER_TESTS "Build and run container tests (implies CARE OPTION (CARES_BUILD_TOOLS "Build tools" ON) OPTION (CARES_SYMBOL_HIDING "Hide private symbols in shared libraries" OFF) OPTION (CARES_THREADS "Build with thread-safety support" ON) +OPTION (CARES_COVERAGE "Build for code coverage" OFF) SET (CARES_RANDOM_FILE "/dev/urandom" CACHE STRING "Suitable File / Device Path for entropy, such as /dev/urandom") @@ -265,7 +266,7 @@ IF (CMAKE_SYSTEM_NAME STREQUAL "Darwin") ELSEIF (CMAKE_SYSTEM_NAME STREQUAL "Linux") LIST (APPEND SYSFLAGS -D_GNU_SOURCE -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700) ELSEIF (CMAKE_SYSTEM_NAME STREQUAL "SunOS") - LIST (APPEND SYSFLAGS -D__EXTENSIONS__ -D_REENTRANT -D_XOPEN_SOURCE=700) + LIST (APPEND SYSFLAGS -D__EXTENSIONS__ -D_REENTRANT -D_XOPEN_SOURCE=600) ELSEIF (CMAKE_SYSTEM_NAME STREQUAL "AIX") LIST (APPEND SYSFLAGS -D_ALL_SOURCE -D_XOPEN_SOURCE=700 -D_USE_IRS) ELSEIF (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") @@ -409,6 +410,7 @@ CHECK_STRUCT_HAS_MEMBER("struct sockaddr_in6" sin6_scope_id "${CMAKE_EXTRA_INCLU CHECK_SYMBOL_EXISTS (closesocket "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_CLOSESOCKET) CHECK_SYMBOL_EXISTS (CloseSocket "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_CLOSESOCKET_CAMEL) CHECK_SYMBOL_EXISTS (connect "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_CONNECT) +CHECK_SYMBOL_EXISTS (connectx "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_CONNECTX) CHECK_SYMBOL_EXISTS (fcntl "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_FCNTL) CHECK_SYMBOL_EXISTS (freeaddrinfo "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_FREEADDRINFO) CHECK_SYMBOL_EXISTS (getaddrinfo "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_GETADDRINFO) @@ -423,6 +425,10 @@ CHECK_SYMBOL_EXISTS (if_indextoname "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_IF_INDE CHECK_SYMBOL_EXISTS (if_nametoindex "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_IF_NAMETOINDEX) CHECK_SYMBOL_EXISTS (ConvertInterfaceIndexToLuid "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_CONVERTINTERFACEINDEXTOLUID) CHECK_SYMBOL_EXISTS (ConvertInterfaceLuidToNameA "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_CONVERTINTERFACELUIDTONAMEA) +CHECK_SYMBOL_EXISTS (NotifyIpInterfaceChange "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_NOTIFYIPINTERFACECHANGE) +CHECK_SYMBOL_EXISTS (RegisterWaitForSingleObject "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_REGISTERWAITFORSINGLEOBJECT) + + CHECK_SYMBOL_EXISTS (inet_net_pton "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_INET_NET_PTON) IF (NOT WIN32) # Disabled on Windows, because these functions are only really supported on Windows @@ -682,6 +688,27 @@ IF (HAVE_ARPA_NAMESER_COMPAT_H) SET (CARES_HAVE_ARPA_NAMESER_COMPAT_H 1) ENDIF() + +# Coverage +IF (CARES_COVERAGE) + # set compiler flags + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ftest-coverage -fprofile-arcs") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftest-coverage -fprofile-arcs") + + # find required tools + FIND_PROGRAM(LCOV lcov REQUIRED) + FIND_PROGRAM(GENHTML genhtml REQUIRED) + + # add coverage target + ADD_CUSTOM_TARGET(coverage + # gather data + COMMAND ${LCOV} --directory . --capture --output-file coverage.info + # generate report + COMMAND ${GENHTML} --demangle-cpp -o coverage coverage.info + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) +ENDIF() + # TRANSFORM_MAKEFILE_INC # # This function consumes the "Makefile.inc" autotools file, and converts it into @@ -729,6 +756,8 @@ IF (CARES_BUILD_TESTS OR CARES_BUILD_CONTAINER_TESTS) ENDIF () + + # Export targets IF (CARES_INSTALL) SET (CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") @@ -743,12 +772,11 @@ IF (CARES_INSTALL) INSTALL (EXPORT ${PROJECT_NAME}-targets COMPONENT Devel DESTINATION ${CMAKECONFIG_INSTALL_DIR} NAMESPACE ${PROJECT_NAME}::) INSTALL (FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake" COMPONENT Devel DESTINATION ${CMAKECONFIG_INSTALL_DIR}) - # pkgconfig support - IF (NOT CARES_SHARED) - FOREACH (LIB ${CARES_DEPENDENT_LIBS}) - SET (CARES_PRIVATE_LIBS "${CARES_PRIVATE_LIBS} -l${LIB}") - ENDFOREACH () - ENDIF () + # pkgconfig support for static builds + FOREACH (LIB ${CARES_DEPENDENT_LIBS}) + SET (CARES_PRIVATE_LIBS "${CARES_PRIVATE_LIBS} -l${LIB}") + ENDFOREACH () + CONFIGURE_FILE("libcares.pc.cmake" "libcares.pc" @ONLY) INSTALL (FILES "${CMAKE_CURRENT_BINARY_DIR}/libcares.pc" COMPONENT Devel DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") ENDIF () diff --git a/lib/c-ares-1.32.3/CONTRIBUTING.md b/lib/c-ares-1.33.1/CONTRIBUTING.md similarity index 100% rename from lib/c-ares-1.32.3/CONTRIBUTING.md rename to lib/c-ares-1.33.1/CONTRIBUTING.md diff --git a/lib/c-ares-1.32.3/DEVELOPER-NOTES.md b/lib/c-ares-1.33.1/DEVELOPER-NOTES.md similarity index 100% rename from lib/c-ares-1.32.3/DEVELOPER-NOTES.md rename to lib/c-ares-1.33.1/DEVELOPER-NOTES.md diff --git a/lib/c-ares-1.32.3/INSTALL.md b/lib/c-ares-1.33.1/INSTALL.md similarity index 100% rename from lib/c-ares-1.32.3/INSTALL.md rename to lib/c-ares-1.33.1/INSTALL.md diff --git a/lib/c-ares-1.32.3/LICENSE.md b/lib/c-ares-1.33.1/LICENSE.md similarity index 98% rename from lib/c-ares-1.32.3/LICENSE.md rename to lib/c-ares-1.33.1/LICENSE.md index e27bae933fc..910ddded5c7 100644 --- a/lib/c-ares-1.32.3/LICENSE.md +++ b/lib/c-ares-1.33.1/LICENSE.md @@ -1,5 +1,3 @@ -# c-ares license - MIT License Copyright (c) 1998 Massachusetts Institute of Technology diff --git a/lib/c-ares-1.32.3/Makefile.Watcom b/lib/c-ares-1.33.1/Makefile.Watcom similarity index 68% rename from lib/c-ares-1.32.3/Makefile.Watcom rename to lib/c-ares-1.33.1/Makefile.Watcom index f6eb7c070b2..96ffedb1eb3 100644 --- a/lib/c-ares-1.32.3/Makefile.Watcom +++ b/lib/c-ares-1.33.1/Makefile.Watcom @@ -97,7 +97,19 @@ all: $(ARESBUILDH) $(OBJ_BASE) $(TARGETS) $(DEMOS) .SYMBOLIC $(OBJ_BASE): -$(MD) $^@ -$(MD) $^@\stat + -$(MD) $^@\stat\dsa + -$(MD) $^@\stat\event + -$(MD) $^@\stat\legacy + -$(MD) $^@\stat\record + -$(MD) $^@\stat\str + -$(MD) $^@\stat\util -$(MD) $^@\dyn + -$(MD) $^@\dyn\dsa + -$(MD) $^@\dyn\event + -$(MD) $^@\dyn\legacy + -$(MD) $^@\dyn\record + -$(MD) $^@\dyn\str + -$(MD) $^@\dyn\util -$(MD) $^@\tools $(ARESBUILDH): .EXISTSONLY @@ -129,7 +141,19 @@ vclean realclean: clean .SYMBOLIC -$(RM) $(TARGETS) $(LIBNAME).map -$(RM) $(DEMOS) $(DEMOS:.exe=.map) -$(RD) $(OBJ_BASE)\stat + -$(RD) $(OBJ_BASE)\stat\dsa + -$(RD) $(OBJ_BASE)\stat\event + -$(RD) $(OBJ_BASE)\stat\legacy + -$(RD) $(OBJ_BASE)\stat\record + -$(RD) $(OBJ_BASE)\stat\str + -$(RD) $(OBJ_BASE)\stat\util -$(RD) $(OBJ_BASE)\dyn + -$(RD) $(OBJ_BASE)\dyn\dsa + -$(RD) $(OBJ_BASE)\dyn\event + -$(RD) $(OBJ_BASE)\dyn\legacy + -$(RD) $(OBJ_BASE)\dyn\record + -$(RD) $(OBJ_BASE)\dyn\str + -$(RD) $(OBJ_BASE)\dyn\util -$(RD) $(OBJ_BASE)\tools -$(RD) $(OBJ_BASE) @@ -144,10 +168,58 @@ $(RESOURCE): src\lib\cares.rc .AUTODEPEND .c{$(OBJ_BASE)\dyn}.obj: $(CC) $(CFLAGS) -bd .\src\lib\$^& -fo=$^@ +.ERASE +{dsa}.c{$(OBJ_BASE)\dyn\dsa}.obj: + $(CC) $(CFLAGS) -bd .\src\lib\dsa\$^& -fo=$^@ + +.ERASE +{event}.c{$(OBJ_BASE)\dyn\event}.obj: + $(CC) $(CFLAGS) -bd .\src\lib\event\$^& -fo=$^@ + +.ERASE +{legacy}.c{$(OBJ_BASE)\dyn\legacy}.obj: + $(CC) $(CFLAGS) -bd .\src\lib\legacy\$^& -fo=$^@ + +.ERASE +{record}.c{$(OBJ_BASE)\dyn\record}.obj: + $(CC) $(CFLAGS) -bd .\src\lib\record\$^& -fo=$^@ + +.ERASE +{str}.c{$(OBJ_BASE)\dyn\str}.obj: + $(CC) $(CFLAGS) -bd .\src\lib\str\$^& -fo=$^@ + +.ERASE +{util}.c{$(OBJ_BASE)\dyn\util}.obj: + $(CC) $(CFLAGS) -bd .\src\lib\util\$^& -fo=$^@ + .ERASE .c{$(OBJ_BASE)\stat}.obj: $(CC) $(CFLAGS) -DCARES_STATICLIB .\src\lib\$^& -fo=$^@ +.ERASE +{dsa}.c{$(OBJ_BASE)\stat\dsa}.obj: + $(CC) $(CFLAGS) -DCARES_STATICLIB .\src\lib\dsa\$^& -fo=$^@ + +.ERASE +{event}.c{$(OBJ_BASE)\stat\event}.obj: + $(CC) $(CFLAGS) -DCARES_STATICLIB .\src\lib\event\$^& -fo=$^@ + +.ERASE +{legacy}.c{$(OBJ_BASE)\stat\legacy}.obj: + $(CC) $(CFLAGS) -DCARES_STATICLIB .\src\lib\legacy\$^& -fo=$^@ + +.ERASE +{record}.c{$(OBJ_BASE)\stat\record}.obj: + $(CC) $(CFLAGS) -DCARES_STATICLIB .\src\lib\record\$^& -fo=$^@ + +.ERASE +{str}.c{$(OBJ_BASE)\stat\str}.obj: + $(CC) $(CFLAGS) -DCARES_STATICLIB .\src\lib\str\$^& -fo=$^@ + +.ERASE +{util}.c{$(OBJ_BASE)\stat\util}.obj: + $(CC) $(CFLAGS) -DCARES_STATICLIB .\src\lib\util\$^& -fo=$^@ + $(LINK_ARG): $(__MAKEFILES__) %create $^@ @%append $^@ system nt dll diff --git a/lib/c-ares-1.32.3/Makefile.am b/lib/c-ares-1.33.1/Makefile.am similarity index 98% rename from lib/c-ares-1.32.3/Makefile.am rename to lib/c-ares-1.33.1/Makefile.am index 6c71f4d77d8..e99161a45f7 100644 --- a/lib/c-ares-1.32.3/Makefile.am +++ b/lib/c-ares-1.33.1/Makefile.am @@ -22,7 +22,7 @@ AUTOMAKE_OPTIONS = foreign nostdinc 1.9.6 ACLOCAL_AMFLAGS = -I m4 --install -MSVCFILES = msvc_ver.inc buildconf.bat +MSVCFILES = buildconf.bat # adig and ahost are just sample programs and thus not mentioned with the # regular sources and headers diff --git a/lib/c-ares-1.32.3/Makefile.dj b/lib/c-ares-1.33.1/Makefile.dj similarity index 86% rename from lib/c-ares-1.32.3/Makefile.dj rename to lib/c-ares-1.33.1/Makefile.dj index c28aefe9e22..69b3ca31851 100644 --- a/lib/c-ares-1.32.3/Makefile.dj +++ b/lib/c-ares-1.33.1/Makefile.dj @@ -5,8 +5,14 @@ # include src/lib/Makefile.inc -CSOURCES := $(addprefix src/lib/, $(CSOURCES)) -CSOURCES := $(filter-out src/lib/windows_port.c, $(CSOURCES)) +OBJ_DIR = djgpp +OBJECTS = $(addprefix $(OBJ_DIR)/, \ + $(CSOURCES:.c=.o)) + +CSRC = $(addprefix src/lib/, $(CSOURCES)) +#CSRC := $(filter-out src/lib/windows_port.c, $(CSOURCES)) + +OBJ_SUBDIRS = $(OBJ_DIR)/dsa $(OBJ_DIR)/event $(OBJ_DIR)/legacy $(OBJ_DIR)/record $(OBJ_DIR)/str $(OBJ_DIR)/util VPATH = src/lib src/tools @@ -17,8 +23,6 @@ VPATH = src/lib src/tools WATT32_ROOT = $(realpath $(WATT_ROOT)) WATT32_LIB = $(WATT32_ROOT)/lib/libwatt.a -OBJ_DIR = djgpp - CFLAGS = -g -O2 -I./include -I./src/lib \ -I$(WATT32_ROOT)/inc \ -Wall \ @@ -82,9 +86,6 @@ else CC = gcc endif -OBJECTS = $(addprefix $(OBJ_DIR)/, \ - $(notdir $(CSOURCES:.c=.o))) - GENERATED = src/lib/ares_config.h \ include/ares_build.h @@ -92,7 +93,7 @@ TARGETS = libcares.a adig.exe ahost.exe .SECONDARY: $(OBJ_DIR)/ares_getopt.o -all: $(OBJ_DIR) $(GENERATED) $(TARGETS) +all: $(OBJ_DIR) $(OBJ_SUBDIRS) $(GENERATED) $(TARGETS) @echo Welcome to c-ares. libcares.a: $(OBJECTS) @@ -111,15 +112,19 @@ include/ares_build.h: include/ares_build.h.dist # clean: - rm -f depend.dj $(GENERATED) $(OBJ_DIR)/*.o - - rmdir $(OBJ_DIR) + - rmdir $(OBJ_SUBDIRS) # Clean everything # realclean vclean: clean - rm -f $(TARGETS) $(TARGETS:.exe=.map) -$(OBJ_DIR): - - mkdir $@ +.PHONY: obj_subdirs $(OBJ_SUBDIRS) + +obj_subdirs: $(OBJ_SUBDIRS) + +$(OBJ_SUBDIRS): + mkdir $@ $(OBJ_DIR)/%.o: %.c $(CC) $(CFLAGS) -o $@ -c $< @@ -138,7 +143,7 @@ DEP_REPLACE = sed -e 's@\(.*\)\.o: @\n$$(OBJ_DIR)\/\1.o: @' \ # a foreign 'curl_config.h' is making trouble. # depend: $(GENERATED) Makefile.dj - $(CC) -MM $(CFLAGS) $(CSOURCES) | $(DEP_REPLACE) > depend.dj + $(CC) -MM $(CFLAGS) $(CSRC) | $(DEP_REPLACE) > depend.dj -include depend.dj diff --git a/lib/c-ares-1.32.3/Makefile.in b/lib/c-ares-1.33.1/Makefile.in similarity index 96% rename from lib/c-ares-1.32.3/Makefile.in rename to lib/c-ares-1.33.1/Makefile.in index 7b5a962b8cc..706dafdbdfc 100644 --- a/lib/c-ares-1.32.3/Makefile.in +++ b/lib/c-ares-1.33.1/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.5 from Makefile.am. +# Makefile.in generated by automake 1.17 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2021 Free Software Foundation, Inc. +# Copyright (C) 1994-2024 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -91,6 +91,8 @@ am__make_running_with_option = \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +am__rm_f = rm -f $(am__rm_f_notfound) +am__rm_rf = rm -rf $(am__rm_f_notfound) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -194,10 +196,9 @@ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ + { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && echo $$files | $(am__xargs_n) 40 $(am__rm_f); }; \ } am__installdirs = "$(DESTDIR)$(pkgconfigdir)" DATA = $(pkgconfig_DATA) @@ -238,8 +239,8 @@ distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ if test -d "$(distdir)"; then \ - find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ - && rm -rf "$(distdir)" \ + find "$(distdir)" -type d ! -perm -700 -exec chmod u+rwx {} ';' \ + ; rm -rf "$(distdir)" \ || { sleep 5 && rm -rf "$(distdir)"; }; \ else :; fi am__post_remove_distdir = $(am__remove_distdir) @@ -269,14 +270,16 @@ am__relativize = \ done; \ reldir="$$dir2" DIST_ARCHIVES = $(distdir).tar.gz -GZIP_ENV = --best +GZIP_ENV = -9 DIST_TARGETS = dist-gzip # Exists only to be overridden by the user if desired. AM_DISTCHECK_DVI_TARGET = dvi distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' -distcleancheck_listfiles = find . -type f -print +distcleancheck_listfiles = \ + find . \( -type f -a \! \ + \( -name .nfs* -o -name .smb* -o -name .__afs* \) \) -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ @@ -325,6 +328,8 @@ FGREP = @FGREP@ FILECMD = @FILECMD@ GCOV = @GCOV@ GENHTML = @GENHTML@ +GMOCK112_CFLAGS = @GMOCK112_CFLAGS@ +GMOCK112_LIBS = @GMOCK112_LIBS@ GMOCK_CFLAGS = @GMOCK_CFLAGS@ GMOCK_LIBS = @GMOCK_LIBS@ GREP = @GREP@ @@ -387,8 +392,10 @@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ +am__rm_f_notfound = @am__rm_f_notfound@ am__tar = @am__tar@ am__untar = @am__untar@ +am__xargs_n = @am__xargs_n@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ @@ -435,7 +442,7 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = foreign nostdinc 1.9.6 ACLOCAL_AMFLAGS = -I m4 --install -MSVCFILES = msvc_ver.inc buildconf.bat +MSVCFILES = buildconf.bat # adig and ahost are just sample programs and thus not mentioned with the # regular sources and headers @@ -634,7 +641,7 @@ distdir: $(BUILT_SOURCES) distdir-am: $(DISTFILES) $(am__remove_distdir) - test -d "$(distdir)" || mkdir "$(distdir)" + $(AM_V_at)$(MKDIR_P) "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -748,7 +755,7 @@ dist dist-all: distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ - eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\ + eval GZIP= gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lz*) \ @@ -758,7 +765,7 @@ distcheck: dist *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ - eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\ + eval GZIP= gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ *.tar.zst*) \ @@ -859,12 +866,12 @@ install-strip: mostlyclean-generic: clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + -$(am__rm_f) $(CLEANFILES) distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + -$(am__rm_f) $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || $(am__rm_f) $(CONFIG_CLEAN_VPATH_FILES) + -$(am__rm_f) $(DISTCLEANFILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @@ -973,3 +980,10 @@ dist-hook: # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: + +# Tell GNU make to disable its built-in pattern rules. +%:: %,v +%:: RCS/%,v +%:: RCS/% +%:: s.% +%:: SCCS/s.% diff --git a/lib/c-ares-1.32.3/Makefile.m32 b/lib/c-ares-1.33.1/Makefile.m32 similarity index 100% rename from lib/c-ares-1.32.3/Makefile.m32 rename to lib/c-ares-1.33.1/Makefile.m32 diff --git a/lib/c-ares-1.32.3/Makefile.msvc b/lib/c-ares-1.33.1/Makefile.msvc similarity index 85% rename from lib/c-ares-1.32.3/Makefile.msvc rename to lib/c-ares-1.33.1/Makefile.msvc index 4b338f27999..619c2d39274 100644 --- a/lib/c-ares-1.32.3/Makefile.msvc +++ b/lib/c-ares-1.33.1/Makefile.msvc @@ -75,11 +75,6 @@ RTLIBD = /MTd USE_WATT32 = 0 !ENDIF -# -------------------------------------------------------- -# Detect compiler version. -# -------------------------------------------------------- -!INCLUDE .\msvc_ver.inc - # ---------------------------------------------------- # Verify that current subdir is the c-ares source one # ---------------------------------------------------- @@ -190,30 +185,13 @@ EX_LIBS_REL = ws2_32.lib advapi32.lib kernel32.lib iphlpapi.lib EX_LIBS_DBG = ws2_32.lib advapi32.lib kernel32.lib iphlpapi.lib !ENDIF -# ------------------------------------------------- -# Switches that depend on ancient compiler versions -# ------------------------------------------------- - -!IF $(CC_VERS_NUM) == 60 -PDB_NONE = /pdb:none -PDBTYPE_CONSOLIDATE = /pdbtype:consolidate -!ELSE -!UNDEF PDB_NONE -!UNDEF PDBTYPE_CONSOLIDATE -!ENDIF - -!IF $(CC_VERS_NUM) <= 70 -RT_ERROR_CHECKING = /GZ -!ELSE -RT_ERROR_CHECKING = /RTCsu -!ENDIF # ---------------------------- # Assorted commands and flags # ---------------------------- CC_CMD_REL = cl.exe /nologo $(RTLIB) /DNDEBUG /O2 -CC_CMD_DBG = cl.exe /nologo $(RTLIBD) /D_DEBUG /Od /Zi $(RT_ERROR_CHECKING) +CC_CMD_DBG = cl.exe /nologo $(RTLIBD) /D_DEBUG /Od /Zi /RTCsu CC_CFLAGS = $(CFLAGS) /D_REENTRANT /I.\src\lib /I.\include /W3 /EHsc /FD RC_CMD_REL = rc.exe /l 0x409 /d "NDEBUG" @@ -223,8 +201,8 @@ LINK_CMD_LIB = link.exe /lib /nologo LINK_CMD_DLL = link.exe /dll /nologo /incremental:no /fixed:no LINK_CMD_EXE = link.exe /nologo /incremental:no /fixed:no /subsystem:console -LINK_CMD_EXE_REL = $(LINK_CMD_EXE) /release $(PDB_NONE) -LINK_CMD_EXE_DBG = $(LINK_CMD_EXE) /debug $(PDBTYPE_CONSOLIDATE) +LINK_CMD_EXE_REL = $(LINK_CMD_EXE) /release +LINK_CMD_EXE_DBG = $(LINK_CMD_EXE) /debug # --------------------------------- # Configuration dependent settings @@ -255,7 +233,7 @@ CC_CMD = $(CC_CMD_DBG) !IF "$(CFG)" == "dll-release" CARES_TARGET = $(DYN_LIB_REL).dll CARES_CFLAGS = /DCARES_BUILDING_LIBRARY -CARES_LFLAGS = /release $(EX_LIBS_REL) /implib:$(CARES_OUTDIR)\$(IMP_LIB_REL).lib $(PDB_NONE) +CARES_LFLAGS = /release $(EX_LIBS_REL) /implib:$(CARES_OUTDIR)\$(IMP_LIB_REL).lib SPROG_CFLAGS = /DCARES_NO_DEPRECATED SPROG_LFLAGS = /libpath:$(CARES_OUTDIR) $(EX_LIBS_REL) $(IMP_LIB_REL).lib CARES_LINK = $(LINK_CMD_DLL) @@ -268,7 +246,7 @@ RC_CMD = $(RC_CMD_REL) !IF "$(CFG)" == "dll-debug" CARES_TARGET = $(DYN_LIB_DBG).dll CARES_CFLAGS = /DCARES_BUILDING_LIBRARY /DDEBUGBUILD -CARES_LFLAGS = /debug $(EX_LIBS_DBG) /implib:$(CARES_OUTDIR)\$(IMP_LIB_DBG).lib /pdb:$(CARES_OUTDIR)\$(DYN_LIB_DBG).pdb $(PDBTYPE_CONSOLIDATE) +CARES_LFLAGS = /debug $(EX_LIBS_DBG) /implib:$(CARES_OUTDIR)\$(IMP_LIB_DBG).lib /pdb:$(CARES_OUTDIR)\$(DYN_LIB_DBG).pdb SPROG_CFLAGS = /DCARES_NO_DEPRECATED SPROG_LFLAGS = /libpath:$(CARES_OUTDIR) $(EX_LIBS_DBG) $(IMP_LIB_DBG).lib CARES_LINK = $(LINK_CMD_DLL) @@ -299,6 +277,7 @@ RC_CMD = $(RC_CMD_DBG) !ERROR Problem generating CARES_OBJS list. !ENDIF CARES_OBJS = $(CARES_OBJS:.c=.obj) +CARES_OBJS = $(CARES_OBJS:/=\) !IF "$(USE_RES_FILE)" == "TRUE" CARES_OBJS = $(CARES_OBJS) $(CARES_OBJDIR)\cares.res !ENDIF @@ -341,20 +320,38 @@ PROG3_OBJS = $(PROG3_OBJS) $(PROG3_OBJDIR)\ahost.obj {$(SRCDIR)\src\lib}.c{$(CARES_OBJDIR)}.obj: $(CC_CMD) $(CC_CFLAGS) $(CARES_CFLAGS) /Fo$@ /Fd$(@D)\ /c $< +{$(SRCDIR)\src\lib\dsa}.c{$(CARES_OBJDIR)\dsa}.obj: + $(CC_CMD) $(CC_CFLAGS) $(CARES_CFLAGS) /Fo$@ /Fd$(@D)\ /c $< + +{$(SRCDIR)\src\lib\event}.c{$(CARES_OBJDIR)\event}.obj: + $(CC_CMD) $(CC_CFLAGS) $(CARES_CFLAGS) /Fo$@ /Fd$(@D)\ /c $< + +{$(SRCDIR)\src\lib\legacy}.c{$(CARES_OBJDIR)\legacy}.obj: + $(CC_CMD) $(CC_CFLAGS) $(CARES_CFLAGS) /Fo$@ /Fd$(@D)\ /c $< + +{$(SRCDIR)\src\lib\record}.c{$(CARES_OBJDIR)\record}.obj: + $(CC_CMD) $(CC_CFLAGS) $(CARES_CFLAGS) /Fo$@ /Fd$(@D)\ /c $< + +{$(SRCDIR)\src\lib\str}.c{$(CARES_OBJDIR)\str}.obj: + $(CC_CMD) $(CC_CFLAGS) $(CARES_CFLAGS) /Fo$@ /Fd$(@D)\ /c $< + +{$(SRCDIR)\src\lib\util}.c{$(CARES_OBJDIR)\util}.obj: + $(CC_CMD) $(CC_CFLAGS) $(CARES_CFLAGS) /Fo$@ /Fd$(@D)\ /c $< + {$(SRCDIR)\src\tools}.c{$(PROG2_OBJDIR)}.obj: - $(CC_CMD) $(CC_CFLAGS) $(SPROG_CFLAGS) /Fo$@ /Fd$(@D)\ /c $< + $(CC_CMD) $(CC_CFLAGS) $(SPROG_CFLAGS) /Fo$@ /Fd$(PROG2_OBJDIR)\ /c $< {$(SRCDIR)\src\tools}.c{$(PROG3_OBJDIR)}.obj: - $(CC_CMD) $(CC_CFLAGS) $(SPROG_CFLAGS) /Fo$@ /Fd$(@D)\ /c $< + $(CC_CMD) $(CC_CFLAGS) $(SPROG_CFLAGS) /Fo$@ /Fd$(PROG3_OBJDIR)\ /c $< -# Hack Alert! we reference ../lib/ files in the Makefile.inc for tools as they +# Hack Alert! we reference ../lib/str files in the Makefile.inc for tools as they # share some files with the library itself. We need to hack around that here. -{$(SRCDIR)\src\lib}.c{$(PROG2_OBJDIR)\..\lib}.obj: - $(CC_CMD) $(CC_CFLAGS) $(SPROG_CFLAGS) /Fo$(PROG2_OBJDIR)\$(@F) /Fd$(PROG2_OBJDIR)\ /c $< +{$(SRCDIR)\src\lib\str}.c{$(PROG2_OBJDIR)\..\lib\str}.obj: + $(CC_CMD) $(CC_CFLAGS) $(SPROG_CFLAGS) /Fo$(PROG2_OBJDIR)\str\$(@F) /Fd$(PROG2_OBJDIR)\str\ /c $< -{$(SRCDIR)\src\lib}.c{$(PROG3_OBJDIR)\..\lib}.obj: - $(CC_CMD) $(CC_CFLAGS) $(SPROG_CFLAGS) /Fo$(PROG3_OBJDIR)\$(@F) /Fd$(PROG3_OBJDIR)\ /c $< +{$(SRCDIR)\src\lib\str}.c{$(PROG3_OBJDIR)\..\lib\str}.obj: + $(CC_CMD) $(CC_CFLAGS) $(SPROG_CFLAGS) /Fo$(PROG3_OBJDIR)\str\$(@F) /Fd$(PROG3_OBJDIR)\str\ /c $< # ------------------------------------------------------------- # # ------------------------------------------------------------- # @@ -419,16 +416,32 @@ $(PROG3_OUTDIR): $(PROG3_DIR) $(CARES_OBJDIR): $(CARES_OUTDIR) @if not exist $(CARES_OBJDIR) mkdir $(CARES_OBJDIR) + @if not exist $(CARES_OBJDIR)\dsa mkdir $(CARES_OBJDIR)\dsa + @if not exist $(CARES_OBJDIR)\event mkdir $(CARES_OBJDIR)\event + @if not exist $(CARES_OBJDIR)\legacy mkdir $(CARES_OBJDIR)\legacy + @if not exist $(CARES_OBJDIR)\record mkdir $(CARES_OBJDIR)\record + @if not exist $(CARES_OBJDIR)\str mkdir $(CARES_OBJDIR)\str + @if not exist $(CARES_OBJDIR)\util mkdir $(CARES_OBJDIR)\util $(PROG2_OBJDIR): $(PROG2_OUTDIR) @if not exist $(PROG2_OBJDIR) mkdir $(PROG2_OBJDIR) + @if not exist $(PROG2_OBJDIR)\str mkdir $(PROG2_OBJDIR)\str $(PROG3_OBJDIR): $(PROG3_OUTDIR) @if not exist $(PROG3_OBJDIR) mkdir $(PROG3_OBJDIR) + @if not exist $(PROG3_OBJDIR)\str mkdir $(PROG3_OBJDIR)\str clean: + @-RMDIR /S /Q $(CARES_OBJDIR)\dsa >NUL 2>&1 + @-RMDIR /S /Q $(CARES_OBJDIR)\event >NUL 2>&1 + @-RMDIR /S /Q $(CARES_OBJDIR)\legacy >NUL 2>&1 + @-RMDIR /S /Q $(CARES_OBJDIR)\record >NUL 2>&1 + @-RMDIR /S /Q $(CARES_OBJDIR)\str >NUL 2>&1 + @-RMDIR /S /Q $(CARES_OBJDIR)\util >NUL 2>&1 @-RMDIR /S /Q $(CARES_OUTDIR) >NUL 2>&1 + @-RMDIR /S /Q $(PROG2_OBJDIR)\str >NUL 2>&1 @-RMDIR /S /Q $(PROG2_OUTDIR) >NUL 2>&1 + @-RMDIR /S /Q $(PROG3_OBJDIR)\str >NUL 2>&1 @-RMDIR /S /Q $(PROG3_OUTDIR) >NUL 2>&1 install: diff --git a/lib/c-ares-1.32.3/Makefile.netware b/lib/c-ares-1.33.1/Makefile.netware similarity index 100% rename from lib/c-ares-1.32.3/Makefile.netware rename to lib/c-ares-1.33.1/Makefile.netware diff --git a/lib/c-ares-1.32.3/README.md b/lib/c-ares-1.33.1/README.md similarity index 66% rename from lib/c-ares-1.32.3/README.md rename to lib/c-ares-1.33.1/README.md index 86b25bc3159..c32d0677c83 100644 --- a/lib/c-ares-1.32.3/README.md +++ b/lib/c-ares-1.33.1/README.md @@ -8,6 +8,14 @@ [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=c-ares_c-ares&metric=bugs)](https://sonarcloud.io/summary/new_code?id=c-ares_c-ares) [![Coverity Scan Status](https://scan.coverity.com/projects/c-ares/badge.svg)](https://scan.coverity.com/projects/c-ares) +- [Overview](#overview) +- [Code](#code) +- [Communication](#communication) +- [Release Keys](#release-keys) + - [Verifying signatures](#verifying-signatures) +- [Features](#features) + - [RFCs and Proposals](#supported-rfcs-and-proposals) + ## Overview [c-ares](https://c-ares.org) is a modern DNS (stub) resolver library, written in C. It provides interfaces for asynchronous queries while trying to abstract the @@ -99,3 +107,47 @@ gpg: There is no indication that the signature belongs to the owner. Primary key fingerprint: 27ED EAF2 2F3A BCEB 50DB 9A12 5CC9 08FD B71E 12C2 gpg: binary signature, digest algorithm SHA512, key algorithm rsa2048 ``` + +## Features +### Supported RFCs and Proposals +- [RFC1035](https://datatracker.ietf.org/doc/html/rfc7873). + Initial/Base DNS RFC +- [RFC2671](https://datatracker.ietf.org/doc/html/rfc2671), + [RFC6891](https://datatracker.ietf.org/doc/html/rfc6891). + EDNS0 option (meta-RR) +- [RFC3596](https://datatracker.ietf.org/doc/html/rfc3596). + IPv6 Address. `AAAA` Record. +- [RFC2782](https://datatracker.ietf.org/doc/html/rfc2782). + Server Selection. `SRV` Record. +- [RFC3403](https://datatracker.ietf.org/doc/html/rfc3403). + Naming Authority Pointer. `NAPTR` Record. +- [RFC6698](https://datatracker.ietf.org/doc/html/rfc6698). + DNS-Based Authentication of Named Entities (DANE) Transport Layer Security (TLS) Protocol. + `TLSA` Record. +- [RFC9460](https://datatracker.ietf.org/doc/html/rfc9460). + General Purpose Service Binding, Service Binding type for use with HTTPS. + `SVCB` and `HTTPS` Records. +- [RFC7553](https://datatracker.ietf.org/doc/html/rfc7553). + Uniform Resource Identifier. `URI` Record. +- [RFC6844](https://datatracker.ietf.org/doc/html/rfc6844). + Certification Authority Authorization. `CAA` Record. +- [RFC2535](https://datatracker.ietf.org/doc/html/rfc2535), + [RFC2931](https://datatracker.ietf.org/doc/html/rfc2931). + `SIG0` Record. Only basic parser, not full implementation. +- [RFC7873](https://datatracker.ietf.org/doc/html/rfc7873), + [RFC9018](https://datatracker.ietf.org/doc/html/rfc9018). + DNS Cookie off-path dns poisoning and amplification mitigation. +- [draft-vixie-dnsext-dns0x20-00](https://datatracker.ietf.org/doc/html/draft-vixie-dnsext-dns0x20-00). + DNS 0x20 query name case randomization to prevent cache poisioning attacks. +- [RFC7686](https://datatracker.ietf.org/doc/html/rfc7686). + Reject queries for `.onion` domain names with `NXDOMAIN`. +- [RFC2606](https://datatracker.ietf.org/doc/html/rfc2606), + [RFC6761](https://datatracker.ietf.org/doc/html/rfc6761). + Special case treatment for `localhost`/`.localhost`. +- [RFC2308](https://datatracker.ietf.org/doc/html/rfc2308), + [RFC9520](https://datatracker.ietf.org/doc/html/rfc9520). + Negative Caching of DNS Resolution Failures. +- [RFC6724](https://datatracker.ietf.org/doc/html/rfc6724). + IPv6 address sorting as used by `ares_getaddrinfo()`. +- [RFC7413](https://datatracker.ietf.org/doc/html/rfc7413). + TCP FastOpen (TFO) for 0-RTT TCP Connection Resumption. diff --git a/lib/c-ares-1.32.3/README.msvc b/lib/c-ares-1.33.1/README.msvc similarity index 100% rename from lib/c-ares-1.32.3/README.msvc rename to lib/c-ares-1.33.1/README.msvc diff --git a/lib/c-ares-1.33.1/RELEASE-NOTES.md b/lib/c-ares-1.33.1/RELEASE-NOTES.md new file mode 100644 index 00000000000..e9c04953dc6 --- /dev/null +++ b/lib/c-ares-1.33.1/RELEASE-NOTES.md @@ -0,0 +1,65 @@ +## c-ares version 1.33.1 - August 23 2024 + +This is a bugfix release. + +Bugfixes: +* Work around systemd-resolved quirk that returns unexpected codes for single + label names. Also adds test cases to validate the work around works and + will continue to work in future releases. + [PR #863](https://github.com/c-ares/c-ares/pull/863), + See Also https://github.com/systemd/systemd/issues/34101 +* Fix sysconfig ndots default value, also adds containerized test case to + prevent future regressions. + [PR #862](https://github.com/c-ares/c-ares/pull/862) +* Fix blank DNS name returning error code rather than valid record for + commands like: `adig -t SOA .`. Also adds test case to prevent future + regressions. + [9e574af](https://github.com/c-ares/c-ares/commit/9e574af) +* Fix calculation of query times > 1s. + [2b2eae7](https://github.com/c-ares/c-ares/commit/2b2eae7) +* Fix building on old Linux releases that don't have `TCP_FASTOPEN_CONNECT`. + [b7a89b9](https://github.com/c-ares/c-ares/commit/b7a89b9) +* Fix minor Android build warnings. + [PR #848](https://github.com/c-ares/c-ares/pull/848) + +Thanks go to these friendly people for their efforts and contributions for this +release: +* Brad House (@bradh352) +* Erik Lax (@eriklax) +* Hans-Christian Egtvedt (@egtvedt) +* Mikael Lindemann (@mikaellindemann) +* Nodar Chkuaselidze (@nodech) + +## c-ares version 1.33.0 - August 2 2024 + +This is a feature and bugfix release. + +Features: +* Add DNS cookie support (RFC7873 + RFC9018) to help prevent off-path cache + poisoning attacks. [PR #833](https://github.com/c-ares/c-ares/pull/833) +* Implement TCP FastOpen (TFO) RFC7413, which will make TCP reconnects 0-RTT + on supported systems. [PR #840](https://github.com/c-ares/c-ares/pull/840) + +Changes: +* Reorganize source tree. [PR #822](https://github.com/c-ares/c-ares/pull/822) +* Refactoring of connection handling to prevent code duplication. + [PR #839](https://github.com/c-ares/c-ares/pull/839) +* New dynamic array data structure to prevent simple logic flaws in array + handling in various code paths. + [PR #841](https://github.com/c-ares/c-ares/pull/841) + +Bugfixes: +* `ares_destroy()` race condition during shutdown due to missing lock. + [PR #831](https://github.com/c-ares/c-ares/pull/831) +* Android: Preserve thread name after attaching it to JVM. + [PR #838](https://github.com/c-ares/c-ares/pull/838) +* Windows UWP (Store) support fix. + [PR #845](https://github.com/c-ares/c-ares/pull/845) + + +Thanks go to these friendly people for their efforts and contributions for this +release: + +* Brad House (@bradh352) +* Yauheni Khnykin (@Hsilgos) + diff --git a/lib/c-ares-1.32.3/SECURITY.md b/lib/c-ares-1.33.1/SECURITY.md similarity index 100% rename from lib/c-ares-1.32.3/SECURITY.md rename to lib/c-ares-1.33.1/SECURITY.md diff --git a/lib/c-ares-1.32.3/aclocal.m4 b/lib/c-ares-1.33.1/aclocal.m4 similarity index 78% rename from lib/c-ares-1.32.3/aclocal.m4 rename to lib/c-ares-1.33.1/aclocal.m4 index dc4eb963d54..68e283c8e59 100644 --- a/lib/c-ares-1.32.3/aclocal.m4 +++ b/lib/c-ares-1.33.1/aclocal.m4 @@ -1,6 +1,6 @@ -# generated automatically by aclocal 1.16.5 -*- Autoconf -*- +# generated automatically by aclocal 1.17 -*- Autoconf -*- -# Copyright (C) 1996-2021 Free Software Foundation, Inc. +# Copyright (C) 1996-2024 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -20,7 +20,7 @@ You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) -# Copyright (C) 2002-2021 Free Software Foundation, Inc. +# Copyright (C) 2002-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -32,10 +32,10 @@ To do so, use the procedure documented by the package, typically 'autoreconf'.]) # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], -[am__api_version='1.16' +[am__api_version='1.17' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.16.5], [], +m4_if([$1], [1.17], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -51,14 +51,14 @@ m4_define([_AM_AUTOCONF_VERSION], []) # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.16.5])dnl +[AM_AUTOMAKE_VERSION([1.17])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- -# Copyright (C) 2001-2021 Free Software Foundation, Inc. +# Copyright (C) 2001-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -110,7 +110,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd` # AM_COND_IF -*- Autoconf -*- -# Copyright (C) 2008-2021 Free Software Foundation, Inc. +# Copyright (C) 2008-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -147,7 +147,7 @@ fi[]dnl # AM_CONDITIONAL -*- Autoconf -*- -# Copyright (C) 1997-2021 Free Software Foundation, Inc. +# Copyright (C) 1997-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -178,7 +178,7 @@ AC_CONFIG_COMMANDS_PRE( Usually this means the macro was only invoked conditionally.]]) fi])]) -# Copyright (C) 1999-2021 Free Software Foundation, Inc. +# Copyright (C) 1999-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -310,7 +310,7 @@ AC_CACHE_CHECK([dependency style of $depcc], # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: + # When given -MP, icc 7.0 and 7.1 complain thus: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported @@ -369,7 +369,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl # Generate code to set up dependency tracking. -*- Autoconf -*- -# Copyright (C) 1999-2021 Free Software Foundation, Inc. +# Copyright (C) 1999-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -437,7 +437,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], # Do all the work for Automake. -*- Autoconf -*- -# Copyright (C) 1996-2021 Free Software Foundation, Inc. +# Copyright (C) 1996-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -571,7 +571,7 @@ if test -z "$CSCOPE"; then fi AC_SUBST([CSCOPE]) -AC_REQUIRE([AM_SILENT_RULES])dnl +AC_REQUIRE([_AM_SILENT_RULES])dnl dnl The testsuite driver may need to know about EXEEXT, so add the dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. @@ -579,47 +579,9 @@ AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl -# POSIX will say in a future version that running "rm -f" with no argument -# is OK; and we want to be able to make that assumption in our Makefile -# recipes. So use an aggressive probe to check that the usage we want is -# actually supported "in the wild" to an acceptable degree. -# See automake bug#10828. -# To make any issue more visible, cause the running configure to be aborted -# by default if the 'rm' program in use doesn't match our expectations; the -# user can still override this though. -if rm -f && rm -fr && rm -rf; then : OK; else - cat >&2 <<'END' -Oops! - -Your 'rm' program seems unable to run without file operands specified -on the command line, even when the '-f' option is present. This is contrary -to the behaviour of most rm programs out there, and not conforming with -the upcoming POSIX standard: - -Please tell bug-automake@gnu.org about your system, including the value -of your $PATH and any error possibly output before this message. This -can help us improve future automake versions. +AC_REQUIRE([_AM_PROG_RM_F]) +AC_REQUIRE([_AM_PROG_XARGS_N]) -END - if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then - echo 'Configuration will proceed anyway, since you have set the' >&2 - echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 - echo >&2 - else - cat >&2 <<'END' -Aborting the configuration process, to ensure you take notice of the issue. - -You can download and install GNU coreutils to get an 'rm' implementation -that behaves properly: . - -If you want to complete the configuration process using your problematic -'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM -to "yes", and re-run configure. - -END - AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) - fi -fi dnl The trailing newline in this macro's definition is deliberate, for dnl backward compatibility and to allow trailing 'dnl'-style comments dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841. @@ -652,7 +614,7 @@ for _am_header in $config_headers :; do done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) -# Copyright (C) 2001-2021 Free Software Foundation, Inc. +# Copyright (C) 2001-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -673,7 +635,7 @@ if test x"${install_sh+set}" != xset; then fi AC_SUBST([install_sh])]) -# Copyright (C) 2003-2021 Free Software Foundation, Inc. +# Copyright (C) 2003-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -695,7 +657,7 @@ AC_SUBST([am__leading_dot])]) # Add --enable-maintainer-mode option to configure. -*- Autoconf -*- # From Jim Meyering -# Copyright (C) 1996-2021 Free Software Foundation, Inc. +# Copyright (C) 1996-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -730,7 +692,7 @@ AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) # Check to see how 'make' treats includes. -*- Autoconf -*- -# Copyright (C) 2001-2021 Free Software Foundation, Inc. +# Copyright (C) 2001-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -773,7 +735,7 @@ AC_SUBST([am__quote])]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- -# Copyright (C) 1997-2021 Free Software Foundation, Inc. +# Copyright (C) 1997-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -807,7 +769,7 @@ fi # Helper functions for option handling. -*- Autoconf -*- -# Copyright (C) 2001-2021 Free Software Foundation, Inc. +# Copyright (C) 2001-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -836,7 +798,7 @@ AC_DEFUN([_AM_SET_OPTIONS], AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) -# Copyright (C) 1999-2021 Free Software Foundation, Inc. +# Copyright (C) 1999-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -883,7 +845,23 @@ AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) -# Copyright (C) 2001-2021 Free Software Foundation, Inc. +# Copyright (C) 2022-2024 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# _AM_PROG_RM_F +# --------------- +# Check whether 'rm -f' without any arguments works. +# https://bugs.gnu.org/10828 +AC_DEFUN([_AM_PROG_RM_F], +[am__rm_f_notfound= +AS_IF([(rm -f && rm -fr && rm -rf) 2>/dev/null], [], [am__rm_f_notfound='""']) +AC_SUBST(am__rm_f_notfound) +]) + +# Copyright (C) 2001-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -902,16 +880,169 @@ AC_DEFUN([AM_RUN_LOG], # Check to make sure that the build environment is sane. -*- Autoconf -*- -# Copyright (C) 1996-2021 Free Software Foundation, Inc. +# Copyright (C) 1996-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# _AM_SLEEP_FRACTIONAL_SECONDS +# ---------------------------- +AC_DEFUN([_AM_SLEEP_FRACTIONAL_SECONDS], [dnl +AC_CACHE_CHECK([whether sleep supports fractional seconds], + am_cv_sleep_fractional_seconds, [dnl +AS_IF([sleep 0.001 2>/dev/null], [am_cv_sleep_fractional_seconds=yes], + [am_cv_sleep_fractional_seconds=no]) +])]) + +# _AM_FILESYSTEM_TIMESTAMP_RESOLUTION +# ----------------------------------- +# Determine the filesystem's resolution for file modification +# timestamps. The coarsest we know of is FAT, with a resolution +# of only two seconds, even with the most recent "exFAT" extensions. +# The finest (e.g. ext4 with large inodes, XFS, ZFS) is one +# nanosecond, matching clock_gettime. However, it is probably not +# possible to delay execution of a shell script for less than one +# millisecond, due to process creation overhead and scheduling +# granularity, so we don't check for anything finer than that. (See below.) +AC_DEFUN([_AM_FILESYSTEM_TIMESTAMP_RESOLUTION], [dnl +AC_REQUIRE([_AM_SLEEP_FRACTIONAL_SECONDS]) +AC_CACHE_CHECK([filesystem timestamp resolution], + am_cv_filesystem_timestamp_resolution, [dnl +# Default to the worst case. +am_cv_filesystem_timestamp_resolution=2 + +# Only try to go finer than 1 sec if sleep can do it. +# Don't try 1 sec, because if 0.01 sec and 0.1 sec don't work, +# - 1 sec is not much of a win compared to 2 sec, and +# - it takes 2 seconds to perform the test whether 1 sec works. +# +# Instead, just use the default 2s on platforms that have 1s resolution, +# accept the extra 1s delay when using $sleep in the Automake tests, in +# exchange for not incurring the 2s delay for running the test for all +# packages. +# +am_try_resolutions= +if test "$am_cv_sleep_fractional_seconds" = yes; then + # Even a millisecond often causes a bunch of false positives, + # so just try a hundredth of a second. The time saved between .001 and + # .01 is not terribly consequential. + am_try_resolutions="0.01 0.1 $am_try_resolutions" +fi + +# In order to catch current-generation FAT out, we must *modify* files +# that already exist; the *creation* timestamp is finer. Use names +# that make ls -t sort them differently when they have equal +# timestamps than when they have distinct timestamps, keeping +# in mind that ls -t prints the *newest* file first. +rm -f conftest.ts? +: > conftest.ts1 +: > conftest.ts2 +: > conftest.ts3 + +# Make sure ls -t actually works. Do 'set' in a subshell so we don't +# clobber the current shell's arguments. (Outer-level square brackets +# are removed by m4; they're present so that m4 does not expand +# ; be careful, easy to get confused.) +if ( + set X `[ls -t conftest.ts[12]]` && + { + test "$[]*" != "X conftest.ts1 conftest.ts2" || + test "$[]*" != "X conftest.ts2 conftest.ts1"; + } +); then :; else + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + _AS_ECHO_UNQUOTED( + ["Bad output from ls -t: \"`[ls -t conftest.ts[12]]`\""], + [AS_MESSAGE_LOG_FD]) + AC_MSG_FAILURE([ls -t produces unexpected output. +Make sure there is not a broken ls alias in your environment.]) +fi + +for am_try_res in $am_try_resolutions; do + # Any one fine-grained sleep might happen to cross the boundary + # between two values of a coarser actual resolution, but if we do + # two fine-grained sleeps in a row, at least one of them will fall + # entirely within a coarse interval. + echo alpha > conftest.ts1 + sleep $am_try_res + echo beta > conftest.ts2 + sleep $am_try_res + echo gamma > conftest.ts3 + + # We assume that 'ls -t' will make use of high-resolution + # timestamps if the operating system supports them at all. + if (set X `ls -t conftest.ts?` && + test "$[]2" = conftest.ts3 && + test "$[]3" = conftest.ts2 && + test "$[]4" = conftest.ts1); then + # + # Ok, ls -t worked. If we're at a resolution of 1 second, we're done, + # because we don't need to test make. + make_ok=true + if test $am_try_res != 1; then + # But if we've succeeded so far with a subsecond resolution, we + # have one more thing to check: make. It can happen that + # everything else supports the subsecond mtimes, but make doesn't; + # notably on macOS, which ships make 3.81 from 2006 (the last one + # released under GPLv2). https://bugs.gnu.org/68808 + # + # We test $MAKE if it is defined in the environment, else "make". + # It might get overridden later, but our hope is that in practice + # it does not matter: it is the system "make" which is (by far) + # the most likely to be broken, whereas if the user overrides it, + # probably they did so with a better, or at least not worse, make. + # https://lists.gnu.org/archive/html/automake/2024-06/msg00051.html + # + # Create a Makefile (real tab character here): + rm -f conftest.mk + echo 'conftest.ts1: conftest.ts2' >conftest.mk + echo ' touch conftest.ts2' >>conftest.mk + # + # Now, running + # touch conftest.ts1; touch conftest.ts2; make + # should touch ts1 because ts2 is newer. This could happen by luck, + # but most often, it will fail if make's support is insufficient. So + # test for several consecutive successes. + # + # (We reuse conftest.ts[12] because we still want to modify existing + # files, not create new ones, per above.) + n=0 + make=${MAKE-make} + until test $n -eq 3; do + echo one > conftest.ts1 + sleep $am_try_res + echo two > conftest.ts2 # ts2 should now be newer than ts1 + if $make -f conftest.mk | grep 'up to date' >/dev/null; then + make_ok=false + break # out of $n loop + fi + n=`expr $n + 1` + done + fi + # + if $make_ok; then + # Everything we know to check worked out, so call this resolution good. + am_cv_filesystem_timestamp_resolution=$am_try_res + break # out of $am_try_res loop + fi + # Otherwise, we'll go on to check the next resolution. + fi +done +rm -f conftest.ts? +# (end _am_filesystem_timestamp_resolution) +])]) + # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], -[AC_MSG_CHECKING([whether build environment is sane]) +[AC_REQUIRE([_AM_FILESYSTEM_TIMESTAMP_RESOLUTION]) +# This check should not be cached, as it may vary across builds of +# different projects. +AC_MSG_CHECKING([whether build environment is sane]) # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' @@ -930,49 +1061,40 @@ esac # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). -if ( - am_has_slept=no - for am_try in 1 2; do - echo "timestamp, slept: $am_has_slept" > conftest.file - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$[*]" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - if test "$[*]" != "X $srcdir/configure conftest.file" \ - && test "$[*]" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken - alias in your environment]) - fi - if test "$[2]" = conftest.file || test $am_try -eq 2; then - break - fi - # Just in case. - sleep 1 - am_has_slept=yes - done - test "$[2]" = conftest.file - ) -then - # Ok. - : -else - AC_MSG_ERROR([newly created file is older than distributed files! +am_build_env_is_sane=no +am_has_slept=no +rm -f conftest.file +for am_try in 1 2; do + echo "timestamp, slept: $am_has_slept" > conftest.file + if ( + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$[]*" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + test "$[]2" = conftest.file + ); then + am_build_env_is_sane=yes + break + fi + # Just in case. + sleep "$am_cv_filesystem_timestamp_resolution" + am_has_slept=yes +done + +AC_MSG_RESULT([$am_build_env_is_sane]) +if test "$am_build_env_is_sane" = no; then + AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi -AC_MSG_RESULT([yes]) + # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= -if grep 'slept: no' conftest.file >/dev/null 2>&1; then - ( sleep 1 ) & +AS_IF([test -e conftest.file || grep 'slept: no' conftest.file >/dev/null 2>&1],, [dnl + ( sleep "$am_cv_filesystem_timestamp_resolution" ) & am_sleep_pid=$! -fi +]) AC_CONFIG_COMMANDS_PRE( [AC_MSG_CHECKING([that generated files are newer than configure]) if test -n "$am_sleep_pid"; then @@ -983,18 +1105,18 @@ AC_CONFIG_COMMANDS_PRE( rm -f conftest.file ]) -# Copyright (C) 2009-2021 Free Software Foundation, Inc. +# Copyright (C) 2009-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# AM_SILENT_RULES([DEFAULT]) -# -------------------------- -# Enable less verbose build rules; with the default set to DEFAULT -# ("yes" being less verbose, "no" or empty being verbose). -AC_DEFUN([AM_SILENT_RULES], -[AC_ARG_ENABLE([silent-rules], [dnl +# _AM_SILENT_RULES +# ---------------- +# Enable less verbose build rules support. +AC_DEFUN([_AM_SILENT_RULES], +[AM_DEFAULT_VERBOSITY=1 +AC_ARG_ENABLE([silent-rules], [dnl AS_HELP_STRING( [--enable-silent-rules], [less verbose build output (undo: "make V=1")]) @@ -1002,11 +1124,6 @@ AS_HELP_STRING( [--disable-silent-rules], [verbose build output (undo: "make V=0")])dnl ]) -case $enable_silent_rules in @%:@ ((( - yes) AM_DEFAULT_VERBOSITY=0;; - no) AM_DEFAULT_VERBOSITY=1;; - *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; -esac dnl dnl A few 'make' implementations (e.g., NonStop OS and NextStep) dnl do not support nested variable expansions. @@ -1025,14 +1142,6 @@ am__doit: else am_cv_make_support_nested_variables=no fi]) -if test $am_cv_make_support_nested_variables = yes; then - dnl Using '$V' instead of '$(V)' breaks IRIX make. - AM_V='$(V)' - AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' -else - AM_V=$AM_DEFAULT_VERBOSITY - AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY -fi AC_SUBST([AM_V])dnl AM_SUBST_NOTMAKE([AM_V])dnl AC_SUBST([AM_DEFAULT_V])dnl @@ -1041,9 +1150,33 @@ AC_SUBST([AM_DEFAULT_VERBOSITY])dnl AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl +dnl Delay evaluation of AM_DEFAULT_VERBOSITY to the end to allow multiple calls +dnl to AM_SILENT_RULES to change the default value. +AC_CONFIG_COMMANDS_PRE([dnl +case $enable_silent_rules in @%:@ ((( + yes) AM_DEFAULT_VERBOSITY=0;; + no) AM_DEFAULT_VERBOSITY=1;; +esac +if test $am_cv_make_support_nested_variables = yes; then + dnl Using '$V' instead of '$(V)' breaks IRIX make. + AM_V='$(V)' + AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' +else + AM_V=$AM_DEFAULT_VERBOSITY + AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY +fi +])dnl ]) -# Copyright (C) 2001-2021 Free Software Foundation, Inc. +# AM_SILENT_RULES([DEFAULT]) +# -------------------------- +# Set the default verbosity level to DEFAULT ("yes" being less verbose, "no" or +# empty being verbose). +AC_DEFUN([AM_SILENT_RULES], +[AC_REQUIRE([_AM_SILENT_RULES]) +AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1])]) + +# Copyright (C) 2001-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1071,7 +1204,7 @@ fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) -# Copyright (C) 2006-2021 Free Software Foundation, Inc. +# Copyright (C) 2006-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1090,7 +1223,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- -# Copyright (C) 2004-2021 Free Software Foundation, Inc. +# Copyright (C) 2004-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1136,15 +1269,19 @@ m4_if([$1], [v7], am_uid=`id -u || echo unknown` am_gid=`id -g || echo unknown` AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) - if test $am_uid -le $am_max_uid; then - AC_MSG_RESULT([yes]) + if test x$am_uid = xunknown; then + AC_MSG_WARN([ancient id detected; assuming current UID is ok, but dist-ustar might not work]) + elif test $am_uid -le $am_max_uid; then + AC_MSG_RESULT([yes]) else - AC_MSG_RESULT([no]) - _am_tools=none + AC_MSG_RESULT([no]) + _am_tools=none fi AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) - if test $am_gid -le $am_max_gid; then - AC_MSG_RESULT([yes]) + if test x$gm_gid = xunknown; then + AC_MSG_WARN([ancient id detected; assuming current GID is ok, but dist-ustar might not work]) + elif test $am_gid -le $am_max_gid; then + AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none @@ -1221,6 +1358,26 @@ AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR +# Copyright (C) 2022-2024 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# _AM_PROG_XARGS_N +# ---------------- +# Check whether 'xargs -n' works. It should work everywhere, so the fallback +# is not optimized at all as we never expect to use it. +AC_DEFUN([_AM_PROG_XARGS_N], +[AC_CACHE_CHECK([xargs -n works], am_cv_xargs_n_works, [dnl +AS_IF([test "`echo 1 2 3 | xargs -n2 echo`" = "1 2 +3"], [am_cv_xargs_n_works=yes], [am_cv_xargs_n_works=no])]) +AS_IF([test "$am_cv_xargs_n_works" = yes], [am__xargs_n='xargs -n'], [dnl + am__xargs_n='am__xargs_n () { shift; sed "s/ /\\n/g" | while read am__xargs_n_arg; do "$@" "$am__xargs_n_arg"; done; }' +])dnl +AC_SUBST(am__xargs_n) +]) + m4_include([m4/ax_ac_append_to_file.m4]) m4_include([m4/ax_ac_print_to_file.m4]) m4_include([m4/ax_add_am_macro_static.m4]) diff --git a/lib/c-ares-1.32.3/aminclude_static.am b/lib/c-ares-1.33.1/aminclude_static.am similarity index 99% rename from lib/c-ares-1.32.3/aminclude_static.am rename to lib/c-ares-1.33.1/aminclude_static.am index d542444c4e2..538a810c9eb 100644 --- a/lib/c-ares-1.32.3/aminclude_static.am +++ b/lib/c-ares-1.33.1/aminclude_static.am @@ -1,6 +1,6 @@ # aminclude_static.am generated automatically by Autoconf -# from AX_AM_MACROS_STATIC on Wed Jul 24 05:40:58 EDT 2024 +# from AX_AM_MACROS_STATIC on Fri Aug 23 09:37:25 EDT 2024 # Code coverage diff --git a/lib/c-ares-1.32.3/buildconf b/lib/c-ares-1.33.1/buildconf similarity index 100% rename from lib/c-ares-1.32.3/buildconf rename to lib/c-ares-1.33.1/buildconf diff --git a/lib/c-ares-1.32.3/buildconf.bat b/lib/c-ares-1.33.1/buildconf.bat similarity index 100% rename from lib/c-ares-1.32.3/buildconf.bat rename to lib/c-ares-1.33.1/buildconf.bat diff --git a/lib/c-ares-1.32.3/c-ares-config.cmake.in b/lib/c-ares-1.33.1/c-ares-config.cmake.in similarity index 100% rename from lib/c-ares-1.32.3/c-ares-config.cmake.in rename to lib/c-ares-1.33.1/c-ares-config.cmake.in diff --git a/lib/c-ares-1.32.3/cmake/EnableWarnings.cmake b/lib/c-ares-1.33.1/cmake/EnableWarnings.cmake similarity index 100% rename from lib/c-ares-1.32.3/cmake/EnableWarnings.cmake rename to lib/c-ares-1.33.1/cmake/EnableWarnings.cmake diff --git a/lib/c-ares-1.32.3/config/compile b/lib/c-ares-1.33.1/config/compile similarity index 95% rename from lib/c-ares-1.32.3/config/compile rename to lib/c-ares-1.33.1/config/compile index df363c8fbfb..49b3d05fde4 100755 --- a/lib/c-ares-1.32.3/config/compile +++ b/lib/c-ares-1.33.1/config/compile @@ -1,9 +1,9 @@ #! /bin/sh # Wrapper for compilers which do not understand '-c -o'. -scriptversion=2018-03-07.03; # UTC +scriptversion=2024-06-19.01; # UTC -# Copyright (C) 1999-2021 Free Software Foundation, Inc. +# Copyright (C) 1999-2024 Free Software Foundation, Inc. # Written by Tom Tromey . # # This program is free software; you can redistribute it and/or modify @@ -143,7 +143,7 @@ func_cl_wrapper () # configure might choose to run compile as 'compile cc -o foo foo.c'. eat=1 case $2 in - *.o | *.[oO][bB][jJ]) + *.o | *.lo | *.[oO][bB][jJ]) func_file_conv "$2" set x "$@" -Fo"$file" shift @@ -248,14 +248,17 @@ If you are trying to build a whole package this is not the right script to run: please start by reading the file 'INSTALL'. Report bugs to . +GNU Automake home page: . +General help using GNU software: . EOF exit $? ;; -v | --v*) - echo "compile $scriptversion" + echo "compile (GNU Automake) $scriptversion" exit $? ;; cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \ + clang-cl | *[/\\]clang-cl | clang-cl.exe | *[/\\]clang-cl.exe | \ icl | *[/\\]icl | icl.exe | *[/\\]icl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; diff --git a/lib/c-ares-1.32.3/config/config.guess b/lib/c-ares-1.33.1/config/config.guess similarity index 99% rename from lib/c-ares-1.32.3/config/config.guess rename to lib/c-ares-1.33.1/config/config.guess index cdfc4392047..f6d217a49f8 100755 --- a/lib/c-ares-1.32.3/config/config.guess +++ b/lib/c-ares-1.33.1/config/config.guess @@ -1,10 +1,10 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2023 Free Software Foundation, Inc. +# Copyright 1992-2024 Free Software Foundation, Inc. # shellcheck disable=SC2006,SC2268 # see below for rationale -timestamp='2023-08-22' +timestamp='2024-01-01' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -60,7 +60,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2023 Free Software Foundation, Inc. +Copyright 1992-2024 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -165,6 +165,8 @@ Linux|GNU|GNU/*) LIBC=dietlibc #elif defined(__GLIBC__) LIBC=gnu + #elif defined(__LLVM_LIBC__) + LIBC=llvm #else #include /* First heuristic to detect musl libc. */ @@ -1593,6 +1595,9 @@ EOF *:Unleashed:*:*) GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE ;; + *:Ironclad:*:*) + GUESS=$UNAME_MACHINE-unknown-ironclad + ;; esac # Do we have a guess based on uname results? diff --git a/lib/c-ares-1.32.3/config/config.sub b/lib/c-ares-1.33.1/config/config.sub similarity index 97% rename from lib/c-ares-1.32.3/config/config.sub rename to lib/c-ares-1.33.1/config/config.sub index defe52c0c87..2c6a07ab3c3 100755 --- a/lib/c-ares-1.32.3/config/config.sub +++ b/lib/c-ares-1.33.1/config/config.sub @@ -1,10 +1,10 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2023 Free Software Foundation, Inc. +# Copyright 1992-2024 Free Software Foundation, Inc. # shellcheck disable=SC2006,SC2268 # see below for rationale -timestamp='2023-09-19' +timestamp='2024-01-01' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -76,7 +76,7 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright 1992-2023 Free Software Foundation, Inc. +Copyright 1992-2024 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -1222,6 +1222,7 @@ case $cpu-$vendor in | moxie \ | mt \ | msp430 \ + | nanomips* \ | nds32 | nds32le | nds32be \ | nfp \ | nios | nios2 | nios2eb | nios2el \ @@ -1253,6 +1254,7 @@ case $cpu-$vendor in | ubicom32 \ | v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \ | vax \ + | vc4 \ | visium \ | w65 \ | wasm32 | wasm64 \ @@ -1597,7 +1599,7 @@ case $cpu-$vendor in os= obj=elf ;; - mips*-*) + mips*-*|nanomips*-*) os= obj=elf ;; @@ -1721,7 +1723,7 @@ fi case $os in # Sometimes we do "kernel-libc", so those need to count as OSes. - musl* | newlib* | relibc* | uclibc*) + llvm* | musl* | newlib* | relibc* | uclibc*) ;; # Likewise for "kernel-abi" eabi* | gnueabi*) @@ -1766,12 +1768,19 @@ case $os in | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \ - | fiwix* | mlibc* | cos* | mbr* ) + | fiwix* | mlibc* | cos* | mbr* | ironclad* ) ;; # This one is extra strict with allowed versions sco3.2v2 | sco3.2v[4-9]* | sco5v6*) # Don't forget version if it is 3.2v4 or newer. ;; + # This refers to builds using the UEFI calling convention + # (which depends on the architecture) and PE file format. + # Note that this is both a different calling convention and + # different file format than that of GNU-EFI + # (x86_64-w64-mingw32). + uefi) + ;; none) ;; kernel* | msvc* ) @@ -1818,8 +1827,9 @@ esac # As a final step for OS-related things, validate the OS-kernel combination # (given a valid OS), if there is a kernel. case $kernel-$os-$obj in - linux-gnu*- | linux-dietlibc*- | linux-android*- | linux-newlib*- \ - | linux-musl*- | linux-relibc*- | linux-uclibc*- | linux-mlibc*- ) + linux-gnu*- | linux-android*- | linux-dietlibc*- | linux-llvm*- \ + | linux-mlibc*- | linux-musl*- | linux-newlib*- \ + | linux-relibc*- | linux-uclibc*- ) ;; uclinux-uclibc*- ) ;; @@ -1827,7 +1837,8 @@ case $kernel-$os-$obj in ;; windows*-msvc*-) ;; - -dietlibc*- | -newlib*- | -musl*- | -relibc*- | -uclibc*- | -mlibc*- ) + -dietlibc*- | -llvm*- | -mlibc*- | -musl*- | -newlib*- | -relibc*- \ + | -uclibc*- ) # These are just libc implementations, not actual OSes, and thus # require a kernel. echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2 diff --git a/lib/c-ares-1.32.3/config/depcomp b/lib/c-ares-1.33.1/config/depcomp similarity index 98% rename from lib/c-ares-1.32.3/config/depcomp rename to lib/c-ares-1.33.1/config/depcomp index 715e34311ed..1f0aa972c93 100755 --- a/lib/c-ares-1.32.3/config/depcomp +++ b/lib/c-ares-1.33.1/config/depcomp @@ -1,9 +1,9 @@ #! /bin/sh # depcomp - compile a program generating dependencies as side-effects -scriptversion=2018-03-07.03; # UTC +scriptversion=2024-06-19.01; # UTC -# Copyright (C) 1999-2021 Free Software Foundation, Inc. +# Copyright (C) 1999-2024 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -47,11 +47,13 @@ Environment variables: libtool Whether libtool is used (yes/no). Report bugs to . +GNU Automake home page: . +General help using GNU software: . EOF exit $? ;; -v | --v*) - echo "depcomp $scriptversion" + echo "depcomp (GNU Automake) $scriptversion" exit $? ;; esac @@ -113,7 +115,6 @@ nl=' # These definitions help. upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ lower=abcdefghijklmnopqrstuvwxyz -digits=0123456789 alpha=${upper}${lower} if test -z "$depmode" || test -z "$source" || test -z "$object"; then @@ -128,7 +129,7 @@ tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" -# Avoid interferences from the environment. +# Avoid interference from the environment. gccflag= dashmflag= # Some modes work just like other modes, but use different flags. We @@ -198,8 +199,8 @@ gcc3) ;; gcc) -## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. -## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. +## Note that this doesn't just cater to obsolete pre-3.x GCC compilers. +## but also to in-use compilers like IBM xlc/xlC and the HP C compiler. ## (see the conditional assignment to $gccflag above). ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: diff --git a/lib/c-ares-1.32.3/config/install-sh b/lib/c-ares-1.33.1/config/install-sh similarity index 98% rename from lib/c-ares-1.32.3/config/install-sh rename to lib/c-ares-1.33.1/config/install-sh index 7c56c9c0151..b1d7a6f67f6 100755 --- a/lib/c-ares-1.32.3/config/install-sh +++ b/lib/c-ares-1.33.1/config/install-sh @@ -1,7 +1,7 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2023-11-23.18; # UTC +scriptversion=2024-06-19.01; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the @@ -170,7 +170,7 @@ while test $# -ne 0; do -T) is_target_a_directory=never;; - --version) echo "$0 $scriptversion"; exit $?;; + --version) echo "$0 (GNU Automake) $scriptversion"; exit $?;; --) shift break;; @@ -345,7 +345,7 @@ do ' 0 # Because "mkdir -p" follows existing symlinks and we likely work - # directly in world-writeable /tmp, make sure that the '$tmpdir' + # directly in world-writable /tmp, make sure that the '$tmpdir' # directory is successfully created first before we actually test # 'mkdir -p'. if (umask $mkdir_umask && @@ -353,7 +353,7 @@ do exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 then if test -z "$dir_arg" || { - # Check for POSIX incompatibilities with -m. + # Check for POSIX incompatibility with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. diff --git a/lib/c-ares-1.32.3/config/ltmain.sh b/lib/c-ares-1.33.1/config/ltmain.sh similarity index 100% rename from lib/c-ares-1.32.3/config/ltmain.sh rename to lib/c-ares-1.33.1/config/ltmain.sh diff --git a/lib/c-ares-1.32.3/config/missing b/lib/c-ares-1.33.1/config/missing similarity index 77% rename from lib/c-ares-1.32.3/config/missing rename to lib/c-ares-1.33.1/config/missing index 1fe1611f185..7e7d78ec52c 100755 --- a/lib/c-ares-1.32.3/config/missing +++ b/lib/c-ares-1.33.1/config/missing @@ -1,9 +1,11 @@ #! /bin/sh -# Common wrapper for a few potentially missing GNU programs. +# Common wrapper for a few potentially missing GNU and other programs. -scriptversion=2018-03-07.03; # UTC +scriptversion=2024-06-07.14; # UTC -# Copyright (C) 1996-2021 Free Software Foundation, Inc. +# shellcheck disable=SC2006,SC2268 # we must support pre-POSIX shells + +# Copyright (C) 1996-2024 Free Software Foundation, Inc. # Originally written by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify @@ -54,18 +56,20 @@ Options: -v, --version output version information and exit Supported PROGRAM values: - aclocal autoconf autoheader autom4te automake makeinfo - bison yacc flex lex help2man +aclocal autoconf autogen autoheader autom4te automake autoreconf +bison flex help2man lex makeinfo perl yacc Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 'g' are ignored when checking the name. -Send bug reports to ." +Report bugs to . +GNU Automake home page: . +General help using GNU software: ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) - echo "missing $scriptversion (GNU Automake)" + echo "missing (GNU Automake) $scriptversion" exit $? ;; @@ -108,7 +112,7 @@ gnu_software_URL=https://www.gnu.org/software program_details () { case $1 in - aclocal|automake) + aclocal|automake|autoreconf) echo "The '$1' program is part of the GNU Automake package:" echo "<$gnu_software_URL/automake>" echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" @@ -123,6 +127,9 @@ program_details () echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; + *) + : + ;; esac } @@ -137,48 +144,55 @@ give_advice () printf '%s\n' "'$1' is $msg." configure_deps="'configure.ac' or m4 files included by 'configure.ac'" + autoheader_deps="'acconfig.h'" + automake_deps="'Makefile.am'" + aclocal_deps="'acinclude.m4'" case $normalized_program in + aclocal*) + echo "You should only need it if you modified $aclocal_deps or" + echo "$configure_deps." + ;; autoconf*) - echo "You should only need it if you modified 'configure.ac'," - echo "or m4 files included by it." - program_details 'autoconf' + echo "You should only need it if you modified $configure_deps." + ;; + autogen*) + echo "You should only need it if you modified a '.def' or '.tpl' file." + echo "You may want to install the GNU AutoGen package:" + echo "<$gnu_software_URL/autogen/>" ;; autoheader*) - echo "You should only need it if you modified 'acconfig.h' or" + echo "You should only need it if you modified $autoheader_deps or" echo "$configure_deps." - program_details 'autoheader' ;; automake*) - echo "You should only need it if you modified 'Makefile.am' or" - echo "$configure_deps." - program_details 'automake' - ;; - aclocal*) - echo "You should only need it if you modified 'acinclude.m4' or" + echo "You should only need it if you modified $automake_deps or" echo "$configure_deps." - program_details 'aclocal' ;; - autom4te*) + autom4te*) echo "You might have modified some maintainer files that require" echo "the 'autom4te' program to be rebuilt." - program_details 'autom4te' + ;; + autoreconf*) + echo "You should only need it if you modified $aclocal_deps or" + echo "$automake_deps or $autoheader_deps or $automake_deps or" + echo "$configure_deps." ;; bison*|yacc*) echo "You should only need it if you modified a '.y' file." echo "You may want to install the GNU Bison package:" echo "<$gnu_software_URL/bison/>" ;; - lex*|flex*) - echo "You should only need it if you modified a '.l' file." - echo "You may want to install the Fast Lexical Analyzer package:" - echo "<$flex_URL>" - ;; help2man*) echo "You should only need it if you modified a dependency" \ "of a man page." echo "You may want to install the GNU Help2man package:" echo "<$gnu_software_URL/help2man/>" ;; + lex*|flex*) + echo "You should only need it if you modified a '.l' file." + echo "You may want to install the Fast Lexical Analyzer package:" + echo "<$flex_URL>" + ;; makeinfo*) echo "You should only need it if you modified a '.texi' file, or" echo "any other file indirectly affecting the aspect of the manual." @@ -189,6 +203,12 @@ give_advice () echo "want to install GNU make:" echo "<$gnu_software_URL/make/>" ;; + perl*) + echo "You should only need it to run GNU Autoconf, GNU Automake, " + echo " assorted other tools, or if you modified a Perl source file." + echo "You may want to install the Perl 5 language interpreter:" + echo "<$perl_URL>" + ;; *) echo "You might have modified some files without having the proper" echo "tools for further handling them. Check the 'README' file, it" @@ -197,6 +217,7 @@ give_advice () echo "case some other package contains this missing '$1' program." ;; esac + program_details "$normalized_program" } give_advice "$1" | sed -e '1s/^/WARNING: /' \ diff --git a/lib/c-ares-1.32.3/config/test-driver b/lib/c-ares-1.33.1/config/test-driver similarity index 89% rename from lib/c-ares-1.32.3/config/test-driver rename to lib/c-ares-1.33.1/config/test-driver index be73b80adf9..dc38f623f43 100755 --- a/lib/c-ares-1.32.3/config/test-driver +++ b/lib/c-ares-1.33.1/config/test-driver @@ -1,9 +1,9 @@ #! /bin/sh # test-driver - basic testsuite driver script. -scriptversion=2018-03-07.03; # UTC +scriptversion=2024-06-19.01; # UTC -# Copyright (C) 2011-2021 Free Software Foundation, Inc. +# Copyright (C) 2011-2024 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -44,11 +44,16 @@ print_usage () Usage: test-driver --test-name NAME --log-file PATH --trs-file PATH [--expect-failure {yes|no}] [--color-tests {yes|no}] + [--collect-skipped-logs {yes|no}] [--enable-hard-errors {yes|no}] [--] TEST-SCRIPT [TEST-SCRIPT-ARGUMENTS] The '--test-name', '--log-file' and '--trs-file' options are mandatory. See the GNU Automake documentation for information. + +Report bugs to . +GNU Automake home page: . +General help using GNU software: . END } @@ -57,15 +62,17 @@ log_file= # Where to save the output of the test script. trs_file= # Where to save the metadata of the test run. expect_failure=no color_tests=no +collect_skipped_logs=yes enable_hard_errors=yes while test $# -gt 0; do case $1 in --help) print_usage; exit $?;; - --version) echo "test-driver $scriptversion"; exit $?;; + --version) echo "test-driver (GNU Automake) $scriptversion"; exit $?;; --test-name) test_name=$2; shift;; --log-file) log_file=$2; shift;; --trs-file) trs_file=$2; shift;; --color-tests) color_tests=$2; shift;; + --collect-skipped-logs) collect_skipped_logs=$2; shift;; --expect-failure) expect_failure=$2; shift;; --enable-hard-errors) enable_hard_errors=$2; shift;; --) shift; break;; @@ -121,7 +128,7 @@ fi case $tweaked_estatus:$expect_failure in 0:yes) col=$red res=XPASS recheck=yes gcopy=yes;; 0:*) col=$grn res=PASS recheck=no gcopy=no;; - 77:*) col=$blu res=SKIP recheck=no gcopy=yes;; + 77:*) col=$blu res=SKIP recheck=no gcopy=$collect_skipped_logs;; 99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;; *:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;; *:*) col=$red res=FAIL recheck=yes gcopy=yes;; diff --git a/lib/c-ares-1.32.3/configure b/lib/c-ares-1.33.1/configure similarity index 98% rename from lib/c-ares-1.32.3/configure rename to lib/c-ares-1.33.1/configure index f5fc16a49bf..74e9741fe6e 100755 --- a/lib/c-ares-1.32.3/configure +++ b/lib/c-ares-1.33.1/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.72 for c-ares 1.32.3. +# Generated by GNU Autoconf 2.72 for c-ares 1.33.1. # # Report bugs to . # @@ -614,8 +614,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='c-ares' PACKAGE_TARNAME='c-ares' -PACKAGE_VERSION='1.32.3' -PACKAGE_STRING='c-ares 1.32.3' +PACKAGE_VERSION='1.33.1' +PACKAGE_STRING='c-ares 1.33.1' PACKAGE_BUGREPORT='c-ares mailing list: http://lists.haxx.se/listinfo/c-ares' PACKAGE_URL='' @@ -663,6 +663,8 @@ AM_CPPFLAGS AM_CFLAGS BUILD_TESTS_FALSE BUILD_TESTS_TRUE +GMOCK112_LIBS +GMOCK112_CFLAGS GMOCK_LIBS GMOCK_CFLAGS PKG_CONFIG_LIBDIR @@ -729,6 +731,8 @@ LIBTOOL OBJDUMP DLLTOOL AS +am__xargs_n +am__rm_f_notfound AM_BACKSLASH AM_DEFAULT_VERBOSITY AM_DEFAULT_V @@ -866,7 +870,9 @@ PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR GMOCK_CFLAGS -GMOCK_LIBS' +GMOCK_LIBS +GMOCK112_CFLAGS +GMOCK112_LIBS' # Initialize some variables set by options. @@ -1415,7 +1421,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -'configure' configures c-ares 1.32.3 to adapt to many kinds of systems. +'configure' configures c-ares 1.33.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1486,7 +1492,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of c-ares 1.32.3:";; + short | recursive ) echo "Configuration of c-ares 1.33.1:";; esac cat <<\_ACEOF @@ -1555,6 +1561,10 @@ Some influential environment variables: GMOCK_CFLAGS C compiler flags for GMOCK, overriding pkg-config GMOCK_LIBS linker flags for GMOCK, overriding pkg-config + GMOCK112_CFLAGS + C compiler flags for GMOCK112, overriding pkg-config + GMOCK112_LIBS + linker flags for GMOCK112, overriding pkg-config Use these variables to override the choices made by 'configure' or to help it to find libraries and programs with nonstandard names/locations. @@ -1623,7 +1633,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -c-ares configure 1.32.3 +c-ares configure 1.33.1 generated by GNU Autoconf 2.72 Copyright (C) 2023 Free Software Foundation, Inc. @@ -1951,50 +1961,6 @@ fi } # ac_fn_cxx_try_link -# ac_fn_c_try_run LINENO -# ---------------------- -# Try to run conftest.$ac_ext, and return whether this succeeded. Assumes that -# executables *can* be run. -ac_fn_c_try_run () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; } -then : - ac_retval=0 -else case e in #( - e) printf "%s\n" "$as_me: program exited with status $ac_status" >&5 - printf "%s\n" "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=$ac_status ;; -esac -fi - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_run - # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. @@ -2243,6 +2209,50 @@ printf "%s\n" "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_member + +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to run conftest.$ac_ext, and return whether this succeeded. Assumes that +# executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } +then : + ac_retval=0 +else case e in #( + e) printf "%s\n" "$as_me: program exited with status $ac_status" >&5 + printf "%s\n" "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status ;; +esac +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run ac_configure_args_raw= for ac_arg do @@ -2267,7 +2277,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by c-ares $as_me 1.32.3, which was +It was created by c-ares $as_me 1.33.1, which was generated by GNU Autoconf 2.72. Invocation command line was $ $0$ac_configure_args_raw @@ -3259,7 +3269,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu -CARES_VERSION_INFO="19:3:17" +CARES_VERSION_INFO="20:1:18" @@ -5421,7 +5431,7 @@ printf "%s\n" "#define HAVE_CXX14 1" >>confdefs.h fi -am__api_version='1.16' +am__api_version='1.17' # Find a good install program. We prefer a C program (faster), @@ -5523,6 +5533,165 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether sleep supports fractional seconds" >&5 +printf %s "checking whether sleep supports fractional seconds... " >&6; } +if test ${am_cv_sleep_fractional_seconds+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if sleep 0.001 2>/dev/null +then : + am_cv_sleep_fractional_seconds=yes +else case e in #( + e) am_cv_sleep_fractional_seconds=no ;; +esac +fi + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_sleep_fractional_seconds" >&5 +printf "%s\n" "$am_cv_sleep_fractional_seconds" >&6; } + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking filesystem timestamp resolution" >&5 +printf %s "checking filesystem timestamp resolution... " >&6; } +if test ${am_cv_filesystem_timestamp_resolution+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) # Default to the worst case. +am_cv_filesystem_timestamp_resolution=2 + +# Only try to go finer than 1 sec if sleep can do it. +# Don't try 1 sec, because if 0.01 sec and 0.1 sec don't work, +# - 1 sec is not much of a win compared to 2 sec, and +# - it takes 2 seconds to perform the test whether 1 sec works. +# +# Instead, just use the default 2s on platforms that have 1s resolution, +# accept the extra 1s delay when using $sleep in the Automake tests, in +# exchange for not incurring the 2s delay for running the test for all +# packages. +# +am_try_resolutions= +if test "$am_cv_sleep_fractional_seconds" = yes; then + # Even a millisecond often causes a bunch of false positives, + # so just try a hundredth of a second. The time saved between .001 and + # .01 is not terribly consequential. + am_try_resolutions="0.01 0.1 $am_try_resolutions" +fi + +# In order to catch current-generation FAT out, we must *modify* files +# that already exist; the *creation* timestamp is finer. Use names +# that make ls -t sort them differently when they have equal +# timestamps than when they have distinct timestamps, keeping +# in mind that ls -t prints the *newest* file first. +rm -f conftest.ts? +: > conftest.ts1 +: > conftest.ts2 +: > conftest.ts3 + +# Make sure ls -t actually works. Do 'set' in a subshell so we don't +# clobber the current shell's arguments. (Outer-level square brackets +# are removed by m4; they're present so that m4 does not expand +# ; be careful, easy to get confused.) +if ( + set X `ls -t conftest.ts[12]` && + { + test "$*" != "X conftest.ts1 conftest.ts2" || + test "$*" != "X conftest.ts2 conftest.ts1"; + } +); then :; else + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + printf "%s\n" ""Bad output from ls -t: \"`ls -t conftest.ts[12]`\""" >&5 + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "ls -t produces unexpected output. +Make sure there is not a broken ls alias in your environment. +See 'config.log' for more details" "$LINENO" 5; } +fi + +for am_try_res in $am_try_resolutions; do + # Any one fine-grained sleep might happen to cross the boundary + # between two values of a coarser actual resolution, but if we do + # two fine-grained sleeps in a row, at least one of them will fall + # entirely within a coarse interval. + echo alpha > conftest.ts1 + sleep $am_try_res + echo beta > conftest.ts2 + sleep $am_try_res + echo gamma > conftest.ts3 + + # We assume that 'ls -t' will make use of high-resolution + # timestamps if the operating system supports them at all. + if (set X `ls -t conftest.ts?` && + test "$2" = conftest.ts3 && + test "$3" = conftest.ts2 && + test "$4" = conftest.ts1); then + # + # Ok, ls -t worked. If we're at a resolution of 1 second, we're done, + # because we don't need to test make. + make_ok=true + if test $am_try_res != 1; then + # But if we've succeeded so far with a subsecond resolution, we + # have one more thing to check: make. It can happen that + # everything else supports the subsecond mtimes, but make doesn't; + # notably on macOS, which ships make 3.81 from 2006 (the last one + # released under GPLv2). https://bugs.gnu.org/68808 + # + # We test $MAKE if it is defined in the environment, else "make". + # It might get overridden later, but our hope is that in practice + # it does not matter: it is the system "make" which is (by far) + # the most likely to be broken, whereas if the user overrides it, + # probably they did so with a better, or at least not worse, make. + # https://lists.gnu.org/archive/html/automake/2024-06/msg00051.html + # + # Create a Makefile (real tab character here): + rm -f conftest.mk + echo 'conftest.ts1: conftest.ts2' >conftest.mk + echo ' touch conftest.ts2' >>conftest.mk + # + # Now, running + # touch conftest.ts1; touch conftest.ts2; make + # should touch ts1 because ts2 is newer. This could happen by luck, + # but most often, it will fail if make's support is insufficient. So + # test for several consecutive successes. + # + # (We reuse conftest.ts[12] because we still want to modify existing + # files, not create new ones, per above.) + n=0 + make=${MAKE-make} + until test $n -eq 3; do + echo one > conftest.ts1 + sleep $am_try_res + echo two > conftest.ts2 # ts2 should now be newer than ts1 + if $make -f conftest.mk | grep 'up to date' >/dev/null; then + make_ok=false + break # out of $n loop + fi + n=`expr $n + 1` + done + fi + # + if $make_ok; then + # Everything we know to check worked out, so call this resolution good. + am_cv_filesystem_timestamp_resolution=$am_try_res + break # out of $am_try_res loop + fi + # Otherwise, we'll go on to check the next resolution. + fi +done +rm -f conftest.ts? +# (end _am_filesystem_timestamp_resolution) + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_filesystem_timestamp_resolution" >&5 +printf "%s\n" "$am_cv_filesystem_timestamp_resolution" >&6; } + +# This check should not be cached, as it may vary across builds of +# different projects. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 printf %s "checking whether build environment is sane... " >&6; } # Reject unsafe characters in $srcdir or the absolute working directory @@ -5543,49 +5712,45 @@ esac # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). -if ( - am_has_slept=no - for am_try in 1 2; do - echo "timestamp, slept: $am_has_slept" > conftest.file - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$*" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - if test "$*" != "X $srcdir/configure conftest.file" \ - && test "$*" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - as_fn_error $? "ls -t appears to fail. Make sure there is not a broken - alias in your environment" "$LINENO" 5 - fi - if test "$2" = conftest.file || test $am_try -eq 2; then - break - fi - # Just in case. - sleep 1 - am_has_slept=yes - done - test "$2" = conftest.file - ) -then - # Ok. - : -else - as_fn_error $? "newly created file is older than distributed files! +am_build_env_is_sane=no +am_has_slept=no +rm -f conftest.file +for am_try in 1 2; do + echo "timestamp, slept: $am_has_slept" > conftest.file + if ( + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + test "$2" = conftest.file + ); then + am_build_env_is_sane=yes + break + fi + # Just in case. + sleep "$am_cv_filesystem_timestamp_resolution" + am_has_slept=yes +done + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_build_env_is_sane" >&5 +printf "%s\n" "$am_build_env_is_sane" >&6; } +if test "$am_build_env_is_sane" = no; then + as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= -if grep 'slept: no' conftest.file >/dev/null 2>&1; then - ( sleep 1 ) & +if test -e conftest.file || grep 'slept: no' conftest.file >/dev/null 2>&1 +then : + +else case e in #( + e) ( sleep "$am_cv_filesystem_timestamp_resolution" ) & am_sleep_pid=$! + ;; +esac fi rm -f conftest.file @@ -5935,17 +6100,13 @@ else fi +AM_DEFAULT_VERBOSITY=1 # Check whether --enable-silent-rules was given. if test ${enable_silent_rules+y} then : enableval=$enable_silent_rules; fi -case $enable_silent_rules in # ((( - yes) AM_DEFAULT_VERBOSITY=0;; - no) AM_DEFAULT_VERBOSITY=1;; - *) AM_DEFAULT_VERBOSITY=1;; -esac am_make=${MAKE-make} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 printf %s "checking whether $am_make supports nested variables... " >&6; } @@ -5968,15 +6129,45 @@ esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 printf "%s\n" "$am_cv_make_support_nested_variables" >&6; } -if test $am_cv_make_support_nested_variables = yes; then - AM_V='$(V)' - AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' -else - AM_V=$AM_DEFAULT_VERBOSITY - AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY -fi AM_BACKSLASH='\' +am__rm_f_notfound= +if (rm -f && rm -fr && rm -rf) 2>/dev/null +then : + +else case e in #( + e) am__rm_f_notfound='""' ;; +esac +fi + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking xargs -n works" >&5 +printf %s "checking xargs -n works... " >&6; } +if test ${am_cv_xargs_n_works+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if test "`echo 1 2 3 | xargs -n2 echo`" = "1 2 +3" +then : + am_cv_xargs_n_works=yes +else case e in #( + e) am_cv_xargs_n_works=no ;; +esac +fi ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_xargs_n_works" >&5 +printf "%s\n" "$am_cv_xargs_n_works" >&6; } +if test "$am_cv_xargs_n_works" = yes +then : + am__xargs_n='xargs -n' +else case e in #( + e) am__xargs_n='am__xargs_n () { shift; sed "s/ /\\n/g" | while read am__xargs_n_arg; do "" "$am__xargs_n_arg"; done; }' + ;; +esac +fi + if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." @@ -5999,7 +6190,7 @@ fi # Define the identity of the package. PACKAGE='c-ares' - VERSION='1.32.3' + VERSION='1.33.1' printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h @@ -6140,7 +6331,7 @@ else case e in #( # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: + # When given -MP, icc 7.0 and 7.1 complain thus: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported @@ -6270,7 +6461,7 @@ else case e in #( # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: + # When given -MP, icc 7.0 and 7.1 complain thus: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported @@ -6320,47 +6511,9 @@ fi -# POSIX will say in a future version that running "rm -f" with no argument -# is OK; and we want to be able to make that assumption in our Makefile -# recipes. So use an aggressive probe to check that the usage we want is -# actually supported "in the wild" to an acceptable degree. -# See automake bug#10828. -# To make any issue more visible, cause the running configure to be aborted -# by default if the 'rm' program in use doesn't match our expectations; the -# user can still override this though. -if rm -f && rm -fr && rm -rf; then : OK; else - cat >&2 <<'END' -Oops! - -Your 'rm' program seems unable to run without file operands specified -on the command line, even when the '-f' option is present. This is contrary -to the behaviour of most rm programs out there, and not conforming with -the upcoming POSIX standard: - -Please tell bug-automake@gnu.org about your system, including the value -of your $PATH and any error possibly output before this message. This -can help us improve future automake versions. -END - if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then - echo 'Configuration will proceed anyway, since you have set the' >&2 - echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 - echo >&2 - else - cat >&2 <<'END' -Aborting the configuration process, to ensure you take notice of the issue. -You can download and install GNU coreutils to get an 'rm' implementation -that behaves properly: . -If you want to complete the configuration process using your problematic -'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM -to "yes", and re-run configure. - -END - as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 - fi -fi case `pwd` in *\ * | *\ *) @@ -19498,48 +19651,8 @@ fi MAINT=$MAINTAINER_MODE_TRUE -# Check whether --enable-silent-rules was given. -if test ${enable_silent_rules+y} -then : - enableval=$enable_silent_rules; -fi - -case $enable_silent_rules in # ((( - yes) AM_DEFAULT_VERBOSITY=0;; - no) AM_DEFAULT_VERBOSITY=1;; - *) AM_DEFAULT_VERBOSITY=0;; -esac -am_make=${MAKE-make} -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 -printf %s "checking whether $am_make supports nested variables... " >&6; } -if test ${am_cv_make_support_nested_variables+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) if printf "%s\n" 'TRUE=$(BAR$(V)) -BAR0=false -BAR1=true -V=1 -am__doit: - @$(TRUE) -.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then - am_cv_make_support_nested_variables=yes -else - am_cv_make_support_nested_variables=no -fi ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 -printf "%s\n" "$am_cv_make_support_nested_variables" >&6; } -if test $am_cv_make_support_nested_variables = yes; then - AM_V='$(V)' - AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' -else - AM_V=$AM_DEFAULT_VERBOSITY - AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY -fi -AM_BACKSLASH='\' +AM_DEFAULT_VERBOSITY=0 @@ -19939,211 +20052,27 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether user namespaces are supported" >&5 -printf %s "checking whether user namespaces are supported... " >&6; } -if test ${ax_cv_user_namespace+y} +# Check whether --enable-largefile was given. +if test ${enable_largefile+y} +then : + enableval=$enable_largefile; +fi +if test "$enable_largefile,$enable_year2038" != no,no +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable large file support" >&5 +printf %s "checking for $CC option to enable large file support... " >&6; } +if test ${ac_cv_sys_largefile_opts+y} then : printf %s "(cached) " >&6 else case e in #( - e) - ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - if test "$cross_compiling" = yes + e) ac_save_CC="$CC" + ac_opt_found=no + for ac_opt in "none needed" "-D_FILE_OFFSET_BITS=64" "-D_LARGE_FILES=1" "-n32"; do + if test x"$ac_opt" != x"none needed" then : - ax_cv_user_namespace=no -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include - -int userfn(void *d) { - usleep(100000); /* synchronize by sleep */ - return (getuid() != 0); -} -char userst[1024*1024]; -int main() { - char buffer[1024]; - int rc, status, fd; - pid_t child = clone(userfn, userst + 1024*1024, CLONE_NEWUSER|SIGCHLD, 0); - if (child < 0) return 1; - - snprintf(buffer, sizeof(buffer), "/proc/%d/uid_map", child); - fd = open(buffer, O_CREAT|O_WRONLY|O_TRUNC, 0755); - snprintf(buffer, sizeof(buffer), "0 %d 1\n", getuid()); - write(fd, buffer, strlen(buffer)); - close(fd); - - rc = waitpid(child, &status, 0); - if (rc <= 0) return 1; - if (!WIFEXITED(status)) return 1; - return WEXITSTATUS(status); -} - -_ACEOF -if ac_fn_c_try_run "$LINENO" -then : - ax_cv_user_namespace=yes -else case e in #( - e) ax_cv_user_namespace=no ;; -esac -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext ;; -esac -fi - - ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_user_namespace" >&5 -printf "%s\n" "$ax_cv_user_namespace" >&6; } - if test "$ax_cv_user_namespace" = yes; then - -printf "%s\n" "#define HAVE_USER_NAMESPACE 1" >>confdefs.h - - fi - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether UTS namespaces are supported" >&5 -printf %s "checking whether UTS namespaces are supported... " >&6; } -if test ${ax_cv_uts_namespace+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) - ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - if test "$cross_compiling" = yes -then : - ax_cv_uts_namespace=no -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include -#include - -int utsfn(void *d) { - char buffer[1024]; - const char *name = "autoconftest"; - int rc = sethostname(name, strlen(name)); - if (rc != 0) return 1; - gethostname(buffer, 1024); - return (strcmp(buffer, name) != 0); -} - -char st2[1024*1024]; -int fn(void *d) { - pid_t child; - int rc, status; - usleep(100000); /* synchronize by sleep */ - if (getuid() != 0) return 1; - child = clone(utsfn, st2 + 1024*1024, CLONE_NEWUTS|SIGCHLD, 0); - if (child < 0) return 1; - rc = waitpid(child, &status, 0); - if (rc <= 0) return 1; - if (!WIFEXITED(status)) return 1; - return WEXITSTATUS(status); -} -char st[1024*1024]; -int main() { - char buffer[1024]; - int rc, status, fd; - pid_t child = clone(fn, st + 1024*1024, CLONE_NEWUSER|SIGCHLD, 0); - if (child < 0) return 1; - - snprintf(buffer, sizeof(buffer), "/proc/%d/uid_map", child); - fd = open(buffer, O_CREAT|O_WRONLY|O_TRUNC, 0755); - snprintf(buffer, sizeof(buffer), "0 %d 1\n", getuid()); - write(fd, buffer, strlen(buffer)); - close(fd); - - rc = waitpid(child, &status, 0); - if (rc <= 0) return 1; - if (!WIFEXITED(status)) return 1; - return WEXITSTATUS(status); -} - - -_ACEOF -if ac_fn_c_try_run "$LINENO" -then : - ax_cv_uts_namespace=yes -else case e in #( - e) ax_cv_uts_namespace=no ;; -esac -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext ;; -esac -fi - - ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_uts_namespace" >&5 -printf "%s\n" "$ax_cv_uts_namespace" >&6; } - if test "$ax_cv_uts_namespace" = yes; then - -printf "%s\n" "#define HAVE_UTS_NAMESPACE 1" >>confdefs.h - - fi - -# Check whether --enable-largefile was given. -if test ${enable_largefile+y} -then : - enableval=$enable_largefile; -fi -if test "$enable_largefile,$enable_year2038" != no,no -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable large file support" >&5 -printf %s "checking for $CC option to enable large file support... " >&6; } -if test ${ac_cv_sys_largefile_opts+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) ac_save_CC="$CC" - ac_opt_found=no - for ac_opt in "none needed" "-D_FILE_OFFSET_BITS=64" "-D_LARGE_FILES=1" "-n32"; do - if test x"$ac_opt" != x"none needed" -then : - CC="$ac_save_CC $ac_opt" -fi - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + CC="$ac_save_CC $ac_opt" +fi + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifndef FTYPE @@ -20682,7 +20611,154 @@ fi if test "$enable_warnings" = "yes"; then -for flag in -std=c90 -Wall -Wextra -Waggregate-return -Wcast-align -Wcast-qual -Wconversion -Wdeclaration-after-statement -Wdouble-promotion -Wfloat-equal -Wformat-security -Winit-self -Wjump-misses-init -Wlogical-op -Wmissing-braces -Wmissing-declarations -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-prototypes -Wnested-externs -Wno-coverage-mismatch -Wold-style-definition -Wpacked -Wpedantic -Wpointer-arith -Wredundant-decls -Wshadow -Wsign-conversion -Wstrict-overflow -Wstrict-prototypes -Wtrampolines -Wundef -Wunreachable-code -Wunused -Wvariadic-macros -Wvla -Wwrite-strings -Werror=implicit-int -Werror=implicit-function-declaration -Werror=partial-availability -Wno-long-long ; do +for flag in -Wall -Wextra -Waggregate-return -Wcast-align -Wcast-qual -Wconversion -Wdeclaration-after-statement -Wdouble-promotion -Wfloat-equal -Wformat-security -Winit-self -Wjump-misses-init -Wlogical-op -Wmissing-braces -Wmissing-declarations -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-prototypes -Wnested-externs -Wno-coverage-mismatch -Wold-style-definition -Wpacked -Wpedantic -Wpointer-arith -Wredundant-decls -Wshadow -Wsign-conversion -Wstrict-overflow -Wstrict-prototypes -Wtrampolines -Wundef -Wunreachable-code -Wunused -Wvariadic-macros -Wvla -Wwrite-strings -Werror=implicit-int -Werror=implicit-function-declaration -Werror=partial-availability -Wno-long-long ; do + as_CACHEVAR=`printf "%s\n" "ax_cv_check_cflags_-Werror_$flag" | sed "$as_sed_sh"` +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 +printf %s "checking whether C compiler accepts $flag... " >&6; } +if eval test \${$as_CACHEVAR+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) + ax_check_save_flags=$CFLAGS + CFLAGS="$CFLAGS -Werror $flag" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + eval "$as_CACHEVAR=yes" +else case e in #( + e) eval "$as_CACHEVAR=no" ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + CFLAGS=$ax_check_save_flags ;; +esac +fi +eval ac_res=\$$as_CACHEVAR + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } +if test x"`eval 'as_val=${'$as_CACHEVAR'};printf "%s\n" "$as_val"'`" = xyes +then : + if test ${AM_CFLAGS+y} +then : + case " $AM_CFLAGS " in + *" $flag "*) + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : AM_CFLAGS already contains \$flag"; } >&5 + (: AM_CFLAGS already contains $flag) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + ;; + *) + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : AM_CFLAGS=\"\$AM_CFLAGS \$flag\""; } >&5 + (: AM_CFLAGS="$AM_CFLAGS $flag") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + AM_CFLAGS="$AM_CFLAGS $flag" + ;; + esac +else case e in #( + e) AM_CFLAGS="$flag" ;; +esac +fi + +else case e in #( + e) : ;; +esac +fi + +done + + + case $host_os in + *android*) + + +for flag in -std=c99; do + as_CACHEVAR=`printf "%s\n" "ax_cv_check_cflags_-Werror_$flag" | sed "$as_sed_sh"` +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 +printf %s "checking whether C compiler accepts $flag... " >&6; } +if eval test \${$as_CACHEVAR+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) + ax_check_save_flags=$CFLAGS + CFLAGS="$CFLAGS -Werror $flag" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + eval "$as_CACHEVAR=yes" +else case e in #( + e) eval "$as_CACHEVAR=no" ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + CFLAGS=$ax_check_save_flags ;; +esac +fi +eval ac_res=\$$as_CACHEVAR + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } +if test x"`eval 'as_val=${'$as_CACHEVAR'};printf "%s\n" "$as_val"'`" = xyes +then : + if test ${AM_CFLAGS+y} +then : + case " $AM_CFLAGS " in + *" $flag "*) + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : AM_CFLAGS already contains \$flag"; } >&5 + (: AM_CFLAGS already contains $flag) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + ;; + *) + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : AM_CFLAGS=\"\$AM_CFLAGS \$flag\""; } >&5 + (: AM_CFLAGS="$AM_CFLAGS $flag") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + AM_CFLAGS="$AM_CFLAGS $flag" + ;; + esac +else case e in #( + e) AM_CFLAGS="$flag" ;; +esac +fi + +else case e in #( + e) : ;; +esac +fi + +done + + ;; + *) + + +for flag in -std=c90; do as_CACHEVAR=`printf "%s\n" "ax_cv_check_cflags_-Werror_$flag" | sed "$as_sed_sh"` { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 printf %s "checking whether C compiler accepts $flag... " >&6; } @@ -20751,6 +20827,8 @@ fi done + ;; + esac fi if test "$ax_cv_c_compiler_vendor" = "intel"; then @@ -22622,6 +22700,14 @@ then : printf "%s\n" "#define HAVE_CONNECT 1" >>confdefs.h +fi +ac_fn_check_decl "$LINENO" "connectx" "ac_cv_have_decl_connectx" "$cares_all_includes +" "$ac_c_undeclared_builtin_options" "CFLAGS" +if test "x$ac_cv_have_decl_connectx" = xyes +then : + +printf "%s\n" "#define HAVE_CONNECTX 1" >>confdefs.h + fi ac_fn_check_decl "$LINENO" "closesocket" "ac_cv_have_decl_closesocket" "$cares_all_includes " "$ac_c_undeclared_builtin_options" "CFLAGS" @@ -22892,23 +22978,39 @@ ac_fn_check_decl "$LINENO" "epoll_create1" "ac_cv_have_decl_epoll_create1" "$car if test "x$ac_cv_have_decl_epoll_create1" = xyes then : -printf "%s\n" "#define HAVE_EPOLL 1" >>confdefs.h +printf "%s\n" "#define HAVE_EPOLL 1" >>confdefs.h + +fi +ac_fn_check_decl "$LINENO" "ConvertInterfaceIndexToLuid" "ac_cv_have_decl_ConvertInterfaceIndexToLuid" "$cares_all_includes +" "$ac_c_undeclared_builtin_options" "CFLAGS" +if test "x$ac_cv_have_decl_ConvertInterfaceIndexToLuid" = xyes +then : + +printf "%s\n" "#define HAVE_CONVERTINTERFACEINDEXTOLUID 1" >>confdefs.h + +fi +ac_fn_check_decl "$LINENO" "ConvertInterfaceLuidToNameA" "ac_cv_have_decl_ConvertInterfaceLuidToNameA" "$cares_all_includes +" "$ac_c_undeclared_builtin_options" "CFLAGS" +if test "x$ac_cv_have_decl_ConvertInterfaceLuidToNameA" = xyes +then : + +printf "%s\n" "#define HAVE_CONVERTINTERFACELUIDTONAMEA 1" >>confdefs.h fi -ac_fn_check_decl "$LINENO" "ConvertInterfaceIndexToLuid" "ac_cv_have_decl_ConvertInterfaceIndexToLuid" "$cares_all_includes +ac_fn_check_decl "$LINENO" "NotifyIpInterfaceChange" "ac_cv_have_decl_NotifyIpInterfaceChange" "$cares_all_includes " "$ac_c_undeclared_builtin_options" "CFLAGS" -if test "x$ac_cv_have_decl_ConvertInterfaceIndexToLuid" = xyes +if test "x$ac_cv_have_decl_NotifyIpInterfaceChange" = xyes then : -printf "%s\n" "#define HAVE_CONVERTINTERFACEINDEXTOLUID 1" >>confdefs.h +printf "%s\n" "#define HAVE_NOTIFYIPINTERFACECHANGE 1" >>confdefs.h fi -ac_fn_check_decl "$LINENO" "ConvertInterfaceLuidToNameA" "ac_cv_have_decl_ConvertInterfaceLuidToNameA" "$cares_all_includes +ac_fn_check_decl "$LINENO" "RegisterWaitForSingleObject" "ac_cv_have_decl_RegisterWaitForSingleObject" "$cares_all_includes " "$ac_c_undeclared_builtin_options" "CFLAGS" -if test "x$ac_cv_have_decl_ConvertInterfaceLuidToNameA" = xyes +if test "x$ac_cv_have_decl_RegisterWaitForSingleObject" = xyes then : -printf "%s\n" "#define HAVE_CONVERTINTERFACELUIDTONAMEA 1" >>confdefs.h +printf "%s\n" "#define HAVE_REGISTERWAITFORSINGLEOBJECT 1" >>confdefs.h fi ac_fn_check_decl "$LINENO" "__system_property_get" "ac_cv_have_decl___system_property_get" "$cares_all_includes @@ -24475,6 +24577,264 @@ printf "%s\n" "$as_me: WARNING: gmock could not be found, not building tests" >& else as_fn_error $? "tests require gmock" "$LINENO" 5 fi + else + +pkg_failed=no +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gmock >= 1.12.0" >&5 +printf %s "checking for gmock >= 1.12.0... " >&6; } + +if test -n "$GMOCK112_CFLAGS"; then + pkg_cv_GMOCK112_CFLAGS="$GMOCK112_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gmock >= 1.12.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "gmock >= 1.12.0") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_GMOCK112_CFLAGS=`$PKG_CONFIG --cflags "gmock >= 1.12.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$GMOCK112_LIBS"; then + pkg_cv_GMOCK112_LIBS="$GMOCK112_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gmock >= 1.12.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "gmock >= 1.12.0") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_GMOCK112_LIBS=`$PKG_CONFIG --libs "gmock >= 1.12.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + GMOCK112_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "gmock >= 1.12.0" 2>&1` + else + GMOCK112_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "gmock >= 1.12.0" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$GMOCK112_PKG_ERRORS" >&5 + + have_gmock_v112=no +elif test $pkg_failed = untried; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + have_gmock_v112=no +else + GMOCK112_CFLAGS=$pkg_cv_GMOCK112_CFLAGS + GMOCK112_LIBS=$pkg_cv_GMOCK112_LIBS + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + have_gmock_v112=yes +fi + if test "x$have_gmock_v112" = "xyes" ; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether user namespaces are supported" >&5 +printf %s "checking whether user namespaces are supported... " >&6; } +if test ${ax_cv_user_namespace+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + if test "$cross_compiling" = yes +then : + ax_cv_user_namespace=no +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include + +int userfn(void *d) { + usleep(100000); /* synchronize by sleep */ + return (getuid() != 0); +} +char userst[1024*1024]; +int main() { + char buffer[1024]; + int rc, status, fd; + pid_t child = clone(userfn, userst + 1024*1024, CLONE_NEWUSER|SIGCHLD, 0); + if (child < 0) return 1; + + snprintf(buffer, sizeof(buffer), "/proc/%d/uid_map", child); + fd = open(buffer, O_CREAT|O_WRONLY|O_TRUNC, 0755); + snprintf(buffer, sizeof(buffer), "0 %d 1\n", getuid()); + write(fd, buffer, strlen(buffer)); + close(fd); + + rc = waitpid(child, &status, 0); + if (rc <= 0) return 1; + if (!WIFEXITED(status)) return 1; + return WEXITSTATUS(status); +} + +_ACEOF +if ac_fn_c_try_run "$LINENO" +then : + ax_cv_user_namespace=yes +else case e in #( + e) ax_cv_user_namespace=no ;; +esac +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac +fi + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_user_namespace" >&5 +printf "%s\n" "$ax_cv_user_namespace" >&6; } + if test "$ax_cv_user_namespace" = yes; then + +printf "%s\n" "#define HAVE_USER_NAMESPACE 1" >>confdefs.h + + fi + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether UTS namespaces are supported" >&5 +printf %s "checking whether UTS namespaces are supported... " >&6; } +if test ${ax_cv_uts_namespace+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + if test "$cross_compiling" = yes +then : + ax_cv_uts_namespace=no +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include + +int utsfn(void *d) { + char buffer[1024]; + const char *name = "autoconftest"; + int rc = sethostname(name, strlen(name)); + if (rc != 0) return 1; + gethostname(buffer, 1024); + return (strcmp(buffer, name) != 0); +} + +char st2[1024*1024]; +int fn(void *d) { + pid_t child; + int rc, status; + usleep(100000); /* synchronize by sleep */ + if (getuid() != 0) return 1; + child = clone(utsfn, st2 + 1024*1024, CLONE_NEWUTS|SIGCHLD, 0); + if (child < 0) return 1; + rc = waitpid(child, &status, 0); + if (rc <= 0) return 1; + if (!WIFEXITED(status)) return 1; + return WEXITSTATUS(status); +} +char st[1024*1024]; +int main() { + char buffer[1024]; + int rc, status, fd; + pid_t child = clone(fn, st + 1024*1024, CLONE_NEWUSER|SIGCHLD, 0); + if (child < 0) return 1; + + snprintf(buffer, sizeof(buffer), "/proc/%d/uid_map", child); + fd = open(buffer, O_CREAT|O_WRONLY|O_TRUNC, 0755); + snprintf(buffer, sizeof(buffer), "0 %d 1\n", getuid()); + write(fd, buffer, strlen(buffer)); + close(fd); + + rc = waitpid(child, &status, 0); + if (rc <= 0) return 1; + if (!WIFEXITED(status)) return 1; + return WEXITSTATUS(status); +} + + +_ACEOF +if ac_fn_c_try_run "$LINENO" +then : + ax_cv_uts_namespace=yes +else case e in #( + e) ax_cv_uts_namespace=no ;; +esac +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac +fi + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_uts_namespace" >&5 +printf "%s\n" "$ax_cv_uts_namespace" >&6; } + if test "$ax_cv_uts_namespace" = yes; then + +printf "%s\n" "#define HAVE_UTS_NAMESPACE 1" >>confdefs.h + + fi + + fi fi fi if test "x$build_tests" != "xno" ; then @@ -25912,6 +26272,18 @@ if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +case $enable_silent_rules in # ((( + yes) AM_DEFAULT_VERBOSITY=0;; + no) AM_DEFAULT_VERBOSITY=1;; +esac +if test $am_cv_make_support_nested_variables = yes; then + AM_V='$(V)' + AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' +else + AM_V=$AM_DEFAULT_VERBOSITY + AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY +fi + if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' @@ -26339,7 +26711,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by c-ares $as_me 1.32.3, which was +This file was extended by c-ares $as_me 1.33.1, which was generated by GNU Autoconf 2.72. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -26407,7 +26779,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ -c-ares config.status 1.32.3 +c-ares config.status 1.33.1 configured by $0, generated by GNU Autoconf 2.72, with options \\"\$ac_cs_config\\" diff --git a/lib/c-ares-1.32.3/configure.ac b/lib/c-ares-1.33.1/configure.ac similarity index 94% rename from lib/c-ares-1.32.3/configure.ac rename to lib/c-ares-1.33.1/configure.ac index 7abf80f68bd..59fd975b64f 100644 --- a/lib/c-ares-1.32.3/configure.ac +++ b/lib/c-ares-1.33.1/configure.ac @@ -2,10 +2,10 @@ dnl Copyright (C) The c-ares project and its contributors dnl SPDX-License-Identifier: MIT AC_PREREQ([2.69]) -AC_INIT([c-ares], [1.32.3], +AC_INIT([c-ares], [1.33.1], [c-ares mailing list: http://lists.haxx.se/listinfo/c-ares]) -CARES_VERSION_INFO="19:3:17" +CARES_VERSION_INFO="20:1:18" dnl This flag accepts an argument of the form current[:revision[:age]]. So, dnl passing -version-info 3:12:1 sets current to 3, revision to 12, and age to dnl 1. @@ -153,8 +153,6 @@ _EOF ]) AX_CODE_COVERAGE -AX_CHECK_USER_NAMESPACE -AX_CHECK_UTS_NAMESPACE AC_SYS_LARGEFILE case $host_os in @@ -245,8 +243,18 @@ AC_SUBST(CARES_SYMBOL_HIDING_CFLAG) if test "$enable_warnings" = "yes"; then - AX_APPEND_COMPILE_FLAGS([-std=c90 -Wall -Wextra -Waggregate-return -Wcast-align -Wcast-qual -Wconversion -Wdeclaration-after-statement -Wdouble-promotion -Wfloat-equal -Wformat-security -Winit-self -Wjump-misses-init -Wlogical-op -Wmissing-braces -Wmissing-declarations -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-prototypes -Wnested-externs -Wno-coverage-mismatch -Wold-style-definition -Wpacked -Wpedantic -Wpointer-arith -Wredundant-decls -Wshadow -Wsign-conversion -Wstrict-overflow -Wstrict-prototypes -Wtrampolines -Wundef -Wunreachable-code -Wunused -Wvariadic-macros -Wvla -Wwrite-strings -Werror=implicit-int -Werror=implicit-function-declaration -Werror=partial-availability -Wno-long-long ], + AX_APPEND_COMPILE_FLAGS([-Wall -Wextra -Waggregate-return -Wcast-align -Wcast-qual -Wconversion -Wdeclaration-after-statement -Wdouble-promotion -Wfloat-equal -Wformat-security -Winit-self -Wjump-misses-init -Wlogical-op -Wmissing-braces -Wmissing-declarations -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-prototypes -Wnested-externs -Wno-coverage-mismatch -Wold-style-definition -Wpacked -Wpedantic -Wpointer-arith -Wredundant-decls -Wshadow -Wsign-conversion -Wstrict-overflow -Wstrict-prototypes -Wtrampolines -Wundef -Wunreachable-code -Wunused -Wvariadic-macros -Wvla -Wwrite-strings -Werror=implicit-int -Werror=implicit-function-declaration -Werror=partial-availability -Wno-long-long ], [AM_CFLAGS], [-Werror]) + + dnl Android requires c99, all others should use c90 + case $host_os in + *android*) + AX_APPEND_COMPILE_FLAGS([-std=c99], [AM_CFLAGS], [-Werror]) + ;; + *) + AX_APPEND_COMPILE_FLAGS([-std=c90], [AM_CFLAGS], [-Werror]) + ;; + esac fi if test "$ax_cv_c_compiler_vendor" = "intel"; then @@ -538,6 +546,7 @@ AC_CHECK_DECL(send, [AC_DEFINE([HAVE_SEND], 1, [Define t AC_CHECK_DECL(getnameinfo, [AC_DEFINE([HAVE_GETNAMEINFO], 1, [Define to 1 if you have `getnameinfo`] )], [], $cares_all_includes) AC_CHECK_DECL(gethostname, [AC_DEFINE([HAVE_GETHOSTNAME], 1, [Define to 1 if you have `gethostname`] )], [], $cares_all_includes) AC_CHECK_DECL(connect, [AC_DEFINE([HAVE_CONNECT], 1, [Define to 1 if you have `connect`] )], [], $cares_all_includes) +AC_CHECK_DECL(connectx, [AC_DEFINE([HAVE_CONNECTX], 1, [Define to 1 if you have `connectx`] )], [], $cares_all_includes) AC_CHECK_DECL(closesocket, [AC_DEFINE([HAVE_CLOSESOCKET], 1, [Define to 1 if you have `closesocket`] )], [], $cares_all_includes) AC_CHECK_DECL(CloseSocket, [AC_DEFINE([HAVE_CLOSESOCKET_CAMEL], 1, [Define to 1 if you have `CloseSocket`] )], [], $cares_all_includes) AC_CHECK_DECL(fcntl, [AC_DEFINE([HAVE_FCNTL], 1, [Define to 1 if you have `fcntl`] )], [], $cares_all_includes) @@ -574,6 +583,8 @@ AC_CHECK_DECL(kqueue, [AC_DEFINE([HAVE_KQUEUE], 1, [Define t AC_CHECK_DECL(epoll_create1, [AC_DEFINE([HAVE_EPOLL], 1, [Define to 1 if you have `epoll_{create1,ctl,wait}`])], [], $cares_all_includes) AC_CHECK_DECL(ConvertInterfaceIndexToLuid, [AC_DEFINE([HAVE_CONVERTINTERFACEINDEXTOLUID], 1, [Define to 1 if you have `ConvertInterfaceIndexToLuid`])], [], $cares_all_includes) AC_CHECK_DECL(ConvertInterfaceLuidToNameA, [AC_DEFINE([HAVE_CONVERTINTERFACELUIDTONAMEA], 1, [Define to 1 if you have `ConvertInterfaceLuidToNameA`])], [], $cares_all_includes) +AC_CHECK_DECL(NotifyIpInterfaceChange, [AC_DEFINE([HAVE_NOTIFYIPINTERFACECHANGE], 1, [Define to 1 if you have `NotifyIpInterfaceChange`] )], [], $cares_all_includes) +AC_CHECK_DECL(RegisterWaitForSingleObject, [AC_DEFINE([HAVE_REGISTERWAITFORSINGLEOBJECT], 1, [Define to 1 if you have `RegisterWaitForSingleObject`])], [], $cares_all_includes) AC_CHECK_DECL(__system_property_get, [AC_DEFINE([HAVE___SYSTEM_PROPERTY_GET], 1, [Define to 1 if you have `__system_property_get`] )], [], $cares_all_includes) @@ -806,6 +817,12 @@ if test "x$build_tests" != "xno" ; then else AC_MSG_ERROR([tests require gmock]) fi + else + PKG_CHECK_MODULES([GMOCK112], [gmock >= 1.12.0], [ have_gmock_v112=yes ], [ have_gmock_v112=no ]) + if test "x$have_gmock_v112" = "xyes" ; then + AX_CHECK_USER_NAMESPACE + AX_CHECK_UTS_NAMESPACE + fi fi fi if test "x$build_tests" != "xno" ; then diff --git a/lib/c-ares-1.32.3/docs/CMakeLists.txt b/lib/c-ares-1.33.1/docs/CMakeLists.txt similarity index 100% rename from lib/c-ares-1.32.3/docs/CMakeLists.txt rename to lib/c-ares-1.33.1/docs/CMakeLists.txt diff --git a/lib/c-ares-1.32.3/docs/Makefile.am b/lib/c-ares-1.33.1/docs/Makefile.am similarity index 100% rename from lib/c-ares-1.32.3/docs/Makefile.am rename to lib/c-ares-1.33.1/docs/Makefile.am diff --git a/lib/c-ares-1.32.3/docs/Makefile.in b/lib/c-ares-1.33.1/docs/Makefile.in similarity index 96% rename from lib/c-ares-1.32.3/docs/Makefile.in rename to lib/c-ares-1.33.1/docs/Makefile.in index 0b44dbd8c53..a57cd0abc18 100644 --- a/lib/c-ares-1.32.3/docs/Makefile.in +++ b/lib/c-ares-1.33.1/docs/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.5 from Makefile.am. +# Makefile.in generated by automake 1.17 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2021 Free Software Foundation, Inc. +# Copyright (C) 1994-2024 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -72,6 +72,8 @@ am__make_running_with_option = \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +am__rm_f = rm -f $(am__rm_f_notfound) +am__rm_rf = rm -rf $(am__rm_f_notfound) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -166,10 +168,9 @@ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ + { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && echo $$files | $(am__xargs_n) 40 $(am__rm_f); }; \ } man3dir = $(mandir)/man3 am__installdirs = "$(DESTDIR)$(man3dir)" @@ -226,6 +227,8 @@ FGREP = @FGREP@ FILECMD = @FILECMD@ GCOV = @GCOV@ GENHTML = @GENHTML@ +GMOCK112_CFLAGS = @GMOCK112_CFLAGS@ +GMOCK112_LIBS = @GMOCK112_LIBS@ GMOCK_CFLAGS = @GMOCK_CFLAGS@ GMOCK_LIBS = @GMOCK_LIBS@ GREP = @GREP@ @@ -288,8 +291,10 @@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ +am__rm_f_notfound = @am__rm_f_notfound@ am__tar = @am__tar@ am__untar = @am__untar@ +am__xargs_n = @am__xargs_n@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ @@ -638,8 +643,8 @@ mostlyclean-generic: clean-generic: distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -$(am__rm_f) $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || $(am__rm_f) $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @@ -733,3 +738,10 @@ uninstall-man: uninstall-man3 # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: + +# Tell GNU make to disable its built-in pattern rules. +%:: %,v +%:: RCS/%,v +%:: RCS/% +%:: s.% +%:: SCCS/s.% diff --git a/lib/c-ares-1.32.3/docs/Makefile.inc b/lib/c-ares-1.33.1/docs/Makefile.inc similarity index 100% rename from lib/c-ares-1.32.3/docs/Makefile.inc rename to lib/c-ares-1.33.1/docs/Makefile.inc diff --git a/lib/c-ares-1.32.3/docs/adig.1 b/lib/c-ares-1.33.1/docs/adig.1 similarity index 100% rename from lib/c-ares-1.32.3/docs/adig.1 rename to lib/c-ares-1.33.1/docs/adig.1 diff --git a/lib/c-ares-1.32.3/docs/ahost.1 b/lib/c-ares-1.33.1/docs/ahost.1 similarity index 100% rename from lib/c-ares-1.32.3/docs/ahost.1 rename to lib/c-ares-1.33.1/docs/ahost.1 diff --git a/lib/c-ares-1.32.3/docs/ares_cancel.3 b/lib/c-ares-1.33.1/docs/ares_cancel.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_cancel.3 rename to lib/c-ares-1.33.1/docs/ares_cancel.3 diff --git a/lib/c-ares-1.32.3/docs/ares_create_query.3 b/lib/c-ares-1.33.1/docs/ares_create_query.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_create_query.3 rename to lib/c-ares-1.33.1/docs/ares_create_query.3 diff --git a/lib/c-ares-1.32.3/docs/ares_destroy.3 b/lib/c-ares-1.33.1/docs/ares_destroy.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_destroy.3 rename to lib/c-ares-1.33.1/docs/ares_destroy.3 diff --git a/lib/c-ares-1.32.3/docs/ares_destroy_options.3 b/lib/c-ares-1.33.1/docs/ares_destroy_options.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_destroy_options.3 rename to lib/c-ares-1.33.1/docs/ares_destroy_options.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_class_fromstr.3 b/lib/c-ares-1.33.1/docs/ares_dns_class_fromstr.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_class_fromstr.3 rename to lib/c-ares-1.33.1/docs/ares_dns_class_fromstr.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_class_t.3 b/lib/c-ares-1.33.1/docs/ares_dns_class_t.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_class_t.3 rename to lib/c-ares-1.33.1/docs/ares_dns_class_t.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_class_tostr.3 b/lib/c-ares-1.33.1/docs/ares_dns_class_tostr.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_class_tostr.3 rename to lib/c-ares-1.33.1/docs/ares_dns_class_tostr.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_datatype_t.3 b/lib/c-ares-1.33.1/docs/ares_dns_datatype_t.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_datatype_t.3 rename to lib/c-ares-1.33.1/docs/ares_dns_datatype_t.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_flags_t.3 b/lib/c-ares-1.33.1/docs/ares_dns_flags_t.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_flags_t.3 rename to lib/c-ares-1.33.1/docs/ares_dns_flags_t.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_mapping.3 b/lib/c-ares-1.33.1/docs/ares_dns_mapping.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_mapping.3 rename to lib/c-ares-1.33.1/docs/ares_dns_mapping.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_opcode_t.3 b/lib/c-ares-1.33.1/docs/ares_dns_opcode_t.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_opcode_t.3 rename to lib/c-ares-1.33.1/docs/ares_dns_opcode_t.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_opcode_tostr.3 b/lib/c-ares-1.33.1/docs/ares_dns_opcode_tostr.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_opcode_tostr.3 rename to lib/c-ares-1.33.1/docs/ares_dns_opcode_tostr.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_opt_datatype_t.3 b/lib/c-ares-1.33.1/docs/ares_dns_opt_datatype_t.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_opt_datatype_t.3 rename to lib/c-ares-1.33.1/docs/ares_dns_opt_datatype_t.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_opt_get_datatype.3 b/lib/c-ares-1.33.1/docs/ares_dns_opt_get_datatype.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_opt_get_datatype.3 rename to lib/c-ares-1.33.1/docs/ares_dns_opt_get_datatype.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_opt_get_name.3 b/lib/c-ares-1.33.1/docs/ares_dns_opt_get_name.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_opt_get_name.3 rename to lib/c-ares-1.33.1/docs/ares_dns_opt_get_name.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_parse.3 b/lib/c-ares-1.33.1/docs/ares_dns_parse.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_parse.3 rename to lib/c-ares-1.33.1/docs/ares_dns_parse.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rcode_t.3 b/lib/c-ares-1.33.1/docs/ares_dns_rcode_t.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rcode_t.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rcode_t.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rcode_tostr.3 b/lib/c-ares-1.33.1/docs/ares_dns_rcode_tostr.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rcode_tostr.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rcode_tostr.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rec_type_fromstr.3 b/lib/c-ares-1.33.1/docs/ares_dns_rec_type_fromstr.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rec_type_fromstr.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rec_type_fromstr.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rec_type_t.3 b/lib/c-ares-1.33.1/docs/ares_dns_rec_type_t.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rec_type_t.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rec_type_t.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rec_type_tostr.3 b/lib/c-ares-1.33.1/docs/ares_dns_rec_type_tostr.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rec_type_tostr.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rec_type_tostr.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_record.3 b/lib/c-ares-1.33.1/docs/ares_dns_record.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_record.3 rename to lib/c-ares-1.33.1/docs/ares_dns_record.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_record_create.3 b/lib/c-ares-1.33.1/docs/ares_dns_record_create.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_record_create.3 rename to lib/c-ares-1.33.1/docs/ares_dns_record_create.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_record_destroy.3 b/lib/c-ares-1.33.1/docs/ares_dns_record_destroy.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_record_destroy.3 rename to lib/c-ares-1.33.1/docs/ares_dns_record_destroy.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_record_duplicate.3 b/lib/c-ares-1.33.1/docs/ares_dns_record_duplicate.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_record_duplicate.3 rename to lib/c-ares-1.33.1/docs/ares_dns_record_duplicate.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_record_get_flags.3 b/lib/c-ares-1.33.1/docs/ares_dns_record_get_flags.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_record_get_flags.3 rename to lib/c-ares-1.33.1/docs/ares_dns_record_get_flags.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_record_get_id.3 b/lib/c-ares-1.33.1/docs/ares_dns_record_get_id.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_record_get_id.3 rename to lib/c-ares-1.33.1/docs/ares_dns_record_get_id.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_record_get_opcode.3 b/lib/c-ares-1.33.1/docs/ares_dns_record_get_opcode.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_record_get_opcode.3 rename to lib/c-ares-1.33.1/docs/ares_dns_record_get_opcode.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_record_get_rcode.3 b/lib/c-ares-1.33.1/docs/ares_dns_record_get_rcode.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_record_get_rcode.3 rename to lib/c-ares-1.33.1/docs/ares_dns_record_get_rcode.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_record_query_add.3 b/lib/c-ares-1.33.1/docs/ares_dns_record_query_add.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_record_query_add.3 rename to lib/c-ares-1.33.1/docs/ares_dns_record_query_add.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_record_query_cnt.3 b/lib/c-ares-1.33.1/docs/ares_dns_record_query_cnt.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_record_query_cnt.3 rename to lib/c-ares-1.33.1/docs/ares_dns_record_query_cnt.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_record_query_get.3 b/lib/c-ares-1.33.1/docs/ares_dns_record_query_get.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_record_query_get.3 rename to lib/c-ares-1.33.1/docs/ares_dns_record_query_get.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_record_query_set_name.3 b/lib/c-ares-1.33.1/docs/ares_dns_record_query_set_name.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_record_query_set_name.3 rename to lib/c-ares-1.33.1/docs/ares_dns_record_query_set_name.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_record_query_set_type.3 b/lib/c-ares-1.33.1/docs/ares_dns_record_query_set_type.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_record_query_set_type.3 rename to lib/c-ares-1.33.1/docs/ares_dns_record_query_set_type.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_record_rr_add.3 b/lib/c-ares-1.33.1/docs/ares_dns_record_rr_add.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_record_rr_add.3 rename to lib/c-ares-1.33.1/docs/ares_dns_record_rr_add.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_record_rr_cnt.3 b/lib/c-ares-1.33.1/docs/ares_dns_record_rr_cnt.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_record_rr_cnt.3 rename to lib/c-ares-1.33.1/docs/ares_dns_record_rr_cnt.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_record_rr_del.3 b/lib/c-ares-1.33.1/docs/ares_dns_record_rr_del.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_record_rr_del.3 rename to lib/c-ares-1.33.1/docs/ares_dns_record_rr_del.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_record_rr_get.3 b/lib/c-ares-1.33.1/docs/ares_dns_record_rr_get.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_record_rr_get.3 rename to lib/c-ares-1.33.1/docs/ares_dns_record_rr_get.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_record_rr_get_const.3 b/lib/c-ares-1.33.1/docs/ares_dns_record_rr_get_const.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_record_rr_get_const.3 rename to lib/c-ares-1.33.1/docs/ares_dns_record_rr_get_const.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_record_set_id.3 b/lib/c-ares-1.33.1/docs/ares_dns_record_set_id.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_record_set_id.3 rename to lib/c-ares-1.33.1/docs/ares_dns_record_set_id.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr.3 similarity index 96% rename from lib/c-ares-1.32.3/docs/ares_dns_rr.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr.3 index 9d5ab37515e..4da768650b5 100644 --- a/lib/c-ares-1.32.3/docs/ares_dns_rr.3 +++ b/lib/c-ares-1.33.1/docs/ares_dns_rr.3 @@ -96,6 +96,10 @@ ares_status_t ares_dns_rr_set_opt(ares_dns_rr_t *dns_rr, const unsigned char *val, size_t val_len); +ares_status_t ares_dns_rr_del_opt_byid(ares_dns_rr_t *dns_rr, + ares_dns_rr_key_t key, + unsigned short opt); + const struct in_addr *ares_dns_rr_get_addr(const ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key); @@ -553,7 +557,7 @@ parameter, and the index to remove is provided in the parameter. The \fIares_dns_rr_set_opt(3)\fP function is used to set option/parameter keys and -values for the resource record when the datatype if \fIARES_DATATYPE_OPT\fP. The +values for the resource record when the datatype is \fIARES_DATATYPE_OPT\fP. The resource record to be modified is provided in the .IR dns_rr parameter. They key/parameter is provided in the @@ -568,6 +572,18 @@ enumerations. The value for the option is always provided in binary form in with length provided in .IR val_len. +The \fIares_dns_rr_del_opt_byid(3)\fP function is used to delete option/parameter +keys and values for the resource record when the datatype is +\fIARES_DATATYPE_OPT\fP. The resource record to be modified is provided in the +.IR dns_rr +parameter. They key/parameter is provided in the +.IR key +parameter. The option/parameter value specific to the resource record is provided +in the +.IR opt +parameter. This function returns \fIARES_SUCCESS\fP if the record is successfully +removed, or \fIARES_ENOTFOUND\fP if the record could not be found. + The \fIares_dns_rr_get_addr(3)\fP function is used to retrieve the IPv4 address from the resource record when the datatype is \fIARES_DATATYPE_INADDR\fP. The resource record is provided in the @@ -635,7 +651,7 @@ parameter and the key/parameter to retrieve is provided in the .IR key parameter. -The \fIares_dns_rr_get_abin(3)\fP function is used to retrive binary data from +The \fIares_dns_rr_get_abin(3)\fP function is used to retrieve binary data from the resource record array when the datatype is \fIARES_DATATYPE_ABINP\fP. The resource record is provided in the .IR dns_rr diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_add_abin.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_add_abin.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_add_abin.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_add_abin.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_del_abin.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_del_abin.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_del_abin.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_del_abin.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_get_abin.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_get_abin.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_get_abin.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_get_abin.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_get_abin_cnt.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_get_abin_cnt.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_get_abin_cnt.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_get_abin_cnt.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_get_addr.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_get_addr.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_get_addr.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_get_addr.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_get_addr6.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_get_addr6.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_get_addr6.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_get_addr6.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_get_bin.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_get_bin.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_get_bin.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_get_bin.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_get_class.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_get_class.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_get_class.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_get_class.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_get_keys.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_get_keys.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_get_keys.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_get_keys.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_get_name.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_get_name.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_get_name.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_get_name.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_get_opt.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_get_opt.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_get_opt.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_get_opt.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_get_opt_byid.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_get_opt_byid.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_get_opt_byid.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_get_opt_byid.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_get_opt_cnt.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_get_opt_cnt.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_get_opt_cnt.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_get_opt_cnt.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_get_str.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_get_str.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_get_str.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_get_str.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_get_ttl.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_get_ttl.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_get_ttl.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_get_ttl.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_get_type.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_get_type.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_get_type.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_get_type.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_get_u16.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_get_u16.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_get_u16.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_get_u16.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_get_u32.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_get_u32.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_get_u32.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_get_u32.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_get_u8.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_get_u8.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_get_u8.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_get_u8.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_key_datatype.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_key_datatype.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_key_datatype.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_key_datatype.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_key_t.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_key_t.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_key_t.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_key_t.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_key_to_rec_type.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_key_to_rec_type.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_key_to_rec_type.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_key_to_rec_type.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_key_tostr.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_key_tostr.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_key_tostr.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_key_tostr.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_set_addr.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_set_addr.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_set_addr.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_set_addr.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_set_addr6.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_set_addr6.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_set_addr6.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_set_addr6.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_set_bin.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_set_bin.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_set_bin.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_set_bin.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_set_opt.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_set_opt.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_set_opt.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_set_opt.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_set_str.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_set_str.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_set_str.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_set_str.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_set_u16.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_set_u16.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_set_u16.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_set_u16.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_set_u32.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_set_u32.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_set_u32.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_set_u32.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_rr_set_u8.3 b/lib/c-ares-1.33.1/docs/ares_dns_rr_set_u8.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_rr_set_u8.3 rename to lib/c-ares-1.33.1/docs/ares_dns_rr_set_u8.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_section_t.3 b/lib/c-ares-1.33.1/docs/ares_dns_section_t.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_section_t.3 rename to lib/c-ares-1.33.1/docs/ares_dns_section_t.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_section_tostr.3 b/lib/c-ares-1.33.1/docs/ares_dns_section_tostr.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_section_tostr.3 rename to lib/c-ares-1.33.1/docs/ares_dns_section_tostr.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dns_write.3 b/lib/c-ares-1.33.1/docs/ares_dns_write.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dns_write.3 rename to lib/c-ares-1.33.1/docs/ares_dns_write.3 diff --git a/lib/c-ares-1.32.3/docs/ares_dup.3 b/lib/c-ares-1.33.1/docs/ares_dup.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_dup.3 rename to lib/c-ares-1.33.1/docs/ares_dup.3 diff --git a/lib/c-ares-1.32.3/docs/ares_expand_name.3 b/lib/c-ares-1.33.1/docs/ares_expand_name.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_expand_name.3 rename to lib/c-ares-1.33.1/docs/ares_expand_name.3 diff --git a/lib/c-ares-1.32.3/docs/ares_expand_string.3 b/lib/c-ares-1.33.1/docs/ares_expand_string.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_expand_string.3 rename to lib/c-ares-1.33.1/docs/ares_expand_string.3 diff --git a/lib/c-ares-1.32.3/docs/ares_fds.3 b/lib/c-ares-1.33.1/docs/ares_fds.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_fds.3 rename to lib/c-ares-1.33.1/docs/ares_fds.3 diff --git a/lib/c-ares-1.32.3/docs/ares_free_data.3 b/lib/c-ares-1.33.1/docs/ares_free_data.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_free_data.3 rename to lib/c-ares-1.33.1/docs/ares_free_data.3 diff --git a/lib/c-ares-1.32.3/docs/ares_free_hostent.3 b/lib/c-ares-1.33.1/docs/ares_free_hostent.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_free_hostent.3 rename to lib/c-ares-1.33.1/docs/ares_free_hostent.3 diff --git a/lib/c-ares-1.32.3/docs/ares_free_string.3 b/lib/c-ares-1.33.1/docs/ares_free_string.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_free_string.3 rename to lib/c-ares-1.33.1/docs/ares_free_string.3 diff --git a/lib/c-ares-1.32.3/docs/ares_freeaddrinfo.3 b/lib/c-ares-1.33.1/docs/ares_freeaddrinfo.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_freeaddrinfo.3 rename to lib/c-ares-1.33.1/docs/ares_freeaddrinfo.3 diff --git a/lib/c-ares-1.32.3/docs/ares_get_servers.3 b/lib/c-ares-1.33.1/docs/ares_get_servers.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_get_servers.3 rename to lib/c-ares-1.33.1/docs/ares_get_servers.3 diff --git a/lib/c-ares-1.32.3/docs/ares_get_servers_csv.3 b/lib/c-ares-1.33.1/docs/ares_get_servers_csv.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_get_servers_csv.3 rename to lib/c-ares-1.33.1/docs/ares_get_servers_csv.3 diff --git a/lib/c-ares-1.32.3/docs/ares_get_servers_ports.3 b/lib/c-ares-1.33.1/docs/ares_get_servers_ports.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_get_servers_ports.3 rename to lib/c-ares-1.33.1/docs/ares_get_servers_ports.3 diff --git a/lib/c-ares-1.32.3/docs/ares_getaddrinfo.3 b/lib/c-ares-1.33.1/docs/ares_getaddrinfo.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_getaddrinfo.3 rename to lib/c-ares-1.33.1/docs/ares_getaddrinfo.3 diff --git a/lib/c-ares-1.32.3/docs/ares_gethostbyaddr.3 b/lib/c-ares-1.33.1/docs/ares_gethostbyaddr.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_gethostbyaddr.3 rename to lib/c-ares-1.33.1/docs/ares_gethostbyaddr.3 diff --git a/lib/c-ares-1.32.3/docs/ares_gethostbyname.3 b/lib/c-ares-1.33.1/docs/ares_gethostbyname.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_gethostbyname.3 rename to lib/c-ares-1.33.1/docs/ares_gethostbyname.3 diff --git a/lib/c-ares-1.32.3/docs/ares_gethostbyname_file.3 b/lib/c-ares-1.33.1/docs/ares_gethostbyname_file.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_gethostbyname_file.3 rename to lib/c-ares-1.33.1/docs/ares_gethostbyname_file.3 diff --git a/lib/c-ares-1.32.3/docs/ares_getnameinfo.3 b/lib/c-ares-1.33.1/docs/ares_getnameinfo.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_getnameinfo.3 rename to lib/c-ares-1.33.1/docs/ares_getnameinfo.3 diff --git a/lib/c-ares-1.32.3/docs/ares_getsock.3 b/lib/c-ares-1.33.1/docs/ares_getsock.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_getsock.3 rename to lib/c-ares-1.33.1/docs/ares_getsock.3 diff --git a/lib/c-ares-1.32.3/docs/ares_inet_ntop.3 b/lib/c-ares-1.33.1/docs/ares_inet_ntop.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_inet_ntop.3 rename to lib/c-ares-1.33.1/docs/ares_inet_ntop.3 diff --git a/lib/c-ares-1.32.3/docs/ares_inet_pton.3 b/lib/c-ares-1.33.1/docs/ares_inet_pton.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_inet_pton.3 rename to lib/c-ares-1.33.1/docs/ares_inet_pton.3 diff --git a/lib/c-ares-1.32.3/docs/ares_init.3 b/lib/c-ares-1.33.1/docs/ares_init.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_init.3 rename to lib/c-ares-1.33.1/docs/ares_init.3 diff --git a/lib/c-ares-1.32.3/docs/ares_init_options.3 b/lib/c-ares-1.33.1/docs/ares_init_options.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_init_options.3 rename to lib/c-ares-1.33.1/docs/ares_init_options.3 diff --git a/lib/c-ares-1.32.3/docs/ares_library_cleanup.3 b/lib/c-ares-1.33.1/docs/ares_library_cleanup.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_library_cleanup.3 rename to lib/c-ares-1.33.1/docs/ares_library_cleanup.3 diff --git a/lib/c-ares-1.32.3/docs/ares_library_init.3 b/lib/c-ares-1.33.1/docs/ares_library_init.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_library_init.3 rename to lib/c-ares-1.33.1/docs/ares_library_init.3 diff --git a/lib/c-ares-1.32.3/docs/ares_library_init_android.3 b/lib/c-ares-1.33.1/docs/ares_library_init_android.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_library_init_android.3 rename to lib/c-ares-1.33.1/docs/ares_library_init_android.3 diff --git a/lib/c-ares-1.32.3/docs/ares_library_initialized.3 b/lib/c-ares-1.33.1/docs/ares_library_initialized.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_library_initialized.3 rename to lib/c-ares-1.33.1/docs/ares_library_initialized.3 diff --git a/lib/c-ares-1.32.3/docs/ares_mkquery.3 b/lib/c-ares-1.33.1/docs/ares_mkquery.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_mkquery.3 rename to lib/c-ares-1.33.1/docs/ares_mkquery.3 diff --git a/lib/c-ares-1.32.3/docs/ares_opt_param_t.3 b/lib/c-ares-1.33.1/docs/ares_opt_param_t.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_opt_param_t.3 rename to lib/c-ares-1.33.1/docs/ares_opt_param_t.3 diff --git a/lib/c-ares-1.32.3/docs/ares_parse_a_reply.3 b/lib/c-ares-1.33.1/docs/ares_parse_a_reply.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_parse_a_reply.3 rename to lib/c-ares-1.33.1/docs/ares_parse_a_reply.3 diff --git a/lib/c-ares-1.32.3/docs/ares_parse_aaaa_reply.3 b/lib/c-ares-1.33.1/docs/ares_parse_aaaa_reply.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_parse_aaaa_reply.3 rename to lib/c-ares-1.33.1/docs/ares_parse_aaaa_reply.3 diff --git a/lib/c-ares-1.32.3/docs/ares_parse_caa_reply.3 b/lib/c-ares-1.33.1/docs/ares_parse_caa_reply.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_parse_caa_reply.3 rename to lib/c-ares-1.33.1/docs/ares_parse_caa_reply.3 diff --git a/lib/c-ares-1.32.3/docs/ares_parse_mx_reply.3 b/lib/c-ares-1.33.1/docs/ares_parse_mx_reply.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_parse_mx_reply.3 rename to lib/c-ares-1.33.1/docs/ares_parse_mx_reply.3 diff --git a/lib/c-ares-1.32.3/docs/ares_parse_naptr_reply.3 b/lib/c-ares-1.33.1/docs/ares_parse_naptr_reply.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_parse_naptr_reply.3 rename to lib/c-ares-1.33.1/docs/ares_parse_naptr_reply.3 diff --git a/lib/c-ares-1.32.3/docs/ares_parse_ns_reply.3 b/lib/c-ares-1.33.1/docs/ares_parse_ns_reply.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_parse_ns_reply.3 rename to lib/c-ares-1.33.1/docs/ares_parse_ns_reply.3 diff --git a/lib/c-ares-1.32.3/docs/ares_parse_ptr_reply.3 b/lib/c-ares-1.33.1/docs/ares_parse_ptr_reply.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_parse_ptr_reply.3 rename to lib/c-ares-1.33.1/docs/ares_parse_ptr_reply.3 diff --git a/lib/c-ares-1.32.3/docs/ares_parse_soa_reply.3 b/lib/c-ares-1.33.1/docs/ares_parse_soa_reply.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_parse_soa_reply.3 rename to lib/c-ares-1.33.1/docs/ares_parse_soa_reply.3 diff --git a/lib/c-ares-1.32.3/docs/ares_parse_srv_reply.3 b/lib/c-ares-1.33.1/docs/ares_parse_srv_reply.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_parse_srv_reply.3 rename to lib/c-ares-1.33.1/docs/ares_parse_srv_reply.3 diff --git a/lib/c-ares-1.32.3/docs/ares_parse_txt_reply.3 b/lib/c-ares-1.33.1/docs/ares_parse_txt_reply.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_parse_txt_reply.3 rename to lib/c-ares-1.33.1/docs/ares_parse_txt_reply.3 diff --git a/lib/c-ares-1.32.3/docs/ares_parse_uri_reply.3 b/lib/c-ares-1.33.1/docs/ares_parse_uri_reply.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_parse_uri_reply.3 rename to lib/c-ares-1.33.1/docs/ares_parse_uri_reply.3 diff --git a/lib/c-ares-1.32.3/docs/ares_process.3 b/lib/c-ares-1.33.1/docs/ares_process.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_process.3 rename to lib/c-ares-1.33.1/docs/ares_process.3 diff --git a/lib/c-ares-1.32.3/docs/ares_query.3 b/lib/c-ares-1.33.1/docs/ares_query.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_query.3 rename to lib/c-ares-1.33.1/docs/ares_query.3 diff --git a/lib/c-ares-1.32.3/docs/ares_query_dnsrec.3 b/lib/c-ares-1.33.1/docs/ares_query_dnsrec.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_query_dnsrec.3 rename to lib/c-ares-1.33.1/docs/ares_query_dnsrec.3 diff --git a/lib/c-ares-1.32.3/docs/ares_queue.3 b/lib/c-ares-1.33.1/docs/ares_queue.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_queue.3 rename to lib/c-ares-1.33.1/docs/ares_queue.3 diff --git a/lib/c-ares-1.32.3/docs/ares_queue_active_queries.3 b/lib/c-ares-1.33.1/docs/ares_queue_active_queries.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_queue_active_queries.3 rename to lib/c-ares-1.33.1/docs/ares_queue_active_queries.3 diff --git a/lib/c-ares-1.32.3/docs/ares_queue_wait_empty.3 b/lib/c-ares-1.33.1/docs/ares_queue_wait_empty.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_queue_wait_empty.3 rename to lib/c-ares-1.33.1/docs/ares_queue_wait_empty.3 diff --git a/lib/c-ares-1.32.3/docs/ares_reinit.3 b/lib/c-ares-1.33.1/docs/ares_reinit.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_reinit.3 rename to lib/c-ares-1.33.1/docs/ares_reinit.3 diff --git a/lib/c-ares-1.32.3/docs/ares_save_options.3 b/lib/c-ares-1.33.1/docs/ares_save_options.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_save_options.3 rename to lib/c-ares-1.33.1/docs/ares_save_options.3 diff --git a/lib/c-ares-1.32.3/docs/ares_search.3 b/lib/c-ares-1.33.1/docs/ares_search.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_search.3 rename to lib/c-ares-1.33.1/docs/ares_search.3 diff --git a/lib/c-ares-1.32.3/docs/ares_search_dnsrec.3 b/lib/c-ares-1.33.1/docs/ares_search_dnsrec.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_search_dnsrec.3 rename to lib/c-ares-1.33.1/docs/ares_search_dnsrec.3 diff --git a/lib/c-ares-1.32.3/docs/ares_send.3 b/lib/c-ares-1.33.1/docs/ares_send.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_send.3 rename to lib/c-ares-1.33.1/docs/ares_send.3 diff --git a/lib/c-ares-1.32.3/docs/ares_send_dnsrec.3 b/lib/c-ares-1.33.1/docs/ares_send_dnsrec.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_send_dnsrec.3 rename to lib/c-ares-1.33.1/docs/ares_send_dnsrec.3 diff --git a/lib/c-ares-1.32.3/docs/ares_set_local_dev.3 b/lib/c-ares-1.33.1/docs/ares_set_local_dev.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_set_local_dev.3 rename to lib/c-ares-1.33.1/docs/ares_set_local_dev.3 diff --git a/lib/c-ares-1.32.3/docs/ares_set_local_ip4.3 b/lib/c-ares-1.33.1/docs/ares_set_local_ip4.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_set_local_ip4.3 rename to lib/c-ares-1.33.1/docs/ares_set_local_ip4.3 diff --git a/lib/c-ares-1.32.3/docs/ares_set_local_ip6.3 b/lib/c-ares-1.33.1/docs/ares_set_local_ip6.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_set_local_ip6.3 rename to lib/c-ares-1.33.1/docs/ares_set_local_ip6.3 diff --git a/lib/c-ares-1.32.3/docs/ares_set_server_state_callback.3 b/lib/c-ares-1.33.1/docs/ares_set_server_state_callback.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_set_server_state_callback.3 rename to lib/c-ares-1.33.1/docs/ares_set_server_state_callback.3 diff --git a/lib/c-ares-1.32.3/docs/ares_set_servers.3 b/lib/c-ares-1.33.1/docs/ares_set_servers.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_set_servers.3 rename to lib/c-ares-1.33.1/docs/ares_set_servers.3 diff --git a/lib/c-ares-1.32.3/docs/ares_set_servers_csv.3 b/lib/c-ares-1.33.1/docs/ares_set_servers_csv.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_set_servers_csv.3 rename to lib/c-ares-1.33.1/docs/ares_set_servers_csv.3 diff --git a/lib/c-ares-1.32.3/docs/ares_set_servers_ports.3 b/lib/c-ares-1.33.1/docs/ares_set_servers_ports.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_set_servers_ports.3 rename to lib/c-ares-1.33.1/docs/ares_set_servers_ports.3 diff --git a/lib/c-ares-1.32.3/docs/ares_set_servers_ports_csv.3 b/lib/c-ares-1.33.1/docs/ares_set_servers_ports_csv.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_set_servers_ports_csv.3 rename to lib/c-ares-1.33.1/docs/ares_set_servers_ports_csv.3 diff --git a/lib/c-ares-1.32.3/docs/ares_set_socket_callback.3 b/lib/c-ares-1.33.1/docs/ares_set_socket_callback.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_set_socket_callback.3 rename to lib/c-ares-1.33.1/docs/ares_set_socket_callback.3 diff --git a/lib/c-ares-1.32.3/docs/ares_set_socket_configure_callback.3 b/lib/c-ares-1.33.1/docs/ares_set_socket_configure_callback.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_set_socket_configure_callback.3 rename to lib/c-ares-1.33.1/docs/ares_set_socket_configure_callback.3 diff --git a/lib/c-ares-1.32.3/docs/ares_set_socket_functions.3 b/lib/c-ares-1.33.1/docs/ares_set_socket_functions.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_set_socket_functions.3 rename to lib/c-ares-1.33.1/docs/ares_set_socket_functions.3 diff --git a/lib/c-ares-1.32.3/docs/ares_set_sortlist.3 b/lib/c-ares-1.33.1/docs/ares_set_sortlist.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_set_sortlist.3 rename to lib/c-ares-1.33.1/docs/ares_set_sortlist.3 diff --git a/lib/c-ares-1.32.3/docs/ares_strerror.3 b/lib/c-ares-1.33.1/docs/ares_strerror.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_strerror.3 rename to lib/c-ares-1.33.1/docs/ares_strerror.3 diff --git a/lib/c-ares-1.32.3/docs/ares_svcb_param_t.3 b/lib/c-ares-1.33.1/docs/ares_svcb_param_t.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_svcb_param_t.3 rename to lib/c-ares-1.33.1/docs/ares_svcb_param_t.3 diff --git a/lib/c-ares-1.32.3/docs/ares_threadsafety.3 b/lib/c-ares-1.33.1/docs/ares_threadsafety.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_threadsafety.3 rename to lib/c-ares-1.33.1/docs/ares_threadsafety.3 diff --git a/lib/c-ares-1.32.3/docs/ares_timeout.3 b/lib/c-ares-1.33.1/docs/ares_timeout.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_timeout.3 rename to lib/c-ares-1.33.1/docs/ares_timeout.3 diff --git a/lib/c-ares-1.32.3/docs/ares_tlsa_match_t.3 b/lib/c-ares-1.33.1/docs/ares_tlsa_match_t.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_tlsa_match_t.3 rename to lib/c-ares-1.33.1/docs/ares_tlsa_match_t.3 diff --git a/lib/c-ares-1.32.3/docs/ares_tlsa_selector_t.3 b/lib/c-ares-1.33.1/docs/ares_tlsa_selector_t.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_tlsa_selector_t.3 rename to lib/c-ares-1.33.1/docs/ares_tlsa_selector_t.3 diff --git a/lib/c-ares-1.32.3/docs/ares_tlsa_usage_t.3 b/lib/c-ares-1.33.1/docs/ares_tlsa_usage_t.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_tlsa_usage_t.3 rename to lib/c-ares-1.33.1/docs/ares_tlsa_usage_t.3 diff --git a/lib/c-ares-1.32.3/docs/ares_version.3 b/lib/c-ares-1.33.1/docs/ares_version.3 similarity index 100% rename from lib/c-ares-1.32.3/docs/ares_version.3 rename to lib/c-ares-1.33.1/docs/ares_version.3 diff --git a/lib/c-ares-1.32.3/include/CMakeLists.txt b/lib/c-ares-1.33.1/include/CMakeLists.txt similarity index 100% rename from lib/c-ares-1.32.3/include/CMakeLists.txt rename to lib/c-ares-1.33.1/include/CMakeLists.txt diff --git a/lib/c-ares-1.32.3/include/Makefile.am b/lib/c-ares-1.33.1/include/Makefile.am similarity index 100% rename from lib/c-ares-1.32.3/include/Makefile.am rename to lib/c-ares-1.33.1/include/Makefile.am diff --git a/lib/c-ares-1.32.3/include/Makefile.in b/lib/c-ares-1.33.1/include/Makefile.in similarity index 95% rename from lib/c-ares-1.32.3/include/Makefile.in rename to lib/c-ares-1.33.1/include/Makefile.in index 94e8e640fbe..99936f86497 100644 --- a/lib/c-ares-1.32.3/include/Makefile.in +++ b/lib/c-ares-1.33.1/include/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.5 from Makefile.am. +# Makefile.in generated by automake 1.17 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2021 Free Software Foundation, Inc. +# Copyright (C) 1994-2024 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -70,6 +70,8 @@ am__make_running_with_option = \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +am__rm_f = rm -f $(am__rm_f_notfound) +am__rm_rf = rm -rf $(am__rm_f_notfound) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -162,10 +164,9 @@ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ + { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && echo $$files | $(am__xargs_n) 40 $(am__rm_f); }; \ } am__installdirs = "$(DESTDIR)$(includedir)" HEADERS = $(include_HEADERS) @@ -237,6 +238,8 @@ FGREP = @FGREP@ FILECMD = @FILECMD@ GCOV = @GCOV@ GENHTML = @GENHTML@ +GMOCK112_CFLAGS = @GMOCK112_CFLAGS@ +GMOCK112_LIBS = @GMOCK112_LIBS@ GMOCK_CFLAGS = @GMOCK_CFLAGS@ GMOCK_LIBS = @GMOCK_LIBS@ GREP = @GREP@ @@ -299,8 +302,10 @@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ +am__rm_f_notfound = @am__rm_f_notfound@ am__tar = @am__tar@ am__untar = @am__untar@ +am__xargs_n = @am__xargs_n@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ @@ -393,8 +398,8 @@ ares_build.h: stamp-h2 @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h2 stamp-h2: $(srcdir)/ares_build.h.in $(top_builddir)/config.status - @rm -f stamp-h2 - cd $(top_builddir) && $(SHELL) ./config.status include/ares_build.h + $(AM_V_at)rm -f stamp-h2 + $(AM_V_GEN)cd $(top_builddir) && $(SHELL) ./config.status include/ares_build.h distclean-hdr: -rm -f ares_build.h stamp-h2 @@ -541,8 +546,8 @@ mostlyclean-generic: clean-generic: distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -$(am__rm_f) $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || $(am__rm_f) $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @@ -635,3 +640,10 @@ uninstall-am: uninstall-includeHEADERS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: + +# Tell GNU make to disable its built-in pattern rules. +%:: %,v +%:: RCS/%,v +%:: RCS/% +%:: s.% +%:: SCCS/s.% diff --git a/lib/c-ares-1.32.3/include/ares.h b/lib/c-ares-1.33.1/include/ares.h similarity index 99% rename from lib/c-ares-1.32.3/include/ares.h rename to lib/c-ares-1.33.1/include/ares.h index afff1759b39..95fc2440a1f 100644 --- a/lib/c-ares-1.32.3/include/ares.h +++ b/lib/c-ares-1.33.1/include/ares.h @@ -95,7 +95,7 @@ #endif typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t; -typedef CARES_TYPEOF_ARES_SSIZE_T ares_ssize_t; +typedef CARES_TYPEOF_ARES_SSIZE_T ares_ssize_t; #ifdef __cplusplus extern "C" { diff --git a/lib/c-ares-1.32.3/include/ares_build.h b/lib/c-ares-1.33.1/include/ares_build.h similarity index 100% rename from lib/c-ares-1.32.3/include/ares_build.h rename to lib/c-ares-1.33.1/include/ares_build.h diff --git a/lib/c-ares-1.32.3/include/ares_build.h.cmake b/lib/c-ares-1.33.1/include/ares_build.h.cmake similarity index 100% rename from lib/c-ares-1.32.3/include/ares_build.h.cmake rename to lib/c-ares-1.33.1/include/ares_build.h.cmake diff --git a/lib/c-ares-1.32.3/include/ares_build.h.in b/lib/c-ares-1.33.1/include/ares_build.h.in similarity index 100% rename from lib/c-ares-1.32.3/include/ares_build.h.in rename to lib/c-ares-1.33.1/include/ares_build.h.in diff --git a/lib/c-ares-1.32.3/include/ares_dns.h b/lib/c-ares-1.33.1/include/ares_dns.h similarity index 100% rename from lib/c-ares-1.32.3/include/ares_dns.h rename to lib/c-ares-1.33.1/include/ares_dns.h diff --git a/lib/c-ares-1.32.3/include/ares_dns_record.h b/lib/c-ares-1.33.1/include/ares_dns_record.h similarity index 95% rename from lib/c-ares-1.32.3/include/ares_dns_record.h rename to lib/c-ares-1.33.1/include/ares_dns_record.h index 00b6809f124..2896eab24b3 100644 --- a/lib/c-ares-1.32.3/include/ares_dns_record.h +++ b/lib/c-ares-1.33.1/include/ares_dns_record.h @@ -152,28 +152,28 @@ typedef enum { ARES_RCODE_BADNAME = 20, /*!< RFC 2930. Duplicate Key Name */ ARES_RCODE_BADALG = 21, /*!< RFC 2930. Algorithm not supported */ ARES_RCODE_BADTRUNC = 22, /*!< RFC 8945. Bad Truncation */ - ARES_RCODE_BADCOOKIE = 23 /*!< RVC 7973. Bad/missing Server Cookie */ + ARES_RCODE_BADCOOKIE = 23 /*!< RFC 7873. Bad/missing Server Cookie */ } ares_dns_rcode_t; /*! Data types used */ typedef enum { - ARES_DATATYPE_INADDR = 1, /*!< struct in_addr * type */ - ARES_DATATYPE_INADDR6 = 2, /*!< struct ares_in6_addr * type */ - ARES_DATATYPE_U8 = 3, /*!< 8bit unsigned integer */ - ARES_DATATYPE_U16 = 4, /*!< 16bit unsigned integer */ - ARES_DATATYPE_U32 = 5, /*!< 32bit unsigned integer */ - ARES_DATATYPE_NAME = 6, /*!< Null-terminated string of a domain name */ - ARES_DATATYPE_STR = 7, /*!< Null-terminated string */ - ARES_DATATYPE_BIN = 8, /*!< Binary data */ - ARES_DATATYPE_BINP = 9, /*!< Officially defined as binary data, but likely - * printable. Guaranteed to have a NULL - * terminator for convenience (not included in - * length) */ - ARES_DATATYPE_OPT = 10, /*!< Array of options. 16bit identifier, BIN - * data. */ - ARES_DATATYPE_ABINP = 11 /*!< Array of binary data, likely printable. - * Guaranteed to have a NULL terminator for - * convenience (not included in length) */ + ARES_DATATYPE_INADDR = 1, /*!< struct in_addr * type */ + ARES_DATATYPE_INADDR6 = 2, /*!< struct ares_in6_addr * type */ + ARES_DATATYPE_U8 = 3, /*!< 8bit unsigned integer */ + ARES_DATATYPE_U16 = 4, /*!< 16bit unsigned integer */ + ARES_DATATYPE_U32 = 5, /*!< 32bit unsigned integer */ + ARES_DATATYPE_NAME = 6, /*!< Null-terminated string of a domain name */ + ARES_DATATYPE_STR = 7, /*!< Null-terminated string */ + ARES_DATATYPE_BIN = 8, /*!< Binary data */ + ARES_DATATYPE_BINP = 9, /*!< Officially defined as binary data, but likely + * printable. Guaranteed to have a NULL + * terminator for convenience (not included in + * length) */ + ARES_DATATYPE_OPT = 10, /*!< Array of options. 16bit identifier, BIN + * data. */ + ARES_DATATYPE_ABINP = 11 /*!< Array of binary data, likely printable. + * Guaranteed to have a NULL terminator for + * convenience (not included in length) */ } ares_dns_datatype_t; /*! Keys used for all RR Types. We take the record type and multiply by 100 @@ -609,8 +609,8 @@ CARES_EXTERN unsigned short * \param[in] id DNS query id * \return ARES_TRUE on success, ARES_FALSE on usage error */ -CARES_EXTERN ares_bool_t - ares_dns_record_set_id(ares_dns_record_t *dnsrec, unsigned short id); +CARES_EXTERN ares_bool_t ares_dns_record_set_id(ares_dns_record_t *dnsrec, + unsigned short id); /*! Get the DNS Record Flags * @@ -885,10 +885,10 @@ CARES_EXTERN ares_status_t ares_dns_rr_set_bin(ares_dns_rr_t *dns_rr, * \param[in] len Length of binary data * \return ARES_SUCCESS on success */ -CARES_EXTERN ares_status_t ares_dns_rr_add_abin(ares_dns_rr_t *dns_rr, - ares_dns_rr_key_t key, +CARES_EXTERN ares_status_t ares_dns_rr_add_abin(ares_dns_rr_t *dns_rr, + ares_dns_rr_key_t key, const unsigned char *val, - size_t len); + size_t len); /*! Delete binary array value (ABINP) data for specified resource record and * key by specified index. Can only be used on keys with datatype @@ -899,9 +899,9 @@ CARES_EXTERN ares_status_t ares_dns_rr_add_abin(ares_dns_rr_t *dns_rr, * \param[in] idx Index to delete * \return ARES_SUCCESS on success */ -CARES_EXTERN ares_status_t ares_dns_rr_del_abin(ares_dns_rr_t *dns_rr, +CARES_EXTERN ares_status_t ares_dns_rr_del_abin(ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key, - size_t idx); + size_t idx); /*! Set the option for the RR * @@ -918,6 +918,17 @@ CARES_EXTERN ares_status_t ares_dns_rr_set_opt(ares_dns_rr_t *dns_rr, const unsigned char *val, size_t val_len); +/*! Delete the option for the RR by id + * + * \param[in] dns_rr Pointer to resource record + * \param[in] key DNS Resource Record Key + * \param[in] opt Option record key id. + * \return ARES_SUCCESS if removed, ARES_ENOTFOUND if not found + */ +CARES_EXTERN ares_status_t ares_dns_rr_del_opt_byid(ares_dns_rr_t *dns_rr, + ares_dns_rr_key_t key, + unsigned short opt); + /*! Retrieve a pointer to the ipv4 address. Can only be used on keys with * datatype ARES_DATATYPE_INADDR. * @@ -1000,7 +1011,7 @@ CARES_EXTERN const unsigned char * * \return count of values */ CARES_EXTERN size_t ares_dns_rr_get_abin_cnt(const ares_dns_rr_t *dns_rr, - ares_dns_rr_key_t key); + ares_dns_rr_key_t key); /*! Retrieve a pointer to the binary array data from the specified index. Can * only be used on keys with datatype ARES_DATATYPE_ABINP. If ABINP, the data @@ -1014,8 +1025,9 @@ CARES_EXTERN size_t ares_dns_rr_get_abin_cnt(const ares_dns_rr_t *dns_rr, * \param[out] len Length of binary data returned * \return pointer binary data or NULL on error */ -CARES_EXTERN const unsigned char *ares_dns_rr_get_abin( - const ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key, size_t idx, size_t *len); +CARES_EXTERN const unsigned char * + ares_dns_rr_get_abin(const ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key, + size_t idx, size_t *len); /*! Retrieve the number of options stored for the RR. diff --git a/lib/c-ares-1.32.3/include/ares_nameser.h b/lib/c-ares-1.33.1/include/ares_nameser.h similarity index 100% rename from lib/c-ares-1.32.3/include/ares_nameser.h rename to lib/c-ares-1.33.1/include/ares_nameser.h diff --git a/lib/c-ares-1.32.3/include/ares_version.h b/lib/c-ares-1.33.1/include/ares_version.h similarity index 94% rename from lib/c-ares-1.32.3/include/ares_version.h rename to lib/c-ares-1.33.1/include/ares_version.h index 62541c31ba9..c910d79209a 100644 --- a/lib/c-ares-1.32.3/include/ares_version.h +++ b/lib/c-ares-1.33.1/include/ares_version.h @@ -31,12 +31,12 @@ #define ARES_COPYRIGHT "2004 - 2024 Daniel Stenberg, ." #define ARES_VERSION_MAJOR 1 -#define ARES_VERSION_MINOR 32 -#define ARES_VERSION_PATCH 3 +#define ARES_VERSION_MINOR 33 +#define ARES_VERSION_PATCH 1 #define ARES_VERSION \ ((ARES_VERSION_MAJOR << 16) | (ARES_VERSION_MINOR << 8) | \ (ARES_VERSION_PATCH)) -#define ARES_VERSION_STR "1.32.3" +#define ARES_VERSION_STR "1.33.1" #define CARES_HAVE_ARES_LIBRARY_INIT 1 #define CARES_HAVE_ARES_LIBRARY_CLEANUP 1 diff --git a/lib/c-ares-1.32.3/libcares.pc.cmake b/lib/c-ares-1.33.1/libcares.pc.cmake similarity index 78% rename from lib/c-ares-1.32.3/libcares.pc.cmake rename to lib/c-ares-1.33.1/libcares.pc.cmake index 74e4d0cf445..257255d84d5 100644 --- a/lib/c-ares-1.32.3/libcares.pc.cmake +++ b/lib/c-ares-1.33.1/libcares.pc.cmake @@ -7,9 +7,9 @@ # Copyright (C) The c-ares project and its contributors # SPDX-License-Identifier: MIT prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=@CMAKE_INSTALL_FULL_BINDIR@ -libdir=@CMAKE_INSTALL_FULL_LIBDIR@ -includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ +exec_prefix=${prefix}/@CMAKE_INSTALL_BINDIR@ +libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ Name: c-ares URL: https://c-ares.org/ @@ -18,5 +18,6 @@ Version: @CARES_VERSION@ Requires: Requires.private: Cflags: -I${includedir} +Cflags.private: -DCARES_STATICLIB Libs: -L${libdir} -lcares Libs.private: @CARES_PRIVATE_LIBS@ diff --git a/lib/c-ares-1.32.3/libcares.pc.in b/lib/c-ares-1.33.1/libcares.pc.in similarity index 100% rename from lib/c-ares-1.32.3/libcares.pc.in rename to lib/c-ares-1.33.1/libcares.pc.in diff --git a/lib/c-ares-1.32.3/m4/ax_ac_append_to_file.m4 b/lib/c-ares-1.33.1/m4/ax_ac_append_to_file.m4 similarity index 100% rename from lib/c-ares-1.32.3/m4/ax_ac_append_to_file.m4 rename to lib/c-ares-1.33.1/m4/ax_ac_append_to_file.m4 diff --git a/lib/c-ares-1.32.3/m4/ax_ac_print_to_file.m4 b/lib/c-ares-1.33.1/m4/ax_ac_print_to_file.m4 similarity index 100% rename from lib/c-ares-1.32.3/m4/ax_ac_print_to_file.m4 rename to lib/c-ares-1.33.1/m4/ax_ac_print_to_file.m4 diff --git a/lib/c-ares-1.32.3/m4/ax_add_am_macro_static.m4 b/lib/c-ares-1.33.1/m4/ax_add_am_macro_static.m4 similarity index 100% rename from lib/c-ares-1.32.3/m4/ax_add_am_macro_static.m4 rename to lib/c-ares-1.33.1/m4/ax_add_am_macro_static.m4 diff --git a/lib/c-ares-1.32.3/m4/ax_am_macros_static.m4 b/lib/c-ares-1.33.1/m4/ax_am_macros_static.m4 similarity index 100% rename from lib/c-ares-1.32.3/m4/ax_am_macros_static.m4 rename to lib/c-ares-1.33.1/m4/ax_am_macros_static.m4 diff --git a/lib/c-ares-1.32.3/m4/ax_append_compile_flags.m4 b/lib/c-ares-1.33.1/m4/ax_append_compile_flags.m4 similarity index 100% rename from lib/c-ares-1.32.3/m4/ax_append_compile_flags.m4 rename to lib/c-ares-1.33.1/m4/ax_append_compile_flags.m4 diff --git a/lib/c-ares-1.32.3/m4/ax_append_flag.m4 b/lib/c-ares-1.33.1/m4/ax_append_flag.m4 similarity index 100% rename from lib/c-ares-1.32.3/m4/ax_append_flag.m4 rename to lib/c-ares-1.33.1/m4/ax_append_flag.m4 diff --git a/lib/c-ares-1.32.3/m4/ax_append_link_flags.m4 b/lib/c-ares-1.33.1/m4/ax_append_link_flags.m4 similarity index 100% rename from lib/c-ares-1.32.3/m4/ax_append_link_flags.m4 rename to lib/c-ares-1.33.1/m4/ax_append_link_flags.m4 diff --git a/lib/c-ares-1.32.3/m4/ax_check_compile_flag.m4 b/lib/c-ares-1.33.1/m4/ax_check_compile_flag.m4 similarity index 100% rename from lib/c-ares-1.32.3/m4/ax_check_compile_flag.m4 rename to lib/c-ares-1.33.1/m4/ax_check_compile_flag.m4 diff --git a/lib/c-ares-1.32.3/m4/ax_check_gnu_make.m4 b/lib/c-ares-1.33.1/m4/ax_check_gnu_make.m4 similarity index 100% rename from lib/c-ares-1.32.3/m4/ax_check_gnu_make.m4 rename to lib/c-ares-1.33.1/m4/ax_check_gnu_make.m4 diff --git a/lib/c-ares-1.32.3/m4/ax_check_link_flag.m4 b/lib/c-ares-1.33.1/m4/ax_check_link_flag.m4 similarity index 100% rename from lib/c-ares-1.32.3/m4/ax_check_link_flag.m4 rename to lib/c-ares-1.33.1/m4/ax_check_link_flag.m4 diff --git a/lib/c-ares-1.32.3/m4/ax_check_user_namespace.m4 b/lib/c-ares-1.33.1/m4/ax_check_user_namespace.m4 similarity index 100% rename from lib/c-ares-1.32.3/m4/ax_check_user_namespace.m4 rename to lib/c-ares-1.33.1/m4/ax_check_user_namespace.m4 diff --git a/lib/c-ares-1.32.3/m4/ax_check_uts_namespace.m4 b/lib/c-ares-1.33.1/m4/ax_check_uts_namespace.m4 similarity index 100% rename from lib/c-ares-1.32.3/m4/ax_check_uts_namespace.m4 rename to lib/c-ares-1.33.1/m4/ax_check_uts_namespace.m4 diff --git a/lib/c-ares-1.32.3/m4/ax_code_coverage.m4 b/lib/c-ares-1.33.1/m4/ax_code_coverage.m4 similarity index 100% rename from lib/c-ares-1.32.3/m4/ax_code_coverage.m4 rename to lib/c-ares-1.33.1/m4/ax_code_coverage.m4 diff --git a/lib/c-ares-1.32.3/m4/ax_compiler_vendor.m4 b/lib/c-ares-1.33.1/m4/ax_compiler_vendor.m4 similarity index 100% rename from lib/c-ares-1.32.3/m4/ax_compiler_vendor.m4 rename to lib/c-ares-1.33.1/m4/ax_compiler_vendor.m4 diff --git a/lib/c-ares-1.32.3/m4/ax_cxx_compile_stdcxx.m4 b/lib/c-ares-1.33.1/m4/ax_cxx_compile_stdcxx.m4 similarity index 100% rename from lib/c-ares-1.32.3/m4/ax_cxx_compile_stdcxx.m4 rename to lib/c-ares-1.33.1/m4/ax_cxx_compile_stdcxx.m4 diff --git a/lib/c-ares-1.32.3/m4/ax_cxx_compile_stdcxx_14.m4 b/lib/c-ares-1.33.1/m4/ax_cxx_compile_stdcxx_14.m4 similarity index 100% rename from lib/c-ares-1.32.3/m4/ax_cxx_compile_stdcxx_14.m4 rename to lib/c-ares-1.33.1/m4/ax_cxx_compile_stdcxx_14.m4 diff --git a/lib/c-ares-1.32.3/m4/ax_file_escapes.m4 b/lib/c-ares-1.33.1/m4/ax_file_escapes.m4 similarity index 100% rename from lib/c-ares-1.32.3/m4/ax_file_escapes.m4 rename to lib/c-ares-1.33.1/m4/ax_file_escapes.m4 diff --git a/lib/c-ares-1.32.3/m4/ax_pthread.m4 b/lib/c-ares-1.33.1/m4/ax_pthread.m4 similarity index 100% rename from lib/c-ares-1.32.3/m4/ax_pthread.m4 rename to lib/c-ares-1.33.1/m4/ax_pthread.m4 diff --git a/lib/c-ares-1.32.3/m4/ax_require_defined.m4 b/lib/c-ares-1.33.1/m4/ax_require_defined.m4 similarity index 100% rename from lib/c-ares-1.32.3/m4/ax_require_defined.m4 rename to lib/c-ares-1.33.1/m4/ax_require_defined.m4 diff --git a/lib/c-ares-1.32.3/m4/libtool.m4 b/lib/c-ares-1.33.1/m4/libtool.m4 similarity index 100% rename from lib/c-ares-1.32.3/m4/libtool.m4 rename to lib/c-ares-1.33.1/m4/libtool.m4 diff --git a/lib/c-ares-1.32.3/m4/ltoptions.m4 b/lib/c-ares-1.33.1/m4/ltoptions.m4 similarity index 100% rename from lib/c-ares-1.32.3/m4/ltoptions.m4 rename to lib/c-ares-1.33.1/m4/ltoptions.m4 diff --git a/lib/c-ares-1.32.3/m4/ltsugar.m4 b/lib/c-ares-1.33.1/m4/ltsugar.m4 similarity index 100% rename from lib/c-ares-1.32.3/m4/ltsugar.m4 rename to lib/c-ares-1.33.1/m4/ltsugar.m4 diff --git a/lib/c-ares-1.32.3/m4/ltversion.m4 b/lib/c-ares-1.33.1/m4/ltversion.m4 similarity index 100% rename from lib/c-ares-1.32.3/m4/ltversion.m4 rename to lib/c-ares-1.33.1/m4/ltversion.m4 diff --git a/lib/c-ares-1.32.3/m4/lt~obsolete.m4 b/lib/c-ares-1.33.1/m4/lt~obsolete.m4 similarity index 100% rename from lib/c-ares-1.32.3/m4/lt~obsolete.m4 rename to lib/c-ares-1.33.1/m4/lt~obsolete.m4 diff --git a/lib/c-ares-1.32.3/m4/pkg.m4 b/lib/c-ares-1.33.1/m4/pkg.m4 similarity index 100% rename from lib/c-ares-1.32.3/m4/pkg.m4 rename to lib/c-ares-1.33.1/m4/pkg.m4 diff --git a/lib/c-ares-1.32.3/src/CMakeLists.txt b/lib/c-ares-1.33.1/src/CMakeLists.txt similarity index 100% rename from lib/c-ares-1.32.3/src/CMakeLists.txt rename to lib/c-ares-1.33.1/src/CMakeLists.txt diff --git a/lib/c-ares-1.32.3/src/Makefile.am b/lib/c-ares-1.33.1/src/Makefile.am similarity index 100% rename from lib/c-ares-1.32.3/src/Makefile.am rename to lib/c-ares-1.33.1/src/Makefile.am diff --git a/lib/c-ares-1.32.3/src/Makefile.in b/lib/c-ares-1.33.1/src/Makefile.in similarity index 97% rename from lib/c-ares-1.32.3/src/Makefile.in rename to lib/c-ares-1.33.1/src/Makefile.in index f657ef0d43e..3ad8a92a6a4 100644 --- a/lib/c-ares-1.32.3/src/Makefile.in +++ b/lib/c-ares-1.33.1/src/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.5 from Makefile.am. +# Makefile.in generated by automake 1.17 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2021 Free Software Foundation, Inc. +# Copyright (C) 1994-2024 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -69,6 +69,8 @@ am__make_running_with_option = \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +am__rm_f = rm -f $(am__rm_f_notfound) +am__rm_rf = rm -rf $(am__rm_f_notfound) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -248,6 +250,8 @@ FGREP = @FGREP@ FILECMD = @FILECMD@ GCOV = @GCOV@ GENHTML = @GENHTML@ +GMOCK112_CFLAGS = @GMOCK112_CFLAGS@ +GMOCK112_LIBS = @GMOCK112_LIBS@ GMOCK_CFLAGS = @GMOCK_CFLAGS@ GMOCK_LIBS = @GMOCK_LIBS@ GREP = @GREP@ @@ -310,8 +314,10 @@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ +am__rm_f_notfound = @am__rm_f_notfound@ am__tar = @am__tar@ am__untar = @am__untar@ +am__xargs_n = @am__xargs_n@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ @@ -585,8 +591,8 @@ mostlyclean-generic: clean-generic: distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -$(am__rm_f) $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || $(am__rm_f) $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @@ -678,3 +684,10 @@ uninstall-am: # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: + +# Tell GNU make to disable its built-in pattern rules. +%:: %,v +%:: RCS/%,v +%:: RCS/% +%:: s.% +%:: SCCS/s.% diff --git a/lib/c-ares-1.32.3/src/lib/CMakeLists.txt b/lib/c-ares-1.33.1/src/lib/CMakeLists.txt similarity index 100% rename from lib/c-ares-1.32.3/src/lib/CMakeLists.txt rename to lib/c-ares-1.33.1/src/lib/CMakeLists.txt diff --git a/lib/c-ares-1.32.3/src/lib/Makefile.am b/lib/c-ares-1.33.1/src/lib/Makefile.am similarity index 100% rename from lib/c-ares-1.32.3/src/lib/Makefile.am rename to lib/c-ares-1.33.1/src/lib/Makefile.am diff --git a/lib/c-ares-1.32.3/src/lib/Makefile.in b/lib/c-ares-1.33.1/src/lib/Makefile.in similarity index 65% rename from lib/c-ares-1.32.3/src/lib/Makefile.in rename to lib/c-ares-1.33.1/src/lib/Makefile.in index d1758eb8adb..30d33843d5d 100644 --- a/lib/c-ares-1.32.3/src/lib/Makefile.in +++ b/lib/c-ares-1.33.1/src/lib/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.5 from Makefile.am. +# Makefile.in generated by automake 1.17 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2021 Free Software Foundation, Inc. +# Copyright (C) 1994-2024 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -15,7 +15,7 @@ @SET_MAKE@ # aminclude_static.am generated automatically by Autoconf -# from AX_AM_MACROS_STATIC on Wed Jul 24 05:40:58 EDT 2024 +# from AX_AM_MACROS_STATIC on Fri Aug 23 09:37:25 EDT 2024 # Copyright (C) The c-ares project and its contributors # SPDX-License-Identifier: MIT @@ -76,6 +76,8 @@ am__make_running_with_option = \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +am__rm_f = rm -f $(am__rm_f_notfound) +am__rm_rf = rm -rf $(am__rm_f_notfound) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -152,75 +154,84 @@ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ + { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && echo $$files | $(am__xargs_n) 40 $(am__rm_f); }; \ } am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) libcares_la_LIBADD = +am__dirstamp = $(am__leading_dot)dirstamp am__objects_1 = libcares_la-ares__addrinfo2hostent.lo \ libcares_la-ares__addrinfo_localhost.lo \ - libcares_la-ares__buf.lo libcares_la-ares__close_sockets.lo \ - libcares_la-ares__hosts_file.lo libcares_la-ares__htable.lo \ - libcares_la-ares__htable_asvp.lo \ - libcares_la-ares__htable_strvp.lo \ - libcares_la-ares__htable_szvp.lo \ - libcares_la-ares__htable_vpvp.lo \ - libcares_la-ares__iface_ips.lo libcares_la-ares__llist.lo \ + libcares_la-ares__close_sockets.lo \ + libcares_la-ares__hosts_file.lo \ libcares_la-ares__parse_into_addrinfo.lo \ - libcares_la-ares__slist.lo libcares_la-ares__socket.lo \ - libcares_la-ares__sortaddrinfo.lo libcares_la-ares__threads.lo \ - libcares_la-ares__timeval.lo libcares_la-ares_android.lo \ - libcares_la-ares_cancel.lo libcares_la-ares_data.lo \ - libcares_la-ares_destroy.lo libcares_la-ares_dns_mapping.lo \ - libcares_la-ares_dns_multistring.lo \ - libcares_la-ares_dns_name.lo libcares_la-ares_dns_parse.lo \ - libcares_la-ares_dns_record.lo libcares_la-ares_dns_write.lo \ - libcares_la-ares_event_configchg.lo \ - libcares_la-ares_event_epoll.lo \ - libcares_la-ares_event_kqueue.lo \ - libcares_la-ares_event_poll.lo \ - libcares_la-ares_event_select.lo \ - libcares_la-ares_event_thread.lo \ - libcares_la-ares_event_wake_pipe.lo \ - libcares_la-ares_event_win32.lo \ - libcares_la-ares_expand_name.lo \ - libcares_la-ares_expand_string.lo libcares_la-ares_fds.lo \ - libcares_la-ares_free_hostent.lo \ + libcares_la-ares__socket.lo libcares_la-ares__sortaddrinfo.lo \ + libcares_la-ares_android.lo libcares_la-ares_cancel.lo \ + libcares_la-ares_cookie.lo libcares_la-ares_data.lo \ + libcares_la-ares_destroy.lo libcares_la-ares_free_hostent.lo \ libcares_la-ares_free_string.lo \ libcares_la-ares_freeaddrinfo.lo \ libcares_la-ares_getaddrinfo.lo libcares_la-ares_getenv.lo \ libcares_la-ares_gethostbyaddr.lo \ libcares_la-ares_gethostbyname.lo \ - libcares_la-ares_getnameinfo.lo libcares_la-ares_getsock.lo \ - libcares_la-ares_init.lo libcares_la-ares_library_init.lo \ - libcares_la-ares_math.lo libcares_la-ares_metrics.lo \ - libcares_la-ares_create_query.lo libcares_la-ares_options.lo \ - libcares_la-ares_parse_a_reply.lo \ - libcares_la-ares_parse_aaaa_reply.lo \ - libcares_la-ares_parse_caa_reply.lo \ - libcares_la-ares_parse_mx_reply.lo \ - libcares_la-ares_parse_naptr_reply.lo \ - libcares_la-ares_parse_ns_reply.lo \ - libcares_la-ares_parse_ptr_reply.lo \ - libcares_la-ares_parse_soa_reply.lo \ - libcares_la-ares_parse_srv_reply.lo \ - libcares_la-ares_parse_txt_reply.lo \ - libcares_la-ares_parse_uri_reply.lo \ - libcares_la-ares_platform.lo libcares_la-ares_process.lo \ - libcares_la-ares_qcache.lo libcares_la-ares_query.lo \ - libcares_la-ares_rand.lo libcares_la-ares_search.lo \ - libcares_la-ares_send.lo libcares_la-ares_strcasecmp.lo \ - libcares_la-ares_str.lo libcares_la-ares_strerror.lo \ - libcares_la-ares_strsplit.lo libcares_la-ares_sysconfig.lo \ + libcares_la-ares_getnameinfo.lo libcares_la-ares_init.lo \ + libcares_la-ares_library_init.lo libcares_la-ares_metrics.lo \ + libcares_la-ares_options.lo libcares_la-ares_platform.lo \ + libcares_la-ares_process.lo libcares_la-ares_qcache.lo \ + libcares_la-ares_query.lo libcares_la-ares_search.lo \ + libcares_la-ares_send.lo libcares_la-ares_strerror.lo \ + libcares_la-ares_sysconfig.lo \ libcares_la-ares_sysconfig_files.lo \ libcares_la-ares_sysconfig_mac.lo \ libcares_la-ares_sysconfig_win.lo libcares_la-ares_timeout.lo \ libcares_la-ares_update_servers.lo libcares_la-ares_version.lo \ libcares_la-inet_net_pton.lo libcares_la-inet_ntop.lo \ - libcares_la-windows_port.lo + libcares_la-windows_port.lo dsa/libcares_la-ares__array.lo \ + dsa/libcares_la-ares__htable.lo \ + dsa/libcares_la-ares__htable_asvp.lo \ + dsa/libcares_la-ares__htable_strvp.lo \ + dsa/libcares_la-ares__htable_szvp.lo \ + dsa/libcares_la-ares__htable_vpvp.lo \ + dsa/libcares_la-ares__llist.lo dsa/libcares_la-ares__slist.lo \ + event/libcares_la-ares_event_configchg.lo \ + event/libcares_la-ares_event_epoll.lo \ + event/libcares_la-ares_event_kqueue.lo \ + event/libcares_la-ares_event_poll.lo \ + event/libcares_la-ares_event_select.lo \ + event/libcares_la-ares_event_thread.lo \ + event/libcares_la-ares_event_wake_pipe.lo \ + event/libcares_la-ares_event_win32.lo \ + legacy/libcares_la-ares_create_query.lo \ + legacy/libcares_la-ares_expand_name.lo \ + legacy/libcares_la-ares_expand_string.lo \ + legacy/libcares_la-ares_fds.lo \ + legacy/libcares_la-ares_getsock.lo \ + legacy/libcares_la-ares_parse_a_reply.lo \ + legacy/libcares_la-ares_parse_aaaa_reply.lo \ + legacy/libcares_la-ares_parse_caa_reply.lo \ + legacy/libcares_la-ares_parse_mx_reply.lo \ + legacy/libcares_la-ares_parse_naptr_reply.lo \ + legacy/libcares_la-ares_parse_ns_reply.lo \ + legacy/libcares_la-ares_parse_ptr_reply.lo \ + legacy/libcares_la-ares_parse_soa_reply.lo \ + legacy/libcares_la-ares_parse_srv_reply.lo \ + legacy/libcares_la-ares_parse_txt_reply.lo \ + legacy/libcares_la-ares_parse_uri_reply.lo \ + record/libcares_la-ares_dns_mapping.lo \ + record/libcares_la-ares_dns_multistring.lo \ + record/libcares_la-ares_dns_name.lo \ + record/libcares_la-ares_dns_parse.lo \ + record/libcares_la-ares_dns_record.lo \ + record/libcares_la-ares_dns_write.lo \ + str/libcares_la-ares__buf.lo \ + str/libcares_la-ares_strcasecmp.lo str/libcares_la-ares_str.lo \ + str/libcares_la-ares_strsplit.lo \ + util/libcares_la-ares__iface_ips.lo \ + util/libcares_la-ares__threads.lo \ + util/libcares_la-ares__timeval.lo \ + util/libcares_la-ares_math.lo util/libcares_la-ares_rand.lo am__objects_2 = am_libcares_la_OBJECTS = $(am__objects_1) $(am__objects_2) libcares_la_OBJECTS = $(am_libcares_la_OBJECTS) @@ -249,44 +260,16 @@ am__maybe_remake_depfiles = depfiles am__depfiles_remade = \ ./$(DEPDIR)/libcares_la-ares__addrinfo2hostent.Plo \ ./$(DEPDIR)/libcares_la-ares__addrinfo_localhost.Plo \ - ./$(DEPDIR)/libcares_la-ares__buf.Plo \ ./$(DEPDIR)/libcares_la-ares__close_sockets.Plo \ ./$(DEPDIR)/libcares_la-ares__hosts_file.Plo \ - ./$(DEPDIR)/libcares_la-ares__htable.Plo \ - ./$(DEPDIR)/libcares_la-ares__htable_asvp.Plo \ - ./$(DEPDIR)/libcares_la-ares__htable_strvp.Plo \ - ./$(DEPDIR)/libcares_la-ares__htable_szvp.Plo \ - ./$(DEPDIR)/libcares_la-ares__htable_vpvp.Plo \ - ./$(DEPDIR)/libcares_la-ares__iface_ips.Plo \ - ./$(DEPDIR)/libcares_la-ares__llist.Plo \ ./$(DEPDIR)/libcares_la-ares__parse_into_addrinfo.Plo \ - ./$(DEPDIR)/libcares_la-ares__slist.Plo \ ./$(DEPDIR)/libcares_la-ares__socket.Plo \ ./$(DEPDIR)/libcares_la-ares__sortaddrinfo.Plo \ - ./$(DEPDIR)/libcares_la-ares__threads.Plo \ - ./$(DEPDIR)/libcares_la-ares__timeval.Plo \ ./$(DEPDIR)/libcares_la-ares_android.Plo \ ./$(DEPDIR)/libcares_la-ares_cancel.Plo \ - ./$(DEPDIR)/libcares_la-ares_create_query.Plo \ + ./$(DEPDIR)/libcares_la-ares_cookie.Plo \ ./$(DEPDIR)/libcares_la-ares_data.Plo \ ./$(DEPDIR)/libcares_la-ares_destroy.Plo \ - ./$(DEPDIR)/libcares_la-ares_dns_mapping.Plo \ - ./$(DEPDIR)/libcares_la-ares_dns_multistring.Plo \ - ./$(DEPDIR)/libcares_la-ares_dns_name.Plo \ - ./$(DEPDIR)/libcares_la-ares_dns_parse.Plo \ - ./$(DEPDIR)/libcares_la-ares_dns_record.Plo \ - ./$(DEPDIR)/libcares_la-ares_dns_write.Plo \ - ./$(DEPDIR)/libcares_la-ares_event_configchg.Plo \ - ./$(DEPDIR)/libcares_la-ares_event_epoll.Plo \ - ./$(DEPDIR)/libcares_la-ares_event_kqueue.Plo \ - ./$(DEPDIR)/libcares_la-ares_event_poll.Plo \ - ./$(DEPDIR)/libcares_la-ares_event_select.Plo \ - ./$(DEPDIR)/libcares_la-ares_event_thread.Plo \ - ./$(DEPDIR)/libcares_la-ares_event_wake_pipe.Plo \ - ./$(DEPDIR)/libcares_la-ares_event_win32.Plo \ - ./$(DEPDIR)/libcares_la-ares_expand_name.Plo \ - ./$(DEPDIR)/libcares_la-ares_expand_string.Plo \ - ./$(DEPDIR)/libcares_la-ares_fds.Plo \ ./$(DEPDIR)/libcares_la-ares_free_hostent.Plo \ ./$(DEPDIR)/libcares_la-ares_free_string.Plo \ ./$(DEPDIR)/libcares_la-ares_freeaddrinfo.Plo \ @@ -295,34 +278,17 @@ am__depfiles_remade = \ ./$(DEPDIR)/libcares_la-ares_gethostbyaddr.Plo \ ./$(DEPDIR)/libcares_la-ares_gethostbyname.Plo \ ./$(DEPDIR)/libcares_la-ares_getnameinfo.Plo \ - ./$(DEPDIR)/libcares_la-ares_getsock.Plo \ ./$(DEPDIR)/libcares_la-ares_init.Plo \ ./$(DEPDIR)/libcares_la-ares_library_init.Plo \ - ./$(DEPDIR)/libcares_la-ares_math.Plo \ ./$(DEPDIR)/libcares_la-ares_metrics.Plo \ ./$(DEPDIR)/libcares_la-ares_options.Plo \ - ./$(DEPDIR)/libcares_la-ares_parse_a_reply.Plo \ - ./$(DEPDIR)/libcares_la-ares_parse_aaaa_reply.Plo \ - ./$(DEPDIR)/libcares_la-ares_parse_caa_reply.Plo \ - ./$(DEPDIR)/libcares_la-ares_parse_mx_reply.Plo \ - ./$(DEPDIR)/libcares_la-ares_parse_naptr_reply.Plo \ - ./$(DEPDIR)/libcares_la-ares_parse_ns_reply.Plo \ - ./$(DEPDIR)/libcares_la-ares_parse_ptr_reply.Plo \ - ./$(DEPDIR)/libcares_la-ares_parse_soa_reply.Plo \ - ./$(DEPDIR)/libcares_la-ares_parse_srv_reply.Plo \ - ./$(DEPDIR)/libcares_la-ares_parse_txt_reply.Plo \ - ./$(DEPDIR)/libcares_la-ares_parse_uri_reply.Plo \ ./$(DEPDIR)/libcares_la-ares_platform.Plo \ ./$(DEPDIR)/libcares_la-ares_process.Plo \ ./$(DEPDIR)/libcares_la-ares_qcache.Plo \ ./$(DEPDIR)/libcares_la-ares_query.Plo \ - ./$(DEPDIR)/libcares_la-ares_rand.Plo \ ./$(DEPDIR)/libcares_la-ares_search.Plo \ ./$(DEPDIR)/libcares_la-ares_send.Plo \ - ./$(DEPDIR)/libcares_la-ares_str.Plo \ - ./$(DEPDIR)/libcares_la-ares_strcasecmp.Plo \ ./$(DEPDIR)/libcares_la-ares_strerror.Plo \ - ./$(DEPDIR)/libcares_la-ares_strsplit.Plo \ ./$(DEPDIR)/libcares_la-ares_sysconfig.Plo \ ./$(DEPDIR)/libcares_la-ares_sysconfig_files.Plo \ ./$(DEPDIR)/libcares_la-ares_sysconfig_mac.Plo \ @@ -332,7 +298,54 @@ am__depfiles_remade = \ ./$(DEPDIR)/libcares_la-ares_version.Plo \ ./$(DEPDIR)/libcares_la-inet_net_pton.Plo \ ./$(DEPDIR)/libcares_la-inet_ntop.Plo \ - ./$(DEPDIR)/libcares_la-windows_port.Plo + ./$(DEPDIR)/libcares_la-windows_port.Plo \ + dsa/$(DEPDIR)/libcares_la-ares__array.Plo \ + dsa/$(DEPDIR)/libcares_la-ares__htable.Plo \ + dsa/$(DEPDIR)/libcares_la-ares__htable_asvp.Plo \ + dsa/$(DEPDIR)/libcares_la-ares__htable_strvp.Plo \ + dsa/$(DEPDIR)/libcares_la-ares__htable_szvp.Plo \ + dsa/$(DEPDIR)/libcares_la-ares__htable_vpvp.Plo \ + dsa/$(DEPDIR)/libcares_la-ares__llist.Plo \ + dsa/$(DEPDIR)/libcares_la-ares__slist.Plo \ + event/$(DEPDIR)/libcares_la-ares_event_configchg.Plo \ + event/$(DEPDIR)/libcares_la-ares_event_epoll.Plo \ + event/$(DEPDIR)/libcares_la-ares_event_kqueue.Plo \ + event/$(DEPDIR)/libcares_la-ares_event_poll.Plo \ + event/$(DEPDIR)/libcares_la-ares_event_select.Plo \ + event/$(DEPDIR)/libcares_la-ares_event_thread.Plo \ + event/$(DEPDIR)/libcares_la-ares_event_wake_pipe.Plo \ + event/$(DEPDIR)/libcares_la-ares_event_win32.Plo \ + legacy/$(DEPDIR)/libcares_la-ares_create_query.Plo \ + legacy/$(DEPDIR)/libcares_la-ares_expand_name.Plo \ + legacy/$(DEPDIR)/libcares_la-ares_expand_string.Plo \ + legacy/$(DEPDIR)/libcares_la-ares_fds.Plo \ + legacy/$(DEPDIR)/libcares_la-ares_getsock.Plo \ + legacy/$(DEPDIR)/libcares_la-ares_parse_a_reply.Plo \ + legacy/$(DEPDIR)/libcares_la-ares_parse_aaaa_reply.Plo \ + legacy/$(DEPDIR)/libcares_la-ares_parse_caa_reply.Plo \ + legacy/$(DEPDIR)/libcares_la-ares_parse_mx_reply.Plo \ + legacy/$(DEPDIR)/libcares_la-ares_parse_naptr_reply.Plo \ + legacy/$(DEPDIR)/libcares_la-ares_parse_ns_reply.Plo \ + legacy/$(DEPDIR)/libcares_la-ares_parse_ptr_reply.Plo \ + legacy/$(DEPDIR)/libcares_la-ares_parse_soa_reply.Plo \ + legacy/$(DEPDIR)/libcares_la-ares_parse_srv_reply.Plo \ + legacy/$(DEPDIR)/libcares_la-ares_parse_txt_reply.Plo \ + legacy/$(DEPDIR)/libcares_la-ares_parse_uri_reply.Plo \ + record/$(DEPDIR)/libcares_la-ares_dns_mapping.Plo \ + record/$(DEPDIR)/libcares_la-ares_dns_multistring.Plo \ + record/$(DEPDIR)/libcares_la-ares_dns_name.Plo \ + record/$(DEPDIR)/libcares_la-ares_dns_parse.Plo \ + record/$(DEPDIR)/libcares_la-ares_dns_record.Plo \ + record/$(DEPDIR)/libcares_la-ares_dns_write.Plo \ + str/$(DEPDIR)/libcares_la-ares__buf.Plo \ + str/$(DEPDIR)/libcares_la-ares_str.Plo \ + str/$(DEPDIR)/libcares_la-ares_strcasecmp.Plo \ + str/$(DEPDIR)/libcares_la-ares_strsplit.Plo \ + util/$(DEPDIR)/libcares_la-ares__iface_ips.Plo \ + util/$(DEPDIR)/libcares_la-ares__threads.Plo \ + util/$(DEPDIR)/libcares_la-ares__timeval.Plo \ + util/$(DEPDIR)/libcares_la-ares_math.Plo \ + util/$(DEPDIR)/libcares_la-ares_rand.Plo am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -477,6 +490,8 @@ FGREP = @FGREP@ FILECMD = @FILECMD@ GCOV = @GCOV@ GENHTML = @GENHTML@ +GMOCK112_CFLAGS = @GMOCK112_CFLAGS@ +GMOCK112_LIBS = @GMOCK112_LIBS@ GMOCK_CFLAGS = @GMOCK_CFLAGS@ GMOCK_LIBS = @GMOCK_LIBS@ GREP = @GREP@ @@ -539,8 +554,10 @@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ +am__rm_f_notfound = @am__rm_f_notfound@ am__tar = @am__tar@ am__untar = @am__untar@ +am__xargs_n = @am__xargs_n@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ @@ -628,43 +645,16 @@ libcares_la_CFLAGS = $(AM_CFLAGS) $(libcares_la_CFLAGS_EXTRA) libcares_la_CPPFLAGS = $(AM_CPPFLAGS) $(libcares_la_CPPFLAGS_EXTRA) CSOURCES = ares__addrinfo2hostent.c \ ares__addrinfo_localhost.c \ - ares__buf.c \ ares__close_sockets.c \ ares__hosts_file.c \ - ares__htable.c \ - ares__htable_asvp.c \ - ares__htable_strvp.c \ - ares__htable_szvp.c \ - ares__htable_vpvp.c \ - ares__iface_ips.c \ - ares__llist.c \ ares__parse_into_addrinfo.c \ - ares__slist.c \ ares__socket.c \ ares__sortaddrinfo.c \ - ares__threads.c \ - ares__timeval.c \ ares_android.c \ ares_cancel.c \ + ares_cookie.c \ ares_data.c \ ares_destroy.c \ - ares_dns_mapping.c \ - ares_dns_multistring.c \ - ares_dns_name.c \ - ares_dns_parse.c \ - ares_dns_record.c \ - ares_dns_write.c \ - ares_event_configchg.c \ - ares_event_epoll.c \ - ares_event_kqueue.c \ - ares_event_poll.c \ - ares_event_select.c \ - ares_event_thread.c \ - ares_event_wake_pipe.c \ - ares_event_win32.c \ - ares_expand_name.c \ - ares_expand_string.c \ - ares_fds.c \ ares_free_hostent.c \ ares_free_string.c \ ares_freeaddrinfo.c \ @@ -673,35 +663,17 @@ CSOURCES = ares__addrinfo2hostent.c \ ares_gethostbyaddr.c \ ares_gethostbyname.c \ ares_getnameinfo.c \ - ares_getsock.c \ ares_init.c \ ares_library_init.c \ - ares_math.c \ ares_metrics.c \ - ares_create_query.c \ ares_options.c \ - ares_parse_a_reply.c \ - ares_parse_aaaa_reply.c \ - ares_parse_caa_reply.c \ - ares_parse_mx_reply.c \ - ares_parse_naptr_reply.c \ - ares_parse_ns_reply.c \ - ares_parse_ptr_reply.c \ - ares_parse_soa_reply.c \ - ares_parse_srv_reply.c \ - ares_parse_txt_reply.c \ - ares_parse_uri_reply.c \ ares_platform.c \ ares_process.c \ ares_qcache.c \ ares_query.c \ - ares_rand.c \ ares_search.c \ ares_send.c \ - ares_strcasecmp.c \ - ares_str.c \ ares_strerror.c \ - ares_strsplit.c \ ares_sysconfig.c \ ares_sysconfig_files.c \ ares_sysconfig_mac.c \ @@ -711,33 +683,81 @@ CSOURCES = ares__addrinfo2hostent.c \ ares_version.c \ inet_net_pton.c \ inet_ntop.c \ - windows_port.c - -HHEADERS = ares__buf.h \ - ares__htable.h \ - ares__htable_asvp.h \ - ares__htable_strvp.h \ - ares__htable_szvp.h \ - ares__htable_vpvp.h \ - ares__iface_ips.h \ - ares__llist.h \ - ares__slist.h \ - ares__threads.h \ - ares_android.h \ + windows_port.c \ + dsa/ares__array.c \ + dsa/ares__htable.c \ + dsa/ares__htable_asvp.c \ + dsa/ares__htable_strvp.c \ + dsa/ares__htable_szvp.c \ + dsa/ares__htable_vpvp.c \ + dsa/ares__llist.c \ + dsa/ares__slist.c \ + event/ares_event_configchg.c \ + event/ares_event_epoll.c \ + event/ares_event_kqueue.c \ + event/ares_event_poll.c \ + event/ares_event_select.c \ + event/ares_event_thread.c \ + event/ares_event_wake_pipe.c \ + event/ares_event_win32.c \ + legacy/ares_create_query.c \ + legacy/ares_expand_name.c \ + legacy/ares_expand_string.c \ + legacy/ares_fds.c \ + legacy/ares_getsock.c \ + legacy/ares_parse_a_reply.c \ + legacy/ares_parse_aaaa_reply.c \ + legacy/ares_parse_caa_reply.c \ + legacy/ares_parse_mx_reply.c \ + legacy/ares_parse_naptr_reply.c \ + legacy/ares_parse_ns_reply.c \ + legacy/ares_parse_ptr_reply.c \ + legacy/ares_parse_soa_reply.c \ + legacy/ares_parse_srv_reply.c \ + legacy/ares_parse_txt_reply.c \ + legacy/ares_parse_uri_reply.c \ + record/ares_dns_mapping.c \ + record/ares_dns_multistring.c \ + record/ares_dns_name.c \ + record/ares_dns_parse.c \ + record/ares_dns_record.c \ + record/ares_dns_write.c \ + str/ares__buf.c \ + str/ares_strcasecmp.c \ + str/ares_str.c \ + str/ares_strsplit.c \ + util/ares__iface_ips.c \ + util/ares__threads.c \ + util/ares__timeval.c \ + util/ares_math.c \ + util/ares_rand.c + +HHEADERS = ares_android.h \ ares_data.h \ - ares_dns_multistring.h \ - ares_dns_private.h \ - ares_event.h \ - ares_event_win32.h \ ares_getenv.h \ ares_inet_net_pton.h \ ares_ipv6.h \ ares_platform.h \ ares_private.h \ - ares_strcasecmp.h \ - ares_str.h \ - ares_strsplit.h \ ares_setup.h \ + dsa/ares__array.h \ + dsa/ares__htable.h \ + dsa/ares__htable_asvp.h \ + dsa/ares__htable_strvp.h \ + dsa/ares__htable_szvp.h \ + dsa/ares__htable_vpvp.h \ + dsa/ares__llist.h \ + dsa/ares__slist.h \ + event/ares_event.h \ + event/ares_event_win32.h \ + record/ares_dns_multistring.h \ + record/ares_dns_private.h \ + str/ares__buf.h \ + str/ares_strcasecmp.h \ + str/ares_str.h \ + str/ares_strsplit.h \ + util/ares__iface_ips.h \ + util/ares__threads.h \ thirdparty/apple/dnsinfo.h @@ -784,12 +804,12 @@ ares_config.h: stamp-h1 @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 stamp-h1: $(srcdir)/ares_config.h.in $(top_builddir)/config.status - @rm -f stamp-h1 - cd $(top_builddir) && $(SHELL) ./config.status src/lib/ares_config.h + $(AM_V_at)rm -f stamp-h1 + $(AM_V_GEN)cd $(top_builddir) && $(SHELL) ./config.status src/lib/ares_config.h $(srcdir)/ares_config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) - rm -f stamp-h1 - touch $@ + $(AM_V_GEN)($(am__cd) $(top_srcdir) && $(AUTOHEADER)) + $(AM_V_at)rm -f stamp-h1 + $(AM_V_at)touch $@ distclean-hdr: -rm -f ares_config.h stamp-h1 @@ -819,65 +839,177 @@ uninstall-libLTLIBRARIES: done clean-libLTLIBRARIES: - -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + -$(am__rm_f) $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } + echo rm -f $${locs}; \ + $(am__rm_f) $${locs} +dsa/$(am__dirstamp): + @$(MKDIR_P) dsa + @: >>dsa/$(am__dirstamp) +dsa/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) dsa/$(DEPDIR) + @: >>dsa/$(DEPDIR)/$(am__dirstamp) +dsa/libcares_la-ares__array.lo: dsa/$(am__dirstamp) \ + dsa/$(DEPDIR)/$(am__dirstamp) +dsa/libcares_la-ares__htable.lo: dsa/$(am__dirstamp) \ + dsa/$(DEPDIR)/$(am__dirstamp) +dsa/libcares_la-ares__htable_asvp.lo: dsa/$(am__dirstamp) \ + dsa/$(DEPDIR)/$(am__dirstamp) +dsa/libcares_la-ares__htable_strvp.lo: dsa/$(am__dirstamp) \ + dsa/$(DEPDIR)/$(am__dirstamp) +dsa/libcares_la-ares__htable_szvp.lo: dsa/$(am__dirstamp) \ + dsa/$(DEPDIR)/$(am__dirstamp) +dsa/libcares_la-ares__htable_vpvp.lo: dsa/$(am__dirstamp) \ + dsa/$(DEPDIR)/$(am__dirstamp) +dsa/libcares_la-ares__llist.lo: dsa/$(am__dirstamp) \ + dsa/$(DEPDIR)/$(am__dirstamp) +dsa/libcares_la-ares__slist.lo: dsa/$(am__dirstamp) \ + dsa/$(DEPDIR)/$(am__dirstamp) +event/$(am__dirstamp): + @$(MKDIR_P) event + @: >>event/$(am__dirstamp) +event/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) event/$(DEPDIR) + @: >>event/$(DEPDIR)/$(am__dirstamp) +event/libcares_la-ares_event_configchg.lo: event/$(am__dirstamp) \ + event/$(DEPDIR)/$(am__dirstamp) +event/libcares_la-ares_event_epoll.lo: event/$(am__dirstamp) \ + event/$(DEPDIR)/$(am__dirstamp) +event/libcares_la-ares_event_kqueue.lo: event/$(am__dirstamp) \ + event/$(DEPDIR)/$(am__dirstamp) +event/libcares_la-ares_event_poll.lo: event/$(am__dirstamp) \ + event/$(DEPDIR)/$(am__dirstamp) +event/libcares_la-ares_event_select.lo: event/$(am__dirstamp) \ + event/$(DEPDIR)/$(am__dirstamp) +event/libcares_la-ares_event_thread.lo: event/$(am__dirstamp) \ + event/$(DEPDIR)/$(am__dirstamp) +event/libcares_la-ares_event_wake_pipe.lo: event/$(am__dirstamp) \ + event/$(DEPDIR)/$(am__dirstamp) +event/libcares_la-ares_event_win32.lo: event/$(am__dirstamp) \ + event/$(DEPDIR)/$(am__dirstamp) +legacy/$(am__dirstamp): + @$(MKDIR_P) legacy + @: >>legacy/$(am__dirstamp) +legacy/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) legacy/$(DEPDIR) + @: >>legacy/$(DEPDIR)/$(am__dirstamp) +legacy/libcares_la-ares_create_query.lo: legacy/$(am__dirstamp) \ + legacy/$(DEPDIR)/$(am__dirstamp) +legacy/libcares_la-ares_expand_name.lo: legacy/$(am__dirstamp) \ + legacy/$(DEPDIR)/$(am__dirstamp) +legacy/libcares_la-ares_expand_string.lo: legacy/$(am__dirstamp) \ + legacy/$(DEPDIR)/$(am__dirstamp) +legacy/libcares_la-ares_fds.lo: legacy/$(am__dirstamp) \ + legacy/$(DEPDIR)/$(am__dirstamp) +legacy/libcares_la-ares_getsock.lo: legacy/$(am__dirstamp) \ + legacy/$(DEPDIR)/$(am__dirstamp) +legacy/libcares_la-ares_parse_a_reply.lo: legacy/$(am__dirstamp) \ + legacy/$(DEPDIR)/$(am__dirstamp) +legacy/libcares_la-ares_parse_aaaa_reply.lo: legacy/$(am__dirstamp) \ + legacy/$(DEPDIR)/$(am__dirstamp) +legacy/libcares_la-ares_parse_caa_reply.lo: legacy/$(am__dirstamp) \ + legacy/$(DEPDIR)/$(am__dirstamp) +legacy/libcares_la-ares_parse_mx_reply.lo: legacy/$(am__dirstamp) \ + legacy/$(DEPDIR)/$(am__dirstamp) +legacy/libcares_la-ares_parse_naptr_reply.lo: legacy/$(am__dirstamp) \ + legacy/$(DEPDIR)/$(am__dirstamp) +legacy/libcares_la-ares_parse_ns_reply.lo: legacy/$(am__dirstamp) \ + legacy/$(DEPDIR)/$(am__dirstamp) +legacy/libcares_la-ares_parse_ptr_reply.lo: legacy/$(am__dirstamp) \ + legacy/$(DEPDIR)/$(am__dirstamp) +legacy/libcares_la-ares_parse_soa_reply.lo: legacy/$(am__dirstamp) \ + legacy/$(DEPDIR)/$(am__dirstamp) +legacy/libcares_la-ares_parse_srv_reply.lo: legacy/$(am__dirstamp) \ + legacy/$(DEPDIR)/$(am__dirstamp) +legacy/libcares_la-ares_parse_txt_reply.lo: legacy/$(am__dirstamp) \ + legacy/$(DEPDIR)/$(am__dirstamp) +legacy/libcares_la-ares_parse_uri_reply.lo: legacy/$(am__dirstamp) \ + legacy/$(DEPDIR)/$(am__dirstamp) +record/$(am__dirstamp): + @$(MKDIR_P) record + @: >>record/$(am__dirstamp) +record/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) record/$(DEPDIR) + @: >>record/$(DEPDIR)/$(am__dirstamp) +record/libcares_la-ares_dns_mapping.lo: record/$(am__dirstamp) \ + record/$(DEPDIR)/$(am__dirstamp) +record/libcares_la-ares_dns_multistring.lo: record/$(am__dirstamp) \ + record/$(DEPDIR)/$(am__dirstamp) +record/libcares_la-ares_dns_name.lo: record/$(am__dirstamp) \ + record/$(DEPDIR)/$(am__dirstamp) +record/libcares_la-ares_dns_parse.lo: record/$(am__dirstamp) \ + record/$(DEPDIR)/$(am__dirstamp) +record/libcares_la-ares_dns_record.lo: record/$(am__dirstamp) \ + record/$(DEPDIR)/$(am__dirstamp) +record/libcares_la-ares_dns_write.lo: record/$(am__dirstamp) \ + record/$(DEPDIR)/$(am__dirstamp) +str/$(am__dirstamp): + @$(MKDIR_P) str + @: >>str/$(am__dirstamp) +str/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) str/$(DEPDIR) + @: >>str/$(DEPDIR)/$(am__dirstamp) +str/libcares_la-ares__buf.lo: str/$(am__dirstamp) \ + str/$(DEPDIR)/$(am__dirstamp) +str/libcares_la-ares_strcasecmp.lo: str/$(am__dirstamp) \ + str/$(DEPDIR)/$(am__dirstamp) +str/libcares_la-ares_str.lo: str/$(am__dirstamp) \ + str/$(DEPDIR)/$(am__dirstamp) +str/libcares_la-ares_strsplit.lo: str/$(am__dirstamp) \ + str/$(DEPDIR)/$(am__dirstamp) +util/$(am__dirstamp): + @$(MKDIR_P) util + @: >>util/$(am__dirstamp) +util/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) util/$(DEPDIR) + @: >>util/$(DEPDIR)/$(am__dirstamp) +util/libcares_la-ares__iface_ips.lo: util/$(am__dirstamp) \ + util/$(DEPDIR)/$(am__dirstamp) +util/libcares_la-ares__threads.lo: util/$(am__dirstamp) \ + util/$(DEPDIR)/$(am__dirstamp) +util/libcares_la-ares__timeval.lo: util/$(am__dirstamp) \ + util/$(DEPDIR)/$(am__dirstamp) +util/libcares_la-ares_math.lo: util/$(am__dirstamp) \ + util/$(DEPDIR)/$(am__dirstamp) +util/libcares_la-ares_rand.lo: util/$(am__dirstamp) \ + util/$(DEPDIR)/$(am__dirstamp) libcares.la: $(libcares_la_OBJECTS) $(libcares_la_DEPENDENCIES) $(EXTRA_libcares_la_DEPENDENCIES) $(AM_V_CCLD)$(libcares_la_LINK) -rpath $(libdir) $(libcares_la_OBJECTS) $(libcares_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) + -rm -f dsa/*.$(OBJEXT) + -rm -f dsa/*.lo + -rm -f event/*.$(OBJEXT) + -rm -f event/*.lo + -rm -f legacy/*.$(OBJEXT) + -rm -f legacy/*.lo + -rm -f record/*.$(OBJEXT) + -rm -f record/*.lo + -rm -f str/*.$(OBJEXT) + -rm -f str/*.lo + -rm -f util/*.$(OBJEXT) + -rm -f util/*.lo distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares__addrinfo2hostent.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares__addrinfo_localhost.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares__buf.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares__close_sockets.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares__hosts_file.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares__htable.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares__htable_asvp.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares__htable_strvp.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares__htable_szvp.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares__htable_vpvp.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares__iface_ips.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares__llist.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares__parse_into_addrinfo.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares__slist.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares__socket.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares__sortaddrinfo.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares__threads.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares__timeval.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_android.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_cancel.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_create_query.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_cookie.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_data.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_destroy.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_dns_mapping.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_dns_multistring.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_dns_name.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_dns_parse.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_dns_record.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_dns_write.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_event_configchg.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_event_epoll.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_event_kqueue.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_event_poll.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_event_select.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_event_thread.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_event_wake_pipe.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_event_win32.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_expand_name.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_expand_string.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_fds.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_free_hostent.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_free_string.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_freeaddrinfo.Plo@am__quote@ # am--include-marker @@ -886,34 +1018,17 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_gethostbyaddr.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_gethostbyname.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_getnameinfo.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_getsock.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_init.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_library_init.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_math.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_metrics.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_options.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_parse_a_reply.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_parse_aaaa_reply.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_parse_caa_reply.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_parse_mx_reply.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_parse_naptr_reply.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_parse_ns_reply.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_parse_ptr_reply.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_parse_soa_reply.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_parse_srv_reply.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_parse_txt_reply.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_parse_uri_reply.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_platform.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_process.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_qcache.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_query.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_rand.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_search.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_send.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_str.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_strcasecmp.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_strerror.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_strsplit.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_sysconfig.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_sysconfig_files.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_sysconfig_mac.Plo@am__quote@ # am--include-marker @@ -924,10 +1039,57 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-inet_net_pton.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-inet_ntop.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-windows_port.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@dsa/$(DEPDIR)/libcares_la-ares__array.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@dsa/$(DEPDIR)/libcares_la-ares__htable.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@dsa/$(DEPDIR)/libcares_la-ares__htable_asvp.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@dsa/$(DEPDIR)/libcares_la-ares__htable_strvp.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@dsa/$(DEPDIR)/libcares_la-ares__htable_szvp.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@dsa/$(DEPDIR)/libcares_la-ares__htable_vpvp.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@dsa/$(DEPDIR)/libcares_la-ares__llist.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@dsa/$(DEPDIR)/libcares_la-ares__slist.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@event/$(DEPDIR)/libcares_la-ares_event_configchg.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@event/$(DEPDIR)/libcares_la-ares_event_epoll.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@event/$(DEPDIR)/libcares_la-ares_event_kqueue.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@event/$(DEPDIR)/libcares_la-ares_event_poll.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@event/$(DEPDIR)/libcares_la-ares_event_select.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@event/$(DEPDIR)/libcares_la-ares_event_thread.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@event/$(DEPDIR)/libcares_la-ares_event_wake_pipe.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@event/$(DEPDIR)/libcares_la-ares_event_win32.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@legacy/$(DEPDIR)/libcares_la-ares_create_query.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@legacy/$(DEPDIR)/libcares_la-ares_expand_name.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@legacy/$(DEPDIR)/libcares_la-ares_expand_string.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@legacy/$(DEPDIR)/libcares_la-ares_fds.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@legacy/$(DEPDIR)/libcares_la-ares_getsock.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@legacy/$(DEPDIR)/libcares_la-ares_parse_a_reply.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@legacy/$(DEPDIR)/libcares_la-ares_parse_aaaa_reply.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@legacy/$(DEPDIR)/libcares_la-ares_parse_caa_reply.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@legacy/$(DEPDIR)/libcares_la-ares_parse_mx_reply.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@legacy/$(DEPDIR)/libcares_la-ares_parse_naptr_reply.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@legacy/$(DEPDIR)/libcares_la-ares_parse_ns_reply.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@legacy/$(DEPDIR)/libcares_la-ares_parse_ptr_reply.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@legacy/$(DEPDIR)/libcares_la-ares_parse_soa_reply.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@legacy/$(DEPDIR)/libcares_la-ares_parse_srv_reply.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@legacy/$(DEPDIR)/libcares_la-ares_parse_txt_reply.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@legacy/$(DEPDIR)/libcares_la-ares_parse_uri_reply.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@record/$(DEPDIR)/libcares_la-ares_dns_mapping.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@record/$(DEPDIR)/libcares_la-ares_dns_multistring.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@record/$(DEPDIR)/libcares_la-ares_dns_name.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@record/$(DEPDIR)/libcares_la-ares_dns_parse.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@record/$(DEPDIR)/libcares_la-ares_dns_record.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@record/$(DEPDIR)/libcares_la-ares_dns_write.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@str/$(DEPDIR)/libcares_la-ares__buf.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@str/$(DEPDIR)/libcares_la-ares_str.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@str/$(DEPDIR)/libcares_la-ares_strcasecmp.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@str/$(DEPDIR)/libcares_la-ares_strsplit.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@util/$(DEPDIR)/libcares_la-ares__iface_ips.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@util/$(DEPDIR)/libcares_la-ares__threads.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@util/$(DEPDIR)/libcares_la-ares__timeval.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@util/$(DEPDIR)/libcares_la-ares_math.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@util/$(DEPDIR)/libcares_la-ares_rand.Plo@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) - @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + @: >>$@ am--depfiles: $(am__depfiles_remade) @@ -969,13 +1131,6 @@ libcares_la-ares__addrinfo_localhost.lo: ares__addrinfo_localhost.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares__addrinfo_localhost.lo `test -f 'ares__addrinfo_localhost.c' || echo '$(srcdir)/'`ares__addrinfo_localhost.c -libcares_la-ares__buf.lo: ares__buf.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares__buf.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares__buf.Tpo -c -o libcares_la-ares__buf.lo `test -f 'ares__buf.c' || echo '$(srcdir)/'`ares__buf.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares__buf.Tpo $(DEPDIR)/libcares_la-ares__buf.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares__buf.c' object='libcares_la-ares__buf.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares__buf.lo `test -f 'ares__buf.c' || echo '$(srcdir)/'`ares__buf.c - libcares_la-ares__close_sockets.lo: ares__close_sockets.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares__close_sockets.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares__close_sockets.Tpo -c -o libcares_la-ares__close_sockets.lo `test -f 'ares__close_sockets.c' || echo '$(srcdir)/'`ares__close_sockets.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares__close_sockets.Tpo $(DEPDIR)/libcares_la-ares__close_sockets.Plo @@ -990,55 +1145,6 @@ libcares_la-ares__hosts_file.lo: ares__hosts_file.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares__hosts_file.lo `test -f 'ares__hosts_file.c' || echo '$(srcdir)/'`ares__hosts_file.c -libcares_la-ares__htable.lo: ares__htable.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares__htable.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares__htable.Tpo -c -o libcares_la-ares__htable.lo `test -f 'ares__htable.c' || echo '$(srcdir)/'`ares__htable.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares__htable.Tpo $(DEPDIR)/libcares_la-ares__htable.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares__htable.c' object='libcares_la-ares__htable.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares__htable.lo `test -f 'ares__htable.c' || echo '$(srcdir)/'`ares__htable.c - -libcares_la-ares__htable_asvp.lo: ares__htable_asvp.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares__htable_asvp.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares__htable_asvp.Tpo -c -o libcares_la-ares__htable_asvp.lo `test -f 'ares__htable_asvp.c' || echo '$(srcdir)/'`ares__htable_asvp.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares__htable_asvp.Tpo $(DEPDIR)/libcares_la-ares__htable_asvp.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares__htable_asvp.c' object='libcares_la-ares__htable_asvp.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares__htable_asvp.lo `test -f 'ares__htable_asvp.c' || echo '$(srcdir)/'`ares__htable_asvp.c - -libcares_la-ares__htable_strvp.lo: ares__htable_strvp.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares__htable_strvp.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares__htable_strvp.Tpo -c -o libcares_la-ares__htable_strvp.lo `test -f 'ares__htable_strvp.c' || echo '$(srcdir)/'`ares__htable_strvp.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares__htable_strvp.Tpo $(DEPDIR)/libcares_la-ares__htable_strvp.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares__htable_strvp.c' object='libcares_la-ares__htable_strvp.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares__htable_strvp.lo `test -f 'ares__htable_strvp.c' || echo '$(srcdir)/'`ares__htable_strvp.c - -libcares_la-ares__htable_szvp.lo: ares__htable_szvp.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares__htable_szvp.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares__htable_szvp.Tpo -c -o libcares_la-ares__htable_szvp.lo `test -f 'ares__htable_szvp.c' || echo '$(srcdir)/'`ares__htable_szvp.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares__htable_szvp.Tpo $(DEPDIR)/libcares_la-ares__htable_szvp.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares__htable_szvp.c' object='libcares_la-ares__htable_szvp.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares__htable_szvp.lo `test -f 'ares__htable_szvp.c' || echo '$(srcdir)/'`ares__htable_szvp.c - -libcares_la-ares__htable_vpvp.lo: ares__htable_vpvp.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares__htable_vpvp.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares__htable_vpvp.Tpo -c -o libcares_la-ares__htable_vpvp.lo `test -f 'ares__htable_vpvp.c' || echo '$(srcdir)/'`ares__htable_vpvp.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares__htable_vpvp.Tpo $(DEPDIR)/libcares_la-ares__htable_vpvp.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares__htable_vpvp.c' object='libcares_la-ares__htable_vpvp.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares__htable_vpvp.lo `test -f 'ares__htable_vpvp.c' || echo '$(srcdir)/'`ares__htable_vpvp.c - -libcares_la-ares__iface_ips.lo: ares__iface_ips.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares__iface_ips.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares__iface_ips.Tpo -c -o libcares_la-ares__iface_ips.lo `test -f 'ares__iface_ips.c' || echo '$(srcdir)/'`ares__iface_ips.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares__iface_ips.Tpo $(DEPDIR)/libcares_la-ares__iface_ips.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares__iface_ips.c' object='libcares_la-ares__iface_ips.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares__iface_ips.lo `test -f 'ares__iface_ips.c' || echo '$(srcdir)/'`ares__iface_ips.c - -libcares_la-ares__llist.lo: ares__llist.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares__llist.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares__llist.Tpo -c -o libcares_la-ares__llist.lo `test -f 'ares__llist.c' || echo '$(srcdir)/'`ares__llist.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares__llist.Tpo $(DEPDIR)/libcares_la-ares__llist.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares__llist.c' object='libcares_la-ares__llist.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares__llist.lo `test -f 'ares__llist.c' || echo '$(srcdir)/'`ares__llist.c - libcares_la-ares__parse_into_addrinfo.lo: ares__parse_into_addrinfo.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares__parse_into_addrinfo.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares__parse_into_addrinfo.Tpo -c -o libcares_la-ares__parse_into_addrinfo.lo `test -f 'ares__parse_into_addrinfo.c' || echo '$(srcdir)/'`ares__parse_into_addrinfo.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares__parse_into_addrinfo.Tpo $(DEPDIR)/libcares_la-ares__parse_into_addrinfo.Plo @@ -1046,13 +1152,6 @@ libcares_la-ares__parse_into_addrinfo.lo: ares__parse_into_addrinfo.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares__parse_into_addrinfo.lo `test -f 'ares__parse_into_addrinfo.c' || echo '$(srcdir)/'`ares__parse_into_addrinfo.c -libcares_la-ares__slist.lo: ares__slist.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares__slist.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares__slist.Tpo -c -o libcares_la-ares__slist.lo `test -f 'ares__slist.c' || echo '$(srcdir)/'`ares__slist.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares__slist.Tpo $(DEPDIR)/libcares_la-ares__slist.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares__slist.c' object='libcares_la-ares__slist.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares__slist.lo `test -f 'ares__slist.c' || echo '$(srcdir)/'`ares__slist.c - libcares_la-ares__socket.lo: ares__socket.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares__socket.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares__socket.Tpo -c -o libcares_la-ares__socket.lo `test -f 'ares__socket.c' || echo '$(srcdir)/'`ares__socket.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares__socket.Tpo $(DEPDIR)/libcares_la-ares__socket.Plo @@ -1067,20 +1166,6 @@ libcares_la-ares__sortaddrinfo.lo: ares__sortaddrinfo.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares__sortaddrinfo.lo `test -f 'ares__sortaddrinfo.c' || echo '$(srcdir)/'`ares__sortaddrinfo.c -libcares_la-ares__threads.lo: ares__threads.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares__threads.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares__threads.Tpo -c -o libcares_la-ares__threads.lo `test -f 'ares__threads.c' || echo '$(srcdir)/'`ares__threads.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares__threads.Tpo $(DEPDIR)/libcares_la-ares__threads.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares__threads.c' object='libcares_la-ares__threads.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares__threads.lo `test -f 'ares__threads.c' || echo '$(srcdir)/'`ares__threads.c - -libcares_la-ares__timeval.lo: ares__timeval.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares__timeval.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares__timeval.Tpo -c -o libcares_la-ares__timeval.lo `test -f 'ares__timeval.c' || echo '$(srcdir)/'`ares__timeval.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares__timeval.Tpo $(DEPDIR)/libcares_la-ares__timeval.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares__timeval.c' object='libcares_la-ares__timeval.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares__timeval.lo `test -f 'ares__timeval.c' || echo '$(srcdir)/'`ares__timeval.c - libcares_la-ares_android.lo: ares_android.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_android.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_android.Tpo -c -o libcares_la-ares_android.lo `test -f 'ares_android.c' || echo '$(srcdir)/'`ares_android.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_android.Tpo $(DEPDIR)/libcares_la-ares_android.Plo @@ -1095,6 +1180,13 @@ libcares_la-ares_cancel.lo: ares_cancel.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_cancel.lo `test -f 'ares_cancel.c' || echo '$(srcdir)/'`ares_cancel.c +libcares_la-ares_cookie.lo: ares_cookie.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_cookie.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_cookie.Tpo -c -o libcares_la-ares_cookie.lo `test -f 'ares_cookie.c' || echo '$(srcdir)/'`ares_cookie.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_cookie.Tpo $(DEPDIR)/libcares_la-ares_cookie.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_cookie.c' object='libcares_la-ares_cookie.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_cookie.lo `test -f 'ares_cookie.c' || echo '$(srcdir)/'`ares_cookie.c + libcares_la-ares_data.lo: ares_data.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_data.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_data.Tpo -c -o libcares_la-ares_data.lo `test -f 'ares_data.c' || echo '$(srcdir)/'`ares_data.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_data.Tpo $(DEPDIR)/libcares_la-ares_data.Plo @@ -1109,125 +1201,6 @@ libcares_la-ares_destroy.lo: ares_destroy.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_destroy.lo `test -f 'ares_destroy.c' || echo '$(srcdir)/'`ares_destroy.c -libcares_la-ares_dns_mapping.lo: ares_dns_mapping.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_dns_mapping.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_dns_mapping.Tpo -c -o libcares_la-ares_dns_mapping.lo `test -f 'ares_dns_mapping.c' || echo '$(srcdir)/'`ares_dns_mapping.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_dns_mapping.Tpo $(DEPDIR)/libcares_la-ares_dns_mapping.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_dns_mapping.c' object='libcares_la-ares_dns_mapping.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_dns_mapping.lo `test -f 'ares_dns_mapping.c' || echo '$(srcdir)/'`ares_dns_mapping.c - -libcares_la-ares_dns_multistring.lo: ares_dns_multistring.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_dns_multistring.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_dns_multistring.Tpo -c -o libcares_la-ares_dns_multistring.lo `test -f 'ares_dns_multistring.c' || echo '$(srcdir)/'`ares_dns_multistring.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_dns_multistring.Tpo $(DEPDIR)/libcares_la-ares_dns_multistring.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_dns_multistring.c' object='libcares_la-ares_dns_multistring.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_dns_multistring.lo `test -f 'ares_dns_multistring.c' || echo '$(srcdir)/'`ares_dns_multistring.c - -libcares_la-ares_dns_name.lo: ares_dns_name.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_dns_name.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_dns_name.Tpo -c -o libcares_la-ares_dns_name.lo `test -f 'ares_dns_name.c' || echo '$(srcdir)/'`ares_dns_name.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_dns_name.Tpo $(DEPDIR)/libcares_la-ares_dns_name.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_dns_name.c' object='libcares_la-ares_dns_name.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_dns_name.lo `test -f 'ares_dns_name.c' || echo '$(srcdir)/'`ares_dns_name.c - -libcares_la-ares_dns_parse.lo: ares_dns_parse.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_dns_parse.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_dns_parse.Tpo -c -o libcares_la-ares_dns_parse.lo `test -f 'ares_dns_parse.c' || echo '$(srcdir)/'`ares_dns_parse.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_dns_parse.Tpo $(DEPDIR)/libcares_la-ares_dns_parse.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_dns_parse.c' object='libcares_la-ares_dns_parse.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_dns_parse.lo `test -f 'ares_dns_parse.c' || echo '$(srcdir)/'`ares_dns_parse.c - -libcares_la-ares_dns_record.lo: ares_dns_record.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_dns_record.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_dns_record.Tpo -c -o libcares_la-ares_dns_record.lo `test -f 'ares_dns_record.c' || echo '$(srcdir)/'`ares_dns_record.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_dns_record.Tpo $(DEPDIR)/libcares_la-ares_dns_record.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_dns_record.c' object='libcares_la-ares_dns_record.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_dns_record.lo `test -f 'ares_dns_record.c' || echo '$(srcdir)/'`ares_dns_record.c - -libcares_la-ares_dns_write.lo: ares_dns_write.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_dns_write.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_dns_write.Tpo -c -o libcares_la-ares_dns_write.lo `test -f 'ares_dns_write.c' || echo '$(srcdir)/'`ares_dns_write.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_dns_write.Tpo $(DEPDIR)/libcares_la-ares_dns_write.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_dns_write.c' object='libcares_la-ares_dns_write.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_dns_write.lo `test -f 'ares_dns_write.c' || echo '$(srcdir)/'`ares_dns_write.c - -libcares_la-ares_event_configchg.lo: ares_event_configchg.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_event_configchg.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_event_configchg.Tpo -c -o libcares_la-ares_event_configchg.lo `test -f 'ares_event_configchg.c' || echo '$(srcdir)/'`ares_event_configchg.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_event_configchg.Tpo $(DEPDIR)/libcares_la-ares_event_configchg.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_event_configchg.c' object='libcares_la-ares_event_configchg.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_event_configchg.lo `test -f 'ares_event_configchg.c' || echo '$(srcdir)/'`ares_event_configchg.c - -libcares_la-ares_event_epoll.lo: ares_event_epoll.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_event_epoll.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_event_epoll.Tpo -c -o libcares_la-ares_event_epoll.lo `test -f 'ares_event_epoll.c' || echo '$(srcdir)/'`ares_event_epoll.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_event_epoll.Tpo $(DEPDIR)/libcares_la-ares_event_epoll.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_event_epoll.c' object='libcares_la-ares_event_epoll.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_event_epoll.lo `test -f 'ares_event_epoll.c' || echo '$(srcdir)/'`ares_event_epoll.c - -libcares_la-ares_event_kqueue.lo: ares_event_kqueue.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_event_kqueue.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_event_kqueue.Tpo -c -o libcares_la-ares_event_kqueue.lo `test -f 'ares_event_kqueue.c' || echo '$(srcdir)/'`ares_event_kqueue.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_event_kqueue.Tpo $(DEPDIR)/libcares_la-ares_event_kqueue.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_event_kqueue.c' object='libcares_la-ares_event_kqueue.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_event_kqueue.lo `test -f 'ares_event_kqueue.c' || echo '$(srcdir)/'`ares_event_kqueue.c - -libcares_la-ares_event_poll.lo: ares_event_poll.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_event_poll.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_event_poll.Tpo -c -o libcares_la-ares_event_poll.lo `test -f 'ares_event_poll.c' || echo '$(srcdir)/'`ares_event_poll.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_event_poll.Tpo $(DEPDIR)/libcares_la-ares_event_poll.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_event_poll.c' object='libcares_la-ares_event_poll.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_event_poll.lo `test -f 'ares_event_poll.c' || echo '$(srcdir)/'`ares_event_poll.c - -libcares_la-ares_event_select.lo: ares_event_select.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_event_select.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_event_select.Tpo -c -o libcares_la-ares_event_select.lo `test -f 'ares_event_select.c' || echo '$(srcdir)/'`ares_event_select.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_event_select.Tpo $(DEPDIR)/libcares_la-ares_event_select.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_event_select.c' object='libcares_la-ares_event_select.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_event_select.lo `test -f 'ares_event_select.c' || echo '$(srcdir)/'`ares_event_select.c - -libcares_la-ares_event_thread.lo: ares_event_thread.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_event_thread.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_event_thread.Tpo -c -o libcares_la-ares_event_thread.lo `test -f 'ares_event_thread.c' || echo '$(srcdir)/'`ares_event_thread.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_event_thread.Tpo $(DEPDIR)/libcares_la-ares_event_thread.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_event_thread.c' object='libcares_la-ares_event_thread.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_event_thread.lo `test -f 'ares_event_thread.c' || echo '$(srcdir)/'`ares_event_thread.c - -libcares_la-ares_event_wake_pipe.lo: ares_event_wake_pipe.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_event_wake_pipe.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_event_wake_pipe.Tpo -c -o libcares_la-ares_event_wake_pipe.lo `test -f 'ares_event_wake_pipe.c' || echo '$(srcdir)/'`ares_event_wake_pipe.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_event_wake_pipe.Tpo $(DEPDIR)/libcares_la-ares_event_wake_pipe.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_event_wake_pipe.c' object='libcares_la-ares_event_wake_pipe.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_event_wake_pipe.lo `test -f 'ares_event_wake_pipe.c' || echo '$(srcdir)/'`ares_event_wake_pipe.c - -libcares_la-ares_event_win32.lo: ares_event_win32.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_event_win32.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_event_win32.Tpo -c -o libcares_la-ares_event_win32.lo `test -f 'ares_event_win32.c' || echo '$(srcdir)/'`ares_event_win32.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_event_win32.Tpo $(DEPDIR)/libcares_la-ares_event_win32.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_event_win32.c' object='libcares_la-ares_event_win32.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_event_win32.lo `test -f 'ares_event_win32.c' || echo '$(srcdir)/'`ares_event_win32.c - -libcares_la-ares_expand_name.lo: ares_expand_name.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_expand_name.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_expand_name.Tpo -c -o libcares_la-ares_expand_name.lo `test -f 'ares_expand_name.c' || echo '$(srcdir)/'`ares_expand_name.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_expand_name.Tpo $(DEPDIR)/libcares_la-ares_expand_name.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_expand_name.c' object='libcares_la-ares_expand_name.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_expand_name.lo `test -f 'ares_expand_name.c' || echo '$(srcdir)/'`ares_expand_name.c - -libcares_la-ares_expand_string.lo: ares_expand_string.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_expand_string.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_expand_string.Tpo -c -o libcares_la-ares_expand_string.lo `test -f 'ares_expand_string.c' || echo '$(srcdir)/'`ares_expand_string.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_expand_string.Tpo $(DEPDIR)/libcares_la-ares_expand_string.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_expand_string.c' object='libcares_la-ares_expand_string.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_expand_string.lo `test -f 'ares_expand_string.c' || echo '$(srcdir)/'`ares_expand_string.c - -libcares_la-ares_fds.lo: ares_fds.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_fds.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_fds.Tpo -c -o libcares_la-ares_fds.lo `test -f 'ares_fds.c' || echo '$(srcdir)/'`ares_fds.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_fds.Tpo $(DEPDIR)/libcares_la-ares_fds.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_fds.c' object='libcares_la-ares_fds.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_fds.lo `test -f 'ares_fds.c' || echo '$(srcdir)/'`ares_fds.c - libcares_la-ares_free_hostent.lo: ares_free_hostent.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_free_hostent.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_free_hostent.Tpo -c -o libcares_la-ares_free_hostent.lo `test -f 'ares_free_hostent.c' || echo '$(srcdir)/'`ares_free_hostent.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_free_hostent.Tpo $(DEPDIR)/libcares_la-ares_free_hostent.Plo @@ -1284,13 +1257,6 @@ libcares_la-ares_getnameinfo.lo: ares_getnameinfo.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_getnameinfo.lo `test -f 'ares_getnameinfo.c' || echo '$(srcdir)/'`ares_getnameinfo.c -libcares_la-ares_getsock.lo: ares_getsock.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_getsock.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_getsock.Tpo -c -o libcares_la-ares_getsock.lo `test -f 'ares_getsock.c' || echo '$(srcdir)/'`ares_getsock.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_getsock.Tpo $(DEPDIR)/libcares_la-ares_getsock.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_getsock.c' object='libcares_la-ares_getsock.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_getsock.lo `test -f 'ares_getsock.c' || echo '$(srcdir)/'`ares_getsock.c - libcares_la-ares_init.lo: ares_init.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_init.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_init.Tpo -c -o libcares_la-ares_init.lo `test -f 'ares_init.c' || echo '$(srcdir)/'`ares_init.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_init.Tpo $(DEPDIR)/libcares_la-ares_init.Plo @@ -1305,13 +1271,6 @@ libcares_la-ares_library_init.lo: ares_library_init.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_library_init.lo `test -f 'ares_library_init.c' || echo '$(srcdir)/'`ares_library_init.c -libcares_la-ares_math.lo: ares_math.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_math.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_math.Tpo -c -o libcares_la-ares_math.lo `test -f 'ares_math.c' || echo '$(srcdir)/'`ares_math.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_math.Tpo $(DEPDIR)/libcares_la-ares_math.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_math.c' object='libcares_la-ares_math.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_math.lo `test -f 'ares_math.c' || echo '$(srcdir)/'`ares_math.c - libcares_la-ares_metrics.lo: ares_metrics.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_metrics.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_metrics.Tpo -c -o libcares_la-ares_metrics.lo `test -f 'ares_metrics.c' || echo '$(srcdir)/'`ares_metrics.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_metrics.Tpo $(DEPDIR)/libcares_la-ares_metrics.Plo @@ -1319,13 +1278,6 @@ libcares_la-ares_metrics.lo: ares_metrics.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_metrics.lo `test -f 'ares_metrics.c' || echo '$(srcdir)/'`ares_metrics.c -libcares_la-ares_create_query.lo: ares_create_query.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_create_query.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_create_query.Tpo -c -o libcares_la-ares_create_query.lo `test -f 'ares_create_query.c' || echo '$(srcdir)/'`ares_create_query.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_create_query.Tpo $(DEPDIR)/libcares_la-ares_create_query.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_create_query.c' object='libcares_la-ares_create_query.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_create_query.lo `test -f 'ares_create_query.c' || echo '$(srcdir)/'`ares_create_query.c - libcares_la-ares_options.lo: ares_options.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_options.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_options.Tpo -c -o libcares_la-ares_options.lo `test -f 'ares_options.c' || echo '$(srcdir)/'`ares_options.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_options.Tpo $(DEPDIR)/libcares_la-ares_options.Plo @@ -1333,83 +1285,6 @@ libcares_la-ares_options.lo: ares_options.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_options.lo `test -f 'ares_options.c' || echo '$(srcdir)/'`ares_options.c -libcares_la-ares_parse_a_reply.lo: ares_parse_a_reply.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_parse_a_reply.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_parse_a_reply.Tpo -c -o libcares_la-ares_parse_a_reply.lo `test -f 'ares_parse_a_reply.c' || echo '$(srcdir)/'`ares_parse_a_reply.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_parse_a_reply.Tpo $(DEPDIR)/libcares_la-ares_parse_a_reply.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_parse_a_reply.c' object='libcares_la-ares_parse_a_reply.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_parse_a_reply.lo `test -f 'ares_parse_a_reply.c' || echo '$(srcdir)/'`ares_parse_a_reply.c - -libcares_la-ares_parse_aaaa_reply.lo: ares_parse_aaaa_reply.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_parse_aaaa_reply.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_parse_aaaa_reply.Tpo -c -o libcares_la-ares_parse_aaaa_reply.lo `test -f 'ares_parse_aaaa_reply.c' || echo '$(srcdir)/'`ares_parse_aaaa_reply.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_parse_aaaa_reply.Tpo $(DEPDIR)/libcares_la-ares_parse_aaaa_reply.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_parse_aaaa_reply.c' object='libcares_la-ares_parse_aaaa_reply.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_parse_aaaa_reply.lo `test -f 'ares_parse_aaaa_reply.c' || echo '$(srcdir)/'`ares_parse_aaaa_reply.c - -libcares_la-ares_parse_caa_reply.lo: ares_parse_caa_reply.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_parse_caa_reply.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_parse_caa_reply.Tpo -c -o libcares_la-ares_parse_caa_reply.lo `test -f 'ares_parse_caa_reply.c' || echo '$(srcdir)/'`ares_parse_caa_reply.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_parse_caa_reply.Tpo $(DEPDIR)/libcares_la-ares_parse_caa_reply.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_parse_caa_reply.c' object='libcares_la-ares_parse_caa_reply.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_parse_caa_reply.lo `test -f 'ares_parse_caa_reply.c' || echo '$(srcdir)/'`ares_parse_caa_reply.c - -libcares_la-ares_parse_mx_reply.lo: ares_parse_mx_reply.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_parse_mx_reply.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_parse_mx_reply.Tpo -c -o libcares_la-ares_parse_mx_reply.lo `test -f 'ares_parse_mx_reply.c' || echo '$(srcdir)/'`ares_parse_mx_reply.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_parse_mx_reply.Tpo $(DEPDIR)/libcares_la-ares_parse_mx_reply.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_parse_mx_reply.c' object='libcares_la-ares_parse_mx_reply.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_parse_mx_reply.lo `test -f 'ares_parse_mx_reply.c' || echo '$(srcdir)/'`ares_parse_mx_reply.c - -libcares_la-ares_parse_naptr_reply.lo: ares_parse_naptr_reply.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_parse_naptr_reply.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_parse_naptr_reply.Tpo -c -o libcares_la-ares_parse_naptr_reply.lo `test -f 'ares_parse_naptr_reply.c' || echo '$(srcdir)/'`ares_parse_naptr_reply.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_parse_naptr_reply.Tpo $(DEPDIR)/libcares_la-ares_parse_naptr_reply.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_parse_naptr_reply.c' object='libcares_la-ares_parse_naptr_reply.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_parse_naptr_reply.lo `test -f 'ares_parse_naptr_reply.c' || echo '$(srcdir)/'`ares_parse_naptr_reply.c - -libcares_la-ares_parse_ns_reply.lo: ares_parse_ns_reply.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_parse_ns_reply.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_parse_ns_reply.Tpo -c -o libcares_la-ares_parse_ns_reply.lo `test -f 'ares_parse_ns_reply.c' || echo '$(srcdir)/'`ares_parse_ns_reply.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_parse_ns_reply.Tpo $(DEPDIR)/libcares_la-ares_parse_ns_reply.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_parse_ns_reply.c' object='libcares_la-ares_parse_ns_reply.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_parse_ns_reply.lo `test -f 'ares_parse_ns_reply.c' || echo '$(srcdir)/'`ares_parse_ns_reply.c - -libcares_la-ares_parse_ptr_reply.lo: ares_parse_ptr_reply.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_parse_ptr_reply.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_parse_ptr_reply.Tpo -c -o libcares_la-ares_parse_ptr_reply.lo `test -f 'ares_parse_ptr_reply.c' || echo '$(srcdir)/'`ares_parse_ptr_reply.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_parse_ptr_reply.Tpo $(DEPDIR)/libcares_la-ares_parse_ptr_reply.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_parse_ptr_reply.c' object='libcares_la-ares_parse_ptr_reply.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_parse_ptr_reply.lo `test -f 'ares_parse_ptr_reply.c' || echo '$(srcdir)/'`ares_parse_ptr_reply.c - -libcares_la-ares_parse_soa_reply.lo: ares_parse_soa_reply.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_parse_soa_reply.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_parse_soa_reply.Tpo -c -o libcares_la-ares_parse_soa_reply.lo `test -f 'ares_parse_soa_reply.c' || echo '$(srcdir)/'`ares_parse_soa_reply.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_parse_soa_reply.Tpo $(DEPDIR)/libcares_la-ares_parse_soa_reply.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_parse_soa_reply.c' object='libcares_la-ares_parse_soa_reply.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_parse_soa_reply.lo `test -f 'ares_parse_soa_reply.c' || echo '$(srcdir)/'`ares_parse_soa_reply.c - -libcares_la-ares_parse_srv_reply.lo: ares_parse_srv_reply.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_parse_srv_reply.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_parse_srv_reply.Tpo -c -o libcares_la-ares_parse_srv_reply.lo `test -f 'ares_parse_srv_reply.c' || echo '$(srcdir)/'`ares_parse_srv_reply.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_parse_srv_reply.Tpo $(DEPDIR)/libcares_la-ares_parse_srv_reply.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_parse_srv_reply.c' object='libcares_la-ares_parse_srv_reply.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_parse_srv_reply.lo `test -f 'ares_parse_srv_reply.c' || echo '$(srcdir)/'`ares_parse_srv_reply.c - -libcares_la-ares_parse_txt_reply.lo: ares_parse_txt_reply.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_parse_txt_reply.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_parse_txt_reply.Tpo -c -o libcares_la-ares_parse_txt_reply.lo `test -f 'ares_parse_txt_reply.c' || echo '$(srcdir)/'`ares_parse_txt_reply.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_parse_txt_reply.Tpo $(DEPDIR)/libcares_la-ares_parse_txt_reply.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_parse_txt_reply.c' object='libcares_la-ares_parse_txt_reply.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_parse_txt_reply.lo `test -f 'ares_parse_txt_reply.c' || echo '$(srcdir)/'`ares_parse_txt_reply.c - -libcares_la-ares_parse_uri_reply.lo: ares_parse_uri_reply.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_parse_uri_reply.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_parse_uri_reply.Tpo -c -o libcares_la-ares_parse_uri_reply.lo `test -f 'ares_parse_uri_reply.c' || echo '$(srcdir)/'`ares_parse_uri_reply.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_parse_uri_reply.Tpo $(DEPDIR)/libcares_la-ares_parse_uri_reply.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_parse_uri_reply.c' object='libcares_la-ares_parse_uri_reply.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_parse_uri_reply.lo `test -f 'ares_parse_uri_reply.c' || echo '$(srcdir)/'`ares_parse_uri_reply.c - libcares_la-ares_platform.lo: ares_platform.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_platform.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_platform.Tpo -c -o libcares_la-ares_platform.lo `test -f 'ares_platform.c' || echo '$(srcdir)/'`ares_platform.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_platform.Tpo $(DEPDIR)/libcares_la-ares_platform.Plo @@ -1438,13 +1313,6 @@ libcares_la-ares_query.lo: ares_query.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_query.lo `test -f 'ares_query.c' || echo '$(srcdir)/'`ares_query.c -libcares_la-ares_rand.lo: ares_rand.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_rand.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_rand.Tpo -c -o libcares_la-ares_rand.lo `test -f 'ares_rand.c' || echo '$(srcdir)/'`ares_rand.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_rand.Tpo $(DEPDIR)/libcares_la-ares_rand.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_rand.c' object='libcares_la-ares_rand.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_rand.lo `test -f 'ares_rand.c' || echo '$(srcdir)/'`ares_rand.c - libcares_la-ares_search.lo: ares_search.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_search.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_search.Tpo -c -o libcares_la-ares_search.lo `test -f 'ares_search.c' || echo '$(srcdir)/'`ares_search.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_search.Tpo $(DEPDIR)/libcares_la-ares_search.Plo @@ -1459,20 +1327,6 @@ libcares_la-ares_send.lo: ares_send.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_send.lo `test -f 'ares_send.c' || echo '$(srcdir)/'`ares_send.c -libcares_la-ares_strcasecmp.lo: ares_strcasecmp.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_strcasecmp.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_strcasecmp.Tpo -c -o libcares_la-ares_strcasecmp.lo `test -f 'ares_strcasecmp.c' || echo '$(srcdir)/'`ares_strcasecmp.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_strcasecmp.Tpo $(DEPDIR)/libcares_la-ares_strcasecmp.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_strcasecmp.c' object='libcares_la-ares_strcasecmp.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_strcasecmp.lo `test -f 'ares_strcasecmp.c' || echo '$(srcdir)/'`ares_strcasecmp.c - -libcares_la-ares_str.lo: ares_str.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_str.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_str.Tpo -c -o libcares_la-ares_str.lo `test -f 'ares_str.c' || echo '$(srcdir)/'`ares_str.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_str.Tpo $(DEPDIR)/libcares_la-ares_str.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_str.c' object='libcares_la-ares_str.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_str.lo `test -f 'ares_str.c' || echo '$(srcdir)/'`ares_str.c - libcares_la-ares_strerror.lo: ares_strerror.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_strerror.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_strerror.Tpo -c -o libcares_la-ares_strerror.lo `test -f 'ares_strerror.c' || echo '$(srcdir)/'`ares_strerror.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_strerror.Tpo $(DEPDIR)/libcares_la-ares_strerror.Plo @@ -1480,13 +1334,6 @@ libcares_la-ares_strerror.lo: ares_strerror.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_strerror.lo `test -f 'ares_strerror.c' || echo '$(srcdir)/'`ares_strerror.c -libcares_la-ares_strsplit.lo: ares_strsplit.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_strsplit.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_strsplit.Tpo -c -o libcares_la-ares_strsplit.lo `test -f 'ares_strsplit.c' || echo '$(srcdir)/'`ares_strsplit.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_strsplit.Tpo $(DEPDIR)/libcares_la-ares_strsplit.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_strsplit.c' object='libcares_la-ares_strsplit.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_strsplit.lo `test -f 'ares_strsplit.c' || echo '$(srcdir)/'`ares_strsplit.c - libcares_la-ares_sysconfig.lo: ares_sysconfig.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_sysconfig.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_sysconfig.Tpo -c -o libcares_la-ares_sysconfig.lo `test -f 'ares_sysconfig.c' || echo '$(srcdir)/'`ares_sysconfig.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_sysconfig.Tpo $(DEPDIR)/libcares_la-ares_sysconfig.Plo @@ -1557,11 +1404,346 @@ libcares_la-windows_port.lo: windows_port.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-windows_port.lo `test -f 'windows_port.c' || echo '$(srcdir)/'`windows_port.c +dsa/libcares_la-ares__array.lo: dsa/ares__array.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT dsa/libcares_la-ares__array.lo -MD -MP -MF dsa/$(DEPDIR)/libcares_la-ares__array.Tpo -c -o dsa/libcares_la-ares__array.lo `test -f 'dsa/ares__array.c' || echo '$(srcdir)/'`dsa/ares__array.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dsa/$(DEPDIR)/libcares_la-ares__array.Tpo dsa/$(DEPDIR)/libcares_la-ares__array.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dsa/ares__array.c' object='dsa/libcares_la-ares__array.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o dsa/libcares_la-ares__array.lo `test -f 'dsa/ares__array.c' || echo '$(srcdir)/'`dsa/ares__array.c + +dsa/libcares_la-ares__htable.lo: dsa/ares__htable.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT dsa/libcares_la-ares__htable.lo -MD -MP -MF dsa/$(DEPDIR)/libcares_la-ares__htable.Tpo -c -o dsa/libcares_la-ares__htable.lo `test -f 'dsa/ares__htable.c' || echo '$(srcdir)/'`dsa/ares__htable.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dsa/$(DEPDIR)/libcares_la-ares__htable.Tpo dsa/$(DEPDIR)/libcares_la-ares__htable.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dsa/ares__htable.c' object='dsa/libcares_la-ares__htable.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o dsa/libcares_la-ares__htable.lo `test -f 'dsa/ares__htable.c' || echo '$(srcdir)/'`dsa/ares__htable.c + +dsa/libcares_la-ares__htable_asvp.lo: dsa/ares__htable_asvp.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT dsa/libcares_la-ares__htable_asvp.lo -MD -MP -MF dsa/$(DEPDIR)/libcares_la-ares__htable_asvp.Tpo -c -o dsa/libcares_la-ares__htable_asvp.lo `test -f 'dsa/ares__htable_asvp.c' || echo '$(srcdir)/'`dsa/ares__htable_asvp.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dsa/$(DEPDIR)/libcares_la-ares__htable_asvp.Tpo dsa/$(DEPDIR)/libcares_la-ares__htable_asvp.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dsa/ares__htable_asvp.c' object='dsa/libcares_la-ares__htable_asvp.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o dsa/libcares_la-ares__htable_asvp.lo `test -f 'dsa/ares__htable_asvp.c' || echo '$(srcdir)/'`dsa/ares__htable_asvp.c + +dsa/libcares_la-ares__htable_strvp.lo: dsa/ares__htable_strvp.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT dsa/libcares_la-ares__htable_strvp.lo -MD -MP -MF dsa/$(DEPDIR)/libcares_la-ares__htable_strvp.Tpo -c -o dsa/libcares_la-ares__htable_strvp.lo `test -f 'dsa/ares__htable_strvp.c' || echo '$(srcdir)/'`dsa/ares__htable_strvp.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dsa/$(DEPDIR)/libcares_la-ares__htable_strvp.Tpo dsa/$(DEPDIR)/libcares_la-ares__htable_strvp.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dsa/ares__htable_strvp.c' object='dsa/libcares_la-ares__htable_strvp.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o dsa/libcares_la-ares__htable_strvp.lo `test -f 'dsa/ares__htable_strvp.c' || echo '$(srcdir)/'`dsa/ares__htable_strvp.c + +dsa/libcares_la-ares__htable_szvp.lo: dsa/ares__htable_szvp.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT dsa/libcares_la-ares__htable_szvp.lo -MD -MP -MF dsa/$(DEPDIR)/libcares_la-ares__htable_szvp.Tpo -c -o dsa/libcares_la-ares__htable_szvp.lo `test -f 'dsa/ares__htable_szvp.c' || echo '$(srcdir)/'`dsa/ares__htable_szvp.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dsa/$(DEPDIR)/libcares_la-ares__htable_szvp.Tpo dsa/$(DEPDIR)/libcares_la-ares__htable_szvp.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dsa/ares__htable_szvp.c' object='dsa/libcares_la-ares__htable_szvp.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o dsa/libcares_la-ares__htable_szvp.lo `test -f 'dsa/ares__htable_szvp.c' || echo '$(srcdir)/'`dsa/ares__htable_szvp.c + +dsa/libcares_la-ares__htable_vpvp.lo: dsa/ares__htable_vpvp.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT dsa/libcares_la-ares__htable_vpvp.lo -MD -MP -MF dsa/$(DEPDIR)/libcares_la-ares__htable_vpvp.Tpo -c -o dsa/libcares_la-ares__htable_vpvp.lo `test -f 'dsa/ares__htable_vpvp.c' || echo '$(srcdir)/'`dsa/ares__htable_vpvp.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dsa/$(DEPDIR)/libcares_la-ares__htable_vpvp.Tpo dsa/$(DEPDIR)/libcares_la-ares__htable_vpvp.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dsa/ares__htable_vpvp.c' object='dsa/libcares_la-ares__htable_vpvp.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o dsa/libcares_la-ares__htable_vpvp.lo `test -f 'dsa/ares__htable_vpvp.c' || echo '$(srcdir)/'`dsa/ares__htable_vpvp.c + +dsa/libcares_la-ares__llist.lo: dsa/ares__llist.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT dsa/libcares_la-ares__llist.lo -MD -MP -MF dsa/$(DEPDIR)/libcares_la-ares__llist.Tpo -c -o dsa/libcares_la-ares__llist.lo `test -f 'dsa/ares__llist.c' || echo '$(srcdir)/'`dsa/ares__llist.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dsa/$(DEPDIR)/libcares_la-ares__llist.Tpo dsa/$(DEPDIR)/libcares_la-ares__llist.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dsa/ares__llist.c' object='dsa/libcares_la-ares__llist.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o dsa/libcares_la-ares__llist.lo `test -f 'dsa/ares__llist.c' || echo '$(srcdir)/'`dsa/ares__llist.c + +dsa/libcares_la-ares__slist.lo: dsa/ares__slist.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT dsa/libcares_la-ares__slist.lo -MD -MP -MF dsa/$(DEPDIR)/libcares_la-ares__slist.Tpo -c -o dsa/libcares_la-ares__slist.lo `test -f 'dsa/ares__slist.c' || echo '$(srcdir)/'`dsa/ares__slist.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dsa/$(DEPDIR)/libcares_la-ares__slist.Tpo dsa/$(DEPDIR)/libcares_la-ares__slist.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dsa/ares__slist.c' object='dsa/libcares_la-ares__slist.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o dsa/libcares_la-ares__slist.lo `test -f 'dsa/ares__slist.c' || echo '$(srcdir)/'`dsa/ares__slist.c + +event/libcares_la-ares_event_configchg.lo: event/ares_event_configchg.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT event/libcares_la-ares_event_configchg.lo -MD -MP -MF event/$(DEPDIR)/libcares_la-ares_event_configchg.Tpo -c -o event/libcares_la-ares_event_configchg.lo `test -f 'event/ares_event_configchg.c' || echo '$(srcdir)/'`event/ares_event_configchg.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) event/$(DEPDIR)/libcares_la-ares_event_configchg.Tpo event/$(DEPDIR)/libcares_la-ares_event_configchg.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='event/ares_event_configchg.c' object='event/libcares_la-ares_event_configchg.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o event/libcares_la-ares_event_configchg.lo `test -f 'event/ares_event_configchg.c' || echo '$(srcdir)/'`event/ares_event_configchg.c + +event/libcares_la-ares_event_epoll.lo: event/ares_event_epoll.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT event/libcares_la-ares_event_epoll.lo -MD -MP -MF event/$(DEPDIR)/libcares_la-ares_event_epoll.Tpo -c -o event/libcares_la-ares_event_epoll.lo `test -f 'event/ares_event_epoll.c' || echo '$(srcdir)/'`event/ares_event_epoll.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) event/$(DEPDIR)/libcares_la-ares_event_epoll.Tpo event/$(DEPDIR)/libcares_la-ares_event_epoll.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='event/ares_event_epoll.c' object='event/libcares_la-ares_event_epoll.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o event/libcares_la-ares_event_epoll.lo `test -f 'event/ares_event_epoll.c' || echo '$(srcdir)/'`event/ares_event_epoll.c + +event/libcares_la-ares_event_kqueue.lo: event/ares_event_kqueue.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT event/libcares_la-ares_event_kqueue.lo -MD -MP -MF event/$(DEPDIR)/libcares_la-ares_event_kqueue.Tpo -c -o event/libcares_la-ares_event_kqueue.lo `test -f 'event/ares_event_kqueue.c' || echo '$(srcdir)/'`event/ares_event_kqueue.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) event/$(DEPDIR)/libcares_la-ares_event_kqueue.Tpo event/$(DEPDIR)/libcares_la-ares_event_kqueue.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='event/ares_event_kqueue.c' object='event/libcares_la-ares_event_kqueue.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o event/libcares_la-ares_event_kqueue.lo `test -f 'event/ares_event_kqueue.c' || echo '$(srcdir)/'`event/ares_event_kqueue.c + +event/libcares_la-ares_event_poll.lo: event/ares_event_poll.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT event/libcares_la-ares_event_poll.lo -MD -MP -MF event/$(DEPDIR)/libcares_la-ares_event_poll.Tpo -c -o event/libcares_la-ares_event_poll.lo `test -f 'event/ares_event_poll.c' || echo '$(srcdir)/'`event/ares_event_poll.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) event/$(DEPDIR)/libcares_la-ares_event_poll.Tpo event/$(DEPDIR)/libcares_la-ares_event_poll.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='event/ares_event_poll.c' object='event/libcares_la-ares_event_poll.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o event/libcares_la-ares_event_poll.lo `test -f 'event/ares_event_poll.c' || echo '$(srcdir)/'`event/ares_event_poll.c + +event/libcares_la-ares_event_select.lo: event/ares_event_select.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT event/libcares_la-ares_event_select.lo -MD -MP -MF event/$(DEPDIR)/libcares_la-ares_event_select.Tpo -c -o event/libcares_la-ares_event_select.lo `test -f 'event/ares_event_select.c' || echo '$(srcdir)/'`event/ares_event_select.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) event/$(DEPDIR)/libcares_la-ares_event_select.Tpo event/$(DEPDIR)/libcares_la-ares_event_select.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='event/ares_event_select.c' object='event/libcares_la-ares_event_select.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o event/libcares_la-ares_event_select.lo `test -f 'event/ares_event_select.c' || echo '$(srcdir)/'`event/ares_event_select.c + +event/libcares_la-ares_event_thread.lo: event/ares_event_thread.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT event/libcares_la-ares_event_thread.lo -MD -MP -MF event/$(DEPDIR)/libcares_la-ares_event_thread.Tpo -c -o event/libcares_la-ares_event_thread.lo `test -f 'event/ares_event_thread.c' || echo '$(srcdir)/'`event/ares_event_thread.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) event/$(DEPDIR)/libcares_la-ares_event_thread.Tpo event/$(DEPDIR)/libcares_la-ares_event_thread.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='event/ares_event_thread.c' object='event/libcares_la-ares_event_thread.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o event/libcares_la-ares_event_thread.lo `test -f 'event/ares_event_thread.c' || echo '$(srcdir)/'`event/ares_event_thread.c + +event/libcares_la-ares_event_wake_pipe.lo: event/ares_event_wake_pipe.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT event/libcares_la-ares_event_wake_pipe.lo -MD -MP -MF event/$(DEPDIR)/libcares_la-ares_event_wake_pipe.Tpo -c -o event/libcares_la-ares_event_wake_pipe.lo `test -f 'event/ares_event_wake_pipe.c' || echo '$(srcdir)/'`event/ares_event_wake_pipe.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) event/$(DEPDIR)/libcares_la-ares_event_wake_pipe.Tpo event/$(DEPDIR)/libcares_la-ares_event_wake_pipe.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='event/ares_event_wake_pipe.c' object='event/libcares_la-ares_event_wake_pipe.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o event/libcares_la-ares_event_wake_pipe.lo `test -f 'event/ares_event_wake_pipe.c' || echo '$(srcdir)/'`event/ares_event_wake_pipe.c + +event/libcares_la-ares_event_win32.lo: event/ares_event_win32.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT event/libcares_la-ares_event_win32.lo -MD -MP -MF event/$(DEPDIR)/libcares_la-ares_event_win32.Tpo -c -o event/libcares_la-ares_event_win32.lo `test -f 'event/ares_event_win32.c' || echo '$(srcdir)/'`event/ares_event_win32.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) event/$(DEPDIR)/libcares_la-ares_event_win32.Tpo event/$(DEPDIR)/libcares_la-ares_event_win32.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='event/ares_event_win32.c' object='event/libcares_la-ares_event_win32.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o event/libcares_la-ares_event_win32.lo `test -f 'event/ares_event_win32.c' || echo '$(srcdir)/'`event/ares_event_win32.c + +legacy/libcares_la-ares_create_query.lo: legacy/ares_create_query.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT legacy/libcares_la-ares_create_query.lo -MD -MP -MF legacy/$(DEPDIR)/libcares_la-ares_create_query.Tpo -c -o legacy/libcares_la-ares_create_query.lo `test -f 'legacy/ares_create_query.c' || echo '$(srcdir)/'`legacy/ares_create_query.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) legacy/$(DEPDIR)/libcares_la-ares_create_query.Tpo legacy/$(DEPDIR)/libcares_la-ares_create_query.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='legacy/ares_create_query.c' object='legacy/libcares_la-ares_create_query.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o legacy/libcares_la-ares_create_query.lo `test -f 'legacy/ares_create_query.c' || echo '$(srcdir)/'`legacy/ares_create_query.c + +legacy/libcares_la-ares_expand_name.lo: legacy/ares_expand_name.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT legacy/libcares_la-ares_expand_name.lo -MD -MP -MF legacy/$(DEPDIR)/libcares_la-ares_expand_name.Tpo -c -o legacy/libcares_la-ares_expand_name.lo `test -f 'legacy/ares_expand_name.c' || echo '$(srcdir)/'`legacy/ares_expand_name.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) legacy/$(DEPDIR)/libcares_la-ares_expand_name.Tpo legacy/$(DEPDIR)/libcares_la-ares_expand_name.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='legacy/ares_expand_name.c' object='legacy/libcares_la-ares_expand_name.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o legacy/libcares_la-ares_expand_name.lo `test -f 'legacy/ares_expand_name.c' || echo '$(srcdir)/'`legacy/ares_expand_name.c + +legacy/libcares_la-ares_expand_string.lo: legacy/ares_expand_string.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT legacy/libcares_la-ares_expand_string.lo -MD -MP -MF legacy/$(DEPDIR)/libcares_la-ares_expand_string.Tpo -c -o legacy/libcares_la-ares_expand_string.lo `test -f 'legacy/ares_expand_string.c' || echo '$(srcdir)/'`legacy/ares_expand_string.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) legacy/$(DEPDIR)/libcares_la-ares_expand_string.Tpo legacy/$(DEPDIR)/libcares_la-ares_expand_string.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='legacy/ares_expand_string.c' object='legacy/libcares_la-ares_expand_string.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o legacy/libcares_la-ares_expand_string.lo `test -f 'legacy/ares_expand_string.c' || echo '$(srcdir)/'`legacy/ares_expand_string.c + +legacy/libcares_la-ares_fds.lo: legacy/ares_fds.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT legacy/libcares_la-ares_fds.lo -MD -MP -MF legacy/$(DEPDIR)/libcares_la-ares_fds.Tpo -c -o legacy/libcares_la-ares_fds.lo `test -f 'legacy/ares_fds.c' || echo '$(srcdir)/'`legacy/ares_fds.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) legacy/$(DEPDIR)/libcares_la-ares_fds.Tpo legacy/$(DEPDIR)/libcares_la-ares_fds.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='legacy/ares_fds.c' object='legacy/libcares_la-ares_fds.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o legacy/libcares_la-ares_fds.lo `test -f 'legacy/ares_fds.c' || echo '$(srcdir)/'`legacy/ares_fds.c + +legacy/libcares_la-ares_getsock.lo: legacy/ares_getsock.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT legacy/libcares_la-ares_getsock.lo -MD -MP -MF legacy/$(DEPDIR)/libcares_la-ares_getsock.Tpo -c -o legacy/libcares_la-ares_getsock.lo `test -f 'legacy/ares_getsock.c' || echo '$(srcdir)/'`legacy/ares_getsock.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) legacy/$(DEPDIR)/libcares_la-ares_getsock.Tpo legacy/$(DEPDIR)/libcares_la-ares_getsock.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='legacy/ares_getsock.c' object='legacy/libcares_la-ares_getsock.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o legacy/libcares_la-ares_getsock.lo `test -f 'legacy/ares_getsock.c' || echo '$(srcdir)/'`legacy/ares_getsock.c + +legacy/libcares_la-ares_parse_a_reply.lo: legacy/ares_parse_a_reply.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT legacy/libcares_la-ares_parse_a_reply.lo -MD -MP -MF legacy/$(DEPDIR)/libcares_la-ares_parse_a_reply.Tpo -c -o legacy/libcares_la-ares_parse_a_reply.lo `test -f 'legacy/ares_parse_a_reply.c' || echo '$(srcdir)/'`legacy/ares_parse_a_reply.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) legacy/$(DEPDIR)/libcares_la-ares_parse_a_reply.Tpo legacy/$(DEPDIR)/libcares_la-ares_parse_a_reply.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='legacy/ares_parse_a_reply.c' object='legacy/libcares_la-ares_parse_a_reply.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o legacy/libcares_la-ares_parse_a_reply.lo `test -f 'legacy/ares_parse_a_reply.c' || echo '$(srcdir)/'`legacy/ares_parse_a_reply.c + +legacy/libcares_la-ares_parse_aaaa_reply.lo: legacy/ares_parse_aaaa_reply.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT legacy/libcares_la-ares_parse_aaaa_reply.lo -MD -MP -MF legacy/$(DEPDIR)/libcares_la-ares_parse_aaaa_reply.Tpo -c -o legacy/libcares_la-ares_parse_aaaa_reply.lo `test -f 'legacy/ares_parse_aaaa_reply.c' || echo '$(srcdir)/'`legacy/ares_parse_aaaa_reply.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) legacy/$(DEPDIR)/libcares_la-ares_parse_aaaa_reply.Tpo legacy/$(DEPDIR)/libcares_la-ares_parse_aaaa_reply.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='legacy/ares_parse_aaaa_reply.c' object='legacy/libcares_la-ares_parse_aaaa_reply.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o legacy/libcares_la-ares_parse_aaaa_reply.lo `test -f 'legacy/ares_parse_aaaa_reply.c' || echo '$(srcdir)/'`legacy/ares_parse_aaaa_reply.c + +legacy/libcares_la-ares_parse_caa_reply.lo: legacy/ares_parse_caa_reply.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT legacy/libcares_la-ares_parse_caa_reply.lo -MD -MP -MF legacy/$(DEPDIR)/libcares_la-ares_parse_caa_reply.Tpo -c -o legacy/libcares_la-ares_parse_caa_reply.lo `test -f 'legacy/ares_parse_caa_reply.c' || echo '$(srcdir)/'`legacy/ares_parse_caa_reply.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) legacy/$(DEPDIR)/libcares_la-ares_parse_caa_reply.Tpo legacy/$(DEPDIR)/libcares_la-ares_parse_caa_reply.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='legacy/ares_parse_caa_reply.c' object='legacy/libcares_la-ares_parse_caa_reply.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o legacy/libcares_la-ares_parse_caa_reply.lo `test -f 'legacy/ares_parse_caa_reply.c' || echo '$(srcdir)/'`legacy/ares_parse_caa_reply.c + +legacy/libcares_la-ares_parse_mx_reply.lo: legacy/ares_parse_mx_reply.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT legacy/libcares_la-ares_parse_mx_reply.lo -MD -MP -MF legacy/$(DEPDIR)/libcares_la-ares_parse_mx_reply.Tpo -c -o legacy/libcares_la-ares_parse_mx_reply.lo `test -f 'legacy/ares_parse_mx_reply.c' || echo '$(srcdir)/'`legacy/ares_parse_mx_reply.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) legacy/$(DEPDIR)/libcares_la-ares_parse_mx_reply.Tpo legacy/$(DEPDIR)/libcares_la-ares_parse_mx_reply.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='legacy/ares_parse_mx_reply.c' object='legacy/libcares_la-ares_parse_mx_reply.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o legacy/libcares_la-ares_parse_mx_reply.lo `test -f 'legacy/ares_parse_mx_reply.c' || echo '$(srcdir)/'`legacy/ares_parse_mx_reply.c + +legacy/libcares_la-ares_parse_naptr_reply.lo: legacy/ares_parse_naptr_reply.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT legacy/libcares_la-ares_parse_naptr_reply.lo -MD -MP -MF legacy/$(DEPDIR)/libcares_la-ares_parse_naptr_reply.Tpo -c -o legacy/libcares_la-ares_parse_naptr_reply.lo `test -f 'legacy/ares_parse_naptr_reply.c' || echo '$(srcdir)/'`legacy/ares_parse_naptr_reply.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) legacy/$(DEPDIR)/libcares_la-ares_parse_naptr_reply.Tpo legacy/$(DEPDIR)/libcares_la-ares_parse_naptr_reply.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='legacy/ares_parse_naptr_reply.c' object='legacy/libcares_la-ares_parse_naptr_reply.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o legacy/libcares_la-ares_parse_naptr_reply.lo `test -f 'legacy/ares_parse_naptr_reply.c' || echo '$(srcdir)/'`legacy/ares_parse_naptr_reply.c + +legacy/libcares_la-ares_parse_ns_reply.lo: legacy/ares_parse_ns_reply.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT legacy/libcares_la-ares_parse_ns_reply.lo -MD -MP -MF legacy/$(DEPDIR)/libcares_la-ares_parse_ns_reply.Tpo -c -o legacy/libcares_la-ares_parse_ns_reply.lo `test -f 'legacy/ares_parse_ns_reply.c' || echo '$(srcdir)/'`legacy/ares_parse_ns_reply.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) legacy/$(DEPDIR)/libcares_la-ares_parse_ns_reply.Tpo legacy/$(DEPDIR)/libcares_la-ares_parse_ns_reply.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='legacy/ares_parse_ns_reply.c' object='legacy/libcares_la-ares_parse_ns_reply.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o legacy/libcares_la-ares_parse_ns_reply.lo `test -f 'legacy/ares_parse_ns_reply.c' || echo '$(srcdir)/'`legacy/ares_parse_ns_reply.c + +legacy/libcares_la-ares_parse_ptr_reply.lo: legacy/ares_parse_ptr_reply.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT legacy/libcares_la-ares_parse_ptr_reply.lo -MD -MP -MF legacy/$(DEPDIR)/libcares_la-ares_parse_ptr_reply.Tpo -c -o legacy/libcares_la-ares_parse_ptr_reply.lo `test -f 'legacy/ares_parse_ptr_reply.c' || echo '$(srcdir)/'`legacy/ares_parse_ptr_reply.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) legacy/$(DEPDIR)/libcares_la-ares_parse_ptr_reply.Tpo legacy/$(DEPDIR)/libcares_la-ares_parse_ptr_reply.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='legacy/ares_parse_ptr_reply.c' object='legacy/libcares_la-ares_parse_ptr_reply.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o legacy/libcares_la-ares_parse_ptr_reply.lo `test -f 'legacy/ares_parse_ptr_reply.c' || echo '$(srcdir)/'`legacy/ares_parse_ptr_reply.c + +legacy/libcares_la-ares_parse_soa_reply.lo: legacy/ares_parse_soa_reply.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT legacy/libcares_la-ares_parse_soa_reply.lo -MD -MP -MF legacy/$(DEPDIR)/libcares_la-ares_parse_soa_reply.Tpo -c -o legacy/libcares_la-ares_parse_soa_reply.lo `test -f 'legacy/ares_parse_soa_reply.c' || echo '$(srcdir)/'`legacy/ares_parse_soa_reply.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) legacy/$(DEPDIR)/libcares_la-ares_parse_soa_reply.Tpo legacy/$(DEPDIR)/libcares_la-ares_parse_soa_reply.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='legacy/ares_parse_soa_reply.c' object='legacy/libcares_la-ares_parse_soa_reply.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o legacy/libcares_la-ares_parse_soa_reply.lo `test -f 'legacy/ares_parse_soa_reply.c' || echo '$(srcdir)/'`legacy/ares_parse_soa_reply.c + +legacy/libcares_la-ares_parse_srv_reply.lo: legacy/ares_parse_srv_reply.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT legacy/libcares_la-ares_parse_srv_reply.lo -MD -MP -MF legacy/$(DEPDIR)/libcares_la-ares_parse_srv_reply.Tpo -c -o legacy/libcares_la-ares_parse_srv_reply.lo `test -f 'legacy/ares_parse_srv_reply.c' || echo '$(srcdir)/'`legacy/ares_parse_srv_reply.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) legacy/$(DEPDIR)/libcares_la-ares_parse_srv_reply.Tpo legacy/$(DEPDIR)/libcares_la-ares_parse_srv_reply.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='legacy/ares_parse_srv_reply.c' object='legacy/libcares_la-ares_parse_srv_reply.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o legacy/libcares_la-ares_parse_srv_reply.lo `test -f 'legacy/ares_parse_srv_reply.c' || echo '$(srcdir)/'`legacy/ares_parse_srv_reply.c + +legacy/libcares_la-ares_parse_txt_reply.lo: legacy/ares_parse_txt_reply.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT legacy/libcares_la-ares_parse_txt_reply.lo -MD -MP -MF legacy/$(DEPDIR)/libcares_la-ares_parse_txt_reply.Tpo -c -o legacy/libcares_la-ares_parse_txt_reply.lo `test -f 'legacy/ares_parse_txt_reply.c' || echo '$(srcdir)/'`legacy/ares_parse_txt_reply.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) legacy/$(DEPDIR)/libcares_la-ares_parse_txt_reply.Tpo legacy/$(DEPDIR)/libcares_la-ares_parse_txt_reply.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='legacy/ares_parse_txt_reply.c' object='legacy/libcares_la-ares_parse_txt_reply.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o legacy/libcares_la-ares_parse_txt_reply.lo `test -f 'legacy/ares_parse_txt_reply.c' || echo '$(srcdir)/'`legacy/ares_parse_txt_reply.c + +legacy/libcares_la-ares_parse_uri_reply.lo: legacy/ares_parse_uri_reply.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT legacy/libcares_la-ares_parse_uri_reply.lo -MD -MP -MF legacy/$(DEPDIR)/libcares_la-ares_parse_uri_reply.Tpo -c -o legacy/libcares_la-ares_parse_uri_reply.lo `test -f 'legacy/ares_parse_uri_reply.c' || echo '$(srcdir)/'`legacy/ares_parse_uri_reply.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) legacy/$(DEPDIR)/libcares_la-ares_parse_uri_reply.Tpo legacy/$(DEPDIR)/libcares_la-ares_parse_uri_reply.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='legacy/ares_parse_uri_reply.c' object='legacy/libcares_la-ares_parse_uri_reply.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o legacy/libcares_la-ares_parse_uri_reply.lo `test -f 'legacy/ares_parse_uri_reply.c' || echo '$(srcdir)/'`legacy/ares_parse_uri_reply.c + +record/libcares_la-ares_dns_mapping.lo: record/ares_dns_mapping.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT record/libcares_la-ares_dns_mapping.lo -MD -MP -MF record/$(DEPDIR)/libcares_la-ares_dns_mapping.Tpo -c -o record/libcares_la-ares_dns_mapping.lo `test -f 'record/ares_dns_mapping.c' || echo '$(srcdir)/'`record/ares_dns_mapping.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) record/$(DEPDIR)/libcares_la-ares_dns_mapping.Tpo record/$(DEPDIR)/libcares_la-ares_dns_mapping.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='record/ares_dns_mapping.c' object='record/libcares_la-ares_dns_mapping.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o record/libcares_la-ares_dns_mapping.lo `test -f 'record/ares_dns_mapping.c' || echo '$(srcdir)/'`record/ares_dns_mapping.c + +record/libcares_la-ares_dns_multistring.lo: record/ares_dns_multistring.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT record/libcares_la-ares_dns_multistring.lo -MD -MP -MF record/$(DEPDIR)/libcares_la-ares_dns_multistring.Tpo -c -o record/libcares_la-ares_dns_multistring.lo `test -f 'record/ares_dns_multistring.c' || echo '$(srcdir)/'`record/ares_dns_multistring.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) record/$(DEPDIR)/libcares_la-ares_dns_multistring.Tpo record/$(DEPDIR)/libcares_la-ares_dns_multistring.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='record/ares_dns_multistring.c' object='record/libcares_la-ares_dns_multistring.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o record/libcares_la-ares_dns_multistring.lo `test -f 'record/ares_dns_multistring.c' || echo '$(srcdir)/'`record/ares_dns_multistring.c + +record/libcares_la-ares_dns_name.lo: record/ares_dns_name.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT record/libcares_la-ares_dns_name.lo -MD -MP -MF record/$(DEPDIR)/libcares_la-ares_dns_name.Tpo -c -o record/libcares_la-ares_dns_name.lo `test -f 'record/ares_dns_name.c' || echo '$(srcdir)/'`record/ares_dns_name.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) record/$(DEPDIR)/libcares_la-ares_dns_name.Tpo record/$(DEPDIR)/libcares_la-ares_dns_name.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='record/ares_dns_name.c' object='record/libcares_la-ares_dns_name.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o record/libcares_la-ares_dns_name.lo `test -f 'record/ares_dns_name.c' || echo '$(srcdir)/'`record/ares_dns_name.c + +record/libcares_la-ares_dns_parse.lo: record/ares_dns_parse.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT record/libcares_la-ares_dns_parse.lo -MD -MP -MF record/$(DEPDIR)/libcares_la-ares_dns_parse.Tpo -c -o record/libcares_la-ares_dns_parse.lo `test -f 'record/ares_dns_parse.c' || echo '$(srcdir)/'`record/ares_dns_parse.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) record/$(DEPDIR)/libcares_la-ares_dns_parse.Tpo record/$(DEPDIR)/libcares_la-ares_dns_parse.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='record/ares_dns_parse.c' object='record/libcares_la-ares_dns_parse.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o record/libcares_la-ares_dns_parse.lo `test -f 'record/ares_dns_parse.c' || echo '$(srcdir)/'`record/ares_dns_parse.c + +record/libcares_la-ares_dns_record.lo: record/ares_dns_record.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT record/libcares_la-ares_dns_record.lo -MD -MP -MF record/$(DEPDIR)/libcares_la-ares_dns_record.Tpo -c -o record/libcares_la-ares_dns_record.lo `test -f 'record/ares_dns_record.c' || echo '$(srcdir)/'`record/ares_dns_record.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) record/$(DEPDIR)/libcares_la-ares_dns_record.Tpo record/$(DEPDIR)/libcares_la-ares_dns_record.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='record/ares_dns_record.c' object='record/libcares_la-ares_dns_record.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o record/libcares_la-ares_dns_record.lo `test -f 'record/ares_dns_record.c' || echo '$(srcdir)/'`record/ares_dns_record.c + +record/libcares_la-ares_dns_write.lo: record/ares_dns_write.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT record/libcares_la-ares_dns_write.lo -MD -MP -MF record/$(DEPDIR)/libcares_la-ares_dns_write.Tpo -c -o record/libcares_la-ares_dns_write.lo `test -f 'record/ares_dns_write.c' || echo '$(srcdir)/'`record/ares_dns_write.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) record/$(DEPDIR)/libcares_la-ares_dns_write.Tpo record/$(DEPDIR)/libcares_la-ares_dns_write.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='record/ares_dns_write.c' object='record/libcares_la-ares_dns_write.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o record/libcares_la-ares_dns_write.lo `test -f 'record/ares_dns_write.c' || echo '$(srcdir)/'`record/ares_dns_write.c + +str/libcares_la-ares__buf.lo: str/ares__buf.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT str/libcares_la-ares__buf.lo -MD -MP -MF str/$(DEPDIR)/libcares_la-ares__buf.Tpo -c -o str/libcares_la-ares__buf.lo `test -f 'str/ares__buf.c' || echo '$(srcdir)/'`str/ares__buf.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) str/$(DEPDIR)/libcares_la-ares__buf.Tpo str/$(DEPDIR)/libcares_la-ares__buf.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='str/ares__buf.c' object='str/libcares_la-ares__buf.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o str/libcares_la-ares__buf.lo `test -f 'str/ares__buf.c' || echo '$(srcdir)/'`str/ares__buf.c + +str/libcares_la-ares_strcasecmp.lo: str/ares_strcasecmp.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT str/libcares_la-ares_strcasecmp.lo -MD -MP -MF str/$(DEPDIR)/libcares_la-ares_strcasecmp.Tpo -c -o str/libcares_la-ares_strcasecmp.lo `test -f 'str/ares_strcasecmp.c' || echo '$(srcdir)/'`str/ares_strcasecmp.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) str/$(DEPDIR)/libcares_la-ares_strcasecmp.Tpo str/$(DEPDIR)/libcares_la-ares_strcasecmp.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='str/ares_strcasecmp.c' object='str/libcares_la-ares_strcasecmp.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o str/libcares_la-ares_strcasecmp.lo `test -f 'str/ares_strcasecmp.c' || echo '$(srcdir)/'`str/ares_strcasecmp.c + +str/libcares_la-ares_str.lo: str/ares_str.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT str/libcares_la-ares_str.lo -MD -MP -MF str/$(DEPDIR)/libcares_la-ares_str.Tpo -c -o str/libcares_la-ares_str.lo `test -f 'str/ares_str.c' || echo '$(srcdir)/'`str/ares_str.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) str/$(DEPDIR)/libcares_la-ares_str.Tpo str/$(DEPDIR)/libcares_la-ares_str.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='str/ares_str.c' object='str/libcares_la-ares_str.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o str/libcares_la-ares_str.lo `test -f 'str/ares_str.c' || echo '$(srcdir)/'`str/ares_str.c + +str/libcares_la-ares_strsplit.lo: str/ares_strsplit.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT str/libcares_la-ares_strsplit.lo -MD -MP -MF str/$(DEPDIR)/libcares_la-ares_strsplit.Tpo -c -o str/libcares_la-ares_strsplit.lo `test -f 'str/ares_strsplit.c' || echo '$(srcdir)/'`str/ares_strsplit.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) str/$(DEPDIR)/libcares_la-ares_strsplit.Tpo str/$(DEPDIR)/libcares_la-ares_strsplit.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='str/ares_strsplit.c' object='str/libcares_la-ares_strsplit.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o str/libcares_la-ares_strsplit.lo `test -f 'str/ares_strsplit.c' || echo '$(srcdir)/'`str/ares_strsplit.c + +util/libcares_la-ares__iface_ips.lo: util/ares__iface_ips.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT util/libcares_la-ares__iface_ips.lo -MD -MP -MF util/$(DEPDIR)/libcares_la-ares__iface_ips.Tpo -c -o util/libcares_la-ares__iface_ips.lo `test -f 'util/ares__iface_ips.c' || echo '$(srcdir)/'`util/ares__iface_ips.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) util/$(DEPDIR)/libcares_la-ares__iface_ips.Tpo util/$(DEPDIR)/libcares_la-ares__iface_ips.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='util/ares__iface_ips.c' object='util/libcares_la-ares__iface_ips.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o util/libcares_la-ares__iface_ips.lo `test -f 'util/ares__iface_ips.c' || echo '$(srcdir)/'`util/ares__iface_ips.c + +util/libcares_la-ares__threads.lo: util/ares__threads.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT util/libcares_la-ares__threads.lo -MD -MP -MF util/$(DEPDIR)/libcares_la-ares__threads.Tpo -c -o util/libcares_la-ares__threads.lo `test -f 'util/ares__threads.c' || echo '$(srcdir)/'`util/ares__threads.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) util/$(DEPDIR)/libcares_la-ares__threads.Tpo util/$(DEPDIR)/libcares_la-ares__threads.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='util/ares__threads.c' object='util/libcares_la-ares__threads.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o util/libcares_la-ares__threads.lo `test -f 'util/ares__threads.c' || echo '$(srcdir)/'`util/ares__threads.c + +util/libcares_la-ares__timeval.lo: util/ares__timeval.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT util/libcares_la-ares__timeval.lo -MD -MP -MF util/$(DEPDIR)/libcares_la-ares__timeval.Tpo -c -o util/libcares_la-ares__timeval.lo `test -f 'util/ares__timeval.c' || echo '$(srcdir)/'`util/ares__timeval.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) util/$(DEPDIR)/libcares_la-ares__timeval.Tpo util/$(DEPDIR)/libcares_la-ares__timeval.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='util/ares__timeval.c' object='util/libcares_la-ares__timeval.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o util/libcares_la-ares__timeval.lo `test -f 'util/ares__timeval.c' || echo '$(srcdir)/'`util/ares__timeval.c + +util/libcares_la-ares_math.lo: util/ares_math.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT util/libcares_la-ares_math.lo -MD -MP -MF util/$(DEPDIR)/libcares_la-ares_math.Tpo -c -o util/libcares_la-ares_math.lo `test -f 'util/ares_math.c' || echo '$(srcdir)/'`util/ares_math.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) util/$(DEPDIR)/libcares_la-ares_math.Tpo util/$(DEPDIR)/libcares_la-ares_math.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='util/ares_math.c' object='util/libcares_la-ares_math.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o util/libcares_la-ares_math.lo `test -f 'util/ares_math.c' || echo '$(srcdir)/'`util/ares_math.c + +util/libcares_la-ares_rand.lo: util/ares_rand.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT util/libcares_la-ares_rand.lo -MD -MP -MF util/$(DEPDIR)/libcares_la-ares_rand.Tpo -c -o util/libcares_la-ares_rand.lo `test -f 'util/ares_rand.c' || echo '$(srcdir)/'`util/ares_rand.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) util/$(DEPDIR)/libcares_la-ares_rand.Tpo util/$(DEPDIR)/libcares_la-ares_rand.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='util/ares_rand.c' object='util/libcares_la-ares_rand.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o util/libcares_la-ares_rand.lo `test -f 'util/ares_rand.c' || echo '$(srcdir)/'`util/ares_rand.c + mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs + -rm -rf dsa/.libs dsa/_libs + -rm -rf event/.libs event/_libs + -rm -rf legacy/.libs legacy/_libs + -rm -rf record/.libs record/_libs + -rm -rf str/.libs str/_libs + -rm -rf util/.libs util/_libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. @@ -1751,9 +1933,21 @@ mostlyclean-generic: clean-generic: distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + -$(am__rm_f) $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || $(am__rm_f) $(CONFIG_CLEAN_VPATH_FILES) + -$(am__rm_f) $(DISTCLEANFILES) + -$(am__rm_f) dsa/$(DEPDIR)/$(am__dirstamp) + -$(am__rm_f) dsa/$(am__dirstamp) + -$(am__rm_f) event/$(DEPDIR)/$(am__dirstamp) + -$(am__rm_f) event/$(am__dirstamp) + -$(am__rm_f) legacy/$(DEPDIR)/$(am__dirstamp) + -$(am__rm_f) legacy/$(am__dirstamp) + -$(am__rm_f) record/$(DEPDIR)/$(am__dirstamp) + -$(am__rm_f) record/$(am__dirstamp) + -$(am__rm_f) str/$(DEPDIR)/$(am__dirstamp) + -$(am__rm_f) str/$(am__dirstamp) + -$(am__rm_f) util/$(DEPDIR)/$(am__dirstamp) + -$(am__rm_f) util/$(am__dirstamp) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @@ -1764,46 +1958,18 @@ clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-recursive - -rm -f ./$(DEPDIR)/libcares_la-ares__addrinfo2hostent.Plo + -rm -f ./$(DEPDIR)/libcares_la-ares__addrinfo2hostent.Plo -rm -f ./$(DEPDIR)/libcares_la-ares__addrinfo_localhost.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares__buf.Plo -rm -f ./$(DEPDIR)/libcares_la-ares__close_sockets.Plo -rm -f ./$(DEPDIR)/libcares_la-ares__hosts_file.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares__htable.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares__htable_asvp.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares__htable_strvp.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares__htable_szvp.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares__htable_vpvp.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares__iface_ips.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares__llist.Plo -rm -f ./$(DEPDIR)/libcares_la-ares__parse_into_addrinfo.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares__slist.Plo -rm -f ./$(DEPDIR)/libcares_la-ares__socket.Plo -rm -f ./$(DEPDIR)/libcares_la-ares__sortaddrinfo.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares__threads.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares__timeval.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_android.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_cancel.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_create_query.Plo + -rm -f ./$(DEPDIR)/libcares_la-ares_cookie.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_data.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_destroy.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_dns_mapping.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_dns_multistring.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_dns_name.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_dns_parse.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_dns_record.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_dns_write.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_event_configchg.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_event_epoll.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_event_kqueue.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_event_poll.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_event_select.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_event_thread.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_event_wake_pipe.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_event_win32.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_expand_name.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_expand_string.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_fds.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_free_hostent.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_free_string.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_freeaddrinfo.Plo @@ -1812,34 +1978,17 @@ distclean: distclean-recursive -rm -f ./$(DEPDIR)/libcares_la-ares_gethostbyaddr.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_gethostbyname.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_getnameinfo.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_getsock.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_init.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_library_init.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_math.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_metrics.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_options.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_parse_a_reply.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_parse_aaaa_reply.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_parse_caa_reply.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_parse_mx_reply.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_parse_naptr_reply.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_parse_ns_reply.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_parse_ptr_reply.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_parse_soa_reply.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_parse_srv_reply.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_parse_txt_reply.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_parse_uri_reply.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_platform.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_process.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_qcache.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_query.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_rand.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_search.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_send.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_str.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_strcasecmp.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_strerror.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_strsplit.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_sysconfig.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_sysconfig_files.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_sysconfig_mac.Plo @@ -1850,6 +1999,53 @@ distclean: distclean-recursive -rm -f ./$(DEPDIR)/libcares_la-inet_net_pton.Plo -rm -f ./$(DEPDIR)/libcares_la-inet_ntop.Plo -rm -f ./$(DEPDIR)/libcares_la-windows_port.Plo + -rm -f dsa/$(DEPDIR)/libcares_la-ares__array.Plo + -rm -f dsa/$(DEPDIR)/libcares_la-ares__htable.Plo + -rm -f dsa/$(DEPDIR)/libcares_la-ares__htable_asvp.Plo + -rm -f dsa/$(DEPDIR)/libcares_la-ares__htable_strvp.Plo + -rm -f dsa/$(DEPDIR)/libcares_la-ares__htable_szvp.Plo + -rm -f dsa/$(DEPDIR)/libcares_la-ares__htable_vpvp.Plo + -rm -f dsa/$(DEPDIR)/libcares_la-ares__llist.Plo + -rm -f dsa/$(DEPDIR)/libcares_la-ares__slist.Plo + -rm -f event/$(DEPDIR)/libcares_la-ares_event_configchg.Plo + -rm -f event/$(DEPDIR)/libcares_la-ares_event_epoll.Plo + -rm -f event/$(DEPDIR)/libcares_la-ares_event_kqueue.Plo + -rm -f event/$(DEPDIR)/libcares_la-ares_event_poll.Plo + -rm -f event/$(DEPDIR)/libcares_la-ares_event_select.Plo + -rm -f event/$(DEPDIR)/libcares_la-ares_event_thread.Plo + -rm -f event/$(DEPDIR)/libcares_la-ares_event_wake_pipe.Plo + -rm -f event/$(DEPDIR)/libcares_la-ares_event_win32.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_create_query.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_expand_name.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_expand_string.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_fds.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_getsock.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_parse_a_reply.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_parse_aaaa_reply.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_parse_caa_reply.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_parse_mx_reply.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_parse_naptr_reply.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_parse_ns_reply.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_parse_ptr_reply.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_parse_soa_reply.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_parse_srv_reply.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_parse_txt_reply.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_parse_uri_reply.Plo + -rm -f record/$(DEPDIR)/libcares_la-ares_dns_mapping.Plo + -rm -f record/$(DEPDIR)/libcares_la-ares_dns_multistring.Plo + -rm -f record/$(DEPDIR)/libcares_la-ares_dns_name.Plo + -rm -f record/$(DEPDIR)/libcares_la-ares_dns_parse.Plo + -rm -f record/$(DEPDIR)/libcares_la-ares_dns_record.Plo + -rm -f record/$(DEPDIR)/libcares_la-ares_dns_write.Plo + -rm -f str/$(DEPDIR)/libcares_la-ares__buf.Plo + -rm -f str/$(DEPDIR)/libcares_la-ares_str.Plo + -rm -f str/$(DEPDIR)/libcares_la-ares_strcasecmp.Plo + -rm -f str/$(DEPDIR)/libcares_la-ares_strsplit.Plo + -rm -f util/$(DEPDIR)/libcares_la-ares__iface_ips.Plo + -rm -f util/$(DEPDIR)/libcares_la-ares__threads.Plo + -rm -f util/$(DEPDIR)/libcares_la-ares__timeval.Plo + -rm -f util/$(DEPDIR)/libcares_la-ares_math.Plo + -rm -f util/$(DEPDIR)/libcares_la-ares_rand.Plo -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-tags @@ -1895,46 +2091,18 @@ install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive - -rm -f ./$(DEPDIR)/libcares_la-ares__addrinfo2hostent.Plo + -rm -f ./$(DEPDIR)/libcares_la-ares__addrinfo2hostent.Plo -rm -f ./$(DEPDIR)/libcares_la-ares__addrinfo_localhost.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares__buf.Plo -rm -f ./$(DEPDIR)/libcares_la-ares__close_sockets.Plo -rm -f ./$(DEPDIR)/libcares_la-ares__hosts_file.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares__htable.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares__htable_asvp.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares__htable_strvp.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares__htable_szvp.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares__htable_vpvp.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares__iface_ips.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares__llist.Plo -rm -f ./$(DEPDIR)/libcares_la-ares__parse_into_addrinfo.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares__slist.Plo -rm -f ./$(DEPDIR)/libcares_la-ares__socket.Plo -rm -f ./$(DEPDIR)/libcares_la-ares__sortaddrinfo.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares__threads.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares__timeval.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_android.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_cancel.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_create_query.Plo + -rm -f ./$(DEPDIR)/libcares_la-ares_cookie.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_data.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_destroy.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_dns_mapping.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_dns_multistring.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_dns_name.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_dns_parse.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_dns_record.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_dns_write.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_event_configchg.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_event_epoll.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_event_kqueue.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_event_poll.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_event_select.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_event_thread.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_event_wake_pipe.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_event_win32.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_expand_name.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_expand_string.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_fds.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_free_hostent.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_free_string.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_freeaddrinfo.Plo @@ -1943,34 +2111,17 @@ maintainer-clean: maintainer-clean-recursive -rm -f ./$(DEPDIR)/libcares_la-ares_gethostbyaddr.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_gethostbyname.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_getnameinfo.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_getsock.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_init.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_library_init.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_math.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_metrics.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_options.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_parse_a_reply.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_parse_aaaa_reply.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_parse_caa_reply.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_parse_mx_reply.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_parse_naptr_reply.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_parse_ns_reply.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_parse_ptr_reply.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_parse_soa_reply.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_parse_srv_reply.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_parse_txt_reply.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_parse_uri_reply.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_platform.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_process.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_qcache.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_query.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_rand.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_search.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_send.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_str.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_strcasecmp.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_strerror.Plo - -rm -f ./$(DEPDIR)/libcares_la-ares_strsplit.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_sysconfig.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_sysconfig_files.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_sysconfig_mac.Plo @@ -1981,6 +2132,53 @@ maintainer-clean: maintainer-clean-recursive -rm -f ./$(DEPDIR)/libcares_la-inet_net_pton.Plo -rm -f ./$(DEPDIR)/libcares_la-inet_ntop.Plo -rm -f ./$(DEPDIR)/libcares_la-windows_port.Plo + -rm -f dsa/$(DEPDIR)/libcares_la-ares__array.Plo + -rm -f dsa/$(DEPDIR)/libcares_la-ares__htable.Plo + -rm -f dsa/$(DEPDIR)/libcares_la-ares__htable_asvp.Plo + -rm -f dsa/$(DEPDIR)/libcares_la-ares__htable_strvp.Plo + -rm -f dsa/$(DEPDIR)/libcares_la-ares__htable_szvp.Plo + -rm -f dsa/$(DEPDIR)/libcares_la-ares__htable_vpvp.Plo + -rm -f dsa/$(DEPDIR)/libcares_la-ares__llist.Plo + -rm -f dsa/$(DEPDIR)/libcares_la-ares__slist.Plo + -rm -f event/$(DEPDIR)/libcares_la-ares_event_configchg.Plo + -rm -f event/$(DEPDIR)/libcares_la-ares_event_epoll.Plo + -rm -f event/$(DEPDIR)/libcares_la-ares_event_kqueue.Plo + -rm -f event/$(DEPDIR)/libcares_la-ares_event_poll.Plo + -rm -f event/$(DEPDIR)/libcares_la-ares_event_select.Plo + -rm -f event/$(DEPDIR)/libcares_la-ares_event_thread.Plo + -rm -f event/$(DEPDIR)/libcares_la-ares_event_wake_pipe.Plo + -rm -f event/$(DEPDIR)/libcares_la-ares_event_win32.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_create_query.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_expand_name.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_expand_string.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_fds.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_getsock.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_parse_a_reply.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_parse_aaaa_reply.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_parse_caa_reply.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_parse_mx_reply.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_parse_naptr_reply.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_parse_ns_reply.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_parse_ptr_reply.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_parse_soa_reply.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_parse_srv_reply.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_parse_txt_reply.Plo + -rm -f legacy/$(DEPDIR)/libcares_la-ares_parse_uri_reply.Plo + -rm -f record/$(DEPDIR)/libcares_la-ares_dns_mapping.Plo + -rm -f record/$(DEPDIR)/libcares_la-ares_dns_multistring.Plo + -rm -f record/$(DEPDIR)/libcares_la-ares_dns_name.Plo + -rm -f record/$(DEPDIR)/libcares_la-ares_dns_parse.Plo + -rm -f record/$(DEPDIR)/libcares_la-ares_dns_record.Plo + -rm -f record/$(DEPDIR)/libcares_la-ares_dns_write.Plo + -rm -f str/$(DEPDIR)/libcares_la-ares__buf.Plo + -rm -f str/$(DEPDIR)/libcares_la-ares_str.Plo + -rm -f str/$(DEPDIR)/libcares_la-ares_strcasecmp.Plo + -rm -f str/$(DEPDIR)/libcares_la-ares_strsplit.Plo + -rm -f util/$(DEPDIR)/libcares_la-ares__iface_ips.Plo + -rm -f util/$(DEPDIR)/libcares_la-ares__threads.Plo + -rm -f util/$(DEPDIR)/libcares_la-ares__timeval.Plo + -rm -f util/$(DEPDIR)/libcares_la-ares_math.Plo + -rm -f util/$(DEPDIR)/libcares_la-ares_rand.Plo -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic @@ -2123,3 +2321,10 @@ code-coverage-capture-hook: # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: + +# Tell GNU make to disable its built-in pattern rules. +%:: %,v +%:: RCS/%,v +%:: RCS/% +%:: s.% +%:: SCCS/s.% diff --git a/lib/c-ares-1.33.1/src/lib/Makefile.inc b/lib/c-ares-1.33.1/src/lib/Makefile.inc new file mode 100644 index 00000000000..8fa434c3e2c --- /dev/null +++ b/lib/c-ares-1.33.1/src/lib/Makefile.inc @@ -0,0 +1,120 @@ +# Copyright (C) The c-ares project and its contributors +# SPDX-License-Identifier: MIT + +CSOURCES = ares__addrinfo2hostent.c \ + ares__addrinfo_localhost.c \ + ares__close_sockets.c \ + ares__hosts_file.c \ + ares__parse_into_addrinfo.c \ + ares__socket.c \ + ares__sortaddrinfo.c \ + ares_android.c \ + ares_cancel.c \ + ares_cookie.c \ + ares_data.c \ + ares_destroy.c \ + ares_free_hostent.c \ + ares_free_string.c \ + ares_freeaddrinfo.c \ + ares_getaddrinfo.c \ + ares_getenv.c \ + ares_gethostbyaddr.c \ + ares_gethostbyname.c \ + ares_getnameinfo.c \ + ares_init.c \ + ares_library_init.c \ + ares_metrics.c \ + ares_options.c \ + ares_platform.c \ + ares_process.c \ + ares_qcache.c \ + ares_query.c \ + ares_search.c \ + ares_send.c \ + ares_strerror.c \ + ares_sysconfig.c \ + ares_sysconfig_files.c \ + ares_sysconfig_mac.c \ + ares_sysconfig_win.c \ + ares_timeout.c \ + ares_update_servers.c \ + ares_version.c \ + inet_net_pton.c \ + inet_ntop.c \ + windows_port.c \ + dsa/ares__array.c \ + dsa/ares__htable.c \ + dsa/ares__htable_asvp.c \ + dsa/ares__htable_strvp.c \ + dsa/ares__htable_szvp.c \ + dsa/ares__htable_vpvp.c \ + dsa/ares__llist.c \ + dsa/ares__slist.c \ + event/ares_event_configchg.c \ + event/ares_event_epoll.c \ + event/ares_event_kqueue.c \ + event/ares_event_poll.c \ + event/ares_event_select.c \ + event/ares_event_thread.c \ + event/ares_event_wake_pipe.c \ + event/ares_event_win32.c \ + legacy/ares_create_query.c \ + legacy/ares_expand_name.c \ + legacy/ares_expand_string.c \ + legacy/ares_fds.c \ + legacy/ares_getsock.c \ + legacy/ares_parse_a_reply.c \ + legacy/ares_parse_aaaa_reply.c \ + legacy/ares_parse_caa_reply.c \ + legacy/ares_parse_mx_reply.c \ + legacy/ares_parse_naptr_reply.c \ + legacy/ares_parse_ns_reply.c \ + legacy/ares_parse_ptr_reply.c \ + legacy/ares_parse_soa_reply.c \ + legacy/ares_parse_srv_reply.c \ + legacy/ares_parse_txt_reply.c \ + legacy/ares_parse_uri_reply.c \ + record/ares_dns_mapping.c \ + record/ares_dns_multistring.c \ + record/ares_dns_name.c \ + record/ares_dns_parse.c \ + record/ares_dns_record.c \ + record/ares_dns_write.c \ + str/ares__buf.c \ + str/ares_strcasecmp.c \ + str/ares_str.c \ + str/ares_strsplit.c \ + util/ares__iface_ips.c \ + util/ares__threads.c \ + util/ares__timeval.c \ + util/ares_math.c \ + util/ares_rand.c + +HHEADERS = ares_android.h \ + ares_data.h \ + ares_getenv.h \ + ares_inet_net_pton.h \ + ares_ipv6.h \ + ares_platform.h \ + ares_private.h \ + ares_setup.h \ + dsa/ares__array.h \ + dsa/ares__htable.h \ + dsa/ares__htable_asvp.h \ + dsa/ares__htable_strvp.h \ + dsa/ares__htable_szvp.h \ + dsa/ares__htable_vpvp.h \ + dsa/ares__llist.h \ + dsa/ares__slist.h \ + event/ares_event.h \ + event/ares_event_win32.h \ + record/ares_dns_multistring.h \ + record/ares_dns_private.h \ + str/ares__buf.h \ + str/ares_strcasecmp.h \ + str/ares_str.h \ + str/ares_strsplit.h \ + util/ares__iface_ips.h \ + util/ares__threads.h \ + thirdparty/apple/dnsinfo.h + diff --git a/lib/c-ares-1.32.3/src/lib/ares__addrinfo2hostent.c b/lib/c-ares-1.33.1/src/lib/ares__addrinfo2hostent.c similarity index 90% rename from lib/c-ares-1.32.3/src/lib/ares__addrinfo2hostent.c rename to lib/c-ares-1.33.1/src/lib/ares__addrinfo2hostent.c index 9505af7340d..f7b6d1edd25 100644 --- a/lib/c-ares-1.32.3/src/lib/ares__addrinfo2hostent.c +++ b/lib/c-ares-1.33.1/src/lib/ares__addrinfo2hostent.c @@ -161,16 +161,16 @@ ares_status_t ares__addrinfo2hostent(const struct ares_addrinfo *ai, int family, } (*host)->h_addr_list[i] = addrs + (i * (size_t)(*host)->h_length); if (family == AF_INET6) { - memcpy( - (*host)->h_addr_list[i], - &(CARES_INADDR_CAST(const struct sockaddr_in6 *, next->ai_addr)->sin6_addr), - (size_t)(*host)->h_length); + memcpy((*host)->h_addr_list[i], + &(CARES_INADDR_CAST(const struct sockaddr_in6 *, next->ai_addr) + ->sin6_addr), + (size_t)(*host)->h_length); } if (family == AF_INET) { - memcpy( - (*host)->h_addr_list[i], - &(CARES_INADDR_CAST(const struct sockaddr_in *, next->ai_addr)->sin_addr), - (size_t)(*host)->h_length); + memcpy((*host)->h_addr_list[i], + &(CARES_INADDR_CAST(const struct sockaddr_in *, next->ai_addr) + ->sin_addr), + (size_t)(*host)->h_length); } ++i; } @@ -252,20 +252,20 @@ ares_status_t ares__addrinfo2addrttl(const struct ares_addrinfo *ai, int family, addr6ttls[*naddrttls].ttl = next->ai_ttl; } - memcpy( - &addr6ttls[*naddrttls].ip6addr, - &(CARES_INADDR_CAST(const struct sockaddr_in6 *, next->ai_addr)->sin6_addr), - sizeof(struct ares_in6_addr)); + memcpy(&addr6ttls[*naddrttls].ip6addr, + &(CARES_INADDR_CAST(const struct sockaddr_in6 *, next->ai_addr) + ->sin6_addr), + sizeof(struct ares_in6_addr)); } else { if (next->ai_ttl > cname_ttl) { addrttls[*naddrttls].ttl = cname_ttl; } else { addrttls[*naddrttls].ttl = next->ai_ttl; } - memcpy( - &addrttls[*naddrttls].ipaddr, - &(CARES_INADDR_CAST(const struct sockaddr_in *, next->ai_addr)->sin_addr), - sizeof(struct in_addr)); + memcpy(&addrttls[*naddrttls].ipaddr, + &(CARES_INADDR_CAST(const struct sockaddr_in *, next->ai_addr) + ->sin_addr), + sizeof(struct in_addr)); } (*naddrttls)++; } diff --git a/lib/c-ares-1.32.3/src/lib/ares__addrinfo_localhost.c b/lib/c-ares-1.33.1/src/lib/ares__addrinfo_localhost.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares__addrinfo_localhost.c rename to lib/c-ares-1.33.1/src/lib/ares__addrinfo_localhost.c diff --git a/lib/c-ares-1.32.3/src/lib/ares__close_sockets.c b/lib/c-ares-1.33.1/src/lib/ares__close_sockets.c similarity index 80% rename from lib/c-ares-1.32.3/src/lib/ares__close_sockets.c rename to lib/c-ares-1.33.1/src/lib/ares__close_sockets.c index 33a030c9d23..71c7e64f08a 100644 --- a/lib/c-ares-1.32.3/src/lib/ares__close_sockets.c +++ b/lib/c-ares-1.33.1/src/lib/ares__close_sockets.c @@ -28,31 +28,30 @@ #include "ares_private.h" #include -static void ares__requeue_queries(struct server_connection *conn, +static void ares__requeue_queries(ares_conn_t *conn, ares_status_t requeue_status) { - struct query *query; + ares_query_t *query; ares_timeval_t now; ares__tvnow(&now); while ((query = ares__llist_first_val(conn->queries_to_conn)) != NULL) { - ares__requeue_query(query, &now, requeue_status); + ares__requeue_query(query, &now, requeue_status, ARES_TRUE, NULL); } } -void ares__close_connection(struct server_connection *conn, - ares_status_t requeue_status) +void ares__close_connection(ares_conn_t *conn, ares_status_t requeue_status) { - struct server_state *server = conn->server; - ares_channel_t *channel = server->channel; + ares_server_t *server = conn->server; + ares_channel_t *channel = server->channel; /* Unlink */ ares__llist_node_claim( ares__htable_asvp_get_direct(channel->connnode_by_socket, conn->fd)); ares__htable_asvp_remove(channel->connnode_by_socket, conn->fd); - if (conn->is_tcp) { + if (conn->flags & ARES_CONN_FLAG_TCP) { /* Reset any existing input and output buffer. */ ares__buf_consume(server->tcp_parser, ares__buf_len(server->tcp_parser)); ares__buf_consume(server->tcp_send, ares__buf_len(server->tcp_send)); @@ -70,12 +69,12 @@ void ares__close_connection(struct server_connection *conn, ares_free(conn); } -void ares__close_sockets(struct server_state *server) +void ares__close_sockets(ares_server_t *server) { ares__llist_node_t *node; while ((node = ares__llist_node_first(server->connections)) != NULL) { - struct server_connection *conn = ares__llist_node_val(node); + ares_conn_t *conn = ares__llist_node_val(node); ares__close_connection(conn, ARES_SUCCESS); } } @@ -91,17 +90,16 @@ void ares__check_cleanup_conns(const ares_channel_t *channel) /* Iterate across each server */ for (snode = ares__slist_node_first(channel->servers); snode != NULL; snode = ares__slist_node_next(snode)) { - - struct server_state *server = ares__slist_node_val(snode); - ares__llist_node_t *cnode; + ares_server_t *server = ares__slist_node_val(snode); + ares__llist_node_t *cnode; /* Iterate across each connection */ cnode = ares__llist_node_first(server->connections); while (cnode != NULL) { - ares__llist_node_t *next = ares__llist_node_next(cnode); - struct server_connection *conn = ares__llist_node_val(cnode); - ares_bool_t do_cleanup = ARES_FALSE; - cnode = next; + ares__llist_node_t *next = ares__llist_node_next(cnode); + ares_conn_t *conn = ares__llist_node_val(cnode); + ares_bool_t do_cleanup = ARES_FALSE; + cnode = next; /* Has connections, not eligible */ if (ares__llist_len(conn->queries_to_conn)) { @@ -122,7 +120,7 @@ void ares__check_cleanup_conns(const ares_channel_t *channel) } /* If the udp connection hit its max queries, always close it */ - if (!conn->is_tcp && channel->udp_max_queries > 0 && + if (!(conn->flags & ARES_CONN_FLAG_TCP) && channel->udp_max_queries > 0 && conn->total_queries >= channel->udp_max_queries) { do_cleanup = ARES_TRUE; } diff --git a/lib/c-ares-1.32.3/src/lib/ares__hosts_file.c b/lib/c-ares-1.33.1/src/lib/ares__hosts_file.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares__hosts_file.c rename to lib/c-ares-1.33.1/src/lib/ares__hosts_file.c diff --git a/lib/c-ares-1.32.3/src/lib/ares__parse_into_addrinfo.c b/lib/c-ares-1.33.1/src/lib/ares__parse_into_addrinfo.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares__parse_into_addrinfo.c rename to lib/c-ares-1.33.1/src/lib/ares__parse_into_addrinfo.c diff --git a/lib/c-ares-1.33.1/src/lib/ares__socket.c b/lib/c-ares-1.33.1/src/lib/ares__socket.c new file mode 100644 index 00000000000..86e281fcdda --- /dev/null +++ b/lib/c-ares-1.33.1/src/lib/ares__socket.c @@ -0,0 +1,764 @@ +/* MIT License + * + * Copyright (c) Massachusetts Institute of Technology + * Copyright (c) The c-ares project and its contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * SPDX-License-Identifier: MIT + */ +#include "ares_private.h" + +#ifdef HAVE_SYS_UIO_H +# include +#endif +#ifdef HAVE_NETINET_IN_H +# include +#endif +#ifdef HAVE_NETINET_TCP_H +# include +#endif +#ifdef HAVE_NETDB_H +# include +#endif +#ifdef HAVE_ARPA_INET_H +# include +#endif + +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_SYS_IOCTL_H +# include +#endif +#ifdef NETWARE +# include +#endif + +#include +#include +#include + +#if defined(__linux__) && defined(TCP_FASTOPEN_CONNECT) +# define TFO_SUPPORTED 1 +# define TFO_SKIP_CONNECT 0 +# define TFO_USE_SENDTO 0 +# define TFO_USE_CONNECTX 0 +# define TFO_CLIENT_SOCKOPT TCP_FASTOPEN_CONNECT +#elif defined(__FreeBSD__) && defined(TCP_FASTOPEN) +# define TFO_SUPPORTED 1 +# define TFO_SKIP_CONNECT 1 +# define TFO_USE_SENDTO 1 +# define TFO_USE_CONNECTX 0 +# define TFO_CLIENT_SOCKOPT TCP_FASTOPEN +#elif defined(__APPLE__) && defined(HAVE_CONNECTX) +# define TFO_SUPPORTED 1 +# define TFO_SKIP_CONNECT 0 +# define TFO_USE_SENDTO 0 +# define TFO_USE_CONNECTX 1 +# undef TFO_CLIENT_SOCKOPT +#else +# define TFO_SUPPORTED 0 +#endif + + +#ifndef HAVE_WRITEV +/* Structure for scatter/gather I/O. */ +struct iovec { + void *iov_base; /* Pointer to data. */ + size_t iov_len; /* Length of data. */ +}; +#endif + + +/* Return 1 if the specified error number describes a readiness error, or 0 + * otherwise. This is mostly for HP-UX, which could return EAGAIN or + * EWOULDBLOCK. See this man page + * + * http://devrsrc1.external.hp.com/STKS/cgi-bin/man2html? + * manpage=/usr/share/man/man2.Z/send.2 + */ +ares_bool_t ares__socket_try_again(int errnum) +{ +#if !defined EWOULDBLOCK && !defined EAGAIN +# error "Neither EWOULDBLOCK nor EAGAIN defined" +#endif + +#ifdef EWOULDBLOCK + if (errnum == EWOULDBLOCK) { + return ARES_TRUE; + } +#endif + +#if defined EAGAIN && EAGAIN != EWOULDBLOCK + if (errnum == EAGAIN) { + return ARES_TRUE; + } +#endif + + return ARES_FALSE; +} + +ares_ssize_t ares__socket_recv(ares_channel_t *channel, ares_socket_t s, + void *data, size_t data_len) +{ + if (channel->sock_funcs && channel->sock_funcs->arecvfrom) { + return channel->sock_funcs->arecvfrom(s, data, data_len, 0, 0, 0, + channel->sock_func_cb_data); + } + + return (ares_ssize_t)recv((RECV_TYPE_ARG1)s, (RECV_TYPE_ARG2)data, + (RECV_TYPE_ARG3)data_len, (RECV_TYPE_ARG4)(0)); +} + +ares_ssize_t ares__socket_recvfrom(ares_channel_t *channel, ares_socket_t s, + void *data, size_t data_len, int flags, + struct sockaddr *from, + ares_socklen_t *from_len) +{ + if (channel->sock_funcs && channel->sock_funcs->arecvfrom) { + return channel->sock_funcs->arecvfrom(s, data, data_len, flags, from, + from_len, channel->sock_func_cb_data); + } + +#ifdef HAVE_RECVFROM + return (ares_ssize_t)recvfrom(s, data, (RECVFROM_TYPE_ARG3)data_len, flags, + from, from_len); +#else + return ares__socket_recv(channel, s, data, data_len); +#endif +} + +/* Use like: + * struct sockaddr_storage sa_storage; + * ares_socklen_t salen = sizeof(sa_storage); + * struct sockaddr *sa = (struct sockaddr *)&sa_storage; + * ares__conn_set_sockaddr(conn, sa, &salen); + */ +static ares_status_t ares__conn_set_sockaddr(const ares_conn_t *conn, + struct sockaddr *sa, + ares_socklen_t *salen) +{ + const ares_server_t *server = conn->server; + unsigned short port = + conn->flags & ARES_CONN_FLAG_TCP ? server->tcp_port : server->udp_port; + struct sockaddr_in *sin; + struct sockaddr_in6 *sin6; + + switch (server->addr.family) { + case AF_INET: + sin = (struct sockaddr_in *)(void *)sa; + if (*salen < (ares_socklen_t)sizeof(*sin)) { + return ARES_EFORMERR; + } + *salen = sizeof(*sin); + memset(sin, 0, sizeof(*sin)); + sin->sin_family = AF_INET; + sin->sin_port = htons(port); + memcpy(&sin->sin_addr, &server->addr.addr.addr4, sizeof(sin->sin_addr)); + return ARES_SUCCESS; + case AF_INET6: + sin6 = (struct sockaddr_in6 *)(void *)sa; + if (*salen < (ares_socklen_t)sizeof(*sin6)) { + return ARES_EFORMERR; + } + *salen = sizeof(*sin6); + memset(sin6, 0, sizeof(*sin6)); + sin6->sin6_family = AF_INET6; + sin6->sin6_port = htons(port); + memcpy(&sin6->sin6_addr, &server->addr.addr.addr6, + sizeof(sin6->sin6_addr)); +#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID + sin6->sin6_scope_id = server->ll_scope; +#endif + return ARES_SUCCESS; + default: + break; + } + + return ARES_EBADFAMILY; +} + +static ares_status_t ares_conn_set_self_ip(ares_conn_t *conn, ares_bool_t early) +{ + struct sockaddr_storage sa_storage; + int rv; + ares_socklen_t len = sizeof(sa_storage); + + /* We call this twice on TFO, if we already have the IP we can go ahead and + * skip processing */ + if (!early && conn->self_ip.family != AF_UNSPEC) { + return ARES_SUCCESS; + } + + memset(&sa_storage, 0, sizeof(sa_storage)); + + rv = getsockname(conn->fd, (struct sockaddr *)(void *)&sa_storage, &len); + if (rv != 0) { + /* During TCP FastOpen, we can't get the IP this early since connect() + * may not be called. That's ok, we'll try again later */ + if (early && conn->flags & ARES_CONN_FLAG_TCP && + conn->flags & ARES_CONN_FLAG_TFO) { + memset(&conn->self_ip, 0, sizeof(conn->self_ip)); + return ARES_SUCCESS; + } + return ARES_ECONNREFUSED; + } + + if (!ares_sockaddr_to_ares_addr(&conn->self_ip, NULL, + (struct sockaddr *)(void *)&sa_storage)) { + return ARES_ECONNREFUSED; + } + + return ARES_SUCCESS; +} + +ares_ssize_t ares__conn_write(ares_conn_t *conn, const void *data, size_t len) +{ + ares_channel_t *channel = conn->server->channel; + int flags = 0; + +#ifdef HAVE_MSG_NOSIGNAL + flags |= MSG_NOSIGNAL; +#endif + + if (channel->sock_funcs && channel->sock_funcs->asendv) { + struct iovec vec; + vec.iov_base = (void *)((size_t)data); /* Cast off const */ + vec.iov_len = len; + return channel->sock_funcs->asendv(conn->fd, &vec, 1, + channel->sock_func_cb_data); + } + + if (conn->flags & ARES_CONN_FLAG_TFO_INITIAL) { + conn->flags &= ~((unsigned int)ARES_CONN_FLAG_TFO_INITIAL); + +#if defined(TFO_USE_SENDTO) && TFO_USE_SENDTO + { + struct sockaddr_storage sa_storage; + ares_socklen_t salen = sizeof(sa_storage); + struct sockaddr *sa = (struct sockaddr *)&sa_storage; + ares_status_t status; + ares_ssize_t rv; + + status = ares__conn_set_sockaddr(conn, sa, &salen); + if (status != ARES_SUCCESS) { + return status; + } + + rv = (ares_ssize_t)sendto((SEND_TYPE_ARG1)conn->fd, (SEND_TYPE_ARG2)data, + (SEND_TYPE_ARG3)len, (SEND_TYPE_ARG4)flags, sa, + salen); + + /* If using TFO, we might not have been able to get an IP earlier, since + * we hadn't informed the OS of the destination. When using sendto() + * now we have so we should be able to fetch it */ + ares_conn_set_self_ip(conn, ARES_TRUE); + return rv; + } +#endif + } + + return (ares_ssize_t)send((SEND_TYPE_ARG1)conn->fd, (SEND_TYPE_ARG2)data, + (SEND_TYPE_ARG3)len, (SEND_TYPE_ARG4)flags); +} + +/* + * setsocknonblock sets the given socket to either blocking or non-blocking + * mode based on the 'nonblock' boolean argument. This function is highly + * portable. + */ +static int setsocknonblock(ares_socket_t sockfd, /* operate on this */ + int nonblock /* TRUE or FALSE */) +{ +#if defined(USE_BLOCKING_SOCKETS) + + return 0; /* returns success */ + +#elif defined(HAVE_FCNTL_O_NONBLOCK) + + /* most recent unix versions */ + int flags; + flags = fcntl(sockfd, F_GETFL, 0); + if (nonblock) { + return fcntl(sockfd, F_SETFL, flags | O_NONBLOCK); + } else { + return fcntl(sockfd, F_SETFL, flags & (~O_NONBLOCK)); /* LCOV_EXCL_LINE */ + } + +#elif defined(HAVE_IOCTL_FIONBIO) + + /* older unix versions */ + int flags = nonblock ? 1 : 0; + return ioctl(sockfd, FIONBIO, &flags); + +#elif defined(HAVE_IOCTLSOCKET_FIONBIO) + +# ifdef WATT32 + char flags = nonblock ? 1 : 0; +# else + /* Windows */ + unsigned long flags = nonblock ? 1UL : 0UL; +# endif + return ioctlsocket(sockfd, (long)FIONBIO, &flags); + +#elif defined(HAVE_IOCTLSOCKET_CAMEL_FIONBIO) + + /* Amiga */ + long flags = nonblock ? 1L : 0L; + return IoctlSocket(sockfd, FIONBIO, flags); + +#elif defined(HAVE_SETSOCKOPT_SO_NONBLOCK) + + /* BeOS */ + long b = nonblock ? 1L : 0L; + return setsockopt(sockfd, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b)); + +#else +# error "no non-blocking method was found/used/set" +#endif +} + +#if defined(IPV6_V6ONLY) && defined(USE_WINSOCK) +/* It makes support for IPv4-mapped IPv6 addresses. + * Linux kernel, NetBSD, FreeBSD and Darwin: default is off; + * Windows Vista and later: default is on; + * DragonFly BSD: acts like off, and dummy setting; + * OpenBSD and earlier Windows: unsupported. + * Linux: controlled by /proc/sys/net/ipv6/bindv6only. + */ +static void set_ipv6_v6only(ares_socket_t sockfd, int on) +{ + (void)setsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&on, sizeof(on)); +} +#else +# define set_ipv6_v6only(s, v) +#endif + +static ares_status_t configure_socket(ares_conn_t *conn) +{ + union { + struct sockaddr sa; + struct sockaddr_in sa4; + struct sockaddr_in6 sa6; + } local; + + ares_socklen_t bindlen = 0; + ares_server_t *server = conn->server; + ares_channel_t *channel = server->channel; + + /* do not set options for user-managed sockets */ + if (channel->sock_funcs && channel->sock_funcs->asocket) { + return ARES_SUCCESS; + } + + (void)setsocknonblock(conn->fd, 1); + +#if defined(FD_CLOEXEC) && !defined(MSDOS) + /* Configure the socket fd as close-on-exec. */ + if (fcntl(conn->fd, F_SETFD, FD_CLOEXEC) != 0) { + return ARES_ECONNREFUSED; /* LCOV_EXCL_LINE */ + } +#endif + + /* No need to emit SIGPIPE on socket errors */ +#if defined(SO_NOSIGPIPE) + { + int opt = 1; + (void)setsockopt(conn->fd, SOL_SOCKET, SO_NOSIGPIPE, (void *)&opt, + sizeof(opt)); + } +#endif + + /* Set the socket's send and receive buffer sizes. */ + if (channel->socket_send_buffer_size > 0 && + setsockopt(conn->fd, SOL_SOCKET, SO_SNDBUF, + (void *)&channel->socket_send_buffer_size, + sizeof(channel->socket_send_buffer_size)) != 0) { + return ARES_ECONNREFUSED; /* LCOV_EXCL_LINE: UntestablePath */ + } + + if (channel->socket_receive_buffer_size > 0 && + setsockopt(conn->fd, SOL_SOCKET, SO_RCVBUF, + (void *)&channel->socket_receive_buffer_size, + sizeof(channel->socket_receive_buffer_size)) != 0) { + return ARES_ECONNREFUSED; /* LCOV_EXCL_LINE: UntestablePath */ + } + +#ifdef SO_BINDTODEVICE + if (ares_strlen(channel->local_dev_name)) { + /* Only root can do this, and usually not fatal if it doesn't work, so + * just continue on. */ + (void)setsockopt(conn->fd, SOL_SOCKET, SO_BINDTODEVICE, + channel->local_dev_name, sizeof(channel->local_dev_name)); + } +#endif + + if (server->addr.family == AF_INET && channel->local_ip4) { + memset(&local.sa4, 0, sizeof(local.sa4)); + local.sa4.sin_family = AF_INET; + local.sa4.sin_addr.s_addr = htonl(channel->local_ip4); + bindlen = sizeof(local.sa4); + } else if (server->addr.family == AF_INET6 && server->ll_scope == 0 && + memcmp(channel->local_ip6, ares_in6addr_any._S6_un._S6_u8, + sizeof(channel->local_ip6)) != 0) { + /* Only if not link-local and an ip other than "::" is specified */ + memset(&local.sa6, 0, sizeof(local.sa6)); + local.sa6.sin6_family = AF_INET6; + memcpy(&local.sa6.sin6_addr, channel->local_ip6, + sizeof(channel->local_ip6)); + bindlen = sizeof(local.sa6); + } + + if (bindlen && bind(conn->fd, &local.sa, bindlen) < 0) { + return ARES_ECONNREFUSED; + } + + if (server->addr.family == AF_INET6) { + set_ipv6_v6only(conn->fd, 0); + } + + if (conn->flags & ARES_CONN_FLAG_TCP) { + int opt = 1; + +#ifdef TCP_NODELAY + /* + * Disable the Nagle algorithm (only relevant for TCP sockets, and thus not + * in configure_socket). In general, in DNS lookups we're pretty much + * interested in firing off a single request and then waiting for a reply, + * so batching isn't very interesting. + */ + if (setsockopt(conn->fd, IPPROTO_TCP, TCP_NODELAY, (void *)&opt, + sizeof(opt)) != 0) { + return ARES_ECONNREFUSED; + } +#endif + +#if defined(TFO_CLIENT_SOCKOPT) + if (conn->flags & ARES_CONN_FLAG_TFO && + setsockopt(conn->fd, IPPROTO_TCP, TFO_CLIENT_SOCKOPT, (void *)&opt, + sizeof(opt)) != 0) { + /* Disable TFO if flag can't be set. */ + conn->flags &= ~((unsigned int)ARES_CONN_FLAG_TFO); + } +#endif + } + + return ARES_SUCCESS; +} + +ares_bool_t ares_sockaddr_to_ares_addr(struct ares_addr *ares_addr, + unsigned short *port, + const struct sockaddr *sockaddr) +{ + if (sockaddr->sa_family == AF_INET) { + /* NOTE: memcpy sockaddr_in due to alignment issues found by UBSAN due to + * dnsinfo packing on MacOS */ + struct sockaddr_in sockaddr_in; + memcpy(&sockaddr_in, sockaddr, sizeof(sockaddr_in)); + + ares_addr->family = AF_INET; + memcpy(&ares_addr->addr.addr4, &(sockaddr_in.sin_addr), + sizeof(ares_addr->addr.addr4)); + + if (port) { + *port = ntohs(sockaddr_in.sin_port); + } + return ARES_TRUE; + } + + if (sockaddr->sa_family == AF_INET6) { + /* NOTE: memcpy sockaddr_in6 due to alignment issues found by UBSAN due to + * dnsinfo packing on MacOS */ + struct sockaddr_in6 sockaddr_in6; + memcpy(&sockaddr_in6, sockaddr, sizeof(sockaddr_in6)); + + ares_addr->family = AF_INET6; + memcpy(&ares_addr->addr.addr6, &(sockaddr_in6.sin6_addr), + sizeof(ares_addr->addr.addr6)); + if (port) { + *port = ntohs(sockaddr_in6.sin6_port); + } + return ARES_TRUE; + } + + return ARES_FALSE; +} + +static ares_status_t ares__conn_connect(ares_conn_t *conn, struct sockaddr *sa, + ares_socklen_t salen) +{ + /* Normal non TCPFastOpen style connect */ + if (!(conn->flags & ARES_CONN_FLAG_TFO)) { + return ares__connect_socket(conn->server->channel, conn->fd, sa, salen); + } + + /* FreeBSD don't want any sort of connect() so skip */ +#if defined(TFO_SKIP_CONNECT) && TFO_SKIP_CONNECT + return ARES_SUCCESS; +#elif defined(TFO_USE_CONNECTX) && TFO_USE_CONNECTX + { + int rv; + int err; + + do { + sa_endpoints_t endpoints; + memset(&endpoints, 0, sizeof(endpoints)); + endpoints.sae_dstaddr = sa; + endpoints.sae_dstaddrlen = salen; + + rv = connectx(conn->fd, &endpoints, SAE_ASSOCID_ANY, + CONNECT_DATA_IDEMPOTENT | CONNECT_RESUME_ON_READ_WRITE, + NULL, 0, NULL, NULL); + + err = SOCKERRNO; + if (rv == -1 && err != EINPROGRESS && err != EWOULDBLOCK) { + return ARES_ECONNREFUSED; + } + + } while (rv == -1 && err == EINTR); + } + return ARES_SUCCESS; +#elif defined(TFO_SUPPORTED) && TFO_SUPPORTED + return ares__connect_socket(conn->server->channel, conn->fd, sa, salen); +#else + /* Shouldn't be possible */ + return ARES_ECONNREFUSED; +#endif +} + +ares_status_t ares__open_connection(ares_conn_t **conn_out, + ares_channel_t *channel, + ares_server_t *server, ares_bool_t is_tcp) +{ + ares_status_t status; + struct sockaddr_storage sa_storage; + ares_socklen_t salen = sizeof(sa_storage); + struct sockaddr *sa = (struct sockaddr *)&sa_storage; + ares_conn_t *conn; + ares__llist_node_t *node = NULL; + int stype = is_tcp ? SOCK_STREAM : SOCK_DGRAM; + + *conn_out = NULL; + + conn = ares_malloc(sizeof(*conn)); + if (conn == NULL) { + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + } + + memset(conn, 0, sizeof(*conn)); + conn->fd = ARES_SOCKET_BAD; + conn->server = server; + conn->queries_to_conn = ares__llist_create(NULL); + conn->flags = is_tcp ? ARES_CONN_FLAG_TCP : ARES_CONN_FLAG_NONE; + + /* Enable TFO if the OS supports it and we were passed in data to send during + * the connect. It might be disabled later if an error is encountered. Make + * sure a user isn't overriding anything. */ + if (conn->flags & ARES_CONN_FLAG_TCP && channel->sock_funcs == NULL && + TFO_SUPPORTED) { + conn->flags |= ARES_CONN_FLAG_TFO; + } + + if (conn->queries_to_conn == NULL) { + /* LCOV_EXCL_START: OutOfMemory */ + status = ARES_ENOMEM; + goto done; + /* LCOV_EXCL_STOP */ + } + + /* Convert into the struct sockaddr structure needed by the OS */ + status = ares__conn_set_sockaddr(conn, sa, &salen); + if (status != ARES_SUCCESS) { + goto done; + } + + /* Acquire a socket. */ + conn->fd = ares__open_socket(channel, server->addr.family, stype, 0); + if (conn->fd == ARES_SOCKET_BAD) { + status = ARES_ECONNREFUSED; + goto done; + } + + /* Configure it. */ + status = configure_socket(conn); + if (status != ARES_SUCCESS) { + goto done; + } + + if (channel->sock_config_cb) { + int err = + channel->sock_config_cb(conn->fd, stype, channel->sock_config_cb_data); + if (err < 0) { + status = ARES_ECONNREFUSED; + goto done; + } + } + + /* Connect */ + status = ares__conn_connect(conn, sa, salen); + if (status != ARES_SUCCESS) { + goto done; + } + + if (channel->sock_create_cb) { + int err = + channel->sock_create_cb(conn->fd, stype, channel->sock_create_cb_data); + if (err < 0) { + status = ARES_ECONNREFUSED; + goto done; + } + } + + /* Let the connection know we haven't written our first packet yet for TFO */ + if (conn->flags & ARES_CONN_FLAG_TFO) { + conn->flags |= ARES_CONN_FLAG_TFO_INITIAL; + } + + /* Need to store our own ip for DNS cookie support */ + status = ares_conn_set_self_ip(conn, ARES_FALSE); + if (status != ARES_SUCCESS) { + goto done; /* LCOV_EXCL_LINE: UntestablePath */ + } + + /* TCP connections are thrown to the end as we don't spawn multiple TCP + * connections. UDP connections are put on front where the newest connection + * can be quickly pulled */ + if (is_tcp) { + node = ares__llist_insert_last(server->connections, conn); + } else { + node = ares__llist_insert_first(server->connections, conn); + } + if (node == NULL) { + /* LCOV_EXCL_START: OutOfMemory */ + status = ARES_ENOMEM; + goto done; + /* LCOV_EXCL_STOP */ + } + + /* Register globally to quickly map event on file descriptor to connection + * node object */ + if (!ares__htable_asvp_insert(channel->connnode_by_socket, conn->fd, node)) { + /* LCOV_EXCL_START: OutOfMemory */ + status = ARES_ENOMEM; + goto done; + /* LCOV_EXCL_STOP */ + } + + SOCK_STATE_CALLBACK(channel, conn->fd, 1, is_tcp ? 1 : 0); + + if (is_tcp) { + server->tcp_conn = conn; + } + +done: + if (status != ARES_SUCCESS) { + ares__llist_node_claim(node); + ares__llist_destroy(conn->queries_to_conn); + ares__close_socket(channel, conn->fd); + ares_free(conn); + } else { + *conn_out = conn; + } + return status; +} + +ares_socket_t ares__open_socket(ares_channel_t *channel, int af, int type, + int protocol) +{ + if (channel->sock_funcs && channel->sock_funcs->asocket) { + return channel->sock_funcs->asocket(af, type, protocol, + channel->sock_func_cb_data); + } + + return socket(af, type, protocol); +} + +ares_status_t ares__connect_socket(ares_channel_t *channel, + ares_socket_t sockfd, + const struct sockaddr *addr, + ares_socklen_t addrlen) +{ + int rv; + int err; + + do { + if (channel->sock_funcs && channel->sock_funcs->aconnect) { + rv = channel->sock_funcs->aconnect(sockfd, addr, addrlen, + channel->sock_func_cb_data); + } else { + rv = connect(sockfd, addr, addrlen); + } + + err = SOCKERRNO; + + if (rv == -1 && err != EINPROGRESS && err != EWOULDBLOCK) { + return ARES_ECONNREFUSED; + } + + } while (rv == -1 && err == EINTR); + + return ARES_SUCCESS; +} + +void ares__close_socket(ares_channel_t *channel, ares_socket_t s) +{ + if (s == ARES_SOCKET_BAD) { + return; + } + + if (channel->sock_funcs && channel->sock_funcs->aclose) { + channel->sock_funcs->aclose(s, channel->sock_func_cb_data); + } else { + sclose(s); + } +} + +void ares_set_socket_callback(ares_channel_t *channel, + ares_sock_create_callback cb, void *data) +{ + if (channel == NULL) { + return; + } + channel->sock_create_cb = cb; + channel->sock_create_cb_data = data; +} + +void ares_set_socket_configure_callback(ares_channel_t *channel, + ares_sock_config_callback cb, + void *data) +{ + if (channel == NULL || channel->optmask & ARES_OPT_EVENT_THREAD) { + return; + } + channel->sock_config_cb = cb; + channel->sock_config_cb_data = data; +} + +void ares_set_socket_functions(ares_channel_t *channel, + const struct ares_socket_functions *funcs, + void *data) +{ + if (channel == NULL || channel->optmask & ARES_OPT_EVENT_THREAD) { + return; + } + channel->sock_funcs = funcs; + channel->sock_func_cb_data = data; +} diff --git a/lib/c-ares-1.32.3/src/lib/ares__sortaddrinfo.c b/lib/c-ares-1.33.1/src/lib/ares__sortaddrinfo.c similarity index 98% rename from lib/c-ares-1.32.3/src/lib/ares__sortaddrinfo.c rename to lib/c-ares-1.33.1/src/lib/ares__sortaddrinfo.c index e9bca4e386d..1aab81ecf84 100644 --- a/lib/c-ares-1.32.3/src/lib/ares__sortaddrinfo.c +++ b/lib/c-ares-1.33.1/src/lib/ares__sortaddrinfo.c @@ -51,7 +51,6 @@ #include #include - struct addrinfo_sort_elem { struct ares_addrinfo_node *ai; ares_bool_t has_src_addr; @@ -347,7 +346,6 @@ static int find_src_addr(ares_channel_t *channel, const struct sockaddr *addr, struct sockaddr *src_addr) { ares_socket_t sock; - int ret; ares_socklen_t len; switch (addr->sa_family) { @@ -364,18 +362,14 @@ static int find_src_addr(ares_channel_t *channel, const struct sockaddr *addr, sock = ares__open_socket(channel, addr->sa_family, SOCK_DGRAM, IPPROTO_UDP); if (sock == ARES_SOCKET_BAD) { - if (errno == EAFNOSUPPORT) { + if (SOCKERRNO == EAFNOSUPPORT) { return 0; } else { return -1; } } - do { - ret = ares__connect_socket(channel, sock, addr, len); - } while (ret == -1 && errno == EINTR); - - if (ret == -1) { + if (ares__connect_socket(channel, sock, addr, len) != ARES_SUCCESS) { ares__close_socket(channel, sock); return 0; } diff --git a/lib/c-ares-1.32.3/src/lib/ares_android.c b/lib/c-ares-1.33.1/src/lib/ares_android.c similarity index 96% rename from lib/c-ares-1.32.3/src/lib/ares_android.c rename to lib/c-ares-1.33.1/src/lib/ares_android.c index 67a9482d72e..06ab8940ad7 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_android.c +++ b/lib/c-ares-1.33.1/src/lib/ares_android.c @@ -26,6 +26,8 @@ #if defined(ANDROID) || defined(__ANDROID__) # include "ares_private.h" # include +# include +# include "ares_android.h" static JavaVM *android_jvm = NULL; static jobject android_connectivity_manager = NULL; @@ -80,6 +82,23 @@ static jmethodID jni_get_method_id(JNIEnv *env, jclass cls, return mid; } +static int jvm_attach(JNIEnv **env) +{ + char name[17] = {0}; + + JavaVMAttachArgs args; + + args.version = JNI_VERSION_1_6; + if (prctl(PR_GET_NAME, name) == 0) { + args.name = name; + } else { + args.name = NULL; + } + args.group = NULL; + + return (*android_jvm)->AttachCurrentThread(android_jvm, env, &args); +} + void ares_library_init_jvm(JavaVM *jvm) { android_jvm = jvm; @@ -100,7 +119,7 @@ int ares_library_init_android(jobject connectivity_manager) res = (*android_jvm)->GetEnv(android_jvm, (void **)&env, JNI_VERSION_1_6); if (res == JNI_EDETACHED) { env = NULL; - res = (*android_jvm)->AttachCurrentThread(android_jvm, &env, NULL); + res = jvm_attach(&env); need_detatch = 1; } if (res != JNI_OK || env == NULL) { @@ -209,7 +228,7 @@ int ares_library_init_android(jobject connectivity_manager) (*android_jvm)->DetachCurrentThread(android_jvm); } - return ret; + return (int)ret; } int ares_library_android_initialized(void) @@ -233,7 +252,7 @@ void ares_library_cleanup_android(void) res = (*android_jvm)->GetEnv(android_jvm, (void **)&env, JNI_VERSION_1_6); if (res == JNI_EDETACHED) { env = NULL; - res = (*android_jvm)->AttachCurrentThread(android_jvm, &env, NULL); + res = jvm_attach(&env); need_detatch = 1; } if (res != JNI_OK || env == NULL) { @@ -285,7 +304,7 @@ char **ares_get_android_server_list(size_t max_servers, size_t *num_servers) res = (*android_jvm)->GetEnv(android_jvm, (void **)&env, JNI_VERSION_1_6); if (res == JNI_EDETACHED) { env = NULL; - res = (*android_jvm)->AttachCurrentThread(android_jvm, &env, NULL); + res = jvm_attach(&env); need_detatch = 1; } if (res != JNI_OK || env == NULL) { @@ -403,7 +422,7 @@ char *ares_get_android_search_domains_list(void) res = (*android_jvm)->GetEnv(android_jvm, (void **)&env, JNI_VERSION_1_6); if (res == JNI_EDETACHED) { env = NULL; - res = (*android_jvm)->AttachCurrentThread(android_jvm, &env, NULL); + res = jvm_attach(&env); need_detatch = 1; } if (res != JNI_OK || env == NULL) { diff --git a/lib/c-ares-1.32.3/src/lib/ares_android.h b/lib/c-ares-1.33.1/src/lib/ares_android.h similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_android.h rename to lib/c-ares-1.33.1/src/lib/ares_android.h diff --git a/lib/c-ares-1.32.3/src/lib/ares_cancel.c b/lib/c-ares-1.33.1/src/lib/ares_cancel.c similarity index 98% rename from lib/c-ares-1.32.3/src/lib/ares_cancel.c rename to lib/c-ares-1.33.1/src/lib/ares_cancel.c index 4312b5e188e..c29d8ef82f4 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_cancel.c +++ b/lib/c-ares-1.33.1/src/lib/ares_cancel.c @@ -59,7 +59,7 @@ void ares_cancel(ares_channel_t *channel) node = ares__llist_node_first(list_copy); while (node != NULL) { - struct query *query; + ares_query_t *query; /* Cache next since this node is being deleted */ next = ares__llist_node_next(node); diff --git a/lib/c-ares-1.32.3/src/lib/ares_config.h.cmake b/lib/c-ares-1.33.1/src/lib/ares_config.h.cmake similarity index 97% rename from lib/c-ares-1.32.3/src/lib/ares_config.h.cmake rename to lib/c-ares-1.33.1/src/lib/ares_config.h.cmake index cafdadd9bbc..da738671971 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_config.h.cmake +++ b/lib/c-ares-1.33.1/src/lib/ares_config.h.cmake @@ -67,6 +67,9 @@ /* Define to 1 if you have the connect function. */ #cmakedefine HAVE_CONNECT 1 +/* Define to 1 if you have the connectx function. */ +#cmakedefine HAVE_CONNECTX 1 + /* define if the compiler supports basic C++11 syntax */ #cmakedefine HAVE_CXX11 1 @@ -145,6 +148,12 @@ /* Define to 1 if you have the `ConvertInterfaceLuidToNameA' function. */ #cmakedefine HAVE_CONVERTINTERFACELUIDTONAMEA 1 +/* Define to 1 if you have the `NotifyIpInterfaceChange' function. */ +#cmakedefine HAVE_NOTIFYIPINTERFACECHANGE 1 + +/* Define to 1 if you have the `RegisterWaitForSingleObject' function. */ +#cmakedefine HAVE_REGISTERWAITFORSINGLEOBJECT 1 + /* Define to 1 if you have a IPv6 capable working inet_net_pton function. */ #cmakedefine HAVE_INET_NET_PTON 1 diff --git a/lib/c-ares-1.32.3/src/lib/ares_config.h.in b/lib/c-ares-1.33.1/src/lib/ares_config.h.in similarity index 98% rename from lib/c-ares-1.32.3/src/lib/ares_config.h.in rename to lib/c-ares-1.33.1/src/lib/ares_config.h.in index 0a4aa069580..3e75b4c2cd0 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_config.h.in +++ b/lib/c-ares-1.33.1/src/lib/ares_config.h.in @@ -75,6 +75,9 @@ /* Define to 1 if you have `connect` */ #undef HAVE_CONNECT +/* Define to 1 if you have `connectx` */ +#undef HAVE_CONNECTX + /* Define to 1 if you have `ConvertInterfaceIndexToLuid` */ #undef HAVE_CONVERTINTERFACEINDEXTOLUID @@ -201,6 +204,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_NET_IF_H +/* Define to 1 if you have `NotifyIpInterfaceChange` */ +#undef HAVE_NOTIFYIPINTERFACECHANGE + /* Define to 1 if you have the header file. */ #undef HAVE_NTDEF_H @@ -237,6 +243,9 @@ /* Define to 1 if you have `recvfrom` */ #undef HAVE_RECVFROM +/* Define to 1 if you have `RegisterWaitForSingleObject` */ +#undef HAVE_REGISTERWAITFORSINGLEOBJECT + /* Define to 1 if you have `send` */ #undef HAVE_SEND diff --git a/lib/c-ares-1.33.1/src/lib/ares_cookie.c b/lib/c-ares-1.33.1/src/lib/ares_cookie.c new file mode 100644 index 00000000000..bf9d1ba25da --- /dev/null +++ b/lib/c-ares-1.33.1/src/lib/ares_cookie.c @@ -0,0 +1,460 @@ +/* MIT License + * + * Copyright (c) 2024 Brad House + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * SPDX-License-Identifier: MIT + */ + +/* DNS cookies are a simple form of learned mutual authentication supported by + * most DNS server implementations these days and can help prevent DNS Cache + * Poisoning attacks for clients and DNS amplification attacks for servers. + * + * A good overview is here: + * https://www.dotmagazine.online/issues/digital-responsibility-and-sustainability/dns-cookies-transaction-mechanism + * + * RFCs used for implementation are + * [RFC7873](https://datatracker.ietf.org/doc/html/rfc7873) which is extended by + * [RFC9018](https://datatracker.ietf.org/doc/html/rfc9018). + * + * Though this could be used on TCP, the likelihood of it being useful is small + * and could cause some issues. TCP is better used as a fallback in case there + * are issues with DNS Cookie support in the upstream servers (e.g. AnyCast + * cluster issues). + * + * While most recursive DNS servers support DNS Cookies, public DNS servers like + * Google (8.8.8.8, 8.8.4.4) and CloudFlare (1.1.1.1, 1.0.0.1) don't seem to + * have this enabled yet for unknown reasons. + * + * The risk to having DNS Cookie support always enabled is nearly zero as there + * is built-in detection support and it will simply bypass using cookies if the + * remote server doesn't support it. The problem arises if a remote server + * supports DNS cookies, then stops supporting them (such as if an administrator + * reconfigured the server, or maybe there are different servers in a cluster + * with different configurations). We need to detect this behavior by tracking + * how much time has gone by since we received our last valid cookie reply, and + * if we exceed the threshold, reset all cookie parameters like we haven't + * attempted a request yet. + * + * ## Implementation Plan + * + * ### Constants: + * - `COOKIE_CLIENT_TIMEOUT`: 86400s (1 day) + * - How often to regenerate the per-server client cookie, even if our + * source ip address hasn't changed. + * - `COOKIE_UNSUPPORTED_TIMEOUT`: 300s (5 minutes) + * - If a server responds without a cookie in the reply, this is how long to + * wait before attempting to send a client cookie again. + * - `COOKIE_REGRESSION_TIMEOUT`: 120s (2 minutes) + * - If a server was once known to return cookies, and all of a sudden stops + * returning cookies (but the reply is otherwise valid), this is how long + * to continue to attempt to use cookies before giving up and resetting. + * Such an event would cause an outage for this duration, but since a + * cache poisoning attack should be dropping invalid replies we should be + * able to still get the valid reply and not assume it is a server + * regression just because we received replies without cookies. + * - `COOKIE_RESEND_MAX`: 3 + * - Maximum times to resend a query to a server due to the server responding + * with `BAD_COOKIE`, after this, we switch to TCP. + * + * ### Per-server variables: + * - `cookie.state`: Known state of cookie support, enumeration. + * - `INITIAL` (0): Initial state, not yet determined. Used during startup. + * - `GENERATED` (1): Cookie has been generated and sent to a server, but no + * validated response yet. + * - `SUPPORTED` (2): Server has been determined to properly support cookies + * - `UNSUPPORTED` (3): Server has been determined to not support cookies + * - `cookie.client` : 8 byte randomly generated client cookie + * - `cookie.client_ts`: Timestamp client cookie was generated + * - `cookie.client_ip`: IP address client used to connect to server + * - `cookie.server`: 8 to 32 byte server cookie + * - `cookie.server_len`: length of server cookie + * - `cookie.unsupported_ts`: Timestamp of last attempt to use a cookies, but + * it was determined that the server didn't support them. + * + * ### Per-query variables: + * - `query.client_cookie`: Duplicate of `cookie.client` at the point in time + * the query is put on the wire. This should be available in the + * `ares_dns_record_t` for the request for verification purposes so we don't + * actually need to duplicate this, just naming it here for the ease of + * documentation below. + * - `query.cookie_try_count`: Number of tries to send a cookie but receive + * `BAD_COOKIE` responses. Used to know when we need to switch to TCP. + * + * ### Procedure: + * **NOTE**: These steps will all be done after obtaining a connection handle as + * some of these steps depend on determining the source ip address for the + * connection. + * + * 1. If the query is not using EDNS, then **skip any remaining processing**. + * 2. If using TCP, ensure there is no EDNS cookie opt (10) set (there may have + * been if this is a resend after upgrade to TCP), then **skip any remaining + * processing**. + * 3. If `cookie.state == SUPPORTED`, `cookie.unsupported_ts` is non-zero, and + * evaluates greater than `COOKIE_REGRESSION_TIMEOUT`, then clear all cookie + * settings, set `cookie.state = INITIAL`. Continue to next step (4) + * 4. If `cookie.state == UNSUPPORTED` + * - If `cookie.unsupported_ts` evaluates less than + * `COOKIE_UNSUPPORTED_TIMEOUT` + * - Ensure there is no EDNS cookie opt (10) set (shouldn't be unless + * requestor had put this themselves), then **skip any remaining + * processing** as we don't want to try to send cookies. + * - Otherwise: + * - clear all cookie settings, set `cookie.state = INITIAL`. + * - Continue to next step (5) which will send a new cookie. + * 5. If `cookie.state == INITIAL`: + * - randomly generate new `cookie.client` + * - set `cookie.client_ts` to the current timestamp. + * - set `cookie.state = GENERATED`. + * - set `cookie.client_ip` to the current source ip address. + * 6. If `cookie.state == GENERATED || cookie.state == SUPPORTED` and + * `cookie.client_ip` does not match the current source ip address: + * - clear `cookie.server` + * - randomly generate new `cookie.client` + * - set `cookie.client_ts` to the current timestamp. + * - set `cookie.client_ip` to the current source ip address. + * - do not change the `cookie.state` + * 7. If `cookie.state == SUPPORTED` and `cookie.client_ts` evaluation exceeds + * `COOKIE_CLIENT_TIMEOUT`: + * - clear `cookie.server` + * - randomly generate new `cookie.client` + * - set `cookie.client_ts` to the current timestamp. + * - set `cookie.client_ip` to the current source ip address. + * - do not change the `cookie.state` + * 8. Generate EDNS OPT record (10) for client cookie. The option value will be + * the `cookie.client` concatenated with the `cookie.server`. If there is no + * known server cookie, it will not be appended. Copy `cookie.client` to + * `query.client_cookie` to handle possible client cookie changes by other + * queries before a reply is received (technically this is in the cached + * `ares_dns_record_t` so no need to manually do this). Send request to + * server. + * 9. Evaluate response: + * 1. If invalid EDNS OPT cookie (10) length sent back in response (valid + * length is 16-40), or bad client cookie value (validate first 8 bytes + * against `query.client_cookie` not `cookie.client`), **drop response** + * as if it hadn't been received. This is likely a spoofing attack. + * Wait for valid response up to normal response timeout. + * 2. If a EDNS OPT cookie (10) server cookie is returned: + * - set `cookie.unsupported_ts` to zero and `cookie.state = SUPPORTED`. + * We can confirm this server supports cookies based on the existence + * of this record. + * - If a new EDNS OPT cookie (10) server cookie is in the response, and + * the `client.cookie` matches the `query.client_cookie` still (hasn't + * been rotated by some other parallel query), save it as + * `cookie.server`. + * 3. If dns response `rcode` is `BAD_COOKIE`: + * - Ensure a EDNS OPT cookie (10) is returned, otherwise **drop + * response**, this is completely invalid and likely an spoof of some + * sort. + * - Otherwise + * - Increment `query.cookie_try_count` + * - If `query.cookie_try_count >= COOKIE_RESEND_MAX`, set + * `query.using_tcp` to force the next attempt to use TCP. + * - **Requeue the query**, but do not increment the normal + * `try_count` as a `BAD_COOKIE` reply isn't a normal try failure. + * This should end up going all the way back to step 1 on the next + * attempt. + * 4. If EDNS OPT cookie (10) is **NOT** returned in the response: + * - If `cookie.state == SUPPORTED` + * - if `cookie.unsupported_ts` is zero, set to the current timestamp. + * - Drop the response, wait for a valid response to be returned + * - if `cookie.state == GENERATED` + * - clear all cookie settings + * - set `cookie.state = UNSUPPORTED` + * - set `cookie.unsupported_ts` to the current time + * - Accept response (state should be `UNSUPPORTED` if we're here) + */ + +#include "ares_private.h" + +/* 1 day */ +#define COOKIE_CLIENT_TIMEOUT_MS (86400 * 1000) + +/* 5 minutes */ +#define COOKIE_UNSUPPORTED_TIMEOUT_MS (300 * 1000) + +/* 2 minutes */ +#define COOKIE_REGRESSION_TIMEOUT_MS (120 * 1000) + +#define COOKIE_RESEND_MAX 3 + +static const unsigned char * + ares_dns_cookie_fetch(const ares_dns_record_t *dnsrec, size_t *len) +{ + const ares_dns_rr_t *rr = ares_dns_get_opt_rr_const(dnsrec); + const unsigned char *val = NULL; + *len = 0; + + if (rr == NULL) { + return NULL; + } + + if (!ares_dns_rr_get_opt_byid(rr, ARES_RR_OPT_OPTIONS, ARES_OPT_PARAM_COOKIE, + &val, len)) { + return NULL; + } + + return val; +} + +static ares_bool_t timeval_is_set(const ares_timeval_t *tv) +{ + if (tv->sec != 0 && tv->usec != 0) { + return ARES_TRUE; + } + return ARES_FALSE; +} + +static ares_bool_t timeval_expired(const ares_timeval_t *tv, + const ares_timeval_t *now, + unsigned long millsecs) +{ + ares_int64_t tvdiff_ms; + ares_timeval_t tvdiff; + ares__timeval_diff(&tvdiff, tv, now); + + tvdiff_ms = tvdiff.sec * 1000 + tvdiff.usec / 1000; + if (tvdiff_ms >= (ares_int64_t)millsecs) { + return ARES_TRUE; + } + return ARES_FALSE; +} + +static void ares_cookie_clear(ares_cookie_t *cookie) +{ + memset(cookie, 0, sizeof(*cookie)); + cookie->state = ARES_COOKIE_INITIAL; +} + +static void ares_cookie_generate(ares_cookie_t *cookie, ares_conn_t *conn, + const ares_timeval_t *now) +{ + ares_channel_t *channel = conn->server->channel; + + ares__rand_bytes(channel->rand_state, cookie->client, sizeof(cookie->client)); + memcpy(&cookie->client_ts, now, sizeof(cookie->client_ts)); + memcpy(&cookie->client_ip, &conn->self_ip, sizeof(cookie->client_ip)); +} + +static void ares_cookie_clear_server(ares_cookie_t *cookie) +{ + memset(cookie->server, 0, sizeof(cookie->server)); + cookie->server_len = 0; +} + +static ares_bool_t ares_addr_equal(const struct ares_addr *addr1, + const struct ares_addr *addr2) +{ + if (addr1->family != addr2->family) { + return ARES_FALSE; + } + + switch (addr1->family) { + case AF_INET: + if (memcmp(&addr1->addr.addr4, &addr2->addr.addr4, + sizeof(addr1->addr.addr4)) == 0) { + return ARES_TRUE; + } + break; + case AF_INET6: + /* This structure is weird, and due to padding SonarCloud complains if + * you don't punch all the way down. At some point we should rework + * this structure */ + if (memcmp(&addr1->addr.addr6._S6_un._S6_u8, + &addr2->addr.addr6._S6_un._S6_u8, + sizeof(addr1->addr.addr6._S6_un._S6_u8)) == 0) { + return ARES_TRUE; + } + break; + default: + break; /* LCOV_EXCL_LINE */ + } + + return ARES_FALSE; +} + +ares_status_t ares_cookie_apply(ares_dns_record_t *dnsrec, ares_conn_t *conn, + const ares_timeval_t *now) +{ + ares_server_t *server = conn->server; + ares_cookie_t *cookie = &server->cookie; + ares_dns_rr_t *rr = ares_dns_get_opt_rr(dnsrec); + unsigned char c[40]; + size_t c_len; + + /* If there is no OPT record, then EDNS isn't supported, and therefore + * cookies can't be supported */ + if (rr == NULL) { + return ARES_SUCCESS; + } + + /* No cookies on TCP, make sure we remove one if one is present */ + if (conn->flags & ARES_CONN_FLAG_TCP) { + ares_dns_rr_del_opt_byid(rr, ARES_RR_OPT_OPTIONS, ARES_OPT_PARAM_COOKIE); + return ARES_SUCCESS; + } + + /* Look for regression */ + if (cookie->state == ARES_COOKIE_SUPPORTED && + timeval_is_set(&cookie->unsupported_ts) && + timeval_expired(&cookie->unsupported_ts, now, + COOKIE_REGRESSION_TIMEOUT_MS)) { + ares_cookie_clear(cookie); + } + + /* Handle unsupported state */ + if (cookie->state == ARES_COOKIE_UNSUPPORTED) { + /* If timer hasn't expired, just delete any possible cookie and return */ + if (!timeval_expired(&cookie->unsupported_ts, now, + COOKIE_REGRESSION_TIMEOUT_MS)) { + ares_dns_rr_del_opt_byid(rr, ARES_RR_OPT_OPTIONS, ARES_OPT_PARAM_COOKIE); + return ARES_SUCCESS; + } + + /* We want to try to "learn" again */ + ares_cookie_clear(cookie); + } + + /* Generate a new cookie */ + if (cookie->state == ARES_COOKIE_INITIAL) { + ares_cookie_generate(cookie, conn, now); + cookie->state = ARES_COOKIE_GENERATED; + } + + /* Regenerate the cookie and clear the server cookie if the client ip has + * changed */ + if ((cookie->state == ARES_COOKIE_GENERATED || + cookie->state == ARES_COOKIE_SUPPORTED) && + !ares_addr_equal(&conn->self_ip, &cookie->client_ip)) { + ares_cookie_clear_server(cookie); + ares_cookie_generate(cookie, conn, now); + } + + /* If the client cookie has reached its maximum time, refresh it */ + if (cookie->state == ARES_COOKIE_SUPPORTED && + timeval_expired(&cookie->client_ts, now, COOKIE_CLIENT_TIMEOUT_MS)) { + ares_cookie_clear_server(cookie); + ares_cookie_generate(cookie, conn, now); + } + + /* Generate the full cookie which is the client cookie concatenated with the + * server cookie (if there is one) and apply it. */ + memcpy(c, cookie->client, sizeof(cookie->client)); + if (cookie->server_len) { + memcpy(c + sizeof(cookie->client), cookie->server, cookie->server_len); + } + c_len = sizeof(cookie->client) + cookie->server_len; + + return ares_dns_rr_set_opt(rr, ARES_RR_OPT_OPTIONS, ARES_OPT_PARAM_COOKIE, c, + c_len); +} + +ares_status_t ares_cookie_validate(ares_query_t *query, + const ares_dns_record_t *dnsresp, + ares_conn_t *conn, const ares_timeval_t *now) +{ + ares_server_t *server = conn->server; + ares_cookie_t *cookie = &server->cookie; + const ares_dns_record_t *dnsreq = query->query; + const unsigned char *resp_cookie; + size_t resp_cookie_len; + const unsigned char *req_cookie; + size_t req_cookie_len; + + resp_cookie = ares_dns_cookie_fetch(dnsresp, &resp_cookie_len); + + /* Invalid cookie length, drop */ + if (resp_cookie && (resp_cookie_len < 8 || resp_cookie_len > 40)) { + return ARES_EBADRESP; + } + + req_cookie = ares_dns_cookie_fetch(dnsreq, &req_cookie_len); + + /* Didn't request cookies, so we can stop evaluating */ + if (req_cookie == NULL) { + return ARES_SUCCESS; + } + + /* If 8-byte prefix for returned cookie doesn't match the requested cookie, + * drop for spoofing */ + if (resp_cookie && memcmp(req_cookie, resp_cookie, 8) != 0) { + return ARES_EBADRESP; + } + + if (resp_cookie && resp_cookie_len > 8) { + /* Make sure we record that we successfully received a cookie response */ + cookie->state = ARES_COOKIE_SUPPORTED; + memset(&cookie->unsupported_ts, 0, sizeof(cookie->unsupported_ts)); + + /* If client cookie hasn't been rotated, save the returned server cookie */ + if (memcmp(cookie->client, req_cookie, sizeof(cookie->client)) == 0) { + cookie->server_len = resp_cookie_len - 8; + memcpy(cookie->server, resp_cookie + 8, cookie->server_len); + } + } + + if (ares_dns_record_get_rcode(dnsresp) == ARES_RCODE_BADCOOKIE) { + /* Illegal to return BADCOOKIE but no cookie, drop */ + if (resp_cookie == NULL) { + return ARES_EBADRESP; + } + + /* If we have too many attempts to send a cookie, we need to requeue as + * tcp */ + query->cookie_try_count++; + if (query->cookie_try_count >= COOKIE_RESEND_MAX) { + query->using_tcp = ARES_TRUE; + } + + /* Resend the request, hopefully it will work the next time as we should + * have recorded a server cookie */ + ares__requeue_query(query, now, ARES_SUCCESS, + ARES_FALSE /* Don't increment try count */, + NULL); + + /* Parent needs to drop this response */ + return ARES_EBADRESP; + } + + /* We've got a response with a server cookie, and we've done all the + * evaluation we can, return success */ + if (resp_cookie_len > 8) { + return ARES_SUCCESS; + } + + if (cookie->state == ARES_COOKIE_SUPPORTED) { + /* If we're not currently tracking an error time yet, start */ + if (!timeval_is_set(&cookie->unsupported_ts)) { + memcpy(&cookie->unsupported_ts, now, sizeof(cookie->unsupported_ts)); + } + /* Drop it since we expected a cookie */ + return ARES_EBADRESP; + } + + if (cookie->state == ARES_COOKIE_GENERATED) { + ares_cookie_clear(cookie); + cookie->state = ARES_COOKIE_UNSUPPORTED; + memcpy(&cookie->unsupported_ts, now, sizeof(cookie->unsupported_ts)); + } + + /* Cookie state should be UNSUPPORTED if we're here */ + return ARES_SUCCESS; +} diff --git a/lib/c-ares-1.32.3/src/lib/ares_data.c b/lib/c-ares-1.33.1/src/lib/ares_data.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_data.c rename to lib/c-ares-1.33.1/src/lib/ares_data.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_data.h b/lib/c-ares-1.33.1/src/lib/ares_data.h similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_data.h rename to lib/c-ares-1.33.1/src/lib/ares_data.h diff --git a/lib/c-ares-1.32.3/src/lib/ares_destroy.c b/lib/c-ares-1.33.1/src/lib/ares_destroy.c similarity index 96% rename from lib/c-ares-1.32.3/src/lib/ares_destroy.c rename to lib/c-ares-1.33.1/src/lib/ares_destroy.c index 1be42b1dec1..d75b5e227cc 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_destroy.c +++ b/lib/c-ares-1.33.1/src/lib/ares_destroy.c @@ -26,7 +26,7 @@ */ #include "ares_private.h" -#include "ares_event.h" +#include "event/ares_event.h" #include void ares_destroy(ares_channel_t *channel) @@ -73,7 +73,7 @@ void ares_destroy(ares_channel_t *channel) node = ares__llist_node_first(channel->all_queries); while (node != NULL) { ares__llist_node_t *next = ares__llist_node_next(node); - struct query *query = ares__llist_node_claim(node); + ares_query_t *query = ares__llist_node_claim(node); query->node_all_queries = NULL; query->callback(query->arg, ARES_EDESTRUCTION, 0, NULL); @@ -134,7 +134,7 @@ void ares_destroy(ares_channel_t *channel) ares_free(channel); } -void ares__destroy_server(struct server_state *server) +void ares__destroy_server(ares_server_t *server) { if (server == NULL) { return; /* LCOV_EXCL_LINE: DefensiveCoding */ @@ -152,7 +152,7 @@ void ares__destroy_servers_state(ares_channel_t *channel) ares__slist_node_t *node; while ((node = ares__slist_node_first(channel->servers)) != NULL) { - struct server_state *server = ares__slist_node_claim(node); + ares_server_t *server = ares__slist_node_claim(node); ares__destroy_server(server); } diff --git a/lib/c-ares-1.32.3/src/lib/ares_free_hostent.c b/lib/c-ares-1.33.1/src/lib/ares_free_hostent.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_free_hostent.c rename to lib/c-ares-1.33.1/src/lib/ares_free_hostent.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_free_string.c b/lib/c-ares-1.33.1/src/lib/ares_free_string.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_free_string.c rename to lib/c-ares-1.33.1/src/lib/ares_free_string.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_freeaddrinfo.c b/lib/c-ares-1.33.1/src/lib/ares_freeaddrinfo.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_freeaddrinfo.c rename to lib/c-ares-1.33.1/src/lib/ares_freeaddrinfo.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_getaddrinfo.c b/lib/c-ares-1.33.1/src/lib/ares_getaddrinfo.c similarity index 97% rename from lib/c-ares-1.32.3/src/lib/ares_getaddrinfo.c rename to lib/c-ares-1.33.1/src/lib/ares_getaddrinfo.c index 8a195ed0220..713acf744a0 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_getaddrinfo.c +++ b/lib/c-ares-1.33.1/src/lib/ares_getaddrinfo.c @@ -252,7 +252,7 @@ static ares_bool_t fake_addrinfo(const char *name, unsigned short port, ares_bool_t valid = ARES_TRUE; const char *p; for (p = name; *p; p++) { - if (!isdigit(*p) && *p != '.') { + if (!ares__isdigit(*p) && *p != '.') { valid = ARES_FALSE; break; } else if (*p == '.') { @@ -469,7 +469,7 @@ static void terminate_retries(const struct host_query *hquery, unsigned short term_qid = (qid == hquery->qid_a) ? hquery->qid_aaaa : hquery->qid_a; const ares_channel_t *channel = hquery->channel; - struct query *query = NULL; + ares_query_t *query = NULL; /* No other outstanding queries, nothing to do */ if (!hquery->remaining) { @@ -528,6 +528,13 @@ static void host_callback(void *arg, ares_status_t status, size_t timeouts, hquery->nodata_cnt++; } next_lookup(hquery, hquery->nodata_cnt ? ARES_ENODATA : status); + } else if ( + (status == ARES_ESERVFAIL || status == ARES_EREFUSED) && + ares__name_label_cnt(hquery->names[hquery->next_name_idx-1]) == 1 + ) { + /* Issue #852, systemd-resolved may return SERVFAIL or REFUSED on a + * single label domain name. */ + next_lookup(hquery, hquery->nodata_cnt ? ARES_ENODATA : status); } else { end_hquery(hquery, status); } diff --git a/lib/c-ares-1.32.3/src/lib/ares_getenv.c b/lib/c-ares-1.33.1/src/lib/ares_getenv.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_getenv.c rename to lib/c-ares-1.33.1/src/lib/ares_getenv.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_getenv.h b/lib/c-ares-1.33.1/src/lib/ares_getenv.h similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_getenv.h rename to lib/c-ares-1.33.1/src/lib/ares_getenv.h diff --git a/lib/c-ares-1.32.3/src/lib/ares_gethostbyaddr.c b/lib/c-ares-1.33.1/src/lib/ares_gethostbyaddr.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_gethostbyaddr.c rename to lib/c-ares-1.33.1/src/lib/ares_gethostbyaddr.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_gethostbyname.c b/lib/c-ares-1.33.1/src/lib/ares_gethostbyname.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_gethostbyname.c rename to lib/c-ares-1.33.1/src/lib/ares_gethostbyname.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_getnameinfo.c b/lib/c-ares-1.33.1/src/lib/ares_getnameinfo.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_getnameinfo.c rename to lib/c-ares-1.33.1/src/lib/ares_getnameinfo.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_inet_net_pton.h b/lib/c-ares-1.33.1/src/lib/ares_inet_net_pton.h similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_inet_net_pton.h rename to lib/c-ares-1.33.1/src/lib/ares_inet_net_pton.h diff --git a/lib/c-ares-1.32.3/src/lib/ares_init.c b/lib/c-ares-1.33.1/src/lib/ares_init.c similarity index 98% rename from lib/c-ares-1.32.3/src/lib/ares_init.c rename to lib/c-ares-1.33.1/src/lib/ares_init.c index cc7b85d783e..6dc5f4f9353 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_init.c +++ b/lib/c-ares-1.33.1/src/lib/ares_init.c @@ -63,7 +63,7 @@ #include "ares_inet_net_pton.h" #include "ares_platform.h" -#include "ares_event.h" +#include "event/ares_event.h" int ares_init(ares_channel_t **channelptr) { @@ -72,8 +72,8 @@ int ares_init(ares_channel_t **channelptr) static int ares_query_timeout_cmp_cb(const void *arg1, const void *arg2) { - const struct query *q1 = arg1; - const struct query *q2 = arg2; + const ares_query_t *q1 = arg1; + const ares_query_t *q2 = arg2; if (q1->timeout.sec > q2->timeout.sec) { return 1; @@ -94,8 +94,8 @@ static int ares_query_timeout_cmp_cb(const void *arg1, const void *arg2) static int server_sort_cb(const void *data1, const void *data2) { - const struct server_state *s1 = data1; - const struct server_state *s2 = data2; + const ares_server_t *s1 = data1; + const ares_server_t *s2 = data2; if (s1->consec_failures < s2->consec_failures) { return -1; diff --git a/lib/c-ares-1.32.3/src/lib/ares_ipv6.h b/lib/c-ares-1.33.1/src/lib/ares_ipv6.h similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_ipv6.h rename to lib/c-ares-1.33.1/src/lib/ares_ipv6.h diff --git a/lib/c-ares-1.32.3/src/lib/ares_library_init.c b/lib/c-ares-1.33.1/src/lib/ares_library_init.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_library_init.c rename to lib/c-ares-1.33.1/src/lib/ares_library_init.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_metrics.c b/lib/c-ares-1.33.1/src/lib/ares_metrics.c similarity index 96% rename from lib/c-ares-1.32.3/src/lib/ares_metrics.c rename to lib/c-ares-1.33.1/src/lib/ares_metrics.c index 78f93bc1b7d..0e22fc37e7c 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_metrics.c +++ b/lib/c-ares-1.33.1/src/lib/ares_metrics.c @@ -145,7 +145,7 @@ static time_t ares_metric_timestamp(ares_server_bucket_t bucket, return (time_t)(now->sec / divisor); } -void ares_metrics_record(const struct query *query, struct server_state *server, +void ares_metrics_record(const ares_query_t *query, ares_server_t *server, ares_status_t status, const ares_dns_record_t *dnsrec) { ares_timeval_t now; @@ -170,7 +170,7 @@ void ares_metrics_record(const struct query *query, struct server_state *server, } ares__timeval_diff(&tvdiff, &query->ts, &now); - query_ms = (unsigned int)(tvdiff.sec + (tvdiff.usec / 1000)); + query_ms = (unsigned int)((tvdiff.sec * 1000) + (tvdiff.usec / 1000)); if (query_ms == 0) { query_ms = 1; } @@ -205,8 +205,8 @@ void ares_metrics_record(const struct query *query, struct server_state *server, } } -size_t ares_metrics_server_timeout(const struct server_state *server, - const ares_timeval_t *now) +size_t ares_metrics_server_timeout(const ares_server_t *server, + const ares_timeval_t *now) { const ares_channel_t *channel = server->channel; ares_server_bucket_t i; @@ -252,7 +252,7 @@ size_t ares_metrics_server_timeout(const struct server_state *server, } /* don't go above upper bounds */ - max_timeout_ms = channel->maxtimeout?channel->maxtimeout:MAX_TIMEOUT_MS; + max_timeout_ms = channel->maxtimeout ? channel->maxtimeout : MAX_TIMEOUT_MS; if (timeout_ms > max_timeout_ms) { timeout_ms = max_timeout_ms; } diff --git a/lib/c-ares-1.32.3/src/lib/ares_options.c b/lib/c-ares-1.33.1/src/lib/ares_options.c similarity index 99% rename from lib/c-ares-1.32.3/src/lib/ares_options.c rename to lib/c-ares-1.33.1/src/lib/ares_options.c index 19ddf6d8ca1..9aeb4bad3d7 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_options.c +++ b/lib/c-ares-1.33.1/src/lib/ares_options.c @@ -66,7 +66,7 @@ static struct in_addr *ares_save_opt_servers(const ares_channel_t *channel, for (snode = ares__slist_node_first(channel->servers); snode != NULL; snode = ares__slist_node_next(snode)) { - const struct server_state *server = ares__slist_node_val(snode); + const ares_server_t *server = ares__slist_node_val(snode); if (server->addr.family != AF_INET) { continue; diff --git a/lib/c-ares-1.32.3/src/lib/ares_platform.c b/lib/c-ares-1.33.1/src/lib/ares_platform.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_platform.c rename to lib/c-ares-1.33.1/src/lib/ares_platform.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_platform.h b/lib/c-ares-1.33.1/src/lib/ares_platform.h similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_platform.h rename to lib/c-ares-1.33.1/src/lib/ares_platform.h diff --git a/lib/c-ares-1.32.3/src/lib/ares_private.h b/lib/c-ares-1.33.1/src/lib/ares_private.h similarity index 80% rename from lib/c-ares-1.32.3/src/lib/ares_private.h rename to lib/c-ares-1.33.1/src/lib/ares_private.h index 5506416d8ef..263c2a606d3 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_private.h +++ b/lib/c-ares-1.33.1/src/lib/ares_private.h @@ -105,33 +105,34 @@ W32_FUNC const char *_w32_GetHostsFile(void); struct ares_rand_state; typedef struct ares_rand_state ares_rand_state; -#include "ares__llist.h" -#include "ares__slist.h" -#include "ares__htable_strvp.h" -#include "ares__htable_szvp.h" -#include "ares__htable_asvp.h" -#include "ares__htable_vpvp.h" -#include "ares_dns_multistring.h" -#include "ares__buf.h" -#include "ares_dns_private.h" -#include "ares__iface_ips.h" -#include "ares__threads.h" +#include "dsa/ares__array.h" +#include "dsa/ares__llist.h" +#include "dsa/ares__slist.h" +#include "dsa/ares__htable_strvp.h" +#include "dsa/ares__htable_szvp.h" +#include "dsa/ares__htable_asvp.h" +#include "dsa/ares__htable_vpvp.h" +#include "record/ares_dns_multistring.h" +#include "str/ares__buf.h" +#include "record/ares_dns_private.h" +#include "util/ares__iface_ips.h" +#include "util/ares__threads.h" #ifndef HAVE_GETENV # include "ares_getenv.h" # define getenv(ptr) ares_getenv(ptr) #endif -#include "ares_str.h" -#include "ares_strsplit.h" +#include "str/ares_str.h" +#include "str/ares_strsplit.h" #ifndef HAVE_STRCASECMP -# include "ares_strcasecmp.h" +# include "str/ares_strcasecmp.h" # define strcasecmp(p1, p2) ares_strcasecmp(p1, p2) #endif #ifndef HAVE_STRNCASECMP -# include "ares_strcasecmp.h" +# include "str/ares_strcasecmp.h" # define strncasecmp(p1, p2, n) ares_strncasecmp(p1, p2, n) #endif @@ -150,18 +151,36 @@ typedef struct ares_rand_state ares_rand_state; #define DEFAULT_SERVER_RETRY_CHANCE 10 #define DEFAULT_SERVER_RETRY_DELAY 5000 -struct query; +struct ares_query; +typedef struct ares_query ares_query_t; -struct server_state; +struct ares_server; +typedef struct ares_server ares_server_t; -struct server_connection { - struct server_state *server; - ares_socket_t fd; - ares_bool_t is_tcp; +struct ares_conn; +typedef struct ares_conn ares_conn_t; + +typedef enum { + /*! No flags */ + ARES_CONN_FLAG_NONE = 0, + /*! TCP connection, not UDP */ + ARES_CONN_FLAG_TCP = 1 << 0, + /*! TCP Fast Open is enabled and being used if supported by the OS */ + ARES_CONN_FLAG_TFO = 1 << 1, + /*! TCP Fast Open has not yet sent its first packet. Gets unset on first + * write to a connection */ + ARES_CONN_FLAG_TFO_INITIAL = 1 << 2 +} ares_conn_flags_t; + +struct ares_conn { + ares_server_t *server; + ares_socket_t fd; + struct ares_addr self_ip; + ares_conn_flags_t flags; /* total number of queries run on this connection since it was established */ - size_t total_queries; + size_t total_queries; /* list of outstanding queries to this connection */ - ares__llist_t *queries_to_conn; + ares__llist_t *queries_to_conn; }; #ifdef _MSC_VER @@ -204,70 +223,104 @@ typedef struct { ares_uint64_t prev_total_count; /*!< Previous period bucket query count */ } ares_server_metrics_t; -struct server_state { +typedef enum { + ARES_COOKIE_INITIAL = 0, + ARES_COOKIE_GENERATED = 1, + ARES_COOKIE_SUPPORTED = 2, + ARES_COOKIE_UNSUPPORTED = 3 +} ares_cookie_state_t; + +/*! Structure holding tracking data for RFC 7873/9018 DNS cookies. + * Implementation plan for this feature is here: + * https://github.com/c-ares/c-ares/issues/620 + */ +typedef struct { + /*! starts at INITIAL, transitions as needed. */ + ares_cookie_state_t state; + /*! randomly-generate client cookie */ + unsigned char client[8]; + /*! timestamp client cookie was generated, used for rotation purposes */ + ares_timeval_t client_ts; + /*! IP address last used for client to connect to server. If this changes + * The client cookie gets invalidated */ + struct ares_addr client_ip; + /*! Server Cookie last received, 8-32 bytes in length */ + unsigned char server[32]; + /*! Length of server cookie on file. */ + size_t server_len; + /*! Timestamp of last attempt to use cookies, but it was determined that the + * server didn't support them */ + ares_timeval_t unsupported_ts; +} ares_cookie_t; + +struct ares_server { /* Configuration */ - size_t idx; /* index for server in system configuration */ - struct ares_addr addr; - unsigned short udp_port; /* host byte order */ - unsigned short tcp_port; /* host byte order */ - char ll_iface[64]; /* IPv6 Link Local Interface */ - unsigned int ll_scope; /* IPv6 Link Local Scope */ - - size_t consec_failures; /* Consecutive query failure count - * can be hard errors or timeouts - */ - ares__llist_t *connections; - struct server_connection *tcp_conn; + size_t idx; /* index for server in system configuration */ + struct ares_addr addr; + unsigned short udp_port; /* host byte order */ + unsigned short tcp_port; /* host byte order */ + char ll_iface[64]; /* IPv6 Link Local Interface */ + unsigned int ll_scope; /* IPv6 Link Local Scope */ + + size_t consec_failures; /* Consecutive query failure count + * can be hard errors or timeouts + */ + ares__llist_t *connections; + ares_conn_t *tcp_conn; /* The next time when we will retry this server if it has hit failures */ - ares_timeval_t next_retry_time; + ares_timeval_t next_retry_time; /* TCP buffer since multiple responses can come back in one read, or partial * in a read */ - ares__buf_t *tcp_parser; + ares__buf_t *tcp_parser; /* TCP output queue */ - ares__buf_t *tcp_send; + ares__buf_t *tcp_send; /*! Buckets for collecting metrics about the server */ - ares_server_metrics_t metrics[ARES_METRIC_COUNT]; + ares_server_metrics_t metrics[ARES_METRIC_COUNT]; + + /*! RFC 7873/9018 DNS Cookies */ + ares_cookie_t cookie; /* Link back to owning channel */ - ares_channel_t *channel; + ares_channel_t *channel; }; /* State to represent a DNS query */ -struct query { +struct ares_query { /* Query ID from qbuf, for faster lookup, and current timeout */ - unsigned short qid; /* host byte order */ - ares_timeval_t ts; /*!< Timestamp query was sent */ - ares_timeval_t timeout; - ares_channel_t *channel; + unsigned short qid; /* host byte order */ + ares_timeval_t ts; /*!< Timestamp query was sent */ + ares_timeval_t timeout; + ares_channel_t *channel; /* * Node object for each list entry the query belongs to in order to * make removal operations O(1). */ - ares__slist_node_t *node_queries_by_timeout; - ares__llist_node_t *node_queries_to_conn; - ares__llist_node_t *node_all_queries; + ares__slist_node_t *node_queries_by_timeout; + ares__llist_node_t *node_queries_to_conn; + ares__llist_node_t *node_all_queries; /* connection handle query is associated with */ - struct server_connection *conn; + ares_conn_t *conn; /* Query */ - ares_dns_record_t *query; + ares_dns_record_t *query; - ares_callback_dnsrec callback; - void *arg; + ares_callback_dnsrec callback; + void *arg; /* Query status */ size_t try_count; /* Number of times we tried this query already. */ + size_t cookie_try_count; /* Attempt count for cookie resends */ ares_bool_t using_tcp; ares_status_t error_status; - size_t timeouts; /* number of timeouts we saw for this request */ - ares_bool_t no_retries; /* do not perform any additional retries, this is set - * when a query is to be canceled */ + size_t timeouts; /* number of timeouts we saw for this request */ + ares_bool_t no_retries; /* do not perform any additional retries, this is + * set when a query is to be canceled */ }; struct apattern { @@ -408,10 +461,15 @@ ares_bool_t ares__timedout(const ares_timeval_t *now, const ares_timeval_t *check); /* Returns one of the normal ares status codes like ARES_SUCCESS */ -ares_status_t ares__send_query(struct query *query, const ares_timeval_t *now); -ares_status_t ares__requeue_query(struct query *query, - const ares_timeval_t *now, - ares_status_t status); +ares_status_t ares__send_query(ares_query_t *query, const ares_timeval_t *now); +ares_status_t ares__requeue_query(ares_query_t *query, + const ares_timeval_t *now, + ares_status_t status, + ares_bool_t inc_try_count, + const ares_dns_record_t *dnsrec); + +/*! Count the number of labels (dots+1) in a domain */ +size_t ares__name_label_cnt(const char *name); /*! Retrieve a list of names to use for searching. The first successful * query in the list wins. This function also uses the HOSTSALIASES file @@ -439,11 +497,10 @@ void *ares__dnsrec_convert_arg(ares_callback callback, void *arg); void ares__dnsrec_convert_cb(void *arg, ares_status_t status, size_t timeouts, const ares_dns_record_t *dnsrec); -void ares__close_connection(struct server_connection *conn, - ares_status_t requeue_status); -void ares__close_sockets(struct server_state *server); +void ares__close_connection(ares_conn_t *conn, ares_status_t requeue_status); +void ares__close_sockets(ares_server_t *server); void ares__check_cleanup_conns(const ares_channel_t *channel); -void ares__free_query(struct query *query); +void ares__free_query(ares_query_t *query); ares_rand_state *ares__init_rand_state(void); void ares__destroy_rand_state(ares_rand_state *state); @@ -550,23 +607,28 @@ ares_status_t ares__addrinfo2addrttl(const struct ares_addrinfo *ai, int family, ares_status_t ares__addrinfo_localhost(const char *name, unsigned short port, const struct ares_addrinfo_hints *hints, struct ares_addrinfo *ai); -ares_status_t ares__open_connection(ares_channel_t *channel, - struct server_state *server, - ares_bool_t is_tcp); +ares_status_t ares__open_connection(ares_conn_t **conn_out, + ares_channel_t *channel, + ares_server_t *server, ares_bool_t is_tcp); +ares_bool_t ares_sockaddr_to_ares_addr(struct ares_addr *ares_addr, + unsigned short *port, + const struct sockaddr *sockaddr); ares_socket_t ares__open_socket(ares_channel_t *channel, int af, int type, int protocol); -ares_ssize_t ares__socket_write(ares_channel_t *channel, ares_socket_t s, - const void *data, size_t len); +ares_bool_t ares__socket_try_again(int errnum); +ares_ssize_t ares__conn_write(ares_conn_t *conn, const void *data, size_t len); ares_ssize_t ares__socket_recvfrom(ares_channel_t *channel, ares_socket_t s, void *data, size_t data_len, int flags, struct sockaddr *from, ares_socklen_t *from_len); ares_ssize_t ares__socket_recv(ares_channel_t *channel, ares_socket_t s, void *data, size_t data_len); -void ares__close_socket(ares_channel, ares_socket_t); -int ares__connect_socket(ares_channel_t *channel, ares_socket_t sockfd, - const struct sockaddr *addr, ares_socklen_t addrlen); -void ares__destroy_server(struct server_state *server); +void ares__close_socket(ares_channel_t *channel, ares_socket_t s); +ares_status_t ares__connect_socket(ares_channel_t *channel, + ares_socket_t sockfd, + const struct sockaddr *addr, + ares_socklen_t addrlen); +void ares__destroy_server(ares_server_t *server); ares_status_t ares__servers_update(ares_channel_t *channel, ares__llist_t *server_list, @@ -582,8 +644,8 @@ ares_status_t ares__sconfig_append_fromstr(ares__llist_t **sconfig, ares_status_t ares_in_addr_to_server_config_llist(const struct in_addr *servers, size_t nservers, ares__llist_t **llist); -ares_status_t ares_get_server_addr(const struct server_state *server, - ares__buf_t *buf); +ares_status_t ares_get_server_addr(const ares_server_t *server, + ares__buf_t *buf); struct ares_hosts_entry; typedef struct ares_hosts_entry ares_hosts_entry_t; @@ -616,8 +678,8 @@ ares_status_t ares_query_nolock(ares_channel_t *channel, const char *name, * if a channel lock is already held */ ares_status_t ares_send_nolock(ares_channel_t *channel, const ares_dns_record_t *dnsrec, - ares_callback_dnsrec callback, - void *arg, unsigned short *qid); + ares_callback_dnsrec callback, void *arg, + unsigned short *qid); /* Same as ares_gethostbyaddr() except does not take a channel lock. Use this * if a channel lock is already held */ @@ -703,17 +765,24 @@ ares_status_t ares__qcache_create(ares_rand_state *rand_state, void ares__qcache_flush(ares__qcache_t *cache); ares_status_t ares_qcache_insert(ares_channel_t *channel, const ares_timeval_t *now, - const struct query *query, + const ares_query_t *query, ares_dns_record_t *dnsrec); ares_status_t ares_qcache_fetch(ares_channel_t *channel, const ares_timeval_t *now, const ares_dns_record_t *dnsrec, const ares_dns_record_t **dnsrec_resp); -void ares_metrics_record(const struct query *query, struct server_state *server, - ares_status_t status, const ares_dns_record_t *dnsrec); -size_t ares_metrics_server_timeout(const struct server_state *server, - const ares_timeval_t *now); +void ares_metrics_record(const ares_query_t *query, ares_server_t *server, + ares_status_t status, const ares_dns_record_t *dnsrec); +size_t ares_metrics_server_timeout(const ares_server_t *server, + const ares_timeval_t *now); + +ares_status_t ares_cookie_apply(ares_dns_record_t *dnsrec, ares_conn_t *conn, + const ares_timeval_t *now); +ares_status_t ares_cookie_validate(ares_query_t *query, + const ares_dns_record_t *dnsresp, + ares_conn_t *conn, + const ares_timeval_t *now); ares_status_t ares__channel_threading_init(ares_channel_t *channel); void ares__channel_threading_destroy(ares_channel_t *channel); diff --git a/lib/c-ares-1.32.3/src/lib/ares_process.c b/lib/c-ares-1.33.1/src/lib/ares_process.c similarity index 72% rename from lib/c-ares-1.32.3/src/lib/ares_process.c rename to lib/c-ares-1.33.1/src/lib/ares_process.c index 01d9e6a49d3..f05f67d8f2b 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_process.c +++ b/lib/c-ares-1.33.1/src/lib/ares_process.c @@ -46,7 +46,6 @@ static void timeadd(ares_timeval_t *now, size_t millisecs); -static ares_bool_t try_again(int errnum); static void write_tcp_data(ares_channel_t *channel, fd_set *write_fds, ares_socket_t write_fd); static void read_packets(ares_channel_t *channel, fd_set *read_fds, @@ -55,22 +54,20 @@ static void process_timeouts(ares_channel_t *channel, const ares_timeval_t *now); static ares_status_t process_answer(ares_channel_t *channel, const unsigned char *abuf, size_t alen, - struct server_connection *conn, - ares_bool_t tcp, const ares_timeval_t *now); -static void handle_conn_error(struct server_connection *conn, - ares_bool_t critical_failure, - ares_status_t failure_status); - -static ares_bool_t same_questions(const struct query *query, - const ares_dns_record_t *arec); -static ares_bool_t same_address(const struct sockaddr *sa, - const struct ares_addr *aa); -static void end_query(ares_channel_t *channel, struct server_state *server, - struct query *query, ares_status_t status, - const ares_dns_record_t *dnsrec); - - -static void ares__query_disassociate_from_conn(struct query *query) + ares_conn_t *conn, ares_bool_t tcp, + const ares_timeval_t *now); +static void handle_conn_error(ares_conn_t *conn, ares_bool_t critical_failure, + ares_status_t failure_status); + +static ares_bool_t same_questions(const ares_query_t *query, + const ares_dns_record_t *arec); +static ares_bool_t same_address(const struct sockaddr *sa, + const struct ares_addr *aa); +static void end_query(ares_channel_t *channel, ares_server_t *server, + ares_query_t *query, ares_status_t status, + const ares_dns_record_t *dnsrec); + +static void ares__query_disassociate_from_conn(ares_query_t *query) { /* If its not part of a connection, it can't be tracked for timeouts either */ ares__slist_node_destroy(query->node_queries_by_timeout); @@ -81,7 +78,7 @@ static void ares__query_disassociate_from_conn(struct query *query) } /* Invoke the server state callback after a success or failure */ -static void invoke_server_state_cb(const struct server_state *server, +static void invoke_server_state_cb(const ares_server_t *server, ares_bool_t success, int flags) { const ares_channel_t *channel = server->channel; @@ -115,8 +112,8 @@ static void invoke_server_state_cb(const struct server_state *server, ares_free(server_string); } -static void server_increment_failures(struct server_state *server, - ares_bool_t used_tcp) +static void server_increment_failures(ares_server_t *server, + ares_bool_t used_tcp) { ares__slist_node_t *node; const ares_channel_t *channel = server->channel; @@ -139,7 +136,7 @@ static void server_increment_failures(struct server_state *server, : ARES_SERV_STATE_UDP); } -static void server_set_good(struct server_state *server, ares_bool_t used_tcp) +static void server_set_good(ares_server_t *server, ares_bool_t used_tcp) { ares__slist_node_t *node; const ares_channel_t *channel = server->channel; @@ -238,34 +235,6 @@ void ares_process_fd(ares_channel_t *channel, processfds(channel, NULL, read_fd, NULL, write_fd); } -/* Return 1 if the specified error number describes a readiness error, or 0 - * otherwise. This is mostly for HP-UX, which could return EAGAIN or - * EWOULDBLOCK. See this man page - * - * http://devrsrc1.external.hp.com/STKS/cgi-bin/man2html? - * manpage=/usr/share/man/man2.Z/send.2 - */ -static ares_bool_t try_again(int errnum) -{ -#if !defined EWOULDBLOCK && !defined EAGAIN -# error "Neither EWOULDBLOCK nor EAGAIN defined" -#endif - -#ifdef EWOULDBLOCK - if (errnum == EWOULDBLOCK) { - return ARES_TRUE; - } -#endif - -#if defined EAGAIN && EAGAIN != EWOULDBLOCK - if (errnum == EAGAIN) { - return ARES_TRUE; - } -#endif - - return ARES_FALSE; -} - /* If any TCP sockets select true for writing, write out queued data * we have for them. */ @@ -281,7 +250,7 @@ static void write_tcp_data(ares_channel_t *channel, fd_set *write_fds, for (node = ares__slist_node_first(channel->servers); node != NULL; node = ares__slist_node_next(node)) { - struct server_state *server = ares__slist_node_val(node); + ares_server_t *server = ares__slist_node_val(node); const unsigned char *data; size_t data_len; ares_ssize_t count; @@ -312,9 +281,9 @@ static void write_tcp_data(ares_channel_t *channel, fd_set *write_fds, } data = ares__buf_peek(server->tcp_send, &data_len); - count = ares__socket_write(channel, server->tcp_conn->fd, data, data_len); + count = ares__conn_write(server->tcp_conn, data, data_len); if (count <= 0) { - if (!try_again(SOCKERRNO)) { + if (!ares__socket_try_again(SOCKERRNO)) { handle_conn_error(server->tcp_conn, ARES_TRUE, ARES_ECONNREFUSED); } continue; @@ -334,21 +303,21 @@ static void write_tcp_data(ares_channel_t *channel, fd_set *write_fds, * allocate a buffer if we finish reading the length word, and process * a packet if we finish reading one. */ -static void read_tcp_data(ares_channel_t *channel, - struct server_connection *conn, - const ares_timeval_t *now) +static void read_tcp_data(ares_channel_t *channel, ares_conn_t *conn, + const ares_timeval_t *now) { - ares_ssize_t count; - struct server_state *server = conn->server; + ares_ssize_t count; + ares_server_t *server = conn->server; /* Fetch buffer to store data we are reading */ - size_t ptr_len = 65535; - unsigned char *ptr; + size_t ptr_len = 65535; + unsigned char *ptr; ptr = ares__buf_append_start(server->tcp_parser, &ptr_len); if (ptr == NULL) { - handle_conn_error(conn, ARES_FALSE /* not critical to connection */, ARES_SUCCESS); + handle_conn_error(conn, ARES_FALSE /* not critical to connection */, + ARES_SUCCESS); return; /* bail out on malloc failure. TODO: make this function return error codes */ } @@ -357,7 +326,7 @@ static void read_tcp_data(ares_channel_t *channel, count = ares__socket_recv(channel, conn->fd, ptr, ptr_len); if (count <= 0) { ares__buf_append_finish(server->tcp_parser, 0); - if (!(count == -1 && try_again(SOCKERRNO))) { + if (!(count == -1 && ares__socket_try_again(SOCKERRNO))) { handle_conn_error(conn, ARES_TRUE, ARES_ECONNREFUSED); } return; @@ -411,69 +380,48 @@ static void read_tcp_data(ares_channel_t *channel, } } -static int socket_list_append(ares_socket_t **socketlist, ares_socket_t fd, - size_t *alloc_cnt, size_t *num) -{ - if (*num >= *alloc_cnt) { - /* Grow by powers of 2 */ - size_t new_alloc = (*alloc_cnt) << 1; - ares_socket_t *new_list = - ares_realloc(socketlist, new_alloc * sizeof(*new_list)); - if (new_list == NULL) { - return 0; /* LCOV_EXCL_LINE: OutOfMemory */ - } - *alloc_cnt = new_alloc; - *socketlist = new_list; - } - - (*socketlist)[(*num)++] = fd; - return 1; -} - static ares_socket_t *channel_socket_list(const ares_channel_t *channel, size_t *num) { - size_t alloc_cnt = 1 << 4; - ares_socket_t *out = ares_malloc(alloc_cnt * sizeof(*out)); ares__slist_node_t *snode; + ares__array_t *arr = ares__array_create(sizeof(ares_socket_t), NULL); *num = 0; - if (out == NULL) { + if (arr == NULL) { return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ } for (snode = ares__slist_node_first(channel->servers); snode != NULL; snode = ares__slist_node_next(snode)) { - struct server_state *server = ares__slist_node_val(snode); - ares__llist_node_t *node; + ares_server_t *server = ares__slist_node_val(snode); + ares__llist_node_t *node; for (node = ares__llist_node_first(server->connections); node != NULL; node = ares__llist_node_next(node)) { - const struct server_connection *conn = ares__llist_node_val(node); + const ares_conn_t *conn = ares__llist_node_val(node); + ares_socket_t *sptr; + ares_status_t status; if (conn->fd == ARES_SOCKET_BAD) { continue; } - if (!socket_list_append(&out, conn->fd, &alloc_cnt, num)) { - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + status = ares__array_insert_last((void **)&sptr, arr); + if (status != ARES_SUCCESS) { + ares__array_destroy(arr); /* LCOV_EXCL_LINE: OutOfMemory */ + return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ } + *sptr = conn->fd; } } - return out; - -fail: - ares_free(out); - *num = 0; - return NULL; + return ares__array_finish(arr, num); } /* If any UDP sockets select true for reading, process them. */ -static void read_udp_packets_fd(ares_channel_t *channel, - struct server_connection *conn, - const ares_timeval_t *now) +static void read_udp_packets_fd(ares_channel_t *channel, ares_conn_t *conn, + const ares_timeval_t *now) { ares_ssize_t read_len; unsigned char buf[MAXENDSSZ + 1]; @@ -511,7 +459,7 @@ static void read_udp_packets_fd(ares_channel_t *channel, * tcp */ continue; } else if (read_len < 0) { - if (try_again(SOCKERRNO)) { + if (ares__socket_try_again(SOCKERRNO)) { break; } @@ -537,11 +485,11 @@ static void read_udp_packets_fd(ares_channel_t *channel, static void read_packets(ares_channel_t *channel, fd_set *read_fds, ares_socket_t read_fd, const ares_timeval_t *now) { - size_t i; - ares_socket_t *socketlist = NULL; - size_t num_sockets = 0; - struct server_connection *conn = NULL; - ares__llist_node_t *node = NULL; + size_t i; + ares_socket_t *socketlist = NULL; + size_t num_sockets = 0; + ares_conn_t *conn = NULL; + ares__llist_node_t *node = NULL; if (!read_fds && (read_fd == ARES_SOCKET_BAD)) { /* no possible action */ @@ -557,7 +505,7 @@ static void read_packets(ares_channel_t *channel, fd_set *read_fds, conn = ares__llist_node_val(node); - if (conn->is_tcp) { + if (conn->flags & ARES_CONN_FLAG_TCP) { read_tcp_data(channel, conn, now); } else { read_udp_packets_fd(channel, conn, now); @@ -591,7 +539,7 @@ static void read_packets(ares_channel_t *channel, fd_set *read_fds, conn = ares__llist_node_val(node); - if (conn->is_tcp) { + if (conn->flags & ARES_CONN_FLAG_TCP) { read_tcp_data(channel, conn, now); } else { read_udp_packets_fd(channel, conn, now); @@ -610,8 +558,8 @@ static void process_timeouts(ares_channel_t *channel, const ares_timeval_t *now) * and go. We don't want to try to rely on 'next' as some operation might * cause a cleanup of that pointer and would become invalid */ while ((node = ares__slist_node_first(channel->queries_by_timeout)) != NULL) { - struct query *query = ares__slist_node_val(node); - struct server_connection *conn; + ares_query_t *query = ares__slist_node_val(node); + ares_conn_t *conn; /* Since this is sorted, as soon as we hit a query that isn't timed out, * break */ @@ -623,15 +571,15 @@ static void process_timeouts(ares_channel_t *channel, const ares_timeval_t *now) conn = query->conn; server_increment_failures(conn->server, query->using_tcp); - ares__requeue_query(query, now, ARES_ETIMEOUT); + ares__requeue_query(query, now, ARES_ETIMEOUT, ARES_TRUE, NULL); } } -static ares_status_t rewrite_without_edns(struct query *query) +static ares_status_t rewrite_without_edns(ares_query_t *query) { - ares_status_t status = ARES_SUCCESS; - size_t i; - ares_bool_t found_opt_rr = ARES_FALSE; + ares_status_t status = ARES_SUCCESS; + size_t i; + ares_bool_t found_opt_rr = ARES_FALSE; /* Find and remove the OPT RR record */ for (i = 0; i < ares_dns_record_rr_cnt(query->query, ARES_SECTION_ADDITIONAL); @@ -659,16 +607,16 @@ static ares_status_t rewrite_without_edns(struct query *query) * the connection to be terminated after this call. */ static ares_status_t process_answer(ares_channel_t *channel, const unsigned char *abuf, size_t alen, - struct server_connection *conn, - ares_bool_t tcp, const ares_timeval_t *now) + ares_conn_t *conn, ares_bool_t tcp, + const ares_timeval_t *now) { - struct query *query; + ares_query_t *query; /* Cache these as once ares__send_query() gets called, it may end up * invalidating the connection all-together */ - struct server_state *server = conn->server; - ares_dns_record_t *rdnsrec = NULL; - ares_status_t status; - ares_bool_t is_cached = ARES_FALSE; + ares_server_t *server = conn->server; + ares_dns_record_t *rdnsrec = NULL; + ares_status_t status; + ares_bool_t is_cached = ARES_FALSE; /* Parse the response */ status = ares_dns_parse(abuf, alen, 0, &rdnsrec); @@ -697,6 +645,14 @@ static ares_status_t process_answer(ares_channel_t *channel, goto cleanup; } + /* Validate DNS cookie in response. This function may need to requeue the + * query. */ + if (ares_cookie_validate(query, rdnsrec, conn, now) != ARES_SUCCESS) { + /* Drop response and return */ + status = ARES_SUCCESS; + goto cleanup; + } + /* At this point we know we've received an answer for this query, so we should * remove it from the connection's queue so we can possibly invalidate the * connection. Delay cleaning up the connection though as we may enqueue @@ -708,7 +664,8 @@ static ares_status_t process_answer(ares_channel_t *channel, * protocol extension is not understood by the responder. We must retry the * query without EDNS enabled. */ if (ares_dns_record_get_rcode(rdnsrec) == ARES_RCODE_FORMERR && - ares_dns_has_opt_rr(query->query) && !ares_dns_has_opt_rr(rdnsrec)) { + ares_dns_get_opt_rr_const(query->query) != NULL && + ares_dns_get_opt_rr_const(rdnsrec) == NULL) { status = rewrite_without_edns(query); if (status != ARES_SUCCESS) { end_query(channel, server, query, status, NULL); @@ -754,7 +711,7 @@ static ares_status_t process_answer(ares_channel_t *channel, } server_increment_failures(server, query->using_tcp); - ares__requeue_query(query, now, status); + ares__requeue_query(query, now, status, ARES_TRUE, rdnsrec); /* Should any of these cause a connection termination? * Maybe SERVER_FAILURE? */ @@ -783,25 +740,27 @@ static ares_status_t process_answer(ares_channel_t *channel, return status; } -static void handle_conn_error(struct server_connection *conn, - ares_bool_t critical_failure, - ares_status_t failure_status) +static void handle_conn_error(ares_conn_t *conn, ares_bool_t critical_failure, + ares_status_t failure_status) { - struct server_state *server = conn->server; + ares_server_t *server = conn->server; /* Increment failures first before requeue so it is unlikely to requeue * to the same server */ if (critical_failure) { - server_increment_failures(server, conn->is_tcp); + server_increment_failures( + server, (conn->flags & ARES_CONN_FLAG_TCP) ? ARES_TRUE : ARES_FALSE); } /* This will requeue any connections automatically */ ares__close_connection(conn, failure_status); } -ares_status_t ares__requeue_query(struct query *query, - const ares_timeval_t *now, - ares_status_t status) +ares_status_t ares__requeue_query(ares_query_t *query, + const ares_timeval_t *now, + ares_status_t status, + ares_bool_t inc_try_count, + const ares_dns_record_t *dnsrec) { ares_channel_t *channel = query->channel; size_t max_tries = ares__slist_len(channel->servers) * channel->tries; @@ -812,7 +771,10 @@ ares_status_t ares__requeue_query(struct query *query, query->error_status = status; } - query->try_count++; + if (inc_try_count) { + query->try_count++; + } + if (query->try_count < max_tries && !query->no_retries) { return ares__send_query(query, now); } @@ -822,14 +784,14 @@ ares_status_t ares__requeue_query(struct query *query, query->error_status = ARES_ETIMEOUT; } - end_query(channel, NULL, query, query->error_status, NULL); + end_query(channel, NULL, query, query->error_status, dnsrec); return ARES_ETIMEOUT; } /* Pick a random server from the list, we first get a random number in the * range of the number of servers, then scan until we find that server in * the list */ -static struct server_state *ares__random_server(ares_channel_t *channel) +static ares_server_t *ares__random_server(ares_channel_t *channel) { unsigned char c; size_t cnt; @@ -873,12 +835,11 @@ static struct server_state *ares__random_server(ares_channel_t *channel) * To resolve this, with some probability we select a failed server to retry * instead. */ -static struct server_state *ares__failover_server(ares_channel_t *channel) +static ares_server_t *ares__failover_server(ares_channel_t *channel) { - struct server_state *first_server = ares__slist_first_val(channel->servers); - const struct server_state *last_server = - ares__slist_last_val(channel->servers); - unsigned short r; + ares_server_t *first_server = ares__slist_first_val(channel->servers); + const ares_server_t *last_server = ares__slist_last_val(channel->servers); + unsigned short r; /* Defensive code against no servers being available on the channel. */ if (first_server == NULL) { @@ -911,7 +872,7 @@ static struct server_state *ares__failover_server(ares_channel_t *channel) ares__tvnow(&now); for (node = ares__slist_node_first(channel->servers); node != NULL; node = ares__slist_node_next(node)) { - struct server_state *node_val = ares__slist_node_val(node); + ares_server_t *node_val = ares__slist_node_val(node); if (node_val != NULL && node_val->consec_failures > 0 && ares__timedout(&now, &node_val->next_retry_time)) { return node_val; @@ -923,65 +884,9 @@ static struct server_state *ares__failover_server(ares_channel_t *channel) return first_server; } -static ares_status_t ares__append_tcpbuf(struct server_state *server, - const struct query *query) -{ - ares_status_t status; - unsigned char *qbuf = NULL; - size_t qbuf_len = 0; - - status = ares_dns_write(query->query, &qbuf, &qbuf_len); - if (status != ARES_SUCCESS) { - goto done; - } - - status = ares__buf_append_be16(server->tcp_send, (unsigned short)qbuf_len); - if (status != ARES_SUCCESS) { - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ - } - - status = ares__buf_append(server->tcp_send, qbuf, qbuf_len); - -done: - ares_free(qbuf); - return status; -} - - -static ares_status_t ares__write_udpbuf(ares_channel_t *channel, - ares_socket_t fd, - const struct query *query) -{ - ares_status_t status; - unsigned char *qbuf = NULL; - size_t qbuf_len = 0; - - status = ares_dns_write(query->query, &qbuf, &qbuf_len); - if (status != ARES_SUCCESS) { - goto done; - } - - if (ares__socket_write(channel, fd, qbuf, qbuf_len) == -1) { - if (try_again(SOCKERRNO)) { - status = ARES_ESERVFAIL; - } else { - /* UDP is connection-less, but we might receive an ICMP unreachable which - * means we can't talk to the remote host at all and that will be - * reflected here */ - status = ARES_ECONNREFUSED; - } - } else { - status = ARES_SUCCESS; - } - -done: - ares_free(qbuf); - return status; -} - -static size_t ares__calc_query_timeout(const struct query *query, - const struct server_state *server, - const ares_timeval_t *now) +static size_t ares__calc_query_timeout(const ares_query_t *query, + const ares_server_t *server, + const ares_timeval_t *now) { const ares_channel_t *channel = query->channel; size_t timeout = ares_metrics_server_timeout(server, now); @@ -1031,150 +936,187 @@ static size_t ares__calc_query_timeout(const struct query *query, return timeplus; } -ares_status_t ares__send_query(struct query *query, const ares_timeval_t *now) +static ares_conn_t *ares__fetch_connection(const ares_channel_t *channel, + ares_server_t *server, + const ares_query_t *query) { - ares_channel_t *channel = query->channel; - struct server_state *server; - struct server_connection *conn; - size_t timeplus; - ares_status_t status; - ares_bool_t new_connection = ARES_FALSE; + ares__llist_node_t *node; + ares_conn_t *conn; - /* Choose the server to send the query to */ - if (channel->rotate) { - /* Pull random server */ - server = ares__random_server(channel); - } else { - /* Pull server with failover behavior */ - server = ares__failover_server(channel); + if (query->using_tcp) { + return server->tcp_conn; } - if (server == NULL) { - end_query(channel, server, query, ARES_ENOSERVER /* ? */, NULL); - return ARES_ENOSERVER; + /* Fetch existing UDP connection */ + node = ares__llist_node_first(server->connections); + if (node == NULL) { + return NULL; } - if (query->using_tcp) { - size_t prior_len = 0; - /* Make sure the TCP socket for this server is set up and queue - * a send request. - */ - if (server->tcp_conn == NULL) { - new_connection = ARES_TRUE; - status = ares__open_connection(channel, server, ARES_TRUE); - switch (status) { - /* Good result, continue on */ - case ARES_SUCCESS: - break; + conn = ares__llist_node_val(node); + /* Not UDP, skip */ + if (conn->flags & ARES_CONN_FLAG_TCP) { + return NULL; + } - /* These conditions are retryable as they are server-specific - * error codes */ - case ARES_ECONNREFUSED: - case ARES_EBADFAMILY: - server_increment_failures(server, query->using_tcp); - return ares__requeue_query(query, now, status); + /* Used too many times */ + if (channel->udp_max_queries > 0 && + conn->total_queries >= channel->udp_max_queries) { + return NULL; + } - /* Anything else is not retryable, likely ENOMEM */ - default: - end_query(channel, server, query, status, NULL); - return status; - } - } + return conn; +} - conn = server->tcp_conn; +static ares_status_t ares__conn_query_write(ares_conn_t *conn, + ares_query_t *query, + const ares_timeval_t *now) +{ + unsigned char *qbuf = NULL; + size_t qbuf_len = 0; + ares_ssize_t len; + ares_server_t *server = conn->server; + ares_channel_t *channel = server->channel; + ares_status_t status; + + status = ares_cookie_apply(query->query, conn, now); + if (status != ARES_SUCCESS) { + return status; + } - prior_len = ares__buf_len(server->tcp_send); + if (conn->flags & ARES_CONN_FLAG_TCP) { + size_t prior_len = ares__buf_len(server->tcp_send); - status = ares__append_tcpbuf(server, query); + status = ares_dns_write_buf_tcp(query->query, server->tcp_send); if (status != ARES_SUCCESS) { - end_query(channel, server, query, status, NULL); + return status; + } + + if (conn->flags & ARES_CONN_FLAG_TFO_INITIAL) { + /* When using TFO, we need to put it on the wire immediately. */ + size_t data_len; + const unsigned char *data = NULL; + + data = ares__buf_peek(server->tcp_send, &data_len); + len = ares__conn_write(conn, data, data_len); + if (len <= 0) { + if (ares__socket_try_again(SOCKERRNO)) { + /* This means we must not have qualified for TFO, keep the data + * buffered, wait on write signal. */ + return ARES_SUCCESS; + } - /* Only safe to kill connection if it was new, otherwise it should be - * cleaned up by another process later */ - if (new_connection) { - ares__close_connection(conn, status); + /* TCP TFO might delay failure. Reflect that here */ + return ARES_ECONNREFUSED; } - return status; + + /* Consume what was written */ + ares__buf_consume(server->tcp_send, (size_t)len); + return ARES_SUCCESS; } if (prior_len == 0) { SOCK_STATE_CALLBACK(channel, conn->fd, 1, 1); } - } else { - ares__llist_node_t *node = ares__llist_node_first(server->connections); - - /* Don't use the found connection if we've gone over the maximum number - * of queries. Also, skip over the TCP connection if it is the first in - * the list */ - if (node != NULL) { - conn = ares__llist_node_val(node); - if (conn->is_tcp) { - node = NULL; - } else if (channel->udp_max_queries > 0 && - conn->total_queries >= channel->udp_max_queries) { - node = NULL; - } - } + return ARES_SUCCESS; + } - if (node == NULL) { - new_connection = ARES_TRUE; - status = ares__open_connection(channel, server, ARES_FALSE); - switch (status) { - /* Good result, continue on */ - case ARES_SUCCESS: - break; + /* UDP Here */ + status = ares_dns_write(query->query, &qbuf, &qbuf_len); + if (status != ARES_SUCCESS) { + return status; + } - /* These conditions are retryable as they are server-specific - * error codes */ - case ARES_ECONNREFUSED: - case ARES_EBADFAMILY: - server_increment_failures(server, query->using_tcp); - return ares__requeue_query(query, now, status); + len = ares__conn_write(conn, qbuf, qbuf_len); + ares_free(qbuf); - /* Anything else is not retryable, likely ENOMEM */ - default: - end_query(channel, server, query, status, NULL); - return status; - } - node = ares__llist_node_first(server->connections); + if (len == -1) { + if (ares__socket_try_again(SOCKERRNO)) { + return ARES_ESERVFAIL; } + /* UDP is connection-less, but we might receive an ICMP unreachable which + * means we can't talk to the remote host at all and that will be + * reflected here */ + return ARES_ECONNREFUSED; + } - conn = ares__llist_node_val(node); + return ARES_SUCCESS; +} - status = ares__write_udpbuf(channel, conn->fd, query); - if (status != ARES_SUCCESS) { - if (status == ARES_ENOMEM) { - /* Not retryable */ - end_query(channel, server, query, status, NULL); - return status; - } +ares_status_t ares__send_query(ares_query_t *query, const ares_timeval_t *now) +{ + ares_channel_t *channel = query->channel; + ares_server_t *server; + ares_conn_t *conn; + size_t timeplus; + ares_status_t status; - if (status == ARES_ECONNREFUSED) { - handle_conn_error(conn, ARES_TRUE, status); + /* Choose the server to send the query to */ + if (channel->rotate) { + /* Pull random server */ + server = ares__random_server(channel); + } else { + /* Pull server with failover behavior */ + server = ares__failover_server(channel); + } - /* This query wasn't yet bound to the connection, need to manually - * requeue it and return an appropriate error */ - status = ares__requeue_query(query, now, status); - if (status == ARES_ETIMEOUT) { - status = ARES_ECONNREFUSED; - } + if (server == NULL) { + end_query(channel, server, query, ARES_ENOSERVER /* ? */, NULL); + return ARES_ENOSERVER; + } + + conn = ares__fetch_connection(channel, server, query); + if (conn == NULL) { + status = ares__open_connection(&conn, channel, server, query->using_tcp); + switch (status) { + /* Good result, continue on */ + case ARES_SUCCESS: + break; + + /* These conditions are retryable as they are server-specific + * error codes */ + case ARES_ECONNREFUSED: + case ARES_EBADFAMILY: + server_increment_failures(server, query->using_tcp); + return ares__requeue_query(query, now, status, ARES_TRUE, NULL); + + /* Anything else is not retryable, likely ENOMEM */ + default: + end_query(channel, server, query, status, NULL); return status; - } + } + } - /* FIXME: Handle EAGAIN here since it likely can happen. Right now we - * just requeue to a different server/connection. */ - server_increment_failures(server, query->using_tcp); - status = ares__requeue_query(query, now, status); + /* Write the query */ + status = ares__conn_query_write(conn, query, now); + switch (status) { + /* Good result, continue on */ + case ARES_SUCCESS: + break; - /* Only safe to kill connection if it was new, otherwise it should be - * cleaned up by another process later */ - if (new_connection) { - ares__close_connection(conn, status); + case ARES_ENOMEM: + /* Not retryable */ + end_query(channel, server, query, status, NULL); + return status; + + /* These conditions are retryable as they are server-specific + * error codes */ + case ARES_ECONNREFUSED: + case ARES_EBADFAMILY: + handle_conn_error(conn, ARES_TRUE, status); + status = ares__requeue_query(query, now, status, ARES_TRUE, NULL); + if (status == ARES_ETIMEOUT) { + status = ARES_ECONNREFUSED; } + return status; + /* FIXME: Handle EAGAIN here since it likely can happen. Right now we + * just requeue to a different server/connection. */ + default: + server_increment_failures(server, query->using_tcp); + status = ares__requeue_query(query, now, status, ARES_TRUE, NULL); return status; - } } timeplus = ares__calc_query_timeout(query, server, now); @@ -1190,11 +1132,6 @@ ares_status_t ares__send_query(struct query *query, const ares_timeval_t *now) if (!query->node_queries_by_timeout) { /* LCOV_EXCL_START: OutOfMemory */ end_query(channel, server, query, ARES_ENOMEM, NULL); - /* Only safe to kill connection if it was new, otherwise it should be - * cleaned up by another process later */ - if (new_connection) { - ares__close_connection(conn, ARES_SUCCESS); - } return ARES_ENOMEM; /* LCOV_EXCL_STOP */ } @@ -1208,11 +1145,6 @@ ares_status_t ares__send_query(struct query *query, const ares_timeval_t *now) if (query->node_queries_to_conn == NULL) { /* LCOV_EXCL_START: OutOfMemory */ end_query(channel, server, query, ARES_ENOMEM, NULL); - /* Only safe to kill connection if it was new, otherwise it should be - * cleaned up by another process later */ - if (new_connection) { - ares__close_connection(conn, ARES_SUCCESS); - } return ARES_ENOMEM; /* LCOV_EXCL_STOP */ } @@ -1222,7 +1154,7 @@ ares_status_t ares__send_query(struct query *query, const ares_timeval_t *now) return ARES_SUCCESS; } -static ares_bool_t same_questions(const struct query *query, +static ares_bool_t same_questions(const ares_query_t *query, const ares_dns_record_t *arec) { size_t i; @@ -1299,7 +1231,8 @@ static ares_bool_t same_address(const struct sockaddr *sa, break; case AF_INET6: addr1 = &aa->addr.addr6; - addr2 = &(CARES_INADDR_CAST(const struct sockaddr_in6 *, sa))->sin6_addr; + addr2 = + &(CARES_INADDR_CAST(const struct sockaddr_in6 *, sa))->sin6_addr; if (memcmp(addr1, addr2, sizeof(aa->addr.addr6)) == 0) { return ARES_TRUE; /* match */ } @@ -1311,17 +1244,17 @@ static ares_bool_t same_address(const struct sockaddr *sa, return ARES_FALSE; /* different */ } -static void ares_detach_query(struct query *query) +static void ares_detach_query(ares_query_t *query) { /* Remove the query from all the lists in which it is linked */ ares__query_disassociate_from_conn(query); ares__htable_szvp_remove(query->channel->queries_by_qid, query->qid); ares__llist_node_destroy(query->node_all_queries); - query->node_all_queries = NULL; + query->node_all_queries = NULL; } -static void end_query(ares_channel_t *channel, struct server_state *server, - struct query *query, ares_status_t status, +static void end_query(ares_channel_t *channel, ares_server_t *server, + ares_query_t *query, ares_status_t status, const ares_dns_record_t *dnsrec) { ares_metrics_record(query, server, status, dnsrec); @@ -1338,7 +1271,7 @@ static void end_query(ares_channel_t *channel, struct server_state *server, ares_queue_notify_empty(channel); } -void ares__free_query(struct query *query) +void ares__free_query(ares_query_t *query) { ares_detach_query(query); /* Zero out some important stuff, to help catch bugs */ diff --git a/lib/c-ares-1.32.3/src/lib/ares_qcache.c b/lib/c-ares-1.33.1/src/lib/ares_qcache.c similarity index 96% rename from lib/c-ares-1.32.3/src/lib/ares_qcache.c rename to lib/c-ares-1.33.1/src/lib/ares_qcache.c index 2d9919fd104..9725212fded 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_qcache.c +++ b/lib/c-ares-1.33.1/src/lib/ares_qcache.c @@ -121,9 +121,11 @@ static char *ares__qcache_calc_key(const ares_dns_record_t *dnsrec) name_len--; } - status = ares__buf_append(buf, (const unsigned char *)name, name_len); - if (status != ARES_SUCCESS) { - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + if (name_len > 0) { + status = ares__buf_append(buf, (const unsigned char *)name, name_len); + if (status != ARES_SUCCESS) { + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + } } } @@ -300,10 +302,10 @@ static unsigned int ares__qcache_soa_minimum(ares_dns_record_t *dnsrec) } /* On success, takes ownership of dnsrec */ -static ares_status_t ares__qcache_insert(ares__qcache_t *qcache, - ares_dns_record_t *qresp, - const ares_dns_record_t *qreq, - const ares_timeval_t *now) +static ares_status_t ares__qcache_insert(ares__qcache_t *qcache, + ares_dns_record_t *qresp, + const ares_dns_record_t *qreq, + const ares_timeval_t *now) { ares__qcache_entry_t *entry; unsigned int ttl; @@ -346,8 +348,8 @@ static ares_status_t ares__qcache_insert(ares__qcache_t *qcache, } entry->dnsrec = qresp; - entry->expire_ts = now->sec + (time_t)ttl; - entry->insert_ts = now->sec; + entry->expire_ts = (time_t)now->sec + (time_t)ttl; + entry->insert_ts = (time_t)now->sec; /* We can't guarantee the server responded with the same flags as the * request had, so we have to re-parse the request in order to generate the @@ -422,9 +424,8 @@ ares_status_t ares_qcache_fetch(ares_channel_t *channel, ares_status_t ares_qcache_insert(ares_channel_t *channel, const ares_timeval_t *now, - const struct query *query, + const ares_query_t *query, ares_dns_record_t *dnsrec) { - return ares__qcache_insert(channel->qcache, dnsrec, query->query, - now); + return ares__qcache_insert(channel->qcache, dnsrec, query->query, now); } diff --git a/lib/c-ares-1.32.3/src/lib/ares_query.c b/lib/c-ares-1.33.1/src/lib/ares_query.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_query.c rename to lib/c-ares-1.33.1/src/lib/ares_query.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_search.c b/lib/c-ares-1.33.1/src/lib/ares_search.c similarity index 93% rename from lib/c-ares-1.32.3/src/lib/ares_search.c rename to lib/c-ares-1.33.1/src/lib/ares_search.c index ae98df39a80..2d3c0fc5145 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_search.c +++ b/lib/c-ares-1.33.1/src/lib/ares_search.c @@ -107,26 +107,37 @@ static void search_callback(void *arg, ares_status_t status, size_t timeouts, { struct search_query *squery = (struct search_query *)arg; ares_channel_t *channel = squery->channel; - ares_dns_rcode_t rcode; - size_t ancount; + ares_status_t mystatus; ares_bool_t skip_cleanup = ARES_FALSE; squery->timeouts += timeouts; - if (status != ARES_SUCCESS) { - end_squery(squery, status, dnsrec); - return; - } - - rcode = ares_dns_record_get_rcode(dnsrec); - ancount = ares_dns_record_rr_cnt(dnsrec, ARES_SECTION_ANSWER); - mystatus = ares_dns_query_reply_tostatus(rcode, ancount); - - if (mystatus != ARES_ENODATA && mystatus != ARES_ESERVFAIL && - mystatus != ARES_ENOTFOUND) { - end_squery(squery, mystatus, dnsrec); - return; + if (dnsrec) { + ares_dns_rcode_t rcode = ares_dns_record_get_rcode(dnsrec); + size_t ancount = ares_dns_record_rr_cnt(dnsrec, + ARES_SECTION_ANSWER); + mystatus = ares_dns_query_reply_tostatus(rcode, ancount); + } else { + mystatus = status; + } + + switch (mystatus) { + case ARES_ENODATA: + case ARES_ENOTFOUND: + break; + case ARES_ESERVFAIL: + case ARES_EREFUSED: + /* Issue #852, systemd-resolved may return SERVFAIL or REFUSED on a + * single label domain name. */ + if (ares__name_label_cnt(squery->names[squery->next_name_idx-1]) != 1) { + end_squery(squery, mystatus, dnsrec); + return; + } + break; + default: + end_squery(squery, mystatus, dnsrec); + return; } /* If we ever get ARES_ENODATA along the way, record that; if the search @@ -147,7 +158,6 @@ static void search_callback(void *arg, ares_status_t status, size_t timeouts, return; } - /* We have no more domains to search, return an appropriate response. */ if (mystatus == ARES_ENOTFOUND && squery->ever_got_nodata) { end_squery(squery, ARES_ENODATA, NULL); @@ -176,6 +186,25 @@ static ares_bool_t ares__search_eligible(const ares_channel_t *channel, return ARES_TRUE; } +size_t ares__name_label_cnt(const char *name) +{ + const char *p; + size_t ndots = 0; + + if (name == NULL) { + return 0; + } + + for (p = name; p != NULL && *p != 0; p++) { + if (*p == '.') { + ndots++; + } + } + + /* Label count is 1 greater than ndots */ + return ndots+1; +} + ares_status_t ares__search_name_list(const ares_channel_t *channel, const char *name, char ***names, size_t *names_len) @@ -186,7 +215,6 @@ ares_status_t ares__search_name_list(const ares_channel_t *channel, char *alias = NULL; size_t ndots = 0; size_t idx = 0; - const char *p; size_t i; /* Perform HOSTALIASES resolution */ @@ -223,12 +251,10 @@ ares_status_t ares__search_name_list(const ares_channel_t *channel, goto done; } - /* Count the number of dots in name */ - ndots = 0; - for (p = name; *p != 0; p++) { - if (*p == '.') { - ndots++; - } + /* Count the number of dots in name, 1 less than label count */ + ndots = ares__name_label_cnt(name); + if (ndots > 0) { + ndots--; } /* Allocate an entry for each search domain, plus one for as-is */ diff --git a/lib/c-ares-1.32.3/src/lib/ares_send.c b/lib/c-ares-1.33.1/src/lib/ares_send.c similarity index 91% rename from lib/c-ares-1.32.3/src/lib/ares_send.c rename to lib/c-ares-1.33.1/src/lib/ares_send.c index e07ef5b51fe..64ff7edd3ac 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_send.c +++ b/lib/c-ares-1.33.1/src/lib/ares_send.c @@ -43,13 +43,12 @@ static unsigned short generate_unique_qid(ares_channel_t *channel) return id; } - /* https://datatracker.ietf.org/doc/html/draft-vixie-dnsext-dns0x20-00 */ -static ares_status_t ares_apply_dns0x20(ares_channel_t *channel, +static ares_status_t ares_apply_dns0x20(ares_channel_t *channel, ares_dns_record_t *dnsrec) { - ares_status_t status = ARES_SUCCESS; - const char *name = NULL; + ares_status_t status = ARES_SUCCESS; + const char *name = NULL; char dns0x20name[256]; unsigned char randdata[256 / 8]; size_t len; @@ -63,7 +62,11 @@ static ares_status_t ares_apply_dns0x20(ares_channel_t *channel, } len = ares_strlen(name); - if (len == 0 || len >= sizeof(dns0x20name)) { + if (len == 0) { + return ARES_SUCCESS; + } + + if (len >= sizeof(dns0x20name)) { status = ARES_EBADNAME; goto done; } @@ -72,16 +75,16 @@ static ares_status_t ares_apply_dns0x20(ares_channel_t *channel, /* Fetch the minimum amount of random data we'd need for the string, which * is 1 bit per byte */ - total_bits = ((len + 7) / 8) * 8; + total_bits = ((len + 7) / 8) * 8; remaining_bits = total_bits; ares__rand_bytes(channel->rand_state, randdata, total_bits / 8); /* Randomly apply 0x20 to name */ - for (i=0; iqid = id; query->timeout.sec = 0; query->timeout.usec = 0; - query->using_tcp = (channel->flags & ARES_FLAG_USEVC)?ARES_TRUE:ARES_FALSE; + query->using_tcp = + (channel->flags & ARES_FLAG_USEVC) ? ARES_TRUE : ARES_FALSE; /* Duplicate Query */ status = ares_dns_record_duplicate_ex(&query->query, dnsrec); diff --git a/lib/c-ares-1.32.3/src/lib/ares_setup.h b/lib/c-ares-1.33.1/src/lib/ares_setup.h similarity index 79% rename from lib/c-ares-1.32.3/src/lib/ares_setup.h rename to lib/c-ares-1.33.1/src/lib/ares_setup.h index 1b554f1974c..b6ce077ff64 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_setup.h +++ b/lib/c-ares-1.33.1/src/lib/ares_setup.h @@ -231,95 +231,6 @@ struct timeval { }; #endif - -/* - * If we have the MSG_NOSIGNAL define, make sure we use - * it as the fourth argument of function send() - */ - -#ifdef HAVE_MSG_NOSIGNAL -# define SEND_4TH_ARG MSG_NOSIGNAL -#else -# define SEND_4TH_ARG 0 -#endif - - -#if defined(__minix) -/* Minix doesn't support recv on TCP sockets */ -# define sread(x, y, z) \ - (ares_ssize_t) \ - read((RECV_TYPE_ARG1)(x), (RECV_TYPE_ARG2)(y), (RECV_TYPE_ARG3)(z)) - -#elif defined(HAVE_RECV) -/* - * The definitions for the return type and arguments types - * of functions recv() and send() belong and come from the - * configuration file. Do not define them in any other place. - * - * HAVE_RECV is defined if you have a function named recv() - * which is used to read incoming data from sockets. If your - * function has another name then don't define HAVE_RECV. - * - * If HAVE_RECV is defined then RECV_TYPE_ARG1, RECV_TYPE_ARG2, - * RECV_TYPE_ARG3, RECV_TYPE_ARG4 and RECV_TYPE_RETV must also - * be defined. - * - * HAVE_SEND is defined if you have a function named send() - * which is used to write outgoing data on a connected socket. - * If yours has another name then don't define HAVE_SEND. - * - * If HAVE_SEND is defined then SEND_TYPE_ARG1, - * SEND_TYPE_ARG2, SEND_TYPE_ARG3, SEND_TYPE_ARG4 and - * SEND_TYPE_RETV must also be defined. - */ - -# if !defined(RECV_TYPE_ARG1) || !defined(RECV_TYPE_ARG2) || \ - !defined(RECV_TYPE_ARG3) || !defined(RECV_TYPE_ARG4) || \ - !defined(RECV_TYPE_RETV) -/* */ -Error Missing_definition_of_return_and_arguments_types_of_recv -/* */ -# else -# define sread(x, y, z) \ - (ares_ssize_t) recv((RECV_TYPE_ARG1)(x), (RECV_TYPE_ARG2)(y), \ - (RECV_TYPE_ARG3)(z), (RECV_TYPE_ARG4)(0)) -# endif -#else /* HAVE_RECV */ -# ifndef sread -/* */ -Error Missing_definition_of_macro_sread -/* */ -# endif -#endif /* HAVE_RECV */ - - -#if defined(__minix) -/* Minix doesn't support send on TCP sockets */ -# define swrite(x, y, z) \ - (ares_ssize_t) \ - write((SEND_TYPE_ARG1)(x), (SEND_TYPE_ARG2)(y), (SEND_TYPE_ARG3)(z)) - -#elif defined(HAVE_SEND) -# if !defined(SEND_TYPE_ARG1) || \ - !defined(SEND_TYPE_ARG2) || !defined(SEND_TYPE_ARG3) || \ - !defined(SEND_TYPE_ARG4) || !defined(SEND_TYPE_RETV) - /* */ - Error Missing_definition_of_return_and_arguments_types_of_send -/* */ -# else -# define swrite(x, y, z) \ - (ares_ssize_t) send((SEND_TYPE_ARG1)(x), (SEND_TYPE_ARG2)(y), \ - (SEND_TYPE_ARG3)(z), (SEND_TYPE_ARG4)(SEND_4TH_ARG)) -# endif -#else /* HAVE_SEND */ -# ifndef swrite - /* */ - Error Missing_definition_of_macro_swrite -/* */ -# endif -#endif /* HAVE_SEND */ - - /* * Function-like macro definition used to close a socket. */ @@ -343,7 +254,7 @@ Error Missing_definition_of_macro_sread #else # define DEBUGF(x) \ do { \ - } while(0) + } while (0) #endif /* diff --git a/lib/c-ares-1.32.3/src/lib/ares_strerror.c b/lib/c-ares-1.33.1/src/lib/ares_strerror.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_strerror.c rename to lib/c-ares-1.33.1/src/lib/ares_strerror.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_sysconfig.c b/lib/c-ares-1.33.1/src/lib/ares_sysconfig.c similarity index 99% rename from lib/c-ares-1.32.3/src/lib/ares_sysconfig.c rename to lib/c-ares-1.33.1/src/lib/ares_sysconfig.c index 2cd3df28235..61e6a423a75 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_sysconfig.c +++ b/lib/c-ares-1.33.1/src/lib/ares_sysconfig.c @@ -239,7 +239,7 @@ static ares_status_t ares__init_sysconfig_android(ares_sysconfig_t *sysconfig) char propname[PROP_NAME_MAX]; char propvalue[PROP_VALUE_MAX] = ""; for (i = 1; i <= MAX_DNS_PROPERTIES; i++) { - snprintf(propname, sizeof(propname), "%s%u", DNS_PROP_NAME_PREFIX, i); + snprintf(propname, sizeof(propname), "%s%zu", DNS_PROP_NAME_PREFIX, i); if (__system_property_get(propname, propvalue) < 1) { break; } @@ -494,6 +494,7 @@ ares_status_t ares__init_by_sysconfig(ares_channel_t *channel) ares_sysconfig_t sysconfig; memset(&sysconfig, 0, sizeof(sysconfig)); + sysconfig.ndots = 1; /* Default value if not otherwise set */ #if defined(USE_WINSOCK) status = ares__init_sysconfig_windows(&sysconfig); diff --git a/lib/c-ares-1.32.3/src/lib/ares_sysconfig_files.c b/lib/c-ares-1.33.1/src/lib/ares_sysconfig_files.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_sysconfig_files.c rename to lib/c-ares-1.33.1/src/lib/ares_sysconfig_files.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_sysconfig_mac.c b/lib/c-ares-1.33.1/src/lib/ares_sysconfig_mac.c similarity index 92% rename from lib/c-ares-1.32.3/src/lib/ares_sysconfig_mac.c rename to lib/c-ares-1.33.1/src/lib/ares_sysconfig_mac.c index e2136201f68..38ac451ca5f 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_sysconfig_mac.c +++ b/lib/c-ares-1.33.1/src/lib/ares_sysconfig_mac.c @@ -115,11 +115,11 @@ static ares_status_t dnsinfo_init(dnsinfo_t **dnsinfo_out) continue; } - dnsinfo->dns_configuration_copy = (dns_config_t *(*)(void)) + dnsinfo->dns_configuration_copy = (dns_config_t * (*)(void)) dlsym(dnsinfo->handle, "dns_configuration_copy"); - dnsinfo->dns_configuration_free = (void (*)(dns_config_t *)) - dlsym(dnsinfo->handle, "dns_configuration_free"); + dnsinfo->dns_configuration_free = (void (*)(dns_config_t *))dlsym( + dnsinfo->handle, "dns_configuration_free"); if (dnsinfo->dns_configuration_copy != NULL && dnsinfo->dns_configuration_free != NULL) { @@ -274,25 +274,7 @@ static ares_status_t read_resolver(const dns_resolver_t *resolver, /* UBSAN alignment workaround to fetch memory address */ memcpy(&sockaddr, resolver->nameserver + i, sizeof(sockaddr)); - if (sockaddr->sa_family == AF_INET) { - /* NOTE: memcpy sockaddr_in due to alignment issues found by UBSAN due to - * dnsinfo packing */ - struct sockaddr_in addr_in; - memcpy(&addr_in, sockaddr, sizeof(addr_in)); - - addr.family = AF_INET; - memcpy(&addr.addr.addr4, &(addr_in.sin_addr), sizeof(addr.addr.addr4)); - addrport = ntohs(addr_in.sin_port); - } else if (sockaddr->sa_family == AF_INET6) { - /* NOTE: memcpy sockaddr_in6 due to alignment issues found by UBSAN due to - * dnsinfo packing */ - struct sockaddr_in6 addr_in6; - memcpy(&addr_in6, sockaddr, sizeof(addr_in6)); - - addr.family = AF_INET6; - memcpy(&addr.addr.addr6, &(addr_in6.sin6_addr), sizeof(addr.addr.addr6)); - addrport = ntohs(addr_in6.sin6_port); - } else { + if (!ares_sockaddr_to_ares_addr(&addr, &addrport, sockaddr)) { continue; } diff --git a/lib/c-ares-1.32.3/src/lib/ares_sysconfig_win.c b/lib/c-ares-1.33.1/src/lib/ares_sysconfig_win.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_sysconfig_win.c rename to lib/c-ares-1.33.1/src/lib/ares_sysconfig_win.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_timeout.c b/lib/c-ares-1.33.1/src/lib/ares_timeout.c similarity index 88% rename from lib/c-ares-1.32.3/src/lib/ares_timeout.c rename to lib/c-ares-1.33.1/src/lib/ares_timeout.c index dac439b1b43..5ed8b553a3c 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_timeout.c +++ b/lib/c-ares-1.33.1/src/lib/ares_timeout.c @@ -65,7 +65,8 @@ void ares__timeval_diff(ares_timeval_t *tvdiff, const ares_timeval_t *tvstart, } } -static void ares_timeval_to_struct_timeval(struct timeval *tv, const ares_timeval_t *atv) +static void ares_timeval_to_struct_timeval(struct timeval *tv, + const ares_timeval_t *atv) { #ifdef USE_WINSOCK tv->tv_sec = (long)atv->sec; @@ -76,17 +77,18 @@ static void ares_timeval_to_struct_timeval(struct timeval *tv, const ares_timeva tv->tv_usec = (int)atv->usec; } -static void struct_timeval_to_ares_timeval(ares_timeval_t *atv, const struct timeval *tv) +static void struct_timeval_to_ares_timeval(ares_timeval_t *atv, + const struct timeval *tv) { atv->sec = (ares_int64_t)tv->tv_sec; atv->usec = (unsigned int)tv->tv_usec; } static struct timeval *ares_timeout_int(const ares_channel_t *channel, - struct timeval *maxtv, - struct timeval *tvbuf) + struct timeval *maxtv, + struct timeval *tvbuf) { - const struct query *query; + const ares_query_t *query; ares__slist_node_t *node; ares_timeval_t now; ares_timeval_t atvbuf; @@ -135,8 +137,9 @@ struct timeval *ares_timeout(const ares_channel_t *channel, { struct timeval *rv; - if (channel == NULL || tvbuf == NULL) + if (channel == NULL || tvbuf == NULL) { return NULL; + } ares__channel_lock(channel); diff --git a/lib/c-ares-1.32.3/src/lib/ares_update_servers.c b/lib/c-ares-1.33.1/src/lib/ares_update_servers.c similarity index 97% rename from lib/c-ares-1.32.3/src/lib/ares_update_servers.c rename to lib/c-ares-1.33.1/src/lib/ares_update_servers.c index 455e3001d5c..639f79d8159 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_update_servers.c +++ b/lib/c-ares-1.33.1/src/lib/ares_update_servers.c @@ -525,7 +525,7 @@ static ares__slist_node_t *ares__server_find(ares_channel_t *channel, for (node = ares__slist_node_first(channel->servers); node != NULL; node = ares__slist_node_next(node)) { - const struct server_state *server = ares__slist_node_val(node); + const ares_server_t *server = ares__slist_node_val(node); if (!ares__addr_match(&server->addr, &s->addr)) { continue; @@ -579,8 +579,8 @@ static ares_status_t ares__server_create(ares_channel_t *channel, const ares_sconfig_t *sconfig, size_t idx) { - ares_status_t status; - struct server_state *server = ares_malloc_zero(sizeof(*server)); + ares_status_t status; + ares_server_t *server = ares_malloc_zero(sizeof(*server)); if (server == NULL) { return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ @@ -641,8 +641,8 @@ static ares_status_t ares__server_create(ares_channel_t *channel, return status; } -static ares_bool_t ares__server_in_newconfig(const struct server_state *server, - ares__llist_t *srvlist) +static ares_bool_t ares__server_in_newconfig(const ares_server_t *server, + ares__llist_t *srvlist) { ares__llist_node_t *node; const ares_channel_t *channel = server->channel; @@ -676,8 +676,8 @@ static ares_bool_t ares__servers_remove_stale(ares_channel_t *channel, ares__slist_node_t *snode = ares__slist_node_first(channel->servers); while (snode != NULL) { - ares__slist_node_t *snext = ares__slist_node_next(snode); - const struct server_state *server = ares__slist_node_val(snode); + ares__slist_node_t *snext = ares__slist_node_next(snode); + const ares_server_t *server = ares__slist_node_val(snode); if (!ares__server_in_newconfig(server, srvlist)) { /* This will clean up all server state via the destruction callback and * move any queries to new servers */ @@ -726,7 +726,7 @@ ares_status_t ares__servers_update(ares_channel_t *channel, snode = ares__server_find(channel, sconfig); if (snode != NULL) { - struct server_state *server = ares__slist_node_val(snode); + ares_server_t *server = ares__slist_node_val(snode); /* Copy over link-local settings. Its possible some of this data has * changed, maybe ... */ @@ -928,8 +928,8 @@ ares_status_t ares_in_addr_to_server_config_llist(const struct in_addr *servers, } /* Write out the details of a server to a buffer */ -ares_status_t ares_get_server_addr(const struct server_state *server, - ares__buf_t *buf) +ares_status_t ares_get_server_addr(const ares_server_t *server, + ares__buf_t *buf) { ares_status_t status; char addr[INET6_ADDRSTRLEN]; @@ -1000,7 +1000,7 @@ int ares_get_servers(const ares_channel_t *channel, for (node = ares__slist_node_first(channel->servers); node != NULL; node = ares__slist_node_next(node)) { - const struct server_state *server = ares__slist_node_val(node); + const ares_server_t *server = ares__slist_node_val(node); /* Allocate storage for this server node appending it to the list */ srvr_curr = ares_malloc_data(ARES_DATATYPE_ADDR_NODE); @@ -1055,7 +1055,7 @@ int ares_get_servers_ports(const ares_channel_t *channel, for (node = ares__slist_node_first(channel->servers); node != NULL; node = ares__slist_node_next(node)) { - const struct server_state *server = ares__slist_node_val(node); + const ares_server_t *server = ares__slist_node_val(node); /* Allocate storage for this server node appending it to the list */ srvr_curr = ares_malloc_data(ARES_DATATYPE_ADDR_PORT_NODE); @@ -1203,8 +1203,8 @@ char *ares_get_servers_csv(const ares_channel_t *channel) for (node = ares__slist_node_first(channel->servers); node != NULL; node = ares__slist_node_next(node)) { - ares_status_t status; - const struct server_state *server = ares__slist_node_val(node); + ares_status_t status; + const ares_server_t *server = ares__slist_node_val(node); if (ares__buf_len(buf)) { status = ares__buf_append_byte(buf, ','); diff --git a/lib/c-ares-1.32.3/src/lib/ares_version.c b/lib/c-ares-1.33.1/src/lib/ares_version.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_version.c rename to lib/c-ares-1.33.1/src/lib/ares_version.c diff --git a/lib/c-ares-1.32.3/src/lib/cares.rc b/lib/c-ares-1.33.1/src/lib/cares.rc similarity index 100% rename from lib/c-ares-1.32.3/src/lib/cares.rc rename to lib/c-ares-1.33.1/src/lib/cares.rc diff --git a/lib/c-ares-1.32.3/src/lib/config-dos.h b/lib/c-ares-1.33.1/src/lib/config-dos.h similarity index 100% rename from lib/c-ares-1.32.3/src/lib/config-dos.h rename to lib/c-ares-1.33.1/src/lib/config-dos.h diff --git a/lib/c-ares-1.32.3/src/lib/config-win32.h b/lib/c-ares-1.33.1/src/lib/config-win32.h similarity index 98% rename from lib/c-ares-1.32.3/src/lib/config-win32.h rename to lib/c-ares-1.33.1/src/lib/config-win32.h index da5c7483879..b9c4ec17336 100644 --- a/lib/c-ares-1.32.3/src/lib/config-win32.h +++ b/lib/c-ares-1.33.1/src/lib/config-win32.h @@ -352,6 +352,9 @@ # define HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID 1 #endif +/* Define to 1 if you have the `RegisterWaitForSingleObject' function. */ +#define HAVE_REGISTERWAITFORSINGLEOBJECT 1 + #if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0600) && \ !defined(__WATCOMC__) && !defined(WATT32) /* Define if you have if_nametoindex() */ @@ -362,6 +365,8 @@ # define HAVE_CONVERTINTERFACEINDEXTOLUID 1 /* Define to 1 if you have the `ConvertInterfaceLuidToNameA' function. */ # define HAVE_CONVERTINTERFACELUIDTONAMEA 1 +/* Define to 1 if you have the `NotifyIpInterfaceChange' function. */ +# define HAVE_NOTIFYIPINTERFACECHANGE 1 #endif /* ---------------------------------------------------------------- */ diff --git a/lib/c-ares-1.33.1/src/lib/dsa/ares__array.c b/lib/c-ares-1.33.1/src/lib/dsa/ares__array.c new file mode 100644 index 00000000000..0c724248bf2 --- /dev/null +++ b/lib/c-ares-1.33.1/src/lib/dsa/ares__array.c @@ -0,0 +1,356 @@ +/* MIT License + * + * Copyright (c) 2024 Brad House + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * SPDX-License-Identifier: MIT + */ +#include "ares_private.h" +#include "ares__array.h" + +#define ARES__ARRAY_MIN 4 + +struct ares__array { + ares__array_destructor_t destruct; + void *arr; + size_t member_size; + size_t cnt; + size_t offset; + size_t alloc_cnt; +}; + +ares__array_t *ares__array_create(size_t member_size, + ares__array_destructor_t destruct) +{ + ares__array_t *arr; + + if (member_size == 0) { + return NULL; + } + + arr = ares_malloc_zero(sizeof(*arr)); + if (arr == NULL) { + return NULL; + } + + arr->member_size = member_size; + arr->destruct = destruct; + return arr; +} + +size_t ares__array_len(const ares__array_t *arr) +{ + if (arr == NULL) { + return 0; + } + return arr->cnt; +} + +void *ares__array_at(ares__array_t *arr, size_t idx) +{ + if (arr == NULL || idx >= arr->cnt) { + return NULL; + } + return (unsigned char *)arr->arr + ((idx + arr->offset) * arr->member_size); +} + +const void *ares__array_at_const(const ares__array_t *arr, size_t idx) +{ + if (arr == NULL || idx >= arr->cnt) { + return NULL; + } + return (unsigned char *)arr->arr + ((idx + arr->offset) * arr->member_size); +} + +ares_status_t ares__array_sort(ares__array_t *arr, ares__array_cmp_t cmp) +{ + if (arr == NULL || cmp == NULL) { + return ARES_EFORMERR; + } + + /* Nothing to sort */ + if (arr->cnt < 2) { + return ARES_SUCCESS; + } + + qsort((unsigned char *)arr->arr + (arr->offset * arr->member_size), arr->cnt, + arr->member_size, cmp); + return ARES_SUCCESS; +} + +void ares__array_destroy(ares__array_t *arr) +{ + size_t i; + + if (arr == NULL) { + return; + } + + if (arr->destruct != NULL) { + for (i = 0; i < arr->cnt; i++) { + arr->destruct(ares__array_at(arr, i)); + } + } + + ares_free(arr->arr); + ares_free(arr); +} + +/* NOTE: this function operates on actual indexes, NOT indexes using the + * arr->offset */ +static ares_status_t ares__array_move(ares__array_t *arr, size_t dest_idx, + size_t src_idx) +{ + void *dest_ptr; + const void *src_ptr; + size_t nmembers; + + if (arr == NULL || dest_idx >= arr->alloc_cnt || src_idx >= arr->alloc_cnt) { + return ARES_EFORMERR; + } + + /* Nothing to do */ + if (dest_idx == src_idx) { + return ARES_SUCCESS; + } + + dest_ptr = (unsigned char *)arr->arr + (dest_idx * arr->member_size); + src_ptr = (unsigned char *)arr->arr + (src_idx * arr->member_size); + + /* Check to make sure shifting to the right won't overflow our allocation + * boundary */ + if (dest_idx > src_idx && arr->cnt + (dest_idx - src_idx) > arr->alloc_cnt) { + return ARES_EFORMERR; + } + if (dest_idx < src_idx) { + nmembers = arr->cnt - dest_idx; + } else { + nmembers = arr->cnt - src_idx; + } + + memmove(dest_ptr, src_ptr, nmembers * arr->member_size); + + return ARES_SUCCESS; +} + +void *ares__array_finish(ares__array_t *arr, size_t *num_members) +{ + void *ptr; + + if (arr == NULL || num_members == NULL) { + return NULL; + } + + /* Make sure we move data to beginning of allocation */ + if (arr->offset != 0) { + if (ares__array_move(arr, 0, arr->offset) != ARES_SUCCESS) { + return NULL; + } + arr->offset = 0; + } + + ptr = arr->arr; + *num_members = arr->cnt; + ares_free(arr); + return ptr; +} + +ares_status_t ares__array_set_size(ares__array_t *arr, size_t size) +{ + void *temp; + + if (arr == NULL || size == 0 || size < arr->cnt) { + return ARES_EFORMERR; + } + + /* Always operate on powers of 2 */ + size = ares__round_up_pow2(size); + + if (size < ARES__ARRAY_MIN) { + size = ARES__ARRAY_MIN; + } + + /* If our allocation size is already large enough, skip */ + if (size <= arr->alloc_cnt) { + return ARES_SUCCESS; + } + + temp = ares_realloc_zero(arr->arr, arr->alloc_cnt * arr->member_size, + size * arr->member_size); + if (temp == NULL) { + return ARES_ENOMEM; + } + arr->alloc_cnt = size; + arr->arr = temp; + return ARES_SUCCESS; +} + +ares_status_t ares__array_insert_at(void **elem_ptr, ares__array_t *arr, + size_t idx) +{ + void *ptr; + ares_status_t status; + + if (arr == NULL) { + return ARES_EFORMERR; + } + + /* Not >= since we are allowed to append to the end */ + if (idx > arr->cnt) { + return ARES_EFORMERR; + } + + /* Allocate more if needed */ + status = ares__array_set_size(arr, arr->cnt + 1); + if (status != ARES_SUCCESS) { + return status; + } + + /* Shift if we have memory but not enough room at the end */ + if (arr->cnt + 1 + arr->offset > arr->alloc_cnt) { + status = ares__array_move(arr, 0, arr->offset); + if (status != ARES_SUCCESS) { + return status; + } + arr->offset = 0; + } + + /* If we're inserting anywhere other than the end, we need to move some + * elements out of the way */ + if (idx != arr->cnt) { + status = ares__array_move(arr, idx + arr->offset + 1, idx + arr->offset); + if (status != ARES_SUCCESS) { + return status; + } + } + + /* Ok, we're guaranteed to have a gap where we need it, lets zero it out, + * and return it */ + ptr = (unsigned char *)arr->arr + ((idx + arr->offset) * arr->member_size); + memset(ptr, 0, arr->member_size); + arr->cnt++; + + if (elem_ptr) { + *elem_ptr = ptr; + } + + return ARES_SUCCESS; +} + +ares_status_t ares__array_insert_last(void **elem_ptr, ares__array_t *arr) +{ + return ares__array_insert_at(elem_ptr, arr, ares__array_len(arr)); +} + +ares_status_t ares__array_insert_first(void **elem_ptr, ares__array_t *arr) +{ + return ares__array_insert_at(elem_ptr, arr, 0); +} + +void *ares__array_first(ares__array_t *arr) +{ + return ares__array_at(arr, 0); +} + +void *ares__array_last(ares__array_t *arr) +{ + size_t cnt = ares__array_len(arr); + if (cnt == 0) { + return NULL; + } + return ares__array_at(arr, cnt - 1); +} + +const void *ares__array_first_const(const ares__array_t *arr) +{ + return ares__array_at_const(arr, 0); +} + +const void *ares__array_last_const(const ares__array_t *arr) +{ + size_t cnt = ares__array_len(arr); + if (cnt == 0) { + return NULL; + } + return ares__array_at_const(arr, cnt - 1); +} + +ares_status_t ares__array_claim_at(void *dest, size_t dest_size, + ares__array_t *arr, size_t idx) +{ + ares_status_t status; + + if (arr == NULL || idx >= arr->cnt) { + return ARES_EFORMERR; + } + + if (dest != NULL && dest_size < arr->member_size) { + return ARES_EFORMERR; + } + + if (dest) { + memcpy(dest, ares__array_at(arr, idx), arr->member_size); + } + + if (idx == 0) { + /* Optimization, if first element, just increment offset, makes removing a + * lot from the start quick */ + arr->offset++; + } else if (idx != arr->cnt - 1) { + /* Must shift entire array if removing an element from the middle. Does + * nothing if removing last element other than decrement count. */ + status = ares__array_move(arr, idx + arr->offset, idx + arr->offset + 1); + if (status != ARES_SUCCESS) { + return status; + } + } + + arr->cnt--; + return ARES_SUCCESS; +} + +ares_status_t ares__array_remove_at(ares__array_t *arr, size_t idx) +{ + void *ptr = ares__array_at(arr, idx); + if (arr == NULL || ptr == NULL) { + return ARES_EFORMERR; + } + + if (arr->destruct != NULL) { + arr->destruct(ptr); + } + + return ares__array_claim_at(NULL, 0, arr, idx); +} + +ares_status_t ares__array_remove_first(ares__array_t *arr) +{ + return ares__array_remove_at(arr, 0); +} + +ares_status_t ares__array_remove_last(ares__array_t *arr) +{ + size_t cnt = ares__array_len(arr); + if (cnt == 0) { + return ARES_EFORMERR; + } + return ares__array_remove_at(arr, cnt - 1); +} diff --git a/lib/c-ares-1.33.1/src/lib/dsa/ares__array.h b/lib/c-ares-1.33.1/src/lib/dsa/ares__array.h new file mode 100644 index 00000000000..6fa1c0e15e9 --- /dev/null +++ b/lib/c-ares-1.33.1/src/lib/dsa/ares__array.h @@ -0,0 +1,223 @@ +/* MIT License + * + * Copyright (c) 2024 Brad House + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * SPDX-License-Identifier: MIT + */ +#ifndef __ARES__ARRAY_H +#define __ARES__ARRAY_H + +/*! \addtogroup ares__array Array Data Structure + * + * This is an array with helpers. It is meant to have as little overhead + * as possible over direct array management by applications but to provide + * safety and some optimization features. It can also return the array in + * native form once all manipulation has been performed. + * + * @{ + */ + +struct ares__array; + +/*! Opaque data structure for array */ +typedef struct ares__array ares__array_t; + +/*! Callback to free user-defined member data + * + * \param[in] data pointer to member of array to be destroyed. The pointer + * itself must not be destroyed, just the data it contains. + */ +typedef void (*ares__array_destructor_t)(void *data); + +/*! Callback to compare two array elements used for sorting + * + * \param[in] data1 array member 1 + * \param[in] data2 array member 2 + * \return < 0 if data1 < data2, > 0 if data1 > data2, 0 if data1 == data2 + */ +typedef int (*ares__array_cmp_t)(const void *data1, const void *data2); + +/*! Create an array object + * + * NOTE: members of the array are typically going to be an going to be a + * struct with compiler/ABI specific padding to ensure proper alignment. + * Care needs to be taken if using primitive types, especially floating + * point numbers which size may not indicate the required alignment. + * For example, a double may be 80 bits (10 bytes), but required + * alignment of 16 bytes. In such a case, a member_size of 16 would be + * required to be used. + * + * \param[in] destruct Optional. Destructor to call on a removed member + * \param[in] member_size Size of array member, usually determined using + * sizeof() for the member such as a struct. + * + * \return array object or NULL on out of memory + */ +ares__array_t *ares__array_create(size_t member_size, + ares__array_destructor_t destruct); + + +/*! Request the array be at least the requested size. Useful if the desired + * array size is known prior to populating the array to prevent reallocations. + * + * \param[in] arr Initialized array object. + * \param[in] size Minimum number of members + * \return ARES_SUCCESS on success, ARES_EFORMERR on misuse, + * ARES_ENOMEM on out of memory */ +ares_status_t ares__array_set_size(ares__array_t *arr, size_t size); + +/*! Sort the array using the given comparison function. This is not + * persistent, any future elements inserted will not maintain this sort. + * + * \param[in] arr Initialized array object. + * \param[in] cb Sort callback + * \return ARES_SUCCESS on success + */ +ares_status_t ares__array_sort(ares__array_t *arr, ares__array_cmp_t cmp); + +/*! Destroy an array object. If a destructor is set, will be called on each + * member of the array. + * + * \param[in] arr Initialized array object. + */ +void ares__array_destroy(ares__array_t *arr); + +/*! Retrieve the array in the native format. This will also destroy the + * container. It is the responsibility of the caller to free the returned + * pointer and also any data within each array element. + * + * \param[in] arr Initialized array object + * \param[out] num_members the number of members in the returned array + * \return pointer to native array on success, NULL on failure. + */ +void *ares__array_finish(ares__array_t *arr, size_t *num_members); + +/*! Retrieve the number of members in the array + * + * \param[in] arr Initialized array object. + * \return numbrer of members + */ +size_t ares__array_len(const ares__array_t *arr); + +/*! Insert a new array member at the given index + * + * \param[out] elem_ptr Optional. Pointer to the returned array element. + * \param[in] arr Initialized array object. + * \param[in] idx Index in array to place new element, will shift any + * elements down that exist after this point. + * \return ARES_SUCCESS on success, ARES_EFORMERR on bad index, + * ARES_ENOMEM on out of memory. + */ +ares_status_t ares__array_insert_at(void **elem_ptr, ares__array_t *arr, + size_t idx); + +/*! Insert a new array member at the end of the array + * + * \param[out] elem_ptr Optional. Pointer to the returned array element. + * \param[in] arr Initialized array object. + * \return ARES_SUCCESS on success, ARES_ENOMEM on out of memory. + */ +ares_status_t ares__array_insert_last(void **elem_ptr, ares__array_t *arr); + +/*! Insert a new array member at the beginning of the array + * + * \param[out] elem_ptr Optional. Pointer to the returned array element. + * \param[in] arr Initialized array object. + * \return ARES_SUCCESS on success, ARES_ENOMEM on out of memory. + */ +ares_status_t ares__array_insert_first(void **elem_ptr, ares__array_t *arr); + +/*! Fetch a pointer to the given element in the array + * \param[in] array Initialized array object + * \param[in] idx Index to fetch + * \return pointer on success, NULL on failure */ +void *ares__array_at(ares__array_t *arr, size_t idx); + +/*! Fetch a pointer to the first element in the array + * \param[in] array Initialized array object + * \return pointer on success, NULL on failure */ +void *ares__array_first(ares__array_t *arr); + +/*! Fetch a pointer to the last element in the array + * \param[in] array Initialized array object + * \return pointer on success, NULL on failure */ +void *ares__array_last(ares__array_t *arr); + +/*! Fetch a constant pointer to the given element in the array + * \param[in] array Initialized array object + * \param[in] idx Index to fetch + * \return pointer on success, NULL on failure */ +const void *ares__array_at_const(const ares__array_t *arr, size_t idx); + +/*! Fetch a constant pointer to the first element in the array + * \param[in] array Initialized array object + * \return pointer on success, NULL on failure */ +const void *ares__array_first_const(const ares__array_t *arr); + +/*! Fetch a constant pointer to the last element in the array + * \param[in] array Initialized array object + * \return pointer on success, NULL on failure */ +const void *ares__array_last_const(const ares__array_t *arr); + +/*! Claim the data from the specified array index, copying it to the buffer + * provided by the caller. The index specified in the array will then be + * removed (without calling any possible destructor) + * + * \param[in,out] dest Optional. Buffer to hold array member. Pass NULL + * if not needed. This could leak memory if array + * member needs destructor if not provided. + * \param[in] dest_size Size of buffer provided, used as a sanity check. + * Must match member_size provided to + * ares__array_create() if dest_size specified. + * \param[in] arr Initialized array object + * \param[in] idx Index to claim + * \return ARES_SUCCESS on success, ARES_EFORMERR on usage failure. + */ +ares_status_t ares__array_claim_at(void *dest, size_t dest_size, + ares__array_t *arr, size_t idx); + +/*! Remove the member at the specified array index. The destructor will be + * called. + * + * \param[in] arr Initialized array object + * \param[in] idx Index to remove + * \return ARES_SUCCESS if removed, ARES_EFORMERR on invalid use + */ +ares_status_t ares__array_remove_at(ares__array_t *arr, size_t idx); + +/*! Remove the first member of the array. + * + * \param[in] arr Initialized array object + * \return ARES_SUCCESS if removed, ARES_EFORMERR on invalid use + */ +ares_status_t ares__array_remove_first(ares__array_t *arr); + +/*! Remove the last member of the array. + * + * \param[in] arr Initialized array object + * \return ARES_SUCCESS if removed, ARES_EFORMERR on invalid use + */ +ares_status_t ares__array_remove_last(ares__array_t *arr); + +/*! @} */ + +#endif /* __ARES__ARRAY_H */ diff --git a/lib/c-ares-1.32.3/src/lib/ares__htable.c b/lib/c-ares-1.33.1/src/lib/dsa/ares__htable.c similarity index 99% rename from lib/c-ares-1.32.3/src/lib/ares__htable.c rename to lib/c-ares-1.33.1/src/lib/dsa/ares__htable.c index d608d60ce3a..9049b3246b3 100644 --- a/lib/c-ares-1.32.3/src/lib/ares__htable.c +++ b/lib/c-ares-1.33.1/src/lib/dsa/ares__htable.c @@ -59,7 +59,7 @@ static unsigned int ares__htable_generate_seed(ares__htable_t *htable) * collision attack is very low with a small amount of effort */ seed |= (unsigned int)((size_t)htable & 0xFFFFFFFF); seed |= (unsigned int)((size_t)&seed & 0xFFFFFFFF); - seed |= (unsigned int)(t & 0xFFFFFFFF); + seed |= (unsigned int)(((ares_uint64_t)t) & 0xFFFFFFFF); return seed; } diff --git a/lib/c-ares-1.32.3/src/lib/ares__htable.h b/lib/c-ares-1.33.1/src/lib/dsa/ares__htable.h similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares__htable.h rename to lib/c-ares-1.33.1/src/lib/dsa/ares__htable.h diff --git a/lib/c-ares-1.32.3/src/lib/ares__htable_asvp.c b/lib/c-ares-1.33.1/src/lib/dsa/ares__htable_asvp.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares__htable_asvp.c rename to lib/c-ares-1.33.1/src/lib/dsa/ares__htable_asvp.c diff --git a/lib/c-ares-1.32.3/src/lib/ares__htable_asvp.h b/lib/c-ares-1.33.1/src/lib/dsa/ares__htable_asvp.h similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares__htable_asvp.h rename to lib/c-ares-1.33.1/src/lib/dsa/ares__htable_asvp.h diff --git a/lib/c-ares-1.32.3/src/lib/ares__htable_strvp.c b/lib/c-ares-1.33.1/src/lib/dsa/ares__htable_strvp.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares__htable_strvp.c rename to lib/c-ares-1.33.1/src/lib/dsa/ares__htable_strvp.c diff --git a/lib/c-ares-1.32.3/src/lib/ares__htable_strvp.h b/lib/c-ares-1.33.1/src/lib/dsa/ares__htable_strvp.h similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares__htable_strvp.h rename to lib/c-ares-1.33.1/src/lib/dsa/ares__htable_strvp.h diff --git a/lib/c-ares-1.32.3/src/lib/ares__htable_szvp.c b/lib/c-ares-1.33.1/src/lib/dsa/ares__htable_szvp.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares__htable_szvp.c rename to lib/c-ares-1.33.1/src/lib/dsa/ares__htable_szvp.c diff --git a/lib/c-ares-1.32.3/src/lib/ares__htable_szvp.h b/lib/c-ares-1.33.1/src/lib/dsa/ares__htable_szvp.h similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares__htable_szvp.h rename to lib/c-ares-1.33.1/src/lib/dsa/ares__htable_szvp.h diff --git a/lib/c-ares-1.32.3/src/lib/ares__htable_vpvp.c b/lib/c-ares-1.33.1/src/lib/dsa/ares__htable_vpvp.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares__htable_vpvp.c rename to lib/c-ares-1.33.1/src/lib/dsa/ares__htable_vpvp.c diff --git a/lib/c-ares-1.32.3/src/lib/ares__htable_vpvp.h b/lib/c-ares-1.33.1/src/lib/dsa/ares__htable_vpvp.h similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares__htable_vpvp.h rename to lib/c-ares-1.33.1/src/lib/dsa/ares__htable_vpvp.h diff --git a/lib/c-ares-1.32.3/src/lib/ares__llist.c b/lib/c-ares-1.33.1/src/lib/dsa/ares__llist.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares__llist.c rename to lib/c-ares-1.33.1/src/lib/dsa/ares__llist.c diff --git a/lib/c-ares-1.32.3/src/lib/ares__llist.h b/lib/c-ares-1.33.1/src/lib/dsa/ares__llist.h similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares__llist.h rename to lib/c-ares-1.33.1/src/lib/dsa/ares__llist.h diff --git a/lib/c-ares-1.32.3/src/lib/ares__slist.c b/lib/c-ares-1.33.1/src/lib/dsa/ares__slist.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares__slist.c rename to lib/c-ares-1.33.1/src/lib/dsa/ares__slist.c diff --git a/lib/c-ares-1.32.3/src/lib/ares__slist.h b/lib/c-ares-1.33.1/src/lib/dsa/ares__slist.h similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares__slist.h rename to lib/c-ares-1.33.1/src/lib/dsa/ares__slist.h diff --git a/lib/c-ares-1.32.3/src/lib/ares_event.h b/lib/c-ares-1.33.1/src/lib/event/ares_event.h similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_event.h rename to lib/c-ares-1.33.1/src/lib/event/ares_event.h diff --git a/lib/c-ares-1.32.3/src/lib/ares_event_configchg.c b/lib/c-ares-1.33.1/src/lib/event/ares_event_configchg.c similarity index 94% rename from lib/c-ares-1.32.3/src/lib/ares_event_configchg.c rename to lib/c-ares-1.33.1/src/lib/event/ares_event_configchg.c index 1d5d026ba39..10f0e21dde7 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_event_configchg.c +++ b/lib/c-ares-1.33.1/src/lib/event/ares_event_configchg.c @@ -31,6 +31,8 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, ares_event_thread_t *e) { + (void)configchg; + (void)e; /* No ability */ return ARES_ENOTIMP; } @@ -38,6 +40,7 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, void ares_event_configchg_destroy(ares_event_configchg_t *configchg) { /* No-op */ + (void)configchg; } #elif defined(__linux__) @@ -107,7 +110,7 @@ static void ares_event_configchg_cb(ares_event_thread_t *e, ares_socket_t fd, * size provided, so I assume it won't ever return partial events. */ for (ptr = buf; ptr < buf + len; ptr += sizeof(struct inotify_event) + event->len) { - event = (const struct inotify_event *)ptr; + event = (const struct inotify_event *)((const void *)ptr); if (event->len == 0 || ares_strlen(event->name) == 0) { continue; @@ -195,13 +198,14 @@ void ares_event_configchg_destroy(ares_event_configchg_t *configchg) return; } -# ifndef __WATCOMC__ +# ifdef HAVE_NOTIFYIPINTERFACECHANGE if (configchg->ifchg_hnd != NULL) { CancelMibChangeNotify2(configchg->ifchg_hnd); configchg->ifchg_hnd = NULL; } # endif +# ifdef HAVE_REGISTERWAITFORSINGLEOBJECT if (configchg->regip4_wait != NULL) { UnregisterWait(configchg->regip4_wait); configchg->regip4_wait = NULL; @@ -231,15 +235,15 @@ void ares_event_configchg_destroy(ares_event_configchg_t *configchg) CloseHandle(configchg->regip6_event); configchg->regip6_event = NULL; } +# endif ares_free(configchg); } -# ifndef __WATCOMC__ +# ifdef HAVE_NOTIFYIPINTERFACECHANGE static void NETIOAPI_API_ - ares_event_configchg_ip_cb(PVOID CallerContext, - PMIB_IPINTERFACE_ROW Row, + ares_event_configchg_ip_cb(PVOID CallerContext, PMIB_IPINTERFACE_ROW Row, MIB_NOTIFICATION_TYPE NotificationType) { ares_event_configchg_t *configchg = CallerContext; @@ -252,9 +256,10 @@ static void NETIOAPI_API_ static ares_bool_t ares_event_configchg_regnotify(ares_event_configchg_t *configchg) { -# if defined(__WATCOMC__) && !defined(REG_NOTIFY_THREAD_AGNOSTIC) -# define REG_NOTIFY_THREAD_AGNOSTIC 0x10000000L -# endif +# ifdef HAVE_REGISTERWAITFORSINGLEOBJECT +# if defined(__WATCOMC__) && !defined(REG_NOTIFY_THREAD_AGNOSTIC) +# define REG_NOTIFY_THREAD_AGNOSTIC 0x10000000L +# endif DWORD flags = REG_NOTIFY_CHANGE_NAME | REG_NOTIFY_CHANGE_LAST_SET | REG_NOTIFY_THREAD_AGNOSTIC; @@ -267,7 +272,9 @@ static ares_bool_t configchg->regip6_event, TRUE) != ERROR_SUCCESS) { return ARES_FALSE; } - +# else + (void)configchg; +# endif return ARES_TRUE; } @@ -297,27 +304,27 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, c->e = e; -# ifndef __WATCOMC__ +# ifdef HAVE_NOTIFYIPINTERFACECHANGE /* NOTE: If a user goes into the control panel and changes the network * adapter DNS addresses manually, this will NOT trigger a notification. * We've also tried listening on NotifyUnicastIpAddressChange(), but * that didn't get triggered either. */ - if (NotifyIpInterfaceChange( - AF_UNSPEC, ares_event_configchg_ip_cb, - c, FALSE, &c->ifchg_hnd) != NO_ERROR) { + if (NotifyIpInterfaceChange(AF_UNSPEC, ares_event_configchg_ip_cb, c, FALSE, + &c->ifchg_hnd) != NO_ERROR) { status = ARES_ESERVFAIL; goto done; } # endif +# ifdef HAVE_REGISTERWAITFORSINGLEOBJECT /* Monitor HKLM\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\Interfaces * and HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces * for changes via RegNotifyChangeKeyValue() */ if (RegOpenKeyExW( HKEY_LOCAL_MACHINE, - L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces", 0, - KEY_NOTIFY, &c->regip4) != ERROR_SUCCESS) { + L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces", + 0, KEY_NOTIFY, &c->regip4) != ERROR_SUCCESS) { status = ARES_ESERVFAIL; goto done; } @@ -355,6 +362,7 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, status = ARES_ESERVFAIL; goto done; } +# endif if (!ares_event_configchg_regnotify(c)) { status = ARES_ESERVFAIL; @@ -472,8 +480,8 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, continue; } - pdns_configuration_notify_key = (const char *(*)(void)) - dlsym(handle, "dns_configuration_notify_key"); + pdns_configuration_notify_key = + (const char *(*)(void))dlsym(handle, "dns_configuration_notify_key"); if (pdns_configuration_notify_key != NULL) { break; } @@ -551,7 +559,7 @@ static ares_status_t config_change_check(ares__htable_strvp_t *filestat, { size_t i; const char *configfiles[5]; - ares_bool_t changed = ARES_FALSE; + ares_bool_t changed = ARES_FALSE; configfiles[0] = resolvconf_path; configfiles[1] = "/etc/nsswitch.conf"; diff --git a/lib/c-ares-1.32.3/src/lib/ares_event_epoll.c b/lib/c-ares-1.33.1/src/lib/event/ares_event_epoll.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_event_epoll.c rename to lib/c-ares-1.33.1/src/lib/event/ares_event_epoll.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_event_kqueue.c b/lib/c-ares-1.33.1/src/lib/event/ares_event_kqueue.c similarity index 96% rename from lib/c-ares-1.32.3/src/lib/ares_event_kqueue.c rename to lib/c-ares-1.33.1/src/lib/event/ares_event_kqueue.c index aedd99ec42d..1c35c14f165 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_event_kqueue.c +++ b/lib/c-ares-1.33.1/src/lib/event/ares_event_kqueue.c @@ -123,11 +123,9 @@ static void ares_evsys_kqueue_enqueue(ares_evsys_kqueue_t *kq, int fd, if (kq->nchanges > kq->nchanges_alloc) { kq->nchanges_alloc <<= 1; - kq->changelist = ares_realloc_zero( - kq->changelist, - (kq->nchanges_alloc >> 1) * sizeof(*kq->changelist), - kq->nchanges_alloc * sizeof(*kq->changelist) - ); + kq->changelist = ares_realloc_zero( + kq->changelist, (kq->nchanges_alloc >> 1) * sizeof(*kq->changelist), + kq->nchanges_alloc * sizeof(*kq->changelist)); } EV_SET(&kq->changelist[idx], fd, filter, flags, 0, 0, 0); @@ -198,7 +196,7 @@ static size_t ares_evsys_kqueue_wait(ares_event_thread_t *e, size_t cnt = 0; if (timeout_ms != 0) { - ts.tv_sec = timeout_ms / 1000; + ts.tv_sec = (time_t)timeout_ms / 1000; ts.tv_nsec = (timeout_ms % 1000) * 1000 * 1000; timeout = &ts; } diff --git a/lib/c-ares-1.32.3/src/lib/ares_event_poll.c b/lib/c-ares-1.33.1/src/lib/event/ares_event_poll.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_event_poll.c rename to lib/c-ares-1.33.1/src/lib/event/ares_event_poll.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_event_select.c b/lib/c-ares-1.33.1/src/lib/event/ares_event_select.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_event_select.c rename to lib/c-ares-1.33.1/src/lib/event/ares_event_select.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_event_thread.c b/lib/c-ares-1.33.1/src/lib/event/ares_event_thread.c similarity index 95% rename from lib/c-ares-1.32.3/src/lib/ares_event_thread.c rename to lib/c-ares-1.33.1/src/lib/event/ares_event_thread.c index 63d8aa2218a..8b332e9b019 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_event_thread.c +++ b/lib/c-ares-1.33.1/src/lib/event/ares_event_thread.c @@ -47,6 +47,23 @@ static void ares_event_destroy_cb(void *arg) ares_free(event); } +static void ares_event_signal(const ares_event_t *event) +{ + if (event == NULL || event->signal_cb == NULL) { + return; /* LCOV_EXCL_LINE: DefensiveCoding */ + } + event->signal_cb(event); +} + +static void ares_event_thread_wake(const ares_event_thread_t *e) +{ + if (e == NULL) { + return; /* LCOV_EXCL_LINE: DefensiveCoding */ + } + + ares_event_signal(e->ev_signal); +} + /* See if a pending update already exists. We don't want to enqueue multiple * updates for the same event handle. Right now this is O(n) based on number * of updates already enqueued. In the future, it might make sense to make @@ -86,6 +103,7 @@ ares_status_t ares_event_update(ares_event_t **event, ares_event_thread_t *e, ares_event_signal_cb_t signal_cb) { ares_event_t *ev = NULL; + ares_status_t status; if (e == NULL) { return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ @@ -116,18 +134,22 @@ ares_status_t ares_event_update(ares_event_t **event, ares_event_thread_t *e, /* That's all the validation we can really do */ + ares__thread_mutex_lock(e->mutex); + /* See if we have a queued update already */ ev = ares_event_update_find(e, fd, data); if (ev == NULL) { /* Allocate a new one */ ev = ares_malloc_zero(sizeof(*ev)); if (ev == NULL) { - return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } if (ares__llist_insert_last(e->ev_updates, ev) == NULL) { - ares_free(ev); /* LCOV_EXCL_LINE: OutOfMemory */ - return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + ares_free(ev); /* LCOV_EXCL_LINE: OutOfMemory */ + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -150,24 +172,17 @@ ares_status_t ares_event_update(ares_event_t **event, ares_event_thread_t *e, *event = ev; } - return ARES_SUCCESS; -} + status = ARES_SUCCESS; -static void ares_event_signal(const ares_event_t *event) -{ - if (event == NULL || event->signal_cb == NULL) { - return; /* LCOV_EXCL_LINE: DefensiveCoding */ +done: + if (status == ARES_SUCCESS) { + /* Wake event thread if successful so it can pull the updates */ + ares_event_thread_wake(e); } - event->signal_cb(event); -} -static void ares_event_thread_wake(const ares_event_thread_t *e) -{ - if (e == NULL) { - return; /* LCOV_EXCL_LINE: DefensiveCoding */ - } + ares__thread_mutex_unlock(e->mutex); - ares_event_signal(e->ev_signal); + return status; } static void ares_event_thread_process_fd(ares_event_thread_t *e, @@ -195,15 +210,10 @@ static void ares_event_thread_sockstate_cb(void *data, ares_socket_t socket_fd, flags |= ARES_EVENT_FLAG_WRITE; } - /* Update channel fd */ - ares__thread_mutex_lock(e->mutex); + /* Update channel fd. This function will lock e->mutex and also wake the + * event thread to process the update */ ares_event_update(NULL, e, flags, ares_event_thread_process_fd, socket_fd, NULL, NULL, NULL); - - /* Wake the event thread so it properly enqueues any updates */ - ares_event_thread_wake(e); - - ares__thread_mutex_unlock(e->mutex); } static void ares_event_process_updates(ares_event_thread_t *e) @@ -370,7 +380,7 @@ void ares_event_thread_destroy(ares_channel_t *channel) ares_event_thread_destroy_int(e); channel->sock_state_cb_data = NULL; - channel->sock_state_cb = NULL; + channel->sock_state_cb = NULL; } static const ares_event_sys_t *ares_event_fetch_sys(ares_evsys_t evsys) diff --git a/lib/c-ares-1.32.3/src/lib/ares_event_wake_pipe.c b/lib/c-ares-1.33.1/src/lib/event/ares_event_wake_pipe.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_event_wake_pipe.c rename to lib/c-ares-1.33.1/src/lib/event/ares_event_wake_pipe.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_event_win32.c b/lib/c-ares-1.33.1/src/lib/event/ares_event_win32.c similarity index 99% rename from lib/c-ares-1.32.3/src/lib/ares_event_win32.c rename to lib/c-ares-1.33.1/src/lib/event/ares_event_win32.c index 173d0ca9c9d..0b7e535bbbf 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_event_win32.c +++ b/lib/c-ares-1.33.1/src/lib/event/ares_event_win32.c @@ -25,9 +25,13 @@ */ /* Uses an anonymous union */ -#if defined(__clang__) +#if defined(__clang__) || defined(__GNUC__) # pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wc11-extensions" +# if defined(__clang__) +# pragma GCC diagnostic ignored "-Wc11-extensions" +# else +# pragma GCC diagnostic ignored "-Wpedantic" +# endif #endif #include "ares_private.h" @@ -967,6 +971,6 @@ const ares_event_sys_t ares_evsys_win32 = { "win32", ares_evsys_win32_wait }; #endif -#if defined(__clang__) +#if defined(__clang__) || defined(__GNUC__) # pragma GCC diagnostic pop #endif diff --git a/lib/c-ares-1.32.3/src/lib/ares_event_win32.h b/lib/c-ares-1.33.1/src/lib/event/ares_event_win32.h similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_event_win32.h rename to lib/c-ares-1.33.1/src/lib/event/ares_event_win32.h diff --git a/lib/c-ares-1.32.3/src/lib/inet_net_pton.c b/lib/c-ares-1.33.1/src/lib/inet_net_pton.c similarity index 93% rename from lib/c-ares-1.32.3/src/lib/inet_net_pton.c rename to lib/c-ares-1.33.1/src/lib/inet_net_pton.c index 935058da9ce..5356778c47b 100644 --- a/lib/c-ares-1.32.3/src/lib/inet_net_pton.c +++ b/lib/c-ares-1.33.1/src/lib/inet_net_pton.c @@ -32,11 +32,6 @@ #include "ares_ipv6.h" #include "ares_inet_net_pton.h" -#define ISDIGIT(x) (isdigit((int)((unsigned char)x))) -#define ISXDIGIT(x) (isxdigit((int)((unsigned char)x))) -#define ISASCII(x) (((unsigned char)x) <= 127 ? 1 : 0) -#define ISUPPER(x) (isupper((int)((unsigned char)x))) - const struct ares_in6_addr ares_in6addr_any = { { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } }; @@ -74,16 +69,16 @@ static int ares_inet_net_pton_ipv4(const char *src, unsigned char *dst, const unsigned char *odst = dst; ch = *src++; - if (ch == '0' && (src[0] == 'x' || src[0] == 'X') && ISASCII(src[1]) && - ISXDIGIT(src[1])) { + if (ch == '0' && (src[0] == 'x' || src[0] == 'X') && ares__isascii(src[1]) && + ares__isxdigit(src[1])) { /* Hexadecimal: Eat nybble string. */ if (!size) { goto emsgsize; } dirty = 0; src++; /* skip x or X. */ - while ((ch = *src++) != '\0' && ISASCII(ch) && ISXDIGIT(ch)) { - if (ISUPPER(ch)) { + while ((ch = *src++) != '\0' && ares__isascii(ch) && ares__isxdigit(ch)) { + if (ares__isupper(ch)) { ch = ares__tolower((unsigned char)ch); } n = (int)(strchr(xdigits, ch) - xdigits); @@ -106,7 +101,7 @@ static int ares_inet_net_pton_ipv4(const char *src, unsigned char *dst, } *dst++ = (unsigned char)(tmp << 4); } - } else if (ISASCII(ch) && ISDIGIT(ch)) { + } else if (ares__isascii(ch) && ares__isdigit(ch)) { /* Decimal: eat dotted digit string. */ for (;;) { tmp = 0; @@ -117,7 +112,7 @@ static int ares_inet_net_pton_ipv4(const char *src, unsigned char *dst, if (tmp > 255) { goto enoent; } - } while ((ch = *src++) != '\0' && ISASCII(ch) && ISDIGIT(ch)); + } while ((ch = *src++) != '\0' && ares__isascii(ch) && ares__isdigit(ch)); if (!size--) { goto emsgsize; } @@ -129,7 +124,7 @@ static int ares_inet_net_pton_ipv4(const char *src, unsigned char *dst, goto enoent; } ch = *src++; - if (!ISASCII(ch) || !ISDIGIT(ch)) { + if (!ares__isascii(ch) || !ares__isdigit(ch)) { goto enoent; } } @@ -138,7 +133,8 @@ static int ares_inet_net_pton_ipv4(const char *src, unsigned char *dst, } bits = -1; - if (ch == '/' && ISASCII(src[0]) && ISDIGIT(src[0]) && dst > odst) { + if (ch == '/' && ares__isascii(src[0]) && ares__isdigit(src[0]) && + dst > odst) { /* CIDR width specifier. Nothing can follow it. */ ch = *src++; /* Skip over the /. */ bits = 0; @@ -149,7 +145,7 @@ static int ares_inet_net_pton_ipv4(const char *src, unsigned char *dst, if (bits > 32) { goto enoent; } - } while ((ch = *src++) != '\0' && ISASCII(ch) && ISDIGIT(ch)); + } while ((ch = *src++) != '\0' && ares__isascii(ch) && ares__isdigit(ch)); if (ch != '\0') { goto enoent; } diff --git a/lib/c-ares-1.32.3/src/lib/inet_ntop.c b/lib/c-ares-1.33.1/src/lib/inet_ntop.c similarity index 97% rename from lib/c-ares-1.32.3/src/lib/inet_ntop.c rename to lib/c-ares-1.33.1/src/lib/inet_ntop.c index 8dee8d69da7..6f96b92cccc 100644 --- a/lib/c-ares-1.32.3/src/lib/inet_ntop.c +++ b/lib/c-ares-1.33.1/src/lib/inet_ntop.c @@ -138,7 +138,7 @@ static const char *inet_ntop6(const unsigned char *src, char *dst, size_t size) if (words[i] == 0) { if (cur.base == -1) { cur.base = (ares_ssize_t)i; - cur.len = 1; + cur.len = 1; } else { cur.len++; } @@ -166,7 +166,8 @@ static const char *inet_ntop6(const unsigned char *src, char *dst, size_t size) tp = tmp; for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) { /* Are we inside the best run of 0x00's? */ - if (best.base != -1 && i >= (size_t)best.base && i < ((size_t)best.base + best.len)) { + if (best.base != -1 && i >= (size_t)best.base && + i < ((size_t)best.base + best.len)) { if (i == (size_t)best.base) { *tp++ = ':'; } @@ -205,4 +206,3 @@ static const char *inet_ntop6(const unsigned char *src, char *dst, size_t size) ares_strcpy(dst, tmp, size); return dst; } - diff --git a/lib/c-ares-1.32.3/src/lib/ares_create_query.c b/lib/c-ares-1.33.1/src/lib/legacy/ares_create_query.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_create_query.c rename to lib/c-ares-1.33.1/src/lib/legacy/ares_create_query.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_expand_name.c b/lib/c-ares-1.33.1/src/lib/legacy/ares_expand_name.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_expand_name.c rename to lib/c-ares-1.33.1/src/lib/legacy/ares_expand_name.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_expand_string.c b/lib/c-ares-1.33.1/src/lib/legacy/ares_expand_string.c similarity index 97% rename from lib/c-ares-1.32.3/src/lib/ares_expand_string.c rename to lib/c-ares-1.33.1/src/lib/legacy/ares_expand_string.c index 570ccd917a3..b3e99daa54b 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_expand_string.c +++ b/lib/c-ares-1.33.1/src/lib/legacy/ares_expand_string.c @@ -74,8 +74,7 @@ ares_status_t ares_expand_string_ex(const unsigned char *encoded, } start_len = ares__buf_len(buf); - status = - ares__buf_parse_dns_binstr(buf, ares__buf_len(buf), s, &len); + status = ares__buf_parse_dns_binstr(buf, ares__buf_len(buf), s, &len); /* hrm, no way to pass back 'len' with the prototype */ if (status != ARES_SUCCESS) { goto done; diff --git a/lib/c-ares-1.32.3/src/lib/ares_fds.c b/lib/c-ares-1.33.1/src/lib/legacy/ares_fds.c similarity index 88% rename from lib/c-ares-1.32.3/src/lib/ares_fds.c rename to lib/c-ares-1.33.1/src/lib/legacy/ares_fds.c index 0502e71182a..3aedd2c90e2 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_fds.c +++ b/lib/c-ares-1.33.1/src/lib/legacy/ares_fds.c @@ -45,14 +45,14 @@ int ares_fds(const ares_channel_t *channel, fd_set *read_fds, fd_set *write_fds) nfds = 0; for (snode = ares__slist_node_first(channel->servers); snode != NULL; snode = ares__slist_node_next(snode)) { - struct server_state *server = ares__slist_node_val(snode); - ares__llist_node_t *node; + ares_server_t *server = ares__slist_node_val(snode); + ares__llist_node_t *node; for (node = ares__llist_node_first(server->connections); node != NULL; node = ares__llist_node_next(node)) { - const struct server_connection *conn = ares__llist_node_val(node); + const ares_conn_t *conn = ares__llist_node_val(node); - if (!active_queries && !conn->is_tcp) { + if (!active_queries && !(conn->flags & ARES_CONN_FLAG_TCP)) { continue; } @@ -69,7 +69,7 @@ int ares_fds(const ares_channel_t *channel, fd_set *read_fds, fd_set *write_fds) } /* TCP only wait on write if we have buffered data */ - if (conn->is_tcp && ares__buf_len(server->tcp_send)) { + if (conn->flags & ARES_CONN_FLAG_TCP && ares__buf_len(server->tcp_send)) { FD_SET(conn->fd, write_fds); } } diff --git a/lib/c-ares-1.32.3/src/lib/ares_getsock.c b/lib/c-ares-1.33.1/src/lib/legacy/ares_getsock.c similarity index 87% rename from lib/c-ares-1.32.3/src/lib/ares_getsock.c rename to lib/c-ares-1.33.1/src/lib/legacy/ares_getsock.c index 836d9b973ed..8c8476fa951 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_getsock.c +++ b/lib/c-ares-1.33.1/src/lib/legacy/ares_getsock.c @@ -47,12 +47,12 @@ int ares_getsock(const ares_channel_t *channel, ares_socket_t *socks, for (snode = ares__slist_node_first(channel->servers); snode != NULL; snode = ares__slist_node_next(snode)) { - struct server_state *server = ares__slist_node_val(snode); - ares__llist_node_t *node; + ares_server_t *server = ares__slist_node_val(snode); + ares__llist_node_t *node; for (node = ares__llist_node_first(server->connections); node != NULL; node = ares__llist_node_next(node)) { - const struct server_connection *conn = ares__llist_node_val(node); + const ares_conn_t *conn = ares__llist_node_val(node); if (sockindex >= (size_t)numsocks || sockindex >= ARES_GETSOCK_MAXNUM) { break; @@ -61,17 +61,17 @@ int ares_getsock(const ares_channel_t *channel, ares_socket_t *socks, /* We only need to register interest in UDP sockets if we have * outstanding queries. */ - if (!active_queries && !conn->is_tcp) { + if (!active_queries && !(conn->flags & ARES_CONN_FLAG_TCP)) { continue; } socks[sockindex] = conn->fd; - if (active_queries || conn->is_tcp) { + if (active_queries || conn->flags & ARES_CONN_FLAG_TCP) { bitmap |= ARES_GETSOCK_READABLE(setbits, sockindex); } - if (conn->is_tcp && ares__buf_len(server->tcp_send)) { + if (conn->flags & ARES_CONN_FLAG_TCP && ares__buf_len(server->tcp_send)) { /* then the tcp socket is also writable! */ bitmap |= ARES_GETSOCK_WRITABLE(setbits, sockindex); } diff --git a/lib/c-ares-1.32.3/src/lib/ares_parse_a_reply.c b/lib/c-ares-1.33.1/src/lib/legacy/ares_parse_a_reply.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_parse_a_reply.c rename to lib/c-ares-1.33.1/src/lib/legacy/ares_parse_a_reply.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_parse_aaaa_reply.c b/lib/c-ares-1.33.1/src/lib/legacy/ares_parse_aaaa_reply.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_parse_aaaa_reply.c rename to lib/c-ares-1.33.1/src/lib/legacy/ares_parse_aaaa_reply.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_parse_caa_reply.c b/lib/c-ares-1.33.1/src/lib/legacy/ares_parse_caa_reply.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_parse_caa_reply.c rename to lib/c-ares-1.33.1/src/lib/legacy/ares_parse_caa_reply.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_parse_mx_reply.c b/lib/c-ares-1.33.1/src/lib/legacy/ares_parse_mx_reply.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_parse_mx_reply.c rename to lib/c-ares-1.33.1/src/lib/legacy/ares_parse_mx_reply.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_parse_naptr_reply.c b/lib/c-ares-1.33.1/src/lib/legacy/ares_parse_naptr_reply.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_parse_naptr_reply.c rename to lib/c-ares-1.33.1/src/lib/legacy/ares_parse_naptr_reply.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_parse_ns_reply.c b/lib/c-ares-1.33.1/src/lib/legacy/ares_parse_ns_reply.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_parse_ns_reply.c rename to lib/c-ares-1.33.1/src/lib/legacy/ares_parse_ns_reply.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_parse_ptr_reply.c b/lib/c-ares-1.33.1/src/lib/legacy/ares_parse_ptr_reply.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_parse_ptr_reply.c rename to lib/c-ares-1.33.1/src/lib/legacy/ares_parse_ptr_reply.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_parse_soa_reply.c b/lib/c-ares-1.33.1/src/lib/legacy/ares_parse_soa_reply.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_parse_soa_reply.c rename to lib/c-ares-1.33.1/src/lib/legacy/ares_parse_soa_reply.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_parse_srv_reply.c b/lib/c-ares-1.33.1/src/lib/legacy/ares_parse_srv_reply.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_parse_srv_reply.c rename to lib/c-ares-1.33.1/src/lib/legacy/ares_parse_srv_reply.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_parse_txt_reply.c b/lib/c-ares-1.33.1/src/lib/legacy/ares_parse_txt_reply.c similarity index 99% rename from lib/c-ares-1.32.3/src/lib/ares_parse_txt_reply.c rename to lib/c-ares-1.33.1/src/lib/legacy/ares_parse_txt_reply.c index cd280332d23..71ee0841119 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_parse_txt_reply.c +++ b/lib/c-ares-1.33.1/src/lib/legacy/ares_parse_txt_reply.c @@ -71,7 +71,7 @@ static int ares__parse_txt_reply(const unsigned char *abuf, size_t alen, cnt = ares_dns_rr_get_abin_cnt(rr, ARES_RR_TXT_DATA); - for (j=0; jdata); +} + ares__dns_multistring_t *ares__dns_multistring_create(void) { - return ares_malloc_zero(sizeof(ares__dns_multistring_t)); + ares__dns_multistring_t *strs = ares_malloc_zero(sizeof(*strs)); + if (strs == NULL) { + return NULL; + } + + strs->strs = ares__array_create(sizeof(multistring_data_t), + ares__dns_multistring_free_cb); + if (strs->strs == NULL) { + ares_free(strs); + return NULL; + } + + return strs; } void ares__dns_multistring_clear(ares__dns_multistring_t *strs) { - size_t i; - if (strs == NULL) { return; } - for (i = 0; i < strs->cnt; i++) { - ares_free(strs->strs[i].data); - memset(&strs->strs[i], 0, sizeof(strs->strs[i])); + while (ares__array_len(strs->strs)) { + ares__array_remove_last(strs->strs); } - strs->cnt = 0; } void ares__dns_multistring_destroy(ares__dns_multistring_t *strs) @@ -70,7 +85,7 @@ void ares__dns_multistring_destroy(ares__dns_multistring_t *strs) return; } ares__dns_multistring_clear(strs); - ares_free(strs->strs); + ares__array_destroy(strs->strs); ares_free(strs->cache_str); ares_free(strs); } @@ -79,43 +94,43 @@ ares_status_t ares__dns_multistring_replace_own(ares__dns_multistring_t *strs, size_t idx, unsigned char *str, size_t len) { - if (strs == NULL || str == NULL || len == 0 || idx >= strs->cnt) { + multistring_data_t *data; + + if (strs == NULL || str == NULL || len == 0) { return ARES_EFORMERR; } strs->cache_invalidated = ARES_TRUE; - ares_free(strs->strs[idx].data); - strs->strs[idx].data = str; - strs->strs[idx].len = len; + + data = ares__array_at(strs->strs, idx); + if (data == NULL) { + return ARES_EFORMERR; + } + + ares_free(data->data); + data->data = str; + data->len = len; return ARES_SUCCESS; } ares_status_t ares__dns_multistring_del(ares__dns_multistring_t *strs, size_t idx) { - size_t move_cnt; - - if (strs == NULL || idx >= strs->cnt) { + if (strs == NULL) { return ARES_EFORMERR; } strs->cache_invalidated = ARES_TRUE; - ares_free(strs->strs[idx].data); - - move_cnt = strs->cnt - idx - 1; - if (move_cnt) { - memmove(&strs->strs[idx], &strs->strs[idx + 1], - sizeof(*strs->strs) * move_cnt); - } - - strs->cnt--; - return ARES_SUCCESS; + return ares__array_remove_at(strs->strs, idx); } ares_status_t ares__dns_multistring_add_own(ares__dns_multistring_t *strs, unsigned char *str, size_t len) { + multistring_data_t *data; + ares_status_t status; + if (strs == NULL) { return ARES_EFORMERR; } @@ -127,20 +142,13 @@ ares_status_t ares__dns_multistring_add_own(ares__dns_multistring_t *strs, return ARES_EFORMERR; } - if (strs->alloc < strs->cnt + 1) { - size_t newalloc = (strs->alloc == 0) ? 1 : (strs->alloc << 1); - void *ptr = ares_realloc_zero(strs->strs, strs->alloc * sizeof(*strs->strs), - (newalloc) * sizeof(*strs->strs)); - if (ptr == NULL) { - return ARES_ENOMEM; - } - strs->strs = ptr; - strs->alloc = newalloc; + status = ares__array_insert_last((void **)&data, strs->strs); + if (status != ARES_SUCCESS) { + return status; } - strs->strs[strs->cnt].data = str; - strs->strs[strs->cnt].len = len; - strs->cnt++; + data->data = str; + data->len = len; return ARES_SUCCESS; } @@ -150,18 +158,26 @@ size_t ares__dns_multistring_cnt(const ares__dns_multistring_t *strs) if (strs == NULL) { return 0; } - return strs->cnt; + return ares__array_len(strs->strs); } -const unsigned char *ares__dns_multistring_get( - const ares__dns_multistring_t *strs, size_t idx, size_t *len) +const unsigned char * + ares__dns_multistring_get(const ares__dns_multistring_t *strs, size_t idx, + size_t *len) { - if (strs == NULL || idx >= strs->cnt || len == NULL) { + const multistring_data_t *data; + + if (strs == NULL || len == NULL) { + return NULL; + } + + data = ares__array_at_const(strs->strs, idx); + if (data == NULL) { return NULL; } - *len = strs->strs[idx].len; - return strs->strs[idx].data; + *len = data->len; + return data->data; } const unsigned char * @@ -189,9 +205,10 @@ const unsigned char * buf = ares__buf_create(); - for (i = 0; i < strs->cnt; i++) { - if (ares__buf_append(buf, strs->strs[i].data, strs->strs[i].len) != - ARES_SUCCESS) { + for (i = 0; i < ares__array_len(strs->strs); i++) { + const multistring_data_t *data = ares__array_at_const(strs->strs, i); + if (data == NULL || + ares__buf_append(buf, data->data, data->len) != ARES_SUCCESS) { ares__buf_destroy(buf); return NULL; } diff --git a/lib/c-ares-1.32.3/src/lib/ares_dns_multistring.h b/lib/c-ares-1.33.1/src/lib/record/ares_dns_multistring.h similarity index 94% rename from lib/c-ares-1.32.3/src/lib/ares_dns_multistring.h rename to lib/c-ares-1.33.1/src/lib/record/ares_dns_multistring.h index 3588f5615c3..d9aa7ae3784 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_dns_multistring.h +++ b/lib/c-ares-1.33.1/src/lib/record/ares_dns_multistring.h @@ -40,8 +40,9 @@ ares_status_t ares__dns_multistring_del(ares__dns_multistring_t *strs, ares_status_t ares__dns_multistring_add_own(ares__dns_multistring_t *strs, unsigned char *str, size_t len); size_t ares__dns_multistring_cnt(const ares__dns_multistring_t *strs); -const unsigned char *ares__dns_multistring_get( - const ares__dns_multistring_t *strs, size_t idx, size_t *len); +const unsigned char * + ares__dns_multistring_get(const ares__dns_multistring_t *strs, size_t idx, + size_t *len); const unsigned char * ares__dns_multistring_get_combined(ares__dns_multistring_t *strs, size_t *len); diff --git a/lib/c-ares-1.32.3/src/lib/ares_dns_name.c b/lib/c-ares-1.33.1/src/lib/record/ares_dns_name.c similarity index 87% rename from lib/c-ares-1.32.3/src/lib/ares_dns_name.c rename to lib/c-ares-1.33.1/src/lib/record/ares_dns_name.c index 076d26643eb..a437553b0f2 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_dns_name.c +++ b/lib/c-ares-1.33.1/src/lib/record/ares_dns_name.c @@ -131,72 +131,62 @@ static const ares_nameoffset_t *ares__nameoffset_find(ares__llist_t *list, return longest_match; } -typedef struct { - ares__buf_t **label; - size_t num; -} ares_dns_labels_t; - -static void ares_dns_labels_free(ares_dns_labels_t *labels) +static void ares_dns_labels_free_cb(void *arg) { - size_t i; - - if (labels == NULL) { - return; /* LCOV_EXCL_LINE: DefensiveCoding */ + ares__buf_t **buf = arg; + if (buf == NULL) { + return; } - for (i = 0; i < labels->num; i++) { - ares__buf_destroy(labels->label[i]); - labels->label[i] = NULL; - } - ares_free(labels->label); - labels->label = NULL; - labels->num = 0; + ares__buf_destroy(*buf); } -static ares__buf_t *ares_dns_labels_add(ares_dns_labels_t *labels) +static ares__buf_t *ares_dns_labels_add(ares__array_t *labels) { - void *temp; + ares__buf_t **buf; if (labels == NULL) { return NULL; /* LCOV_EXCL_LINE: DefensiveCoding */ } - temp = ares_realloc_zero(labels->label, sizeof(*labels->label) * labels->num, - sizeof(*labels->label) * (labels->num + 1)); - if (temp == NULL) { - return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ + if (ares__array_insert_last((void **)&buf, labels) != ARES_SUCCESS) { + return NULL; } - labels->label = temp; - - labels->label[labels->num] = ares__buf_create(); - if (labels->label[labels->num] == NULL) { - return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ + *buf = ares__buf_create(); + if (*buf == NULL) { + ares__array_remove_last(labels); + return NULL; } - labels->num++; - return labels->label[labels->num - 1]; + return *buf; } -static const ares__buf_t * - ares_dns_labels_get_last(const ares_dns_labels_t *labels) +static ares__buf_t *ares_dns_labels_get_last(ares__array_t *labels) { - if (labels == NULL || labels->num == 0) { - return NULL; /* LCOV_EXCL_LINE: DefensiveCoding */ + ares__buf_t **buf = ares__array_last(labels); + + if (buf == NULL) { + return NULL; } - return labels->label[labels->num - 1]; + return *buf; } -static void ares_dns_name_labels_del_last(ares_dns_labels_t *labels) +static ares__buf_t *ares_dns_labels_get_at(ares__array_t *labels, size_t idx) { - if (labels == NULL || labels->num == 0) { - return; /* LCOV_EXCL_LINE: DefensiveCoding */ + ares__buf_t **buf = ares__array_at(labels, idx); + + if (buf == NULL) { + return NULL; } - ares__buf_destroy(labels->label[labels->num - 1]); - labels->label[labels->num - 1] = NULL; - labels->num--; + return *buf; +} + +static void ares_dns_name_labels_del_last(ares__array_t *labels) +{ + ares__array_remove_last(labels); } static ares_status_t ares_parse_dns_name_escape(ares__buf_t *namebuf, @@ -212,7 +202,7 @@ static ares_status_t ares_parse_dns_name_escape(ares__buf_t *namebuf, } /* If next character is a digit, read 2 more digits */ - if (isdigit(c)) { + if (ares__isdigit(c)) { size_t i; unsigned int val = 0; @@ -224,7 +214,7 @@ static ares_status_t ares_parse_dns_name_escape(ares__buf_t *namebuf, return ARES_EBADNAME; } - if (!isdigit(c)) { + if (!ares__isdigit(c)) { return ARES_EBADNAME; } val *= 10; @@ -251,9 +241,9 @@ static ares_status_t ares_parse_dns_name_escape(ares__buf_t *namebuf, return ares__buf_append_byte(label, c); } -static ares_status_t ares_split_dns_name(ares_dns_labels_t *labels, - ares_bool_t validate_hostname, - const char *name) +static ares_status_t ares_split_dns_name(ares__array_t *labels, + ares_bool_t validate_hostname, + const char *name) { ares_status_t status; ares__buf_t *label = NULL; @@ -327,14 +317,15 @@ static ares_status_t ares_split_dns_name(ares_dns_labels_t *labels, /* If someone passed in "." there could have been 2 blank labels, check for * that */ - if (labels->num == 1 && + if (ares__array_len(labels) == 1 && ares__buf_len(ares_dns_labels_get_last(labels)) == 0) { ares_dns_name_labels_del_last(labels); } /* Scan to make sure label lengths are valid */ - for (i = 0; i < labels->num; i++) { - size_t len = ares__buf_len(labels->label[i]); + for (i = 0; i < ares__array_len(labels); i++) { + const ares__buf_t *buf = ares_dns_labels_get_at(labels, i); + size_t len = ares__buf_len(buf); /* No 0-length labels, and no labels over 63 bytes */ if (len == 0 || len > 63) { status = ARES_EBADNAME; @@ -344,7 +335,8 @@ static ares_status_t ares_split_dns_name(ares_dns_labels_t *labels, } /* Can't exceed maximum (unescaped) length */ - if (labels->num && total_len + labels->num - 1 > 255) { + if (ares__array_len(labels) && + total_len + ares__array_len(labels) - 1 > 255) { status = ARES_EBADNAME; goto done; } @@ -353,9 +345,6 @@ static ares_status_t ares_split_dns_name(ares_dns_labels_t *labels, done: ares__buf_destroy(namebuf); - if (status != ARES_SUCCESS) { - ares_dns_labels_free(labels); - } return status; } @@ -366,8 +355,8 @@ ares_status_t ares__dns_name_write(ares__buf_t *buf, ares__llist_t **list, const ares_nameoffset_t *off = NULL; size_t name_len; size_t orig_name_len; - size_t pos = ares__buf_len(buf); - ares_dns_labels_t labels; + size_t pos = ares__buf_len(buf); + ares__array_t *labels = NULL; char name_copy[512]; ares_status_t status; @@ -375,7 +364,10 @@ ares_status_t ares__dns_name_write(ares__buf_t *buf, ares__llist_t **list, return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } - memset(&labels, 0, sizeof(labels)); + labels = ares__array_create(sizeof(ares__buf_t *), ares_dns_labels_free_cb); + if (labels == NULL) { + return ARES_ENOMEM; + } /* NOTE: due to possible escaping, name_copy buffer is > 256 to allow for * this */ @@ -396,14 +388,15 @@ ares_status_t ares__dns_name_write(ares__buf_t *buf, ares__llist_t **list, if (off == NULL || off->name_len != orig_name_len) { size_t i; - status = ares_split_dns_name(&labels, validate_hostname, name_copy); + status = ares_split_dns_name(labels, validate_hostname, name_copy); if (status != ARES_SUCCESS) { goto done; } - for (i = 0; i < labels.num; i++) { - size_t len = 0; - const unsigned char *ptr = ares__buf_peek(labels.label[i], &len); + for (i = 0; i < ares__array_len(labels); i++) { + size_t len = 0; + const ares__buf_t *lbuf = ares_dns_labels_get_at(labels, i); + const unsigned char *ptr = ares__buf_peek(lbuf, &len); status = ares__buf_append_byte(buf, (unsigned char)(len & 0xFF)); if (status != ARES_SUCCESS) { @@ -448,7 +441,7 @@ ares_status_t ares__dns_name_write(ares__buf_t *buf, ares__llist_t **list, status = ARES_SUCCESS; done: - ares_dns_labels_free(&labels); + ares__array_destroy(labels); return status; } diff --git a/lib/c-ares-1.32.3/src/lib/ares_dns_parse.c b/lib/c-ares-1.33.1/src/lib/record/ares_dns_parse.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_dns_parse.c rename to lib/c-ares-1.33.1/src/lib/record/ares_dns_parse.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_dns_private.h b/lib/c-ares-1.33.1/src/lib/record/ares_dns_private.h similarity index 76% rename from lib/c-ares-1.32.3/src/lib/ares_dns_private.h rename to lib/c-ares-1.33.1/src/lib/record/ares_dns_private.h index 2dd468a5559..5b86fed51f9 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_dns_private.h +++ b/lib/c-ares-1.33.1/src/lib/record/ares_dns_private.h @@ -26,7 +26,7 @@ #ifndef __ARES_DNS_PRIVATE_H #define __ARES_DNS_PRIVATE_H -ares_status_t ares_dns_record_duplicate_ex(ares_dns_record_t **dest, +ares_status_t ares_dns_record_duplicate_ex(ares_dns_record_t **dest, const ares_dns_record_t *src); ares_bool_t ares_dns_rec_type_allow_name_compression(ares_dns_rec_type_t type); ares_bool_t ares_dns_opcode_isvalid(ares_dns_opcode_t opcode); @@ -38,23 +38,32 @@ ares_bool_t ares_dns_class_isvalid(ares_dns_class_t qclass, ares_dns_rec_type_t type, ares_bool_t is_query); ares_bool_t ares_dns_section_isvalid(ares_dns_section_t sect); -ares_status_t ares_dns_rr_set_str_own(ares_dns_rr_t *dns_rr, - ares_dns_rr_key_t key, char *val); -ares_status_t ares_dns_rr_set_bin_own(ares_dns_rr_t *dns_rr, - ares_dns_rr_key_t key, unsigned char *val, - size_t len); -ares_status_t ares_dns_rr_set_abin_own(ares_dns_rr_t *dns_rr, - ares_dns_rr_key_t key, - ares__dns_multistring_t *strs); -ares_status_t ares_dns_rr_set_opt_own(ares_dns_rr_t *dns_rr, - ares_dns_rr_key_t key, unsigned short opt, - unsigned char *val, size_t val_len); -ares_status_t ares_dns_record_rr_prealloc(ares_dns_record_t *dnsrec, - ares_dns_section_t sect, size_t cnt); -ares_bool_t ares_dns_has_opt_rr(const ares_dns_record_t *rec); +ares_status_t ares_dns_rr_set_str_own(ares_dns_rr_t *dns_rr, + ares_dns_rr_key_t key, char *val); +ares_status_t ares_dns_rr_set_bin_own(ares_dns_rr_t *dns_rr, + ares_dns_rr_key_t key, unsigned char *val, + size_t len); +ares_status_t ares_dns_rr_set_abin_own(ares_dns_rr_t *dns_rr, + ares_dns_rr_key_t key, + ares__dns_multistring_t *strs); +ares_status_t ares_dns_rr_set_opt_own(ares_dns_rr_t *dns_rr, + ares_dns_rr_key_t key, unsigned short opt, + unsigned char *val, size_t val_len); +ares_status_t ares_dns_record_rr_prealloc(ares_dns_record_t *dnsrec, + ares_dns_section_t sect, size_t cnt); +ares_dns_rr_t *ares_dns_get_opt_rr(ares_dns_record_t *rec); +const ares_dns_rr_t *ares_dns_get_opt_rr_const(const ares_dns_record_t *rec); void ares_dns_record_write_ttl_decrement(ares_dns_record_t *dnsrec, unsigned int ttl_decrement); +/* Same as ares_dns_write() but appends to an existing buffer object */ +ares_status_t ares_dns_write_buf(const ares_dns_record_t *dnsrec, + ares__buf_t *buf); + +/* Same as ares_dns_write_buf(), but prepends a 16bit length */ +ares_status_t ares_dns_write_buf_tcp(const ares_dns_record_t *dnsrec, + ares__buf_t *buf); + /*! Create a DNS record object for a query. The arguments are the same as * those for ares_create_query(). * @@ -168,18 +177,11 @@ typedef struct { } ares__dns_optval_t; typedef struct { - ares__dns_optval_t *optval; /*!< Attribute/value pairs */ - size_t cnt; /*!< Count of Attribute/Value pairs */ - size_t alloc; /*!< Allocated count of attribute/value - * pairs */ -} ares__dns_options_t; - -typedef struct { - unsigned short udp_size; /*!< taken from class */ - unsigned char version; /*!< taken from bits 8-16 of ttl */ - unsigned short flags; /*!< Flags, remaining 16 bits, though only - * 1 currently defined */ - ares__dns_options_t *options; /*!< Attribute/Value pairs */ + unsigned short udp_size; /*!< taken from class */ + unsigned char version; /*!< taken from bits 8-16 of ttl */ + unsigned short flags; /*!< Flags, remaining 16 bits, though only + * 1 currently defined */ + ares__array_t *options; /*!< Type is ares__dns_optval_t */ } ares__dns_opt_t; typedef struct { @@ -191,9 +193,9 @@ typedef struct { } ares__dns_tlsa_t; typedef struct { - unsigned short priority; - char *target; - ares__dns_options_t *params; + unsigned short priority; + char *target; + ares__array_t *params; /*!< Type is ares__dns_optval_t */ } ares__dns_svcb_t; typedef struct { @@ -262,21 +264,10 @@ struct ares_dns_record { * the ttl of any resource records by * this amount. Used for cache */ - ares_dns_qd_t *qd; - size_t qdcount; - size_t qdalloc; - - ares_dns_rr_t *an; - size_t ancount; - size_t analloc; - - ares_dns_rr_t *ns; - size_t nscount; - size_t nsalloc; - - ares_dns_rr_t *ar; - size_t arcount; - size_t aralloc; + ares__array_t *qd; /*!< Type is ares_dns_qd_t */ + ares__array_t *an; /*!< Type is ares_dns_rr_t */ + ares__array_t *ns; /*!< Type is ares_dns_rr_t */ + ares__array_t *ar; /*!< Type is ares_dns_rr_t */ }; #endif diff --git a/lib/c-ares-1.32.3/src/lib/ares_dns_record.c b/lib/c-ares-1.33.1/src/lib/record/ares_dns_record.c similarity index 84% rename from lib/c-ares-1.32.3/src/lib/ares_dns_record.c rename to lib/c-ares-1.33.1/src/lib/record/ares_dns_record.c index 8545abecf74..14704949094 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_dns_record.c +++ b/lib/c-ares-1.33.1/src/lib/record/ares_dns_record.c @@ -29,6 +29,25 @@ # include #endif +static void ares__dns_rr_free(ares_dns_rr_t *rr); + +static void ares_dns_qd_free_cb(void *arg) +{ + ares_dns_qd_t *qd = arg; + if (qd == NULL) { + return; + } + ares_free(qd->name); +} + +static void ares_dns_rr_free_cb(void *arg) +{ + ares_dns_rr_t *rr = arg; + if (rr == NULL) { + return; + } + ares__dns_rr_free(rr); +} ares_status_t ares_dns_record_create(ares_dns_record_t **dnsrec, unsigned short id, unsigned short flags, @@ -55,6 +74,22 @@ ares_status_t ares_dns_record_create(ares_dns_record_t **dnsrec, (*dnsrec)->flags = flags; (*dnsrec)->opcode = opcode; (*dnsrec)->rcode = rcode; + (*dnsrec)->qd = + ares__array_create(sizeof(ares_dns_qd_t), ares_dns_qd_free_cb); + (*dnsrec)->an = + ares__array_create(sizeof(ares_dns_rr_t), ares_dns_rr_free_cb); + (*dnsrec)->ns = + ares__array_create(sizeof(ares_dns_rr_t), ares_dns_rr_free_cb); + (*dnsrec)->ar = + ares__array_create(sizeof(ares_dns_rr_t), ares_dns_rr_free_cb); + + if ((*dnsrec)->qd == NULL || (*dnsrec)->an == NULL || (*dnsrec)->ns == NULL || + (*dnsrec)->ar == NULL) { + ares_dns_record_destroy(*dnsrec); + *dnsrec = NULL; + return ARES_ENOMEM; + } + return ARES_SUCCESS; } @@ -99,21 +134,6 @@ ares_dns_rcode_t ares_dns_record_get_rcode(const ares_dns_record_t *dnsrec) return dnsrec->rcode; } -static void ares__dns_options_free(ares__dns_options_t *options) -{ - size_t i; - - if (options == NULL) { - return; - } - - for (i = 0; i < options->cnt; i++) { - ares_free(options->optval[i].val); - } - ares_free(options->optval); - ares_free(options); -} - static void ares__dns_rr_free(ares_dns_rr_t *rr) { ares_free(rr->name); @@ -172,7 +192,7 @@ static void ares__dns_rr_free(ares_dns_rr_t *rr) break; case ARES_REC_TYPE_OPT: - ares__dns_options_free(rr->r.opt.options); + ares__array_destroy(rr->r.opt.options); break; case ARES_REC_TYPE_TLSA: @@ -181,12 +201,12 @@ static void ares__dns_rr_free(ares_dns_rr_t *rr) case ARES_REC_TYPE_SVCB: ares_free(rr->r.svcb.target); - ares__dns_options_free(rr->r.svcb.params); + ares__array_destroy(rr->r.svcb.params); break; case ARES_REC_TYPE_HTTPS: ares_free(rr->r.https.target); - ares__dns_options_free(rr->r.https.params); + ares__array_destroy(rr->r.https.params); break; case ARES_REC_TYPE_URI: @@ -206,35 +226,21 @@ static void ares__dns_rr_free(ares_dns_rr_t *rr) void ares_dns_record_destroy(ares_dns_record_t *dnsrec) { - size_t i; - if (dnsrec == NULL) { return; } /* Free questions */ - for (i = 0; i < dnsrec->qdcount; i++) { - ares_free(dnsrec->qd[i].name); - } - ares_free(dnsrec->qd); + ares__array_destroy(dnsrec->qd); /* Free answers */ - for (i = 0; i < dnsrec->ancount; i++) { - ares__dns_rr_free(&dnsrec->an[i]); - } - ares_free(dnsrec->an); + ares__array_destroy(dnsrec->an); /* Free authority */ - for (i = 0; i < dnsrec->nscount; i++) { - ares__dns_rr_free(&dnsrec->ns[i]); - } - ares_free(dnsrec->ns); + ares__array_destroy(dnsrec->ns); /* Free additional */ - for (i = 0; i < dnsrec->arcount; i++) { - ares__dns_rr_free(&dnsrec->ar[i]); - } - ares_free(dnsrec->ar); + ares__array_destroy(dnsrec->ar); ares_free(dnsrec); } @@ -244,7 +250,7 @@ size_t ares_dns_record_query_cnt(const ares_dns_record_t *dnsrec) if (dnsrec == NULL) { return 0; } - return dnsrec->qdcount; + return ares__array_len(dnsrec->qd); } ares_status_t ares_dns_record_query_add(ares_dns_record_t *dnsrec, @@ -252,8 +258,9 @@ ares_status_t ares_dns_record_query_add(ares_dns_record_t *dnsrec, ares_dns_rec_type_t qtype, ares_dns_class_t qclass) { - ares_dns_qd_t *temp = NULL; size_t idx; + ares_dns_qd_t *qd; + ares_status_t status; if (dnsrec == NULL || name == NULL || !ares_dns_rec_type_isvalid(qtype, ARES_TRUE) || @@ -261,47 +268,39 @@ ares_status_t ares_dns_record_query_add(ares_dns_record_t *dnsrec, return ARES_EFORMERR; } - if (dnsrec->qdcount >= dnsrec->qdalloc) { - size_t alloc_cnt = ares__round_up_pow2(dnsrec->qdcount + 1); - - temp = ares_realloc_zero(dnsrec->qd, sizeof(*temp) * (dnsrec->qdalloc), - sizeof(*temp) * alloc_cnt); - if (temp == NULL) { - return ARES_ENOMEM; - } - - dnsrec->qdalloc = alloc_cnt; - dnsrec->qd = temp; + idx = ares__array_len(dnsrec->qd); + status = ares__array_insert_last((void **)&qd, dnsrec->qd); + if (status != ARES_SUCCESS) { + return status; } - idx = dnsrec->qdcount; - - dnsrec->qd[idx].name = ares_strdup(name); - if (dnsrec->qd[idx].name == NULL) { - /* No need to clean up anything */ + qd->name = ares_strdup(name); + if (qd->name == NULL) { + ares__array_remove_at(dnsrec->qd, idx); return ARES_ENOMEM; } - - dnsrec->qd[idx].qtype = qtype; - dnsrec->qd[idx].qclass = qclass; - dnsrec->qdcount++; + qd->qtype = qtype; + qd->qclass = qclass; return ARES_SUCCESS; } ares_status_t ares_dns_record_query_set_name(ares_dns_record_t *dnsrec, size_t idx, const char *name) { - char *orig_name = NULL; + char *orig_name = NULL; + ares_dns_qd_t *qd; - if (dnsrec == NULL || idx >= dnsrec->qdcount || name == NULL) { + if (dnsrec == NULL || idx >= ares__array_len(dnsrec->qd) || name == NULL) { return ARES_EFORMERR; } - orig_name = dnsrec->qd[idx].name; - dnsrec->qd[idx].name = ares_strdup(name); - if (dnsrec->qd[idx].name == NULL) { - dnsrec->qd[idx].name = orig_name; /* LCOV_EXCL_LINE: OutOfMemory */ - return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + qd = ares__array_at(dnsrec->qd, idx); + + orig_name = qd->name; + qd->name = ares_strdup(name); + if (qd->name == NULL) { + qd->name = orig_name; /* LCOV_EXCL_LINE: OutOfMemory */ + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } ares_free(orig_name); @@ -312,12 +311,15 @@ ares_status_t ares_dns_record_query_set_type(ares_dns_record_t *dnsrec, size_t idx, ares_dns_rec_type_t qtype) { - if (dnsrec == NULL || idx >= dnsrec->qdcount || + ares_dns_qd_t *qd; + + if (dnsrec == NULL || idx >= ares__array_len(dnsrec->qd) || !ares_dns_rec_type_isvalid(qtype, ARES_TRUE)) { return ARES_EFORMERR; } - dnsrec->qd[idx].qtype = qtype; + qd = ares__array_at(dnsrec->qd, idx); + qd->qtype = qtype; return ARES_SUCCESS; } @@ -327,20 +329,22 @@ ares_status_t ares_dns_record_query_get(const ares_dns_record_t *dnsrec, ares_dns_rec_type_t *qtype, ares_dns_class_t *qclass) { - if (dnsrec == NULL || idx >= dnsrec->qdcount) { + const ares_dns_qd_t *qd; + if (dnsrec == NULL || idx >= ares__array_len(dnsrec->qd)) { return ARES_EFORMERR; } + qd = ares__array_at(dnsrec->qd, idx); if (name != NULL) { - *name = dnsrec->qd[idx].name; + *name = qd->name; } if (qtype != NULL) { - *qtype = dnsrec->qd[idx].qtype; + *qtype = qd->qtype; } if (qclass != NULL) { - *qclass = dnsrec->qd[idx].qclass; + *qclass = qd->qclass; } return ARES_SUCCESS; @@ -355,11 +359,11 @@ size_t ares_dns_record_rr_cnt(const ares_dns_record_t *dnsrec, switch (sect) { case ARES_SECTION_ANSWER: - return dnsrec->ancount; + return ares__array_len(dnsrec->an); case ARES_SECTION_AUTHORITY: - return dnsrec->nscount; + return ares__array_len(dnsrec->ns); case ARES_SECTION_ADDITIONAL: - return dnsrec->arcount; + return ares__array_len(dnsrec->ar); } return 0; /* LCOV_EXCL_LINE: DefensiveCoding */ @@ -368,46 +372,29 @@ size_t ares_dns_record_rr_cnt(const ares_dns_record_t *dnsrec, ares_status_t ares_dns_record_rr_prealloc(ares_dns_record_t *dnsrec, ares_dns_section_t sect, size_t cnt) { - ares_dns_rr_t **rr_ptr = NULL; - size_t *rr_alloc = NULL; - ares_dns_rr_t *temp = NULL; + ares__array_t *arr = NULL; - if (dnsrec == NULL || cnt == 0 || !ares_dns_section_isvalid(sect)) { - return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ + if (dnsrec == NULL || !ares_dns_section_isvalid(sect)) { + return ARES_EFORMERR; } switch (sect) { case ARES_SECTION_ANSWER: - rr_ptr = &dnsrec->an; - rr_alloc = &dnsrec->analloc; + arr = dnsrec->an; break; case ARES_SECTION_AUTHORITY: - rr_ptr = &dnsrec->ns; - rr_alloc = &dnsrec->nsalloc; + arr = dnsrec->ns; break; case ARES_SECTION_ADDITIONAL: - rr_ptr = &dnsrec->ar; - rr_alloc = &dnsrec->aralloc; + arr = dnsrec->ar; break; } - /* Round up cnt to a power of 2 */ - cnt = ares__round_up_pow2(cnt); - - /* Already have that */ - if (cnt <= *rr_alloc) { - return ARES_SUCCESS; - } - - temp = ares_realloc_zero(*rr_ptr, sizeof(*temp) * (*rr_alloc), - sizeof(*temp) * cnt); - if (temp == NULL) { - return ARES_ENOMEM; + if (cnt < ares__array_len(arr)) { + return ARES_EFORMERR; } - *rr_alloc = cnt; - *rr_ptr = temp; - return ARES_SUCCESS; + return ares__array_set_size(arr, cnt); } ares_status_t ares_dns_record_rr_add(ares_dns_rr_t **rr_out, @@ -416,11 +403,10 @@ ares_status_t ares_dns_record_rr_add(ares_dns_rr_t **rr_out, ares_dns_rec_type_t type, ares_dns_class_t rclass, unsigned int ttl) { - ares_dns_rr_t **rr_ptr = NULL; - ares_dns_rr_t *rr = NULL; - size_t *rr_len = NULL; - ares_status_t status; - size_t idx; + ares_dns_rr_t *rr = NULL; + ares__array_t *arr = NULL; + ares_status_t status; + size_t idx; if (dnsrec == NULL || name == NULL || rr_out == NULL || !ares_dns_section_isvalid(sect) || @@ -433,30 +419,25 @@ ares_status_t ares_dns_record_rr_add(ares_dns_rr_t **rr_out, switch (sect) { case ARES_SECTION_ANSWER: - rr_ptr = &dnsrec->an; - rr_len = &dnsrec->ancount; + arr = dnsrec->an; break; case ARES_SECTION_AUTHORITY: - rr_ptr = &dnsrec->ns; - rr_len = &dnsrec->nscount; + arr = dnsrec->ns; break; case ARES_SECTION_ADDITIONAL: - rr_ptr = &dnsrec->ar; - rr_len = &dnsrec->arcount; + arr = dnsrec->ar; break; } - status = ares_dns_record_rr_prealloc(dnsrec, sect, *rr_len + 1); + idx = ares__array_len(arr); + status = ares__array_insert_last((void **)&rr, arr); if (status != ARES_SUCCESS) { return status; /* LCOV_EXCL_LINE: OutOfMemory */ } - idx = *rr_len; - rr = &(*rr_ptr)[idx]; - rr->name = ares_strdup(name); if (rr->name == NULL) { - /* No need to clean up anything */ + ares__array_remove_at(arr, idx); return ARES_ENOMEM; } @@ -464,7 +445,6 @@ ares_status_t ares_dns_record_rr_add(ares_dns_rr_t **rr_out, rr->type = type; rr->rclass = rclass; rr->ttl = ttl; - (*rr_len)++; *rr_out = rr; @@ -474,9 +454,7 @@ ares_status_t ares_dns_record_rr_add(ares_dns_rr_t **rr_out, ares_status_t ares_dns_record_rr_del(ares_dns_record_t *dnsrec, ares_dns_section_t sect, size_t idx) { - ares_dns_rr_t *rr_ptr = NULL; - size_t *rr_len = NULL; - size_t cnt_after; + ares__array_t *arr = NULL; if (dnsrec == NULL || !ares_dns_section_isvalid(sect)) { return ARES_EFORMERR; @@ -484,40 +462,23 @@ ares_status_t ares_dns_record_rr_del(ares_dns_record_t *dnsrec, switch (sect) { case ARES_SECTION_ANSWER: - rr_ptr = dnsrec->an; - rr_len = &dnsrec->ancount; + arr = dnsrec->an; break; case ARES_SECTION_AUTHORITY: - rr_ptr = dnsrec->ns; - rr_len = &dnsrec->nscount; + arr = dnsrec->ns; break; case ARES_SECTION_ADDITIONAL: - rr_ptr = dnsrec->ar; - rr_len = &dnsrec->arcount; + arr = dnsrec->ar; break; } - if (idx >= *rr_len) { - return ARES_EFORMERR; - } - - ares__dns_rr_free(&rr_ptr[idx]); - - cnt_after = *rr_len - idx - 1; - - if (cnt_after) { - memmove(&rr_ptr[idx], &rr_ptr[idx + 1], sizeof(*rr_ptr) * cnt_after); - } - - (*rr_len)--; - return ARES_SUCCESS; + return ares__array_remove_at(arr, idx); } ares_dns_rr_t *ares_dns_record_rr_get(ares_dns_record_t *dnsrec, ares_dns_section_t sect, size_t idx) { - ares_dns_rr_t *rr_ptr = NULL; - size_t rr_len = 0; + ares__array_t *arr = NULL; if (dnsrec == NULL || !ares_dns_section_isvalid(sect)) { return NULL; @@ -525,24 +486,17 @@ ares_dns_rr_t *ares_dns_record_rr_get(ares_dns_record_t *dnsrec, switch (sect) { case ARES_SECTION_ANSWER: - rr_ptr = dnsrec->an; - rr_len = dnsrec->ancount; + arr = dnsrec->an; break; case ARES_SECTION_AUTHORITY: - rr_ptr = dnsrec->ns; - rr_len = dnsrec->nscount; + arr = dnsrec->ns; break; case ARES_SECTION_ADDITIONAL: - rr_ptr = dnsrec->ar; - rr_len = dnsrec->arcount; + arr = dnsrec->ar; break; } - if (idx >= rr_len) { - return NULL; - } - - return &rr_ptr[idx]; + return ares__array_at(arr, idx); } const ares_dns_rr_t * @@ -1040,7 +994,7 @@ const char *ares_dns_rr_get_str(const ares_dns_rr_t *dns_rr, size_t ares_dns_rr_get_opt_cnt(const ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key) { - ares__dns_options_t * const *opts; + ares__array_t * const *opts; if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_OPT) { return 0; @@ -1051,14 +1005,15 @@ size_t ares_dns_rr_get_opt_cnt(const ares_dns_rr_t *dns_rr, return 0; } - return (*opts)->cnt; + return ares__array_len(*opts); } unsigned short ares_dns_rr_get_opt(const ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key, size_t idx, const unsigned char **val, size_t *val_len) { - ares__dns_options_t * const *opts; + ares__array_t * const *opts; + const ares__dns_optval_t *opt; if (val) { *val = NULL; @@ -1076,26 +1031,29 @@ unsigned short ares_dns_rr_get_opt(const ares_dns_rr_t *dns_rr, return 65535; } - if (idx >= (*opts)->cnt) { + opt = ares__array_at(*opts, idx); + if (opt == NULL) { return 65535; } if (val) { - *val = (*opts)->optval[idx].val; + *val = opt->val; } if (val_len) { - *val_len = (*opts)->optval[idx].val_len; + *val_len = opt->val_len; } - return (*opts)->optval[idx].opt; + return opt->opt; } ares_bool_t ares_dns_rr_get_opt_byid(const ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key, unsigned short opt, const unsigned char **val, size_t *val_len) { - ares__dns_options_t * const *opts; - size_t i; + ares__array_t * const *opts; + size_t i; + size_t cnt; + const ares__dns_optval_t *optptr = NULL; if (val) { *val = NULL; @@ -1113,21 +1071,26 @@ ares_bool_t ares_dns_rr_get_opt_byid(const ares_dns_rr_t *dns_rr, return ARES_FALSE; } - for (i = 0; i < (*opts)->cnt; i++) { - if ((*opts)->optval[i].opt == opt) { + cnt = ares__array_len(*opts); + for (i = 0; i < cnt; i++) { + optptr = ares__array_at(*opts, i); + if (optptr == NULL) { + return ARES_FALSE; + } + if (optptr->opt == opt) { break; } } - if (i >= (*opts)->cnt) { + if (i >= cnt || optptr == NULL) { return ARES_FALSE; } if (val) { - *val = (*opts)->optval[i].val; + *val = optptr->val; } if (val_len) { - *val_len = (*opts)->optval[i].val_len; + *val_len = optptr->val_len; } return ARES_TRUE; } @@ -1367,12 +1330,24 @@ ares_status_t ares_dns_rr_set_abin_own(ares_dns_rr_t *dns_rr, return ARES_SUCCESS; } +static void ares__dns_opt_free_cb(void *arg) +{ + ares__dns_optval_t *opt = arg; + if (opt == NULL) { + return; + } + ares_free(opt->val); +} + ares_status_t ares_dns_rr_set_opt_own(ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key, unsigned short opt, unsigned char *val, size_t val_len) { - ares__dns_options_t **options; - size_t idx; + ares__array_t **options; + ares__dns_optval_t *optptr = NULL; + size_t idx; + size_t cnt; + ares_status_t status; if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_OPT) { return ARES_EFORMERR; @@ -1384,54 +1359,39 @@ ares_status_t ares_dns_rr_set_opt_own(ares_dns_rr_t *dns_rr, } if (*options == NULL) { - *options = ares_malloc_zero(sizeof(**options)); + *options = + ares__array_create(sizeof(ares__dns_optval_t), ares__dns_opt_free_cb); } if (*options == NULL) { return ARES_ENOMEM; } - for (idx = 0; idx < (*options)->cnt; idx++) { - if ((*options)->optval[idx].opt == opt) { + cnt = ares__array_len(*options); + for (idx = 0; idx < cnt; idx++) { + optptr = ares__array_at(*options, idx); + if (optptr == NULL) { + return ARES_EFORMERR; + } + if (optptr->opt == opt) { break; } } /* Duplicate entry, replace */ - if (idx != (*options)->cnt) { + if (idx != cnt && optptr != NULL) { goto done; } - idx = (*options)->cnt; - - /* Expand by powers of 2 */ - if (idx >= (*options)->alloc) { - size_t alloc_size = (*options)->alloc; - void *temp; - - if (alloc_size == 0) { - alloc_size = 1; - } else { - alloc_size <<= 1; - } - - temp = ares_realloc_zero((*options)->optval, - (*options)->alloc * sizeof(*(*options)->optval), - alloc_size * sizeof(*(*options)->optval)); - if (temp == NULL) { - return ARES_ENOMEM; - } - - (*options)->optval = temp; - (*options)->alloc = alloc_size; + status = ares__array_insert_last((void **)&optptr, *options); + if (status != ARES_SUCCESS) { + return status; } - (*options)->cnt++; - done: - ares_free((*options)->optval[idx].val); - (*options)->optval[idx].opt = opt; - (*options)->optval[idx].val = val; - (*options)->optval[idx].val_len = val_len; + ares_free(optptr->val); + optptr->opt = opt; + optptr->val = val; + optptr->val_len = val_len; return ARES_SUCCESS; } @@ -1460,6 +1420,43 @@ ares_status_t ares_dns_rr_set_opt(ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key, return status; } +ares_status_t ares_dns_rr_del_opt_byid(ares_dns_rr_t *dns_rr, + ares_dns_rr_key_t key, + unsigned short opt) +{ + ares__array_t **options; + const ares__dns_optval_t *optptr; + size_t idx; + size_t cnt; + + if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_OPT) { + return ARES_EFORMERR; + } + + options = ares_dns_rr_data_ptr(dns_rr, key, NULL); + if (options == NULL) { + return ARES_EFORMERR; + } + + /* No options */ + if (*options == NULL) { + return ARES_SUCCESS; + } + + cnt = ares__array_len(*options); + for (idx = 0; idx < cnt; idx++) { + optptr = ares__array_at_const(*options, idx); + if (optptr == NULL) { + return ARES_ENOTFOUND; + } + if (optptr->opt == opt) { + return ares__array_remove_at(*options, idx); + } + } + + return ARES_ENOTFOUND; +} + char *ares_dns_addr_to_ptr(const struct ares_addr *addr) { ares__buf_t *buf = NULL; @@ -1532,8 +1529,20 @@ char *ares_dns_addr_to_ptr(const struct ares_addr *addr) return NULL; } -/* search for an OPT RR in the response */ -ares_bool_t ares_dns_has_opt_rr(const ares_dns_record_t *rec) +ares_dns_rr_t *ares_dns_get_opt_rr(ares_dns_record_t *rec) +{ + size_t i; + for (i = 0; i < ares_dns_record_rr_cnt(rec, ARES_SECTION_ADDITIONAL); i++) { + ares_dns_rr_t *rr = ares_dns_record_rr_get(rec, ARES_SECTION_ADDITIONAL, i); + + if (ares_dns_rr_get_type(rr) == ARES_REC_TYPE_OPT) { + return rr; + } + } + return NULL; +} + +const ares_dns_rr_t *ares_dns_get_opt_rr_const(const ares_dns_record_t *rec) { size_t i; for (i = 0; i < ares_dns_record_rr_cnt(rec, ARES_SECTION_ADDITIONAL); i++) { @@ -1541,10 +1550,10 @@ ares_bool_t ares_dns_has_opt_rr(const ares_dns_record_t *rec) ares_dns_record_rr_get_const(rec, ARES_SECTION_ADDITIONAL, i); if (ares_dns_rr_get_type(rr) == ARES_REC_TYPE_OPT) { - return ARES_TRUE; + return rr; } } - return ARES_FALSE; + return NULL; } /* Construct a DNS record for a name with given class and type. Used internally @@ -1623,12 +1632,12 @@ ares_status_t return status; } -ares_status_t ares_dns_record_duplicate_ex(ares_dns_record_t **dest, +ares_status_t ares_dns_record_duplicate_ex(ares_dns_record_t **dest, const ares_dns_record_t *src) { - unsigned char *data = NULL; - size_t data_len = 0; - ares_status_t status; + unsigned char *data = NULL; + size_t data_len = 0; + ares_status_t status; if (dest == NULL || src == NULL) { return ARES_EFORMERR; diff --git a/lib/c-ares-1.32.3/src/lib/ares_dns_write.c b/lib/c-ares-1.33.1/src/lib/record/ares_dns_write.c similarity index 93% rename from lib/c-ares-1.32.3/src/lib/ares_dns_write.c rename to lib/c-ares-1.33.1/src/lib/record/ares_dns_write.c index 60bbd702889..8a3addd9f01 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_dns_write.c +++ b/lib/c-ares-1.33.1/src/lib/record/ares_dns_write.c @@ -91,7 +91,7 @@ static ares_status_t ares_dns_write_header(const ares_dns_record_t *dnsrec, } /* RCODE */ - if (dnsrec->rcode > 15 && !ares_dns_has_opt_rr(dnsrec)) { + if (dnsrec->rcode > 15 && ares_dns_get_opt_rr_const(dnsrec) == NULL) { /* Must have OPT RR in order to write extended error codes */ rcode = ARES_RCODE_SERVFAIL; } else { @@ -105,25 +105,29 @@ static ares_status_t ares_dns_write_header(const ares_dns_record_t *dnsrec, } /* QDCOUNT */ - status = ares__buf_append_be16(buf, (unsigned short)dnsrec->qdcount); + status = ares__buf_append_be16( + buf, (unsigned short)ares_dns_record_query_cnt(dnsrec)); if (status != ARES_SUCCESS) { return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* ANCOUNT */ - status = ares__buf_append_be16(buf, (unsigned short)dnsrec->ancount); + status = ares__buf_append_be16( + buf, (unsigned short)ares_dns_record_rr_cnt(dnsrec, ARES_SECTION_ANSWER)); if (status != ARES_SUCCESS) { return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* NSCOUNT */ - status = ares__buf_append_be16(buf, (unsigned short)dnsrec->nscount); + status = ares__buf_append_be16(buf, (unsigned short)ares_dns_record_rr_cnt( + dnsrec, ARES_SECTION_AUTHORITY)); if (status != ARES_SUCCESS) { return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* ARCOUNT */ - status = ares__buf_append_be16(buf, (unsigned short)dnsrec->arcount); + status = ares__buf_append_be16(buf, (unsigned short)ares_dns_record_rr_cnt( + dnsrec, ARES_SECTION_ADDITIONAL)); if (status != ARES_SUCCESS) { return status; /* LCOV_EXCL_LINE: OutOfMemory */ } @@ -1090,52 +1094,121 @@ static ares_status_t ares_dns_write_rr(const ares_dns_record_t *dnsrec, return ARES_SUCCESS; } -ares_status_t ares_dns_write(const ares_dns_record_t *dnsrec, - unsigned char **buf, size_t *buf_len) +ares_status_t ares_dns_write_buf(const ares_dns_record_t *dnsrec, + ares__buf_t *buf) { - ares__buf_t *b = NULL; - ares_status_t status; ares__llist_t *namelist = NULL; + size_t orig_len; + ares_status_t status; - if (buf == NULL || buf_len == NULL || dnsrec == NULL) { + if (dnsrec == NULL || buf == NULL) { return ARES_EFORMERR; } - *buf = NULL; - *buf_len = 0; + orig_len = ares__buf_len(buf); - b = ares__buf_create(); - if (b == NULL) { - return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + status = ares_dns_write_header(dnsrec, buf); + if (status != ARES_SUCCESS) { + goto done; } - status = ares_dns_write_header(dnsrec, b); + status = ares_dns_write_questions(dnsrec, &namelist, buf); if (status != ARES_SUCCESS) { goto done; } - status = ares_dns_write_questions(dnsrec, &namelist, b); + status = ares_dns_write_rr(dnsrec, &namelist, ARES_SECTION_ANSWER, buf); if (status != ARES_SUCCESS) { goto done; } - status = ares_dns_write_rr(dnsrec, &namelist, ARES_SECTION_ANSWER, b); + status = ares_dns_write_rr(dnsrec, &namelist, ARES_SECTION_AUTHORITY, buf); if (status != ARES_SUCCESS) { goto done; } - status = ares_dns_write_rr(dnsrec, &namelist, ARES_SECTION_AUTHORITY, b); + status = ares_dns_write_rr(dnsrec, &namelist, ARES_SECTION_ADDITIONAL, buf); if (status != ARES_SUCCESS) { goto done; } - status = ares_dns_write_rr(dnsrec, &namelist, ARES_SECTION_ADDITIONAL, b); +done: + ares__llist_destroy(namelist); + if (status != ARES_SUCCESS) { + ares__buf_set_length(buf, orig_len); + } + + return status; +} + +ares_status_t ares_dns_write_buf_tcp(const ares_dns_record_t *dnsrec, + ares__buf_t *buf) +{ + ares_status_t status; + size_t orig_len; + size_t msg_len; + size_t len; + + if (dnsrec == NULL || buf == NULL) { + return ARES_EFORMERR; + } + + orig_len = ares__buf_len(buf); + + /* Write placeholder for length */ + status = ares__buf_append_be16(buf, 0); if (status != ARES_SUCCESS) { + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + } + + /* Write message */ + status = ares_dns_write_buf(dnsrec, buf); + if (status != ARES_SUCCESS) { + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + } + + len = ares__buf_len(buf); + msg_len = len - orig_len - 2; + if (msg_len > 65535) { + status = ARES_EBADQUERY; goto done; } + /* Now we need to overwrite the length, so we jump back to the original + * message length, overwrite the section and jump back */ + ares__buf_set_length(buf, orig_len); + status = ares__buf_append_be16(buf, (unsigned short)(msg_len & 0xFFFF)); + if (status != ARES_SUCCESS) { + goto done; /* LCOV_EXCL_LINE: UntestablePath */ + } + ares__buf_set_length(buf, len); + done: - ares__llist_destroy(namelist); + if (status != ARES_SUCCESS) { + ares__buf_set_length(buf, orig_len); + } + return status; +} + +ares_status_t ares_dns_write(const ares_dns_record_t *dnsrec, + unsigned char **buf, size_t *buf_len) +{ + ares__buf_t *b = NULL; + ares_status_t status; + + if (buf == NULL || buf_len == NULL || dnsrec == NULL) { + return ARES_EFORMERR; + } + + *buf = NULL; + *buf_len = 0; + + b = ares__buf_create(); + if (b == NULL) { + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + } + + status = ares_dns_write_buf(dnsrec, b); if (status != ARES_SUCCESS) { ares__buf_destroy(b); diff --git a/lib/c-ares-1.32.3/src/lib/ares__buf.c b/lib/c-ares-1.33.1/src/lib/str/ares__buf.c similarity index 99% rename from lib/c-ares-1.32.3/src/lib/ares__buf.c rename to lib/c-ares-1.33.1/src/lib/str/ares__buf.c index 320a73d6748..bf6d4a0e1d3 100644 --- a/lib/c-ares-1.32.3/src/lib/ares__buf.c +++ b/lib/c-ares-1.33.1/src/lib/str/ares__buf.c @@ -204,7 +204,7 @@ ares_status_t ares__buf_set_length(ares__buf_t *buf, size_t len) return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } - buf->data_len = len; + buf->data_len = len + buf->offset; return ARES_SUCCESS; } @@ -213,10 +213,14 @@ ares_status_t ares__buf_append(ares__buf_t *buf, const unsigned char *data, { ares_status_t status; - if (data == NULL || data_len == 0) { + if (data == NULL && data_len != 0) { return ARES_EFORMERR; } + if (data_len == 0) { + return ARES_SUCCESS; + } + status = ares__buf_ensure_space(buf, data_len); if (status != ARES_SUCCESS) { return status; diff --git a/lib/c-ares-1.32.3/src/lib/ares__buf.h b/lib/c-ares-1.33.1/src/lib/str/ares__buf.h similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares__buf.h rename to lib/c-ares-1.33.1/src/lib/str/ares__buf.h diff --git a/lib/c-ares-1.32.3/src/lib/ares_str.c b/lib/c-ares-1.33.1/src/lib/str/ares_str.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_str.c rename to lib/c-ares-1.33.1/src/lib/str/ares_str.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_str.h b/lib/c-ares-1.33.1/src/lib/str/ares_str.h similarity index 82% rename from lib/c-ares-1.32.3/src/lib/ares_str.h rename to lib/c-ares-1.33.1/src/lib/str/ares_str.h index 81353221407..440758c21be 100644 --- a/lib/c-ares-1.32.3/src/lib/ares_str.h +++ b/lib/c-ares-1.33.1/src/lib/str/ares_str.h @@ -72,5 +72,18 @@ ares_bool_t ares__is_hostname(const char *str); */ ares_bool_t ares__str_isprint(const char *str, size_t len); +/* We only care about ASCII rules */ +#define ares__isascii(x) (((unsigned char)x) <= 127) +#define ares__isdigit(x) \ + (((unsigned char)x) >= '0' && ((unsigned char)x) <= '9') +#define ares__isxdigit(x) \ + (ares__isdigit(x) || \ + (((unsigned char)x) >= 'a' && ((unsigned char)x) <= 'f') || \ + (((unsigned char)x) >= 'A' && ((unsigned char)x) <= 'F')) +#define ares__isupper(x) \ + (((unsigned char)x) >= 'A' && ((unsigned char)x) <= 'Z') +#define ares__islower(x) \ + (((unsigned char)x) >= 'a' && ((unsigned char)x) <= 'z') +#define ares__isalpha(x) (ares__islower(x) || ares__isupper(x)) #endif /* __ARES_STR_H */ diff --git a/lib/c-ares-1.32.3/src/lib/ares_strcasecmp.c b/lib/c-ares-1.33.1/src/lib/str/ares_strcasecmp.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_strcasecmp.c rename to lib/c-ares-1.33.1/src/lib/str/ares_strcasecmp.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_strcasecmp.h b/lib/c-ares-1.33.1/src/lib/str/ares_strcasecmp.h similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_strcasecmp.h rename to lib/c-ares-1.33.1/src/lib/str/ares_strcasecmp.h diff --git a/lib/c-ares-1.32.3/src/lib/ares_strsplit.c b/lib/c-ares-1.33.1/src/lib/str/ares_strsplit.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_strsplit.c rename to lib/c-ares-1.33.1/src/lib/str/ares_strsplit.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_strsplit.h b/lib/c-ares-1.33.1/src/lib/str/ares_strsplit.h similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_strsplit.h rename to lib/c-ares-1.33.1/src/lib/str/ares_strsplit.h diff --git a/lib/c-ares-1.32.3/src/lib/thirdparty/apple/dnsinfo.h b/lib/c-ares-1.33.1/src/lib/thirdparty/apple/dnsinfo.h similarity index 100% rename from lib/c-ares-1.32.3/src/lib/thirdparty/apple/dnsinfo.h rename to lib/c-ares-1.33.1/src/lib/thirdparty/apple/dnsinfo.h diff --git a/lib/c-ares-1.32.3/src/lib/ares__iface_ips.c b/lib/c-ares-1.33.1/src/lib/util/ares__iface_ips.c similarity index 90% rename from lib/c-ares-1.32.3/src/lib/ares__iface_ips.c rename to lib/c-ares-1.33.1/src/lib/util/ares__iface_ips.c index 6c983cabb1c..56dc2579041 100644 --- a/lib/c-ares-1.32.3/src/lib/ares__iface_ips.c +++ b/lib/c-ares-1.33.1/src/lib/util/ares__iface_ips.c @@ -71,12 +71,19 @@ typedef struct { } ares__iface_ip_t; struct ares__iface_ips { - ares__iface_ip_t *ips; - size_t cnt; - size_t alloc_size; + ares__array_t *ips; /*!< Type is ares__iface_ip_t */ ares__iface_ip_flags_t enum_flags; }; +static void ares__iface_ip_free_cb(void *arg) +{ + ares__iface_ip_t *ip = arg; + if (ip == NULL) { + return; + } + ares_free(ip->name); +} + static ares__iface_ips_t *ares__iface_ips_alloc(ares__iface_ip_flags_t flags) { ares__iface_ips_t *ips = ares_malloc_zero(sizeof(*ips)); @@ -84,38 +91,23 @@ static ares__iface_ips_t *ares__iface_ips_alloc(ares__iface_ip_flags_t flags) return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ } - /* Prealloc 4 entries */ - ips->alloc_size = 4; - ips->ips = ares_malloc_zero(ips->alloc_size * sizeof(*ips->ips)); + ips->enum_flags = flags; + ips->ips = + ares__array_create(sizeof(ares__iface_ip_t), ares__iface_ip_free_cb); if (ips->ips == NULL) { ares_free(ips); /* LCOV_EXCL_LINE: OutOfMemory */ return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ } - ips->enum_flags = flags; return ips; } -static void ares__iface_ip_destroy(ares__iface_ip_t *ip) -{ - if (ip == NULL) { - return; /* LCOV_EXCL_LINE: DefensiveCoding */ - } - ares_free(ip->name); - memset(ip, 0, sizeof(*ip)); -} - void ares__iface_ips_destroy(ares__iface_ips_t *ips) { - size_t i; - if (ips == NULL) { return; } - for (i = 0; i < ips->cnt; i++) { - ares__iface_ip_destroy(&ips->ips[i]); - } - ares_free(ips->ips); + ares__array_destroy(ips->ips); ares_free(ips); } @@ -150,7 +142,8 @@ static ares_status_t const char *name, const struct ares_addr *addr, unsigned char netmask, unsigned int ll_scope) { - size_t idx; + ares__iface_ip_t *ip; + ares_status_t status; if (ips == NULL || name == NULL || addr == NULL) { return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ @@ -197,32 +190,20 @@ static ares_status_t } } - /* Allocate more ips */ - if (ips->cnt + 1 > ips->alloc_size) { - void *temp; - size_t alloc_size; - - alloc_size = ares__round_up_pow2(ips->alloc_size + 1); - temp = ares_realloc_zero(ips->ips, ips->alloc_size * sizeof(*ips->ips), - alloc_size * sizeof(*ips->ips)); - if (temp == NULL) { - return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - } - ips->ips = temp; - ips->alloc_size = alloc_size; + status = ares__array_insert_last((void **)&ip, ips->ips); + if (status != ARES_SUCCESS) { + return status; } - /* Add */ - idx = ips->cnt++; - - ips->ips[idx].flags = flags; - ips->ips[idx].netmask = netmask; + ip->flags = flags; + ip->netmask = netmask; if (flags & ARES_IFACE_IP_LINKLOCAL) { - ips->ips[idx].ll_scope = ll_scope; + ip->ll_scope = ll_scope; } - memcpy(&ips->ips[idx].addr, addr, sizeof(*addr)); - ips->ips[idx].name = ares_strdup(name); - if (ips->ips[idx].name == NULL) { + memcpy(&ip->addr, addr, sizeof(*addr)); + ip->name = ares_strdup(name); + if (ip->name == NULL) { + ares__array_remove_last(ips->ips); return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } @@ -234,51 +215,91 @@ size_t ares__iface_ips_cnt(const ares__iface_ips_t *ips) if (ips == NULL) { return 0; } - return ips->cnt; + return ares__array_len(ips->ips); } const char *ares__iface_ips_get_name(const ares__iface_ips_t *ips, size_t idx) { - if (ips == NULL || idx >= ips->cnt) { + const ares__iface_ip_t *ip; + + if (ips == NULL) { return NULL; } - return ips->ips[idx].name; + + ip = ares__array_at_const(ips->ips, idx); + if (ip == NULL) { + return NULL; + } + + return ip->name; } const struct ares_addr *ares__iface_ips_get_addr(const ares__iface_ips_t *ips, size_t idx) { - if (ips == NULL || idx >= ips->cnt) { + const ares__iface_ip_t *ip; + + if (ips == NULL) { return NULL; } - return &ips->ips[idx].addr; + + ip = ares__array_at_const(ips->ips, idx); + if (ip == NULL) { + return NULL; + } + + return &ip->addr; } ares__iface_ip_flags_t ares__iface_ips_get_flags(const ares__iface_ips_t *ips, size_t idx) { - if (ips == NULL || idx >= ips->cnt) { + const ares__iface_ip_t *ip; + + if (ips == NULL) { return 0; } - return ips->ips[idx].flags; + + ip = ares__array_at_const(ips->ips, idx); + if (ip == NULL) { + return 0; + } + + return ip->flags; } unsigned char ares__iface_ips_get_netmask(const ares__iface_ips_t *ips, size_t idx) { - if (ips == NULL || idx >= ips->cnt) { + const ares__iface_ip_t *ip; + + if (ips == NULL) { return 0; } - return ips->ips[idx].netmask; + + ip = ares__array_at_const(ips->ips, idx); + if (ip == NULL) { + return 0; + } + + return ip->netmask; } unsigned int ares__iface_ips_get_ll_scope(const ares__iface_ips_t *ips, size_t idx) { - if (ips == NULL || idx >= ips->cnt) { + const ares__iface_ip_t *ip; + + if (ips == NULL) { return 0; } - return ips->ips[idx].ll_scope; + + ip = ares__array_at_const(ips->ips, idx); + if (ip == NULL) { + return 0; + } + + return ip->ll_scope; } diff --git a/lib/c-ares-1.32.3/src/lib/ares__iface_ips.h b/lib/c-ares-1.33.1/src/lib/util/ares__iface_ips.h similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares__iface_ips.h rename to lib/c-ares-1.33.1/src/lib/util/ares__iface_ips.h diff --git a/lib/c-ares-1.32.3/src/lib/ares__threads.c b/lib/c-ares-1.33.1/src/lib/util/ares__threads.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares__threads.c rename to lib/c-ares-1.33.1/src/lib/util/ares__threads.c diff --git a/lib/c-ares-1.32.3/src/lib/ares__threads.h b/lib/c-ares-1.33.1/src/lib/util/ares__threads.h similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares__threads.h rename to lib/c-ares-1.33.1/src/lib/util/ares__threads.h diff --git a/lib/c-ares-1.32.3/src/lib/ares__timeval.c b/lib/c-ares-1.33.1/src/lib/util/ares__timeval.c similarity index 98% rename from lib/c-ares-1.32.3/src/lib/ares__timeval.c rename to lib/c-ares-1.33.1/src/lib/util/ares__timeval.c index 66d07441c80..e3a989dca87 100644 --- a/lib/c-ares-1.32.3/src/lib/ares__timeval.c +++ b/lib/c-ares-1.33.1/src/lib/util/ares__timeval.c @@ -47,7 +47,7 @@ void ares__tvnow(ares_timeval_t *now) /* We want to prevent overflows so we get the remainder, then multiply to * microseconds before dividing */ now->usec = (unsigned int)(((current.QuadPart % freq.QuadPart) * 1000000) / - freq.QuadPart); + freq.QuadPart); } #elif defined(HAVE_CLOCK_GETTIME_MONOTONIC) diff --git a/lib/c-ares-1.32.3/src/lib/ares_math.c b/lib/c-ares-1.33.1/src/lib/util/ares_math.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_math.c rename to lib/c-ares-1.33.1/src/lib/util/ares_math.c diff --git a/lib/c-ares-1.32.3/src/lib/ares_rand.c b/lib/c-ares-1.33.1/src/lib/util/ares_rand.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/ares_rand.c rename to lib/c-ares-1.33.1/src/lib/util/ares_rand.c diff --git a/lib/c-ares-1.32.3/src/lib/windows_port.c b/lib/c-ares-1.33.1/src/lib/windows_port.c similarity index 100% rename from lib/c-ares-1.32.3/src/lib/windows_port.c rename to lib/c-ares-1.33.1/src/lib/windows_port.c diff --git a/lib/c-ares-1.32.3/src/tools/CMakeLists.txt b/lib/c-ares-1.33.1/src/tools/CMakeLists.txt similarity index 100% rename from lib/c-ares-1.32.3/src/tools/CMakeLists.txt rename to lib/c-ares-1.33.1/src/tools/CMakeLists.txt diff --git a/lib/c-ares-1.32.3/src/tools/Makefile.am b/lib/c-ares-1.33.1/src/tools/Makefile.am similarity index 100% rename from lib/c-ares-1.32.3/src/tools/Makefile.am rename to lib/c-ares-1.33.1/src/tools/Makefile.am diff --git a/lib/c-ares-1.32.3/src/tools/Makefile.in b/lib/c-ares-1.33.1/src/tools/Makefile.in similarity index 85% rename from lib/c-ares-1.32.3/src/tools/Makefile.in rename to lib/c-ares-1.33.1/src/tools/Makefile.in index 0b7a310baaa..e1b661ec1d7 100644 --- a/lib/c-ares-1.32.3/src/tools/Makefile.in +++ b/lib/c-ares-1.33.1/src/tools/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.5 from Makefile.am. +# Makefile.in generated by automake 1.17 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2021 Free Software Foundation, Inc. +# Copyright (C) 1994-2024 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -70,6 +70,8 @@ am__make_running_with_option = \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +am__rm_f = rm -f $(am__rm_f_notfound) +am__rm_rf = rm -rf $(am__rm_f_notfound) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -126,7 +128,7 @@ am__EXEEXT_1 = ahost$(EXEEXT) adig$(EXEEXT) PROGRAMS = $(noinst_PROGRAMS) am__dirstamp = $(am__leading_dot)dirstamp am__objects_1 = adig-ares_getopt.$(OBJEXT) \ - ../lib/adig-ares_strcasecmp.$(OBJEXT) + ../lib/str/adig-ares_strcasecmp.$(OBJEXT) am__objects_2 = am_adig_OBJECTS = adig-adig.$(OBJEXT) $(am__objects_1) \ $(am__objects_2) @@ -143,7 +145,7 @@ adig_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(adig_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ am__objects_3 = ahost-ares_getopt.$(OBJEXT) \ - ../lib/ahost-ares_strcasecmp.$(OBJEXT) + ../lib/str/ahost-ares_strcasecmp.$(OBJEXT) am_ahost_OBJECTS = ahost-ahost.$(OBJEXT) $(am__objects_3) \ $(am__objects_2) ahost_OBJECTS = $(am_ahost_OBJECTS) @@ -168,8 +170,8 @@ am__v_at_1 = DEFAULT_INCLUDES = depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__maybe_remake_depfiles = depfiles -am__depfiles_remade = ../lib/$(DEPDIR)/adig-ares_strcasecmp.Po \ - ../lib/$(DEPDIR)/ahost-ares_strcasecmp.Po \ +am__depfiles_remade = ../lib/str/$(DEPDIR)/adig-ares_strcasecmp.Po \ + ../lib/str/$(DEPDIR)/ahost-ares_strcasecmp.Po \ ./$(DEPDIR)/adig-adig.Po ./$(DEPDIR)/adig-ares_getopt.Po \ ./$(DEPDIR)/ahost-ahost.Po ./$(DEPDIR)/ahost-ares_getopt.Po am__mv = mv -f @@ -273,6 +275,8 @@ FGREP = @FGREP@ FILECMD = @FILECMD@ GCOV = @GCOV@ GENHTML = @GENHTML@ +GMOCK112_CFLAGS = @GMOCK112_CFLAGS@ +GMOCK112_LIBS = @GMOCK112_LIBS@ GMOCK_CFLAGS = @GMOCK_CFLAGS@ GMOCK_LIBS = @GMOCK_LIBS@ GREP = @GREP@ @@ -335,8 +339,10 @@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ +am__rm_f_notfound = @am__rm_f_notfound@ am__tar = @am__tar@ am__untar = @am__untar@ +am__xargs_n = @am__xargs_n@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ @@ -391,10 +397,10 @@ EXTRA_DIST = CMakeLists.txt Makefile.inc # Copyright (C) The c-ares project and its contributors # SPDX-License-Identifier: MIT SAMPLESOURCES = ares_getopt.c \ - ../lib/ares_strcasecmp.c + ../lib/str/ares_strcasecmp.c SAMPLEHEADERS = ares_getopt.h \ - ../lib/ares_strcasecmp.h + ../lib/str/ares_strcasecmp.h # We're not interested in code coverage of the test apps themselves, but need @@ -442,27 +448,23 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) $(am__aclocal_m4_deps): clean-noinstPROGRAMS: - @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list -../lib/$(am__dirstamp): - @$(MKDIR_P) ../lib - @: > ../lib/$(am__dirstamp) -../lib/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) ../lib/$(DEPDIR) - @: > ../lib/$(DEPDIR)/$(am__dirstamp) -../lib/adig-ares_strcasecmp.$(OBJEXT): ../lib/$(am__dirstamp) \ - ../lib/$(DEPDIR)/$(am__dirstamp) + $(am__rm_f) $(noinst_PROGRAMS) + test -z "$(EXEEXT)" || $(am__rm_f) $(noinst_PROGRAMS:$(EXEEXT)=) +../lib/str/$(am__dirstamp): + @$(MKDIR_P) ../lib/str + @: >>../lib/str/$(am__dirstamp) +../lib/str/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) ../lib/str/$(DEPDIR) + @: >>../lib/str/$(DEPDIR)/$(am__dirstamp) +../lib/str/adig-ares_strcasecmp.$(OBJEXT): ../lib/str/$(am__dirstamp) \ + ../lib/str/$(DEPDIR)/$(am__dirstamp) adig$(EXEEXT): $(adig_OBJECTS) $(adig_DEPENDENCIES) $(EXTRA_adig_DEPENDENCIES) @rm -f adig$(EXEEXT) $(AM_V_CCLD)$(adig_LINK) $(adig_OBJECTS) $(adig_LDADD) $(LIBS) -../lib/ahost-ares_strcasecmp.$(OBJEXT): ../lib/$(am__dirstamp) \ - ../lib/$(DEPDIR)/$(am__dirstamp) +../lib/str/ahost-ares_strcasecmp.$(OBJEXT): \ + ../lib/str/$(am__dirstamp) \ + ../lib/str/$(DEPDIR)/$(am__dirstamp) ahost$(EXEEXT): $(ahost_OBJECTS) $(ahost_DEPENDENCIES) $(EXTRA_ahost_DEPENDENCIES) @rm -f ahost$(EXEEXT) @@ -470,13 +472,13 @@ ahost$(EXEEXT): $(ahost_OBJECTS) $(ahost_DEPENDENCIES) $(EXTRA_ahost_DEPENDENCIE mostlyclean-compile: -rm -f *.$(OBJEXT) - -rm -f ../lib/*.$(OBJEXT) + -rm -f ../lib/str/*.$(OBJEXT) distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@../lib/$(DEPDIR)/adig-ares_strcasecmp.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@../lib/$(DEPDIR)/ahost-ares_strcasecmp.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@../lib/str/$(DEPDIR)/adig-ares_strcasecmp.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@../lib/str/$(DEPDIR)/ahost-ares_strcasecmp.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/adig-adig.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/adig-ares_getopt.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ahost-ahost.Po@am__quote@ # am--include-marker @@ -484,7 +486,7 @@ distclean-compile: $(am__depfiles_remade): @$(MKDIR_P) $(@D) - @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + @: >>$@ am--depfiles: $(am__depfiles_remade) @@ -540,19 +542,19 @@ adig-ares_getopt.obj: ares_getopt.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(adig_CPPFLAGS) $(CPPFLAGS) $(adig_CFLAGS) $(CFLAGS) -c -o adig-ares_getopt.obj `if test -f 'ares_getopt.c'; then $(CYGPATH_W) 'ares_getopt.c'; else $(CYGPATH_W) '$(srcdir)/ares_getopt.c'; fi` -../lib/adig-ares_strcasecmp.o: ../lib/ares_strcasecmp.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(adig_CPPFLAGS) $(CPPFLAGS) $(adig_CFLAGS) $(CFLAGS) -MT ../lib/adig-ares_strcasecmp.o -MD -MP -MF ../lib/$(DEPDIR)/adig-ares_strcasecmp.Tpo -c -o ../lib/adig-ares_strcasecmp.o `test -f '../lib/ares_strcasecmp.c' || echo '$(srcdir)/'`../lib/ares_strcasecmp.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ../lib/$(DEPDIR)/adig-ares_strcasecmp.Tpo ../lib/$(DEPDIR)/adig-ares_strcasecmp.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../lib/ares_strcasecmp.c' object='../lib/adig-ares_strcasecmp.o' libtool=no @AMDEPBACKSLASH@ +../lib/str/adig-ares_strcasecmp.o: ../lib/str/ares_strcasecmp.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(adig_CPPFLAGS) $(CPPFLAGS) $(adig_CFLAGS) $(CFLAGS) -MT ../lib/str/adig-ares_strcasecmp.o -MD -MP -MF ../lib/str/$(DEPDIR)/adig-ares_strcasecmp.Tpo -c -o ../lib/str/adig-ares_strcasecmp.o `test -f '../lib/str/ares_strcasecmp.c' || echo '$(srcdir)/'`../lib/str/ares_strcasecmp.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ../lib/str/$(DEPDIR)/adig-ares_strcasecmp.Tpo ../lib/str/$(DEPDIR)/adig-ares_strcasecmp.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../lib/str/ares_strcasecmp.c' object='../lib/str/adig-ares_strcasecmp.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(adig_CPPFLAGS) $(CPPFLAGS) $(adig_CFLAGS) $(CFLAGS) -c -o ../lib/adig-ares_strcasecmp.o `test -f '../lib/ares_strcasecmp.c' || echo '$(srcdir)/'`../lib/ares_strcasecmp.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(adig_CPPFLAGS) $(CPPFLAGS) $(adig_CFLAGS) $(CFLAGS) -c -o ../lib/str/adig-ares_strcasecmp.o `test -f '../lib/str/ares_strcasecmp.c' || echo '$(srcdir)/'`../lib/str/ares_strcasecmp.c -../lib/adig-ares_strcasecmp.obj: ../lib/ares_strcasecmp.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(adig_CPPFLAGS) $(CPPFLAGS) $(adig_CFLAGS) $(CFLAGS) -MT ../lib/adig-ares_strcasecmp.obj -MD -MP -MF ../lib/$(DEPDIR)/adig-ares_strcasecmp.Tpo -c -o ../lib/adig-ares_strcasecmp.obj `if test -f '../lib/ares_strcasecmp.c'; then $(CYGPATH_W) '../lib/ares_strcasecmp.c'; else $(CYGPATH_W) '$(srcdir)/../lib/ares_strcasecmp.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ../lib/$(DEPDIR)/adig-ares_strcasecmp.Tpo ../lib/$(DEPDIR)/adig-ares_strcasecmp.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../lib/ares_strcasecmp.c' object='../lib/adig-ares_strcasecmp.obj' libtool=no @AMDEPBACKSLASH@ +../lib/str/adig-ares_strcasecmp.obj: ../lib/str/ares_strcasecmp.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(adig_CPPFLAGS) $(CPPFLAGS) $(adig_CFLAGS) $(CFLAGS) -MT ../lib/str/adig-ares_strcasecmp.obj -MD -MP -MF ../lib/str/$(DEPDIR)/adig-ares_strcasecmp.Tpo -c -o ../lib/str/adig-ares_strcasecmp.obj `if test -f '../lib/str/ares_strcasecmp.c'; then $(CYGPATH_W) '../lib/str/ares_strcasecmp.c'; else $(CYGPATH_W) '$(srcdir)/../lib/str/ares_strcasecmp.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ../lib/str/$(DEPDIR)/adig-ares_strcasecmp.Tpo ../lib/str/$(DEPDIR)/adig-ares_strcasecmp.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../lib/str/ares_strcasecmp.c' object='../lib/str/adig-ares_strcasecmp.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(adig_CPPFLAGS) $(CPPFLAGS) $(adig_CFLAGS) $(CFLAGS) -c -o ../lib/adig-ares_strcasecmp.obj `if test -f '../lib/ares_strcasecmp.c'; then $(CYGPATH_W) '../lib/ares_strcasecmp.c'; else $(CYGPATH_W) '$(srcdir)/../lib/ares_strcasecmp.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(adig_CPPFLAGS) $(CPPFLAGS) $(adig_CFLAGS) $(CFLAGS) -c -o ../lib/str/adig-ares_strcasecmp.obj `if test -f '../lib/str/ares_strcasecmp.c'; then $(CYGPATH_W) '../lib/str/ares_strcasecmp.c'; else $(CYGPATH_W) '$(srcdir)/../lib/str/ares_strcasecmp.c'; fi` ahost-ahost.o: ahost.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahost_CPPFLAGS) $(CPPFLAGS) $(ahost_CFLAGS) $(CFLAGS) -MT ahost-ahost.o -MD -MP -MF $(DEPDIR)/ahost-ahost.Tpo -c -o ahost-ahost.o `test -f 'ahost.c' || echo '$(srcdir)/'`ahost.c @@ -582,19 +584,19 @@ ahost-ares_getopt.obj: ares_getopt.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahost_CPPFLAGS) $(CPPFLAGS) $(ahost_CFLAGS) $(CFLAGS) -c -o ahost-ares_getopt.obj `if test -f 'ares_getopt.c'; then $(CYGPATH_W) 'ares_getopt.c'; else $(CYGPATH_W) '$(srcdir)/ares_getopt.c'; fi` -../lib/ahost-ares_strcasecmp.o: ../lib/ares_strcasecmp.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahost_CPPFLAGS) $(CPPFLAGS) $(ahost_CFLAGS) $(CFLAGS) -MT ../lib/ahost-ares_strcasecmp.o -MD -MP -MF ../lib/$(DEPDIR)/ahost-ares_strcasecmp.Tpo -c -o ../lib/ahost-ares_strcasecmp.o `test -f '../lib/ares_strcasecmp.c' || echo '$(srcdir)/'`../lib/ares_strcasecmp.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ../lib/$(DEPDIR)/ahost-ares_strcasecmp.Tpo ../lib/$(DEPDIR)/ahost-ares_strcasecmp.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../lib/ares_strcasecmp.c' object='../lib/ahost-ares_strcasecmp.o' libtool=no @AMDEPBACKSLASH@ +../lib/str/ahost-ares_strcasecmp.o: ../lib/str/ares_strcasecmp.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahost_CPPFLAGS) $(CPPFLAGS) $(ahost_CFLAGS) $(CFLAGS) -MT ../lib/str/ahost-ares_strcasecmp.o -MD -MP -MF ../lib/str/$(DEPDIR)/ahost-ares_strcasecmp.Tpo -c -o ../lib/str/ahost-ares_strcasecmp.o `test -f '../lib/str/ares_strcasecmp.c' || echo '$(srcdir)/'`../lib/str/ares_strcasecmp.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ../lib/str/$(DEPDIR)/ahost-ares_strcasecmp.Tpo ../lib/str/$(DEPDIR)/ahost-ares_strcasecmp.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../lib/str/ares_strcasecmp.c' object='../lib/str/ahost-ares_strcasecmp.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahost_CPPFLAGS) $(CPPFLAGS) $(ahost_CFLAGS) $(CFLAGS) -c -o ../lib/ahost-ares_strcasecmp.o `test -f '../lib/ares_strcasecmp.c' || echo '$(srcdir)/'`../lib/ares_strcasecmp.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahost_CPPFLAGS) $(CPPFLAGS) $(ahost_CFLAGS) $(CFLAGS) -c -o ../lib/str/ahost-ares_strcasecmp.o `test -f '../lib/str/ares_strcasecmp.c' || echo '$(srcdir)/'`../lib/str/ares_strcasecmp.c -../lib/ahost-ares_strcasecmp.obj: ../lib/ares_strcasecmp.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahost_CPPFLAGS) $(CPPFLAGS) $(ahost_CFLAGS) $(CFLAGS) -MT ../lib/ahost-ares_strcasecmp.obj -MD -MP -MF ../lib/$(DEPDIR)/ahost-ares_strcasecmp.Tpo -c -o ../lib/ahost-ares_strcasecmp.obj `if test -f '../lib/ares_strcasecmp.c'; then $(CYGPATH_W) '../lib/ares_strcasecmp.c'; else $(CYGPATH_W) '$(srcdir)/../lib/ares_strcasecmp.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ../lib/$(DEPDIR)/ahost-ares_strcasecmp.Tpo ../lib/$(DEPDIR)/ahost-ares_strcasecmp.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../lib/ares_strcasecmp.c' object='../lib/ahost-ares_strcasecmp.obj' libtool=no @AMDEPBACKSLASH@ +../lib/str/ahost-ares_strcasecmp.obj: ../lib/str/ares_strcasecmp.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahost_CPPFLAGS) $(CPPFLAGS) $(ahost_CFLAGS) $(CFLAGS) -MT ../lib/str/ahost-ares_strcasecmp.obj -MD -MP -MF ../lib/str/$(DEPDIR)/ahost-ares_strcasecmp.Tpo -c -o ../lib/str/ahost-ares_strcasecmp.obj `if test -f '../lib/str/ares_strcasecmp.c'; then $(CYGPATH_W) '../lib/str/ares_strcasecmp.c'; else $(CYGPATH_W) '$(srcdir)/../lib/str/ares_strcasecmp.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ../lib/str/$(DEPDIR)/ahost-ares_strcasecmp.Tpo ../lib/str/$(DEPDIR)/ahost-ares_strcasecmp.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../lib/str/ares_strcasecmp.c' object='../lib/str/ahost-ares_strcasecmp.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahost_CPPFLAGS) $(CPPFLAGS) $(ahost_CFLAGS) $(CFLAGS) -c -o ../lib/ahost-ares_strcasecmp.obj `if test -f '../lib/ares_strcasecmp.c'; then $(CYGPATH_W) '../lib/ares_strcasecmp.c'; else $(CYGPATH_W) '$(srcdir)/../lib/ares_strcasecmp.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahost_CPPFLAGS) $(CPPFLAGS) $(ahost_CFLAGS) $(CFLAGS) -c -o ../lib/str/ahost-ares_strcasecmp.obj `if test -f '../lib/str/ares_strcasecmp.c'; then $(CYGPATH_W) '../lib/str/ares_strcasecmp.c'; else $(CYGPATH_W) '$(srcdir)/../lib/str/ares_strcasecmp.c'; fi` mostlyclean-libtool: -rm -f *.lo @@ -714,10 +716,10 @@ mostlyclean-generic: clean-generic: distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -rm -f ../lib/$(DEPDIR)/$(am__dirstamp) - -rm -f ../lib/$(am__dirstamp) + -$(am__rm_f) $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || $(am__rm_f) $(CONFIG_CLEAN_VPATH_FILES) + -$(am__rm_f) ../lib/str/$(DEPDIR)/$(am__dirstamp) + -$(am__rm_f) ../lib/str/$(am__dirstamp) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @@ -728,8 +730,8 @@ clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ mostlyclean-am distclean: distclean-am - -rm -f ../lib/$(DEPDIR)/adig-ares_strcasecmp.Po - -rm -f ../lib/$(DEPDIR)/ahost-ares_strcasecmp.Po + -rm -f ../lib/str/$(DEPDIR)/adig-ares_strcasecmp.Po + -rm -f ../lib/str/$(DEPDIR)/ahost-ares_strcasecmp.Po -rm -f ./$(DEPDIR)/adig-adig.Po -rm -f ./$(DEPDIR)/adig-ares_getopt.Po -rm -f ./$(DEPDIR)/ahost-ahost.Po @@ -779,8 +781,8 @@ install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am - -rm -f ../lib/$(DEPDIR)/adig-ares_strcasecmp.Po - -rm -f ../lib/$(DEPDIR)/ahost-ares_strcasecmp.Po + -rm -f ../lib/str/$(DEPDIR)/adig-ares_strcasecmp.Po + -rm -f ../lib/str/$(DEPDIR)/ahost-ares_strcasecmp.Po -rm -f ./$(DEPDIR)/adig-adig.Po -rm -f ./$(DEPDIR)/adig-ares_getopt.Po -rm -f ./$(DEPDIR)/ahost-ahost.Po @@ -825,3 +827,10 @@ uninstall-am: # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: + +# Tell GNU make to disable its built-in pattern rules. +%:: %,v +%:: RCS/%,v +%:: RCS/% +%:: s.% +%:: SCCS/s.% diff --git a/lib/c-ares-1.32.3/src/tools/Makefile.inc b/lib/c-ares-1.33.1/src/tools/Makefile.inc similarity index 71% rename from lib/c-ares-1.32.3/src/tools/Makefile.inc rename to lib/c-ares-1.33.1/src/tools/Makefile.inc index dd081b3005d..4c6b6aaa978 100644 --- a/lib/c-ares-1.32.3/src/tools/Makefile.inc +++ b/lib/c-ares-1.33.1/src/tools/Makefile.inc @@ -1,7 +1,7 @@ # Copyright (C) The c-ares project and its contributors # SPDX-License-Identifier: MIT SAMPLESOURCES = ares_getopt.c \ - ../lib/ares_strcasecmp.c + ../lib/str/ares_strcasecmp.c SAMPLEHEADERS = ares_getopt.h \ - ../lib/ares_strcasecmp.h + ../lib/str/ares_strcasecmp.h diff --git a/lib/c-ares-1.32.3/src/tools/adig.c b/lib/c-ares-1.33.1/src/tools/adig.c similarity index 90% rename from lib/c-ares-1.32.3/src/tools/adig.c rename to lib/c-ares-1.33.1/src/tools/adig.c index 026340c72bf..8b2ad2e96a6 100644 --- a/lib/c-ares-1.32.3/src/tools/adig.c +++ b/lib/c-ares-1.33.1/src/tools/adig.c @@ -46,17 +46,17 @@ #include "ares_dns.h" #ifndef HAVE_STRDUP -# include "ares_str.h" +# include "str/ares_str.h" # define strdup(ptr) ares_strdup(ptr) #endif #ifndef HAVE_STRCASECMP -# include "ares_strcasecmp.h" +# include "str/ares_strcasecmp.h" # define strcasecmp(p1, p2) ares_strcasecmp(p1, p2) #endif #ifndef HAVE_STRNCASECMP -# include "ares_strcasecmp.h" +# include "str/ares_strcasecmp.h" # define strncasecmp(p1, p2, n) ares_strncasecmp(p1, p2, n) #endif @@ -120,35 +120,30 @@ static void print_help(void) printf( "usage: adig [-h] [-d] [-f flag] [[-s server] ...] [-T|U port] [-c class]\n" " [-t type] name ...\n\n"); + printf(" -h : Display this help and exit.\n"); + printf(" -d : Print some extra debugging output.\n"); printf( - " -h : Display this help and exit.\n"); - printf( - " -d : Print some extra debugging output.\n"); - printf( - " -f flag : Add a behavior control flag. May be specified more than once\n" + " -f flag : Add a behavior control flag. May be specified more than " + "once\n" " to add additional flags. Possible values are:\n" " igntc - do not retry a truncated query as TCP, just\n" " return the truncated answer\n" " noaliases - don't honor the HOSTALIASES environment\n" " variable\n"); - printf( - " norecurse - don't query upstream servers recursively\n" - " primary - use the first server\n" - " stayopen - don't close the communication sockets\n" - " usevc - use TCP only\n" - " edns - use EDNS\n" - " dns0x20 - enable DNS 0x20 support\n"); + printf(" norecurse - don't query upstream servers recursively\n" + " primary - use the first server\n" + " stayopen - don't close the communication sockets\n" + " usevc - use TCP only\n" + " edns - use EDNS\n" + " dns0x20 - enable DNS 0x20 support\n"); printf( " -s server : Connect to the specified DNS server, instead of the\n" " system's default one(s). Servers are tried in round-robin,\n" " if the previous one failed.\n"); - printf( - " -T port : Connect to the specified TCP port of DNS server.\n"); - printf( - " -U port : Connect to the specified UDP port of DNS server.\n"); - printf( - " -c class : Set the query class. Possible values for class are:\n" - " ANY, CHAOS, HS and IN (default)\n"); + printf(" -T port : Connect to the specified TCP port of DNS server.\n"); + printf(" -U port : Connect to the specified UDP port of DNS server.\n"); + printf(" -c class : Set the query class. Possible values for class are:\n" + " ANY, CHAOS, HS and IN (default)\n"); printf( " -t type : Query records of the specified type. Possible values for\n" " type are:\n" @@ -156,7 +151,7 @@ static void print_help(void) " SOA, SRV, TXT, TLSA, URI, CAA, SVCB, HTTPS\n\n"); } -static ares_bool_t read_cmdline(int argc, const char * const * argv, +static ares_bool_t read_cmdline(int argc, const char * const *argv, adig_config_t *config) { ares_getopt_state_t state; @@ -219,26 +214,35 @@ static ares_bool_t read_cmdline(int argc, const char * const * argv, break; case 'T': - /* Set the TCP port number. */ - if (!isdigit(*state.optarg)) { - snprintf(config->error, sizeof(config->error), "invalid port number"); - return ARES_FALSE; + { + /* Set the TCP port number. */ + long port = strtol(state.optarg, NULL, 0); + + if (port <= 0 || port > 65535) { + snprintf(config->error, sizeof(config->error), + "invalid port number"); + return ARES_FALSE; + } + config->options.tcp_port = (unsigned short)port; + config->options.flags |= ARES_FLAG_USEVC; + config->optmask |= ARES_OPT_TCP_PORT; } - config->options.tcp_port = - (unsigned short)strtol(state.optarg, NULL, 0); - config->options.flags |= ARES_FLAG_USEVC; - config->optmask |= ARES_OPT_TCP_PORT; break; case 'U': - /* Set the UDP port number. */ - if (!isdigit(*state.optarg)) { - snprintf(config->error, sizeof(config->error), "invalid port number"); - return ARES_FALSE; + { + /* Set the TCP port number. */ + long port = strtol(state.optarg, NULL, 0); + + if (port <= 0 || port > 65535) { + snprintf(config->error, sizeof(config->error), + "invalid port number"); + return ARES_FALSE; + } + config->options.udp_port = (unsigned short)port; + config->options.flags |= ARES_FLAG_USEVC; + config->optmask |= ARES_OPT_UDP_PORT; } - config->options.udp_port = - (unsigned short)strtol(state.optarg, NULL, 0); - config->optmask |= ARES_OPT_UDP_PORT; break; case ':': @@ -630,10 +634,10 @@ static void print_binp(const ares_dns_rr_t *rr, ares_dns_rr_key_t key) static void print_abinp(const ares_dns_rr_t *rr, ares_dns_rr_key_t key) { - size_t i; - size_t cnt = ares_dns_rr_get_abin_cnt(rr, key); + size_t i; + size_t cnt = ares_dns_rr_get_abin_cnt(rr, key); - for (i=0; iopterr = 1; diff --git a/lib/c-ares-1.32.3/src/tools/ares_getopt.h b/lib/c-ares-1.33.1/src/tools/ares_getopt.h similarity index 80% rename from lib/c-ares-1.32.3/src/tools/ares_getopt.h rename to lib/c-ares-1.33.1/src/tools/ares_getopt.h index 7ff1fdeeb28..a8007b2dee0 100644 --- a/lib/c-ares-1.32.3/src/tools/ares_getopt.h +++ b/lib/c-ares-1.33.1/src/tools/ares_getopt.h @@ -34,16 +34,17 @@ typedef struct { - const char *optarg; /* argument associated with option */ - int optind; /* index into parent argv vector */ - int opterr; /* if error message should be printed */ - int optopt; /* character checked for validity */ - const char *place; - int argc; + const char *optarg; /* argument associated with option */ + int optind; /* index into parent argv vector */ + int opterr; /* if error message should be printed */ + int optopt; /* character checked for validity */ + const char *place; + int argc; const char * const *argv; } ares_getopt_state_t; -void ares_getopt_init(ares_getopt_state_t *state, int argc, const char * const * argv); +void ares_getopt_init(ares_getopt_state_t *state, int argc, + const char * const *argv); int ares_getopt(ares_getopt_state_t *state, const char *ostr); #endif /* ARES_GETOPT_H */ diff --git a/lib/c-ares-1.32.3/test/CMakeLists.txt b/lib/c-ares-1.33.1/test/CMakeLists.txt similarity index 80% rename from lib/c-ares-1.32.3/test/CMakeLists.txt rename to lib/c-ares-1.33.1/test/CMakeLists.txt index e397d6e1b9e..8bed6018442 100644 --- a/lib/c-ares-1.32.3/test/CMakeLists.txt +++ b/lib/c-ares-1.33.1/test/CMakeLists.txt @@ -9,8 +9,12 @@ ENDIF () find_package(Threads) find_package(GTest REQUIRED) -IF (NOT TARGET GTest::gmock) - Message(FATAL_ERROR "GoogleTest found but the GMock component was not found") +IF (CMAKE_VERSION VERSION_LESS "3.23.0") + Message("GoogleTest found, cmake version too old to verify GMock, look for errors...") +ELSE () + IF (NOT TARGET GTest::gmock) + Message(FATAL_ERROR "GoogleTest found but the GMock component was not found") + ENDIF() ENDIF() # create target to access and use internal cares library @@ -36,8 +40,15 @@ include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake) add_executable(arestest ${TESTSOURCES} ${TESTHEADERS}) target_include_directories(arestest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) -target_link_libraries(arestest PRIVATE caresinternal GTest::gmock) - +IF (CMAKE_VERSION VERSION_LESS "3.23.0") + FIND_LIBRARY(LIBGMOCK NAMES gmock PATHS ${GTEST_ROOT} PATH_SUFFIXES lib) + IF (LIBGMOCK-NOTFOUND) + MESSAGE(FATAL_ERROR "Could not find Gmock") + ENDIF () + target_link_libraries(arestest PRIVATE caresinternal GTest::GTest ${LIBGMOCK}) +ELSE () + target_link_libraries(arestest PRIVATE caresinternal GTest::gmock) +ENDIF() target_compile_definitions(arestest PRIVATE CARES_NO_DEPRECATED) IF (CARES_BUILD_CONTAINER_TESTS) diff --git a/lib/c-ares-1.32.3/test/Makefile.am b/lib/c-ares-1.33.1/test/Makefile.am similarity index 100% rename from lib/c-ares-1.32.3/test/Makefile.am rename to lib/c-ares-1.33.1/test/Makefile.am diff --git a/lib/c-ares-1.32.3/test/Makefile.in b/lib/c-ares-1.33.1/test/Makefile.in similarity index 97% rename from lib/c-ares-1.32.3/test/Makefile.in rename to lib/c-ares-1.33.1/test/Makefile.in index d04094a43b1..9a7d9df432c 100644 --- a/lib/c-ares-1.32.3/test/Makefile.in +++ b/lib/c-ares-1.33.1/test/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.5 from Makefile.am. +# Makefile.in generated by automake 1.17 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2021 Free Software Foundation, Inc. +# Copyright (C) 1994-2024 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -70,6 +70,8 @@ am__make_running_with_option = \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +am__rm_f = rm -f $(am__rm_f_notfound) +am__rm_rf = rm -rf $(am__rm_f_notfound) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -333,10 +335,9 @@ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ + { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && echo $$files | $(am__xargs_n) 40 $(am__rm_f); }; \ } am__recheck_rx = ^[ ]*:recheck:[ ]* am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* @@ -424,6 +425,7 @@ am__sh_e_setup = case $$- in *e*) set +e;; esac # Default flags passed to test drivers. am__common_driver_flags = \ --color-tests "$$am__color_tests" \ + $$am__collect_skipped_logs \ --enable-hard-errors "$$am__enable_hard_errors" \ --expect-failure "$$am__expect_failure" # To be inserted before the command running the test. Creates the @@ -448,6 +450,11 @@ if test -f "./$$f"; then dir=./; \ elif test -f "$$f"; then dir=; \ else dir="$(srcdir)/"; fi; \ tst=$$dir$$f; log='$@'; \ +if test -n '$(IGNORE_SKIPPED_LOGS)'; then \ + am__collect_skipped_logs='--collect-skipped-logs no'; \ +else \ + am__collect_skipped_logs=''; \ +fi; \ if test -n '$(DISABLE_HARD_ERRORS)'; then \ am__enable_hard_errors=no; \ else \ @@ -549,6 +556,8 @@ FGREP = @FGREP@ FILECMD = @FILECMD@ GCOV = @GCOV@ GENHTML = @GENHTML@ +GMOCK112_CFLAGS = @GMOCK112_CFLAGS@ +GMOCK112_LIBS = @GMOCK112_LIBS@ GMOCK_CFLAGS = @GMOCK_CFLAGS@ GMOCK_LIBS = @GMOCK_LIBS@ GREP = @GREP@ @@ -611,8 +620,10 @@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ +am__rm_f_notfound = @am__rm_f_notfound@ am__tar = @am__tar@ am__untar = @am__untar@ +am__xargs_n = @am__xargs_n@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ @@ -755,13 +766,8 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) $(am__aclocal_m4_deps): clean-noinstPROGRAMS: - @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list + $(am__rm_f) $(noinst_PROGRAMS) + test -z "$(EXEEXT)" || $(am__rm_f) $(noinst_PROGRAMS:$(EXEEXT)=) ares_queryloop$(EXEEXT): $(ares_queryloop_OBJECTS) $(ares_queryloop_DEPENDENCIES) $(EXTRA_ares_queryloop_DEPENDENCIES) @rm -f ares_queryloop$(EXEEXT) @@ -823,7 +829,7 @@ distclean-compile: $(am__depfiles_remade): @$(MKDIR_P) $(@D) - @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + @: >>$@ am--depfiles: $(am__depfiles_remade) @@ -1296,7 +1302,6 @@ distclean-tags: am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) am--force-recheck: @: - $(TEST_SUITE_LOG): $(TEST_LOGS) @$(am__set_TESTS_bases); \ am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ @@ -1372,10 +1377,37 @@ $(TEST_SUITE_LOG): $(TEST_LOGS) result_count $$1 "XPASS:" $$xpass "$$red"; \ result_count $$1 "ERROR:" $$error "$$mgn"; \ }; \ + output_system_information () \ + { \ + echo; \ + { uname -a | $(AWK) '{ \ + printf "System information (uname -a):"; \ + for (i = 1; i < NF; ++i) \ + { \ + if (i != 2) \ + printf " %s", $$i; \ + } \ + printf "\n"; \ +}'; } 2>&1; \ + if test -r /etc/os-release; then \ + echo "Distribution information (/etc/os-release):"; \ + sed 8q /etc/os-release; \ + elif test -r /etc/issue; then \ + echo "Distribution information (/etc/issue):"; \ + cat /etc/issue; \ + fi; \ + }; \ + please_report () \ + { \ +echo "Some test(s) failed. Please report this to $(PACKAGE_BUGREPORT),"; \ +echo "together with the test-suite.log file (gzipped) and your system"; \ +echo "information. Thanks."; \ + }; \ { \ echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ $(am__rst_title); \ create_testsuite_report --no-color; \ + output_system_information; \ echo; \ echo ".. contents:: :depth: 2"; \ echo; \ @@ -1395,26 +1427,25 @@ $(TEST_SUITE_LOG): $(TEST_LOGS) create_testsuite_report --maybe-color; \ echo "$$col$$br$$std"; \ if $$success; then :; else \ - echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ + echo "$${col}See $(subdir)/$(TEST_SUITE_LOG) for debugging.$${std}";\ if test -n "$(PACKAGE_BUGREPORT)"; then \ - echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ + please_report | sed -e "s/^/$${col}/" -e s/'$$'/"$${std}"/; \ fi; \ echo "$$col$$br$$std"; \ fi; \ $$success || exit 1 check-TESTS: - @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list - @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @$(am__rm_f) $(RECHECK_LOGS) + @$(am__rm_f) $(RECHECK_LOGS:.log=.trs) + @$(am__rm_f) $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ log_list=`for i in $$bases; do echo $$i.log; done`; \ - trs_list=`for i in $$bases; do echo $$i.trs; done`; \ - log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ + log_list=`echo $$log_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ exit $$?; recheck: all - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @$(am__rm_f) $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ bases=`for i in $$bases; do echo $$i; done \ | $(am__list_recheck_tests)` || exit 1; \ @@ -1510,15 +1541,15 @@ install-strip: "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: - -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) - -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) - -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + -$(am__rm_f) $(TEST_LOGS) + -$(am__rm_f) $(TEST_LOGS:.log=.trs) + -$(am__rm_f) $(TEST_SUITE_LOG) clean-generic: distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -$(am__rm_f) $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || $(am__rm_f) $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @@ -1529,7 +1560,7 @@ clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ mostlyclean-am distclean: distclean-am - -rm -f ./$(DEPDIR)/ares-fuzz.Po + -rm -f ./$(DEPDIR)/ares-fuzz.Po -rm -f ./$(DEPDIR)/ares-test-fuzz-name.Po -rm -f ./$(DEPDIR)/ares-test-fuzz.Po -rm -f ./$(DEPDIR)/ares_queryloop.Po @@ -1605,7 +1636,7 @@ install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am - -rm -f ./$(DEPDIR)/ares-fuzz.Po + -rm -f ./$(DEPDIR)/ares-fuzz.Po -rm -f ./$(DEPDIR)/ares-test-fuzz-name.Po -rm -f ./$(DEPDIR)/ares-test-fuzz.Po -rm -f ./$(DEPDIR)/ares_queryloop.Po @@ -1679,3 +1710,10 @@ test: check # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: + +# Tell GNU make to disable its built-in pattern rules. +%:: %,v +%:: RCS/%,v +%:: RCS/% +%:: s.% +%:: SCCS/s.% diff --git a/lib/c-ares-1.32.3/test/Makefile.inc b/lib/c-ares-1.33.1/test/Makefile.inc similarity index 100% rename from lib/c-ares-1.32.3/test/Makefile.inc rename to lib/c-ares-1.33.1/test/Makefile.inc diff --git a/lib/c-ares-1.32.3/test/Makefile.m32 b/lib/c-ares-1.33.1/test/Makefile.m32 similarity index 100% rename from lib/c-ares-1.32.3/test/Makefile.m32 rename to lib/c-ares-1.33.1/test/Makefile.m32 diff --git a/lib/c-ares-1.32.3/test/Makefile.msvc b/lib/c-ares-1.33.1/test/Makefile.msvc similarity index 92% rename from lib/c-ares-1.32.3/test/Makefile.msvc rename to lib/c-ares-1.33.1/test/Makefile.msvc index bb2648c246a..9c81b6c17b1 100644 --- a/lib/c-ares-1.32.3/test/Makefile.msvc +++ b/lib/c-ares-1.33.1/test/Makefile.msvc @@ -62,11 +62,6 @@ RTLIB = /MT RTLIBD = /MTd !ENDIF -# -------------------------------------------------------- -# Detect compiler version. -# -------------------------------------------------------- -!INCLUDE ..\msvc_ver.inc - # --------------------------------------------------------- # Verify that current subdir is below the c-ares source one # --------------------------------------------------------- @@ -148,30 +143,13 @@ CFLAGS = /DWIN32 EX_LIBS_REL = ws2_32.lib advapi32.lib kernel32.lib iphlpapi.lib EX_LIBS_DBG = ws2_32.lib advapi32.lib kernel32.lib iphlpapi.lib -# ------------------------------------------------- -# Switches that depend on ancient compiler versions -# ------------------------------------------------- - -!IF $(CC_VERS_NUM) == 60 -PDB_NONE = /pdb:none -PDBTYPE_CONSOLIDATE = /pdbtype:consolidate -!ELSE -!UNDEF PDB_NONE -!UNDEF PDBTYPE_CONSOLIDATE -!ENDIF - -!IF $(CC_VERS_NUM) <= 70 -RT_ERROR_CHECKING = /GZ -!ELSE -RT_ERROR_CHECKING = /RTCsu -!ENDIF # ---------------------------- # Assorted commands and flags # ---------------------------- CC_CMD_REL = cl.exe /nologo $(RTLIB) /DNDEBUG /O2 /D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS -CC_CMD_DBG = cl.exe /nologo $(RTLIBD) /D_DEBUG /Od /Zi /D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS $(RT_ERROR_CHECKING) +CC_CMD_DBG = cl.exe /nologo $(RTLIBD) /D_DEBUG /Od /Zi /D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /RTCsu CC_CFLAGS = $(CFLAGS) /I. /I../src/lib /I../include /I $(GTEST_ROOT)/include /W3 /EHsc /FD RC_CMD_REL = rc.exe /l 0x409 /d "NDEBUG" @@ -181,8 +159,8 @@ LINK_CMD_LIB = link.exe /lib /nologo LINK_CMD_DLL = link.exe /dll /nologo /incremental:no /fixed:no LINK_CMD_EXE = link.exe /nologo /incremental:no /fixed:no /subsystem:console -LINK_CMD_EXE_REL = $(LINK_CMD_EXE) /release $(PDB_NONE) -LINK_CMD_EXE_DBG = $(LINK_CMD_EXE) /debug $(PDBTYPE_CONSOLIDATE) +LINK_CMD_EXE_REL = $(LINK_CMD_EXE) /release +LINK_CMD_EXE_DBG = $(LINK_CMD_EXE) /debug # --------------------------------- # Configuration dependent settings @@ -213,7 +191,7 @@ CC_CMD = $(CC_CMD_DBG) !IF "$(CFG)" == "dll-release" CARES_TARGET = $(DYN_LIB_REL).dll CARES_CFLAGS = /DCARES_BUILDING_LIBRARY -CARES_LFLAGS = /release $(EX_LIBS_REL) /implib:$(PROG_OUTDIR)\$(IMP_LIB_REL).lib $(PDB_NONE) +CARES_LFLAGS = /release $(EX_LIBS_REL) /implib:$(PROG_OUTDIR)\$(IMP_LIB_REL).lib SPROG_CFLAGS = /DCARES_NO_DEPRECATED SPROG_LFLAGS = /libpath:$(LIB_OUTDIR) $(EX_LIBS_REL) $(IMP_LIB_REL).lib CARES_LINK = $(LINK_CMD_DLL) @@ -226,7 +204,7 @@ RC_CMD = $(RC_CMD_REL) !IF "$(CFG)" == "dll-debug" CARES_TARGET = $(DYN_LIB_DBG).dll CARES_CFLAGS = /DCARES_BUILDING_LIBRARY /DDEBUGBUILD -CARES_LFLAGS = /debug $(EX_LIBS_DBG) /implib:$(PROG_OUTDIR)\$(IMP_LIB_DBG).lib /pdb:$(PROG_OUTDIR)\$(DYN_LIB_DBG).pdb $(PDBTYPE_CONSOLIDATE) +CARES_LFLAGS = /debug $(EX_LIBS_DBG) /implib:$(PROG_OUTDIR)\$(IMP_LIB_DBG).lib /pdb:$(PROG_OUTDIR)\$(DYN_LIB_DBG).pdb SPROG_CFLAGS = /DCARES_NO_DEPRECATED SPROG_LFLAGS = /libpath:$(LIB_OUTDIR) $(EX_LIBS_DBG) $(IMP_LIB_DBG).lib CARES_LINK = $(LINK_CMD_DLL) diff --git a/lib/c-ares-1.32.3/test/README.md b/lib/c-ares-1.33.1/test/README.md similarity index 100% rename from lib/c-ares-1.32.3/test/README.md rename to lib/c-ares-1.33.1/test/README.md diff --git a/lib/c-ares-1.32.3/test/ares-fuzz.c b/lib/c-ares-1.33.1/test/ares-fuzz.c similarity index 100% rename from lib/c-ares-1.32.3/test/ares-fuzz.c rename to lib/c-ares-1.33.1/test/ares-fuzz.c diff --git a/lib/c-ares-1.32.3/test/ares-test-ai.h b/lib/c-ares-1.33.1/test/ares-test-ai.h similarity index 97% rename from lib/c-ares-1.32.3/test/ares-test-ai.h rename to lib/c-ares-1.33.1/test/ares-test-ai.h index 95eeb885202..f127fae71ff 100644 --- a/lib/c-ares-1.32.3/test/ares-test-ai.h +++ b/lib/c-ares-1.33.1/test/ares-test-ai.h @@ -39,7 +39,7 @@ class MockChannelTestAI public ::testing::WithParamInterface> { public: MockChannelTestAI() - : MockChannelOptsTest(1, GetParam().first, GetParam().second, nullptr, 0) + : MockChannelOptsTest(1, GetParam().first, GetParam().second, false, nullptr, 0) { } }; @@ -47,7 +47,7 @@ class MockChannelTestAI class MockUDPChannelTestAI : public MockChannelOptsTest, public ::testing::WithParamInterface { public: - MockUDPChannelTestAI() : MockChannelOptsTest(1, GetParam(), false, nullptr, 0) + MockUDPChannelTestAI() : MockChannelOptsTest(1, GetParam(), false, false, nullptr, 0) { } }; @@ -55,7 +55,7 @@ class MockUDPChannelTestAI : public MockChannelOptsTest, class MockTCPChannelTestAI : public MockChannelOptsTest, public ::testing::WithParamInterface { public: - MockTCPChannelTestAI() : MockChannelOptsTest(1, GetParam(), true, nullptr, 0) + MockTCPChannelTestAI() : MockChannelOptsTest(1, GetParam(), true, false, nullptr, 0) { } }; diff --git a/lib/c-ares-1.32.3/test/ares-test-fuzz-name.c b/lib/c-ares-1.33.1/test/ares-test-fuzz-name.c similarity index 100% rename from lib/c-ares-1.32.3/test/ares-test-fuzz-name.c rename to lib/c-ares-1.33.1/test/ares-test-fuzz-name.c diff --git a/lib/c-ares-1.32.3/test/ares-test-fuzz.c b/lib/c-ares-1.33.1/test/ares-test-fuzz.c similarity index 100% rename from lib/c-ares-1.32.3/test/ares-test-fuzz.c rename to lib/c-ares-1.33.1/test/ares-test-fuzz.c diff --git a/lib/c-ares-1.32.3/test/ares-test-init.cc b/lib/c-ares-1.33.1/test/ares-test-init.cc similarity index 98% rename from lib/c-ares-1.32.3/test/ares-test-init.cc rename to lib/c-ares-1.33.1/test/ares-test-init.cc index 4fd5cff613a..453848f3ba2 100644 --- a/lib/c-ares-1.32.3/test/ares-test-init.cc +++ b/lib/c-ares-1.33.1/test/ares-test-init.cc @@ -417,7 +417,8 @@ CONTAINED_TEST_F(LibraryTest, ContainerChannelInit, CONTAINED_TEST_F(LibraryTest, ContainerSortlistOptionInit, "myhostname", "mydomainname.org", filelist) { ares_channel_t *channel = nullptr; - struct ares_options opts = {0}; + struct ares_options opts; + memset(&opts, 0, sizeof(opts)); int optmask = 0; optmask |= ARES_OPT_SORTLIST; opts.nsort = 0; @@ -461,7 +462,8 @@ CONTAINED_TEST_F(LibraryTest, ContainerMyResolvConfInit, "myhostname", "mydomain.org", myresolvconf) { char filename[] = "/tmp/myresolv.cnf"; ares_channel_t *channel = nullptr; - struct ares_options options = {0}; + struct ares_options options; + memset(&options, 0, sizeof(options)); options.resolvconf_path = strdup(filename); int optmask = ARES_OPT_RESOLVCONF; EXPECT_EQ(ARES_SUCCESS, ares_init_options(&channel, &options, optmask)); @@ -487,11 +489,12 @@ CONTAINED_TEST_F(LibraryTest, ContainerMyHostsInit, "myhostname", "mydomain.org", myhosts) { char filename[] = "/tmp/hosts"; ares_channel_t *channel = nullptr; - struct ares_options options = {0}; + struct ares_options options; + options.hosts_path = strdup(filename); int optmask = ARES_OPT_HOSTS_FILE; EXPECT_EQ(ARES_SUCCESS, ares_init_options(&channel, &options, optmask)); - + memset(&options, 0, sizeof(options)); optmask = 0; free(options.hosts_path); options.hosts_path = NULL; @@ -595,7 +598,8 @@ CONTAINED_TEST_F(LibraryTest, ContainerRotateInit, CONTAINED_TEST_F(LibraryTest, ContainerRotateOverride, "myhostname", "mydomainname.org", rotateenv) { ares_channel_t *channel = nullptr; - struct ares_options opts = {0}; + struct ares_options opts; + memset(&opts, 0, sizeof(opts)); int optmask = ARES_OPT_NOROTATE; EXPECT_EQ(ARES_SUCCESS, ares_init_options(&channel, &opts, optmask)); optmask = 0; @@ -687,7 +691,8 @@ CONTAINED_TEST_F(LibraryTest, ContainerEmptyInit, CONTAINED_TEST_F(LibraryTest, ContainerNoDfltSvrEmptyInit, "myhostname", "mydomainname.org", empty) { ares_channel_t *channel = nullptr; - struct ares_options opts = {0}; + struct ares_options opts; + memset(&opts, 0, sizeof(opts)); int optmask = ARES_OPT_FLAGS; opts.flags = ARES_FLAG_NO_DFLT_SVR; EXPECT_EQ(ARES_ENOSERVER, ares_init_options(&channel, &opts, optmask)); @@ -700,7 +705,8 @@ CONTAINED_TEST_F(LibraryTest, ContainerNoDfltSvrEmptyInit, CONTAINED_TEST_F(LibraryTest, ContainerNoDfltSvrFullInit, "myhostname", "mydomainname.org", filelist) { ares_channel_t *channel = nullptr; - struct ares_options opts = {0}; + struct ares_options opts; + memset(&opts, 0, sizeof(opts)); int optmask = ARES_OPT_FLAGS; opts.flags = ARES_FLAG_NO_DFLT_SVR; EXPECT_EQ(ARES_SUCCESS, ares_init_options(&channel, &opts, optmask)); diff --git a/lib/c-ares-1.32.3/test/ares-test-internal.cc b/lib/c-ares-1.33.1/test/ares-test-internal.cc similarity index 90% rename from lib/c-ares-1.32.3/test/ares-test-internal.cc rename to lib/c-ares-1.33.1/test/ares-test-internal.cc index 74b10d92c07..7539d093b7d 100644 --- a/lib/c-ares-1.32.3/test/ares-test-internal.cc +++ b/lib/c-ares-1.33.1/test/ares-test-internal.cc @@ -45,8 +45,8 @@ extern "C" { #include "ares_private.h" #include "ares_inet_net_pton.h" #include "ares_data.h" -#include "ares_strsplit.h" -#include "ares__htable.h" +#include "str/ares_strsplit.h" +#include "dsa/ares__htable.h" #ifdef HAVE_ARPA_INET_H #include @@ -783,10 +783,12 @@ TEST_F(LibraryTest, DNSRecord) { /* TODO */ break; case ARES_DATATYPE_BINP: - ares__buf_append_byte(printmsg, '"'); - size_t templen; - ares__buf_append_str(printmsg, (const char *)ares_dns_rr_get_bin(rr, keys[k], &templen)); - ares__buf_append_byte(printmsg, '"'); + { + ares__buf_append_byte(printmsg, '"'); + size_t templen; + ares__buf_append_str(printmsg, (const char *)ares_dns_rr_get_bin(rr, keys[k], &templen)); + ares__buf_append_byte(printmsg, '"'); + } break; case ARES_DATATYPE_ABINP: for (size_t a=0; aid = id; + m->buf = ares__buf_create(); + ares__buf_append_be32(m->buf, id); +} + +static void array_member_destroy(void *mb) +{ + array_member_t *m = (array_member_t *)mb; + ares__buf_destroy(m->buf); +} + +static int array_sort_cmp(const void *data1, const void *data2) +{ + const array_member_t *m1 = (const array_member_t *)data1; + const array_member_t *m2 = (const array_member_t *)data2; + if (m1->id > m2->id) + return 1; + if (m1->id < m2->id) + return -1; + return 0; +} + +TEST_F(LibraryTest, Array) { + ares__array_t *a = NULL; + array_member_t *m = NULL; + array_member_t mbuf; + unsigned int cnt = 0; + unsigned int removed = 0; + void *ptr = NULL; + size_t i; + + a = ares__array_create(sizeof(array_member_t), array_member_destroy); + EXPECT_NE(nullptr, a); + + /* Add 8 elements */ + for ( ; cnt < 8 ; cnt++) { + EXPECT_EQ(ARES_SUCCESS, ares__array_insert_last(&ptr, a)); + array_member_init(ptr, cnt+1); + } + + /* Verify count */ + EXPECT_EQ(cnt, ares__array_len(a)); + + /* Remove the first 2 elements */ + EXPECT_EQ(ARES_SUCCESS, ares__array_remove_first(a)); + EXPECT_EQ(ARES_SUCCESS, ares__array_remove_first(a)); + removed += 2; + + /* Verify count */ + EXPECT_EQ(cnt-removed, ares__array_len(a)); + + /* Verify id of first element */ + m = (array_member_t *)ares__array_first(a); + EXPECT_NE(nullptr, m); + EXPECT_EQ(3, m->id); + + + /* Add 100 total elements, this should force a shift of memory at some + * to make sure moves are working */ + for ( ; cnt < 100 ; cnt++) { + EXPECT_EQ(ARES_SUCCESS, ares__array_insert_last(&ptr, a)); + array_member_init(ptr, cnt+1); + } + + /* Verify count */ + EXPECT_EQ(cnt-removed, ares__array_len(a)); + + /* Remove 2 from the end */ + EXPECT_EQ(ARES_SUCCESS, ares__array_remove_last(a)); + EXPECT_EQ(ARES_SUCCESS, ares__array_remove_last(a)); + removed += 2; + + /* Verify count */ + EXPECT_EQ(cnt-removed, ares__array_len(a)); + + /* Verify expected id of last member */ + m = (array_member_t *)ares__array_last(a); + EXPECT_NE(nullptr, m); + EXPECT_EQ(cnt-2, m->id); + + /* Remove 3 middle members */ + EXPECT_EQ(ARES_SUCCESS, ares__array_remove_at(a, ares__array_len(a)/2)); + EXPECT_EQ(ARES_SUCCESS, ares__array_remove_at(a, ares__array_len(a)/2)); + EXPECT_EQ(ARES_SUCCESS, ares__array_remove_at(a, ares__array_len(a)/2)); + removed += 3; + + /* Verify count */ + EXPECT_EQ(cnt-removed, ares__array_len(a)); + + /* Claim a middle member then re-add it at the same position */ + i = ares__array_len(a) / 2; + EXPECT_EQ(ARES_SUCCESS, ares__array_claim_at(&mbuf, sizeof(mbuf), a, i)); + EXPECT_EQ(ARES_SUCCESS, ares__array_insert_at(&ptr, a, i)); + array_member_init(ptr, mbuf.id); + array_member_destroy((void *)&mbuf); + /* Verify count */ + EXPECT_EQ(cnt-removed, ares__array_len(a)); + + /* Iterate across the array, make sure each entry is greater than the last and + * the data in the buffer matches the id in the array */ + unsigned int last_id = 0; + for (i=0; iid, last_id); + last_id = m->id; + + unsigned int bufval = 0; + ares__buf_tag(m->buf); + EXPECT_EQ(ARES_SUCCESS, ares__buf_fetch_be32(m->buf, &bufval)); + ares__buf_tag_rollback(m->buf); + EXPECT_EQ(bufval, m->id); + } + + /* add a new element in the middle to the beginning with a high id */ + EXPECT_EQ(ARES_SUCCESS, ares__array_insert_at(&ptr, a, ares__array_len(a)/2)); + array_member_init(ptr, 100000); + + /* Sort the array */ + EXPECT_EQ(ARES_SUCCESS, ares__array_sort(a, array_sort_cmp)); + + /* Iterate across the array, make sure each entry is greater than the last and + * the data in the buffer matches the id in the array */ + last_id = 0; + for (i=0; iid, last_id); + last_id = m->id; + + unsigned int bufval = 0; + ares__buf_tag(m->buf); + EXPECT_EQ(ARES_SUCCESS, ares__buf_fetch_be32(m->buf, &bufval)); + ares__buf_tag_rollback(m->buf); + EXPECT_EQ(bufval, m->id); + } + + ares__array_destroy(a); +} TEST_F(LibraryTest, HtableVpvp) { ares__llist_t *l = NULL; diff --git a/lib/c-ares-1.32.3/test/ares-test-live.cc b/lib/c-ares-1.33.1/test/ares-test-live.cc similarity index 100% rename from lib/c-ares-1.32.3/test/ares-test-live.cc rename to lib/c-ares-1.33.1/test/ares-test-live.cc diff --git a/lib/c-ares-1.32.3/test/ares-test-main.cc b/lib/c-ares-1.33.1/test/ares-test-main.cc similarity index 100% rename from lib/c-ares-1.32.3/test/ares-test-main.cc rename to lib/c-ares-1.33.1/test/ares-test-main.cc diff --git a/lib/c-ares-1.32.3/test/ares-test-misc.cc b/lib/c-ares-1.33.1/test/ares-test-misc.cc similarity index 99% rename from lib/c-ares-1.32.3/test/ares-test-misc.cc rename to lib/c-ares-1.33.1/test/ares-test-misc.cc index 5d5641a90a3..5e912aa72c4 100644 --- a/lib/c-ares-1.32.3/test/ares-test-misc.cc +++ b/lib/c-ares-1.33.1/test/ares-test-misc.cc @@ -519,7 +519,7 @@ TEST_F(LibraryTest, CreateEDNSQuery) { std::string actual = PacketToString(data); DNSPacket pkt; pkt.set_qid(0x1234).add_question(new DNSQuestion("example.com", T_A)) - .add_additional(new DNSOptRR(0, 1280)); + .add_additional(new DNSOptRR(0, 0, 0, 1280, { }, { } /* No server cookie */, false)); std::string expected = PacketToString(pkt.data()); EXPECT_EQ(expected, actual); } diff --git a/lib/c-ares-1.32.3/test/ares-test-mock-ai.cc b/lib/c-ares-1.33.1/test/ares-test-mock-ai.cc similarity index 78% rename from lib/c-ares-1.32.3/test/ares-test-mock-ai.cc rename to lib/c-ares-1.33.1/test/ares-test-mock-ai.cc index c766d4a9017..b4a4f9926fe 100644 --- a/lib/c-ares-1.32.3/test/ares-test-mock-ai.cc +++ b/lib/c-ares-1.33.1/test/ares-test-mock-ai.cc @@ -266,7 +266,7 @@ class MockExtraOptsTestAI public ::testing::WithParamInterface< std::pair > { public: MockExtraOptsTestAI() - : MockChannelOptsTest(1, GetParam().first, GetParam().second, + : MockChannelOptsTest(1, GetParam().first, GetParam().second, false, FillOptions(&opts_), ARES_OPT_SOCK_SNDBUF|ARES_OPT_SOCK_RCVBUF) {} static struct ares_options* FillOptions(struct ares_options * opts) { @@ -311,7 +311,7 @@ class MockExtraOptsNDotsTestAI public ::testing::WithParamInterface< std::pair > { public: MockExtraOptsNDotsTestAI(int ndots) - : MockChannelOptsTest(1, GetParam().first, GetParam().second, + : MockChannelOptsTest(1, GetParam().first, GetParam().second, false, FillOptions(&opts_, ndots), ARES_OPT_SOCK_SNDBUF|ARES_OPT_SOCK_RCVBUF|ARES_OPT_NDOTS) {} static struct ares_options* FillOptions(struct ares_options * opts, int ndots) { @@ -404,12 +404,129 @@ TEST_P(MockExtraOptsNDots0TestAI, SimpleQuery) { EXPECT_EQ("{addr=[1.2.3.4]}", ss.str()); } + +// Issue #852, systemd-resolved returns SERVFAIL (and possibly REFUSED) on +// single label domains. We need to work around this by continuing to go +// to the next in the search list. See also +// https://github.com/systemd/systemd/issues/34101 +TEST_P(MockExtraOptsNDots0TestAI, SystemdServFail) { + DNSPacket rsp_ndots0; + rsp_ndots0.set_response().set_rcode(SERVFAIL) + .add_question(new DNSQuestion("ndots0", T_A)); + EXPECT_CALL(server_, OnRequest("ndots0", T_A)) + // Will call until it hits max retries + .WillRepeatedly(SetReply(&server_, &rsp_ndots0)); + + DNSPacket rsp_ndots0_first; + rsp_ndots0_first.set_response().set_aa() + .add_question(new DNSQuestion("ndots0.first.com", T_A)) + .add_answer(new DNSARR("ndots0.first.com", 100, {1, 2, 3, 4})); + EXPECT_CALL(server_, OnRequest("ndots0.first.com", T_A)) + .WillOnce(SetReply(&server_, &rsp_ndots0_first)); + + AddrInfoResult result; + struct ares_addrinfo_hints hints = {0, 0, 0, 0}; + hints.ai_family = AF_INET; + hints.ai_flags = ARES_AI_NOSORT; + ares_getaddrinfo(channel_, "ndots0", NULL, &hints, AddrInfoCallback, &result); + Process(); + EXPECT_TRUE(result.done_); + EXPECT_EQ(ARES_SUCCESS, result.status_); + std::stringstream ss; + ss << result.ai_; + EXPECT_EQ("{addr=[1.2.3.4]}", ss.str()); +} +TEST_P(MockExtraOptsNDots0TestAI, SystemdServFailSearch) { + DNSPacket rsp_ndots0; + rsp_ndots0.set_response().set_rcode(SERVFAIL) + .add_question(new DNSQuestion("ndots0", T_A)); + EXPECT_CALL(server_, OnRequest("ndots0", T_A)) + // Will call until it hits max retries + .WillRepeatedly(SetReply(&server_, &rsp_ndots0)); + + DNSPacket rsp_ndots0_first; + rsp_ndots0_first.set_response().set_aa() + .add_question(new DNSQuestion("ndots0.first.com", T_A)) + .add_answer(new DNSARR("ndots0.first.com", 100, {1, 2, 3, 4})); + EXPECT_CALL(server_, OnRequest("ndots0.first.com", T_A)) + .WillOnce(SetReply(&server_, &rsp_ndots0_first)); + + QueryResult result; + ares_dns_record_t *dnsrec = NULL; + ares_dns_record_create(&dnsrec, 0, ARES_FLAG_RD, ARES_OPCODE_QUERY, ARES_RCODE_NOERROR); + ares_dns_record_query_add(dnsrec, "ndots0", ARES_REC_TYPE_A, ARES_CLASS_IN); + ares_search_dnsrec(channel_, dnsrec, QueryCallback, &result); + ares_dns_record_destroy(dnsrec); + Process(); + EXPECT_TRUE(result.done_); + EXPECT_EQ(ARES_SUCCESS, result.status_); + + // QueryResult doesn't provide an easy way to retrieve the address, just ignore, + // success is probably good enough +} +TEST_P(MockExtraOptsNDots0TestAI, SystemdRefused) { + DNSPacket rsp_ndots0; + rsp_ndots0.set_response().set_rcode(REFUSED) + .add_question(new DNSQuestion("ndots0", T_A)); + EXPECT_CALL(server_, OnRequest("ndots0", T_A)) + // Will call until it hits max retries + .WillRepeatedly(SetReply(&server_, &rsp_ndots0)); + + DNSPacket rsp_ndots0_first; + rsp_ndots0_first.set_response().set_aa() + .add_question(new DNSQuestion("ndots0.first.com", T_A)) + .add_answer(new DNSARR("ndots0.first.com", 100, {1, 2, 3, 4})); + EXPECT_CALL(server_, OnRequest("ndots0.first.com", T_A)) + .WillOnce(SetReply(&server_, &rsp_ndots0_first)); + + AddrInfoResult result; + struct ares_addrinfo_hints hints = {0, 0, 0, 0}; + hints.ai_family = AF_INET; + hints.ai_flags = ARES_AI_NOSORT; + ares_getaddrinfo(channel_, "ndots0", NULL, &hints, AddrInfoCallback, &result); + Process(); + EXPECT_TRUE(result.done_); + EXPECT_EQ(ARES_SUCCESS, result.status_); + std::stringstream ss; + ss << result.ai_; + EXPECT_EQ("{addr=[1.2.3.4]}", ss.str()); +} +TEST_P(MockExtraOptsNDots0TestAI, SystemdRefusedSearch) { + DNSPacket rsp_ndots0; + rsp_ndots0.set_response().set_rcode(REFUSED) + .add_question(new DNSQuestion("ndots0", T_A)); + EXPECT_CALL(server_, OnRequest("ndots0", T_A)) + // Will call until it hits max retries + .WillRepeatedly(SetReply(&server_, &rsp_ndots0)); + + DNSPacket rsp_ndots0_first; + rsp_ndots0_first.set_response().set_aa() + .add_question(new DNSQuestion("ndots0.first.com", T_A)) + .add_answer(new DNSARR("ndots0.first.com", 100, {1, 2, 3, 4})); + EXPECT_CALL(server_, OnRequest("ndots0.first.com", T_A)) + .WillOnce(SetReply(&server_, &rsp_ndots0_first)); + + QueryResult result; + ares_dns_record_t *dnsrec = NULL; + ares_dns_record_create(&dnsrec, 0, ARES_FLAG_RD, ARES_OPCODE_QUERY, ARES_RCODE_NOERROR); + ares_dns_record_query_add(dnsrec, "ndots0", ARES_REC_TYPE_A, ARES_CLASS_IN); + ares_search_dnsrec(channel_, dnsrec, QueryCallback, &result); + ares_dns_record_destroy(dnsrec); + Process(); + EXPECT_TRUE(result.done_); + EXPECT_EQ(ARES_SUCCESS, result.status_); + + // QueryResult doesn't provide an easy way to retrieve the address, just ignore, + // success is probably good enough +} + + class MockFlagsChannelOptsTestAI : public MockChannelOptsTest, public ::testing::WithParamInterface< std::pair > { public: MockFlagsChannelOptsTestAI(int flags) - : MockChannelOptsTest(1, GetParam().first, GetParam().second, + : MockChannelOptsTest(1, GetParam().first, GetParam().second, false, FillOptions(&opts_, flags), ARES_OPT_FLAGS) {} static struct ares_options* FillOptions(struct ares_options * opts, int flags) { memset(opts, 0, sizeof(struct ares_options)); @@ -704,7 +821,7 @@ class MockMultiServerChannelTestAI public ::testing::WithParamInterface< std::pair > { public: MockMultiServerChannelTestAI(ares_options *opts, int optmask) - : MockChannelOptsTest(3, GetParam().first, GetParam().second, opts, optmask) {} + : MockChannelOptsTest(3, GetParam().first, GetParam().second, false, opts, optmask) {} void CheckExample() { AddrInfoResult result; struct ares_addrinfo_hints hints = {}; @@ -776,147 +893,6 @@ TEST_P(NoRotateMultiMockTestAI, ThirdServer) { CheckExample(); } -#define SERVER_FAILOVER_RETRY_DELAY 750 -class ServerFailoverOptsMockTestAI : public MockMultiServerChannelTestAI { - public: - ServerFailoverOptsMockTestAI() - : MockMultiServerChannelTestAI(FillOptions(&opts_), - ARES_OPT_SERVER_FAILOVER | ARES_OPT_NOROTATE) {} - static struct ares_options* FillOptions(struct ares_options *opts) { - memset(opts, 0, sizeof(struct ares_options)); - opts->server_failover_opts.retry_chance = 1; - opts->server_failover_opts.retry_delay = SERVER_FAILOVER_RETRY_DELAY; - return opts; - } - private: - struct ares_options opts_; -}; - -// Test case to trigger server failover behavior. We use a retry chance of -// 100% and a retry delay so that we can test behavior reliably. -TEST_P(ServerFailoverOptsMockTestAI, ServerFailoverOpts) { - DNSPacket servfailrsp; - servfailrsp.set_response().set_aa().set_rcode(SERVFAIL) - .add_question(new DNSQuestion("www.example.com", T_A)); - DNSPacket okrsp; - okrsp.set_response().set_aa() - .add_question(new DNSQuestion("www.example.com", T_A)) - .add_answer(new DNSARR("www.example.com", 100, {2,3,4,5})); - - auto tv_begin = std::chrono::high_resolution_clock::now(); - auto tv_now = std::chrono::high_resolution_clock::now(); - unsigned int delay_ms; - - // 1. If all servers are healthy, then the first server should be selected. - if (verbose) std::cerr << std::chrono::duration_cast(tv_now - tv_begin).count() << "ms: First server should be selected" << std::endl; - EXPECT_CALL(*servers_[0], OnRequest("www.example.com", T_A)) - .WillOnce(SetReply(servers_[0].get(), &okrsp)); - CheckExample(); - - // 2. Failed servers should be retried after the retry delay. - // - // Fail server #0 but leave server #1 as healthy. - tv_now = std::chrono::high_resolution_clock::now(); - if (verbose) std::cerr << std::chrono::duration_cast(tv_now - tv_begin).count() << "ms: Server0 will fail but leave Server1 as healthy" << std::endl; - EXPECT_CALL(*servers_[0], OnRequest("www.example.com", T_A)) - .WillOnce(SetReply(servers_[0].get(), &servfailrsp)); - EXPECT_CALL(*servers_[1], OnRequest("www.example.com", T_A)) - .WillOnce(SetReply(servers_[1].get(), &okrsp)); - CheckExample(); - - // Sleep for the retry delay (actually a little more than the retry delay to account - // for unreliable timing, e.g. NTP slew) and send in another query. Server #0 - // should be retried. - tv_now = std::chrono::high_resolution_clock::now(); - delay_ms = SERVER_FAILOVER_RETRY_DELAY + (SERVER_FAILOVER_RETRY_DELAY / 10); - if (verbose) std::cerr << std::chrono::duration_cast(tv_now - tv_begin).count() << "ms: sleep " << delay_ms << "ms" << std::endl; - ares_sleep_time(delay_ms); - tv_now = std::chrono::high_resolution_clock::now(); - if (verbose) std::cerr << std::chrono::duration_cast(tv_now - tv_begin).count() << "ms: Server0 should be past retry delay and should be tried again successfully" << std::endl; - EXPECT_CALL(*servers_[0], OnRequest("www.example.com", T_A)) - .WillOnce(SetReply(servers_[0].get(), &okrsp)); - CheckExample(); - - // 3. If there are multiple failed servers, then the servers should be - // retried in sorted order. - // - // Fail all servers for the first round of tries. On the second round server - // #1 responds successfully. - tv_now = std::chrono::high_resolution_clock::now(); - if (verbose) std::cerr << std::chrono::duration_cast(tv_now - tv_begin).count() << "ms: All 3 servers will fail on the first attempt. On second attempt, Server0 will fail, but Server1 will answer correctly." << std::endl; - EXPECT_CALL(*servers_[0], OnRequest("www.example.com", T_A)) - .WillOnce(SetReply(servers_[0].get(), &servfailrsp)) - .WillOnce(SetReply(servers_[0].get(), &servfailrsp)); - EXPECT_CALL(*servers_[1], OnRequest("www.example.com", T_A)) - .WillOnce(SetReply(servers_[1].get(), &servfailrsp)) - .WillOnce(SetReply(servers_[1].get(), &okrsp)); - EXPECT_CALL(*servers_[2], OnRequest("www.example.com", T_A)) - .WillOnce(SetReply(servers_[2].get(), &servfailrsp)); - CheckExample(); - - // At this point the sorted servers look like [1] (f0) [2] (f1) [0] (f2). - // Sleep for the retry delay and send in another query. Server #2 should be - // retried first, and then server #0. - tv_now = std::chrono::high_resolution_clock::now(); - delay_ms = SERVER_FAILOVER_RETRY_DELAY + (SERVER_FAILOVER_RETRY_DELAY / 10); - if (verbose) std::cerr << std::chrono::duration_cast(tv_now - tv_begin).count() << "ms: sleep " << delay_ms << "ms" << std::endl; - ares_sleep_time(delay_ms); - tv_now = std::chrono::high_resolution_clock::now(); - if (verbose) std::cerr << std::chrono::duration_cast(tv_now - tv_begin).count() << "ms: Past retry delay, so will choose Server2 and Server0 that are down. Server2 will fail but Server0 will succeed." << std::endl; - EXPECT_CALL(*servers_[2], OnRequest("www.example.com", T_A)) - .WillOnce(SetReply(servers_[2].get(), &servfailrsp)); - EXPECT_CALL(*servers_[0], OnRequest("www.example.com", T_A)) - .WillOnce(SetReply(servers_[0].get(), &okrsp)); - CheckExample(); - - // Test might take a while to run and the sleep may not be accurate, so we - // want to track this interval otherwise we may not pass the last test case - // on slow systems. - auto elapse_start = tv_now; - - // 4. If there are multiple failed servers, then servers which have not yet - // met the retry delay should be skipped. - // - // The sorted servers currently look like [0] (f0) [1] (f0) [2] (f2) and - // server #2 has just been retried. - // Sleep for 1/2 the retry delay and trigger a failure on server #0. - tv_now = std::chrono::high_resolution_clock::now(); - delay_ms = (SERVER_FAILOVER_RETRY_DELAY/2); - if (verbose) std::cerr << std::chrono::duration_cast(tv_now - tv_begin).count() << "ms: sleep " << delay_ms << "ms" << std::endl; - ares_sleep_time(delay_ms); - tv_now = std::chrono::high_resolution_clock::now(); - - if (verbose) std::cerr << std::chrono::duration_cast(tv_now - tv_begin).count() << "ms: Retry delay has not been hit yet. Server0 was last successful, so should be tried first (and will fail), Server1 is also healthy so will respond." << std::endl; - EXPECT_CALL(*servers_[0], OnRequest("www.example.com", T_A)) - .WillOnce(SetReply(servers_[0].get(), &servfailrsp)); - EXPECT_CALL(*servers_[1], OnRequest("www.example.com", T_A)) - .WillOnce(SetReply(servers_[1].get(), &okrsp)); - CheckExample(); - - // The sorted servers now look like [1] (f0) [0] (f1) [2] (f2). Server #0 - // has just failed whilst server #2 is somewhere in its retry delay. - // Sleep until we know server #2s retry delay has elapsed but Server #0 has - // not. - tv_now = std::chrono::high_resolution_clock::now(); - - unsigned int elapsed_time = (unsigned int)std::chrono::duration_cast(tv_now - elapse_start).count(); - delay_ms = (SERVER_FAILOVER_RETRY_DELAY) + (SERVER_FAILOVER_RETRY_DELAY / 10); - if (elapsed_time > delay_ms) { - if (verbose) std::cerr << "elapsed duration " << elapsed_time << "ms greater than desired delay of " << delay_ms << "ms, not sleeping" << std::endl; - } else { - delay_ms -= elapsed_time; // subtract already elapsed time - if (verbose) std::cerr << std::chrono::duration_cast(tv_now - tv_begin).count() << "ms: sleep " << delay_ms << "ms" << std::endl; - ares_sleep_time(delay_ms); - } - tv_now = std::chrono::high_resolution_clock::now(); - if (verbose) std::cerr << std::chrono::duration_cast(tv_now - tv_begin).count() << "ms: Retry delay has expired on Server2 but not Server0, will try on Server2 and fail, then Server1 will answer" << std::endl; - EXPECT_CALL(*servers_[2], OnRequest("www.example.com", T_A)) - .WillOnce(SetReply(servers_[2].get(), &servfailrsp)); - EXPECT_CALL(*servers_[1], OnRequest("www.example.com", T_A)) - .WillOnce(SetReply(servers_[1].get(), &okrsp)); - CheckExample(); -} - TEST_P(MockChannelTestAI, FamilyV4ServiceName) { DNSPacket rsp4; rsp4.set_response().set_aa() @@ -964,8 +940,5 @@ INSTANTIATE_TEST_SUITE_P(AddressFamiliesAI, MockEDNSChannelTestAI, INSTANTIATE_TEST_SUITE_P(TransportModesAI, NoRotateMultiMockTestAI, ::testing::ValuesIn(ares::test::families_modes), PrintFamilyMode); -INSTANTIATE_TEST_SUITE_P(TransportModesAI, ServerFailoverOptsMockTestAI, - ::testing::ValuesIn(ares::test::families_modes), PrintFamilyMode); - } // namespace test } // namespace ares diff --git a/lib/c-ares-1.32.3/test/ares-test-mock-et.cc b/lib/c-ares-1.33.1/test/ares-test-mock-et.cc similarity index 99% rename from lib/c-ares-1.32.3/test/ares-test-mock-et.cc rename to lib/c-ares-1.33.1/test/ares-test-mock-et.cc index b32dc8e69e4..1ee15c43791 100644 --- a/lib/c-ares-1.32.3/test/ares-test-mock-et.cc +++ b/lib/c-ares-1.33.1/test/ares-test-mock-et.cc @@ -249,6 +249,9 @@ TEST_P(MockUDPEventThreadMaxQueriesTest, GetHostByNameParallelLookups) { } } +/* This test case is likely to fail in heavily loaded environments, it was + * there to stress the windows event system. Not needed to be on normally */ +#if 0 class MockUDPEventThreadSingleQueryPerConnTest : public MockEventThreadOptsTest, public ::testing::WithParamInterface> { @@ -296,7 +299,7 @@ TEST_P(MockUDPEventThreadSingleQueryPerConnTest, LotsOfConnections) { EXPECT_EQ("{'www.google.com' aliases=[] addrs=[2.3.4.5]}", ss.str()); } } - +#endif class CacheQueriesEventThreadTest : public MockEventThreadOptsTest, @@ -1413,7 +1416,14 @@ TEST_P(NoRotateMultiMockEventThreadTest, ServerNoResponseFailover) { EXPECT_EQ("{'www.example.com' aliases=[] addrs=[2.3.4.5]}", ss4.str()); } -#define SERVER_FAILOVER_RETRY_DELAY 750 +#ifdef __APPLE__ +/* Apple's sleep is no where near accurate, especially on a heavily loaded + * system. Its possible we could set a realtime priority on a thread to + * help with this, but for now, just increase the delay */ +# define SERVER_FAILOVER_RETRY_DELAY 750 +#else +# define SERVER_FAILOVER_RETRY_DELAY 500 +#endif class ServerFailoverOptsMockEventThreadTest : public MockMultiServerEventThreadTest { public: ServerFailoverOptsMockEventThreadTest() @@ -1618,8 +1628,9 @@ INSTANTIATE_TEST_SUITE_P(TransportModes, NoRotateMultiMockEventThreadTest, ::tes INSTANTIATE_TEST_SUITE_P(TransportModes, ServerFailoverOptsMockEventThreadTest, ::testing::ValuesIn(ares::test::evsys_families_modes), ares::test::PrintEvsysFamilyMode); +#if 0 INSTANTIATE_TEST_SUITE_P(AddressFamilies, MockUDPEventThreadSingleQueryPerConnTest, ::testing::ValuesIn(ares::test::evsys_families), ares::test::PrintEvsysFamily); - +#endif } // namespace test } // namespace ares diff --git a/lib/c-ares-1.32.3/test/ares-test-mock.cc b/lib/c-ares-1.33.1/test/ares-test-mock.cc similarity index 83% rename from lib/c-ares-1.32.3/test/ares-test-mock.cc rename to lib/c-ares-1.33.1/test/ares-test-mock.cc index 4c0067131b7..46a5780ae40 100644 --- a/lib/c-ares-1.32.3/test/ares-test-mock.cc +++ b/lib/c-ares-1.33.1/test/ares-test-mock.cc @@ -45,7 +45,7 @@ class NoDNS0x20MockTest public ::testing::WithParamInterface { public: NoDNS0x20MockTest() - : MockChannelOptsTest(1, GetParam(), false, + : MockChannelOptsTest(1, GetParam(), false, false, FillOptions(&opts_), ARES_OPT_FLAGS) {} static struct ares_options* FillOptions(struct ares_options * opts) { @@ -453,7 +453,7 @@ class MockUDPMaxQueriesTest public ::testing::WithParamInterface { public: MockUDPMaxQueriesTest() - : MockChannelOptsTest(1, GetParam(), false, + : MockChannelOptsTest(1, GetParam(), false, false, FillOptions(&opts_), ARES_OPT_UDP_MAX_QUERIES) {} static struct ares_options* FillOptions(struct ares_options * opts) { @@ -500,7 +500,7 @@ class CacheQueriesTest public ::testing::WithParamInterface { public: CacheQueriesTest() - : MockChannelOptsTest(1, GetParam(), false, + : MockChannelOptsTest(1, GetParam(), false, false, FillOptions(&opts_), ARES_OPT_QUERY_CACHE) {} static struct ares_options* FillOptions(struct ares_options * opts) { @@ -665,7 +665,7 @@ class MockExtraOptsTest public ::testing::WithParamInterface< std::pair > { public: MockExtraOptsTest() - : MockChannelOptsTest(1, GetParam().first, GetParam().second, + : MockChannelOptsTest(1, GetParam().first, GetParam().second, false, FillOptions(&opts_), ARES_OPT_SOCK_SNDBUF|ARES_OPT_SOCK_RCVBUF) {} static struct ares_options* FillOptions(struct ares_options * opts) { @@ -707,7 +707,7 @@ class MockFlagsChannelOptsTest public ::testing::WithParamInterface< std::pair > { public: MockFlagsChannelOptsTest(int flags) - : MockChannelOptsTest(1, GetParam().first, GetParam().second, + : MockChannelOptsTest(1, GetParam().first, GetParam().second, false, FillOptions(&opts_, flags), ARES_OPT_FLAGS) {} static struct ares_options* FillOptions(struct ares_options * opts, int flags) { memset(opts, 0, sizeof(struct ares_options)); @@ -817,6 +817,89 @@ TEST_P(MockChannelTest, SearchDomains) { EXPECT_EQ("{'www.third.gov' aliases=[] addrs=[2.3.4.5]}", ss.str()); } +#ifdef HAVE_CONTAINER +// Issue #852 +class ContainedMockChannelSysConfig + : public MockChannelOptsTest, + public ::testing::WithParamInterface> { + public: + ContainedMockChannelSysConfig() + : MockChannelOptsTest(1, GetParam().first, GetParam().second, true, nullptr, 0) {} +}; + +NameContentList files_no_ndots = { + {"/etc/resolv.conf", "nameserver 1.2.3.4\n" // Will be replaced + "search example.com example.org\n" + "options edns0 trust-ad\n"}, // ndots:1 is default + {"/etc/hosts", "3.4.5.6 ahostname.com\n"}, + {"/etc/nsswitch.conf", "hosts: files dns\n"}}; +CONTAINED_TEST_P(ContainedMockChannelSysConfig, SysConfigNdotsDefault, + "myhostname", "mydomainname.org", files_no_ndots) { + DNSPacket rsp; + rsp.set_response().set_aa() + .add_question(new DNSQuestion("www.example.com", T_A)) + .add_answer(new DNSARR("www.example.com", 0x0200, {2, 3, 4, 5})); + EXPECT_CALL(server_, OnRequest("www.example.com", T_A)) + .WillOnce(SetReply(&server_, &rsp)); + + HostResult result; + ares_gethostbyname(channel_, "www", AF_INET, HostCallback, &result); + Process(); + EXPECT_TRUE(result.done_); + std::stringstream ss; + ss << result.host_; + EXPECT_EQ("{'www.example.com' aliases=[] addrs=[2.3.4.5]}", ss.str()); + return HasFailure(); +} + +NameContentList files_ndots0 = { + {"/etc/resolv.conf", "nameserver 1.2.3.4\n" // Will be replaced + "search example.com example.org\n" + "options edns0 trust-ad ndots:0\n"}, // ndots:1 is default + {"/etc/hosts", "3.4.5.6 ahostname.com\n"}, + {"/etc/nsswitch.conf", "hosts: files dns\n"}}; +CONTAINED_TEST_P(ContainedMockChannelSysConfig, SysConfigNdots0, + "myhostname", "mydomainname.org", files_ndots0) { + DNSPacket rsp; + rsp.set_response().set_aa() + .add_question(new DNSQuestion("www", T_A)) + .add_answer(new DNSARR("www", 0x0200, {1, 2, 3, 4})); + EXPECT_CALL(server_, OnRequest("www", T_A)) + .WillOnce(SetReply(&server_, &rsp)); + + HostResult result; + ares_gethostbyname(channel_, "www", AF_INET, HostCallback, &result); + Process(); + EXPECT_TRUE(result.done_); + std::stringstream ss; + ss << result.host_; + EXPECT_EQ("{'www' aliases=[] addrs=[1.2.3.4]}", ss.str()); + return HasFailure(); +} +#endif + +// Issue #858 +TEST_P(CacheQueriesTest, BlankName) { + DNSPacket rsp; + rsp.set_response().set_aa() + .add_question(new DNSQuestion(".", T_SOA)) + .add_answer(new DNSSoaRR(".", 600, "a.root-servers.net", "nstld.verisign-grs.com", 123456, 3600, 3600, 3600, 3600)); + EXPECT_CALL(server_, OnRequest("", T_SOA)) + .WillOnce(SetReply(&server_, &rsp)); + + QueryResult result; + ares_query_dnsrec(channel_, ".", ARES_CLASS_IN, ARES_REC_TYPE_SOA, QueryCallback, &result, NULL); + Process(); + EXPECT_TRUE(result.done_); + EXPECT_EQ(0, result.timeouts_); + + QueryResult cacheresult; + ares_query_dnsrec(channel_, ".", ARES_CLASS_IN, ARES_REC_TYPE_SOA, QueryCallback, &cacheresult, NULL); + Process(); + EXPECT_TRUE(cacheresult.done_); + EXPECT_EQ(0, cacheresult.timeouts_); +} + // Relies on retries so is UDP-only TEST_P(MockUDPChannelTest, SearchDomainsWithResentReply) { DNSPacket nofirst; @@ -876,6 +959,8 @@ TEST_P(MockChannelTest, SearchDomainsBare) { ares_gethostbyname(channel_, "www", AF_INET, HostCallback, &result); Process(); EXPECT_TRUE(result.done_); + EXPECT_EQ(0, result.timeouts_); + std::stringstream ss; ss << result.host_; EXPECT_EQ("{'www' aliases=[] addrs=[2.3.4.5]}", ss.str()); @@ -1005,7 +1090,9 @@ TEST_P(MockChannelTest, SearchHighNdots) { // Test that performing an EDNS search with an OPT RR options value works. The // options value should be included on the requests to the mock server. -TEST_P(MockEDNSChannelTest, SearchOptVal) { +// We are going to do this only via TCP since this won't include the dynamically +// generated DNS cookie that would otherwise mess with this result. +TEST_P(MockTCPChannelTest, SearchOptVal) { /* Define the OPT RR options code and value to use. */ unsigned short opt_opt = 3; unsigned char opt_val[] = { 'c', '-', 'a', 'r', 'e', 's' }; @@ -1511,6 +1598,271 @@ TEST_P(MockChannelTest, GetHostByAddrDestroy) { EXPECT_EQ(0, result.timeouts_); } +static const unsigned char * + fetch_server_cookie(const ares_dns_record_t *dnsrec, size_t *len) +{ + const ares_dns_rr_t *rr = fetch_rr_opt(dnsrec); + const unsigned char *val = NULL; + *len = 0; + + if (rr == NULL) { + return NULL; + } + + if (!ares_dns_rr_get_opt_byid(rr, ARES_RR_OPT_OPTIONS, ARES_OPT_PARAM_COOKIE, + &val, len)) { + return NULL; + } + + if (*len <= 8) { + *len = 0; + return NULL; + } + + *len -= 8; + val += 8; + return val; +} + +static const unsigned char * + fetch_client_cookie(const ares_dns_record_t *dnsrec, size_t *len) +{ + const ares_dns_rr_t *rr = fetch_rr_opt(dnsrec); + const unsigned char *val = NULL; + *len = 0; + + if (rr == NULL) { + return NULL; + } + + if (!ares_dns_rr_get_opt_byid(rr, ARES_RR_OPT_OPTIONS, ARES_OPT_PARAM_COOKIE, + &val, len)) { + return NULL; + } + + if (*len < 8) { + *len = 0; + return NULL; + } + + *len = 8; + return val; +} + +TEST_P(MockUDPChannelTest, DNSCookieSingle) { + DNSPacket reply; + std::vector server_cookie = { 1, 2, 3, 4, 5, 6, 7, 8 }; + reply.set_response().set_aa() + .add_question(new DNSQuestion("www.google.com", T_A)) + .add_answer(new DNSARR("www.google.com", 0x0100, {0x01, 0x02, 0x03, 0x04})) + .add_additional(new DNSOptRR(0, 0, 0, 1280, { }, server_cookie, false)); + EXPECT_CALL(server_, OnRequest("www.google.com", T_A)) + .WillOnce(SetReply(&server_, &reply)); + + QueryResult result; + ares_query_dnsrec(channel_, "www.google.com", ARES_CLASS_IN, ARES_REC_TYPE_A, QueryCallback, &result, NULL); + Process(); + EXPECT_TRUE(result.done_); + EXPECT_EQ(0, result.timeouts_); + + size_t len; + const unsigned char *returned_cookie = fetch_server_cookie(result.dnsrec_.dnsrec_, &len); + EXPECT_EQ(len, server_cookie.size()); + EXPECT_TRUE(memcmp(server_cookie.data(), returned_cookie, len) == 0); +} + +TEST_P(MockUDPChannelTest, DNSCookieMissingAfterGood) { + std::vector server_cookie = { 1, 2, 3, 4, 5, 6, 7, 8 }; + DNSPacket reply; + reply.set_response().set_aa() + .add_question(new DNSQuestion("www.google.com", T_A)) + .add_answer(new DNSARR("www.google.com", 0x0100, {0x01, 0x02, 0x03, 0x04})) + .add_additional(new DNSOptRR(0, 0, 0, 1280, { }, server_cookie, false)); + DNSPacket reply_nocookie; + reply_nocookie.set_response().set_aa() + .add_question(new DNSQuestion("www.google.com", T_A)) + .add_answer(new DNSARR("www.google.com", 0x0100, {0x01, 0x02, 0x03, 0x04})) + .add_additional(new DNSOptRR(0, 0, 0, 1280, { }, { }, false)); + DNSPacket reply_ensurecookie; + reply_ensurecookie.set_response().set_aa() + .add_question(new DNSQuestion("www.google.com", T_A)) + .add_answer(new DNSARR("www.google.com", 0x0100, {0x01, 0x02, 0x03, 0x04})) + .add_additional(new DNSOptRR(0, 0, 0, 1280, { }, server_cookie, true)); + + EXPECT_CALL(server_, OnRequest("www.google.com", T_A)) + .WillOnce(SetReply(&server_, &reply)) + .WillOnce(SetReply(&server_, &reply_nocookie)) + .WillOnce(SetReply(&server_, &reply_ensurecookie)); + + /* This test will establish the server supports cookies, then the next reply + * will be missing the server cookie and therefore be rejected and timeout, then + * an internal retry will occur and the cookie will be present again and it + * will be verified a server cookie was actually present that matches the + * server cookie. */ + QueryResult result1; + ares_query_dnsrec(channel_, "www.google.com", ARES_CLASS_IN, ARES_REC_TYPE_A, QueryCallback, &result1, NULL); + Process(); + EXPECT_TRUE(result1.done_); + EXPECT_EQ(0, result1.timeouts_); + + QueryResult result2; + ares_query_dnsrec(channel_, "www.google.com", ARES_CLASS_IN, ARES_REC_TYPE_A, QueryCallback, &result2, NULL); + Process(); + EXPECT_TRUE(result2.done_); + EXPECT_EQ(1, result2.timeouts_); + + /* Client cookie should NOT have rotated */ + size_t len1; + const unsigned char *client_cookie_1 = fetch_client_cookie(result1.dnsrec_.dnsrec_, &len1); + size_t len2; + const unsigned char *client_cookie_2 = fetch_client_cookie(result2.dnsrec_.dnsrec_, &len2); + EXPECT_EQ(len1, 8); + EXPECT_EQ(len1, len2); + EXPECT_TRUE(memcmp(client_cookie_1, client_cookie_2, len1) == 0); +} + + +TEST_P(MockUDPChannelTest, DNSCookieBadLen) { + std::vector server_cookie = { 1, 2, 3, 4, 5, 6, 7, 8 }; + std::vector server_cookie_bad = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0 }; + DNSPacket reply; + reply.set_response().set_aa() + .add_question(new DNSQuestion("www.google.com", T_A)) + .add_answer(new DNSARR("www.google.com", 0x0100, {0x01, 0x02, 0x03, 0x04})) + .add_additional(new DNSOptRR(0, 0, 0, 1280, { }, server_cookie, false)); + DNSPacket reply_badcookielen; + reply_badcookielen.set_response().set_aa() + .add_question(new DNSQuestion("www.google.com", T_A)) + .add_answer(new DNSARR("www.google.com", 0x0100, {0x01, 0x02, 0x03, 0x04})) + .add_additional(new DNSOptRR(0, 0, 0, 1280, { }, server_cookie_bad, false)); + + EXPECT_CALL(server_, OnRequest("www.google.com", T_A)) + .WillOnce(SetReply(&server_, &reply_badcookielen)) + .WillOnce(SetReply(&server_, &reply)); + + /* This test will send back a malformed cookie len, then when it times out and retry occurs will send back a valid cookie. */ + QueryResult result1; + ares_query_dnsrec(channel_, "www.google.com", ARES_CLASS_IN, ARES_REC_TYPE_A, QueryCallback, &result1, NULL); + Process(); + EXPECT_TRUE(result1.done_); + EXPECT_EQ(1, result1.timeouts_); +} + + +TEST_P(MockUDPChannelTest, DNSCookieServerRotate) { + std::vector server_cookie = { 1, 2, 3, 4, 5, 6, 7, 8 }; + std::vector server_cookie_rotate = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF }; + + DNSPacket reply_cookie1; + reply_cookie1.set_response().set_aa() + .add_question(new DNSQuestion("www.google.com", T_A)) + .add_answer(new DNSARR("www.google.com", 0x0100, {0x01, 0x02, 0x03, 0x04})) + .add_additional(new DNSOptRR(0, 0, 0, 1280, {}, server_cookie, false)); + DNSPacket reply_cookie2_badcookie; + reply_cookie2_badcookie.set_response().set_aa().set_rcode(ARES_RCODE_BADCOOKIE & 0xF) + .add_question(new DNSQuestion("www.google.com", T_A)) + .add_answer(new DNSARR("www.google.com", 0x0100, {0x01, 0x02, 0x03, 0x04})) + .add_additional(new DNSOptRR((ARES_RCODE_BADCOOKIE >> 4) & 0xFF, 0, 0, 1280, { }, server_cookie_rotate, false)); + DNSPacket reply_cookie2; + reply_cookie2.set_response().set_aa() + .add_question(new DNSQuestion("www.google.com", T_A)) + .add_answer(new DNSARR("www.google.com", 0x0100, {0x01, 0x02, 0x03, 0x04})) + .add_additional(new DNSOptRR(0, 0, 0, 1280, { }, server_cookie_rotate, true)); + + EXPECT_CALL(server_, OnRequest("www.google.com", T_A)) + .WillOnce(SetReply(&server_, &reply_cookie1)) + .WillOnce(SetReply(&server_, &reply_cookie2_badcookie)) + .WillOnce(SetReply(&server_, &reply_cookie2)); + + /* This test will establish the server supports cookies, then the next reply + * the server returns BADCOOKIE indicating the cookie has rotated and + * returns a new cookie. Then the query will be automatically retried with + * the newly returned cookie. No timeouts should be indicated, and the + * client cookie should not rotate. */ + QueryResult result1; + ares_query_dnsrec(channel_, "www.google.com", ARES_CLASS_IN, ARES_REC_TYPE_A, QueryCallback, &result1, NULL); + Process(); + EXPECT_TRUE(result1.done_); + EXPECT_EQ(0, result1.timeouts_); + + QueryResult result2; + ares_query_dnsrec(channel_, "www.google.com", ARES_CLASS_IN, ARES_REC_TYPE_A, QueryCallback, &result2, NULL); + Process(); + EXPECT_TRUE(result2.done_); + EXPECT_EQ(0, result2.timeouts_); + + /* Client cookie should NOT have rotated */ + size_t len1; + const unsigned char *client_cookie_1 = fetch_client_cookie(result1.dnsrec_.dnsrec_, &len1); + size_t len2; + const unsigned char *client_cookie_2 = fetch_client_cookie(result2.dnsrec_.dnsrec_, &len2); + EXPECT_EQ(len1, 8); + EXPECT_EQ(len1, len2); + EXPECT_TRUE(memcmp(client_cookie_1, client_cookie_2, len1) == 0); +} + +TEST_P(MockUDPChannelTest, DNSCookieSpoof) { + std::vector client_cookie = { 1, 2, 3, 4, 5, 6, 7, 8 }; + std::vector server_cookie = { 1, 2, 3, 4, 5, 6, 7, 8 }; + + DNSPacket reply_spoof; + reply_spoof.set_response().set_aa() + .add_question(new DNSQuestion("www.google.com", T_A)) + .add_answer(new DNSARR("www.google.com", 0x0100, {0x01, 0x02, 0x03, 0x04})) + .add_additional(new DNSOptRR(0, 0, 0, 1280, client_cookie, server_cookie, false)); + DNSPacket reply; + reply.set_response().set_aa() + .add_question(new DNSQuestion("www.google.com", T_A)) + .add_answer(new DNSARR("www.google.com", 0x0100, {0x01, 0x02, 0x03, 0x04})) + .add_additional(new DNSOptRR(0, 0, 0, 1280, { }, server_cookie, false)); + + EXPECT_CALL(server_, OnRequest("www.google.com", T_A)) + .WillOnce(SetReply(&server_, &reply_spoof)) + .WillOnce(SetReply(&server_, &reply)); + + /* This test will return a reply that doesn't have the same client cookie as + * was sent, this should result in a drop of the packet alltogether, then + * the library will retry and a proper result will be sent. */ + QueryResult result; + ares_query_dnsrec(channel_, "www.google.com", ARES_CLASS_IN, ARES_REC_TYPE_A, QueryCallback, &result, NULL); + Process(); + EXPECT_TRUE(result.done_); + EXPECT_EQ(1, result.timeouts_); +} + +TEST_P(MockUDPChannelTest, DNSCookieTCPUpgrade) { + std::vector server_cookie = { 1, 2, 3, 4, 5, 6, 7, 8 }; + + DNSPacket reply_badcookie; + reply_badcookie.set_response().set_aa().set_rcode(ARES_RCODE_BADCOOKIE & 0xF) + .add_question(new DNSQuestion("www.google.com", T_A)) + .add_answer(new DNSARR("www.google.com", 0x0100, {0x01, 0x02, 0x03, 0x04})) + .add_additional(new DNSOptRR((ARES_RCODE_BADCOOKIE >> 4) & 0xFF, 0, 0, 1280, { }, server_cookie, false)); + DNSPacket reply; + reply.set_response().set_aa() + .add_question(new DNSQuestion("www.google.com", T_A)) + .add_answer(new DNSARR("www.google.com", 0x0100, {0x01, 0x02, 0x03, 0x04})) + .add_additional(new DNSOptRR(0, 0, 0, 1280, { }, { }, false)); + + EXPECT_CALL(server_, OnRequest("www.google.com", T_A)) + .WillOnce(SetReply(&server_, &reply_badcookie)) + .WillOnce(SetReply(&server_, &reply_badcookie)) + .WillOnce(SetReply(&server_, &reply_badcookie)) + .WillOnce(SetReply(&server_, &reply)); + + /* This test will establish the server supports cookies, but continuously + * returns BADCOOKIE which is an indicator that there is some form of + * AnyCast issue across servers, so it upgrades to TCP afterwards. No + * timeouts are recorded as the queries are sent back-to-back as immediate + * reattempts after the response. */ + QueryResult result; + ares_query_dnsrec(channel_, "www.google.com", ARES_CLASS_IN, ARES_REC_TYPE_A, QueryCallback, &result, NULL); + Process(); + EXPECT_TRUE(result.done_); + EXPECT_EQ(0, result.timeouts_); +} + + #ifndef WIN32 TEST_P(MockChannelTest, HostAlias) { DNSPacket reply; @@ -1602,7 +1954,7 @@ class MockMultiServerChannelTest public ::testing::WithParamInterface< std::pair > { public: MockMultiServerChannelTest(ares_options *opts, int optmask) - : MockChannelOptsTest(3, GetParam().first, GetParam().second, opts, optmask) {} + : MockChannelOptsTest(3, GetParam().first, GetParam().second, false, opts, optmask) {} void CheckExample() { HostResult result; ares_gethostbyname(channel_, "www.example.com.", AF_INET, HostCallback, &result); @@ -1739,7 +2091,16 @@ TEST_P(NoRotateMultiMockTest, ServerNoResponseFailover) { EXPECT_EQ("{'www.example.com' aliases=[] addrs=[2.3.4.5]}", ss4.str()); } -#define SERVER_FAILOVER_RETRY_DELAY 750 +#ifdef __APPLE__ +/* Apple's sleep is no where near accurate, especially on a heavily loaded + * system. Its possible we could set a realtime priority on a thread to + * help with this, but for now, just increase the delay */ +# define SERVER_FAILOVER_RETRY_DELAY 750 +#elif defined(_WIN32) +# define SERVER_FAILOVER_RETRY_DELAY 500 +#else +# define SERVER_FAILOVER_RETRY_DELAY 250 +#endif class ServerFailoverOptsMultiMockTest : public MockMultiServerChannelTest { public: ServerFailoverOptsMultiMockTest() @@ -1918,6 +2279,10 @@ INSTANTIATE_TEST_SUITE_P(AddressFamilies, NoDNS0x20MockTest, ::testing::ValuesIn INSTANTIATE_TEST_SUITE_P(AddressFamilies, MockChannelTest, ::testing::ValuesIn(ares::test::families_modes), PrintFamilyMode); +#ifdef HAVE_CONTAINER +INSTANTIATE_TEST_SUITE_P(AddressFamilies, ContainedMockChannelSysConfig, ::testing::ValuesIn(ares::test::families_modes), PrintFamilyMode); +#endif + INSTANTIATE_TEST_SUITE_P(AddressFamilies, MockUDPChannelTest, ::testing::ValuesIn(ares::test::families), PrintFamily); INSTANTIATE_TEST_SUITE_P(AddressFamilies, MockUDPMaxQueriesTest, ::testing::ValuesIn(ares::test::families), PrintFamily); diff --git a/lib/c-ares-1.32.3/test/ares-test-ns.cc b/lib/c-ares-1.33.1/test/ares-test-ns.cc similarity index 96% rename from lib/c-ares-1.32.3/test/ares-test-ns.cc rename to lib/c-ares-1.33.1/test/ares-test-ns.cc index 8837038766b..3ff9b9ad6ac 100644 --- a/lib/c-ares-1.32.3/test/ares-test-ns.cc +++ b/lib/c-ares-1.33.1/test/ares-test-ns.cc @@ -155,8 +155,8 @@ int RunInContainer(ContainerFilesystem* fs, const std::string& hostname, std::stringstream contentss; contentss << "0 " << getuid() << " 1" << std::endl; std::string content = contentss.str(); - int rc = write(fd, content.c_str(), content.size()); - if (rc != (int)content.size()) { + ssize_t rc = write(fd, content.c_str(), content.size()); + if (rc != (ssize_t)content.size()) { std::cerr << "Failed to write uid map to '" << mapfile << "'" << std::endl; } close(fd); @@ -181,8 +181,13 @@ ContainerFilesystem::ContainerFilesystem(NameContentList files, const std::strin dirs_.push_front(rootdir_); for (const auto& nc : files) { std::string fullpath = rootdir_ + nc.first; - int idx = fullpath.rfind('/'); - std::string dir = fullpath.substr(0, idx); + size_t idx = fullpath.rfind('/'); + std::string dir; + if (idx != SIZE_MAX) { + dir = fullpath.substr(0, idx); + } else { + dir = fullpath; + } EnsureDirExists(dir); files_.push_back(std::unique_ptr( new TransientFile(fullpath, nc.second))); diff --git a/lib/c-ares-1.32.3/test/ares-test-parse-a.cc b/lib/c-ares-1.33.1/test/ares-test-parse-a.cc similarity index 100% rename from lib/c-ares-1.32.3/test/ares-test-parse-a.cc rename to lib/c-ares-1.33.1/test/ares-test-parse-a.cc diff --git a/lib/c-ares-1.32.3/test/ares-test-parse-aaaa.cc b/lib/c-ares-1.33.1/test/ares-test-parse-aaaa.cc similarity index 100% rename from lib/c-ares-1.32.3/test/ares-test-parse-aaaa.cc rename to lib/c-ares-1.33.1/test/ares-test-parse-aaaa.cc diff --git a/lib/c-ares-1.32.3/test/ares-test-parse-caa.cc b/lib/c-ares-1.33.1/test/ares-test-parse-caa.cc similarity index 100% rename from lib/c-ares-1.32.3/test/ares-test-parse-caa.cc rename to lib/c-ares-1.33.1/test/ares-test-parse-caa.cc diff --git a/lib/c-ares-1.32.3/test/ares-test-parse-mx.cc b/lib/c-ares-1.33.1/test/ares-test-parse-mx.cc similarity index 100% rename from lib/c-ares-1.32.3/test/ares-test-parse-mx.cc rename to lib/c-ares-1.33.1/test/ares-test-parse-mx.cc diff --git a/lib/c-ares-1.32.3/test/ares-test-parse-naptr.cc b/lib/c-ares-1.33.1/test/ares-test-parse-naptr.cc similarity index 100% rename from lib/c-ares-1.32.3/test/ares-test-parse-naptr.cc rename to lib/c-ares-1.33.1/test/ares-test-parse-naptr.cc diff --git a/lib/c-ares-1.32.3/test/ares-test-parse-ns.cc b/lib/c-ares-1.33.1/test/ares-test-parse-ns.cc similarity index 100% rename from lib/c-ares-1.32.3/test/ares-test-parse-ns.cc rename to lib/c-ares-1.33.1/test/ares-test-parse-ns.cc diff --git a/lib/c-ares-1.32.3/test/ares-test-parse-ptr.cc b/lib/c-ares-1.33.1/test/ares-test-parse-ptr.cc similarity index 99% rename from lib/c-ares-1.32.3/test/ares-test-parse-ptr.cc rename to lib/c-ares-1.33.1/test/ares-test-parse-ptr.cc index 2ebe1b9f86b..9985ef3cd73 100644 --- a/lib/c-ares-1.32.3/test/ares-test-parse-ptr.cc +++ b/lib/c-ares-1.33.1/test/ares-test-parse-ptr.cc @@ -73,8 +73,8 @@ TEST_F(LibraryTest, ParsePtrReplyCname) { struct DNSMalformedCnameRR : public DNSCnameRR { DNSMalformedCnameRR(const std::string& name, int ttl, const std::string& other) : DNSCnameRR(name, ttl, other) {} - std::vector data() const { - std::vector data = DNSRR::data(); + std::vector data(const ares_dns_record_t *dnsrec) const { + std::vector data = DNSRR::data(dnsrec); std::vector encname = EncodeString(other_); encname[0] = encname[0] + 63; // invalid label length int len = (int)encname.size(); diff --git a/lib/c-ares-1.32.3/test/ares-test-parse-soa-any.cc b/lib/c-ares-1.33.1/test/ares-test-parse-soa-any.cc similarity index 100% rename from lib/c-ares-1.32.3/test/ares-test-parse-soa-any.cc rename to lib/c-ares-1.33.1/test/ares-test-parse-soa-any.cc diff --git a/lib/c-ares-1.32.3/test/ares-test-parse-soa.cc b/lib/c-ares-1.33.1/test/ares-test-parse-soa.cc similarity index 100% rename from lib/c-ares-1.32.3/test/ares-test-parse-soa.cc rename to lib/c-ares-1.33.1/test/ares-test-parse-soa.cc diff --git a/lib/c-ares-1.32.3/test/ares-test-parse-srv.cc b/lib/c-ares-1.33.1/test/ares-test-parse-srv.cc similarity index 100% rename from lib/c-ares-1.32.3/test/ares-test-parse-srv.cc rename to lib/c-ares-1.33.1/test/ares-test-parse-srv.cc diff --git a/lib/c-ares-1.32.3/test/ares-test-parse-txt.cc b/lib/c-ares-1.33.1/test/ares-test-parse-txt.cc similarity index 100% rename from lib/c-ares-1.32.3/test/ares-test-parse-txt.cc rename to lib/c-ares-1.33.1/test/ares-test-parse-txt.cc diff --git a/lib/c-ares-1.32.3/test/ares-test-parse-uri.cc b/lib/c-ares-1.33.1/test/ares-test-parse-uri.cc similarity index 100% rename from lib/c-ares-1.32.3/test/ares-test-parse-uri.cc rename to lib/c-ares-1.33.1/test/ares-test-parse-uri.cc diff --git a/lib/c-ares-1.32.3/test/ares-test-parse.cc b/lib/c-ares-1.33.1/test/ares-test-parse.cc similarity index 100% rename from lib/c-ares-1.32.3/test/ares-test-parse.cc rename to lib/c-ares-1.33.1/test/ares-test-parse.cc diff --git a/lib/c-ares-1.32.3/test/ares-test.cc b/lib/c-ares-1.33.1/test/ares-test.cc similarity index 92% rename from lib/c-ares-1.32.3/test/ares-test.cc rename to lib/c-ares-1.33.1/test/ares-test.cc index d78a5ebb263..99ab0a00858 100644 --- a/lib/c-ares-1.32.3/test/ares-test.cc +++ b/lib/c-ares-1.33.1/test/ares-test.cc @@ -41,7 +41,7 @@ extern "C" { #include "ares_setup.h" #include "ares_inet_net_pton.h" #include "ares_data.h" -#include "ares_strsplit.h" +#include "str/ares_strsplit.h" #include "ares_private.h" } @@ -437,6 +437,17 @@ MockServer::MockServer(int family, unsigned short port) setsockopt(tcpfd_, SOL_SOCKET, SO_NOSIGPIPE, (void *)&optval, sizeof(optval)); #endif + /* Test system enable TCP FastOpen */ +#if defined(TCP_FASTOPEN) +# ifdef __linux__ + int qlen = 32; + setsockopt(tcpfd_, IPPROTO_TCP, TCP_FASTOPEN, &qlen, sizeof(qlen)); +# else + int on = 1; + setsockopt(tcpfd_, IPPROTO_TCP, TCP_FASTOPEN, BYTE_CAST &on, sizeof(on)); +# endif +#endif + // Create a UDP socket to receive data on. udpfd_ = socket(family, SOCK_DGRAM, 0); EXPECT_NE(ARES_SOCKET_BAD, udpfd_); @@ -596,7 +607,7 @@ void MockServer::ProcessPacket(ares_socket_t fd, struct sockaddr_storage *addr, std::cerr << "ProcessRequest(" << qid << ", '" << name << "', " << RRTypeToString(rrtype) << ")" << std::endl; } - ProcessRequest(fd, addr, addrlen, reqstr, qid, name, rrtype); + ProcessRequest(fd, addr, addrlen, req, reqstr, qid, name, rrtype); ares_free_string(name); } @@ -666,7 +677,8 @@ std::set MockServer::fds() const { } void MockServer::ProcessRequest(ares_socket_t fd, struct sockaddr_storage* addr, - ares_socklen_t addrlen, const std::string &reqstr, + ares_socklen_t addrlen, const std::vector &req, + const std::string &reqstr, int qid, const char *name, int rrtype) { /* DNS 0x20 will mix case, do case-insensitive matching of name in request */ @@ -683,7 +695,17 @@ void MockServer::ProcessRequest(ares_socket_t fd, struct sockaddr_storage* addr, } if (reply_ != nullptr) { - exact_reply_ = reply_->data(name); + ares_dns_record_t *dnsrec = NULL; + /* We will *attempt* to parse the request string. It may be malformed that + * will lead to a parse failure. If so, we just ignore it. We want to + * pass this parsed data structure to the reply generator in case it needs + * to extract metadata (such as a DNS client cookie) from the original + * request. If we can't parse it, oh well, we'll just pass NULL, most + * replies don't need anything from the request other than the name which + * is passed separately. */ + ares_dns_parse(req.data(), req.size(), 0, &dnsrec); + exact_reply_ = reply_->data(name, dnsrec); + ares_dns_record_destroy(dnsrec); } if (exact_reply_.size() == 0) { @@ -744,11 +766,13 @@ MockChannelOptsTest::NiceMockServers MockChannelOptsTest::BuildServers(int count MockChannelOptsTest::MockChannelOptsTest(int count, int family, bool force_tcp, + bool honor_sysconfig, struct ares_options* givenopts, int optmask) : servers_(BuildServers(count, family, mock_port)), server_(*servers_[0].get()), channel_(nullptr) { // Set up channel options. + const char *domains[3] = {"first.com", "second.org", "third.gov"}; struct ares_options opts; if (givenopts) { memcpy(&opts, givenopts, sizeof(opts)); @@ -756,41 +780,39 @@ MockChannelOptsTest::MockChannelOptsTest(int count, memset(&opts, 0, sizeof(opts)); } - // Point the library at the first mock server by default (overridden below). - opts.udp_port = server_.udpport(); - optmask |= ARES_OPT_UDP_PORT; - opts.tcp_port = server_.tcpport(); - optmask |= ARES_OPT_TCP_PORT; + /* Honor items from resolv.conf except the dns server itself */ + if (!honor_sysconfig) { + if (!(optmask & (ARES_OPT_TIMEOUTMS|ARES_OPT_TIMEOUT))) { + // Reduce timeouts significantly to shorten test times. + opts.timeout = 250; + optmask |= ARES_OPT_TIMEOUTMS; + } + // If not already overridden, set 3 retries. + if (!(optmask & ARES_OPT_TRIES)) { + opts.tries = 3; + optmask |= ARES_OPT_TRIES; + } + + // If not already overridden, set search domains. + if (!(optmask & ARES_OPT_DOMAINS)) { + opts.ndomains = 3; + opts.domains = (char**)domains; + optmask |= ARES_OPT_DOMAINS; + } - if (!(optmask & (ARES_OPT_TIMEOUTMS|ARES_OPT_TIMEOUT))) { - // Reduce timeouts significantly to shorten test times. - opts.timeout = 250; - optmask |= ARES_OPT_TIMEOUTMS; - } - // If not already overridden, set 3 retries. - if (!(optmask & ARES_OPT_TRIES)) { - opts.tries = 3; - optmask |= ARES_OPT_TRIES; - } - // If not already overridden, set search domains. - const char *domains[3] = {"first.com", "second.org", "third.gov"}; - if (!(optmask & ARES_OPT_DOMAINS)) { - opts.ndomains = 3; - opts.domains = (char**)domains; - optmask |= ARES_OPT_DOMAINS; + /* Tests expect ndots=1 in general, the system config may not default to this + * so we don't want to inherit that. */ + if (!(optmask & ARES_OPT_NDOTS)) { + opts.ndots = 1; + optmask |= ARES_OPT_NDOTS; + } } + if (force_tcp) { opts.flags |= ARES_FLAG_USEVC; optmask |= ARES_OPT_FLAGS; } - /* Tests expect ndots=1 in general, the system config may not default to this - * so we don't want to inherit that. */ - if (!(optmask & ARES_OPT_NDOTS)) { - opts.ndots = 1; - optmask |= ARES_OPT_NDOTS; - } - /* Disable the query cache for tests unless explicitly enabled. As of * c-ares 1.31.0, the query cache is enabled by default so we have to set * the option and set the TTL to 0 to effectively disable it. */ @@ -1023,6 +1045,44 @@ void HostCallback(void *data, int status, int timeouts, if (verbose) std::cerr << "HostCallback(" << *result << ")" << std::endl; } +std::ostream& operator<<(std::ostream& os, const AresDnsRecord& dnsrec) { + os << "{'"; + /* XXX: Todo */ + os << '}'; + return os; +} + +std::ostream& operator<<(std::ostream& os, const QueryResult& result) { + os << '{'; + if (result.done_) { + os << StatusToString(result.status_); + if (result.dnsrec_.dnsrec_ != nullptr) { + os << " " << result.dnsrec_; + } else { + os << ", (no dnsrec)"; + } + } else { + os << "(incomplete)"; + } + os << '}'; + return os; +} + +void QueryCallback(void *data, ares_status_t status, size_t timeouts, + const ares_dns_record_t *dnsrec) { + EXPECT_NE(nullptr, data); + if (data == nullptr) + return; + + QueryResult* result = reinterpret_cast(data); + result->done_ = true; + result->status_ = status; + result->timeouts_ = timeouts; + if (dnsrec) + result->dnsrec_.SetDnsRecord(dnsrec); + if (verbose) std::cerr << "QueryCallback(" << *result << ")" << std::endl; +} + std::ostream& operator<<(std::ostream& os, const AddrInfoResult& result) { os << '{'; if (result.done_ && result.ai_) { diff --git a/lib/c-ares-1.32.3/test/ares-test.h b/lib/c-ares-1.33.1/test/ares-test.h similarity index 81% rename from lib/c-ares-1.32.3/test/ares-test.h rename to lib/c-ares-1.33.1/test/ares-test.h index af37ab64c5c..7342daaa189 100644 --- a/lib/c-ares-1.32.3/test/ares-test.h +++ b/lib/c-ares-1.33.1/test/ares-test.h @@ -85,7 +85,7 @@ extern std::vector> families_modes; extern std::vector> evsys_families_modes; // Hopefully a more accurate sleep than sleep_for() -void ares_sleep_time(unsigned int ms); +void ares_sleep_time(unsigned int ms); // Process all pending work on ares-owned file descriptors, plus // optionally the given set-of-FDs + work function. @@ -220,7 +220,6 @@ class DefaultChannelModeTest ares_channel_t *channel_; }; - // Mock DNS server to allow responses to be scripted by tests. class MockServer { public: @@ -236,7 +235,7 @@ class MockServer { void SetReplyData(const std::vector &reply) { exact_reply_ = reply; - reply_ = nullptr; + reply_ = nullptr; } void SetReply(const DNSPacket *reply) @@ -251,7 +250,7 @@ class MockServer { void SetReplyExpRequest(const DNSPacket *reply, const std::string &request) { expected_request_ = request; - reply_ = reply; + reply_ = reply; } void SetReplyQID(int qid) @@ -291,8 +290,9 @@ class MockServer { private: void ProcessRequest(ares_socket_t fd, struct sockaddr_storage *addr, - ares_socklen_t addrlen, const std::string &reqstr, - int qid, const char *name, int rrtype); + ares_socklen_t addrlen, const std::vector &req, + const std::string &reqstr, int qid, const char *name, + int rrtype); void ProcessPacket(ares_socket_t fd, struct sockaddr_storage *addr, ares_socklen_t addrlen, byte *data, int len); unsigned short udpport_; @@ -311,7 +311,7 @@ class MockServer { // Test fixture that uses a mock DNS server. class MockChannelOptsTest : public LibraryTest { public: - MockChannelOptsTest(int count, int family, bool force_tcp, + MockChannelOptsTest(int count, int family, bool force_tcp, bool honor_sysconfig, struct ares_options *givenopts, int optmask); ~MockChannelOptsTest(); @@ -341,7 +341,7 @@ class MockChannelTest public ::testing::WithParamInterface> { public: MockChannelTest() - : MockChannelOptsTest(1, GetParam().first, GetParam().second, nullptr, 0) + : MockChannelOptsTest(1, GetParam().first, GetParam().second, false, nullptr, 0) { } }; @@ -349,7 +349,7 @@ class MockChannelTest class MockUDPChannelTest : public MockChannelOptsTest, public ::testing::WithParamInterface { public: - MockUDPChannelTest() : MockChannelOptsTest(1, GetParam(), false, nullptr, 0) + MockUDPChannelTest() : MockChannelOptsTest(1, GetParam(), false, false, nullptr, 0) { } }; @@ -357,7 +357,7 @@ class MockUDPChannelTest : public MockChannelOptsTest, class MockTCPChannelTest : public MockChannelOptsTest, public ::testing::WithParamInterface { public: - MockTCPChannelTest() : MockChannelOptsTest(1, GetParam(), true, nullptr, 0) + MockTCPChannelTest() : MockChannelOptsTest(1, GetParam(), true, false, nullptr, 0) { } }; @@ -367,7 +367,7 @@ class MockEventThreadOptsTest : public MockChannelOptsTest { MockEventThreadOptsTest(int count, ares_evsys_t evsys, int family, bool force_tcp, struct ares_options *givenopts, int optmask) - : MockChannelOptsTest(count, family, force_tcp, + : MockChannelOptsTest(count, family, force_tcp, false, FillOptionsET(&evopts_, givenopts, evsys), optmask | ARES_OPT_EVENT_THREAD) { @@ -391,6 +391,7 @@ class MockEventThreadOptsTest : public MockChannelOptsTest { } void Process(unsigned int cancel_ms = 0); + private: struct ares_options evopts_; }; @@ -496,6 +497,51 @@ struct HostResult { std::ostream &operator<<(std::ostream &os, const HostResult &result); +// C++ wrapper for ares_dns_record_t. +struct AresDnsRecord { + ~AresDnsRecord() + { + ares_dns_record_destroy(dnsrec_); + dnsrec_ = NULL; + } + + AresDnsRecord() : dnsrec_(NULL) + { + } + + void SetDnsRecord(const ares_dns_record_t *dnsrec) + { + if (dnsrec_ != NULL) { + ares_dns_record_destroy(dnsrec_); + } + if (dnsrec == NULL) { + return; + } + dnsrec_ = ares_dns_record_duplicate(dnsrec); + } + + ares_dns_record_t *dnsrec_ = NULL; +}; + +std::ostream &operator<<(std::ostream &os, const AresDnsRecord &result); + +// Structure that describes the result of an ares_host_callback invocation. +struct QueryResult { + QueryResult() : done_(false), status_(ARES_SUCCESS), timeouts_(0) + { + } + + // Whether the callback has been invoked. + bool done_; + // Explicitly provided result information. + ares_status_t status_; + size_t timeouts_; + // Contents of the ares_dns_record_t structure if provided + AresDnsRecord dnsrec_; +}; + +std::ostream &operator<<(std::ostream &os, const QueryResult &result); + // Structure that describes the result of an ares_callback invocation. struct SearchResult { // Whether the callback has been invoked. @@ -556,6 +602,8 @@ std::ostream &operator<<(std::ostream &os, const AddrInfoResult &result); // structures. void HostCallback(void *data, int status, int timeouts, struct hostent *hostent); +void QueryCallback(void *data, ares_status_t status, size_t timeouts, + const ares_dns_record_t *dnsrec); void SearchCallback(void *data, int status, int timeouts, unsigned char *abuf, int alen); void SearchCallbackDnsRec(void *data, ares_status_t status, size_t timeouts, @@ -716,6 +764,50 @@ int RunInContainer(ContainerFilesystem *fs, const std::string &hostname, } \ int ICLASS_NAME(casename, testname)::InnerTestBody() +#define CONTAINED_TEST_P(test_suite_name, test_name, hostname, domainname, files) \ + class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \ + : public test_suite_name { \ + public: \ + GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() {} \ + int InnerTestBody(); \ + void TestBody() \ + { \ + ContainerFilesystem chroot(files, ".."); \ + VoidToIntFn fn = \ + [this](void) -> int { \ + ares_reinit(this->channel_); \ + ares_sleep_time(100); \ + return this->InnerTestBody(); \ + }; \ + EXPECT_EQ(0, RunInContainer(&chroot, hostname, domainname, fn)); \ + } \ + \ + private: \ + static int AddToRegistry() { \ + ::testing::UnitTest::GetInstance() \ + ->parameterized_test_registry() \ + .GetTestSuitePatternHolder( \ + GTEST_STRINGIFY_(test_suite_name), \ + ::testing::internal::CodeLocation(__FILE__, __LINE__)) \ + ->AddTestPattern( \ + GTEST_STRINGIFY_(test_suite_name), GTEST_STRINGIFY_(test_name), \ + new ::testing::internal::TestMetaFactory(), \ + ::testing::internal::CodeLocation(__FILE__, __LINE__)); \ + return 0; \ + } \ + static int gtest_registering_dummy_ GTEST_ATTRIBUTE_UNUSED_; \ + GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \ + (const GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) &) = delete; \ + GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) & operator=( \ + const GTEST_TEST_CLASS_NAME_(test_suite_name, \ + test_name) &) = delete; /* NOLINT */ \ + }; \ + int GTEST_TEST_CLASS_NAME_(test_suite_name, \ + test_name)::gtest_registering_dummy_ = \ + GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::AddToRegistry(); \ + int GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::InnerTestBody() + #endif /* Assigns virtual IO functions to a channel. These functions simply call diff --git a/lib/c-ares-1.32.3/test/ares_queryloop.c b/lib/c-ares-1.33.1/test/ares_queryloop.c similarity index 99% rename from lib/c-ares-1.32.3/test/ares_queryloop.c rename to lib/c-ares-1.33.1/test/ares_queryloop.c index 8422de8d751..031c7799400 100644 --- a/lib/c-ares-1.32.3/test/ares_queryloop.c +++ b/lib/c-ares-1.33.1/test/ares_queryloop.c @@ -156,7 +156,8 @@ int main(int argc, char *argv[]) memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; - printf("Attempt %u using server list: %s ...\n", (unsigned int)count, servers); + printf("Attempt %u using server list: %s ...\n", (unsigned int)count, + servers); ares_free_string(servers); ares_getaddrinfo(channel, argv[1], NULL, &hints, ai_callback, argv[1]); diff --git a/lib/c-ares-1.32.3/test/dns-dump.cc b/lib/c-ares-1.33.1/test/dns-dump.cc similarity index 100% rename from lib/c-ares-1.32.3/test/dns-dump.cc rename to lib/c-ares-1.33.1/test/dns-dump.cc diff --git a/lib/c-ares-1.32.3/test/dns-proto-test.cc b/lib/c-ares-1.33.1/test/dns-proto-test.cc similarity index 100% rename from lib/c-ares-1.32.3/test/dns-proto-test.cc rename to lib/c-ares-1.33.1/test/dns-proto-test.cc diff --git a/lib/c-ares-1.32.3/test/dns-proto.cc b/lib/c-ares-1.33.1/test/dns-proto.cc similarity index 84% rename from lib/c-ares-1.32.3/test/dns-proto.cc rename to lib/c-ares-1.33.1/test/dns-proto.cc index f9c7d4d56e3..e26e483a6fc 100644 --- a/lib/c-ares-1.32.3/test/dns-proto.cc +++ b/lib/c-ares-1.33.1/test/dns-proto.cc @@ -548,7 +548,7 @@ std::vector EncodeString(const std::string &name) { return data; } -std::vector DNSQuestion::data(const char *request_name) const { +std::vector DNSQuestion::data(const char *request_name, const ares_dns_record_t *dnsrec) const { std::vector data; std::vector encname; if (request_name != nullptr && strcasecmp(request_name, name_.c_str()) == 0) { @@ -562,14 +562,14 @@ std::vector DNSQuestion::data(const char *request_name) const { return data; } -std::vector DNSRR::data() const { - std::vector data = DNSQuestion::data(); +std::vector DNSRR::data(const ares_dns_record_t *dnsrec) const { + std::vector data = DNSQuestion::data(dnsrec); PushInt32(&data, ttl_); return data; } -std::vector DNSSingleNameRR::data() const { - std::vector data = DNSRR::data(); +std::vector DNSSingleNameRR::data(const ares_dns_record_t *dnsrec) const { + std::vector data = DNSRR::data(dnsrec); std::vector encname = EncodeString(other_); int len = (int)encname.size(); PushInt16(&data, len); @@ -577,8 +577,8 @@ std::vector DNSSingleNameRR::data() const { return data; } -std::vector DNSTxtRR::data() const { - std::vector data = DNSRR::data(); +std::vector DNSTxtRR::data(const ares_dns_record_t *dnsrec) const { + std::vector data = DNSRR::data(dnsrec); int len = 0; for (const std::string& txt : txt_) { len += (1 + (int)txt.size()); @@ -591,8 +591,8 @@ std::vector DNSTxtRR::data() const { return data; } -std::vector DNSMxRR::data() const { - std::vector data = DNSRR::data(); +std::vector DNSMxRR::data(const ares_dns_record_t *dnsrec) const { + std::vector data = DNSRR::data(dnsrec); std::vector encname = EncodeString(other_); int len = 2 + (int)encname.size(); PushInt16(&data, len); @@ -601,8 +601,8 @@ std::vector DNSMxRR::data() const { return data; } -std::vector DNSSrvRR::data() const { - std::vector data = DNSRR::data(); +std::vector DNSSrvRR::data(const ares_dns_record_t *dnsrec) const { + std::vector data = DNSRR::data(dnsrec); std::vector encname = EncodeString(target_); int len = 6 + (int)encname.size(); PushInt16(&data, len); @@ -613,8 +613,8 @@ std::vector DNSSrvRR::data() const { return data; } -std::vector DNSUriRR::data() const { - std::vector data = DNSRR::data(); +std::vector DNSUriRR::data(const ares_dns_record_t *dnsrec) const { + std::vector data = DNSRR::data(dnsrec); int len = 4 + (int)target_.size(); PushInt16(&data, len); PushInt16(&data, prio_); @@ -623,16 +623,16 @@ std::vector DNSUriRR::data() const { return data; } -std::vector DNSAddressRR::data() const { - std::vector data = DNSRR::data(); +std::vector DNSAddressRR::data(const ares_dns_record_t *dnsrec) const { + std::vector data = DNSRR::data(dnsrec); int len = (int)addr_.size(); PushInt16(&data, len); data.insert(data.end(), addr_.begin(), addr_.end()); return data; } -std::vector DNSSoaRR::data() const { - std::vector data = DNSRR::data(); +std::vector DNSSoaRR::data(const ares_dns_record_t *dnsrec) const { + std::vector data = DNSRR::data(dnsrec); std::vector encname1 = EncodeString(nsname_); std::vector encname2 = EncodeString(rname_); int len = (int)encname1.size() + (int)encname2.size() + 5*4; @@ -647,23 +647,81 @@ std::vector DNSSoaRR::data() const { return data; } -std::vector DNSOptRR::data() const { - std::vector data = DNSRR::data(); - int len = 0; +const ares_dns_rr_t *fetch_rr_opt(const ares_dns_record_t *rec) +{ + size_t i; + for (i = 0; i < ares_dns_record_rr_cnt(rec, ARES_SECTION_ADDITIONAL); i++) { + const ares_dns_rr_t *rr = + ares_dns_record_rr_get_const(rec, ARES_SECTION_ADDITIONAL, i); + + if (ares_dns_rr_get_type(rr) == ARES_REC_TYPE_OPT) { + return rr; + } + } + return NULL; +} + +std::vector DNSOptRR::data(const ares_dns_record_t *dnsrec) const { + std::vector data = DNSRR::data(dnsrec); + int len = 0; + std::vector cookie; + const ares_dns_rr_t *rr = fetch_rr_opt(dnsrec); + size_t passed_cookie_len = 0; + const unsigned char *passed_cookie = NULL; + + ares_dns_rr_get_opt_byid(rr, ARES_RR_OPT_OPTIONS, ARES_OPT_PARAM_COOKIE, + &passed_cookie, &passed_cookie_len); + + /* Error out if we expected a server cookie but didn't get one, or if the + * passed in server cookie doesn't match our expected value */ + if (expect_server_cookie_ && + (passed_cookie_len <= 8 || + passed_cookie_len - 8 != server_cookie_.size() || + memcmp(passed_cookie + 8, server_cookie_.data(), server_cookie_.size()) != 0 + ) + ) { + data.clear(); + return data; + } + + /* See if we should be applying a server cookie */ + if (server_cookie_.size() && passed_cookie_len >= 8) { + /* If client cookie was provided to test framework, we are overwriting + * the one received from the client. This is likely to test failure + * scenarios */ + if (client_cookie_.size()) { + cookie.insert(cookie.end(), client_cookie_.begin(), client_cookie_.end()); + } else { + cookie.insert(cookie.end(), passed_cookie, passed_cookie+8); + } + cookie.insert(cookie.end(), server_cookie_.begin(), server_cookie_.end()); + } + + if (cookie.size()) { + len += 4 + (int)cookie.size(); + } for (const DNSOption& opt : opts_) { len += (4 + (int)opt.data_.size()); } + PushInt16(&data, len); for (const DNSOption& opt : opts_) { PushInt16(&data, opt.code_); PushInt16(&data, (int)opt.data_.size()); data.insert(data.end(), opt.data_.begin(), opt.data_.end()); } + + if (cookie.size()) { + PushInt16(&data, ARES_OPT_PARAM_COOKIE); + PushInt16(&data, (int)cookie.size()); + data.insert(data.end(), cookie.begin(), cookie.end()); + } + return data; } -std::vector DNSNaptrRR::data() const { - std::vector data = DNSRR::data(); +std::vector DNSNaptrRR::data(const ares_dns_record_t *dnsrec) const { + std::vector data = DNSRR::data(dnsrec); std::vector encname = EncodeString(replacement_); int len = (4 + 1 + (int)flags_.size() + 1 + (int)service_.size() + 1 + (int)regexp_.size() + (int)encname.size()); PushInt16(&data, len); @@ -679,7 +737,7 @@ std::vector DNSNaptrRR::data() const { return data; } -std::vector DNSPacket::data(const char *request_name) const { +std::vector DNSPacket::data(const char *request_name, const ares_dns_record_t *dnsrec) const { std::vector data; PushInt16(&data, qid_); byte b = 0x00; @@ -707,19 +765,35 @@ std::vector DNSPacket::data(const char *request_name) const { PushInt16(&data, count); for (const std::unique_ptr& question : questions_) { - std::vector qdata = question->data(request_name); + std::vector qdata = question->data(request_name, dnsrec); + if (qdata.size() == 0) { + data.clear(); + return data; + } data.insert(data.end(), qdata.begin(), qdata.end()); } for (const std::unique_ptr& rr : answers_) { - std::vector rrdata = rr->data(); + std::vector rrdata = rr->data(dnsrec); + if (rrdata.size() == 0) { + data.clear(); + return data; + } data.insert(data.end(), rrdata.begin(), rrdata.end()); } for (const std::unique_ptr& rr : auths_) { - std::vector rrdata = rr->data(); + std::vector rrdata = rr->data(dnsrec); + if (rrdata.size() == 0) { + data.clear(); + return data; + } data.insert(data.end(), rrdata.begin(), rrdata.end()); } for (const std::unique_ptr& rr : adds_) { - std::vector rrdata = rr->data(); + std::vector rrdata = rr->data(dnsrec); + if (rrdata.size() == 0) { + data.clear(); + return data; + } data.insert(data.end(), rrdata.begin(), rrdata.end()); } return data; diff --git a/lib/c-ares-1.32.3/test/dns-proto.h b/lib/c-ares-1.33.1/test/dns-proto.h similarity index 83% rename from lib/c-ares-1.32.3/test/dns-proto.h rename to lib/c-ares-1.33.1/test/dns-proto.h index 88e0a23cdc1..e42600d25ca 100644 --- a/lib/c-ares-1.32.3/test/dns-proto.h +++ b/lib/c-ares-1.33.1/test/dns-proto.h @@ -36,7 +36,8 @@ #include #include -extern "C" void arestest_strtolower(char *dest, const char *src, size_t dest_size); +extern "C" void arestest_strtolower(char *dest, const char *src, + size_t dest_size); namespace ares { @@ -52,6 +53,8 @@ std::string RRTypeToString(int rrtype); std::string ClassToString(int qclass); std::string AddressToString(const void *addr, int len); +const ares_dns_rr_t *fetch_rr_opt(const ares_dns_record_t *rec); + // Convert DNS protocol data to strings. // Note that these functions are not defensive; they assume // a validly formatted input, and so should not be used on @@ -83,16 +86,22 @@ struct DNSQuestion { { } - virtual std::vector data(const char *request_name) const; + virtual std::vector data(const char *request_name, + const ares_dns_record_t *dnsrec) const; + + virtual std::vector data(const ares_dns_record_t *dnsrec) const + { + return data(nullptr, dnsrec); + } virtual std::vector data() const { - return data(nullptr); + return data(nullptr, nullptr); } - std::string name_; - int rrtype_; - int qclass_; + std::string name_; + int rrtype_; + int qclass_; }; struct DNSRR : public DNSQuestion { @@ -110,7 +119,7 @@ struct DNSRR : public DNSQuestion { { } - virtual std::vector data() const = 0; + virtual std::vector data(const ares_dns_record_t *dnsrec) const = 0; int ttl_; }; @@ -127,7 +136,7 @@ struct DNSAddressRR : public DNSRR { { } - virtual std::vector data() const; + virtual std::vector data(const ares_dns_record_t *dnsrec) const; std::vector addr_; }; @@ -162,7 +171,7 @@ struct DNSSingleNameRR : public DNSRR { { } - virtual std::vector data() const; + virtual std::vector data(const ares_dns_record_t *dnsrec) const; std::string other_; }; @@ -194,7 +203,7 @@ struct DNSTxtRR : public DNSRR { { } - virtual std::vector data() const; + virtual std::vector data(const ares_dns_record_t *dnsrec) const; std::vector txt_; }; @@ -204,7 +213,7 @@ struct DNSMxRR : public DNSRR { { } - virtual std::vector data() const; + virtual std::vector data(const ares_dns_record_t *dnsrec) const; int pref_; std::string other_; }; @@ -217,7 +226,7 @@ struct DNSSrvRR : public DNSRR { { } - virtual std::vector data() const; + virtual std::vector data(const ares_dns_record_t *dnsrec) const; int prio_; int weight_; int port_; @@ -231,7 +240,7 @@ struct DNSUriRR : public DNSRR { { } - virtual std::vector data() const; + virtual std::vector data(const ares_dns_record_t *dnsrec) const; int prio_; int weight_; std::string target_; @@ -246,7 +255,7 @@ struct DNSSoaRR : public DNSRR { { } - virtual std::vector data() const; + virtual std::vector data(const ares_dns_record_t *dnsrec) const; std::string nsname_; std::string rname_; int serial_; @@ -265,7 +274,7 @@ struct DNSNaptrRR : public DNSRR { { } - virtual std::vector data() const; + virtual std::vector data(const ares_dns_record_t *dnsrec) const; int order_; int pref_; std::string flags_; @@ -280,13 +289,23 @@ struct DNSOption { }; struct DNSOptRR : public DNSRR { - DNSOptRR(int extrcode, int udpsize) - : DNSRR("", T_OPT, static_cast(udpsize), extrcode) + DNSOptRR(unsigned char extrcode, unsigned char version, unsigned short flags, + int udpsize, std::vector client_cookie, + std::vector server_cookie, bool expect_server_cookie) + : DNSRR("", T_OPT, static_cast(udpsize), + ((int)extrcode) << 24 | ((int)version) << 16 | + ((int)flags) /* ttl */) { + client_cookie_ = client_cookie; + server_cookie_ = server_cookie; + expect_server_cookie_ = expect_server_cookie; } - virtual std::vector data() const; + virtual std::vector data(const ares_dns_record_t *dnsrec) const; std::vector opts_; + std::vector client_cookie_; + std::vector server_cookie_; + bool expect_server_cookie_; }; struct DNSPacket { @@ -383,13 +402,14 @@ struct DNSPacket { } // Return the encoded packet. - std::vector data(const char *request_name) const; - std::vector data() const + std::vector data(const char *request_name, + const ares_dns_record_t *dnsrec) const; + + std::vector data() const { - return data(nullptr); + return data(nullptr, nullptr); } - int qid_; bool response_; int opcode_; diff --git a/lib/c-ares-1.32.3/test/fuzzcheck.sh b/lib/c-ares-1.33.1/test/fuzzcheck.sh similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzcheck.sh rename to lib/c-ares-1.33.1/test/fuzzcheck.sh diff --git a/lib/c-ares-1.32.3/test/fuzzinput/004a216d3cff18b0c5c6b68b807f1529 b/lib/c-ares-1.33.1/test/fuzzinput/004a216d3cff18b0c5c6b68b807f1529 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/004a216d3cff18b0c5c6b68b807f1529 rename to lib/c-ares-1.33.1/test/fuzzinput/004a216d3cff18b0c5c6b68b807f1529 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/00539467ca159b36aea95e61f9729115 b/lib/c-ares-1.33.1/test/fuzzinput/00539467ca159b36aea95e61f9729115 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/00539467ca159b36aea95e61f9729115 rename to lib/c-ares-1.33.1/test/fuzzinput/00539467ca159b36aea95e61f9729115 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/00e846db8f43f2f507cd1666ed5a753e b/lib/c-ares-1.33.1/test/fuzzinput/00e846db8f43f2f507cd1666ed5a753e similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/00e846db8f43f2f507cd1666ed5a753e rename to lib/c-ares-1.33.1/test/fuzzinput/00e846db8f43f2f507cd1666ed5a753e diff --git a/lib/c-ares-1.32.3/test/fuzzinput/0177b7566f08c013699eaea9a77abeb3 b/lib/c-ares-1.33.1/test/fuzzinput/0177b7566f08c013699eaea9a77abeb3 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/0177b7566f08c013699eaea9a77abeb3 rename to lib/c-ares-1.33.1/test/fuzzinput/0177b7566f08c013699eaea9a77abeb3 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/020a4fa317715bfdb236ed13751e6b65 b/lib/c-ares-1.33.1/test/fuzzinput/020a4fa317715bfdb236ed13751e6b65 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/020a4fa317715bfdb236ed13751e6b65 rename to lib/c-ares-1.33.1/test/fuzzinput/020a4fa317715bfdb236ed13751e6b65 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/0310f2e81bea31f4fe3f330872a877dd b/lib/c-ares-1.33.1/test/fuzzinput/0310f2e81bea31f4fe3f330872a877dd similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/0310f2e81bea31f4fe3f330872a877dd rename to lib/c-ares-1.33.1/test/fuzzinput/0310f2e81bea31f4fe3f330872a877dd diff --git a/lib/c-ares-1.32.3/test/fuzzinput/0449be67df1730b2d0887d412a9b7cc4 b/lib/c-ares-1.33.1/test/fuzzinput/0449be67df1730b2d0887d412a9b7cc4 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/0449be67df1730b2d0887d412a9b7cc4 rename to lib/c-ares-1.33.1/test/fuzzinput/0449be67df1730b2d0887d412a9b7cc4 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/0449dd14f7aa94bf0d716bfe09b287a8 b/lib/c-ares-1.33.1/test/fuzzinput/0449dd14f7aa94bf0d716bfe09b287a8 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/0449dd14f7aa94bf0d716bfe09b287a8 rename to lib/c-ares-1.33.1/test/fuzzinput/0449dd14f7aa94bf0d716bfe09b287a8 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/04c93cdf7208979aa4df80a3a0d5a2d8 b/lib/c-ares-1.33.1/test/fuzzinput/04c93cdf7208979aa4df80a3a0d5a2d8 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/04c93cdf7208979aa4df80a3a0d5a2d8 rename to lib/c-ares-1.33.1/test/fuzzinput/04c93cdf7208979aa4df80a3a0d5a2d8 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/0567e7171e08e75f3f91c4ca74c17adc b/lib/c-ares-1.33.1/test/fuzzinput/0567e7171e08e75f3f91c4ca74c17adc similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/0567e7171e08e75f3f91c4ca74c17adc rename to lib/c-ares-1.33.1/test/fuzzinput/0567e7171e08e75f3f91c4ca74c17adc diff --git a/lib/c-ares-1.32.3/test/fuzzinput/05ba948578a397e9cbc6a7b3e78622fa b/lib/c-ares-1.33.1/test/fuzzinput/05ba948578a397e9cbc6a7b3e78622fa similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/05ba948578a397e9cbc6a7b3e78622fa rename to lib/c-ares-1.33.1/test/fuzzinput/05ba948578a397e9cbc6a7b3e78622fa diff --git a/lib/c-ares-1.32.3/test/fuzzinput/060afe5ed25f3e2e86167e545f27edca b/lib/c-ares-1.33.1/test/fuzzinput/060afe5ed25f3e2e86167e545f27edca similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/060afe5ed25f3e2e86167e545f27edca rename to lib/c-ares-1.33.1/test/fuzzinput/060afe5ed25f3e2e86167e545f27edca diff --git a/lib/c-ares-1.32.3/test/fuzzinput/06d47d3681493f1b1d41236f460d896f b/lib/c-ares-1.33.1/test/fuzzinput/06d47d3681493f1b1d41236f460d896f similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/06d47d3681493f1b1d41236f460d896f rename to lib/c-ares-1.33.1/test/fuzzinput/06d47d3681493f1b1d41236f460d896f diff --git a/lib/c-ares-1.32.3/test/fuzzinput/0724a810b0e131c2fddb6de9003b9064 b/lib/c-ares-1.33.1/test/fuzzinput/0724a810b0e131c2fddb6de9003b9064 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/0724a810b0e131c2fddb6de9003b9064 rename to lib/c-ares-1.33.1/test/fuzzinput/0724a810b0e131c2fddb6de9003b9064 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/0b5279148826f5b962bcf1896bdb4ede b/lib/c-ares-1.33.1/test/fuzzinput/0b5279148826f5b962bcf1896bdb4ede similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/0b5279148826f5b962bcf1896bdb4ede rename to lib/c-ares-1.33.1/test/fuzzinput/0b5279148826f5b962bcf1896bdb4ede diff --git a/lib/c-ares-1.32.3/test/fuzzinput/114048c0f6b10bdc67ce9166405d195e b/lib/c-ares-1.33.1/test/fuzzinput/114048c0f6b10bdc67ce9166405d195e similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/114048c0f6b10bdc67ce9166405d195e rename to lib/c-ares-1.33.1/test/fuzzinput/114048c0f6b10bdc67ce9166405d195e diff --git a/lib/c-ares-1.32.3/test/fuzzinput/11b8464a0ef8735d202955c34c36b0c7 b/lib/c-ares-1.33.1/test/fuzzinput/11b8464a0ef8735d202955c34c36b0c7 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/11b8464a0ef8735d202955c34c36b0c7 rename to lib/c-ares-1.33.1/test/fuzzinput/11b8464a0ef8735d202955c34c36b0c7 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/11cb626f1668c7b41954ce7d768fe528 b/lib/c-ares-1.33.1/test/fuzzinput/11cb626f1668c7b41954ce7d768fe528 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/11cb626f1668c7b41954ce7d768fe528 rename to lib/c-ares-1.33.1/test/fuzzinput/11cb626f1668c7b41954ce7d768fe528 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/14b133bf18125b75a1976fa63a1df6b7 b/lib/c-ares-1.33.1/test/fuzzinput/14b133bf18125b75a1976fa63a1df6b7 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/14b133bf18125b75a1976fa63a1df6b7 rename to lib/c-ares-1.33.1/test/fuzzinput/14b133bf18125b75a1976fa63a1df6b7 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/153c6b3afa8faa03c8bc28f936a6d4cf b/lib/c-ares-1.33.1/test/fuzzinput/153c6b3afa8faa03c8bc28f936a6d4cf similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/153c6b3afa8faa03c8bc28f936a6d4cf rename to lib/c-ares-1.33.1/test/fuzzinput/153c6b3afa8faa03c8bc28f936a6d4cf diff --git a/lib/c-ares-1.32.3/test/fuzzinput/182cad2a342ed7317b7c21a5d17020d1 b/lib/c-ares-1.33.1/test/fuzzinput/182cad2a342ed7317b7c21a5d17020d1 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/182cad2a342ed7317b7c21a5d17020d1 rename to lib/c-ares-1.33.1/test/fuzzinput/182cad2a342ed7317b7c21a5d17020d1 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/1c61a61bb7057b52c5b15188345a5238 b/lib/c-ares-1.33.1/test/fuzzinput/1c61a61bb7057b52c5b15188345a5238 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/1c61a61bb7057b52c5b15188345a5238 rename to lib/c-ares-1.33.1/test/fuzzinput/1c61a61bb7057b52c5b15188345a5238 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/1dbe2cf62ed2e4fa1c3cb473f08710b5 b/lib/c-ares-1.33.1/test/fuzzinput/1dbe2cf62ed2e4fa1c3cb473f08710b5 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/1dbe2cf62ed2e4fa1c3cb473f08710b5 rename to lib/c-ares-1.33.1/test/fuzzinput/1dbe2cf62ed2e4fa1c3cb473f08710b5 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/21199be504fcfece5c7096ee0dbba507 b/lib/c-ares-1.33.1/test/fuzzinput/21199be504fcfece5c7096ee0dbba507 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/21199be504fcfece5c7096ee0dbba507 rename to lib/c-ares-1.33.1/test/fuzzinput/21199be504fcfece5c7096ee0dbba507 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/21891480074b5635dbbe7137bdcabccd b/lib/c-ares-1.33.1/test/fuzzinput/21891480074b5635dbbe7137bdcabccd similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/21891480074b5635dbbe7137bdcabccd rename to lib/c-ares-1.33.1/test/fuzzinput/21891480074b5635dbbe7137bdcabccd diff --git a/lib/c-ares-1.32.3/test/fuzzinput/233aea42e15aa73e131eefabf16088c9 b/lib/c-ares-1.33.1/test/fuzzinput/233aea42e15aa73e131eefabf16088c9 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/233aea42e15aa73e131eefabf16088c9 rename to lib/c-ares-1.33.1/test/fuzzinput/233aea42e15aa73e131eefabf16088c9 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/24660d4e7ac7aa21d600ea7a3d198bbb b/lib/c-ares-1.33.1/test/fuzzinput/24660d4e7ac7aa21d600ea7a3d198bbb similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/24660d4e7ac7aa21d600ea7a3d198bbb rename to lib/c-ares-1.33.1/test/fuzzinput/24660d4e7ac7aa21d600ea7a3d198bbb diff --git a/lib/c-ares-1.32.3/test/fuzzinput/25589deb55c08429345f289d1c9b0254 b/lib/c-ares-1.33.1/test/fuzzinput/25589deb55c08429345f289d1c9b0254 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/25589deb55c08429345f289d1c9b0254 rename to lib/c-ares-1.33.1/test/fuzzinput/25589deb55c08429345f289d1c9b0254 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/2573bd823e4da11f727a17f8e1f35c26 b/lib/c-ares-1.33.1/test/fuzzinput/2573bd823e4da11f727a17f8e1f35c26 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/2573bd823e4da11f727a17f8e1f35c26 rename to lib/c-ares-1.33.1/test/fuzzinput/2573bd823e4da11f727a17f8e1f35c26 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/276f12da56866273e76059ad0e7be97e b/lib/c-ares-1.33.1/test/fuzzinput/276f12da56866273e76059ad0e7be97e similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/276f12da56866273e76059ad0e7be97e rename to lib/c-ares-1.33.1/test/fuzzinput/276f12da56866273e76059ad0e7be97e diff --git a/lib/c-ares-1.32.3/test/fuzzinput/29198a2e380cb19babec9e02116d213e b/lib/c-ares-1.33.1/test/fuzzinput/29198a2e380cb19babec9e02116d213e similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/29198a2e380cb19babec9e02116d213e rename to lib/c-ares-1.33.1/test/fuzzinput/29198a2e380cb19babec9e02116d213e diff --git a/lib/c-ares-1.32.3/test/fuzzinput/2c94ba9434b1a1b9396fc5364f101363 b/lib/c-ares-1.33.1/test/fuzzinput/2c94ba9434b1a1b9396fc5364f101363 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/2c94ba9434b1a1b9396fc5364f101363 rename to lib/c-ares-1.33.1/test/fuzzinput/2c94ba9434b1a1b9396fc5364f101363 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/2d578c357dc2f5e02dc55cddb30641d1 b/lib/c-ares-1.33.1/test/fuzzinput/2d578c357dc2f5e02dc55cddb30641d1 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/2d578c357dc2f5e02dc55cddb30641d1 rename to lib/c-ares-1.33.1/test/fuzzinput/2d578c357dc2f5e02dc55cddb30641d1 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/2dff6cc5a223e67fde9e5e79af456992 b/lib/c-ares-1.33.1/test/fuzzinput/2dff6cc5a223e67fde9e5e79af456992 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/2dff6cc5a223e67fde9e5e79af456992 rename to lib/c-ares-1.33.1/test/fuzzinput/2dff6cc5a223e67fde9e5e79af456992 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/2f103b1f9477f2d8934bd84328d51c75 b/lib/c-ares-1.33.1/test/fuzzinput/2f103b1f9477f2d8934bd84328d51c75 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/2f103b1f9477f2d8934bd84328d51c75 rename to lib/c-ares-1.33.1/test/fuzzinput/2f103b1f9477f2d8934bd84328d51c75 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/31cd3a8413de13d9624adbb1613784bf b/lib/c-ares-1.33.1/test/fuzzinput/31cd3a8413de13d9624adbb1613784bf similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/31cd3a8413de13d9624adbb1613784bf rename to lib/c-ares-1.33.1/test/fuzzinput/31cd3a8413de13d9624adbb1613784bf diff --git a/lib/c-ares-1.32.3/test/fuzzinput/36415bdf1d180098fe6234b4186e69f3 b/lib/c-ares-1.33.1/test/fuzzinput/36415bdf1d180098fe6234b4186e69f3 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/36415bdf1d180098fe6234b4186e69f3 rename to lib/c-ares-1.33.1/test/fuzzinput/36415bdf1d180098fe6234b4186e69f3 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/3a04a80f0242e8dff0cd732e7c4767da b/lib/c-ares-1.33.1/test/fuzzinput/3a04a80f0242e8dff0cd732e7c4767da similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/3a04a80f0242e8dff0cd732e7c4767da rename to lib/c-ares-1.33.1/test/fuzzinput/3a04a80f0242e8dff0cd732e7c4767da diff --git a/lib/c-ares-1.32.3/test/fuzzinput/44d0f973b7b0fb3e4a07770c943dcd5a b/lib/c-ares-1.33.1/test/fuzzinput/44d0f973b7b0fb3e4a07770c943dcd5a similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/44d0f973b7b0fb3e4a07770c943dcd5a rename to lib/c-ares-1.33.1/test/fuzzinput/44d0f973b7b0fb3e4a07770c943dcd5a diff --git a/lib/c-ares-1.32.3/test/fuzzinput/50bc00daa0ddcd6cfb2b5d9f62c81f47 b/lib/c-ares-1.33.1/test/fuzzinput/50bc00daa0ddcd6cfb2b5d9f62c81f47 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/50bc00daa0ddcd6cfb2b5d9f62c81f47 rename to lib/c-ares-1.33.1/test/fuzzinput/50bc00daa0ddcd6cfb2b5d9f62c81f47 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/51ed2d1fb77b3078b54e94e85606b7df b/lib/c-ares-1.33.1/test/fuzzinput/51ed2d1fb77b3078b54e94e85606b7df similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/51ed2d1fb77b3078b54e94e85606b7df rename to lib/c-ares-1.33.1/test/fuzzinput/51ed2d1fb77b3078b54e94e85606b7df diff --git a/lib/c-ares-1.32.3/test/fuzzinput/5c5e0e899cf2e7d053a9e45fb76f6e5a b/lib/c-ares-1.33.1/test/fuzzinput/5c5e0e899cf2e7d053a9e45fb76f6e5a similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/5c5e0e899cf2e7d053a9e45fb76f6e5a rename to lib/c-ares-1.33.1/test/fuzzinput/5c5e0e899cf2e7d053a9e45fb76f6e5a diff --git a/lib/c-ares-1.32.3/test/fuzzinput/70152ed033f139443fbfb1b858bb3b1b b/lib/c-ares-1.33.1/test/fuzzinput/70152ed033f139443fbfb1b858bb3b1b similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/70152ed033f139443fbfb1b858bb3b1b rename to lib/c-ares-1.33.1/test/fuzzinput/70152ed033f139443fbfb1b858bb3b1b diff --git a/lib/c-ares-1.32.3/test/fuzzinput/7030ca2b24e5a7f9dd8f62096a48eb33 b/lib/c-ares-1.33.1/test/fuzzinput/7030ca2b24e5a7f9dd8f62096a48eb33 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/7030ca2b24e5a7f9dd8f62096a48eb33 rename to lib/c-ares-1.33.1/test/fuzzinput/7030ca2b24e5a7f9dd8f62096a48eb33 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/71eec1a0ef2d25bb9e2ef17f23be7e9e b/lib/c-ares-1.33.1/test/fuzzinput/71eec1a0ef2d25bb9e2ef17f23be7e9e similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/71eec1a0ef2d25bb9e2ef17f23be7e9e rename to lib/c-ares-1.33.1/test/fuzzinput/71eec1a0ef2d25bb9e2ef17f23be7e9e diff --git a/lib/c-ares-1.32.3/test/fuzzinput/7a6b0177210ea4ef40b254daf99393c5 b/lib/c-ares-1.33.1/test/fuzzinput/7a6b0177210ea4ef40b254daf99393c5 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/7a6b0177210ea4ef40b254daf99393c5 rename to lib/c-ares-1.33.1/test/fuzzinput/7a6b0177210ea4ef40b254daf99393c5 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/7f1567733711ffb61839621af0cbfa33 b/lib/c-ares-1.33.1/test/fuzzinput/7f1567733711ffb61839621af0cbfa33 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/7f1567733711ffb61839621af0cbfa33 rename to lib/c-ares-1.33.1/test/fuzzinput/7f1567733711ffb61839621af0cbfa33 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/850c6d57c5bb7be8205fc2438d14d7e5 b/lib/c-ares-1.33.1/test/fuzzinput/850c6d57c5bb7be8205fc2438d14d7e5 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/850c6d57c5bb7be8205fc2438d14d7e5 rename to lib/c-ares-1.33.1/test/fuzzinput/850c6d57c5bb7be8205fc2438d14d7e5 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/a5c8cd2784a5792b9e91c2d7895b3b34 b/lib/c-ares-1.33.1/test/fuzzinput/a5c8cd2784a5792b9e91c2d7895b3b34 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/a5c8cd2784a5792b9e91c2d7895b3b34 rename to lib/c-ares-1.33.1/test/fuzzinput/a5c8cd2784a5792b9e91c2d7895b3b34 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/a9135cdc7151d023300ff194bad90af9 b/lib/c-ares-1.33.1/test/fuzzinput/a9135cdc7151d023300ff194bad90af9 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/a9135cdc7151d023300ff194bad90af9 rename to lib/c-ares-1.33.1/test/fuzzinput/a9135cdc7151d023300ff194bad90af9 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/af2597e8ac7dec1e8b4a47518312912a b/lib/c-ares-1.33.1/test/fuzzinput/af2597e8ac7dec1e8b4a47518312912a similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/af2597e8ac7dec1e8b4a47518312912a rename to lib/c-ares-1.33.1/test/fuzzinput/af2597e8ac7dec1e8b4a47518312912a diff --git a/lib/c-ares-1.32.3/test/fuzzinput/answer_a b/lib/c-ares-1.33.1/test/fuzzinput/answer_a similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/answer_a rename to lib/c-ares-1.33.1/test/fuzzinput/answer_a diff --git a/lib/c-ares-1.32.3/test/fuzzinput/answer_aaaa b/lib/c-ares-1.33.1/test/fuzzinput/answer_aaaa similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/answer_aaaa rename to lib/c-ares-1.33.1/test/fuzzinput/answer_aaaa diff --git a/lib/c-ares-1.32.3/test/fuzzinput/b3f53ef826b831bb09dd25c7f5960249 b/lib/c-ares-1.33.1/test/fuzzinput/b3f53ef826b831bb09dd25c7f5960249 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/b3f53ef826b831bb09dd25c7f5960249 rename to lib/c-ares-1.33.1/test/fuzzinput/b3f53ef826b831bb09dd25c7f5960249 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/cda0f8751f5c4993974c2b549d29bcc8 b/lib/c-ares-1.33.1/test/fuzzinput/cda0f8751f5c4993974c2b549d29bcc8 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/cda0f8751f5c4993974c2b549d29bcc8 rename to lib/c-ares-1.33.1/test/fuzzinput/cda0f8751f5c4993974c2b549d29bcc8 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/ce6c26c0e469339873d0e7f616ab0945 b/lib/c-ares-1.33.1/test/fuzzinput/ce6c26c0e469339873d0e7f616ab0945 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/ce6c26c0e469339873d0e7f616ab0945 rename to lib/c-ares-1.33.1/test/fuzzinput/ce6c26c0e469339873d0e7f616ab0945 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/clusterfuzz-5637790584012800 b/lib/c-ares-1.33.1/test/fuzzinput/clusterfuzz-5637790584012800 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/clusterfuzz-5637790584012800 rename to lib/c-ares-1.33.1/test/fuzzinput/clusterfuzz-5637790584012800 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/clusterfuzz-5650695891451904 b/lib/c-ares-1.33.1/test/fuzzinput/clusterfuzz-5650695891451904 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/clusterfuzz-5650695891451904 rename to lib/c-ares-1.33.1/test/fuzzinput/clusterfuzz-5650695891451904 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/clusterfuzz-5651369832218624 b/lib/c-ares-1.33.1/test/fuzzinput/clusterfuzz-5651369832218624 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/clusterfuzz-5651369832218624 rename to lib/c-ares-1.33.1/test/fuzzinput/clusterfuzz-5651369832218624 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/clusterfuzz-5674462260756480 b/lib/c-ares-1.33.1/test/fuzzinput/clusterfuzz-5674462260756480 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/clusterfuzz-5674462260756480 rename to lib/c-ares-1.33.1/test/fuzzinput/clusterfuzz-5674462260756480 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/clusterfuzz-5680630672654336 b/lib/c-ares-1.33.1/test/fuzzinput/clusterfuzz-5680630672654336 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/clusterfuzz-5680630672654336 rename to lib/c-ares-1.33.1/test/fuzzinput/clusterfuzz-5680630672654336 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/clusterfuzz-5683497160671232 b/lib/c-ares-1.33.1/test/fuzzinput/clusterfuzz-5683497160671232 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/clusterfuzz-5683497160671232 rename to lib/c-ares-1.33.1/test/fuzzinput/clusterfuzz-5683497160671232 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/clusterfuzz-5687310655422464 b/lib/c-ares-1.33.1/test/fuzzinput/clusterfuzz-5687310655422464 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/clusterfuzz-5687310655422464 rename to lib/c-ares-1.33.1/test/fuzzinput/clusterfuzz-5687310655422464 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/clusterfuzz-5695341573177344 b/lib/c-ares-1.33.1/test/fuzzinput/clusterfuzz-5695341573177344 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/clusterfuzz-5695341573177344 rename to lib/c-ares-1.33.1/test/fuzzinput/clusterfuzz-5695341573177344 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/clusterfuzz-5697835103682560 b/lib/c-ares-1.33.1/test/fuzzinput/clusterfuzz-5697835103682560 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/clusterfuzz-5697835103682560 rename to lib/c-ares-1.33.1/test/fuzzinput/clusterfuzz-5697835103682560 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/clusterfuzz-5728518081609728 b/lib/c-ares-1.33.1/test/fuzzinput/clusterfuzz-5728518081609728 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/clusterfuzz-5728518081609728 rename to lib/c-ares-1.33.1/test/fuzzinput/clusterfuzz-5728518081609728 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/clusterfuzz-5732960017317888 b/lib/c-ares-1.33.1/test/fuzzinput/clusterfuzz-5732960017317888 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/clusterfuzz-5732960017317888 rename to lib/c-ares-1.33.1/test/fuzzinput/clusterfuzz-5732960017317888 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/e4dd7e7c2dd4ed7c2e17a6af5d04f9c9 b/lib/c-ares-1.33.1/test/fuzzinput/e4dd7e7c2dd4ed7c2e17a6af5d04f9c9 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/e4dd7e7c2dd4ed7c2e17a6af5d04f9c9 rename to lib/c-ares-1.33.1/test/fuzzinput/e4dd7e7c2dd4ed7c2e17a6af5d04f9c9 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/ed50ed8ee36230a5a69746ad830437e5 b/lib/c-ares-1.33.1/test/fuzzinput/ed50ed8ee36230a5a69746ad830437e5 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/ed50ed8ee36230a5a69746ad830437e5 rename to lib/c-ares-1.33.1/test/fuzzinput/ed50ed8ee36230a5a69746ad830437e5 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/f1b900d50806021953321c3b604ee497 b/lib/c-ares-1.33.1/test/fuzzinput/f1b900d50806021953321c3b604ee497 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/f1b900d50806021953321c3b604ee497 rename to lib/c-ares-1.33.1/test/fuzzinput/f1b900d50806021953321c3b604ee497 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/f6606f624be8c628328cea01d2cd07a9 b/lib/c-ares-1.33.1/test/fuzzinput/f6606f624be8c628328cea01d2cd07a9 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/f6606f624be8c628328cea01d2cd07a9 rename to lib/c-ares-1.33.1/test/fuzzinput/f6606f624be8c628328cea01d2cd07a9 diff --git a/lib/c-ares-1.32.3/test/fuzzinput/f89f6c8176b564a7dd646f14305573ce b/lib/c-ares-1.33.1/test/fuzzinput/f89f6c8176b564a7dd646f14305573ce similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/f89f6c8176b564a7dd646f14305573ce rename to lib/c-ares-1.33.1/test/fuzzinput/f89f6c8176b564a7dd646f14305573ce diff --git a/lib/c-ares-1.32.3/test/fuzzinput/f9ad508d2dbd08d3aaaabc7d1174677d b/lib/c-ares-1.33.1/test/fuzzinput/f9ad508d2dbd08d3aaaabc7d1174677d similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/f9ad508d2dbd08d3aaaabc7d1174677d rename to lib/c-ares-1.33.1/test/fuzzinput/f9ad508d2dbd08d3aaaabc7d1174677d diff --git a/lib/c-ares-1.32.3/test/fuzzinput/multi-indir b/lib/c-ares-1.33.1/test/fuzzinput/multi-indir similarity index 100% rename from lib/c-ares-1.32.3/test/fuzzinput/multi-indir rename to lib/c-ares-1.33.1/test/fuzzinput/multi-indir diff --git a/lib/c-ares-1.32.3/test/fuzznames/name01 b/lib/c-ares-1.33.1/test/fuzznames/name01 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzznames/name01 rename to lib/c-ares-1.33.1/test/fuzznames/name01 diff --git a/lib/c-ares-1.32.3/test/fuzznames/name02 b/lib/c-ares-1.33.1/test/fuzznames/name02 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzznames/name02 rename to lib/c-ares-1.33.1/test/fuzznames/name02 diff --git a/lib/c-ares-1.32.3/test/fuzznames/name03 b/lib/c-ares-1.33.1/test/fuzznames/name03 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzznames/name03 rename to lib/c-ares-1.33.1/test/fuzznames/name03 diff --git a/lib/c-ares-1.32.3/test/fuzznames/name04 b/lib/c-ares-1.33.1/test/fuzznames/name04 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzznames/name04 rename to lib/c-ares-1.33.1/test/fuzznames/name04 diff --git a/lib/c-ares-1.32.3/test/fuzznames/name05 b/lib/c-ares-1.33.1/test/fuzznames/name05 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzznames/name05 rename to lib/c-ares-1.33.1/test/fuzznames/name05 diff --git a/lib/c-ares-1.32.3/test/fuzznames/name06 b/lib/c-ares-1.33.1/test/fuzznames/name06 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzznames/name06 rename to lib/c-ares-1.33.1/test/fuzznames/name06 diff --git a/lib/c-ares-1.32.3/test/fuzznames/name07 b/lib/c-ares-1.33.1/test/fuzznames/name07 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzznames/name07 rename to lib/c-ares-1.33.1/test/fuzznames/name07 diff --git a/lib/c-ares-1.32.3/test/fuzznames/name08 b/lib/c-ares-1.33.1/test/fuzznames/name08 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzznames/name08 rename to lib/c-ares-1.33.1/test/fuzznames/name08 diff --git a/lib/c-ares-1.32.3/test/fuzznames/name09 b/lib/c-ares-1.33.1/test/fuzznames/name09 similarity index 100% rename from lib/c-ares-1.32.3/test/fuzznames/name09 rename to lib/c-ares-1.33.1/test/fuzznames/name09 From 89f993176b7e15bb09aa85280fe721e110a9daac Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Thu, 22 Aug 2024 23:09:52 +0200 Subject: [PATCH 117/295] tests: internal: added cpu byte order test cases Signed-off-by: Leonardo Alminana --- tests/internal/CMakeLists.txt | 1 + tests/internal/endianness.c | 32 ++++++++++++ tests/internal/log_event_encoder.c | 78 ++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 tests/internal/endianness.c diff --git a/tests/internal/CMakeLists.txt b/tests/internal/CMakeLists.txt index 7fe08ea0d8f..61009c1b544 100644 --- a/tests/internal/CMakeLists.txt +++ b/tests/internal/CMakeLists.txt @@ -43,6 +43,7 @@ set(UNIT_TESTS_FILES processor.c uri.c msgpack_append_message.c + endianness ) # Config format diff --git a/tests/internal/endianness.c b/tests/internal/endianness.c new file mode 100644 index 00000000000..8ab5f3de575 --- /dev/null +++ b/tests/internal/endianness.c @@ -0,0 +1,32 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +#include +#include + +#include "flb_tests_internal.h" + +/* This test case sets a specific value to a variable and compares + * the memory representation against the byte order detected by + * cmake. + */ +static void flb_test_endianness_detection() +{ + volatile uint64_t source_value; + volatile uint8_t *test_value; + + /* ~TEA, COFFEE */ + source_value = 0x08140C0FFEE; + test_value = (volatile uint8_t *) &source_value; + +#if FLB_BYTE_ORDER == FLB_LITTLE_ENDIAN + TEST_CHECK(test_value[0] == 0xEE); +#else + TEST_CHECK(test_value[0] != 0xEE); +#endif +} + +TEST_LIST = { + { "test_endianness_detection", flb_test_endianness_detection }, + + { 0 } +}; diff --git a/tests/internal/log_event_encoder.c b/tests/internal/log_event_encoder.c index 21c26408c5b..99f67eb2777 100644 --- a/tests/internal/log_event_encoder.c +++ b/tests/internal/log_event_encoder.c @@ -650,6 +650,83 @@ static void emit_raw_record() flb_log_event_encoder_destroy(&encoder); } +/* This test case encodes a log event with a specific timestamp + * value and then it checks the raw data to ensure that regardless + * of the host byte order the value is encoded in network order. + */ +static void timestamp_encoding() +{ + struct flb_time timestamp; + struct flb_log_event_encoder encoder; + int result; + size_t index; + + timestamp.tm.tv_sec = 0x00C0FFEE; + timestamp.tm.tv_nsec = 0; + + result = flb_log_event_encoder_init(&encoder, + FLB_LOG_EVENT_FORMAT_FLUENT_BIT_V2); + if (!TEST_CHECK(result == FLB_EVENT_ENCODER_SUCCESS)) { + TEST_MSG("flb_log_event_encoder_init failed"); + return; + } + + result = flb_log_event_encoder_begin_record(&encoder); + if (!TEST_CHECK(result == FLB_EVENT_ENCODER_SUCCESS)) { + TEST_MSG("flb_log_event_encoder_begin_record failed. result=%s", + flb_log_event_encoder_get_error_description(result)); + flb_log_event_encoder_destroy(&encoder); + return; + } + + result = flb_log_event_encoder_set_timestamp(&encoder, ×tamp); + if (!TEST_CHECK(result == FLB_EVENT_ENCODER_SUCCESS)) { + TEST_MSG("flb_log_event_encoder_set_current_timestamp failed. result=%s", + flb_log_event_encoder_get_error_description(result)); + flb_log_event_encoder_destroy(&encoder); + return; + } + + result = flb_log_event_encoder_append_body_values( + &encoder, + FLB_LOG_EVENT_CSTRING_VALUE("test"), + FLB_LOG_EVENT_CSTRING_VALUE("value")); + + if (!TEST_CHECK(result == FLB_EVENT_ENCODER_SUCCESS)) { + TEST_MSG("flb_log_event_encoder_append_body_values failed. result=%s", + flb_log_event_encoder_get_error_description(result)); + flb_log_event_encoder_destroy(&encoder); + return; + } + + result = flb_log_event_encoder_commit_record(&encoder); + if (!TEST_CHECK(result == FLB_EVENT_ENCODER_SUCCESS)) { + TEST_MSG("flb_log_event_encoder_commit_record failed. result=%s", + flb_log_event_encoder_get_error_description(result)); + flb_log_event_encoder_destroy(&encoder); + return; + } + + result = FLB_FALSE; + + for (index = 0 ; index < encoder.output_length - 4 ; index++) { + if (encoder.output_buffer[index + 0] == 0x00 && + encoder.output_buffer[index + 1] == 0xC0 && + encoder.output_buffer[index + 2] == 0xFF && + encoder.output_buffer[index + 3] == 0xEE) { + result = FLB_TRUE; + + break; + } + } + + if (!TEST_CHECK(result == FLB_TRUE)) { + TEST_MSG("timestamp value not encoded in network order"); + } + + flb_log_event_encoder_destroy(&encoder); +} + TEST_LIST = { { "basic_format_fluent_bit_v2", basic_format_fluent_bit_v2}, { "basic_format_fluent_bit_v1", basic_format_fluent_bit_v1}, @@ -659,5 +736,6 @@ TEST_LIST = { { "init_destroy", init_destroy}, { "init_unsupported_format", init_unsupported_format}, { "emit_raw_record", emit_raw_record}, + { "timestamp_encoding", timestamp_encoding}, { NULL, NULL } }; From b922052aa74b28e569e9941121b13dd1bb7bab4f Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Fri, 23 Aug 2024 12:56:36 +0200 Subject: [PATCH 118/295] tests: internal: fixed type that caused the comparison to fail Signed-off-by: Leonardo Alminana --- tests/internal/log_event_encoder.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/internal/log_event_encoder.c b/tests/internal/log_event_encoder.c index 99f67eb2777..1ee09bccdcc 100644 --- a/tests/internal/log_event_encoder.c +++ b/tests/internal/log_event_encoder.c @@ -656,6 +656,7 @@ static void emit_raw_record() */ static void timestamp_encoding() { + uint8_t *encoder_buffer; struct flb_time timestamp; struct flb_log_event_encoder encoder; int result; @@ -707,13 +708,15 @@ static void timestamp_encoding() return; } + encoder_buffer = (uint8_t *) encoder.output_buffer; + result = FLB_FALSE; for (index = 0 ; index < encoder.output_length - 4 ; index++) { - if (encoder.output_buffer[index + 0] == 0x00 && - encoder.output_buffer[index + 1] == 0xC0 && - encoder.output_buffer[index + 2] == 0xFF && - encoder.output_buffer[index + 3] == 0xEE) { + if (encoder_buffer[index + 0] == 0x00 && + encoder_buffer[index + 1] == 0xC0 && + encoder_buffer[index + 2] == 0xFF && + encoder_buffer[index + 3] == 0xEE) { result = FLB_TRUE; break; From af0a0a39c1b1a79263707d141324cbeba3d121a8 Mon Sep 17 00:00:00 2001 From: Phillip Whelan Date: Tue, 16 Apr 2024 16:43:18 -0400 Subject: [PATCH 119/295] utils: use MachineGUID correctly. correctly copy the buffer from RegQuery in flb_utils_get_machine_id when querying the MachineGUID. Signed-off-by: Phillip Whelan --- src/flb_utils.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/flb_utils.c b/src/flb_utils.c index 2f445980d84..a841ac188f8 100644 --- a/src/flb_utils.c +++ b/src/flb_utils.c @@ -1415,6 +1415,7 @@ int flb_utils_get_machine_id(char **out_id, size_t *out_size) if (status == ERROR_SUCCESS) { *out_id = flb_calloc(1, dwBufSize+1); + memcpy(*out_id, buf, dwBufSize); if (*out_id == NULL) { return -1; From 2bb7ff3cfcf916e427868f418625159ba1a6a80a Mon Sep 17 00:00:00 2001 From: Phillip Whelan Date: Tue, 16 Apr 2024 17:29:01 -0400 Subject: [PATCH 120/295] tests: add utils test for flb_utils_get_machine_id for zero and repeatability. Add tests for flb_utils_get_machine_id to make sure the ID is consistent and is not full of zeroes. Signed-off-by: Phillip Whelan --- tests/internal/utils.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/internal/utils.c b/tests/internal/utils.c index bcb9053d86f..0f94321c595 100644 --- a/tests/internal/utils.c +++ b/tests/internal/utils.c @@ -608,14 +608,31 @@ void test_flb_utils_split_quoted_errors() void test_flb_utils_get_machine_id() { int ret; + int idx; char *id = NULL; size_t size; + char *id2 = NULL; + size_t size2; ret = flb_utils_get_machine_id(&id, &size); TEST_CHECK(size != 0); TEST_CHECK(id != NULL); + for (idx = 0; idx < size; idx++) { + TEST_CHECK(id[idx] != 0); + } + + ret = flb_utils_get_machine_id(&id2, &size2); + TEST_CHECK(size2 != 0); + TEST_CHECK(id2 != NULL); + TEST_CHECK(size2 == size); + + for (idx = 0; idx < size; idx++) { + TEST_CHECK(id[idx] == id2[idx]); + } + flb_free(id); + flb_free(id2); } struct size_to_bytes_check { From 14a2b227f89c59a94c15f2d9d3f13de8d2b156c0 Mon Sep 17 00:00:00 2001 From: Phillip Whelan Date: Wed, 17 Apr 2024 12:00:06 -0400 Subject: [PATCH 121/295] tests: add output for utils test for test_flb_utils_get_machine_id. Signed-off-by: Phillip Whelan --- tests/internal/utils.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/internal/utils.c b/tests/internal/utils.c index 0f94321c595..f55a3672c37 100644 --- a/tests/internal/utils.c +++ b/tests/internal/utils.c @@ -615,20 +615,27 @@ void test_flb_utils_get_machine_id() size_t size2; ret = flb_utils_get_machine_id(&id, &size); + TEST_CHECK(ret == 0); TEST_CHECK(size != 0); TEST_CHECK(id != NULL); for (idx = 0; idx < size; idx++) { - TEST_CHECK(id[idx] != 0); + if (!TEST_CHECK(id[idx] != 0)) { + fprintf(stderr, "zero in ID: id[%d] = 0x%02x\n", idx, id[idx]); + } } ret = flb_utils_get_machine_id(&id2, &size2); + TEST_CHECK(ret == 0); TEST_CHECK(size2 != 0); TEST_CHECK(id2 != NULL); TEST_CHECK(size2 == size); for (idx = 0; idx < size; idx++) { - TEST_CHECK(id[idx] == id2[idx]); + if (!TEST_CHECK(id[idx] == id2[idx])) { + fprintf(stderr, "bad byte in id v2 id2: id[%d] = 0x%02x, id2[%d] = 0x%02x\n", + idx, id[idx], idx, id2[idx]); + } } flb_free(id); From 4b480a1619ba2929f679d85a879c2c8689edf7c4 Mon Sep 17 00:00:00 2001 From: Phillip Whelan Date: Wed, 17 Apr 2024 12:01:21 -0400 Subject: [PATCH 122/295] utils: return strlen() in flb_utils_get_machine_id on win32. Signed-off-by: Phillip Whelan --- src/flb_utils.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/flb_utils.c b/src/flb_utils.c index a841ac188f8..6350fedce93 100644 --- a/src/flb_utils.c +++ b/src/flb_utils.c @@ -1421,7 +1421,9 @@ int flb_utils_get_machine_id(char **out_id, size_t *out_size) return -1; } - *out_size = dwBufSize; + /* RegQueryValueEx sets dwBufSize to strlen()+1 for the NULL + * terminator, but we only need strlen(). */ + *out_size = dwBufSize-1; return 0; } #elif defined (FLB_SYSTEM_MACOS) From 5ddcc8adc240e175f10263388ee724ab2f256ed6 Mon Sep 17 00:00:00 2001 From: Phillip Whelan Date: Wed, 17 Apr 2024 16:44:20 -0400 Subject: [PATCH 123/295] utils: warn when using random ID in flb_utils_get_machine_id. Signed-off-by: Phillip Whelan --- src/flb_utils.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/flb_utils.c b/src/flb_utils.c index 6350fedce93..5ddf1e2684f 100644 --- a/src/flb_utils.c +++ b/src/flb_utils.c @@ -1467,6 +1467,8 @@ int flb_utils_get_machine_id(char **out_id, size_t *out_size) } #endif + flb_warn("falling back on random machine UUID"); + /* generate a random uuid */ uuid = flb_malloc(38); if (!uuid) { From 03b6fc22dd2fa85299a5c131ce3587caf73e1071 Mon Sep 17 00:00:00 2001 From: Phillip Whelan Date: Wed, 17 Apr 2024 17:00:13 -0400 Subject: [PATCH 124/295] utils: report error code for RegQueryValueEx in flb_utils_get_machine_id. Signed-off-by: Phillip Whelan --- src/flb_utils.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/flb_utils.c b/src/flb_utils.c index 5ddf1e2684f..dedf18434ce 100644 --- a/src/flb_utils.c +++ b/src/flb_utils.c @@ -1426,6 +1426,9 @@ int flb_utils_get_machine_id(char **out_id, size_t *out_size) *out_size = dwBufSize-1; return 0; } + else { + flb_error("unable to retrieve MachineGUID, error code: %d", status); + } #elif defined (FLB_SYSTEM_MACOS) bool bret; CFStringRef serialNumber; From 122f99b9c2b380ef043ba4651e8ab14b15b80929 Mon Sep 17 00:00:00 2001 From: Phillip Whelan Date: Thu, 18 Apr 2024 16:15:51 -0400 Subject: [PATCH 125/295] utils: attempt to fix retrieval of machine id on win32. Signed-off-by: Phillip Whelan --- src/flb_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/flb_utils.c b/src/flb_utils.c index dedf18434ce..3761ad2cadc 100644 --- a/src/flb_utils.c +++ b/src/flb_utils.c @@ -1403,7 +1403,7 @@ int flb_utils_get_machine_id(char **out_id, size_t *out_size) status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Cryptography"), 0, - KEY_QUERY_VALUE, + KEY_QUERY_VALUE|KEY_WOW64_64KEY, &hKey); if (status != ERROR_SUCCESS) { From 03f595b55cbb0c664b4b41253f2f659639d02ab1 Mon Sep 17 00:00:00 2001 From: Phillip Whelan Date: Fri, 9 Aug 2024 16:13:20 -0400 Subject: [PATCH 126/295] utils: validate allocation before filling with GUID on windows. Signed-off-by: Phillip Whelan --- src/flb_utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/flb_utils.c b/src/flb_utils.c index 3761ad2cadc..7c287de05e4 100644 --- a/src/flb_utils.c +++ b/src/flb_utils.c @@ -1415,12 +1415,13 @@ int flb_utils_get_machine_id(char **out_id, size_t *out_size) if (status == ERROR_SUCCESS) { *out_id = flb_calloc(1, dwBufSize+1); - memcpy(*out_id, buf, dwBufSize); if (*out_id == NULL) { return -1; } + memcpy(*out_id, buf, dwBufSize); + /* RegQueryValueEx sets dwBufSize to strlen()+1 for the NULL * terminator, but we only need strlen(). */ *out_size = dwBufSize-1; From eea409ca66c9bc797ca9c038da42a96c79cb104d Mon Sep 17 00:00:00 2001 From: JinXinWang Date: Thu, 18 Jul 2024 14:07:45 +0800 Subject: [PATCH 127/295] examples: filter_wasm_go: Upgrade to support Go 1.22.5 and TinyGo 0.32 Signed-off-by: JinXinWang --- examples/filter_wasm_go/README.md | 11 +++++------ examples/filter_wasm_go/filter.go | 6 +++--- examples/filter_wasm_go/go.mod | 8 ++------ examples/filter_wasm_go/go.sum | 16 ---------------- 4 files changed, 10 insertions(+), 31 deletions(-) diff --git a/examples/filter_wasm_go/README.md b/examples/filter_wasm_go/README.md index 863cf836007..7c0e9c7979a 100644 --- a/examples/filter_wasm_go/README.md +++ b/examples/filter_wasm_go/README.md @@ -7,14 +7,13 @@ This source source tree provides an example of WASM filter program with WASI mod Tested on * TinyGo - * [tinygo](https://tinygo.org/) tinygo version 0.23.0 linux/amd64 (using go version go1.18.2 and LLVM version 14.0.0) - * [tinygo](https://tinygo.org/) tinygo version 0.24.0 linux/amd64 (using go version go1.18.2 and LLVM version 14.0.0) + * [tinygo](https://tinygo.org/) tinygo version 0.32.0 linux/amd64 (using go version go1.22.5 and LLVM version 18.1.2) For Ubuntu, it's easy to install with: ```console -$ wget https://github.com/tinygo-org/tinygo/releases/download/v0.24.0/tinygo_0.24.0_amd64.deb -$ sudo dpkg -i tinygo_0.24.0_amd64.deb +$ wget https://github.com/tinygo-org/tinygo/releases/download/v0.32.0/tinygo_0.32.0_amd64.deb +$ sudo dpkg -i tinygo_0.32.0_amd64.deb ``` ## How to build @@ -22,7 +21,7 @@ $ sudo dpkg -i tinygo_0.24.0_amd64.deb Execute _tinygo build_ as follows: ```console -$ tinygo build -wasm-abi=generic -target=wasi -o filter.wasm filter.go +$ tinygo build -target=wasi -o filter.wasm filter.go ``` Finally, under the same directory, `*.wasm` file will be created: @@ -52,6 +51,7 @@ Create fluent-bit configuration file as follows: [FILTER] Name wasm match dummy.* + Event_Format json WASM_Path /path/to/filter.wasm Function_Name go_filter accessible_paths .,/path/to/fluent-bit @@ -59,5 +59,4 @@ Create fluent-bit configuration file as follows: [OUTPUT] Name stdout Match * - ``` diff --git a/examples/filter_wasm_go/filter.go b/examples/filter_wasm_go/filter.go index fe7303c681c..25a9075505c 100644 --- a/examples/filter_wasm_go/filter.go +++ b/examples/filter_wasm_go/filter.go @@ -31,11 +31,11 @@ func go_filter(tag *uint8, tag_len uint, time_sec uint, time_nsec uint, record * obj.Set("time", arena.NewString(now.String())) obj.Set("tag", arena.NewString(string(btag))) obj.Set("original", arena.NewString(br)) - s := obj.String() - s += string(rune(0)) // Note: explicit null terminator. + + s := obj.String() + string(rune(0)) rv := []byte(s) return &rv[0] } -func main() {} +func main() {} \ No newline at end of file diff --git a/examples/filter_wasm_go/go.mod b/examples/filter_wasm_go/go.mod index 8250a72d20f..ec8e1cc8ec9 100644 --- a/examples/filter_wasm_go/go.mod +++ b/examples/filter_wasm_go/go.mod @@ -1,9 +1,5 @@ module filter_wasm_go -go 1.18 +go 1.22.5 -require ( - github.com/valyala/fastjson v1.6.3 // indirect - github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect - github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect -) +require github.com/valyala/fastjson v1.6.3 diff --git a/examples/filter_wasm_go/go.sum b/examples/filter_wasm_go/go.sum index 2489b8d5436..37063017cde 100644 --- a/examples/filter_wasm_go/go.sum +++ b/examples/filter_wasm_go/go.sum @@ -1,18 +1,2 @@ -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/goccy/go-json v0.9.10 h1:hCeNmprSNLB8B8vQKWl6DpuH0t60oEs+TAk9a7CScKc= -github.com/goccy/go-json v0.9.10/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= -github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= -github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= -github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= -github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/valyala/fastjson v1.6.3 h1:tAKFnnwmeMGPbwJ7IwxcTPCNr3uIzoIj3/Fh90ra4xc= github.com/valyala/fastjson v1.6.3/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY= -github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU= -github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= -github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= -github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From cd659c5204a98b2e1d8b615649e8dfb025f4bb39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lecaros?= Date: Tue, 27 Aug 2024 11:01:55 -0400 Subject: [PATCH 128/295] in_elasticsearch: Fix string in http response code 400 (#8977) * in_elasticsearch: Fix string in http response code 400. Signed-off-by: lecaros --- plugins/in_elasticsearch/in_elasticsearch_bulk_prot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/in_elasticsearch/in_elasticsearch_bulk_prot.c b/plugins/in_elasticsearch/in_elasticsearch_bulk_prot.c index 0f452a26da8..5201026ccff 100644 --- a/plugins/in_elasticsearch/in_elasticsearch_bulk_prot.c +++ b/plugins/in_elasticsearch/in_elasticsearch_bulk_prot.c @@ -224,7 +224,7 @@ static int send_response(struct in_elasticsearch_bulk_conn *conn, int http_statu } else if (http_status == 400) { flb_sds_printf(&out, - "HTTP/1.1 400 Forbidden\r\n" + "HTTP/1.1 400 Bad Request\r\n" "Server: Fluent Bit v%s\r\n" "Content-Length: %i\r\n\r\n%s", FLB_VERSION_STR, @@ -942,7 +942,7 @@ static int send_response_ng(struct flb_http_response *response, flb_http_response_set_message(response, "No Content"); } else if (http_status == 400) { - flb_http_response_set_message(response, "Forbidden"); + flb_http_response_set_message(response, "Bad Request"); } if (content_type != NULL) { From 9e5111b676b65d6c44dc829a65a7de6250b0a76b Mon Sep 17 00:00:00 2001 From: Mirko Lazarevic Date: Tue, 27 Aug 2024 17:04:09 +0200 Subject: [PATCH 129/295] out_logdna: refactored LogDNA URI formation to support configurable endpoints (#8051) Previously, the LogDNA URI was hardcoded to use the '/logs/ingest' endpoint. This change introduces flexibility by allowing users to specify their own endpoint through the 'logdna_endpoint' configuration. This can be particularly useful for users with different LogDNA setups or those using Super Tenancy. Signed-off-by: Mirko Lazarevic --- plugins/out_logdna/logdna.c | 9 ++++++++- plugins/out_logdna/logdna.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/out_logdna/logdna.c b/plugins/out_logdna/logdna.c index 88a0fc9814d..bc834c6017d 100644 --- a/plugins/out_logdna/logdna.c +++ b/plugins/out_logdna/logdna.c @@ -405,7 +405,8 @@ static void cb_logdna_flush(struct flb_event_chunk *event_chunk, FLB_OUTPUT_RETURN(FLB_RETRY); } tmp = flb_sds_printf(&uri, - "/logs/ingest?hostname=%s&mac=%s&ip=%s&now=%lu&tags=%s", + "%s?hostname=%s&mac=%s&ip=%s&now=%lu&tags=%s", + ctx->logdna_endpoint, ctx->_hostname, ctx->mac_addr, ctx->ip_addr, @@ -532,6 +533,12 @@ static struct flb_config_map config_map[] = { "LogDNA TCP port" }, + { + FLB_CONFIG_MAP_STR, "logdna_endpoint", FLB_LOGDNA_ENDPOINT, + 0, FLB_TRUE, offsetof(struct flb_logdna, logdna_endpoint), + "LogDNA endpoint to send logs" + }, + { FLB_CONFIG_MAP_STR, "api_key", NULL, 0, FLB_TRUE, offsetof(struct flb_logdna, api_key), diff --git a/plugins/out_logdna/logdna.h b/plugins/out_logdna/logdna.h index b2b3a8f3d5b..b906e2563c4 100644 --- a/plugins/out_logdna/logdna.h +++ b/plugins/out_logdna/logdna.h @@ -25,6 +25,7 @@ #define FLB_LOGDNA_HOST "logs.logdna.com" #define FLB_LOGDNA_PORT "443" +#define FLB_LOGDNA_ENDPOINT "/logs/ingest" #define FLB_LOGDNA_CT "Content-Type" #define FLB_LOGDNA_CT_JSON "application/json; charset=UTF-8" @@ -32,6 +33,7 @@ struct flb_logdna { /* Incoming Configuration Properties */ flb_sds_t logdna_host; int logdna_port; + flb_sds_t logdna_endpoint; flb_sds_t api_key; flb_sds_t hostname; flb_sds_t mac_addr; From 5f3074fb5383b0ee784d8a0f333c0154fbe2b1e2 Mon Sep 17 00:00:00 2001 From: rightblank Date: Tue, 27 Aug 2024 23:05:20 +0800 Subject: [PATCH 130/295] build: use the system lib luajit for s390x (#9172) Signed-off-by: YingJie Fu --- README.md | 2 +- cmake/s390x.cmake | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a6ba08be9e8..be2e805cc50 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ Fluent Bit is fully supported on Windows environments, get started with [these i #### Running on s390x -Fluent Bit is supported on Linux on IBM Z(s390x), but the WASM and LUA filter plugins are not. +Fluent Bit runs on Linux on IBM Z(s390x), but the WASM filter plugin is not. For the LUA filter plugin, it runs when `libluajit` is installed on the system and fluent bit is built with `FLB_LUAJIT` and `FLB_PREFER_SYSTEM_LIB_LUAJIT` on. ### Plugins: Inputs, Filters and Outputs diff --git a/cmake/s390x.cmake b/cmake/s390x.cmake index af70127ceb4..c93633636a0 100644 --- a/cmake/s390x.cmake +++ b/cmake/s390x.cmake @@ -3,6 +3,10 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(SystemZ|s390x)") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsigned-char") message(STATUS "Cannot build WAMR on this platform, so WASM support is disabled.") set(FLB_WASM OFF) - message(STATUS "This platform does not support LuaJIT, so it's disabled.") - set(FLB_LUAJIT OFF) + if(FLB_LUAJIT) + if(NOT FLB_PREFER_SYSTEM_LIB_LUAJIT) + message(WARNING "LuaJIT is disabled, this platform does not support built-in LuaJIT. To use lua filter on this platform, install LuaJIT as system lib and build again with both FLB_LUAJIT and FLB_PREFER_SYSTEM_LIB_LUAJIT on.") + set(FLB_LUAJIT OFF) + endif() + endif() endif () From 8e5c213c6180f936504a6d94833d29ad1b0662f7 Mon Sep 17 00:00:00 2001 From: Mirko Lazarevic Date: Tue, 27 Aug 2024 17:15:27 +0200 Subject: [PATCH 131/295] log_event_encoder: log_event_decoder: enhanced byte order handling for timestamps (#9196) This change ensures correct byte order conversions for timestamp fields within log event decoder and encoder. Added FLB_TO_NATIVE_UINT32 in flb_endian.h. This function checks the host machine's byte order and applies the necessary conversion for 32-bit unsigned integers. Signed-off-by: Mirko Lazarevic Co-authored-by: Bernhard Schmid --- include/fluent-bit/flb_byteswap.h | 12 ++++++++++++ src/flb_log_event_decoder.c | 4 ++-- src/flb_log_event_encoder_primitives.c | 4 ++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/include/fluent-bit/flb_byteswap.h b/include/fluent-bit/flb_byteswap.h index b166378b53f..84e27aff91a 100644 --- a/include/fluent-bit/flb_byteswap.h +++ b/include/fluent-bit/flb_byteswap.h @@ -21,6 +21,7 @@ #define FLB_BYTESWAP_H #include +#include #if defined(FLB_HAVE_WIN32_BYTESWAP) #include @@ -102,4 +103,15 @@ static inline uint64_t FLB_BSWAP_64(uint64_t value) #endif +static inline uint32_t FLB_UINT32_TO_HOST_BYTE_ORDER(uint32_t value) +{ + #if FLB_BYTE_ORDER == FLB_LITTLE_ENDIAN + return FLB_BSWAP_32(value); + #else + return value; + #endif +} + +#define FLB_UINT32_TO_NETWORK_BYTE_ORDER(value) FLB_UINT32_TO_HOST_BYTE_ORDER(value) + #endif diff --git a/src/flb_log_event_decoder.c b/src/flb_log_event_decoder.c index 3e8ca6e56d4..a63d674a12a 100644 --- a/src/flb_log_event_decoder.c +++ b/src/flb_log_event_decoder.c @@ -181,12 +181,12 @@ int flb_log_event_decoder_decode_timestamp(msgpack_object *input, } output->tm.tv_sec = - (int32_t) FLB_BSWAP_32( + (int32_t) FLB_UINT32_TO_HOST_BYTE_ORDER( FLB_ALIGNED_DWORD_READ( (unsigned char *) &input->via.ext.ptr[0])); output->tm.tv_nsec = - (int32_t) FLB_BSWAP_32( + (int32_t) FLB_UINT32_TO_HOST_BYTE_ORDER( FLB_ALIGNED_DWORD_READ( (unsigned char *) &input->via.ext.ptr[4])); } diff --git a/src/flb_log_event_encoder_primitives.c b/src/flb_log_event_encoder_primitives.c index dbcb4a4b808..7b44bd8ea11 100644 --- a/src/flb_log_event_encoder_primitives.c +++ b/src/flb_log_event_encoder_primitives.c @@ -519,8 +519,8 @@ int flb_log_event_encoder_append_forward_v1_timestamp( { uint32_t value[2]; - value[0] = FLB_BSWAP_32((uint32_t) timestamp->tm.tv_sec); - value[1] = FLB_BSWAP_32((uint32_t) timestamp->tm.tv_nsec); + value[0] = FLB_UINT32_TO_NETWORK_BYTE_ORDER((uint32_t) timestamp->tm.tv_sec); + value[1] = FLB_UINT32_TO_NETWORK_BYTE_ORDER((uint32_t) timestamp->tm.tv_nsec); return flb_log_event_encoder_append_ext(context, target_field, 0, (char *) value, 8); From b59e1e9e3cc12429b9c225ec12e5164b18ee0e77 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Fri, 23 Aug 2024 11:29:55 +0900 Subject: [PATCH 132/295] in_splunk: test: Handle 1.0 suffixed endpoints Signed-off-by: Hiroshi Hatake --- plugins/in_splunk/splunk_prot.c | 12 ++++++++---- tests/runtime/in_splunk.c | 20 +++++++++++++++++--- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/plugins/in_splunk/splunk_prot.c b/plugins/in_splunk/splunk_prot.c index a6f9be57ed3..cf614b06679 100644 --- a/plugins/in_splunk/splunk_prot.c +++ b/plugins/in_splunk/splunk_prot.c @@ -834,7 +834,8 @@ int splunk_prot_handle(struct flb_splunk *ctx, struct splunk_conn *conn, flb_log_event_encoder_reset(&ctx->log_encoder); if (request->method == MK_METHOD_POST) { - if (strcasecmp(uri, "/services/collector/raw") == 0) { + if (strcasecmp(uri, "/services/collector/raw/1.0") == 0 || + strcasecmp(uri, "/services/collector/raw") == 0) { ret = process_hec_raw_payload(ctx, conn, tag, session, request); if (!ret) { @@ -842,7 +843,8 @@ int splunk_prot_handle(struct flb_splunk *ctx, struct splunk_conn *conn, } send_json_message_response(conn, 200, "{\"text\":\"Success\",\"code\":0}"); } - else if (strcasecmp(uri, "/services/collector/event") == 0 || + else if (strcasecmp(uri, "/services/collector/event/1.0") == 0 || + strcasecmp(uri, "/services/collector/event") == 0 || strcasecmp(uri, "/services/collector") == 0) { ret = process_hec_payload(ctx, conn, tag, session, request); @@ -1151,7 +1153,8 @@ int splunk_prot_handle_ng(struct flb_http_request *request, return -1; } - if (strcasecmp(request->path, "/services/collector/raw") == 0) { + if (strcasecmp(request->path, "/services/collector/raw/1.0") == 0 || + strcasecmp(request->path, "/services/collector/raw") == 0) { ret = process_hec_raw_payload_ng(request, response, tag, context); if (ret != 0) { @@ -1163,7 +1166,8 @@ int splunk_prot_handle_ng(struct flb_http_request *request, ret = 0; } - else if (strcasecmp(request->path, "/services/collector/event") == 0 || + else if (strcasecmp(request->path, "/services/collector/event/1.0") == 0 || + strcasecmp(request->path, "/services/collector/event") == 0 || strcasecmp(request->path, "/services/collector") == 0) { ret = process_hec_payload_ng(request, response, tag, context); diff --git a/tests/runtime/in_splunk.c b/tests/runtime/in_splunk.c index 77eb80b50f3..666866442c7 100644 --- a/tests/runtime/in_splunk.c +++ b/tests/runtime/in_splunk.c @@ -370,7 +370,7 @@ void flb_test_splunk_collector_event() flb_test_splunk(8810, "/services/collector/event"); } -void flb_test_splunk_raw(int port) +void flb_test_splunk_raw(int port, char *endpoint) { struct flb_lib_out_cb cb_data; struct test_ctx *ctx; @@ -413,7 +413,7 @@ void flb_test_splunk_raw(int port) ctx->httpc = splunk_client_ctx_create(port); TEST_CHECK(ctx->httpc != NULL); - c = flb_http_client(ctx->httpc->u_conn, FLB_HTTP_POST, "/services/collector/raw", buf, strlen(buf), + c = flb_http_client(ctx->httpc->u_conn, FLB_HTTP_POST, endpoint, buf, strlen(buf), "127.0.0.1", port, NULL, 0); ret = flb_http_add_header(c, FLB_HTTP_HEADER_CONTENT_TYPE, strlen(FLB_HTTP_HEADER_CONTENT_TYPE), JSON_CONTENT_TYPE, strlen(JSON_CONTENT_TYPE)); @@ -448,7 +448,7 @@ void flb_test_splunk_raw(int port) void flb_test_splunk_collector_raw() { - flb_test_splunk_raw(8811); + flb_test_splunk_raw(8811, "/services/collector/raw"); } void flb_test_splunk_raw_multilines(int port) @@ -910,11 +910,25 @@ void flb_test_splunk_collector_raw_hec_token_key() flb_test_splunk_auth_header(8817, "/services/collector/raw"); } +/* 1.0 endpoints */ + +void flb_test_splunk_collector_raw_1_0() +{ + flb_test_splunk_raw(8818, "/services/collector/raw/1.0"); +} + +void flb_test_splunk_collector_event_1_0() +{ + flb_test_splunk(8819, "/services/collector/event/1.0"); +} + TEST_LIST = { {"health", flb_test_splunk_health}, {"collector", flb_test_splunk_collector}, {"collector_event", flb_test_splunk_collector_event}, + {"collector_event_1.0", flb_test_splunk_collector_event_1_0}, {"collector_raw", flb_test_splunk_collector_raw}, + {"collector_raw_1.0", flb_test_splunk_collector_raw_1_0}, {"collector_raw_multilines", flb_test_splunk_collector_raw_multilines}, {"collector_gzip", flb_test_splunk_collector_gzip}, {"collector_event_gzip", flb_test_splunk_collector_event_gzip}, From 36c46b790f613b0ac60ebea66b4e3ea57418db9c Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Tue, 27 Aug 2024 15:17:54 +0000 Subject: [PATCH 133/295] utils: fix compatibility for macOS < 12 (#9217) Signed-off-by: Sergey Fedorov --- src/flb_utils.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/flb_utils.c b/src/flb_utils.c index 7c287de05e4..37e89d28a4f 100644 --- a/src/flb_utils.c +++ b/src/flb_utils.c @@ -49,6 +49,10 @@ extern struct flb_aws_error_reporter *error_reporter; #ifdef FLB_SYSTEM_MACOS #include #include +#include +#if MAC_OS_X_VERSION_MIN_REQUIRED < 120000 +#define kIOMainPortDefault kIOMasterPortDefault +#endif #endif /* From e37b56b2a1c75ca50c15848a945b448f7d85ee85 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Thu, 15 Aug 2024 19:32:33 +0900 Subject: [PATCH 134/295] out_elasticsearch: Process error information properly The current out_elasticsearch implementation is just giving up to process responses when encountering the error information. In this patch, continue to process until the end of the elements of msgpack converted JSON response. If there is a succeeded infrmation in the converted response, Fluent Bit will assume the requesting payloads to be succeeded to send ES clusters. Signed-off-by: Hiroshi Hatake --- plugins/out_es/es.c | 51 ++++++++++++++++++++++++++------------------- plugins/out_es/es.h | 9 ++++++++ 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/plugins/out_es/es.c b/plugins/out_es/es.c index 5d6a428992a..b0773a40991 100644 --- a/plugins/out_es/es.c +++ b/plugins/out_es/es.c @@ -647,7 +647,7 @@ static int elasticsearch_error_check(struct flb_elasticsearch *ctx, { int i, j, k; int ret; - int check = FLB_FALSE; + int check = 0; int root_type; char *out_buf; size_t off = 0; @@ -671,17 +671,20 @@ static int elasticsearch_error_check(struct flb_elasticsearch *ctx, if (ret == -1) { /* Is this an incomplete HTTP Request ? */ if (c->resp.payload_size <= 0) { - return FLB_TRUE; + check |= FLB_ES_STATUS_IMCOMPLETE; + return check; } /* Lookup error field */ if (strstr(c->resp.payload, "\"errors\":false,\"items\":[")) { - return FLB_FALSE; + check |= FLB_ES_STATUS_SUCCESS; + return check; } flb_plg_error(ctx->ins, "could not pack/validate JSON response\n%s", c->resp.payload); - return FLB_TRUE; + check |= FLB_ES_STATUS_BAD_RESPONSE; + return check; } /* Lookup error field */ @@ -690,14 +693,15 @@ static int elasticsearch_error_check(struct flb_elasticsearch *ctx, if (ret != MSGPACK_UNPACK_SUCCESS) { flb_plg_error(ctx->ins, "Cannot unpack response to find error\n%s", c->resp.payload); - return FLB_TRUE; + check |= FLB_ES_STATUS_ERROR_UNPACK; + return check; } root = result.data; if (root.type != MSGPACK_OBJECT_MAP) { flb_plg_error(ctx->ins, "unexpected payload type=%i", root.type); - check = FLB_TRUE; + check |= FLB_ES_STATUS_BAD_TYPE; goto done; } @@ -706,7 +710,7 @@ static int elasticsearch_error_check(struct flb_elasticsearch *ctx, if (key.type != MSGPACK_OBJECT_STR) { flb_plg_error(ctx->ins, "unexpected key type=%i", key.type); - check = FLB_TRUE; + check |= FLB_ES_STATUS_INVAILD_ARGUMENT; goto done; } @@ -715,14 +719,14 @@ static int elasticsearch_error_check(struct flb_elasticsearch *ctx, if (val.type != MSGPACK_OBJECT_BOOLEAN) { flb_plg_error(ctx->ins, "unexpected 'error' value type=%i", val.type); - check = FLB_TRUE; + check |= FLB_ES_STATUS_BAD_TYPE; goto done; } /* If error == false, we are OK (no errors = FLB_FALSE) */ if (!val.via.boolean) { /* no errors */ - check = FLB_FALSE; + check |= FLB_ES_STATUS_SUCCESS; goto done; } } @@ -731,7 +735,7 @@ static int elasticsearch_error_check(struct flb_elasticsearch *ctx, if (val.type != MSGPACK_OBJECT_ARRAY) { flb_plg_error(ctx->ins, "unexpected 'items' value type=%i", val.type); - check = FLB_TRUE; + check |= FLB_ES_STATUS_BAD_TYPE; goto done; } @@ -740,14 +744,14 @@ static int elasticsearch_error_check(struct flb_elasticsearch *ctx, if (item.type != MSGPACK_OBJECT_MAP) { flb_plg_error(ctx->ins, "unexpected 'item' outer value type=%i", item.type); - check = FLB_TRUE; + check |= FLB_ES_STATUS_BAD_TYPE; goto done; } if (item.via.map.size != 1) { flb_plg_error(ctx->ins, "unexpected 'item' size=%i", item.via.map.size); - check = FLB_TRUE; + check |= FLB_ES_STATUS_INVAILD_ARGUMENT; goto done; } @@ -755,7 +759,7 @@ static int elasticsearch_error_check(struct flb_elasticsearch *ctx, if (item.type != MSGPACK_OBJECT_MAP) { flb_plg_error(ctx->ins, "unexpected 'item' inner value type=%i", item.type); - check = FLB_TRUE; + check |= FLB_ES_STATUS_BAD_TYPE; goto done; } @@ -764,7 +768,7 @@ static int elasticsearch_error_check(struct flb_elasticsearch *ctx, if (item_key.type != MSGPACK_OBJECT_STR) { flb_plg_error(ctx->ins, "unexpected key type=%i", item_key.type); - check = FLB_TRUE; + check |= FLB_ES_STATUS_BAD_TYPE; goto done; } @@ -774,13 +778,16 @@ static int elasticsearch_error_check(struct flb_elasticsearch *ctx, if (item_val.type != MSGPACK_OBJECT_POSITIVE_INTEGER) { flb_plg_error(ctx->ins, "unexpected 'status' value type=%i", item_val.type); - check = FLB_TRUE; + check |= FLB_ES_STATUS_BAD_TYPE; goto done; } + /* Check for success responses */ + if (item_val.via.i64 == 200 || item_val.via.i64 == 201) { + check |= FLB_ES_STATUS_SUCCESS; + } /* Check for errors other than version conflict (document already exists) */ if (item_val.via.i64 != 409) { - check = FLB_TRUE; - goto done; + check |= FLB_ES_STATUS_ERROR; } } } @@ -920,7 +927,11 @@ static void cb_es_flush(struct flb_event_chunk *event_chunk, * and lookup the 'error' field. */ ret = elasticsearch_error_check(ctx, c); - if (ret == FLB_TRUE) { + if (ret & FLB_ES_STATUS_SUCCESS) { + flb_plg_debug(ctx->ins, "Elasticsearch response\n%s", + c->resp.payload); + } + else { /* we got an error */ if (ctx->trace_error) { /* @@ -946,10 +957,6 @@ static void cb_es_flush(struct flb_event_chunk *event_chunk, } goto retry; } - else { - flb_plg_debug(ctx->ins, "Elasticsearch response\n%s", - c->resp.payload); - } } else { goto retry; diff --git a/plugins/out_es/es.h b/plugins/out_es/es.h index a3f1ecadf98..b6512ebc2a0 100644 --- a/plugins/out_es/es.h +++ b/plugins/out_es/es.h @@ -36,6 +36,15 @@ #define FLB_ES_WRITE_OP_UPDATE "update" #define FLB_ES_WRITE_OP_UPSERT "upsert" +#define FLB_ES_STATUS_SUCCESS (1 << 0) +#define FLB_ES_STATUS_IMCOMPLETE (1 << 1) +#define FLB_ES_STATUS_ERROR_UNPACK (1 << 2) +#define FLB_ES_STATUS_BAD_TYPE (1 << 3) +#define FLB_ES_STATUS_INVAILD_ARGUMENT (1 << 4) +#define FLB_ES_STATUS_BAD_RESPONSE (1 << 5) +#define FLB_ES_STATUS_DUPLICATES (1 << 6) +#define FLB_ES_STATUS_ERROR (1 << 7) + struct flb_elasticsearch { /* Elasticsearch index (database) and type (table) */ char *index; From 144299376a5c21e6fe4ad74d81bbba59f21da44c Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Wed, 28 Aug 2024 21:41:00 +0900 Subject: [PATCH 135/295] out_s3: Plug an error for too many argument for mkdir Signed-off-by: Hiroshi Hatake --- plugins/out_s3/s3.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/out_s3/s3.c b/plugins/out_s3/s3.c index c896b7e36bb..b8fe80f0dd2 100644 --- a/plugins/out_s3/s3.c +++ b/plugins/out_s3/s3.c @@ -380,7 +380,11 @@ static int init_seq_index(void *context) { } /* Create directory path if it doesn't exist */ +#ifdef FLB_SYSTEM_WINDOWS + ret = mkdir(ctx->metadata_dir); +#else ret = mkdir(ctx->metadata_dir, 0700); +#endif if (ret < 0 && errno != EEXIST) { flb_plg_error(ctx->ins, "Failed to create metadata directory"); return -1; From d873502de1e1a7f050c7bba6336d682a3327a7af Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Wed, 28 Aug 2024 22:30:04 +0900 Subject: [PATCH 136/295] in_winevtlog: Remove a needless third argument Signed-off-by: Hiroshi Hatake --- plugins/in_winevtlog/pack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/in_winevtlog/pack.c b/plugins/in_winevtlog/pack.c index 9242da6811c..734839e30f3 100644 --- a/plugins/in_winevtlog/pack.c +++ b/plugins/in_winevtlog/pack.c @@ -450,7 +450,7 @@ static void pack_string_inserts(struct winevtlog_config *ctx, PEVT_VARIANT value } break; case EvtVarTypeEvtXml: - if (pack_wstr(ctx, values[i].XmlVal, ctx)) { + if (pack_wstr(ctx, values[i].XmlVal)) { pack_nullstr(ctx); } break; From efac89c2909eb7f561292eaecfd385349102f340 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Thu, 29 Aug 2024 11:51:45 +0200 Subject: [PATCH 137/295] out_azure_blob: fixed double free Signed-off-by: Leonardo Alminana --- plugins/out_azure_blob/azure_blob_http.c | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/out_azure_blob/azure_blob_http.c b/plugins/out_azure_blob/azure_blob_http.c index 01efdb5c073..5d97d5e25ad 100644 --- a/plugins/out_azure_blob/azure_blob_http.c +++ b/plugins/out_azure_blob/azure_blob_http.c @@ -236,7 +236,6 @@ flb_sds_t azb_http_canonical_request(struct flb_azure_blob *ctx, can_headers = canonical_headers(c); if (!can_headers) { flb_sds_destroy(can_req); - flb_sds_destroy(tmp); return NULL; } tmp = flb_sds_cat(can_req, can_headers, flb_sds_len(can_headers)); From a24c72c5a28b87e9a5ff14c474976802f861576f Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Thu, 29 Aug 2024 13:09:25 +0200 Subject: [PATCH 138/295] in_collectd: fixed out of bounds read Signed-off-by: Leonardo Alminana --- plugins/in_collectd/netprot.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/plugins/in_collectd/netprot.c b/plugins/in_collectd/netprot.c index 6e235bd4916..8d75560ec58 100644 --- a/plugins/in_collectd/netprot.c +++ b/plugins/in_collectd/netprot.c @@ -245,15 +245,27 @@ int netprot_to_msgpack(char *buf, int len, struct mk_list *tdb, while (len >= 4) { part_type = be16read(buf); - part_len = be16read(buf + 2); + part_len = be16read((unsigned char *) buf + 2); if (len < part_len) { flb_error("[in_collectd] data truncated (%i < %i)", len, part_len); return -1; } + ptr = buf + 4; size = part_len - 4; + if ((part_type == PART_TIME || + part_type == PART_TIME_HR || + part_type == PART_INTERVAL || + part_type == PART_INTERVAL_HR) && + size < sizeof(uint64_t)) { + flb_error("[in_collectd] data truncated (%i < %i)", + size, sizeof(uint64_t)); + + return -1; + } + switch (part_type) { case PART_HOST: if (ptr[size] == '\0') { From 66a9cd19dd2dba415d30839b3f659538b0636e45 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Thu, 29 Aug 2024 13:25:40 +0200 Subject: [PATCH 139/295] out_stackdriver: fixed a memory leak Signed-off-by: Leonardo Alminana --- plugins/out_stackdriver/stackdriver.c | 33 +++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/plugins/out_stackdriver/stackdriver.c b/plugins/out_stackdriver/stackdriver.c index 4326683187d..c7e6d925bd6 100644 --- a/plugins/out_stackdriver/stackdriver.c +++ b/plugins/out_stackdriver/stackdriver.c @@ -2304,9 +2304,22 @@ static flb_sds_t stackdriver_format(struct flb_stackdriver *ctx, insert_id_extracted = FLB_FALSE; } else { + if (trace_extracted == FLB_TRUE) { + flb_sds_destroy(trace); + } + + if (span_id_extracted == FLB_TRUE) { + flb_sds_destroy(span_id); + } + + if (project_id_extracted == FLB_TRUE) { + flb_sds_destroy(project_id_key); + } + if (log_name_extracted == FLB_TRUE) { flb_sds_destroy(log_name); } + continue; } @@ -2357,10 +2370,26 @@ static flb_sds_t stackdriver_format(struct flb_stackdriver *ctx, flb_plg_error(ctx->ins, "the type of payload labels should be map"); flb_sds_destroy(operation_id); flb_sds_destroy(operation_producer); - flb_sds_destroy(trace); - flb_sds_destroy(log_name); + + if (trace_extracted == FLB_TRUE) { + flb_sds_destroy(trace); + } + + if (span_id_extracted == FLB_TRUE) { + flb_sds_destroy(span_id); + } + + if (project_id_extracted == FLB_TRUE) { + flb_sds_destroy(project_id_key); + } + + if (log_name_extracted == FLB_TRUE) { + flb_sds_destroy(log_name); + } + flb_log_event_decoder_destroy(&log_decoder); msgpack_sbuffer_destroy(&mp_sbuf); + return NULL; } From 4c95e8807b8b0168901175f1acee8ebef59a7a73 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Thu, 29 Aug 2024 16:49:52 +0200 Subject: [PATCH 140/295] out_stackdriver: fixed a memory leak Signed-off-by: Leonardo Alminana --- plugins/out_stackdriver/stackdriver.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/out_stackdriver/stackdriver.c b/plugins/out_stackdriver/stackdriver.c index c7e6d925bd6..903bffce98d 100644 --- a/plugins/out_stackdriver/stackdriver.c +++ b/plugins/out_stackdriver/stackdriver.c @@ -2370,6 +2370,8 @@ static flb_sds_t stackdriver_format(struct flb_stackdriver *ctx, flb_plg_error(ctx->ins, "the type of payload labels should be map"); flb_sds_destroy(operation_id); flb_sds_destroy(operation_producer); + flb_sds_destroy(source_location_file); + flb_sds_destroy(source_location_function); if (trace_extracted == FLB_TRUE) { flb_sds_destroy(trace); From 665e4a0a429343c165a81dfb3877f08cfefb3f17 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Thu, 29 Aug 2024 13:54:38 +0200 Subject: [PATCH 141/295] in_node_exporter_metrics: fixed possible invalid dereference Signed-off-by: Leonardo Alminana --- .../ne_meminfo_linux.c | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/plugins/in_node_exporter_metrics/ne_meminfo_linux.c b/plugins/in_node_exporter_metrics/ne_meminfo_linux.c index 527ee116d21..5ea5a572b63 100644 --- a/plugins/in_node_exporter_metrics/ne_meminfo_linux.c +++ b/plugins/in_node_exporter_metrics/ne_meminfo_linux.c @@ -33,6 +33,7 @@ static int meminfo_configure(struct flb_ne *ctx) int parts; int len; char *p; + flb_sds_t tmp; char desc[] = "Memory information field "; struct cmt_gauge *g; struct mk_list *head; @@ -100,12 +101,21 @@ static int meminfo_configure(struct flb_ne *ctx) /* Metric description */ flb_sds_len_set(metric_desc, 0); - flb_sds_cat(metric_desc, desc, sizeof(desc) - 1); + ret = flb_sds_cat_safe(&metric_desc, desc, sizeof(desc) - 1); + + if (ret != 0) { + flb_slist_destroy(&split_list); + goto error; + } if (parts == 2) { /* No unit */ - flb_sds_cat(metric_desc, metric_name, flb_sds_len(metric_name)); - flb_sds_cat(metric_desc, ".", 1); + tmp = flb_sds_printf(&metric_desc, "%s.", metric_name); + + if (tmp == NULL) { + flb_slist_destroy(&split_list); + goto error; + } g = cmt_gauge_create(ctx->cmt, "node", "memory", metric_name, metric_desc, @@ -117,9 +127,20 @@ static int meminfo_configure(struct flb_ne *ctx) } else if (parts == 3) { /* It has an extra 'kB' string in the line */ - flb_sds_cat(metric_name, "_bytes", 6); - flb_sds_cat(metric_desc, metric_name, flb_sds_len(metric_name)); - flb_sds_cat(metric_desc, ".", 1); + ret = flb_sds_cat_safe(&metric_name, "_bytes", 6); + + if (ret != 0) { + flb_slist_destroy(&split_list); + goto error; + } + + tmp = flb_sds_printf(&metric_desc, "%s.", metric_name); + + if (tmp == NULL) { + flb_slist_destroy(&split_list); + goto error; + } + g = cmt_gauge_create(ctx->cmt, "node", "memory", metric_name, metric_desc, 0, NULL); @@ -132,6 +153,7 @@ static int meminfo_configure(struct flb_ne *ctx) flb_slist_destroy(&split_list); continue; } + flb_slist_destroy(&split_list); /* From 667e50e302b7bbdd5fc77044655045f32524edfc Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Thu, 29 Aug 2024 16:19:19 +0900 Subject: [PATCH 142/295] in_podman_metrics: Plug a resource leak on exception (CID 507805) Signed-off-by: Hiroshi Hatake --- plugins/in_podman_metrics/podman_metrics_data.c | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/in_podman_metrics/podman_metrics_data.c b/plugins/in_podman_metrics/podman_metrics_data.c index fd4ee280c68..c841ffaff4e 100644 --- a/plugins/in_podman_metrics/podman_metrics_data.c +++ b/plugins/in_podman_metrics/podman_metrics_data.c @@ -287,6 +287,7 @@ int collect_sysfs_directories(struct flb_in_metrics *ctx, flb_sds_t name) pth = flb_malloc(sizeof(struct sysfs_path)); if (!pth) { flb_errno(); + closedir(dir); return -1; } pth->path = flb_sds_create(path); From abcf3a4d2d3f7105c9fa9b085fa084bb40deeabe Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 28 Aug 2024 15:08:24 +0200 Subject: [PATCH 143/295] reload: added appropriate type cast (CID 508209) Signed-off-by: Leonardo Alminana --- src/flb_reload.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/flb_reload.c b/src/flb_reload.c index 2e6c4d6572c..b66a4c80b3b 100644 --- a/src/flb_reload.c +++ b/src/flb_reload.c @@ -407,7 +407,9 @@ int flb_reload(flb_ctx_t *ctx, struct flb_cf *cf_opts) return FLB_RELOAD_HALTED; } - flb_info("reloading instance pid=%lu tid=%p", (long unsigned) getpid(), pthread_self()); + flb_info("reloading instance pid=%lu tid=%p", + (long unsigned int) getpid(), + (void *) pthread_self()); if (old_config->conf_path_file) { file = flb_sds_create(old_config->conf_path_file); From 7fbb63fb098b0432eca634c9e7b881b6b0d247bb Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Thu, 29 Aug 2024 18:13:38 -0600 Subject: [PATCH 144/295] out_opentelemetry: fix record accessor pattern (CID 507960) Signed-off-by: Eduardo Silva --- plugins/out_opentelemetry/opentelemetry_logs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/out_opentelemetry/opentelemetry_logs.c b/plugins/out_opentelemetry/opentelemetry_logs.c index 7d55fe32a8b..8cfd0912479 100644 --- a/plugins/out_opentelemetry/opentelemetry_logs.c +++ b/plugins/out_opentelemetry/opentelemetry_logs.c @@ -482,7 +482,7 @@ static int append_v1_logs_metadata_and_fields(struct opentelemetry_context *ctx, } if (!severity_number_set && ctx->ra_severity_number_message) { - ra_val = flb_ra_get_value_object(ctx->ra_severity_number_metadata, *event->body); + ra_val = flb_ra_get_value_object(ctx->ra_severity_number_message, *event->body); if (ra_val != NULL) { if (ra_val->o.type == MSGPACK_OBJECT_POSITIVE_INTEGER && is_valid_severity_number(ra_val->o.via.u64)) { log_record->severity_number = ra_val->o.via.u64; From 3c367cd3bd7e5893c072c986f4d73a1d561adc4a Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Thu, 29 Aug 2024 18:28:46 -0600 Subject: [PATCH 145/295] out_opentelemetry: skip ra_trace_flags_metadata check (CID 508199) Signed-off-by: Eduardo Silva --- plugins/out_opentelemetry/opentelemetry_logs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/out_opentelemetry/opentelemetry_logs.c b/plugins/out_opentelemetry/opentelemetry_logs.c index 8cfd0912479..d7b7cea2fb3 100644 --- a/plugins/out_opentelemetry/opentelemetry_logs.c +++ b/plugins/out_opentelemetry/opentelemetry_logs.c @@ -640,7 +640,7 @@ static int append_v1_logs_metadata_and_fields(struct opentelemetry_context *ctx, flb_ra_key_value_destroy(ra_val); } - if (!trace_flags_set && ctx->ra_trace_flags_metadata) { + if (!trace_flags_set) { ra_val = flb_ra_get_value_object(ctx->ra_trace_flags_metadata, *event->metadata); if (ra_val != NULL) { if (ra_val->o.type == MSGPACK_OBJECT_POSITIVE_INTEGER) { From fe43ed120ce9c2612f75cca4424150c1b15690d5 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Thu, 29 Aug 2024 18:32:39 -0600 Subject: [PATCH 146/295] out_calyptia: initialize return and http context (CID 507836) Signed-off-by: Eduardo Silva --- plugins/out_calyptia/calyptia.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/plugins/out_calyptia/calyptia.c b/plugins/out_calyptia/calyptia.c index 4f3a7f99fc6..6b53a31c2ca 100644 --- a/plugins/out_calyptia/calyptia.c +++ b/plugins/out_calyptia/calyptia.c @@ -759,7 +759,7 @@ static int cb_calyptia_init(struct flb_output_instance *ins, #ifdef FLB_HAVE_CHUNK_TRACE ctx->trace_endpoint = flb_sds_create_size(256); - flb_sds_printf(&ctx->trace_endpoint, CALYPTIA_ENDPOINT_TRACE, + flb_sds_printf(&ctx->trace_endpoint, CALYPTIA_ENDPOINT_TRACE, ctx->pipeline_id); #endif /* FLB_HAVE_CHUNK_TRACE */ return 0; @@ -790,7 +790,7 @@ static void cb_calyptia_flush(struct flb_event_chunk *event_chunk, void *out_context, struct flb_config *config) { - int ret; + int ret = FLB_RETRY; size_t off = 0; size_t out_size = 0; char *out_buf = NULL; @@ -801,7 +801,7 @@ static void cb_calyptia_flush(struct flb_event_chunk *event_chunk, #endif /* FLB_HAVE_CHUNK_TRACE */ struct flb_connection *u_conn; - struct flb_http_client *c; + struct flb_http_client *c = NULL; struct flb_calyptia *ctx = out_context; struct cmt *cmt; (void) i_ins; @@ -867,7 +867,7 @@ static void cb_calyptia_flush(struct flb_event_chunk *event_chunk, cmt_encode_msgpack_destroy(out_buf); } } - + #ifdef FLB_HAVE_CHUNK_TRACE if (event_chunk->type == (FLB_EVENT_TYPE_LOGS | FLB_EVENT_TYPE_HAS_TRACE)) { json = flb_pack_msgpack_to_json_format(event_chunk->data, @@ -896,7 +896,7 @@ static void cb_calyptia_flush(struct flb_event_chunk *event_chunk, flb_sds_destroy(ctx->metrics_endpoint); FLB_OUTPUT_RETURN(FLB_RETRY); } - + /* perform request: 'ret' might be FLB_OK, FLB_ERROR or FLB_RETRY */ ret = calyptia_http_do(ctx, c, CALYPTIA_ACTION_TRACE); if (ret == FLB_OK) { @@ -911,7 +911,10 @@ static void cb_calyptia_flush(struct flb_event_chunk *event_chunk, #endif /* FLB_HAVE_CHUNK_TRACE */ flb_upstream_conn_release(u_conn); - flb_http_client_destroy(c); + + if (c) { + flb_http_client_destroy(c); + } FLB_OUTPUT_RETURN(ret); } From 851d94bd8594d55681cf6ef2539db7953bc18895 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Fri, 30 Aug 2024 12:30:12 +0200 Subject: [PATCH 147/295] in_event_type: fixed two leaks Signed-off-by: leonardo-albertovich --- plugins/in_event_type/event_type.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/in_event_type/event_type.c b/plugins/in_event_type/event_type.c index 08d97c13774..aad5acccb11 100644 --- a/plugins/in_event_type/event_type.c +++ b/plugins/in_event_type/event_type.c @@ -407,12 +407,13 @@ static int cb_event_type_init(struct flb_input_instance *ins, ret = flb_input_config_map_set(ins, (void *) ctx); if (ret == -1) { + flb_free(ctx); + return -1; } flb_input_set_context(ins, ctx); - ctx->type = FLB_EVENT_TYPE_LOGS; tmp = (char *) flb_input_get_property("type", ins); if (tmp) { @@ -431,8 +432,11 @@ static int cb_event_type_init(struct flb_input_instance *ins, ret = flb_input_set_collector_time(ins, cb_collector_time, ctx->interval_sec, ctx->interval_nsec, config); if (ret < 0) { + flb_free(ctx); + return -1; } + ctx->coll_fd = ret; return 0; From 193448ad19ee7634e26b249655146633b7cf5aac Mon Sep 17 00:00:00 2001 From: leonardo-albertovich Date: Sun, 1 Sep 2024 16:12:39 +0200 Subject: [PATCH 148/295] bin: fix memory leaks (#9310) Signed-off-by: leonardo-albertovich --- src/fluent-bit.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/fluent-bit.c b/src/fluent-bit.c index d35e034ed20..6444b333f2d 100644 --- a/src/fluent-bit.c +++ b/src/fluent-bit.c @@ -809,7 +809,7 @@ static int enable_trace_input(flb_ctx_t *ctx, const char *name, const char *pref static int disable_trace_input(flb_ctx_t *ctx, const char *name) { struct flb_input_instance *in; - + in = find_input(ctx, name); if (in == NULL) { @@ -911,11 +911,18 @@ static int parse_trace_pipeline(flb_ctx_t *ctx, const char *pipeline, char **tra else if (strncmp(key, "output.", strlen("output.")) == 0) { propname = mk_string_copy_substr(key, strlen("output."), strlen(key)); if (propname == NULL) { + mk_mem_free(key); + flb_free(value); + return FLB_ERROR; } propval = flb_strdup(value); if (propval == NULL) { + mk_mem_free(propname); + mk_mem_free(key); + flb_free(value); + return FLB_ERROR; } @@ -927,6 +934,10 @@ static int parse_trace_pipeline(flb_ctx_t *ctx, const char *pipeline, char **tra flb_kv_item_create_len(*props, (char *)propname, strlen(propname), (char *)propval, strlen(propval)); + + mk_mem_free(propname); + flb_free(propval); + } if (key != NULL) { From 78152e43b29f127196c00a6246287b4a7e97c65c Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Fri, 30 Aug 2024 15:32:42 +0900 Subject: [PATCH 149/295] record_accessor: Plug a resource leak on exception (CID 508119) Signed-off-by: Hiroshi Hatake --- src/flb_record_accessor.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/flb_record_accessor.c b/src/flb_record_accessor.c index bb9adad57a9..d4b74edfdee 100644 --- a/src/flb_record_accessor.c +++ b/src/flb_record_accessor.c @@ -386,6 +386,7 @@ flb_sds_t flb_ra_create_str_from_list(struct flb_sds_list *str_list) strs = flb_sds_list_create_str_array(str_list); if (strs == NULL) { flb_error("%s flb_sds_list_create_str_array failed", __FUNCTION__); + flb_sds_destroy(str); return NULL; } From c7e63526872f30ec89366e131881c2803272a369 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Fri, 30 Aug 2024 16:11:45 +0900 Subject: [PATCH 150/295] out_opentelemetry: Prevent null dereference on memcpy (CID 507910) Signed-off-by: Hiroshi Hatake --- plugins/out_opentelemetry/opentelemetry_utils.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/out_opentelemetry/opentelemetry_utils.c b/plugins/out_opentelemetry/opentelemetry_utils.c index 8c09cfcb4f8..981278ef471 100644 --- a/plugins/out_opentelemetry/opentelemetry_utils.c +++ b/plugins/out_opentelemetry/opentelemetry_utils.c @@ -334,13 +334,15 @@ Opentelemetry__Proto__Common__V1__AnyValue *msgpack_bin_to_otlp_any_value(struct result->bytes_value.len = o->via.bin.size; result->bytes_value.data = flb_malloc(o->via.bin.size); - if (result->bytes_value.data == NULL) { + if (result->bytes_value.data) { + memcpy(result->bytes_value.data, o->via.bin.ptr, o->via.bin.size); + } + else { otlp_any_value_destroy(result); result = NULL; } - memcpy(result->bytes_value.data, o->via.bin.ptr, o->via.bin.size); } return result; From 0fbe28c09c60eb12a7446db0b387e3801b575270 Mon Sep 17 00:00:00 2001 From: leonardo-albertovich Date: Fri, 30 Aug 2024 11:35:01 +0200 Subject: [PATCH 151/295] out_opentelemetry: coding style fix Signed-off-by: leonardo-albertovich --- plugins/out_opentelemetry/opentelemetry_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/out_opentelemetry/opentelemetry_utils.c b/plugins/out_opentelemetry/opentelemetry_utils.c index 981278ef471..25f6baa49e6 100644 --- a/plugins/out_opentelemetry/opentelemetry_utils.c +++ b/plugins/out_opentelemetry/opentelemetry_utils.c @@ -334,7 +334,7 @@ Opentelemetry__Proto__Common__V1__AnyValue *msgpack_bin_to_otlp_any_value(struct result->bytes_value.len = o->via.bin.size; result->bytes_value.data = flb_malloc(o->via.bin.size); - if (result->bytes_value.data) { + if (result->bytes_value.data != NULL) { memcpy(result->bytes_value.data, o->via.bin.ptr, o->via.bin.size); } else { From 44ac4192886eb21db46434c9842155f5e468d97d Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Fri, 30 Aug 2024 19:02:44 +0200 Subject: [PATCH 152/295] filter_multiline: fixed memory leak Signed-off-by: leonardo-albertovich --- plugins/filter_multiline/ml.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/filter_multiline/ml.c b/plugins/filter_multiline/ml.c index 152a0982ae0..4c5130a1b74 100644 --- a/plugins/filter_multiline/ml.c +++ b/plugins/filter_multiline/ml.c @@ -224,6 +224,9 @@ static int cb_ml_init(struct flb_filter_instance *ins, flb_plg_error(ins, "'Mode' must be '%s' or '%s'", FLB_MULTILINE_MODE_PARTIAL_MESSAGE, FLB_MULTILINE_MODE_PARSER); + + flb_free(ctx); + return -1; } } From d466d6f4705efaefeceab6203aae84b1de76b97b Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Fri, 30 Aug 2024 19:07:38 +0200 Subject: [PATCH 153/295] sp: changed property type to prevent lossy cast Signed-off-by: leonardo-albertovich --- include/fluent-bit/stream_processor/flb_sp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fluent-bit/stream_processor/flb_sp.h b/include/fluent-bit/stream_processor/flb_sp.h index 506f8b5f161..81ee8ccc6be 100644 --- a/include/fluent-bit/stream_processor/flb_sp.h +++ b/include/fluent-bit/stream_processor/flb_sp.h @@ -116,7 +116,7 @@ struct flb_sp_task_window { */ bool first_hop; int fd_hop; - int advance_by; + time_t advance_by; struct mk_list hopping_slot; int records; From 72a81884551a6817a6227d6a185a372dc9d4e45a Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Sat, 31 Aug 2024 12:05:44 -0600 Subject: [PATCH 154/295] lib: cmetrics: upgrade to v0.9.5 Signed-off-by: Eduardo Silva --- lib/cmetrics/.github/workflows/packages.yaml | 57 +++++++++++++++++++ lib/cmetrics/CMakeLists.txt | 2 +- lib/cmetrics/src/cmt_decode_prometheus.c | 13 ++++- .../src/cmt_decode_prometheus_remote_write.c | 18 +++++- lib/cmetrics/src/cmt_decode_statsd.c | 43 ++++++++++---- lib/cmetrics/src/cmt_encode_influx.c | 34 +++++++---- lib/cmetrics/src/cmt_encode_opentelemetry.c | 8 +-- .../tests/data/issue_fluent_bit_9267.txt | 1 + lib/cmetrics/tests/encoding.c | 53 +++++++++++++++++ lib/cmetrics/tests/prometheus_parser.c | 31 +++++++++- 10 files changed, 227 insertions(+), 33 deletions(-) create mode 100644 lib/cmetrics/tests/data/issue_fluent_bit_9267.txt diff --git a/lib/cmetrics/.github/workflows/packages.yaml b/lib/cmetrics/.github/workflows/packages.yaml index 8272af809d3..f0ed2335d6b 100644 --- a/lib/cmetrics/.github/workflows/packages.yaml +++ b/lib/cmetrics/.github/workflows/packages.yaml @@ -69,11 +69,68 @@ jobs: path: | ./*.${{matrix.format}} + build-macos-packages-amd64: + name: build macOS intel packages + strategy: + fail-fast: true + matrix: + config: + - format: productbuild + arch: intel + ext: pkg + runs-on: macos-12 + steps: + - uses: actions/checkout@v3 + with: + submodules: true + + - name: Build the ${{matrix.config.format}} packages + run: | + cmake . -DCPACK_GENERATOR=${{ matrix.config.format }} + echo ${{ matrix.config.format }} | xargs -I{} cpack -G {} + + - name: Store the master package artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.config.format }}-${{matrix.config.arch}} + path: | + ./*-${{matrix.config.arch}}.${{matrix.config.ext}} + + build-macos-packages-arm64: + name: build macOS Apple Silicon packages + strategy: + fail-fast: true + matrix: + config: + - format: productbuild + arch: apple + ext: pkg + runs-on: macos-14 + steps: + - uses: actions/checkout@v3 + with: + submodules: true + + - name: Build the ${{matrix.config.format}} packages + run: | + cmake . -DCPACK_GENERATOR=${{ matrix.config.format }} + echo ${{ matrix.config.format }} | xargs -I{} cpack -G {} + + - name: Store the master package artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.config.format }}-${{matrix.config.arch}} + path: | + ./*-${{matrix.config.arch}}.${{matrix.config.ext}} + release: name: Create release and upload packages needs: - build-distro-packages-amd64 - build-distro-packages-arm64 + - build-macos-packages-amd64 + - build-macos-packages-arm64 + runs-on: ubuntu-latest permissions: contents: write diff --git a/lib/cmetrics/CMakeLists.txt b/lib/cmetrics/CMakeLists.txt index f5221d7f524..1cdd0db35da 100644 --- a/lib/cmetrics/CMakeLists.txt +++ b/lib/cmetrics/CMakeLists.txt @@ -6,7 +6,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # CMetrics Version set(CMT_VERSION_MAJOR 0) set(CMT_VERSION_MINOR 9) -set(CMT_VERSION_PATCH 4) +set(CMT_VERSION_PATCH 5) set(CMT_VERSION_STR "${CMT_VERSION_MAJOR}.${CMT_VERSION_MINOR}.${CMT_VERSION_PATCH}") # Include helpers diff --git a/lib/cmetrics/src/cmt_decode_prometheus.c b/lib/cmetrics/src/cmt_decode_prometheus.c index 3a87c34ee74..134cb92a54c 100644 --- a/lib/cmetrics/src/cmt_decode_prometheus.c +++ b/lib/cmetrics/src/cmt_decode_prometheus.c @@ -57,9 +57,16 @@ static void reset_context(struct cmt_decode_prometheus_context *context, } if (context->metric.ns) { - if (strcmp(context->metric.ns, "")) { + if ((void *) context->metric.ns != (void *) "") { /* when namespace is empty, "name" contains a pointer to the - * allocated string */ + * allocated string. + * + * Note : When the metric name doesn't include the namespace + * ns is set to a constant empty string and we need to + * differentiate that case from the case where an empty + * namespace is provided. + */ + free(context->metric.ns); } else { @@ -516,7 +523,7 @@ static int add_metric_histogram(struct cmt_decode_prometheus_context *context) "failed to parse bucket"); goto end; } - if (parse_uint64(sample->value1, + if (parse_uint64(sample->value1, bucket_defaults + bucket_index)) { /* Count is supposed to be integer, but apparently * some tools can generate count in a floating format. diff --git a/lib/cmetrics/src/cmt_decode_prometheus_remote_write.c b/lib/cmetrics/src/cmt_decode_prometheus_remote_write.c index 4aa91e676d4..3adeccefc4c 100644 --- a/lib/cmetrics/src/cmt_decode_prometheus_remote_write.c +++ b/lib/cmetrics/src/cmt_decode_prometheus_remote_write.c @@ -413,6 +413,8 @@ static int decode_histogram_points(struct cmt *cmt, destroy_label_list(&metric->labels); free(metric); + + return CMT_DECODE_PROMETHEUS_REMOTE_WRITE_DECODE_ERROR; } else { cfl_list_add(&metric->_head, &map->metrics); @@ -438,7 +440,13 @@ static int decode_histogram_points(struct cmt *cmt, } } else { - free(metric); + if (static_metric_detected == CMT_FALSE) { + destroy_label_list(&metric->labels); + + cfl_list_del(&metric->_head); + + free(metric); + } return CMT_DECODE_PROMETHEUS_REMOTE_WRITE_DECODE_ERROR; } @@ -452,7 +460,13 @@ static int decode_histogram_points(struct cmt *cmt, metric->hist_count = hist->count_float; } else { - free(metric); + if (static_metric_detected == CMT_FALSE) { + destroy_label_list(&metric->labels); + + cfl_list_del(&metric->_head); + + free(metric); + } return CMT_DECODE_PROMETHEUS_REMOTE_WRITE_DECODE_ERROR; } diff --git a/lib/cmetrics/src/cmt_decode_statsd.c b/lib/cmetrics/src/cmt_decode_statsd.c index 168f7ecc338..43b2213135c 100644 --- a/lib/cmetrics/src/cmt_decode_statsd.c +++ b/lib/cmetrics/src/cmt_decode_statsd.c @@ -108,7 +108,7 @@ static int decode_labels(struct cmt *cmt, size_t label_index; int label_found; char *label_kv, *colon; - cfl_sds_t label_k, label_v, tmp; + cfl_sds_t label_k = NULL, label_v = NULL, tmp = NULL; int result; struct cfl_list *head = NULL; struct cfl_list *kvs = NULL; @@ -157,7 +157,14 @@ static int decode_labels(struct cmt *cmt, } label_k = cfl_sds_create_len(label_kv, colon - label_kv); if (label_k == NULL) { + for (label_index = 0 ; label_index < 128 ; label_index++) { + if (value_index_list[label_index] != NULL) { + cfl_sds_destroy(value_index_list[label_index]); + } + } + free(value_index_list); + if (kvs != NULL) { cfl_utils_split_free(kvs); } @@ -167,7 +174,15 @@ static int decode_labels(struct cmt *cmt, label_v = cfl_sds_create_len(colon + 1, strlen(label_kv) - strlen(label_k) - 1); if (label_v == NULL) { cfl_sds_destroy(label_k); + + for (label_index = 0 ; label_index < 128 ; label_index++) { + if (value_index_list[label_index] != NULL) { + cfl_sds_destroy(value_index_list[label_index]); + } + } + free(value_index_list); + if (kvs != NULL) { cfl_utils_split_free(kvs); } @@ -190,7 +205,15 @@ static int decode_labels(struct cmt *cmt, if (label_index > 127) { cfl_sds_destroy(label_k); cfl_sds_destroy(label_v); + + for (label_index = 0 ; label_index < 128 ; label_index++) { + if (value_index_list[label_index] != NULL) { + cfl_sds_destroy(value_index_list[label_index]); + } + } + free(value_index_list); + if (kvs != NULL) { cfl_utils_split_free(kvs); } @@ -203,10 +226,12 @@ static int decode_labels(struct cmt *cmt, } if (result == CMT_DECODE_STATSD_SUCCESS) { - value_index_list[label_index] = (void *) label_v; + value_index_list[label_index] = (void *) cfl_sds_create_len(label_v, + cfl_sds_len(label_v)); } cfl_sds_destroy(label_k); + cfl_sds_destroy(label_v); } } @@ -225,20 +250,18 @@ static int decode_labels(struct cmt *cmt, } } - for (map_label_index = 0 ; - result == CMT_DECODE_STATSD_SUCCESS && - map_label_index < map_label_count ; - map_label_index++) { - label_v = (cfl_sds_t) value_index_list[map_label_index]; - cfl_sds_destroy(label_v); + for (label_index = 0 ; label_index < 128 ; label_index++) { + if (value_index_list[label_index] != NULL) { + cfl_sds_destroy(value_index_list[label_index]); + } } + free(value_index_list); + if (kvs != NULL) { cfl_utils_split_free(kvs); } - free(value_index_list); - return result; } diff --git a/lib/cmetrics/src/cmt_encode_influx.c b/lib/cmetrics/src/cmt_encode_influx.c index 1dfe3797d43..747355d3176 100644 --- a/lib/cmetrics/src/cmt_encode_influx.c +++ b/lib/cmetrics/src/cmt_encode_influx.c @@ -226,8 +226,9 @@ static void format_metric(struct cmt *cmt, cfl_sds_t *buf, struct cmt_map *map, { int i; int n; - int count = 0; + int static_count = 0; int static_labels = 0; + int has_namespace = CMT_FALSE; struct cmt_map_label *label_k; struct cmt_map_label *label_v; struct cfl_list *head; @@ -241,19 +242,26 @@ static void format_metric(struct cmt *cmt, cfl_sds_t *buf, struct cmt_map *map, opts = map->opts; /* Measurement */ - cfl_sds_cat_safe(buf, opts->ns, cfl_sds_len(opts->ns)); - - if (cfl_sds_len(opts->subsystem) > 0) { - cfl_sds_cat_safe(buf, "_", 1); - cfl_sds_cat_safe(buf, opts->subsystem, cfl_sds_len(opts->subsystem)); + if (cfl_sds_len(opts->ns) > 0) { + cfl_sds_cat_safe(buf, opts->ns, cfl_sds_len(opts->ns)); + if (cfl_sds_len(opts->subsystem) > 0) { + cfl_sds_cat_safe(buf, "_", 1); + cfl_sds_cat_safe(buf, opts->subsystem, cfl_sds_len(opts->subsystem)); + } + has_namespace = CMT_TRUE; + } + else { + has_namespace = CMT_FALSE; } /* Static labels (tags) */ static_labels = cmt_labels_count(cmt->static_labels); if (static_labels > 0) { - cfl_sds_cat_safe(buf, ",", 1); + if (has_namespace == CMT_TRUE) { + cfl_sds_cat_safe(buf, ",", 1); + } cfl_list_foreach(head, &cmt->static_labels->list) { - count++; + static_count++; slabel = cfl_list_entry(head, struct cmt_label, _head); /* key */ @@ -265,7 +273,7 @@ static void format_metric(struct cmt *cmt, cfl_sds_t *buf, struct cmt_map *map, /* val */ append_string(buf, slabel->val); - if (count < static_labels) { + if (static_count < static_labels) { cfl_sds_cat_safe(buf, ",", 1); } } @@ -274,7 +282,9 @@ static void format_metric(struct cmt *cmt, cfl_sds_t *buf, struct cmt_map *map, /* Labels / Tags */ n = cfl_list_size(&metric->labels); if (n > 0) { - cfl_sds_cat_safe(buf, ",", 1); + if (static_labels > 0 || has_namespace == CMT_TRUE) { + cfl_sds_cat_safe(buf, ",", 1); + } label_k = cfl_list_entry_first(&map->label_keys, struct cmt_map_label, _head); @@ -297,7 +307,9 @@ static void format_metric(struct cmt *cmt, cfl_sds_t *buf, struct cmt_map *map, } } - cfl_sds_cat_safe(buf, " ", 1); + if (has_namespace == CMT_TRUE || static_labels > 0 || n > 0) { + cfl_sds_cat_safe(buf, " ", 1); + } append_metric_value(map, buf, metric); } diff --git a/lib/cmetrics/src/cmt_encode_opentelemetry.c b/lib/cmetrics/src/cmt_encode_opentelemetry.c index 8c934186330..8378bc8694d 100644 --- a/lib/cmetrics/src/cmt_encode_opentelemetry.c +++ b/lib/cmetrics/src/cmt_encode_opentelemetry.c @@ -711,13 +711,13 @@ static inline Opentelemetry__Proto__Common__V1__AnyValue *cfl_variant_binary_to_ result->bytes_value.len = cfl_sds_len(value->data.as_bytes); result->bytes_value.data = calloc(result->bytes_value.len, sizeof(char)); - if (result->bytes_value.data == NULL) { + if (result->bytes_value.data) { + memcpy(result->bytes_value.data, value->data.as_bytes, result->bytes_value.len); + } + else { otlp_any_value_destroy(result); - result = NULL; } - - memcpy(result->bytes_value.data, value->data.as_bytes, result->bytes_value.len); } return result; diff --git a/lib/cmetrics/tests/data/issue_fluent_bit_9267.txt b/lib/cmetrics/tests/data/issue_fluent_bit_9267.txt new file mode 100644 index 00000000000..979183b032f --- /dev/null +++ b/lib/cmetrics/tests/data/issue_fluent_bit_9267.txt @@ -0,0 +1 @@ +_bu_nn 0 171798732 \ No newline at end of file diff --git a/lib/cmetrics/tests/encoding.c b/lib/cmetrics/tests/encoding.c index 9d4478e4016..b962a468bd3 100644 --- a/lib/cmetrics/tests/encoding.c +++ b/lib/cmetrics/tests/encoding.c @@ -803,6 +803,58 @@ void test_influx() cmt_destroy(cmt); } +void test_influx_without_namespaces() +{ + uint64_t ts; + cfl_sds_t text; + struct cmt *cmt; + struct cmt_counter *c1; + struct cmt_counter *c2; + + char *out1 = \ + "test=1 1435658235000000123\n" + "host=calyptia.com,app=cmetrics test=2 1435658235000000123\n" + "host=aaa,app=bbb nosubsystem=1 1435658235000000123\n"; + + char *out2 = \ + "dev=Calyptia,lang=C test=1 1435658235000000123\n" + "dev=Calyptia,lang=C,host=calyptia.com,app=cmetrics test=2 1435658235000000123\n" + "dev=Calyptia,lang=C,host=aaa,app=bbb nosubsystem=1 1435658235000000123\n"; + + cmt = cmt_create(); + TEST_CHECK(cmt != NULL); + + c1 = cmt_counter_create(cmt, "", "", "test", "Static labels test", + 2, (char *[]) {"host", "app"}); + + ts = 1435658235000000123; + cmt_counter_inc(c1, ts, 0, NULL); + cmt_counter_inc(c1, ts, 2, (char *[]) {"calyptia.com", "cmetrics"}); + cmt_counter_inc(c1, ts, 2, (char *[]) {"calyptia.com", "cmetrics"}); + + c2 = cmt_counter_create(cmt, "", "", "nosubsystem", "No subsystem", + 2, (char *[]) {"host", "app"}); + + cmt_counter_inc(c2, ts, 2, (char *[]) {"aaa", "bbb"}); + + /* Encode to prometheus (no static labels) */ + text = cmt_encode_influx_create(cmt); + printf("%s\n", text); + TEST_CHECK(strcmp(text, out1) == 0); + cmt_encode_influx_destroy(text); + + /* append static labels */ + cmt_label_add(cmt, "dev", "Calyptia"); + cmt_label_add(cmt, "lang", "C"); + + text = cmt_encode_influx_create(cmt); + printf("%s\n", text); + TEST_CHECK(strcmp(text, out2) == 0); + cmt_encode_influx_destroy(text); + + cmt_destroy(cmt); +} + void test_splunk_hec() { uint64_t ts; @@ -1125,6 +1177,7 @@ TEST_LIST = { {"prometheus", test_prometheus}, {"text", test_text}, {"influx", test_influx}, + {"influx_without_namespaces", test_influx_without_namespaces}, {"splunk_hec", test_splunk_hec}, {"splunk_hec_floating_point", test_splunk_hec_floating_point}, {"splunk_hec_histogram", test_splunk_hec_histogram}, diff --git a/lib/cmetrics/tests/prometheus_parser.c b/lib/cmetrics/tests/prometheus_parser.c index 8cdef466a72..5fa0c889886 100644 --- a/lib/cmetrics/tests/prometheus_parser.c +++ b/lib/cmetrics/tests/prometheus_parser.c @@ -261,7 +261,7 @@ void test_escape_sequences() } void test_metric_without_labels() -{ +{ cfl_sds_t result; const char expected[] = @@ -776,7 +776,7 @@ void test_issue_fluent_bit_5541() "http_request_duration_seconds_bucket{le=\"0.25\"} 2 0\n" "http_request_duration_seconds_bucket{le=\"0.5\"} 2 0\n" "http_request_duration_seconds_bucket{le=\"0.75\"} 2 0\n" - "http_request_duration_seconds_bucket{le=\"1.0\"} 2 0\n" + "http_request_duration_seconds_bucket{le=\"1.0\"} 2 0\n" "http_request_duration_seconds_bucket{le=\"2.5\"} 2 0\n" "http_request_duration_seconds_bucket{le=\"5.0\"} 2 0\n" "http_request_duration_seconds_bucket{le=\"7.5\"} 2 0\n" @@ -1665,6 +1665,32 @@ void test_issue_fluent_bit_6534() cmt_decode_prometheus_destroy(cmt); } +void test_issue_fluent_bit_9267() +{ + char errbuf[256]; + int status; + cfl_sds_t result = NULL; + struct cmt *cmt; + struct cmt_decode_prometheus_parse_opts opts; + memset(&opts, 0, sizeof(opts)); + opts.errbuf = errbuf; + opts.errbuf_size = sizeof(errbuf); + cfl_sds_t in_buf = read_file(CMT_TESTS_DATA_PATH "/issue_fluent_bit_9267.txt"); + size_t in_size = cfl_sds_len(in_buf); + + cmt = NULL; + status = cmt_decode_prometheus_create(&cmt, in_buf, in_size, &opts); + TEST_CHECK(status == 0); + if (status) { + fprintf(stderr, "PARSE ERROR:\n======\n%s\n======\n", errbuf); + } + + if (cmt != NULL) { + cmt_decode_prometheus_destroy(cmt); + } + cfl_sds_destroy(in_buf); +} + TEST_LIST = { {"header_help", test_header_help}, {"header_type", test_header_type}, @@ -1697,5 +1723,6 @@ TEST_LIST = { {"pr_168", test_pr_168}, {"histogram_different_label_count", test_histogram_different_label_count}, {"issue_fluent_bit_6534", test_issue_fluent_bit_6534}, + {"issue_fluent_bit_9267", test_issue_fluent_bit_9267}, { 0 } }; From c6e902a43ad48fbaa0669e3cc4deec77ec280c71 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Fri, 30 Aug 2024 19:11:50 +0200 Subject: [PATCH 155/295] filter_alter_size: fixed memory leak Signed-off-by: leonardo-albertovich --- plugins/filter_alter_size/alter_size.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/filter_alter_size/alter_size.c b/plugins/filter_alter_size/alter_size.c index e4f5693ea2b..75e50052bf3 100644 --- a/plugins/filter_alter_size/alter_size.c +++ b/plugins/filter_alter_size/alter_size.c @@ -51,6 +51,8 @@ static int cb_alter_size_init(struct flb_filter_instance *ins, if (ctx->log_decoder == NULL) { flb_plg_error(ins, "could not initialize event decoder"); + flb_free(ctx); + return -1; } @@ -58,7 +60,9 @@ static int cb_alter_size_init(struct flb_filter_instance *ins, if (ctx->log_encoder == NULL) { flb_plg_error(ins, "could not initialize event encoder"); + flb_log_event_decoder_destroy(ctx->log_decoder); + flb_free(ctx); return -1; } From c69a6dfe9bd912892eb22dfddaa9101434e3ef8e Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 2 Sep 2024 07:29:03 -0600 Subject: [PATCH 156/295] build: bump to v3.2 series Signed-off-by: Eduardo Silva --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e2e9fbf3b04..9e42d4faffc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,8 +7,8 @@ set(CMAKE_POLICY_DEFAULT_CMP0069 NEW) # Fluent Bit Version set(FLB_VERSION_MAJOR 3) -set(FLB_VERSION_MINOR 1) -set(FLB_VERSION_PATCH 7) +set(FLB_VERSION_MINOR 2) +set(FLB_VERSION_PATCH 0) set(FLB_VERSION_STR "${FLB_VERSION_MAJOR}.${FLB_VERSION_MINOR}.${FLB_VERSION_PATCH}") set(CMAKE_POSITION_INDEPENDENT_CODE ON) From 766c7dd6809ea976b97ca40dcca623212d5f3420 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 4 Sep 2024 15:22:39 +0300 Subject: [PATCH 157/295] workflows: bump peter-evans/create-pull-request from 6 to 7 (#9342) Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 6 to 7. - [Release notes](https://github.com/peter-evans/create-pull-request/releases) - [Commits](https://github.com/peter-evans/create-pull-request/compare/v6...v7) --- updated-dependencies: - dependency-name: peter-evans/create-pull-request dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/staging-release.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/staging-release.yaml b/.github/workflows/staging-release.yaml index 58d2660c935..b87633a50af 100644 --- a/.github/workflows/staging-release.yaml +++ b/.github/workflows/staging-release.yaml @@ -935,7 +935,7 @@ jobs: - name: Raise docs PR id: cpr - uses: peter-evans/create-pull-request@v6 + uses: peter-evans/create-pull-request@v7 with: commit-message: 'release: update to v${{ inputs.version }}' signoff: true @@ -1011,7 +1011,7 @@ jobs: - name: Raise FB PR to update version id: cpr - uses: peter-evans/create-pull-request@v6 + uses: peter-evans/create-pull-request@v7 with: commit-message: 'release: update to ${{ steps.semvers.outputs.patch }}' signoff: true From 2ff5372817d334257b149f50cdce68631ece9fa7 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Thu, 5 Sep 2024 20:23:35 +0900 Subject: [PATCH 158/295] workflows: linux: Compile and execute internal test on non-amd64 platforms Linux (#9313) * workflows: aarch64: linux: Compile and execute internal test on QEMU aarch64 Linux Signed-off-by: Hiroshi Hatake * workflows: aarch64: Omit to execute flb-it-utils and flb-it-pack tests Signed-off-by: Hiroshi Hatake * workflows: aarch64: Tweak for easily to extend for other non-amd64 platforms Signed-off-by: Hiroshi Hatake * workflows: aarch64: Add actuated runner settings for aarch64 Signed-off-by: Hiroshi Hatake * workflows: Reuse qemu settings for s390x CI task Signed-off-by: Hiroshi Hatake * workflows: s390x: Remove omit option to execute pack and utils internal tests Signed-off-by: Hiroshi Hatake * workflows: Remove needless conditions Signed-off-by: Hiroshi Hatake * workflows: aarch64: Shorten the timeout from 60mins. to 10mins. Signed-off-by: Hiroshi Hatake --------- Signed-off-by: Hiroshi Hatake --- .github/workflows/unit-tests.yaml | 109 ++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml index 61355f4a977..0fa50f11890 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -110,6 +110,113 @@ jobs: CXX: g++ FLB_OPT: ${{ matrix.flb_option }} + run-aarch64-unit-tests: + # Ensure for OSS Fluent Bit repo we enable usage of Actuated runners for ARM builds, for forks it should keep existing ubuntu-latest usage. + runs-on: ${{(github.repository == 'fluent/fluent-bit') && 'actuated-arm64-8cpu-16gb' || 'ubuntu-latest' }} + permissions: + contents: read + # We chain this after Linux one as there are costs for actuated workers + needs: + - run-ubuntu-unit-tests + timeout-minutes: 10 + strategy: + fail-fast: false + matrix: + config: + - name: "Aarch64 actuated testing" + flb_option: "-DFLB_WITHOUT_flb-it-network=1 -DFLB_WITHOUT_flb-it-fstore=1" + omit_option: "-DFLB_WITHOUT_flb-it-utils=1 -DFLB_WITHOUT_flb-it-pack=1" + global_option: "-DFLB_BACKTRACE=Off -DFLB_SHARED_LIB=Off -DFLB_DEBUG=On -DFLB_ALL=On -DFLB_EXAMPLES=Off" + unit_test_option: "-DFLB_TESTS_INTERNAL=On" + compiler: gcc + steps: + - name: Checkout Fluent Bit code + uses: actions/checkout@v4 + + - name: Set up Actuated mirror + if: github.repository == 'fluent/fluent-bit' + uses: self-actuated/hub-mirror@master + + - name: Setup environment + run: | + sudo apt-get update + sudo apt-get install -y gcc-9 g++-9 clang-12 cmake flex bison libsystemd-dev gcovr libyaml-dev + sudo ln -s /usr/bin/llvm-symbolizer-12 /usr/bin/llvm-symbolizer || true + + - name: Build and test with actuated runners + run: | + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90 + sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 90 + sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-12 90 + + export nparallel=$(( $(getconf _NPROCESSORS_ONLN) > 8 ? 8 : $(getconf _NPROCESSORS_ONLN) )) + export FLB_OPTION="${{ matrix.config.flb_option }}" + export FLB_OMIT_OPTION="${{ matrix.config.omit_option }}" + export GLOBAL_OPTION="${{ matrix.config.global_option }}" + export FLB_UNIT_TEST_OPTION="${{ matrix.config.unit_test_option }}" + export FLB_OPT="${FLB_OPTION} ${GLOBAL_OPTION} ${FLB_UNIT_TEST_OPTION} ${FLB_OMIT_OPTION}" + + echo "CC = ${{ matrix.config.compiler }}, CXX = ${{ matrix.config.compiler }}, FLB_OPT = $FLB_OPT" + + cmake ${FLB_OPT} ../ + make -j $nparallel + ctest -j $nparallel --build-run-dir . --output-on-failure + working-directory: build + env: + CC: ${{ matrix.config.compiler }} + CXX: ${{ matrix.config.compiler }} + + run-qemu-ubuntu-unit-tests: + # We chain this after Linux one as there are CPU time costs for QEMU emulation + needs: + - run-ubuntu-unit-tests + runs-on: ubuntu-20.04 + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + arch: + - s390x + steps: + - name: Checkout Fluent Bit code + uses: actions/checkout@v4 + + - name: Prepare and build with QEMU ${{ matrix.arch }} + uses: uraimo/run-on-arch-action@v2 + id: build-and-test-on-qemu + with: + arch: ${{ matrix.arch }} + distro: ubuntu20.04 + shell: /bin/bash + dockerRunArgs: | + --volume "/var/lib/dbus/machine-id:/var/lib/dbus/machine-id" + --volume "/etc/machine-id:/etc/machine-id" + install: | + apt-get update + apt-get install -y gcc-7 g++-7 clang-6.0 libyaml-dev cmake flex bison libssl-dev #libsystemd-dev + ln -s /usr/bin/llvm-symbolizer-6.0 /usr/bin/llvm-symbolizer || true + + update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 90 + update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 90 + update-alternatives --install /usr/bin/clang clang /usr/bin/clang-6.0 90 + run: | + cd build + export nparallel=$(( $(getconf _NPROCESSORS_ONLN) > 8 ? 8 : $(getconf _NPROCESSORS_ONLN) )) + export FLB_OPTION="-DFLB_WITHOUT_flb-it-network=1 -DFLB_WITHOUT_flb-it-fstore=1" + export FLB_OMIT_OPTION="" + export GLOBAL_OPTION="-DFLB_BACKTRACE=Off -DFLB_SHARED_LIB=Off -DFLB_DEBUG=On -DFLB_ALL=On -DFLB_EXAMPLES=Off" + export FLB_UNIT_TEST_OPTION="-DFLB_TESTS_INTERNAL=On" + export FLB_OPT="${FLB_OPTION} ${GLOBAL_OPTION} ${FLB_UNIT_TEST_OPTION} ${FLB_OMIT_OPTION}" + export CC=gcc + export CXX=gcc + + echo "CC = $CC, CXX = $CXX, FLB_OPT = $FLB_OPT" + + cmake ${FLB_OPT} ../ + make -j $nparallel + ctest -j $nparallel --build-run-dir . --output-on-failure + + # Required check looks at this so do not remove run-all-unit-tests: if: always() @@ -120,6 +227,8 @@ jobs: needs: - run-macos-unit-tests - run-ubuntu-unit-tests + - run-aarch64-unit-tests + - run-qemu-ubuntu-unit-tests steps: - name: Check build matrix status # Ignore MacOS failures From bf836312041fbcb171b6ba79f5f193d22f150c08 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Thu, 5 Sep 2024 16:01:11 +0200 Subject: [PATCH 159/295] in_elasticsearch: improved buffer size check Signed-off-by: Leonardo Alminana --- plugins/in_elasticsearch/in_elasticsearch_bulk_conn.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/in_elasticsearch/in_elasticsearch_bulk_conn.c b/plugins/in_elasticsearch/in_elasticsearch_bulk_conn.c index fe6e46fb657..cbab165103b 100644 --- a/plugins/in_elasticsearch/in_elasticsearch_bulk_conn.c +++ b/plugins/in_elasticsearch/in_elasticsearch_bulk_conn.c @@ -116,9 +116,10 @@ static int in_elasticsearch_bulk_conn_event(void *data) } if (NULL != request_end) { - request_len = (size_t)(request_end - conn->buf_data); + request_len = (size_t) ((uintptr_t) request_end - + (uintptr_t) conn->buf_data); - if (0 < (conn->buf_len - request_len)) { + if (request_len < conn->buf_len) { memmove(conn->buf_data, &conn->buf_data[request_len], conn->buf_len - request_len); From b3d6d23861db6fbe5f97a797a08e589f7cf7b1ea Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Thu, 5 Sep 2024 16:06:13 +0200 Subject: [PATCH 160/295] Revert "in_elasticsearch: improved buffer size check" This reverts commit bf836312041fbcb171b6ba79f5f193d22f150c08. --- plugins/in_elasticsearch/in_elasticsearch_bulk_conn.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/in_elasticsearch/in_elasticsearch_bulk_conn.c b/plugins/in_elasticsearch/in_elasticsearch_bulk_conn.c index cbab165103b..fe6e46fb657 100644 --- a/plugins/in_elasticsearch/in_elasticsearch_bulk_conn.c +++ b/plugins/in_elasticsearch/in_elasticsearch_bulk_conn.c @@ -116,10 +116,9 @@ static int in_elasticsearch_bulk_conn_event(void *data) } if (NULL != request_end) { - request_len = (size_t) ((uintptr_t) request_end - - (uintptr_t) conn->buf_data); + request_len = (size_t)(request_end - conn->buf_data); - if (request_len < conn->buf_len) { + if (0 < (conn->buf_len - request_len)) { memmove(conn->buf_data, &conn->buf_data[request_len], conn->buf_len - request_len); From 278bd07c39d54e8b5f3d447f6dc299a365d0b795 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Tue, 3 Sep 2024 11:39:29 +0200 Subject: [PATCH 161/295] engine: added missing explicit cast Signed-off-by: Leonardo Alminana --- src/flb_engine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/flb_engine.c b/src/flb_engine.c index d85c208531c..960ecf41567 100644 --- a/src/flb_engine.c +++ b/src/flb_engine.c @@ -203,7 +203,7 @@ static inline int handle_input_event(flb_pipefd_t fd, uint64_t ts, return -1; } - flb_input_coro_finished(config, ins_id); + flb_input_coro_finished(config, (int) ins_id); return 0; } From 03df4ed9f29839abc1742af441089d925aab49ff Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Thu, 5 Sep 2024 12:12:07 +0200 Subject: [PATCH 162/295] in_elasticsearch: fixed potential issue caused by ingored reallocation Signed-off-by: Leonardo Alminana --- .../in_elasticsearch_bulk_prot.c | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/plugins/in_elasticsearch/in_elasticsearch_bulk_prot.c b/plugins/in_elasticsearch/in_elasticsearch_bulk_prot.c index 5201026ccff..171cda9fefc 100644 --- a/plugins/in_elasticsearch/in_elasticsearch_bulk_prot.c +++ b/plugins/in_elasticsearch/in_elasticsearch_bulk_prot.c @@ -893,13 +893,13 @@ int in_elasticsearch_bulk_prot_handle(struct flb_in_elasticsearch *ctx, } error_str = strstr(bulk_statuses, "\"status\":40"); if (error_str){ - flb_sds_cat(bulk_response, "{\"errors\":true,\"items\":[", 24); + flb_sds_cat_safe(&bulk_response, "{\"errors\":true,\"items\":[", 24); } else { - flb_sds_cat(bulk_response, "{\"errors\":false,\"items\":[", 25); + flb_sds_cat_safe(&bulk_response, "{\"errors\":false,\"items\":[", 25); } - flb_sds_cat(bulk_response, bulk_statuses, flb_sds_len(bulk_statuses)); - flb_sds_cat(bulk_response, "]}", 2); + flb_sds_cat_safe(&bulk_response, bulk_statuses, flb_sds_len(bulk_statuses)); + flb_sds_cat_safe(&bulk_response, "]}", 2); send_response(conn, 200, bulk_response); mk_mem_free(uri); @@ -925,8 +925,8 @@ int in_elasticsearch_bulk_prot_handle_error(struct flb_in_elasticsearch *ctx, /* New gen HTTP server */ -static int send_response_ng(struct flb_http_response *response, - int http_status, +static int send_response_ng(struct flb_http_response *response, + int http_status, char *content_type, char *message) { @@ -946,14 +946,14 @@ static int send_response_ng(struct flb_http_response *response, } if (content_type != NULL) { - flb_http_response_set_header(response, + flb_http_response_set_header(response, "content-type", 0, content_type, 0); } if (message != NULL) { - flb_http_response_set_body(response, - (unsigned char *) message, + flb_http_response_set_body(response, + (unsigned char *) message, strlen(message)); } @@ -962,14 +962,14 @@ static int send_response_ng(struct flb_http_response *response, return 0; } -static int send_json_response_ng(struct flb_http_response *response, +static int send_json_response_ng(struct flb_http_response *response, int http_status, char *message) { - return send_response_ng(response, http_status, "application/json", message); + return send_response_ng(response, http_status, "application/json", message); } -static int send_version_message_response_ng(struct flb_http_response *response, +static int send_version_message_response_ng(struct flb_http_response *response, struct flb_in_elasticsearch *ctx, int http_status) { @@ -989,14 +989,14 @@ static int send_version_message_response_ng(struct flb_http_response *response, ES_VERSION_RESPONSE_TEMPLATE, ctx->es_version); - send_json_response_ng(response, http_status, message); + send_json_response_ng(response, http_status, message); cfl_sds_destroy(message); return 0; } -static int send_dummy_sniffer_response_ng(struct flb_http_response *response, +static int send_dummy_sniffer_response_ng(struct flb_http_response *response, struct flb_in_elasticsearch *ctx, int http_status) { @@ -1024,7 +1024,7 @@ static int send_dummy_sniffer_response_ng(struct flb_http_response *response, ctx->cluster_name, ctx->node_name, hostname, ctx->tcp_port, ctx->buffer_max_size); - send_json_response_ng(response, http_status, resp); + send_json_response_ng(response, http_status, resp); flb_sds_destroy(resp); @@ -1081,7 +1081,7 @@ int in_elasticsearch_bulk_prot_handle_ng(struct flb_http_request *request, } /* HTTP/1.1 needs Host header */ - if (request->protocol_version == HTTP_PROTOCOL_HTTP1 && + if (request->protocol_version == HTTP_PROTOCOL_HTTP1 && request->host == NULL) { return -1; @@ -1113,7 +1113,7 @@ int in_elasticsearch_bulk_prot_handle_ng(struct flb_http_request *request, else if (request->method == HTTP_METHOD_POST) { if (strcmp(request->path, "/_bulk") == 0) { bulk_statuses = flb_sds_create_size(context->buffer_max_size); - + if (bulk_statuses == NULL) { return -1; } @@ -1159,7 +1159,7 @@ int in_elasticsearch_bulk_prot_handle_ng(struct flb_http_request *request, flb_sds_destroy(bulk_statuses); flb_sds_destroy(bulk_response); - + } else { send_response_ng(response, 400, NULL, "error: invalid HTTP endpoint\n"); @@ -1171,6 +1171,6 @@ int in_elasticsearch_bulk_prot_handle_ng(struct flb_http_request *request, return -1; } - + return 0; } \ No newline at end of file From ea58ab83c84778fc619b7453da737d60993fab40 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Tue, 3 Sep 2024 11:44:08 +0200 Subject: [PATCH 163/295] input: added missing initializer Signed-off-by: Leonardo Alminana --- include/fluent-bit/flb_input.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/fluent-bit/flb_input.h b/include/fluent-bit/flb_input.h index 9140b1dc71f..0b69f8cca9a 100644 --- a/include/fluent-bit/flb_input.h +++ b/include/fluent-bit/flb_input.h @@ -627,6 +627,8 @@ static inline int flb_input_config_map_set(struct flb_input_instance *ins, { int ret; + ret = -1; + /* Process normal properties */ if (ins->config_map) { ret = flb_config_map_set(&ins->properties, ins->config_map, context); From 4d50c61ed015fbcf137f5677721dcc74d838c532 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Tue, 3 Sep 2024 12:42:42 +0200 Subject: [PATCH 164/295] out_opentelemetry: fixed memory leaks Signed-off-by: Leonardo Alminana --- plugins/out_opentelemetry/opentelemetry.c | 4 +- plugins/out_opentelemetry/opentelemetry.h | 4 ++ .../out_opentelemetry/opentelemetry_conf.c | 67 +++++++++++-------- .../out_opentelemetry/opentelemetry_logs.c | 2 +- 4 files changed, 47 insertions(+), 30 deletions(-) diff --git a/plugins/out_opentelemetry/opentelemetry.c b/plugins/out_opentelemetry/opentelemetry.c index 6f7ab568a29..cc5680ba3b2 100644 --- a/plugins/out_opentelemetry/opentelemetry.c +++ b/plugins/out_opentelemetry/opentelemetry.c @@ -326,7 +326,7 @@ static int process_metrics(struct flb_event_chunk *event_chunk, result = opentelemetry_http_post(ctx, buf, flb_sds_len(buf), event_chunk->tag, flb_sds_len(event_chunk->tag), - ctx->metrics_uri); + ctx->metrics_uri_sanitized); /* Debug http_post() result statuses */ if (result == FLB_OK) { @@ -416,7 +416,7 @@ static int process_traces(struct flb_event_chunk *event_chunk, result = opentelemetry_http_post(ctx, buf, flb_sds_len(buf), event_chunk->tag, flb_sds_len(event_chunk->tag), - ctx->traces_uri); + ctx->traces_uri_sanitized); /* Debug http_post() result statuses */ if (result == FLB_OK) { diff --git a/plugins/out_opentelemetry/opentelemetry.h b/plugins/out_opentelemetry/opentelemetry.h index a4e188f3708..a43d4184caf 100644 --- a/plugins/out_opentelemetry/opentelemetry.h +++ b/plugins/out_opentelemetry/opentelemetry.h @@ -53,9 +53,13 @@ struct opentelemetry_context { int proxy_port; /* HTTP URI */ + char *traces_uri_sanitized; + char *metrics_uri_sanitized; + char *logs_uri_sanitized; char *traces_uri; char *metrics_uri; char *logs_uri; + char *host; int port; diff --git a/plugins/out_opentelemetry/opentelemetry_conf.c b/plugins/out_opentelemetry/opentelemetry_conf.c index ec44ca02e37..80a193d37b5 100644 --- a/plugins/out_opentelemetry/opentelemetry_conf.c +++ b/plugins/out_opentelemetry/opentelemetry_conf.c @@ -325,29 +325,49 @@ struct opentelemetry_context *flb_opentelemetry_context_create(struct flb_output return NULL; } - logs_uri = sanitize_uri(ctx->logs_uri); - traces_uri = sanitize_uri(ctx->traces_uri); - metrics_uri = sanitize_uri(ctx->metrics_uri); - ctx->u = upstream; ctx->host = ins->host.name; ctx->port = ins->host.port; + ctx->logs_uri_sanitized = sanitize_uri(ctx->logs_uri); + ctx->traces_uri_sanitized = sanitize_uri(ctx->traces_uri); + ctx->metrics_uri_sanitized = sanitize_uri(ctx->metrics_uri); - /* Logs Properties */ - if (logs_uri == NULL) { + if (ctx->logs_uri_sanitized == NULL) { flb_plg_trace(ctx->ins, "Could not allocate memory for sanitized " "log endpoint uri"); + + flb_opentelemetry_context_destroy(ctx); + + return NULL; } - else { - ctx->logs_uri = logs_uri; + + if (ctx->traces_uri_sanitized == NULL) { + flb_plg_trace(ctx->ins, + "Could not allocate memory for sanitized " + "trace endpoint uri"); + + flb_opentelemetry_context_destroy(ctx); + + return NULL; + } + + if (ctx->metrics_uri_sanitized == NULL) { + flb_plg_trace(ctx->ins, + "Could not allocate memory for sanitized " + "metric endpoint uri"); + + flb_opentelemetry_context_destroy(ctx); + + return NULL; } /* list of 'logs_body_key' */ ret = log_body_key_list_create(ctx); if (ret != 0) { flb_opentelemetry_context_destroy(ctx); + return NULL; } @@ -364,25 +384,6 @@ struct opentelemetry_context *flb_opentelemetry_context_create(struct flb_output return NULL; } - if (traces_uri == NULL) { - flb_plg_trace(ctx->ins, - "Could not allocate memory for sanitized " - "trace endpoint uri"); - } - else { - ctx->traces_uri = traces_uri; - } - - if (metrics_uri == NULL) { - flb_plg_trace(ctx->ins, - "Could not allocate memory for sanitized " - "metric endpoint uri"); - } - else { - ctx->metrics_uri = metrics_uri; - } - - /* Set instance flags into upstream */ flb_output_upstream_set(ctx->u, ins); @@ -554,6 +555,18 @@ void flb_opentelemetry_context_destroy(struct opentelemetry_context *ctx) flb_upstream_destroy(ctx->u); } + if (ctx->logs_uri_sanitized != NULL) { + flb_free(ctx->logs_uri_sanitized); + } + + if (ctx->traces_uri_sanitized != NULL) { + flb_free(ctx->traces_uri_sanitized); + } + + if (ctx->metrics_uri_sanitized != NULL) { + flb_free(ctx->metrics_uri_sanitized); + } + /* release log_body_key_list */ log_body_key_list_destroy(ctx); diff --git a/plugins/out_opentelemetry/opentelemetry_logs.c b/plugins/out_opentelemetry/opentelemetry_logs.c index d7b7cea2fb3..f02a21b46fd 100644 --- a/plugins/out_opentelemetry/opentelemetry_logs.c +++ b/plugins/out_opentelemetry/opentelemetry_logs.c @@ -773,7 +773,7 @@ static int logs_flush_to_otel(struct opentelemetry_context *ctx, struct flb_even ret = opentelemetry_http_post(ctx, body, len, event_chunk->tag, flb_sds_len(event_chunk->tag), - ctx->logs_uri); + ctx->logs_uri_sanitized); flb_free(body); return ret; From 65225a8926ac3cb0f165cc23b237c34493e3946f Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 4 Sep 2024 13:04:03 +0200 Subject: [PATCH 165/295] tests: internal: signv4: uncommented code that caused a leak Signed-off-by: Leonardo Alminana --- tests/internal/signv4.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/internal/signv4.c b/tests/internal/signv4.c index 7c691bc31b7..fb9761b3782 100644 --- a/tests/internal/signv4.c +++ b/tests/internal/signv4.c @@ -443,7 +443,8 @@ static struct aws_test *aws_test_create(char *path, char *context, return awt; error: - //aws_test_destroy(awt); + aws_test_destroy(awt); + return NULL; } From 25db2fc804db37668ef6dca6cbde5731062274b5 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Thu, 5 Sep 2024 14:38:01 +0200 Subject: [PATCH 166/295] in_elasticsearch: fixed memory leak Signed-off-by: Leonardo Alminana --- plugins/in_elasticsearch/in_elasticsearch_bulk_prot.c | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/in_elasticsearch/in_elasticsearch_bulk_prot.c b/plugins/in_elasticsearch/in_elasticsearch_bulk_prot.c index 171cda9fefc..c705af60d81 100644 --- a/plugins/in_elasticsearch/in_elasticsearch_bulk_prot.c +++ b/plugins/in_elasticsearch/in_elasticsearch_bulk_prot.c @@ -750,6 +750,7 @@ int in_elasticsearch_bulk_prot_handle(struct flb_in_elasticsearch *ctx, if (ctx->ins->tag && !ctx->ins->tag_default) { tag = flb_sds_create(ctx->ins->tag); if (tag == NULL) { + mk_mem_free(uri); return -1; } } From 1f578db196a34c0c7b3d799ca9a638d7f8e3af56 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Thu, 29 Aug 2024 21:09:02 +0900 Subject: [PATCH 167/295] out_influxdb: Handle signed/unsigned integer as influx's integer of that representation This is because in their line protocol, it needs to add "i" suffix for handling a value as an integer: | Datatype | Element(s) | Description | |:--------:|:------------:|:------------| | Integer | Field values | Signed 64-bit integers (-9223372036854775808 to 9223372036854775807). Specify an integer with a trailing i on the number. Example: 1i | So, we need to add "i" suffix for signed/unsigned integer values. ref: https://docs.influxdata.com/influxdb/v1/write_protocols/line_protocol_reference/ Signed-off-by: Hiroshi Hatake --- plugins/out_influxdb/influxdb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/out_influxdb/influxdb.c b/plugins/out_influxdb/influxdb.c index b84d59ca9f8..d49fbb81ea1 100644 --- a/plugins/out_influxdb/influxdb.c +++ b/plugins/out_influxdb/influxdb.c @@ -171,11 +171,11 @@ static char *influxdb_format(const char *tag, int tag_len, } else if (v->type == MSGPACK_OBJECT_POSITIVE_INTEGER) { val = tmp; - val_len = snprintf(tmp, sizeof(tmp) - 1, "%" PRIu64, v->via.u64); + val_len = snprintf(tmp, sizeof(tmp) - 1, "%" PRIu64 "i", v->via.u64); } else if (v->type == MSGPACK_OBJECT_NEGATIVE_INTEGER) { val = tmp; - val_len = snprintf(tmp, sizeof(tmp) - 1, "%" PRId64, v->via.i64); + val_len = snprintf(tmp, sizeof(tmp) - 1, "%" PRId64 "i", v->via.i64); } else if (v->type == MSGPACK_OBJECT_FLOAT || v->type == MSGPACK_OBJECT_FLOAT32) { val = tmp; From c2a9ba45fa631a6b87d42edfdd2ae99bf22651b0 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Fri, 30 Aug 2024 14:27:11 +0900 Subject: [PATCH 168/295] out_influxdb: Add test_formatter.callback mechanism Signed-off-by: Hiroshi Hatake --- plugins/out_influxdb/influxdb.c | 36 ++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/plugins/out_influxdb/influxdb.c b/plugins/out_influxdb/influxdb.c index d49fbb81ea1..bd74f2a513a 100644 --- a/plugins/out_influxdb/influxdb.c +++ b/plugins/out_influxdb/influxdb.c @@ -58,15 +58,19 @@ static void influxdb_tsmod(struct flb_time *ts, struct flb_time *dupe, * Convert the internal Fluent Bit data representation to the required one * by InfluxDB. */ -static char *influxdb_format(const char *tag, int tag_len, - const void *data, size_t bytes, size_t *out_size, - struct flb_influxdb *ctx) +static int influxdb_format(struct flb_config *config, + struct flb_input_instance *ins, + void *plugin_context, + void *flush_ctx, + int event_type, + const char *tag, int tag_len, + const void *data, size_t bytes, + void **out_data, size_t *out_size) { int i; int ret; int n_size; uint64_t seq = 0; - char *buf; char *str = NULL; size_t str_size; char tmp[128]; @@ -77,6 +81,7 @@ static char *influxdb_format(const char *tag, int tag_len, struct influxdb_bulk *bulk_body = NULL; struct flb_log_event_decoder log_decoder; struct flb_log_event log_event; + struct flb_influxdb *ctx = plugin_context; ret = flb_log_event_decoder_init(&log_decoder, (char *) data, bytes); @@ -84,7 +89,7 @@ static char *influxdb_format(const char *tag, int tag_len, flb_plg_error(ctx->ins, "Log event decoder initialization error : %d", ret); - return NULL; + return -1; } /* Create the bulk composer */ @@ -268,8 +273,8 @@ static char *influxdb_format(const char *tag, int tag_len, flb_log_event_decoder_destroy(&log_decoder); + *out_data = bulk->ptr; *out_size = bulk->len; - buf = bulk->ptr; /* * Note: we don't destroy the bulk as we need to keep the allocated @@ -280,7 +285,7 @@ static char *influxdb_format(const char *tag, int tag_len, influxdb_bulk_destroy(bulk_head); influxdb_bulk_destroy(bulk_body); - return buf; + return 0; error: if (bulk != NULL) { @@ -295,7 +300,7 @@ static char *influxdb_format(const char *tag, int tag_len, flb_log_event_decoder_destroy(&log_decoder); - return NULL; + return -1; } static int cb_influxdb_init(struct flb_output_instance *ins, struct flb_config *config, @@ -453,6 +458,7 @@ static void cb_influxdb_flush(struct flb_event_chunk *event_chunk, int is_metric = FLB_FALSE; size_t b_sent; size_t bytes_out; + void *out_buf; char *pack; char tmp[128]; struct mk_list *head; @@ -477,12 +483,17 @@ static void cb_influxdb_flush(struct flb_event_chunk *event_chunk, } else { /* format logs */ - pack = influxdb_format(event_chunk->tag, flb_sds_len(event_chunk->tag), - event_chunk->data, event_chunk->size, - &bytes_out, ctx); - if (!pack) { + ret = influxdb_format(config, i_ins, + ctx, NULL, + event_chunk->type, + event_chunk->tag, flb_sds_len(event_chunk->tag), + event_chunk->data, event_chunk->size, + &out_buf, &bytes_out); + if (ret != 0) { FLB_OUTPUT_RETURN(FLB_ERROR); } + + pack = (char *) out_buf; } /* Get upstream connection */ @@ -677,6 +688,7 @@ struct flb_output_plugin out_influxdb_plugin = { .cb_flush = cb_influxdb_flush, .cb_exit = cb_influxdb_exit, .config_map = config_map, + .test_formatter.callback = influxdb_format, .flags = FLB_OUTPUT_NET | FLB_IO_OPT_TLS, .event_type = FLB_OUTPUT_LOGS | FLB_OUTPUT_METRICS }; From 9ae6598fa665d24b298cc9bd28cf95c9d6058995 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Fri, 30 Aug 2024 16:55:15 +0900 Subject: [PATCH 169/295] out_influxdb: Plug a memory leak Signed-off-by: Hiroshi Hatake --- plugins/out_influxdb/influxdb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/out_influxdb/influxdb.c b/plugins/out_influxdb/influxdb.c index bd74f2a513a..bf431a2305b 100644 --- a/plugins/out_influxdb/influxdb.c +++ b/plugins/out_influxdb/influxdb.c @@ -580,6 +580,10 @@ static int cb_influxdb_exit(void *data, struct flb_config *config) flb_utils_split_free(ctx->tag_keys); } + if (ctx->seq_name) { + flb_free(ctx->seq_name); + } + flb_upstream_destroy(ctx->u); flb_free(ctx); From b7375f62dbff2a000826188053744429bcf6835e Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Fri, 30 Aug 2024 16:55:44 +0900 Subject: [PATCH 170/295] out_influxdb: test: Add influxdb format test cases Signed-off-by: Hiroshi Hatake --- tests/runtime/CMakeLists.txt | 1 + tests/runtime/out_influxdb.c | 327 +++++++++++++++++++++++++++++++++++ 2 files changed, 328 insertions(+) create mode 100644 tests/runtime/out_influxdb.c diff --git a/tests/runtime/CMakeLists.txt b/tests/runtime/CMakeLists.txt index 9e5cc4670e4..e902f7892ff 100644 --- a/tests/runtime/CMakeLists.txt +++ b/tests/runtime/CMakeLists.txt @@ -124,6 +124,7 @@ if(FLB_IN_LIB) endif() FLB_RT_TEST(FLB_OUT_S3 "out_s3.c") FLB_RT_TEST(FLB_OUT_TD "out_td.c") + FLB_RT_TEST(FLB_OUT_INFLUXDB "out_influxdb.c") endif() diff --git a/tests/runtime/out_influxdb.c b/tests/runtime/out_influxdb.c new file mode 100644 index 00000000000..63c711eb1fd --- /dev/null +++ b/tests/runtime/out_influxdb.c @@ -0,0 +1,327 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* Fluent Bit + * ========== + * Copyright (C) 2019-2024 The Fluent Bit Authors + * Copyright (C) 2015-2018 Treasure Data Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "flb_tests_runtime.h" + +pthread_mutex_t result_mutex = PTHREAD_MUTEX_INITIALIZER; +int num_output = 0; +static int get_output_num() +{ + int ret; + pthread_mutex_lock(&result_mutex); + ret = num_output; + pthread_mutex_unlock(&result_mutex); + + return ret; +} + +static void set_output_num(int num) +{ + pthread_mutex_lock(&result_mutex); + num_output = num; + pthread_mutex_unlock(&result_mutex); +} + +static void clear_output_num() +{ + set_output_num(0); +} + +#define JSON_BASIC "[12345678, {\"key\":\"value\"}]" +static void cb_check_basic(void *ctx, int ffd, + int res_ret, void *res_data, size_t res_size, + void *data) +{ + char *p; + flb_sds_t out = res_data; + char *index_line = "key=\"value\""; + + set_output_num(1); + + p = strstr(out, index_line); + if (!TEST_CHECK(p != NULL)) { + TEST_MSG("Given:%s", out); + } + + flb_free(out); +} + +#define JSON_FLOAT "[12345678, {\"float\":1.3}]" +static void cb_check_float_value(void *ctx, int ffd, + int res_ret, void *res_data, size_t res_size, + void *data) +{ + char *p; + flb_sds_t out = res_data; + char *index_line = "float=1.3"; + + set_output_num(1); + + p = strstr(out, index_line); + if (!TEST_CHECK(p != NULL)) { + TEST_MSG("Given:%s", out); + } + + flb_free(out); +} + +#define JSON_INTEGER "[12345678, {\"int\":100}]" +static void cb_check_int_value(void *ctx, int ffd, + int res_ret, void *res_data, size_t res_size, + void *data) +{ + char *p; + flb_sds_t out = res_data; + char *index_line = "int=100i"; + + set_output_num(1); + + p = strstr(out, index_line); + if (!TEST_CHECK(p != NULL)) { + TEST_MSG("Given:%s", out); + } + + flb_free(out); +} + + +#define JSON_NEGATIVE_INTEGER "[12345678, {\"int\":-200}]" +static void cb_check_negative_int_value(void *ctx, int ffd, + int res_ret, void *res_data, size_t res_size, + void *data) +{ + char *p; + flb_sds_t out = res_data; + char *index_line = "int=-200i"; + + set_output_num(1); + + p = strstr(out, index_line); + if (!TEST_CHECK(p != NULL)) { + TEST_MSG("Given:%s", out); + } + + flb_free(out); +} + +void flb_test_basic() +{ + int ret; + int size = sizeof(JSON_BASIC) - 1; + flb_ctx_t *ctx; + int in_ffd; + int out_ffd; + + clear_output_num(); + + /* Create context, flush every second (some checks omitted here) */ + ctx = flb_create(); + flb_service_set(ctx, "flush", "1", "grace", "1", + "log_level", "error", + NULL); + + /* Lib input mode */ + in_ffd = flb_input(ctx, (char *) "lib", NULL); + flb_input_set(ctx, in_ffd, "tag", "test", NULL); + + /* Elasticsearch output */ + out_ffd = flb_output(ctx, (char *) "influxdb", NULL); + flb_output_set(ctx, out_ffd, + "match", "test", + NULL); + + /* Enable test mode */ + ret = flb_output_set_test(ctx, out_ffd, "formatter", + cb_check_basic, + NULL, NULL); + + /* Start */ + ret = flb_start(ctx); + TEST_CHECK(ret == 0); + + /* Ingest data sample */ + ret = flb_lib_push(ctx, in_ffd, (char *) JSON_BASIC, size); + TEST_CHECK(ret >= 0); + + sleep(2); + + ret = get_output_num(); + if (!TEST_CHECK(ret != 0)) { + TEST_MSG("no output"); + } + + flb_stop(ctx); + flb_destroy(ctx); +} + +void flb_test_float_value() +{ + int ret; + int size = sizeof(JSON_FLOAT) - 1; + flb_ctx_t *ctx; + int in_ffd; + int out_ffd; + + clear_output_num(); + + /* Create context, flush every second (some checks omitted here) */ + ctx = flb_create(); + flb_service_set(ctx, "flush", "1", "grace", "1", + "log_level", "error", + NULL); + + /* Lib input mode */ + in_ffd = flb_input(ctx, (char *) "lib", NULL); + flb_input_set(ctx, in_ffd, "tag", "test", NULL); + + /* Elasticsearch output */ + out_ffd = flb_output(ctx, (char *) "influxdb", NULL); + flb_output_set(ctx, out_ffd, + "match", "test", + NULL); + + /* Enable test mode */ + ret = flb_output_set_test(ctx, out_ffd, "formatter", + cb_check_float_value, + NULL, NULL); + + /* Start */ + ret = flb_start(ctx); + TEST_CHECK(ret == 0); + + /* Ingest data sample */ + ret = flb_lib_push(ctx, in_ffd, (char *) JSON_FLOAT, size); + TEST_CHECK(ret >= 0); + + sleep(2); + flb_stop(ctx); + flb_destroy(ctx); +} + +void flb_test_integer_value() +{ + int ret; + int size = sizeof(JSON_INTEGER) - 1; + flb_ctx_t *ctx; + int in_ffd; + int out_ffd; + + clear_output_num(); + + /* Create context, flush every second (some checks omitted here) */ + ctx = flb_create(); + flb_service_set(ctx, "flush", "1", "grace", "1", + "log_level", "error", + NULL); + + /* Lib input mode */ + in_ffd = flb_input(ctx, (char *) "lib", NULL); + flb_input_set(ctx, in_ffd, "tag", "test", NULL); + + /* Elasticsearch output */ + out_ffd = flb_output(ctx, (char *) "influxdb", NULL); + flb_output_set(ctx, out_ffd, + "match", "test", + NULL); + + /* Enable test mode */ + ret = flb_output_set_test(ctx, out_ffd, "formatter", + cb_check_int_value, + NULL, NULL); + + /* Start */ + ret = flb_start(ctx); + TEST_CHECK(ret == 0); + + /* Ingest data sample */ + ret = flb_lib_push(ctx, in_ffd, (char *) JSON_INTEGER, size); + TEST_CHECK(ret >= 0); + + sleep(2); + + ret = get_output_num(); + if (!TEST_CHECK(ret != 0)) { + TEST_MSG("no output"); + } + + flb_stop(ctx); + flb_destroy(ctx); +} + +void flb_test_negative_integer_value() +{ + int ret; + int size = sizeof(JSON_NEGATIVE_INTEGER) - 1; + flb_ctx_t *ctx; + int in_ffd; + int out_ffd; + + clear_output_num(); + + /* Create context, flush every second (some checks omitted here) */ + ctx = flb_create(); + flb_service_set(ctx, "flush", "1", "grace", "1", + "log_level", "error", + NULL); + + /* Lib input mode */ + in_ffd = flb_input(ctx, (char *) "lib", NULL); + flb_input_set(ctx, in_ffd, "tag", "test", NULL); + + /* Elasticsearch output */ + out_ffd = flb_output(ctx, (char *) "influxdb", NULL); + flb_output_set(ctx, out_ffd, + "match", "test", + NULL); + + /* Enable test mode */ + ret = flb_output_set_test(ctx, out_ffd, "formatter", + cb_check_negative_int_value, + NULL, NULL); + + /* Start */ + ret = flb_start(ctx); + TEST_CHECK(ret == 0); + + /* Ingest data sample */ + ret = flb_lib_push(ctx, in_ffd, (char *) JSON_NEGATIVE_INTEGER, size); + TEST_CHECK(ret >= 0); + + sleep(2); + + ret = get_output_num(); + if (!TEST_CHECK(ret != 0)) { + TEST_MSG("no output"); + } + + flb_stop(ctx); + flb_destroy(ctx); +} + +/* Test list */ +TEST_LIST = { + {"basic" , flb_test_basic }, + {"float" , flb_test_float_value }, + {"integer" , flb_test_integer_value }, + {"negative_integer" , flb_test_negative_integer_value }, + {NULL, NULL} +}; From 8609dbd1f8ba267ad9e4ddac8ccd4075c9d34b1a Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Fri, 30 Aug 2024 17:27:06 +0900 Subject: [PATCH 171/295] out_influxdb: Provide a way to turn on to use integer type on influxdb's line protocol Signed-off-by: Hiroshi Hatake --- plugins/out_influxdb/influxdb.c | 20 +++- plugins/out_influxdb/influxdb.h | 3 + tests/runtime/out_influxdb.c | 159 +++++++++++++++++++++++++++++++- 3 files changed, 178 insertions(+), 4 deletions(-) diff --git a/plugins/out_influxdb/influxdb.c b/plugins/out_influxdb/influxdb.c index bf431a2305b..b7086a37938 100644 --- a/plugins/out_influxdb/influxdb.c +++ b/plugins/out_influxdb/influxdb.c @@ -176,11 +176,21 @@ static int influxdb_format(struct flb_config *config, } else if (v->type == MSGPACK_OBJECT_POSITIVE_INTEGER) { val = tmp; - val_len = snprintf(tmp, sizeof(tmp) - 1, "%" PRIu64 "i", v->via.u64); + if (ctx->use_influxdb_integer) { + val_len = snprintf(tmp, sizeof(tmp) - 1, "%" PRIu64 "i", v->via.u64); + } + else { + val_len = snprintf(tmp, sizeof(tmp) - 1, "%" PRIu64, v->via.u64); + } } else if (v->type == MSGPACK_OBJECT_NEGATIVE_INTEGER) { val = tmp; - val_len = snprintf(tmp, sizeof(tmp) - 1, "%" PRId64 "i", v->via.i64); + if (ctx->use_influxdb_integer) { + val_len = snprintf(tmp, sizeof(tmp) - 1, "%" PRId64 "i", v->via.i64); + } + else { + val_len = snprintf(tmp, sizeof(tmp) - 1, "%" PRId64, v->via.i64); + } } else if (v->type == MSGPACK_OBJECT_FLOAT || v->type == MSGPACK_OBJECT_FLOAT32) { val = tmp; @@ -680,6 +690,12 @@ static struct flb_config_map config_map[] = { "Space separated list of keys that needs to be tagged." }, + { + FLB_CONFIG_MAP_BOOL, "use_integer", "false", + 0, FLB_TRUE, offsetof(struct flb_influxdb, use_influxdb_integer), + "Use influxdb line protocol's integer type suffix." + }, + /* EOF */ {0} }; diff --git a/plugins/out_influxdb/influxdb.h b/plugins/out_influxdb/influxdb.h index c9ff8a383d3..c21145611c8 100644 --- a/plugins/out_influxdb/influxdb.h +++ b/plugins/out_influxdb/influxdb.h @@ -65,6 +65,9 @@ struct flb_influxdb { /* Arbitrary HTTP headers */ struct mk_list *headers; + /* Use line protocol's integer type */ + int use_influxdb_integer; + /* Upstream connection to the backend server */ struct flb_upstream *u; diff --git a/tests/runtime/out_influxdb.c b/tests/runtime/out_influxdb.c index 63c711eb1fd..ec6383ac618 100644 --- a/tests/runtime/out_influxdb.c +++ b/tests/runtime/out_influxdb.c @@ -123,6 +123,53 @@ static void cb_check_negative_int_value(void *ctx, int ffd, flb_free(out); } +static void cb_check_int_as_float_value(void *ctx, int ffd, + int res_ret, void *res_data, size_t res_size, + void *data) +{ + char *p; + flb_sds_t out = res_data; + char *missing_index_line = "int=100i"; + char *index_line = "int=100"; + + set_output_num(1); + + p = strstr(out, missing_index_line); + if (!TEST_CHECK(p == NULL)) { + TEST_MSG("Given:%s", out); + } + p = strstr(out, index_line); + if (!TEST_CHECK(p != NULL)) { + TEST_MSG("Given:%s", out); + } + + flb_free(out); +} + +static void cb_check_negative_int_as_float_value( + void *ctx, int ffd, + int res_ret, void *res_data, size_t res_size, + void *data) +{ + char *p; + flb_sds_t out = res_data; + char *missing_index_line = "int=-200i"; + char *index_line = "int=-200"; + + set_output_num(1); + + p = strstr(out, missing_index_line); + if (!TEST_CHECK(p == NULL)) { + TEST_MSG("Given:%s", out); + } + p = strstr(out, index_line); + if (!TEST_CHECK(p != NULL)) { + TEST_MSG("Given:%s", out); + } + + flb_free(out); +} + void flb_test_basic() { int ret; @@ -217,6 +264,7 @@ void flb_test_float_value() flb_destroy(ctx); } +/* Using integer type */ void flb_test_integer_value() { int ret; @@ -241,6 +289,7 @@ void flb_test_integer_value() out_ffd = flb_output(ctx, (char *) "influxdb", NULL); flb_output_set(ctx, out_ffd, "match", "test", + "use_integer", "true", NULL); /* Enable test mode */ @@ -291,6 +340,7 @@ void flb_test_negative_integer_value() out_ffd = flb_output(ctx, (char *) "influxdb", NULL); flb_output_set(ctx, out_ffd, "match", "test", + "use_integer", "true", NULL); /* Enable test mode */ @@ -317,11 +367,116 @@ void flb_test_negative_integer_value() flb_destroy(ctx); } +/* Not using integer type of line protocol */ +void flb_test_integer_as_float_value() +{ + int ret; + int size = sizeof(JSON_INTEGER) - 1; + flb_ctx_t *ctx; + int in_ffd; + int out_ffd; + + clear_output_num(); + + /* Create context, flush every second (some checks omitted here) */ + ctx = flb_create(); + flb_service_set(ctx, "flush", "1", "grace", "1", + "log_level", "error", + NULL); + + /* Lib input mode */ + in_ffd = flb_input(ctx, (char *) "lib", NULL); + flb_input_set(ctx, in_ffd, "tag", "test", NULL); + + /* Elasticsearch output */ + out_ffd = flb_output(ctx, (char *) "influxdb", NULL); + flb_output_set(ctx, out_ffd, + "match", "test", + "use_integer", "false", + NULL); + + /* Enable test mode */ + ret = flb_output_set_test(ctx, out_ffd, "formatter", + cb_check_int_as_float_value, + NULL, NULL); + + /* Start */ + ret = flb_start(ctx); + TEST_CHECK(ret == 0); + + /* Ingest data sample */ + ret = flb_lib_push(ctx, in_ffd, (char *) JSON_INTEGER, size); + TEST_CHECK(ret >= 0); + + sleep(2); + + ret = get_output_num(); + if (!TEST_CHECK(ret != 0)) { + TEST_MSG("no output"); + } + + flb_stop(ctx); + flb_destroy(ctx); +} + +void flb_test_negative_integer_as_float_value() +{ + int ret; + int size = sizeof(JSON_NEGATIVE_INTEGER) - 1; + flb_ctx_t *ctx; + int in_ffd; + int out_ffd; + + clear_output_num(); + + /* Create context, flush every second (some checks omitted here) */ + ctx = flb_create(); + flb_service_set(ctx, "flush", "1", "grace", "1", + "log_level", "error", + NULL); + + /* Lib input mode */ + in_ffd = flb_input(ctx, (char *) "lib", NULL); + flb_input_set(ctx, in_ffd, "tag", "test", NULL); + + /* Elasticsearch output */ + out_ffd = flb_output(ctx, (char *) "influxdb", NULL); + flb_output_set(ctx, out_ffd, + "match", "test", + "use_integer", "false", + NULL); + + /* Enable test mode */ + ret = flb_output_set_test(ctx, out_ffd, "formatter", + cb_check_negative_int_as_float_value, + NULL, NULL); + + /* Start */ + ret = flb_start(ctx); + TEST_CHECK(ret == 0); + + /* Ingest data sample */ + ret = flb_lib_push(ctx, in_ffd, (char *) JSON_NEGATIVE_INTEGER, size); + TEST_CHECK(ret >= 0); + + sleep(2); + + ret = get_output_num(); + if (!TEST_CHECK(ret != 0)) { + TEST_MSG("no output"); + } + + flb_stop(ctx); + flb_destroy(ctx); +} + /* Test list */ TEST_LIST = { {"basic" , flb_test_basic }, {"float" , flb_test_float_value }, - {"integer" , flb_test_integer_value }, - {"negative_integer" , flb_test_negative_integer_value }, + {"int_integer" , flb_test_integer_value }, + {"int_negative_integer" , flb_test_negative_integer_value }, + {"int_integer_as_float" , flb_test_integer_as_float_value }, + {"int_negative_integer_as_float" , flb_test_negative_integer_as_float_value }, {NULL, NULL} }; From 41cdf32815a2ce060953699f8a59674710147953 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Wed, 4 Sep 2024 12:31:27 +0900 Subject: [PATCH 172/295] out_influxdb: Use add_integer_suffix name for adding integer suffix on the line protocol Signed-off-by: Hiroshi Hatake --- plugins/out_influxdb/influxdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/out_influxdb/influxdb.c b/plugins/out_influxdb/influxdb.c index b7086a37938..671dd5c16a6 100644 --- a/plugins/out_influxdb/influxdb.c +++ b/plugins/out_influxdb/influxdb.c @@ -691,7 +691,7 @@ static struct flb_config_map config_map[] = { }, { - FLB_CONFIG_MAP_BOOL, "use_integer", "false", + FLB_CONFIG_MAP_BOOL, "add_integer_suffix", "false", 0, FLB_TRUE, offsetof(struct flb_influxdb, use_influxdb_integer), "Use influxdb line protocol's integer type suffix." }, From a6c73c88546709736f4f96132e1365e05d8b3287 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Thu, 5 Sep 2024 16:37:41 +0900 Subject: [PATCH 173/295] out_influxdb: test: Follow the change of parameter name Signed-off-by: Hiroshi Hatake --- tests/runtime/out_influxdb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/runtime/out_influxdb.c b/tests/runtime/out_influxdb.c index ec6383ac618..c536d7ea4e0 100644 --- a/tests/runtime/out_influxdb.c +++ b/tests/runtime/out_influxdb.c @@ -289,7 +289,7 @@ void flb_test_integer_value() out_ffd = flb_output(ctx, (char *) "influxdb", NULL); flb_output_set(ctx, out_ffd, "match", "test", - "use_integer", "true", + "add_integer_suffix", "true", NULL); /* Enable test mode */ @@ -340,7 +340,7 @@ void flb_test_negative_integer_value() out_ffd = flb_output(ctx, (char *) "influxdb", NULL); flb_output_set(ctx, out_ffd, "match", "test", - "use_integer", "true", + "add_integer_suffix", "true", NULL); /* Enable test mode */ @@ -392,7 +392,7 @@ void flb_test_integer_as_float_value() out_ffd = flb_output(ctx, (char *) "influxdb", NULL); flb_output_set(ctx, out_ffd, "match", "test", - "use_integer", "false", + "add_integer_suffix", "false", NULL); /* Enable test mode */ @@ -443,7 +443,7 @@ void flb_test_negative_integer_as_float_value() out_ffd = flb_output(ctx, (char *) "influxdb", NULL); flb_output_set(ctx, out_ffd, "match", "test", - "use_integer", "false", + "add_integer_suffix", "false", NULL); /* Enable test mode */ From 072ffe76028ee299358a736127c5b124f571ee21 Mon Sep 17 00:00:00 2001 From: leonardo-albertovich Date: Sat, 7 Sep 2024 06:00:24 +0200 Subject: [PATCH 174/295] in_calyptia_fleet: fixed memory leaks (CID 508187) (#9346) * in_calyptia_fleet: fixed memory leaks Signed-off-by: Leonardo Alminana --- plugins/in_calyptia_fleet/in_calyptia_fleet.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/in_calyptia_fleet/in_calyptia_fleet.c b/plugins/in_calyptia_fleet/in_calyptia_fleet.c index cbacc38de76..36443113900 100644 --- a/plugins/in_calyptia_fleet/in_calyptia_fleet.c +++ b/plugins/in_calyptia_fleet/in_calyptia_fleet.c @@ -1985,6 +1985,10 @@ static int create_fleet_file(flb_sds_t fleetdir, (unsigned char *)b64_content, blen); if (ret != 0) { + fclose(fp); + flb_sds_destroy(dst); + flb_sds_destroy(fname); + return -1; } From 58c1330d77c82197d2d8cd134501e89d3982d437 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Wed, 11 Sep 2024 16:43:30 +0900 Subject: [PATCH 175/295] out_http: Request timed out(408) to be treated as retry Signed-off-by: Hiroshi Hatake --- plugins/out_http/http.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/out_http/http.c b/plugins/out_http/http.c index a0602b91e1a..4fa3d98615d 100644 --- a/plugins/out_http/http.c +++ b/plugins/out_http/http.c @@ -276,7 +276,8 @@ static int http_post(struct flb_out_http *ctx, flb_plg_error(ctx->ins, "%s:%i, HTTP status=%i", ctx->host, ctx->port, c->resp.status); } - if (c->resp.status >= 400 && c->resp.status < 500 && c->resp.status != 429) { + if (c->resp.status >= 400 && c->resp.status < 500 && + c->resp.status != 429 && c->resp.status != 408) { flb_plg_warn(ctx->ins, "could not flush records to %s:%i (http_do=%i), " "chunk will not be retried", ctx->host, ctx->port, ret); From db27a84f14de85d1aef4b7dabddfb092e15e1675 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 4 Sep 2024 12:28:26 +0200 Subject: [PATCH 176/295] tests: internal: signv4: fixed leak Signed-off-by: Leonardo Alminana --- tests/internal/signv4.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/internal/signv4.c b/tests/internal/signv4.c index fb9761b3782..da696b11c96 100644 --- a/tests/internal/signv4.c +++ b/tests/internal/signv4.c @@ -187,6 +187,8 @@ static struct request *http_request_create(char *request) start = sep + 1; br = strchr(start, '\n'); if (!br) { + flb_sds_destroy(key); + break; } From 0665dd95d1f7b8e588731ba9adbd09b60b1702d4 Mon Sep 17 00:00:00 2001 From: Phillip Whelan Date: Mon, 16 Sep 2024 13:24:35 -0300 Subject: [PATCH 177/295] input: disable coroutines for custom events and input callbacks that do not support coroutines. (#9338) * io: respect async connection flag in flb_io_net_connect. * tls: respect async connection flag in flb_tls_session_create. Signed-off-by: Phillip Adair Stewart Whelan --- src/flb_io.c | 3 ++- src/tls/flb_tls.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/flb_io.c b/src/flb_io.c index c500011d8e9..698a2452d39 100644 --- a/src/flb_io.c +++ b/src/flb_io.c @@ -109,6 +109,7 @@ int flb_io_net_connect(struct flb_connection *connection, int ret; int async = FLB_FALSE; flb_sockfd_t fd = -1; + int flags = flb_connection_get_flags(connection); // struct flb_upstream *u = u_conn->u; if (connection->fd > 0) { @@ -119,7 +120,7 @@ int flb_io_net_connect(struct flb_connection *connection, } /* Check which connection mode must be done */ - if (coro) { + if (coro && (flags & FLB_IO_ASYNC)) { async = flb_upstream_is_async(connection->upstream); } else { diff --git a/src/tls/flb_tls.c b/src/tls/flb_tls.c index 6377caec783..f00e9b1ae0e 100644 --- a/src/tls/flb_tls.c +++ b/src/tls/flb_tls.c @@ -579,7 +579,7 @@ int flb_tls_session_create(struct flb_tls *tls, * In the other case for an async socket 'th' is NOT NULL so the code * is under a coroutine context and it can yield. */ - if (co == NULL) { + if (co == NULL || !flb_upstream_is_async(connection->upstream)) { flb_trace("[io_tls] server handshake connection #%i in process to %s", connection->fd, flb_connection_get_remote_address(connection)); From 724940e333361f726632bf66f7a2311204b6291e Mon Sep 17 00:00:00 2001 From: Richard Treu Date: Tue, 20 Aug 2024 10:16:30 +0200 Subject: [PATCH 178/295] filter_log_to_metrics: Add timer callback for emitting metrics This commit will change the log_to_metrics filter to use a timer based metric inject and not directly inject metrics on every incoming log record anymore. This will lower the overall load and memory consumption especially in high-volume and high-cardinality situations. Signed-off-by: Richard Treu --- .../filter_log_to_metrics/log_to_metrics.c | 104 ++++++++++++++++-- .../filter_log_to_metrics/log_to_metrics.h | 10 +- 2 files changed, 105 insertions(+), 9 deletions(-) diff --git a/plugins/filter_log_to_metrics/log_to_metrics.c b/plugins/filter_log_to_metrics/log_to_metrics.c index 0f1370166b8..87231f66392 100644 --- a/plugins/filter_log_to_metrics/log_to_metrics.c +++ b/plugins/filter_log_to_metrics/log_to_metrics.c @@ -450,6 +450,35 @@ static int fill_labels(struct log_to_metrics_ctx *ctx, char **label_values, return label_counter; } +/* Timer callback to inject metrics into the pipeline */ +static void cb_send_metric_chunk(struct flb_config *config, void *data) +{ + int ret; + struct log_to_metrics_ctx *ctx = data; + + /* Check that metric context is not empty */ + if (ctx->cmt == NULL || ctx->input_ins == NULL) { + return; + } + + if (ctx->new_data) { + ret = flb_input_metrics_append(ctx->input_ins, ctx->tag, + strlen(ctx->tag), ctx->cmt); + if (ret != 0) { + flb_plg_error(ctx->ins, "could not append metrics"); + } + } + + /* Check if we are shutting down. If so, stop our timer */ + if (config->is_shutting_down) { + if(ctx->timer && ctx->timer->active) { + flb_plg_debug(ctx->ins, "Stopping callback timer"); + flb_sched_timer_cb_disable(ctx->timer); + } + } + ctx->new_data = FLB_FALSE; +} + static int cb_log_to_metrics_init(struct flb_filter_instance *f_ins, struct flb_config *config, void *data) { @@ -462,6 +491,7 @@ static int cb_log_to_metrics_init(struct flb_filter_instance *f_ins, char metric_subsystem[MAX_METRIC_LENGTH]; char value_field[MAX_METRIC_LENGTH]; struct flb_input_instance *input_ins; + struct flb_sched *sched; int i; @@ -676,7 +706,7 @@ static int cb_log_to_metrics_init(struct flb_filter_instance *f_ins, } ret = flb_input_name_exists(ctx->emitter_name, config); - if (ret == FLB_TRUE) { + if (ret) { flb_plg_error(f_ins, "emitter_name '%s' already exists", ctx->emitter_name); flb_sds_destroy(ctx->emitter_name); @@ -732,6 +762,43 @@ static int cb_log_to_metrics_init(struct flb_filter_instance *f_ins, } ctx->input_ins = input_ins; + + if (ctx->flush_interval_sec <= 0) { + ctx->flush_interval_sec = strtol(DEFAULT_INTERVAL_SEC, NULL, 10); + } + if (ctx->flush_interval_nsec <= 0) { + ctx->flush_interval_nsec = strtol(DEFAULT_INTERVAL_NSEC, NULL, 10); + } + if (ctx->flush_interval_sec == 0 && ctx->flush_interval_nsec == 0) { + flb_plg_debug(ctx->ins, "Interval is set to 0, will not use timer and " + "send metrics immediately"); + ctx->timer_mode = FLB_FALSE; + return 0; + } + + /* Initialize timer for scheduled metric updates */ + sched = flb_sched_ctx_get(); + if(sched == 0) { + flb_plg_error(f_ins, "could not get scheduler context"); + log_to_metrics_destroy(ctx); + return -1; + } + /* Convert flush_interval_sec and flush_interval_nsec to milliseconds */ + ctx->timer_interval = (ctx->flush_interval_sec * 1000) + + (ctx->flush_interval_nsec / 1000000); + flb_plg_debug(ctx->ins, + "Creating metric timer with frequency %d ms", + ctx->timer_interval); + + ret = flb_sched_timer_cb_create(sched, FLB_SCHED_TIMER_CB_PERM, + ctx->timer_interval, cb_send_metric_chunk, + ctx, &ctx->timer); + if (ret < 0) { + flb_plg_error(f_ins, "could not create timer callback"); + log_to_metrics_destroy(ctx); + return -1; + } + ctx->timer_mode = FLB_TRUE; return 0; } @@ -923,9 +990,17 @@ static int cb_log_to_metrics_filter(const void *data, size_t bytes, return -1; } - ret = flb_input_metrics_append(ctx->input_ins, ctx->tag, strlen(ctx->tag), ctx->cmt); - if (ret != 0) { - flb_plg_error(ctx->ins, "could not append metrics"); + if (!ctx->timer_mode) { + ret = flb_input_metrics_append(ctx->input_ins, ctx->tag, + strlen(ctx->tag), ctx->cmt); + + if (ret != 0) { + flb_plg_error(ctx->ins, "could not append metrics. " + "Please consider to use flush_interval_sec and flush_interval_nsec"); + } + } + else { + ctx->new_data = FLB_TRUE; } /* Cleanup */ @@ -944,6 +1019,7 @@ static int cb_log_to_metrics_filter(const void *data, size_t bytes, } } + if (ctx->discard_logs) { *out_buf = NULL; *out_size = 0; @@ -961,7 +1037,10 @@ static int cb_log_to_metrics_filter(const void *data, size_t bytes, static int cb_log_to_metrics_exit(void *data, struct flb_config *config) { struct log_to_metrics_ctx *ctx = data; - + if(ctx->timer != NULL) { + flb_plg_debug(ctx->ins, "Destroying callback timer"); + flb_sched_timer_destroy(ctx->timer); + } return log_to_metrics_destroy(ctx); } @@ -1040,13 +1119,24 @@ static struct flb_config_map config_map[] = { 0, FLB_TRUE, offsetof(struct log_to_metrics_ctx, emitter_name), "Name of the emitter (advanced users)" }, - { FLB_CONFIG_MAP_SIZE, "emitter_mem_buf_limit", FLB_MEM_BUF_LIMIT_DEFAULT, 0, FLB_TRUE, offsetof(struct log_to_metrics_ctx, emitter_mem_buf_limit), "set a buffer limit to restrict memory usage of metrics emitter" }, - + { + FLB_CONFIG_MAP_INT, "flush_interval_sec", DEFAULT_INTERVAL_SEC, + 0, FLB_TRUE, offsetof(struct log_to_metrics_ctx, flush_interval_sec), + "Set the timer interval for metrics emission. If flush_interval_sec and " + "flush_interval_nsec are set to 0, the timer is disabled (default)." + }, + { + FLB_CONFIG_MAP_INT, "flush_interval_nsec", DEFAULT_INTERVAL_NSEC, + 0, FLB_TRUE, offsetof(struct log_to_metrics_ctx, flush_interval_nsec), + "Set the timer interval (subseconds) for metrics emission. " + "If flush_interval_sec and flush_interval_nsec are set to 0, the timer is disabled " + "(default). Final precision is milliseconds." + }, { FLB_CONFIG_MAP_BOOL, "discard_logs", "false", 0, FLB_TRUE, offsetof(struct log_to_metrics_ctx, discard_logs), diff --git a/plugins/filter_log_to_metrics/log_to_metrics.h b/plugins/filter_log_to_metrics/log_to_metrics.h index ae5b822c554..b326ffca467 100644 --- a/plugins/filter_log_to_metrics/log_to_metrics.h +++ b/plugins/filter_log_to_metrics/log_to_metrics.h @@ -50,13 +50,13 @@ #define FLB_MEM_BUF_LIMIT_DEFAULT "10M" #define DEFAULT_LOG_TO_METRICS_NAMESPACE "log_metric" - +#define DEFAULT_INTERVAL_SEC "0" +#define DEFAULT_INTERVAL_NSEC "0" struct log_to_metrics_ctx { struct mk_list rules; struct flb_filter_instance *ins; struct cmt *cmt; - struct flb_input_instance *input_ins; char **label_keys; @@ -84,6 +84,12 @@ struct log_to_metrics_ctx { flb_sds_t tag; flb_sds_t emitter_name; size_t emitter_mem_buf_limit; + long flush_interval_sec; + long flush_interval_nsec; + int timer_interval; + int timer_mode; + struct flb_sched_timer *timer; + int new_data; }; struct grep_rule From c3d2417dc5a3d1a6e31f76ccc2bae22b65033c7c Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 16 Sep 2024 10:20:04 -0600 Subject: [PATCH 179/295] lib: cmetrics: upgrade to v0.9.6 Signed-off-by: Eduardo Silva --- lib/cmetrics/CMakeLists.txt | 8 +- lib/cmetrics/include/cmetrics/cmt_math.h | 10 + lib/cmetrics/src/cmt_cat.c | 265 +++++++++++++++++------ lib/cmetrics/tests/cat.c | 160 ++++++++++++++ lib/cmetrics/tests/prometheus_parser.c | 1 - 5 files changed, 370 insertions(+), 74 deletions(-) diff --git a/lib/cmetrics/CMakeLists.txt b/lib/cmetrics/CMakeLists.txt index 1cdd0db35da..4f298910674 100644 --- a/lib/cmetrics/CMakeLists.txt +++ b/lib/cmetrics/CMakeLists.txt @@ -6,7 +6,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # CMetrics Version set(CMT_VERSION_MAJOR 0) set(CMT_VERSION_MINOR 9) -set(CMT_VERSION_PATCH 5) +set(CMT_VERSION_PATCH 6) set(CMT_VERSION_STR "${CMT_VERSION_MAJOR}.${CMT_VERSION_MINOR}.${CMT_VERSION_PATCH}") # Include helpers @@ -69,12 +69,18 @@ endif() # Configuration options option(CMT_DEV "Enable development mode" No) +option(CMT_DEBUG "Enable debug mode" No) option(CMT_TESTS "Enable unit testing" No) option(CMT_INSTALL_TARGETS "Enable subdirectory library installations" Yes) option(CMT_ENABLE_PROMETHEUS_DECODER "Enable prometheus decoder" Yes) if(CMT_DEV) set(CMT_TESTS Yes) + set(CMT_DEBUG Yes) +endif() + +if(CMT_DEBUG) + set(CMAKE_BUILD_TYPE Debug) endif() set(FLEX_BISON_GENERATED_DIR ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/lib/cmetrics/include/cmetrics/cmt_math.h b/lib/cmetrics/include/cmetrics/cmt_math.h index 6f7e3f18fb6..91383818275 100644 --- a/lib/cmetrics/include/cmetrics/cmt_math.h +++ b/lib/cmetrics/include/cmetrics/cmt_math.h @@ -49,4 +49,14 @@ static inline double cmt_math_uint64_to_d64(uint64_t val) return u.d; } +static inline uint64_t cmt_math_sum_native_uint64_as_d64(uint64_t dst, uint64_t src) +{ + double val; + + val = cmt_math_uint64_to_d64(dst); + val += cmt_math_uint64_to_d64(src); + + return cmt_math_d64_to_uint64(val); +} + #endif diff --git a/lib/cmetrics/src/cmt_cat.c b/lib/cmetrics/src/cmt_cat.c index b2171196086..5ef28d4f831 100644 --- a/lib/cmetrics/src/cmt_cat.c +++ b/lib/cmetrics/src/cmt_cat.c @@ -96,9 +96,66 @@ static int copy_label_values(struct cmt_metric *metric, char **out) return i; } -int cmt_cat_copy_map(struct cmt_opts *opts, struct cmt_map *dst, struct cmt_map *src) +static inline int cat_histogram_values(struct cmt_metric *metric_dst, struct cmt_histogram *histogram, + struct cmt_metric *metric_src) { int i; + + if (!metric_dst->hist_buckets) { + metric_dst->hist_buckets = calloc(1, sizeof(uint64_t) * (histogram->buckets->count + 1)); + if (!metric_dst->hist_buckets) { + return -1; + } + } + + for (i = 0; i < histogram->buckets->count; i++) { + /* histogram buckets are always integers, no need to convert them */ + metric_dst->hist_buckets[i] += metric_src->hist_buckets[i]; + } + + /* histogram count */ + metric_dst->hist_count = cmt_math_sum_native_uint64_as_d64(metric_dst->hist_count, + metric_src->hist_count); + + /* histoggram sum */ + metric_dst->hist_sum = cmt_math_sum_native_uint64_as_d64(metric_dst->hist_sum, + metric_src->hist_sum); + + return 0; +} + +/* + * For summaries we don't support manual updates through the API, on concatenation we just + * keep the last values reported. + */ +static inline int cat_summary_values(struct cmt_metric *metric_dst, struct cmt_summary *summary, + struct cmt_metric *metric_src) +{ + int i; + + if (!metric_dst->sum_quantiles) { + metric_dst->sum_quantiles = calloc(1, sizeof(uint64_t) * (summary->quantiles_count)); + if (!metric_dst->sum_quantiles) { + return -1; + } + } + + for (i = 0; i < summary->quantiles_count; i++) { + /* summary quantiles are always integers, no need to convert them */ + metric_dst->sum_quantiles[i] = metric_src->sum_quantiles[i]; + } + + metric_dst->sum_quantiles_count = metric_src->sum_quantiles_count; + metric_dst->sum_quantiles_set = metric_src->sum_quantiles_set; + + metric_dst->sum_count = metric_src->sum_count; + metric_dst->sum_sum = metric_src->sum_sum; + + return 0; +} + +int cmt_cat_copy_map(struct cmt_opts *opts, struct cmt_map *dst, struct cmt_map *src) +{ int c; int ret; uint64_t ts; @@ -107,6 +164,7 @@ int cmt_cat_copy_map(struct cmt_opts *opts, struct cmt_map *dst, struct cmt_map struct cfl_list *head; struct cmt_metric *metric_dst; struct cmt_metric *metric_src; + struct cmt_summary *summary; struct cmt_histogram *histogram; /* Handle static metric (no labels case) */ @@ -119,33 +177,17 @@ int cmt_cat_copy_map(struct cmt_opts *opts, struct cmt_map *dst, struct cmt_map if (src->type == CMT_HISTOGRAM) { histogram = (struct cmt_histogram *) src->parent; - - if (!metric_dst->hist_buckets) { - metric_dst->hist_buckets = calloc(1, sizeof(uint64_t) * (histogram->buckets->count + 1)); - if (!metric_dst->hist_buckets) { - return -1; - } - } - for (i = 0; i < histogram->buckets->count; i++) { - metric_dst->hist_buckets[i] = metric_src->hist_buckets[i]; + ret = cat_histogram_values(metric_dst, histogram, metric_src); + if (ret == -1) { + return -1; } - metric_dst->hist_count = metric_src->hist_count; - metric_dst->hist_sum = metric_src->hist_sum; } else if (src->type == CMT_SUMMARY) { - metric_dst->sum_quantiles_count = metric_src->sum_quantiles_count; - metric_dst->sum_quantiles_set = metric_src->sum_quantiles_set; - if (!metric_dst->sum_quantiles) { - metric_dst->sum_quantiles = calloc(1, sizeof(uint64_t) * (metric_src->sum_quantiles_count)); - if (!metric_dst->sum_quantiles) { - return -1; - } - } - for (i = 0; i < metric_src->sum_quantiles_count; i++) { - metric_dst->sum_quantiles[i] = metric_src->sum_quantiles[i]; + summary = (struct cmt_summary *) src->parent; + ret = cat_summary_values(metric_dst, summary, metric_src); + if (ret == -1) { + return -1; } - metric_dst->sum_count = metric_src->sum_count; - metric_dst->sum_sum = metric_src->sum_sum; } ts = cmt_metric_get_timestamp(metric_src); @@ -173,34 +215,17 @@ int cmt_cat_copy_map(struct cmt_opts *opts, struct cmt_map *dst, struct cmt_map if (src->type == CMT_HISTOGRAM) { histogram = (struct cmt_histogram *) src->parent; - - if (!metric_dst->hist_buckets) { - metric_dst->hist_buckets = calloc(1, sizeof(uint64_t) * (histogram->buckets->count + 1)); - if (!metric_dst->hist_buckets) { - return -1; - } - } - - for (i = 0; i < histogram->buckets->count; i++) { - metric_dst->hist_buckets[i] = metric_src->hist_buckets[i]; + ret = cat_histogram_values(metric_dst, histogram, metric_src); + if (ret == -1) { + return -1; } - metric_dst->hist_count = metric_src->hist_count; - metric_dst->hist_sum = metric_src->hist_sum; } else if (src->type == CMT_SUMMARY) { - metric_dst->sum_quantiles_count = metric_src->sum_quantiles_count; - metric_dst->sum_quantiles_set = metric_src->sum_quantiles_set; - if (!metric_dst->sum_quantiles) { - metric_dst->sum_quantiles = calloc(1, sizeof(uint64_t) * (metric_src->sum_quantiles_count)); - if (!metric_dst->sum_quantiles) { - return -1; - } + summary = (struct cmt_summary *) src->parent; + ret = cat_summary_values(metric_dst, summary, metric_src); + if (ret == -1) { + return -1; } - for (i = 0; i < metric_src->sum_quantiles_count; i++) { - metric_dst->sum_quantiles[i] = metric_src->sum_quantiles[i]; - } - metric_dst->sum_count = metric_src->sum_count; - metric_dst->sum_sum = metric_src->sum_sum; } ts = cmt_metric_get_timestamp(metric_src); @@ -213,6 +238,88 @@ int cmt_cat_copy_map(struct cmt_opts *opts, struct cmt_map *dst, struct cmt_map } +static inline int cmt_opts_compare(struct cmt_opts *a, struct cmt_opts *b) +{ + int ret; + + ret = strcmp(a->ns, a->ns); + if (ret != 0) { + return ret; + } + + ret = strcmp(a->subsystem, b->subsystem); + if (ret != 0) { + return ret; + } + + ret = strcmp(a->name, b->name); + if (ret != 0) { + return ret; + } + + return strcmp(a->description, b->description); +} + +static struct cmt_counter *counter_lookup(struct cmt *cmt, struct cmt_opts *opts) +{ + struct cmt_counter *counter; + struct cfl_list *head; + + cfl_list_foreach(head, &cmt->counters) { + counter = cfl_list_entry(head, struct cmt_counter, _head); + if (cmt_opts_compare(&counter->opts, opts) == 0) { + return counter; + } + } + + return NULL; +} + +static struct cmt_gauge *gauge_lookup(struct cmt *cmt, struct cmt_opts *opts) +{ + struct cmt_gauge *gauge; + struct cfl_list *head; + + cfl_list_foreach(head, &cmt->gauges) { + gauge = cfl_list_entry(head, struct cmt_gauge, _head); + if (cmt_opts_compare(&gauge->opts, opts) == 0) { + return gauge; + } + } + + return NULL; +} + +static struct cmt_untyped *untyped_lookup(struct cmt *cmt, struct cmt_opts *opts) +{ + struct cmt_untyped *untyped; + struct cfl_list *head; + + cfl_list_foreach(head, &cmt->untypeds) { + untyped = cfl_list_entry(head, struct cmt_untyped, _head); + if (cmt_opts_compare(&untyped->opts, opts) == 0) { + return untyped; + } + } + + return NULL; +} + +static struct cmt_histogram *histogram_lookup(struct cmt *cmt, struct cmt_opts *opts) +{ + struct cmt_histogram *histogram; + struct cfl_list *head; + + cfl_list_foreach(head, &cmt->histograms) { + histogram = cfl_list_entry(head, struct cmt_histogram, _head); + if (cmt_opts_compare(&histogram->opts, opts) == 0) { + return histogram; + } + } + + return NULL; +} + int cmt_cat_counter(struct cmt *cmt, struct cmt_counter *counter, struct cmt_map *filtered_map) { @@ -230,11 +337,14 @@ int cmt_cat_counter(struct cmt *cmt, struct cmt_counter *counter, return -1; } - /* create counter */ - c = cmt_counter_create(cmt, - opts->ns, opts->subsystem, - opts->name, opts->description, - map->label_count, labels); + c = counter_lookup(cmt, opts); + if (!c) { + /* create counter */ + c = cmt_counter_create(cmt, + opts->ns, opts->subsystem, + opts->name, opts->description, + map->label_count, labels); + } free(labels); if (!c) { @@ -274,11 +384,15 @@ int cmt_cat_gauge(struct cmt *cmt, struct cmt_gauge *gauge, return -1; } - /* create counter */ - g = cmt_gauge_create(cmt, - opts->ns, opts->subsystem, - opts->name, opts->description, - map->label_count, labels); + g = gauge_lookup(cmt, opts); + if (!g) { + /* create counter */ + g = cmt_gauge_create(cmt, + opts->ns, opts->subsystem, + opts->name, opts->description, + map->label_count, labels); + } + free(labels); if (!g) { return -1; @@ -317,11 +431,15 @@ int cmt_cat_untyped(struct cmt *cmt, struct cmt_untyped *untyped, return -1; } - /* create counter */ - u = cmt_untyped_create(cmt, - opts->ns, opts->subsystem, - opts->name, opts->description, - map->label_count, labels); + u = untyped_lookup(cmt, opts); + if (!u) { + /* create counter */ + u = cmt_untyped_create(cmt, + opts->ns, opts->subsystem, + opts->name, opts->description, + map->label_count, labels); + } + free(labels); if (!u) { return -1; @@ -362,16 +480,19 @@ int cmt_cat_histogram(struct cmt *cmt, struct cmt_histogram *histogram, return -1; } - buckets_count = histogram->buckets->count; - buckets = cmt_histogram_buckets_create_size(histogram->buckets->upper_bounds, - buckets_count); + hist = histogram_lookup(cmt, opts); + if (!hist) { + buckets_count = histogram->buckets->count; + buckets = cmt_histogram_buckets_create_size(histogram->buckets->upper_bounds, + buckets_count); - /* create histogram */ - hist = cmt_histogram_create(cmt, - opts->ns, opts->subsystem, - opts->name, opts->description, - buckets, - map->label_count, labels); + /* create histogram */ + hist = cmt_histogram_create(cmt, + opts->ns, opts->subsystem, + opts->name, opts->description, + buckets, + map->label_count, labels); + } free(labels); if (!hist) { diff --git a/lib/cmetrics/tests/cat.c b/lib/cmetrics/tests/cat.c index c1bf982e9d2..a41d7945522 100644 --- a/lib/cmetrics/tests/cat.c +++ b/lib/cmetrics/tests/cat.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "cmt_tests.h" @@ -232,7 +233,166 @@ void test_cat() cmt_destroy(cmt5); } + +void test_duplicate_metrics() +{ + int i; + int ret; + double val; + struct cmt *cmt1; + struct cmt *cmt2; + struct cmt *final; + struct cmt_counter *c; + struct cmt_gauge *g; + struct cmt_untyped *u; + struct cmt_summary *s; + struct cmt_histogram *h; + struct cmt_histogram_buckets *buckets1; + struct cmt_histogram_buckets *buckets2; + double sum; + int count; + uint64_t ts; + + cfl_sds_t text; + + /* context 1 */ + cmt1 = cmt_create(); + TEST_CHECK(cmt1 != NULL); + + c = cmt_counter_create(cmt1, "cmetrics", "test", "cat_counter", "first counter", + 2, (char *[]) {"label1", "label2"}); + TEST_CHECK(c != NULL); + cmt_counter_set(c, cfl_time_now(), 10, 0, NULL ); + cmt_counter_inc(c, cfl_time_now(), 2, (char *[]) {"aaa", "bbb"}); + + + g = cmt_gauge_create(cmt1, "cmetrics", "test", "cat_gauge", "first gauge", + 2, (char *[]) {"label3", "label4"}); + TEST_CHECK(g != NULL); + cmt_gauge_inc(g, cfl_time_now(), 2, (char *[]) {"yyy", "xxx"}); + + u = cmt_untyped_create(cmt1, "cmetrics", "test", "cat_untyped", "first untyped", + 2, (char *[]) {"label5", "label6"}); + TEST_CHECK(u != NULL); + cmt_untyped_set(u, cfl_time_now(), 10, 2, (char *[]) {"qwe", "asd"}); + + s = cmt_summary_create(cmt1, + "spring", "kafka_listener", "seconds", "Kafka Listener Timer", + 6, (double[]) {0.1, 0.2, 0.3, 0.4, 0.5, 1.0}, + 3, (char *[]) {"exception", "name", "result"}); + + ts = cfl_time_now(); + + /* Summary + * ------- + */ + /* no quantiles, labels */ + sum = 0.0; + count = 1; + + cmt_summary_set_default(s, ts, NULL, sum, count, + 3, (char *[]) {"ListenerExecutionFailedException", + "org.springframework.kafka.KafkaListenerEndpointContainer#0-0", + "failure"}); + + /* no quantiles, labels */ + sum = 0.1; + count = 2; + cmt_summary_set_default(s, ts, NULL, sum, count, + 3, (char *[]) {"none", + "org.springframework.kafka.KafkaListenerEndpointContainer#0-0", + "success"}); + + /* quantiles, labels */ + sum = 0.2; + count = 3; + cmt_summary_set_default(s, ts, NULL, sum, count, + 3, (char *[]) {"extra test", + "org.springframework.kafka.KafkaListenerEndpointContainer#0-0", + "success"}); + + /* + * Histogram + * --------- + */ + buckets1 = cmt_histogram_buckets_create(11, + 0.005, 0.01, 0.025, 0.05, + 0.1, 0.25, 0.5, 1.0, 2.5, + 5.0, 10.0); + + h = cmt_histogram_create(cmt1, + "k8s", "network", "load", "Network load", + buckets1, + 1, (char *[]) {"my_label"}); + TEST_CHECK(h != NULL); + + ts = cfl_time_now(); + for (i = 0; i < sizeof(hist_observe_values)/(sizeof(double)); i++) { + val = hist_observe_values[i]; + cmt_histogram_observe(h, ts, val, 1, (char *[]) {"my_label"}); + } + + /* duplicate counter */ + cmt2 = cmt_create(); + TEST_CHECK(cmt2 != NULL); + + c = cmt_counter_create(cmt2, "cmetrics", "test", "cat_counter", "first counter", + 2, (char *[]) {"label1", "label2"}); + TEST_CHECK(c != NULL); + cmt_counter_set(c, cfl_time_now(), 11, 0, NULL ); + cmt_counter_inc(c, cfl_time_now(), 2, (char *[]) {"ddd", "eee"}); + + /* duplicate gauge */ + g = cmt_gauge_create(cmt2, "cmetrics", "test", "cat_gauge", "first gauge", + 2, (char *[]) {"label3", "label4"}); + TEST_CHECK(g != NULL); + cmt_gauge_inc(g, cfl_time_now(), 2, (char *[]) {"zzz", "xxx"}); + + /* duplicate untyped */ + u = cmt_untyped_create(cmt2, "cmetrics", "test", "cat_untyped", "first untyped", + 2, (char *[]) {"label5", "label6"}); + TEST_CHECK(u != NULL); + cmt_untyped_set(u, cfl_time_now(), 20, 2, (char *[]) {"rty", "asd"}); + + buckets2 = cmt_histogram_buckets_create(11, + 0.005, 0.01, 0.025, 0.05, + 0.1, 0.25, 0.5, 1.0, 2.5, + 5.0, 10.0); + h = cmt_histogram_create(cmt2, + "k8s", "network", "load", "Network load", + buckets2, + 1, (char *[]) {"my_label2"}); + TEST_CHECK(h != NULL); + + ts = cfl_time_now(); + + for (i = 0; i < sizeof(hist_observe_values)/(sizeof(double)); i++) { + val = hist_observe_values[i]; + cmt_histogram_observe(h, ts, val, 1, (char *[]) {"my_label"}); + } + + /* concatenate cmt1 + cmt2 */ + final = cmt_create(); + ret = cmt_cat(final, cmt1); + TEST_CHECK(ret == 0); + + ret = cmt_cat(final, cmt2); + TEST_CHECK(ret == 0); + + /* prometheus format */ + text = cmt_encode_prometheus_create(final, CMT_FALSE); + printf("Prometheus Text====>\n%s\n", text); + cfl_sds_destroy(text); + + + cmt_destroy(cmt1); + cmt_destroy(cmt2); + cmt_destroy(final); + +} + TEST_LIST = { {"cat", test_cat}, + {"duplicate_metrics", test_duplicate_metrics}, { 0 } }; diff --git a/lib/cmetrics/tests/prometheus_parser.c b/lib/cmetrics/tests/prometheus_parser.c index 5fa0c889886..08b3f2dc82d 100644 --- a/lib/cmetrics/tests/prometheus_parser.c +++ b/lib/cmetrics/tests/prometheus_parser.c @@ -1669,7 +1669,6 @@ void test_issue_fluent_bit_9267() { char errbuf[256]; int status; - cfl_sds_t result = NULL; struct cmt *cmt; struct cmt_decode_prometheus_parse_opts opts; memset(&opts, 0, sizeof(opts)); From 41b90b777c3b83dc1a09299f8ff5147852a82bc0 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Wed, 11 Sep 2024 16:39:26 +0900 Subject: [PATCH 180/295] out_splunk: Extend retrying HTTP status code 408 and 429 also should be treated as retry. Signed-off-by: Hiroshi Hatake --- plugins/out_splunk/splunk.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/out_splunk/splunk.c b/plugins/out_splunk/splunk.c index a928f52843b..413c1e04036 100644 --- a/plugins/out_splunk/splunk.c +++ b/plugins/out_splunk/splunk.c @@ -768,8 +768,13 @@ static void cb_splunk_flush(struct flb_event_chunk *event_chunk, * them: * * https://docs.splunk.com/Documentation/Splunk/8.0.5/Data/TroubleshootHTTPEventCollector#Possible_error_codes + * From trouble shoot document on Splunk secure gateway, + * 408 and 429 should be also handled as try again: + * + * https://docs.splunk.com/Documentation/SecureGateway/3.5.15/Admin/TroubleshootGateway#Troubleshoot_error_codes */ - ret = (c->resp.status < 400 || c->resp.status >= 500) ? + ret = (c->resp.status < 400 || c->resp.status >= 500 || + c->resp.status == 408 || c->resp.status == 429) ? FLB_RETRY : FLB_ERROR; From f36c95620224b0a372e4ce481e3dd58b6670251f Mon Sep 17 00:00:00 2001 From: Pat Date: Wed, 25 Sep 2024 14:09:23 +0100 Subject: [PATCH 181/295] workflows: Update scorecard workflow and remove Dockerfile warnings (#9421) Signed-off-by: Patrick Stephens --- .../workflows/cron-scorecards-analysis.yaml | 21 +++++++------------ dockerfiles/Dockerfile | 20 ++++++++++-------- dockerfiles/Dockerfile.windows | 4 ++-- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/.github/workflows/cron-scorecards-analysis.yaml b/.github/workflows/cron-scorecards-analysis.yaml index cd54e475dd4..3c6d8230a0b 100644 --- a/.github/workflows/cron-scorecards-analysis.yaml +++ b/.github/workflows/cron-scorecards-analysis.yaml @@ -3,8 +3,10 @@ # https://openssf.org/blog/2022/01/19/reducing-security-risks-in-open-source-software-at-scale-scorecards-launches-v4/ name: Scorecards supply-chain security on: - # Only the default branch is supported. - branch_protection_rule: + push: + # Only the default branch is supported. + branches: + - main schedule: # Weekly on Saturdays. - cron: '30 1 * * 6' @@ -31,29 +33,20 @@ jobs: - name: "Run analysis" uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 with: - results_file: scorecard-results.sarif + results_file: results.sarif results_format: sarif - # (Optional) fine-grained personal access token. Uncomment the `repo_token` line below if: - # - you want to enable the Branch-Protection check on a *public* repository, or - # To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-fine-grained-pat-optional. - repo_token: ${{ secrets.SCORECARD_TOKEN }} - # - # Publish the results for public repositories to enable scorecard badges. For more details, see - # https://github.com/ossf/scorecard-action#publishing-results. - # For private repositories, `publish_results` will automatically be set to `false`, regardless - # of the value entered here. publish_results: true - name: "Upload artifact" uses: actions/upload-artifact@v4 with: name: SARIF file - path: scorecard-results.sarif + path: results.sarif retention-days: 7 # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" uses: github/codeql-action/upload-sarif@v3 with: - sarif_file: scorecard-results.sarif + sarif_file: results.sarif category: ossf-scorecard diff --git a/dockerfiles/Dockerfile b/dockerfiles/Dockerfile index feb84bb49d1..f068611e654 100644 --- a/dockerfiles/Dockerfile +++ b/dockerfiles/Dockerfile @@ -1,3 +1,5 @@ +# syntax=docker/dockerfile:1 +# check=skip=InvalidBaseImagePlatform # To use this container you may need to do the following: # https://askubuntu.com/a/1369504 @@ -14,10 +16,10 @@ ARG RELEASE_VERSION=3.1.7 # For multi-arch builds - assumption is running on an AMD64 host -FROM multiarch/qemu-user-static:x86_64-arm as qemu-arm32 -FROM multiarch/qemu-user-static:x86_64-aarch64 as qemu-arm64 +FROM multiarch/qemu-user-static:x86_64-arm AS qemu-arm32 +FROM multiarch/qemu-user-static:x86_64-aarch64 AS qemu-arm64 -FROM debian:bookworm-slim as builder-base +FROM debian:bookworm-slim AS builder-base COPY --from=qemu-arm32 /usr/bin/qemu-arm-static /usr/bin/ COPY --from=qemu-arm64 /usr/bin/qemu-aarch64-static /usr/bin/ @@ -30,7 +32,7 @@ ENV FLB_CHUNK_TRACE=${FLB_CHUNK_TRACE} RUN mkdir -p /fluent-bit/bin /fluent-bit/etc /fluent-bit/log -ENV DEBIAN_FRONTEND noninteractive +ENV DEBIAN_FRONTEND=noninteractive # hadolint ignore=DL3008 RUN echo "deb http://deb.debian.org/debian bookworm-backports main" >> /etc/apt/sources.list && \ @@ -61,7 +63,7 @@ WORKDIR /src/fluent-bit/ COPY . ./ # We split the builder setup out so people can target it or use as a base image without doing a full build. -FROM builder-base as builder +FROM builder-base AS builder WORKDIR /src/fluent-bit/build/ RUN cmake -DFLB_RELEASE=On \ -DFLB_JEMALLOC=On \ @@ -97,7 +99,7 @@ RUN /fluent-bit/bin/fluent-bit -J > /fluent-bit/etc/schema.json # Simple example of how to properly extract packages for reuse in distroless # Taken from: https://github.com/GoogleContainerTools/distroless/issues/863 -FROM debian:bookworm-slim as deb-extractor +FROM debian:bookworm-slim AS deb-extractor COPY --from=qemu-arm32 /usr/bin/qemu-arm-static /usr/bin/ COPY --from=qemu-arm64 /usr/bin/qemu-aarch64-static /usr/bin/ @@ -154,7 +156,7 @@ RUN find /dpkg/ -type d -empty -delete && \ # We want latest at time of build # hadolint ignore=DL3006 -FROM gcr.io/distroless/cc-debian12 as production +FROM gcr.io/distroless/cc-debian12 AS production ARG RELEASE_VERSION ENV FLUENT_BIT_VERSION=${RELEASE_VERSION} LABEL description="Fluent Bit multi-architecture container image" \ @@ -185,7 +187,7 @@ EXPOSE 2020 ENTRYPOINT [ "/fluent-bit/bin/fluent-bit" ] CMD ["/fluent-bit/bin/fluent-bit", "-c", "/fluent-bit/etc/fluent-bit.conf"] -FROM debian:bookworm-slim as debug +FROM debian:bookworm-slim AS debug ARG RELEASE_VERSION ENV FLUENT_BIT_VERSION=${RELEASE_VERSION} LABEL description="Fluent Bit multi-architecture debug container image" \ @@ -203,7 +205,7 @@ LABEL description="Fluent Bit multi-architecture debug container image" \ COPY --from=qemu-arm32 /usr/bin/qemu-arm-static /usr/bin/ COPY --from=qemu-arm64 /usr/bin/qemu-aarch64-static /usr/bin/ -ENV DEBIAN_FRONTEND noninteractive +ENV DEBIAN_FRONTEND=noninteractive # hadolint ignore=DL3008 RUN echo "deb http://deb.debian.org/debian bookworm-backports main" >> /etc/apt/sources.list && \ diff --git a/dockerfiles/Dockerfile.windows b/dockerfiles/Dockerfile.windows index 8ffefe78e55..14c901c4776 100644 --- a/dockerfiles/Dockerfile.windows +++ b/dockerfiles/Dockerfile.windows @@ -14,7 +14,7 @@ ARG WINDOWS_VERSION=ltsc2019 # Builder Image - Windows Server Core -FROM mcr.microsoft.com/windows/servercore:$WINDOWS_VERSION as builder +FROM mcr.microsoft.com/windows/servercore:$WINDOWS_VERSION AS builder RUN setx /M PATH "%PATH%;C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;C:\WinFlexBison;C:\dev\vcpkg" @@ -87,7 +87,7 @@ RUN New-Item -Path /fluent-bit/etc/ -ItemType "directory"; ` # # Runtime Image - Windows Server Core # -FROM mcr.microsoft.com/windows/servercore:$WINDOWS_VERSION as runtime +FROM mcr.microsoft.com/windows/servercore:$WINDOWS_VERSION AS runtime ARG FLUENTBIT_VERSION=master ARG IMAGE_CREATE_DATE From 4729f0c8ada17048e12791a9802bbfc5b32ff502 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Thu, 26 Sep 2024 18:04:10 +0900 Subject: [PATCH 182/295] config_format: cf_yaml: Plug memory leaks on exception for variants on plugin elements Signed-off-by: Hiroshi Hatake --- src/config_format/flb_cf_yaml.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/config_format/flb_cf_yaml.c b/src/config_format/flb_cf_yaml.c index c2ec53abc0c..c7c88ae5e8d 100644 --- a/src/config_format/flb_cf_yaml.c +++ b/src/config_format/flb_cf_yaml.c @@ -2083,6 +2083,15 @@ static struct parser_state *state_pop(struct local_ctx *ctx) cfl_kvlist_destroy(last->keyvals); } + /* Teardown associated variant stuffs */ + if (last->variant_kvlist_key != NULL) { + cfl_sds_destroy(last->variant_kvlist_key); + } + + if (last->variant != NULL) { + cfl_variant_destroy(last->variant); + } + state_destroy(last); if (cfl_list_size(&ctx->states) <= 0) { From 0a2dd4a0f8678e39e803b06b86ecad25d3140e19 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Thu, 26 Sep 2024 18:42:42 +0900 Subject: [PATCH 183/295] config_format: cf_yaml: tests: Add a test case for broken plugin variant Signed-off-by: Hiroshi Hatake --- tests/internal/config_format_yaml.c | 16 +++++++++ .../yaml/broken_plugin_variant.yaml | 34 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 tests/internal/data/config_format/yaml/broken_plugin_variant.yaml diff --git a/tests/internal/config_format_yaml.c b/tests/internal/config_format_yaml.c index 6f1fc488a6a..f34bdb273d4 100644 --- a/tests/internal/config_format_yaml.c +++ b/tests/internal/config_format_yaml.c @@ -21,6 +21,7 @@ #define FLB_001 FLB_TESTS_CONF_PATH "/issue_7559.yaml" #define FLB_002 FLB_TESTS_CONF_PATH "/processors.yaml" #define FLB_000_WIN FLB_TESTS_CONF_PATH "\\fluent-bit-windows.yaml" +#define FLB_BROKEN_PLUGIN_VARIANT FLB_TESTS_CONF_PATH "/broken_plugin_variant.yaml" #ifdef _WIN32 #define FLB_BASIC FLB_000_WIN @@ -180,6 +181,20 @@ static void test_customs_section() flb_cf_destroy(cf); } +static void test_broken_plugin_variant_yaml() +{ + struct flb_cf *cf; + + cf = flb_cf_yaml_create(NULL, FLB_BROKEN_PLUGIN_VARIANT, NULL, 0); + TEST_CHECK(cf == NULL); + + if (cf != NULL) { + TEST_CHECK_(cf != NULL, "somewhat config_format is created wrongly"); + flb_cf_dump(cf); + flb_cf_destroy(cf); + } +} + static void test_slist_even() { struct flb_cf *cf; @@ -443,6 +458,7 @@ static void test_processors() TEST_LIST = { { "basic" , test_basic}, { "customs section", test_customs_section}, + { "broken_plugin_variant_yaml", test_broken_plugin_variant_yaml}, { "slist odd", test_slist_odd}, { "slist even", test_slist_even}, { "parsers file conf", test_parser_conf}, diff --git a/tests/internal/data/config_format/yaml/broken_plugin_variant.yaml b/tests/internal/data/config_format/yaml/broken_plugin_variant.yaml new file mode 100644 index 00000000000..65a5160013d --- /dev/null +++ b/tests/internal/data/config_format/yaml/broken_plugin_variant.yaml @@ -0,0 +1,34 @@ +env: + flush_interval: 1 + +service: + http_server: "on" + Health_Check: "on" + log_level: info + +pipeline: + inputs: + - name: event_type + tag: event + type: logs + processors: + logs: + - name: log_replacer + replacement: + some_extra_data: + unsupported: + hi: * # this character should be quoted + some_string: "hello world" + unquoted_literals: + - some_int: 4 + - some_float: 3.1 + - some_bool: true + quoted_literals: + - some_quoted_int: "4" + - some_quoted_float: '3.1' + - some_quoted_bool: "true" + + outputs: + - name: stdout + format: json + match: event \ No newline at end of file From 013837a04ccc146b416b8bfd20f29720bbed483b Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Thu, 26 Sep 2024 19:07:53 +0900 Subject: [PATCH 184/295] config_format: cf_yaml: Cleanup variants only if occurred an exception Signed-off-by: Hiroshi Hatake --- src/config_format/flb_cf_yaml.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/config_format/flb_cf_yaml.c b/src/config_format/flb_cf_yaml.c index c7c88ae5e8d..e09034393f3 100644 --- a/src/config_format/flb_cf_yaml.c +++ b/src/config_format/flb_cf_yaml.c @@ -2060,7 +2060,7 @@ static int state_create_group(struct flb_cf *conf, struct parser_state *state, c return YAML_SUCCESS; } -static struct parser_state *state_pop(struct local_ctx *ctx) +static struct parser_state *state_pop_with_cleanup(struct local_ctx *ctx, int destroy_variants) { struct parser_state *last; @@ -2083,13 +2083,15 @@ static struct parser_state *state_pop(struct local_ctx *ctx) cfl_kvlist_destroy(last->keyvals); } - /* Teardown associated variant stuffs */ - if (last->variant_kvlist_key != NULL) { - cfl_sds_destroy(last->variant_kvlist_key); - } + if (destroy_variants == FLB_TRUE) { + /* Teardown associated variant stuffs */ + if (last->variant_kvlist_key != NULL) { + cfl_sds_destroy(last->variant_kvlist_key); + } - if (last->variant != NULL) { - cfl_variant_destroy(last->variant); + if (last->variant != NULL) { + cfl_variant_destroy(last->variant); + } } state_destroy(last); @@ -2101,6 +2103,11 @@ static struct parser_state *state_pop(struct local_ctx *ctx) return cfl_list_entry_last(&ctx->states, struct parser_state, _head); } +static struct parser_state *state_pop(struct local_ctx *ctx) +{ + return state_pop_with_cleanup(ctx, FLB_FALSE); +} + static void state_destroy(struct parser_state *s) { flb_free(s); @@ -2273,7 +2280,7 @@ static int read_config(struct flb_cf *conf, struct local_ctx *ctx, /* free all remaining states */ if (code == -1) { - while ((state = state_pop(ctx))); + while ((state = state_pop_with_cleanup(ctx, FLB_TRUE))); } else { state = state_pop(ctx); From 530b42a6984c2207c21ce1e466e61e57458fa0f4 Mon Sep 17 00:00:00 2001 From: Phillip Whelan Date: Tue, 6 Feb 2024 16:15:18 -0300 Subject: [PATCH 185/295] out_calyptia: register OS and architecture for agents. Signed-off-by: Phillip Whelan --- plugins/out_calyptia/calyptia.c | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/plugins/out_calyptia/calyptia.c b/plugins/out_calyptia/calyptia.c index 6b53a31c2ca..b56b2e4c487 100644 --- a/plugins/out_calyptia/calyptia.c +++ b/plugins/out_calyptia/calyptia.c @@ -239,6 +239,52 @@ static flb_sds_t get_agent_metadata(struct flb_calyptia *ctx) msgpack_pack_str(&mp_pck, 9); msgpack_pack_str_body(&mp_pck, "community", 9); + flb_mp_map_header_append(&mh); + msgpack_pack_str(&mp_pck, 2); + msgpack_pack_str_body(&mp_pck, "os", 2); +#ifdef FLB_SYSTEM_WINDOWS + len = strlen("windows"); + msgpack_pack_str(&mp_pck); + msgpack_pack_str_body(&mp_pck, "windows", len); +#elif FLB_SYSTEM_MACOS + len = strlen("macos"); + msgpack_pack_str(&mp_pck, len); + msgpack_pack_str_body(&mp_pck, "macos", len); +#elif __linux__ + len = strlen("linux"); + msgpack_pack_str(&mp_pck, len); + msgpack_pack_str_body(&mp_pck, "linux", len); +#else + len = strlen("unknown"); + msgpack_pack_str(&mp_pck, len); + msgpack_pack_str_body(&mp_pck, "unknown", len); +#endif + + flb_mp_map_header_append(&mh); + msgpack_pack_str(&mp_pck, 4); + msgpack_pack_str_body(&mp_pck, "arch", 4); +#if defined(__arm__) || defined(_M_ARM) + len = strlen("arm"); + msgpack_pack_str(&mp_pck, len); + msgpack_pack_str_body(&mp_pck, "arm", len); +#elif defined(__aarch64__) + len = strlen("arm64"); + msgpack_pack_str(&mp_pck, len); + msgpack_pack_str_body(&mp_pck, "arm64", len); +#elif defined(__amd64__) || defined(_M_AMD64) + len = strlen("x86_64"); + msgpack_pack_str(&mp_pck, len); + msgpack_pack_str_body(&mp_pck, "x86_64", len); +#elif defined(__i686__) || defined(_M_I86) + len = strlen("x86"); + msgpack_pack_str(&mp_pck, len); + msgpack_pack_str_body(&mp_pck, "x86", len); +#else + len = strlen("unknown"); + msgpack_pack_str(&mp_pck, len); + msgpack_pack_str_body(&mp_pck, "unknown", len); +#endif + /* machineID */ flb_mp_map_header_append(&mh); msgpack_pack_str(&mp_pck, 9); From 103c5448ace009f583e88df22a39affd0ba0c2cb Mon Sep 17 00:00:00 2001 From: Phillip Whelan Date: Tue, 6 Feb 2024 17:27:43 -0300 Subject: [PATCH 186/295] out_calyptia: add missing parameter for msgpack_str for windows os field. Signed-off-by: Phillip Whelan --- plugins/out_calyptia/calyptia.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/out_calyptia/calyptia.c b/plugins/out_calyptia/calyptia.c index b56b2e4c487..aa760e2fa5e 100644 --- a/plugins/out_calyptia/calyptia.c +++ b/plugins/out_calyptia/calyptia.c @@ -244,7 +244,7 @@ static flb_sds_t get_agent_metadata(struct flb_calyptia *ctx) msgpack_pack_str_body(&mp_pck, "os", 2); #ifdef FLB_SYSTEM_WINDOWS len = strlen("windows"); - msgpack_pack_str(&mp_pck); + msgpack_pack_str(&mp_pck, len); msgpack_pack_str_body(&mp_pck, "windows", len); #elif FLB_SYSTEM_MACOS len = strlen("macos"); From 09550246a60d30bba75d60ac1e9dfd080dea41ad Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Thu, 26 Sep 2024 11:59:17 -0600 Subject: [PATCH 187/295] lib: ctraces: upgrade to v0.5.6 Signed-off-by: Eduardo Silva --- lib/ctraces/CMakeLists.txt | 2 +- lib/ctraces/src/ctr_encode_opentelemetry.c | 29 ++++++- lib/ctraces/tests/decoding.c | 94 ++++++++++++++++++++++ 3 files changed, 120 insertions(+), 5 deletions(-) diff --git a/lib/ctraces/CMakeLists.txt b/lib/ctraces/CMakeLists.txt index 3cef9282fe2..e92834e0611 100644 --- a/lib/ctraces/CMakeLists.txt +++ b/lib/ctraces/CMakeLists.txt @@ -27,7 +27,7 @@ endif() # CTraces Version set(CTR_VERSION_MAJOR 0) set(CTR_VERSION_MINOR 5) -set(CTR_VERSION_PATCH 5) +set(CTR_VERSION_PATCH 6) set(CTR_VERSION_STR "${CTR_VERSION_MAJOR}.${CTR_VERSION_MINOR}.${CTR_VERSION_PATCH}") # Define __FILENAME__ consistently across Operating Systems diff --git a/lib/ctraces/src/ctr_encode_opentelemetry.c b/lib/ctraces/src/ctr_encode_opentelemetry.c index 8f0c81ed0bb..8a78f81a7fc 100644 --- a/lib/ctraces/src/ctr_encode_opentelemetry.c +++ b/lib/ctraces/src/ctr_encode_opentelemetry.c @@ -20,6 +20,9 @@ #include #include +static void destroy_scope_spans(Opentelemetry__Proto__Trace__V1__ScopeSpans **scope_spans, + size_t count); + static inline Opentelemetry__Proto__Common__V1__AnyValue *ctr_variant_to_otlp_any_value(struct cfl_variant *value); static inline Opentelemetry__Proto__Common__V1__KeyValue *ctr_variant_kvpair_to_otlp_kvpair(struct cfl_kvpair *input_pair); static inline Opentelemetry__Proto__Common__V1__AnyValue *ctr_variant_kvlist_to_otlp_any_value(struct cfl_variant *value); @@ -914,11 +917,21 @@ static Opentelemetry__Proto__Common__V1__InstrumentationScope *set_instrumentati return NULL; } - otel_scope->name = instrumentation_scope->name; - otel_scope->version = instrumentation_scope->version; + if (instrumentation_scope->name) { + otel_scope->name = instrumentation_scope->name; + } + else { + otel_scope->name = ""; + } + if (instrumentation_scope->version) { + otel_scope->version = instrumentation_scope->version; + } + else { + otel_scope->version = ""; + } otel_scope->n_attributes = get_attributes_count(instrumentation_scope->attr); otel_scope->dropped_attributes_count = instrumentation_scope->dropped_attr_count; - otel_scope->attributes = set_attributes_from_ctr(instrumentation_scope->attr);; + otel_scope->attributes = set_attributes_from_ctr(instrumentation_scope->attr); return otel_scope; } @@ -976,11 +989,19 @@ static Opentelemetry__Proto__Trace__V1__ScopeSpans **set_scope_spans(struct ctra otel_scope_span = initialize_scope_span(); if (!otel_scope_span) { + if (scope_span_index > 0) { + destroy_scope_spans(scope_spans, scope_span_index - 1); + } + + free(scope_spans); + return NULL; } otel_scope_span->schema_url = scope_span->schema_url; - otel_scope_span->scope = set_instrumentation_scope(scope_span->instrumentation_scope); + if (scope_span->instrumentation_scope != NULL) { + otel_scope_span->scope = set_instrumentation_scope(scope_span->instrumentation_scope); + } span_count = cfl_list_size(&scope_span->spans); otel_scope_span->n_spans = span_count; diff --git a/lib/ctraces/tests/decoding.c b/lib/ctraces/tests/decoding.c index e798f15389a..4e4a9a45453 100644 --- a/lib/ctraces/tests/decoding.c +++ b/lib/ctraces/tests/decoding.c @@ -429,6 +429,81 @@ static struct ctrace *generate_encoder_test_data() return context; } +static int generate_sample_resource_minimal_attributes(struct ctrace_resource *resource) +{ + struct ctrace_attributes *attributes; + int result; + + attributes = ctr_attributes_create(); + + if (attributes == NULL) { + return -1; + } + + result = ctr_attributes_set_string(attributes, "receiver.tool", "ctraces"); + + if (result != 0) { + ctr_attributes_destroy(attributes); + + return -2; + } + + result = ctr_resource_set_attributes(resource, attributes); + + if (result != 0) { + ctr_attributes_destroy(attributes); + + return -3; + } + + return 0; +} + +static struct ctrace *generate_encoder_test_data_with_empty_spans() +{ + struct ctrace_resource_span *resource_span; + struct ctrace_scope_span *scope_span; + struct ctrace *context; + int result; + + context = ctr_create(NULL); + + if (context == NULL) { + return NULL; + } + + resource_span = ctr_resource_span_create(context); + + if (resource_span == NULL) { + ctr_destroy(context); + + return NULL; + } + + ctr_resource_span_set_schema_url(resource_span, ""); + ctr_resource_set_dropped_attr_count(resource_span->resource, 0); + + result = generate_sample_resource_minimal_attributes(resource_span->resource); + + if (result != 0) { + ctr_destroy(context); + + return NULL; + } + + scope_span = ctr_scope_span_create(resource_span); + + if (scope_span == NULL) { + ctr_destroy(context); + + return NULL; + } + + ctr_scope_span_set_schema_url(scope_span, ""); + + return context; +} + /* * perform the following and then compare text buffers * @@ -483,6 +558,24 @@ void test_msgpack_to_cmt() ctr_destroy(context); } +void test_msgpack_to_ctr_with_empty_spans() +{ + struct ctrace *context; + char *referece_text_buffer; + + context = generate_encoder_test_data_with_empty_spans(); + TEST_ASSERT(context != NULL); + + referece_text_buffer = ctr_encode_text_create(context); + TEST_ASSERT(referece_text_buffer != NULL); + + printf("%s\n", referece_text_buffer); + msgpack_encode_decode_and_compare(context); + + ctr_encode_text_destroy(referece_text_buffer); + ctr_destroy(context); +} + void test_simple_to_msgpack_and_back() { struct ctrace *ctx; @@ -640,5 +733,6 @@ void test_simple_to_msgpack_and_back() TEST_LIST = { {"cmt_simple_to_msgpack_and_back", test_simple_to_msgpack_and_back}, {"cmt_msgpack", test_msgpack_to_cmt}, + {"empty_spans", test_msgpack_to_ctr_with_empty_spans}, { 0 } }; From dc4da5a03bda1196e55fd676caa89c8955506166 Mon Sep 17 00:00:00 2001 From: Phillip Adair Stewart Whelan Date: Mon, 23 Sep 2024 12:33:05 -0300 Subject: [PATCH 188/295] in_calyptia_fleet: fix 'unable to find fleet by name'. Signed-off-by: Phillip Adair Stewart Whelan --- plugins/in_calyptia_fleet/in_calyptia_fleet.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/in_calyptia_fleet/in_calyptia_fleet.c b/plugins/in_calyptia_fleet/in_calyptia_fleet.c index 36443113900..19307b1b3b3 100644 --- a/plugins/in_calyptia_fleet/in_calyptia_fleet.c +++ b/plugins/in_calyptia_fleet/in_calyptia_fleet.c @@ -682,6 +682,10 @@ static msgpack_object *msgpack_lookup_map_key(msgpack_object *obj, const char *k key = &cur->key.via.str; + if (key->size != strlen(keyname)) { + continue; + } + if (strncmp(key->ptr, keyname, key->size) == 0) { return &cur->val; } @@ -799,7 +803,7 @@ static ssize_t parse_fleet_search_json(struct flb_in_calyptia_fleet_config *ctx, break; } - fleet = msgpack_lookup_map_key(map, "ID"); + fleet = msgpack_lookup_map_key(map, "id"); if (fleet == NULL) { flb_plg_error(ctx->ins, "unable to find fleet by name"); break; From dd53a3997e5e1de7f2609399bd65a3991b58a466 Mon Sep 17 00:00:00 2001 From: Richard Treu Date: Thu, 26 Sep 2024 10:51:05 +0200 Subject: [PATCH 189/295] filter_multiline: Reset group metadata buffer on flush This commit resets the size of the metadata buffer on a flush. It fixes continuous growth of this buffer over time. Signed-off-by: Richard Treu --- src/multiline/flb_ml.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/multiline/flb_ml.c b/src/multiline/flb_ml.c index d08eeccb112..66814835e18 100644 --- a/src/multiline/flb_ml.c +++ b/src/multiline/flb_ml.c @@ -1443,6 +1443,7 @@ int flb_ml_flush_stream_group(struct flb_ml_parser *ml_parser, } msgpack_unpacked_destroy(&result); group->mp_sbuf.size = 0; + group->mp_md_sbuf.size = 0; } else if (len > 0) { /* Pack raw content as Fluent Bit record */ From 173192380a68049c2c3200f1db21ffa038609864 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Thu, 26 Sep 2024 17:16:52 -0600 Subject: [PATCH 190/295] lib: fluent-otel-proto: update generated files and add profiling support Signed-off-by: Eduardo Silva --- lib/fluent-otel-proto/CMakeLists.txt | 32 +- .../fluent-otel-proto/fluent-otel-info.h | 8 +- .../fluent-otel-proto/fluent-otel_found.h | 2 +- .../collector/logs/v1/logs_service.pb-c.h | 2 +- .../metrics/v1/metrics_service.pb-c.h | 2 +- .../collector/trace/v1/trace_service.pb-c.h | 2 +- .../proto/common/v1/common.pb-c.c | 14 +- .../proto/common/v1/common.pb-c.h | 7 +- .../opentelemetry/proto/logs/v1/logs.pb-c.c | 8 +- .../opentelemetry/proto/logs/v1/logs.pb-c.h | 51 +- .../proto/metrics/v1/metrics.pb-c.c | 92 +- .../proto/metrics/v1/metrics.pb-c.h | 193 ++- .../v1development/pprofextended.pb-c.c | 1525 +++++++++++++++++ .../v1development/pprofextended.pb-c.h | 799 +++++++++ .../profiles/v1development/profiles.pb-c.c | 484 ++++++ .../profiles/v1development/profiles.pb-c.h | 290 ++++ .../proto/resource/v1/resource.pb-c.h | 2 +- .../opentelemetry/proto/trace/v1/trace.pb-c.c | 70 +- .../opentelemetry/proto/trace/v1/trace.pb-c.h | 97 +- .../proto_c/protobuf-c/protobuf-c.c | 6 +- .../proto_c/protobuf-c/protobuf-c.h | 6 +- lib/fluent-otel-proto/src/CMakeLists.txt | 5 + lib/fluent-otel-proto/src/fluent-otel.c | 6 + 23 files changed, 3558 insertions(+), 145 deletions(-) create mode 100644 lib/fluent-otel-proto/proto_c/opentelemetry/proto/profiles/v1development/pprofextended.pb-c.c create mode 100644 lib/fluent-otel-proto/proto_c/opentelemetry/proto/profiles/v1development/pprofextended.pb-c.h create mode 100644 lib/fluent-otel-proto/proto_c/opentelemetry/proto/profiles/v1development/profiles.pb-c.c create mode 100644 lib/fluent-otel-proto/proto_c/opentelemetry/proto/profiles/v1development/profiles.pb-c.h diff --git a/lib/fluent-otel-proto/CMakeLists.txt b/lib/fluent-otel-proto/CMakeLists.txt index aae43bc0064..e741e184dff 100644 --- a/lib/fluent-otel-proto/CMakeLists.txt +++ b/lib/fluent-otel-proto/CMakeLists.txt @@ -8,12 +8,13 @@ include(cmake/macros.cmake) option(FLUENT_PROTO_REGENERATE "Regenerate .[ch] files only" "No") # build options for files generation -option(FLUENT_PROTO_COMMON "Include common.proto" "Yes") -option(FLUENT_PROTO_RESOURCE "Include resource.proto" "Yes") -option(FLUENT_PROTO_TRACE "Include trace.proto" "Yes") -option(FLUENT_PROTO_LOGS "Include logs.proto" "Yes") -option(FLUENT_PROTO_METRICS "Inlcude metrics.proto" "No") -option(FLUENT_PROTO_EXAMPLES "Add example programs" "Yes") +option(FLUENT_PROTO_COMMON "Include common.proto" "Yes") +option(FLUENT_PROTO_RESOURCE "Include resource.proto" "Yes") +option(FLUENT_PROTO_TRACE "Include trace.proto" "Yes") +option(FLUENT_PROTO_LOGS "Include logs.proto" "Yes") +option(FLUENT_PROTO_METRICS "Inlcude metrics.proto" "Yes") +option(FLUENT_PROTO_PROFILES "Includes profiles proto files" "Yes") +option(FLUENT_PROTO_EXAMPLES "Add example programs" "Yes") if(FLUENT_PROTO_REGENERATE AND (NOT PROTOBUF_C_SOURCE_DIR OR NOT OTEL_PROTO_DIR)) if (NOT PROTOBUF_C_SOURCE_DIR) @@ -86,12 +87,12 @@ if (FLUENT_PROTO_REGENERATE) set(proto_file "${OTEL_PROTO_DIR}/opentelemetry/proto/logs/v1/logs.proto") execute_process(COMMAND ${PROTOC_BIN} ${PROTOC_ARG_OUT} ${PROTOC_ARG_PATH} ${proto_file}) include_directories(${PROJECT_BINARY_DIR}/opentelemetry/proto/logs/v1/) - FLUENT_OTEL_DEFINITION(FLUENT_OTEL_HAVE_LOGS) message(STATUS "processing logs_service.proto") set(proto_file "${OTEL_PROTO_DIR}/opentelemetry/proto/collector/logs/v1/logs_service.proto") execute_process(COMMAND ${PROTOC_BIN} ${PROTOC_ARG_OUT} ${PROTOC_ARG_PATH} ${proto_file}) include_directories(${PROJECT_BINARY_DIR}/opentelemetry/proto/collector/logs/v1/) + FLUENT_OTEL_DEFINITION(FLUENT_OTEL_HAVE_LOGS) endif() @@ -99,15 +100,28 @@ if (FLUENT_PROTO_REGENERATE) message(STATUS "processing metrics.proto") set(proto_file "${OTEL_PROTO_DIR}/opentelemetry/proto/metrics/v1/metrics.proto") execute_process(COMMAND ${PROTOC_BIN} ${PROTOC_ARG_OUT} ${PROTOC_ARG_PATH} ${proto_file}) - include_directories(${PROJECT_BINARY_DIR}/opentelemetry/proto/metrics/v1/) message(STATUS "processing metrics_service.proto") set(proto_file "${OTEL_PROTO_DIR}/opentelemetry/proto/collector/metrics/v1/metrics_service.proto") execute_process(COMMAND ${PROTOC_BIN} ${PROTOC_ARG_OUT} ${PROTOC_ARG_PATH} ${proto_file}) - include_directories(${PROJECT_BINARY_DIR}/opentelemetry/proto/collector/logs/v1/) + + include_directories(${PROJECT_BINARY_DIR}/opentelemetry/proto/metrics/v1/) FLUENT_OTEL_DEFINITION(FLUENT_OTEL_HAVE_METRICS) endif() + if (FLUENT_PROTO_PROFILES) + message(STATUS "processing profiles.proto") + set(proto_file "${OTEL_PROTO_DIR}/opentelemetry/proto/profiles/v1development/profiles.proto") + execute_process(COMMAND ${PROTOC_BIN} ${PROTOC_ARG_OUT} ${PROTOC_ARG_PATH} ${proto_file}) + + message(STATUS "processing pprofextended.proto") + set(proto_file "${OTEL_PROTO_DIR}/opentelemetry/proto/profiles/v1development/pprofextended.proto") + execute_process(COMMAND ${PROTOC_BIN} ${PROTOC_ARG_OUT} ${PROTOC_ARG_PATH} ${proto_file}) + + include_directories(${PROJECT_BINARY_DIR}/opentelemetry/proto/profiles/v1development/) + FLUENT_OTEL_DEFINITION(FLUENT_OTEL_HAVE_PROFILES) + endif() + configure_file( "${PROJECT_SOURCE_DIR}/include/fluent-otel-proto/fluent-otel-info.h.in" "${PROJECT_SOURCE_DIR}/include/fluent-otel-proto/fluent-otel-info.h" diff --git a/lib/fluent-otel-proto/include/fluent-otel-proto/fluent-otel-info.h b/lib/fluent-otel-proto/include/fluent-otel-proto/fluent-otel-info.h index e8e158e900b..888253973ad 100644 --- a/lib/fluent-otel-proto/include/fluent-otel-proto/fluent-otel-info.h +++ b/lib/fluent-otel-proto/include/fluent-otel-proto/fluent-otel-info.h @@ -20,7 +20,7 @@ #ifndef FLUENT_OTEL_INFO_H #define FLUENT_OTEL_INFO_H -#define FLUENT_OTEL_SOURCE_DIR "/Users/edsiper/coding/fluent-otel-proto" +#define FLUENT_OTEL_SOURCE_DIR "/home/edsiper/c/fluent-otel-proto" /* General flags set by /CMakeLists.txt */ #ifndef FLUENT_OTEL_HAVE_COMMON @@ -35,12 +35,12 @@ #ifndef FLUENT_OTEL_HAVE_LOGS #define FLUENT_OTEL_HAVE_LOGS #endif -#ifndef FLUENT_OTEL_HAVE_LOGS -#define FLUENT_OTEL_HAVE_LOGS -#endif #ifndef FLUENT_OTEL_HAVE_METRICS #define FLUENT_OTEL_HAVE_METRICS #endif +#ifndef FLUENT_OTEL_HAVE_PROFILES +#define FLUENT_OTEL_HAVE_PROFILES +#endif #endif diff --git a/lib/fluent-otel-proto/include/fluent-otel-proto/fluent-otel_found.h b/lib/fluent-otel-proto/include/fluent-otel-proto/fluent-otel_found.h index 864ff4f2c62..6b2c1d03d1f 100644 --- a/lib/fluent-otel-proto/include/fluent-otel-proto/fluent-otel_found.h +++ b/lib/fluent-otel-proto/include/fluent-otel-proto/fluent-otel_found.h @@ -2,7 +2,7 @@ /* Fluent Bit * ========== - * Copyright (C) 2022 The Fluent Bit Authors + * Copyright (C) 2022-2024 The Fluent Bit Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/logs/v1/logs_service.pb-c.h b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/logs/v1/logs_service.pb-c.h index cdd346075f7..6779ccdf372 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/logs/v1/logs_service.pb-c.h +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/logs/v1/logs_service.pb-c.h @@ -10,7 +10,7 @@ PROTOBUF_C__BEGIN_DECLS #if PROTOBUF_C_VERSION_NUMBER < 1003000 # error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. -#elif 1004001 < PROTOBUF_C_MIN_COMPILER_VERSION +#elif 1005000 < PROTOBUF_C_MIN_COMPILER_VERSION # error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. #endif diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/metrics/v1/metrics_service.pb-c.h b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/metrics/v1/metrics_service.pb-c.h index 4b19ffc0568..d6a2b085d8e 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/metrics/v1/metrics_service.pb-c.h +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/metrics/v1/metrics_service.pb-c.h @@ -10,7 +10,7 @@ PROTOBUF_C__BEGIN_DECLS #if PROTOBUF_C_VERSION_NUMBER < 1003000 # error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. -#elif 1004001 < PROTOBUF_C_MIN_COMPILER_VERSION +#elif 1005000 < PROTOBUF_C_MIN_COMPILER_VERSION # error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. #endif diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/trace/v1/trace_service.pb-c.h b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/trace/v1/trace_service.pb-c.h index 35f5fdb18a5..094aed6f1b6 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/trace/v1/trace_service.pb-c.h +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/trace/v1/trace_service.pb-c.h @@ -10,7 +10,7 @@ PROTOBUF_C__BEGIN_DECLS #if PROTOBUF_C_VERSION_NUMBER < 1003000 # error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. -#elif 1004001 < PROTOBUF_C_MIN_COMPILER_VERSION +#elif 1005000 < PROTOBUF_C_MIN_COMPILER_VERSION # error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. #endif diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/common/v1/common.pb-c.c b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/common/v1/common.pb-c.c index 8937ccc2e50..5c5abd9f7d5 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/common/v1/common.pb-c.c +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/common/v1/common.pb-c.c @@ -243,7 +243,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__common__v1__any_valu offsetof(Opentelemetry__Proto__Common__V1__AnyValue, string_value), NULL, &protobuf_c_empty_string, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -255,7 +255,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__common__v1__any_valu offsetof(Opentelemetry__Proto__Common__V1__AnyValue, bool_value), NULL, NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -267,7 +267,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__common__v1__any_valu offsetof(Opentelemetry__Proto__Common__V1__AnyValue, int_value), NULL, NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -279,7 +279,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__common__v1__any_valu offsetof(Opentelemetry__Proto__Common__V1__AnyValue, double_value), NULL, NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -291,7 +291,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__common__v1__any_valu offsetof(Opentelemetry__Proto__Common__V1__AnyValue, array_value), &opentelemetry__proto__common__v1__array_value__descriptor, NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -303,7 +303,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__common__v1__any_valu offsetof(Opentelemetry__Proto__Common__V1__AnyValue, kvlist_value), &opentelemetry__proto__common__v1__key_value_list__descriptor, NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -315,7 +315,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__common__v1__any_valu offsetof(Opentelemetry__Proto__Common__V1__AnyValue, bytes_value), NULL, NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/common/v1/common.pb-c.h b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/common/v1/common.pb-c.h index d13169c2645..a8c52626cc9 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/common/v1/common.pb-c.h +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/common/v1/common.pb-c.h @@ -10,7 +10,7 @@ PROTOBUF_C__BEGIN_DECLS #if PROTOBUF_C_VERSION_NUMBER < 1003000 # error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. -#elif 1004001 < PROTOBUF_C_MIN_COMPILER_VERSION +#elif 1005000 < PROTOBUF_C_MIN_COMPILER_VERSION # error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. #endif @@ -132,6 +132,11 @@ struct Opentelemetry__Proto__Common__V1__InstrumentationScope */ char *name; char *version; + /* + * Additional attributes that describe the scope. [Optional]. + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). + */ size_t n_attributes; Opentelemetry__Proto__Common__V1__KeyValue **attributes; uint32_t dropped_attributes_count; diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/logs/v1/logs.pb-c.c b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/logs/v1/logs.pb-c.c index 124f766288e..9ecfa356ac3 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/logs/v1/logs.pb-c.c +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/logs/v1/logs.pb-c.c @@ -585,16 +585,16 @@ const ProtobufCEnumDescriptor opentelemetry__proto__logs__v1__severity_number__d }; static const ProtobufCEnumValue opentelemetry__proto__logs__v1__log_record_flags__enum_values_by_number[2] = { - { "LOG_RECORD_FLAG_UNSPECIFIED", "OPENTELEMETRY__PROTO__LOGS__V1__LOG_RECORD_FLAGS__LOG_RECORD_FLAG_UNSPECIFIED", 0 }, - { "LOG_RECORD_FLAG_TRACE_FLAGS_MASK", "OPENTELEMETRY__PROTO__LOGS__V1__LOG_RECORD_FLAGS__LOG_RECORD_FLAG_TRACE_FLAGS_MASK", 255 }, + { "LOG_RECORD_FLAGS_DO_NOT_USE", "OPENTELEMETRY__PROTO__LOGS__V1__LOG_RECORD_FLAGS__LOG_RECORD_FLAGS_DO_NOT_USE", 0 }, + { "LOG_RECORD_FLAGS_TRACE_FLAGS_MASK", "OPENTELEMETRY__PROTO__LOGS__V1__LOG_RECORD_FLAGS__LOG_RECORD_FLAGS_TRACE_FLAGS_MASK", 255 }, }; static const ProtobufCIntRange opentelemetry__proto__logs__v1__log_record_flags__value_ranges[] = { {0, 0},{255, 1},{0, 2} }; static const ProtobufCEnumValueIndex opentelemetry__proto__logs__v1__log_record_flags__enum_values_by_name[2] = { - { "LOG_RECORD_FLAG_TRACE_FLAGS_MASK", 1 }, - { "LOG_RECORD_FLAG_UNSPECIFIED", 0 }, + { "LOG_RECORD_FLAGS_DO_NOT_USE", 0 }, + { "LOG_RECORD_FLAGS_TRACE_FLAGS_MASK", 1 }, }; const ProtobufCEnumDescriptor opentelemetry__proto__logs__v1__log_record_flags__descriptor = { diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/logs/v1/logs.pb-c.h b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/logs/v1/logs.pb-c.h index 4dbaa1d3bf4..ea7f00fc125 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/logs/v1/logs.pb-c.h +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/logs/v1/logs.pb-c.h @@ -10,7 +10,7 @@ PROTOBUF_C__BEGIN_DECLS #if PROTOBUF_C_VERSION_NUMBER < 1003000 # error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. -#elif 1004001 < PROTOBUF_C_MIN_COMPILER_VERSION +#elif 1005000 < PROTOBUF_C_MIN_COMPILER_VERSION # error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. #endif @@ -60,11 +60,23 @@ typedef enum _Opentelemetry__Proto__Logs__V1__SeverityNumber { PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(OPENTELEMETRY__PROTO__LOGS__V1__SEVERITY_NUMBER) } Opentelemetry__Proto__Logs__V1__SeverityNumber; /* - * Masks for LogRecord.flags field. + * LogRecordFlags represents constants used to interpret the + * LogRecord.flags field, which is protobuf 'fixed32' type and is to + * be used as bit-fields. Each non-zero value defined in this enum is + * a bit-mask. To extract the bit-field, for example, use an + * expression like: + * (logRecord.flags & LOG_RECORD_FLAGS_TRACE_FLAGS_MASK) */ typedef enum _Opentelemetry__Proto__Logs__V1__LogRecordFlags { - OPENTELEMETRY__PROTO__LOGS__V1__LOG_RECORD_FLAGS__LOG_RECORD_FLAG_UNSPECIFIED = 0, - OPENTELEMETRY__PROTO__LOGS__V1__LOG_RECORD_FLAGS__LOG_RECORD_FLAG_TRACE_FLAGS_MASK = 255 + /* + * The zero value for the enum. Should not be used for comparisons. + * Instead use bitwise "and" with the appropriate mask as shown above. + */ + OPENTELEMETRY__PROTO__LOGS__V1__LOG_RECORD_FLAGS__LOG_RECORD_FLAGS_DO_NOT_USE = 0, + /* + * Bits 0-7 are used for trace flags. + */ + OPENTELEMETRY__PROTO__LOGS__V1__LOG_RECORD_FLAGS__LOG_RECORD_FLAGS_TRACE_FLAGS_MASK = 255 PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(OPENTELEMETRY__PROTO__LOGS__V1__LOG_RECORD_FLAGS) } Opentelemetry__Proto__Logs__V1__LogRecordFlags; @@ -115,6 +127,9 @@ struct Opentelemetry__Proto__Logs__V1__ResourceLogs size_t n_scope_logs; Opentelemetry__Proto__Logs__V1__ScopeLogs **scope_logs; /* + * The Schema URL, if known. This is the identifier of the Schema that the resource data + * is recorded in. To learn more about Schema URL see + * https://opentelemetry.io/docs/specs/otel/schemas/#schema-url * This schema_url applies to the data in the "resource" field. It does not apply * to the data in the "scope_logs" field which have their own schema_url field. */ @@ -143,6 +158,9 @@ struct Opentelemetry__Proto__Logs__V1__ScopeLogs size_t n_log_records; Opentelemetry__Proto__Logs__V1__LogRecord **log_records; /* + * The Schema URL, if known. This is the identifier of the Schema that the log data + * is recorded in. To learn more about Schema URL see + * https://opentelemetry.io/docs/specs/otel/schemas/#schema-url * This schema_url applies to all logs in the "logs" field. */ char *schema_url; @@ -210,21 +228,32 @@ struct Opentelemetry__Proto__Logs__V1__LogRecord * defined in W3C Trace Context specification. 24 most significant bits are reserved * and must be set to 0. Readers must not assume that 24 most significant bits * will be zero and must correctly mask the bits when reading 8-bit trace flag (use - * flags & TRACE_FLAGS_MASK). [Optional]. + * flags & LOG_RECORD_FLAGS_TRACE_FLAGS_MASK). [Optional]. */ uint32_t flags; /* * A unique identifier for a trace. All logs from the same trace share - * the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes - * is considered invalid. Can be set for logs that are part of request processing - * and have an assigned trace id. [Optional]. + * the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes OR + * of length other than 16 bytes is considered invalid (empty string in OTLP/JSON + * is zero-length and thus is also invalid). + * This field is optional. + * The receivers SHOULD assume that the log record is not associated with a + * trace if any of the following is true: + * - the field is not present, + * - the field contains an invalid value. */ ProtobufCBinaryData trace_id; /* * A unique identifier for a span within a trace, assigned when the span - * is created. The ID is an 8-byte array. An ID with all zeroes is considered - * invalid. Can be set for logs that are part of a particular processing span. - * If span_id is present trace_id SHOULD be also present. [Optional]. + * is created. The ID is an 8-byte array. An ID with all zeroes OR of length + * other than 8 bytes is considered invalid (empty string in OTLP/JSON + * is zero-length and thus is also invalid). + * This field is optional. If the sender specifies a valid span_id then it SHOULD also + * specify a valid trace_id. + * The receivers SHOULD assume that the log record is not associated with a + * span if any of the following is true: + * - the field is not present, + * - the field contains an invalid value. */ ProtobufCBinaryData span_id; }; diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/metrics/v1/metrics.pb-c.c b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/metrics/v1/metrics.pb-c.c index eb660b78dfa..31671477da8 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/metrics/v1/metrics.pb-c.c +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/metrics/v1/metrics.pb-c.c @@ -815,7 +815,7 @@ const ProtobufCMessageDescriptor opentelemetry__proto__metrics__v1__scope_metric (ProtobufCMessageInit) opentelemetry__proto__metrics__v1__scope_metrics__init, NULL,NULL,NULL /* reserved[123] */ }; -static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__metric__field_descriptors[8] = +static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__metric__field_descriptors[9] = { { "name", @@ -862,7 +862,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__metric_ offsetof(Opentelemetry__Proto__Metrics__V1__Metric, gauge), &opentelemetry__proto__metrics__v1__gauge__descriptor, NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -874,7 +874,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__metric_ offsetof(Opentelemetry__Proto__Metrics__V1__Metric, sum), &opentelemetry__proto__metrics__v1__sum__descriptor, NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -886,7 +886,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__metric_ offsetof(Opentelemetry__Proto__Metrics__V1__Metric, histogram), &opentelemetry__proto__metrics__v1__histogram__descriptor, NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -898,7 +898,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__metric_ offsetof(Opentelemetry__Proto__Metrics__V1__Metric, exponential_histogram), &opentelemetry__proto__metrics__v1__exponential_histogram__descriptor, NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -910,7 +910,19 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__metric_ offsetof(Opentelemetry__Proto__Metrics__V1__Metric, summary), &opentelemetry__proto__metrics__v1__summary__descriptor, NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "metadata", + 12, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(Opentelemetry__Proto__Metrics__V1__Metric, n_metadata), + offsetof(Opentelemetry__Proto__Metrics__V1__Metric, metadata), + &opentelemetry__proto__common__v1__key_value__descriptor, + NULL, + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -919,6 +931,7 @@ static const unsigned opentelemetry__proto__metrics__v1__metric__field_indices_b 6, /* field[6] = exponential_histogram */ 3, /* field[3] = gauge */ 5, /* field[5] = histogram */ + 8, /* field[8] = metadata */ 0, /* field[0] = name */ 4, /* field[4] = sum */ 7, /* field[7] = summary */ @@ -930,7 +943,7 @@ static const ProtobufCIntRange opentelemetry__proto__metrics__v1__metric__number { 5, 3 }, { 7, 4 }, { 9, 5 }, - { 0, 8 } + { 0, 9 } }; const ProtobufCMessageDescriptor opentelemetry__proto__metrics__v1__metric__descriptor = { @@ -940,7 +953,7 @@ const ProtobufCMessageDescriptor opentelemetry__proto__metrics__v1__metric__desc "Opentelemetry__Proto__Metrics__V1__Metric", "opentelemetry.proto.metrics.v1", sizeof(Opentelemetry__Proto__Metrics__V1__Metric), - 8, + 9, opentelemetry__proto__metrics__v1__metric__field_descriptors, opentelemetry__proto__metrics__v1__metric__field_indices_by_name, 4, opentelemetry__proto__metrics__v1__metric__number_ranges, @@ -1224,7 +1237,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__number_ offsetof(Opentelemetry__Proto__Metrics__V1__NumberDataPoint, as_double), NULL, NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1248,7 +1261,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__number_ offsetof(Opentelemetry__Proto__Metrics__V1__NumberDataPoint, as_int), NULL, NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1348,11 +1361,11 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__histogr 5, PROTOBUF_C_LABEL_NONE, PROTOBUF_C_TYPE_DOUBLE, - 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Metrics__V1__HistogramDataPoint, _sum_case), offsetof(Opentelemetry__Proto__Metrics__V1__HistogramDataPoint, sum), NULL, NULL, - 0, /* flags */ + PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1364,7 +1377,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__histogr offsetof(Opentelemetry__Proto__Metrics__V1__HistogramDataPoint, bucket_counts), NULL, NULL, - 0 | PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ + PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1376,7 +1389,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__histogr offsetof(Opentelemetry__Proto__Metrics__V1__HistogramDataPoint, explicit_bounds), NULL, NULL, - 0 | PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ + PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1420,11 +1433,11 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__histogr 11, PROTOBUF_C_LABEL_NONE, PROTOBUF_C_TYPE_DOUBLE, - 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Metrics__V1__HistogramDataPoint, _min_case), offsetof(Opentelemetry__Proto__Metrics__V1__HistogramDataPoint, min), NULL, NULL, - 0, /* flags */ + PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1432,11 +1445,11 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__histogr 12, PROTOBUF_C_LABEL_NONE, PROTOBUF_C_TYPE_DOUBLE, - 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Metrics__V1__HistogramDataPoint, _max_case), offsetof(Opentelemetry__Proto__Metrics__V1__HistogramDataPoint, max), NULL, NULL, - 0, /* flags */ + PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -1496,7 +1509,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__exponen offsetof(Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint__Buckets, bucket_counts), NULL, NULL, - 0 | PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ + PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -1524,7 +1537,7 @@ const ProtobufCMessageDescriptor opentelemetry__proto__metrics__v1__exponential_ (ProtobufCMessageInit) opentelemetry__proto__metrics__v1__exponential_histogram_data_point__buckets__init, NULL,NULL,NULL /* reserved[123] */ }; -static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__exponential_histogram_data_point__field_descriptors[13] = +static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__exponential_histogram_data_point__field_descriptors[14] = { { "attributes", @@ -1579,11 +1592,11 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__exponen 5, PROTOBUF_C_LABEL_NONE, PROTOBUF_C_TYPE_DOUBLE, - 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint, _sum_case), offsetof(Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint, sum), NULL, NULL, - 0, /* flags */ + PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1663,11 +1676,11 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__exponen 12, PROTOBUF_C_LABEL_NONE, PROTOBUF_C_TYPE_DOUBLE, - 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint, _min_case), offsetof(Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint, min), NULL, NULL, - 0, /* flags */ + PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1675,10 +1688,22 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__exponen 13, PROTOBUF_C_LABEL_NONE, PROTOBUF_C_TYPE_DOUBLE, - 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint, _max_case), offsetof(Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint, max), NULL, NULL, + PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "zero_threshold", + 14, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_DOUBLE, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint, zero_threshold), + NULL, + NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, @@ -1697,11 +1722,12 @@ static const unsigned opentelemetry__proto__metrics__v1__exponential_histogram_d 4, /* field[4] = sum */ 2, /* field[2] = time_unix_nano */ 6, /* field[6] = zero_count */ + 13, /* field[13] = zero_threshold */ }; static const ProtobufCIntRange opentelemetry__proto__metrics__v1__exponential_histogram_data_point__number_ranges[1 + 1] = { { 1, 0 }, - { 0, 13 } + { 0, 14 } }; const ProtobufCMessageDescriptor opentelemetry__proto__metrics__v1__exponential_histogram_data_point__descriptor = { @@ -1711,7 +1737,7 @@ const ProtobufCMessageDescriptor opentelemetry__proto__metrics__v1__exponential_ "Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint", "opentelemetry.proto.metrics.v1", sizeof(Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint), - 13, + 14, opentelemetry__proto__metrics__v1__exponential_histogram_data_point__field_descriptors, opentelemetry__proto__metrics__v1__exponential_histogram_data_point__field_indices_by_name, 1, opentelemetry__proto__metrics__v1__exponential_histogram_data_point__number_ranges, @@ -1908,7 +1934,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__exempla offsetof(Opentelemetry__Proto__Metrics__V1__Exemplar, as_double), NULL, NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1944,7 +1970,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__exempla offsetof(Opentelemetry__Proto__Metrics__V1__Exemplar, as_int), NULL, NULL, - 0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2020,16 +2046,16 @@ const ProtobufCEnumDescriptor opentelemetry__proto__metrics__v1__aggregation_tem }; static const ProtobufCEnumValue opentelemetry__proto__metrics__v1__data_point_flags__enum_values_by_number[2] = { - { "FLAG_NONE", "OPENTELEMETRY__PROTO__METRICS__V1__DATA_POINT_FLAGS__FLAG_NONE", 0 }, - { "FLAG_NO_RECORDED_VALUE", "OPENTELEMETRY__PROTO__METRICS__V1__DATA_POINT_FLAGS__FLAG_NO_RECORDED_VALUE", 1 }, + { "DATA_POINT_FLAGS_DO_NOT_USE", "OPENTELEMETRY__PROTO__METRICS__V1__DATA_POINT_FLAGS__DATA_POINT_FLAGS_DO_NOT_USE", 0 }, + { "DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK", "OPENTELEMETRY__PROTO__METRICS__V1__DATA_POINT_FLAGS__DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK", 1 }, }; static const ProtobufCIntRange opentelemetry__proto__metrics__v1__data_point_flags__value_ranges[] = { {0, 0},{0, 2} }; static const ProtobufCEnumValueIndex opentelemetry__proto__metrics__v1__data_point_flags__enum_values_by_name[2] = { - { "FLAG_NONE", 0 }, - { "FLAG_NO_RECORDED_VALUE", 1 }, + { "DATA_POINT_FLAGS_DO_NOT_USE", 0 }, + { "DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK", 1 }, }; const ProtobufCEnumDescriptor opentelemetry__proto__metrics__v1__data_point_flags__descriptor = { diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/metrics/v1/metrics.pb-c.h b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/metrics/v1/metrics.pb-c.h index 938147690a8..48a96611546 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/metrics/v1/metrics.pb-c.h +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/metrics/v1/metrics.pb-c.h @@ -10,7 +10,7 @@ PROTOBUF_C__BEGIN_DECLS #if PROTOBUF_C_VERSION_NUMBER < 1003000 # error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. -#elif 1004001 < PROTOBUF_C_MIN_COMPILER_VERSION +#elif 1005000 < PROTOBUF_C_MIN_COMPILER_VERSION # error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. #endif @@ -113,16 +113,20 @@ typedef enum _Opentelemetry__Proto__Metrics__V1__AggregationTemporality { * bit-field representing 32 distinct boolean flags. Each flag defined in this * enum is a bit-mask. To test the presence of a single flag in the flags of * a data point, for example, use an expression like: - * (point.flags & FLAG_NO_RECORDED_VALUE) == FLAG_NO_RECORDED_VALUE + * (point.flags & DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK) == DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK */ typedef enum _Opentelemetry__Proto__Metrics__V1__DataPointFlags { - OPENTELEMETRY__PROTO__METRICS__V1__DATA_POINT_FLAGS__FLAG_NONE = 0, + /* + * The zero value for the enum. Should not be used for comparisons. + * Instead use bitwise "and" with the appropriate mask as shown above. + */ + OPENTELEMETRY__PROTO__METRICS__V1__DATA_POINT_FLAGS__DATA_POINT_FLAGS_DO_NOT_USE = 0, /* * This DataPoint is valid but has no recorded value. This value * SHOULD be used to reflect explicitly missing data in a series, as * for an equivalent to the Prometheus "staleness marker". */ - OPENTELEMETRY__PROTO__METRICS__V1__DATA_POINT_FLAGS__FLAG_NO_RECORDED_VALUE = 1 + OPENTELEMETRY__PROTO__METRICS__V1__DATA_POINT_FLAGS__DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK = 1 PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(OPENTELEMETRY__PROTO__METRICS__V1__DATA_POINT_FLAGS) } Opentelemetry__Proto__Metrics__V1__DataPointFlags; @@ -132,6 +136,23 @@ typedef enum _Opentelemetry__Proto__Metrics__V1__DataPointFlags { * MetricsData represents the metrics data that can be stored in a persistent * storage, OR can be embedded by other protocols that transfer OTLP metrics * data but do not implement the OTLP protocol. + * MetricsData + * └─── ResourceMetrics + * ├── Resource + * ├── SchemaURL + * └── ScopeMetrics + * ├── Scope + * ├── SchemaURL + * └── Metric + * ├── Name + * ├── Description + * ├── Unit + * └── data + * ├── Gauge + * ├── Sum + * ├── Histogram + * ├── ExponentialHistogram + * └── Summary * The main difference between this message and collector protocol is that * in this message there will not be any "control" or "metadata" specific to * OTLP protocol. @@ -173,6 +194,9 @@ struct Opentelemetry__Proto__Metrics__V1__ResourceMetrics size_t n_scope_metrics; Opentelemetry__Proto__Metrics__V1__ScopeMetrics **scope_metrics; /* + * The Schema URL, if known. This is the identifier of the Schema that the resource data + * is recorded in. To learn more about Schema URL see + * https://opentelemetry.io/docs/specs/otel/schemas/#schema-url * This schema_url applies to the data in the "resource" field. It does not apply * to the data in the "scope_metrics" field which have their own schema_url field. */ @@ -201,6 +225,9 @@ struct Opentelemetry__Proto__Metrics__V1__ScopeMetrics size_t n_metrics; Opentelemetry__Proto__Metrics__V1__Metric **metrics; /* + * The Schema URL, if known. This is the identifier of the Schema that the metric data + * is recorded in. To learn more about Schema URL see + * https://opentelemetry.io/docs/specs/otel/schemas/#schema-url * This schema_url applies to all metrics in the "metrics" field. */ char *schema_url; @@ -233,7 +260,7 @@ typedef enum { * - Data is one of the possible types (Sum, Gauge, Histogram, Summary). * - DataPoint contains timestamps, attributes, and one of the possible value type * fields. - * Metric + * Metric * +------------+ * |name | * |description | @@ -297,7 +324,7 @@ struct Opentelemetry__Proto__Metrics__V1__Metric { ProtobufCMessage base; /* - * name of the metric, including its DNS name prefix. It must be unique. + * name of the metric. */ char *name; /* @@ -309,6 +336,17 @@ struct Opentelemetry__Proto__Metrics__V1__Metric * described by http://unitsofmeasure.org/ucum.html. */ char *unit; + /* + * Additional metadata attributes that describe the metric. [Optional]. + * Attributes are non-identifying. + * Consumers SHOULD NOT need to be aware of these attributes. + * These attributes MAY be used to encode information allowing + * for lossless roundtrip translation to / from another data model. + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). + */ + size_t n_metadata; + Opentelemetry__Proto__Common__V1__KeyValue **metadata; Opentelemetry__Proto__Metrics__V1__Metric__DataCase data_case; union { Opentelemetry__Proto__Metrics__V1__Gauge *gauge; @@ -320,7 +358,7 @@ struct Opentelemetry__Proto__Metrics__V1__Metric }; #define OPENTELEMETRY__PROTO__METRICS__V1__METRIC__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__metrics__v1__metric__descriptor) \ - , (char *)protobuf_c_empty_string, (char *)protobuf_c_empty_string, (char *)protobuf_c_empty_string, OPENTELEMETRY__PROTO__METRICS__V1__METRIC__DATA__NOT_SET, {0} } + , (char *)protobuf_c_empty_string, (char *)protobuf_c_empty_string, (char *)protobuf_c_empty_string, 0,NULL, OPENTELEMETRY__PROTO__METRICS__V1__METRIC__DATA__NOT_SET, {0} } /* @@ -484,6 +522,24 @@ struct Opentelemetry__Proto__Metrics__V1__NumberDataPoint , 0,NULL, 0, 0, 0,NULL, 0, OPENTELEMETRY__PROTO__METRICS__V1__NUMBER_DATA_POINT__VALUE__NOT_SET, {0} } +typedef enum { + OPENTELEMETRY__PROTO__METRICS__V1__HISTOGRAM_DATA_POINT___SUM__NOT_SET = 0, + OPENTELEMETRY__PROTO__METRICS__V1__HISTOGRAM_DATA_POINT___SUM_SUM = 5 + PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(OPENTELEMETRY__PROTO__METRICS__V1__HISTOGRAM_DATA_POINT___SUM__CASE) +} Opentelemetry__Proto__Metrics__V1__HistogramDataPoint__SumCase; + +typedef enum { + OPENTELEMETRY__PROTO__METRICS__V1__HISTOGRAM_DATA_POINT___MIN__NOT_SET = 0, + OPENTELEMETRY__PROTO__METRICS__V1__HISTOGRAM_DATA_POINT___MIN_MIN = 11 + PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(OPENTELEMETRY__PROTO__METRICS__V1__HISTOGRAM_DATA_POINT___MIN__CASE) +} Opentelemetry__Proto__Metrics__V1__HistogramDataPoint__MinCase; + +typedef enum { + OPENTELEMETRY__PROTO__METRICS__V1__HISTOGRAM_DATA_POINT___MAX__NOT_SET = 0, + OPENTELEMETRY__PROTO__METRICS__V1__HISTOGRAM_DATA_POINT___MAX_MAX = 12 + PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(OPENTELEMETRY__PROTO__METRICS__V1__HISTOGRAM_DATA_POINT___MAX__CASE) +} Opentelemetry__Proto__Metrics__V1__HistogramDataPoint__MaxCase; + /* * HistogramDataPoint is a single data point in a timeseries that describes the * time-varying values of a Histogram. A Histogram contains summary statistics @@ -525,16 +581,6 @@ struct Opentelemetry__Proto__Metrics__V1__HistogramDataPoint * histogram is provided. */ uint64_t count; - /* - * sum of the values in the population. If count is zero then this field - * must be zero. - * Note: Sum should only be filled out when measuring non-negative discrete - * events, and is assumed to be monotonic over the values of these events. - * Negative events *can* be recorded, but sum should not be filled out when - * doing so. This is specifically to enforce compatibility w/ OpenMetrics, - * see: https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#histogram - */ - double sum; /* * bucket_counts is an optional field contains the count values of histogram * for each bucket. @@ -568,18 +614,37 @@ struct Opentelemetry__Proto__Metrics__V1__HistogramDataPoint * for the available flags and their meaning. */ uint32_t flags; - /* - * min is the minimum value over (start_time, end_time]. - */ - double min; - /* - * max is the maximum value over (start_time, end_time]. - */ - double max; + Opentelemetry__Proto__Metrics__V1__HistogramDataPoint__SumCase _sum_case; + union { + /* + * sum of the values in the population. If count is zero then this field + * must be zero. + * Note: Sum should only be filled out when measuring non-negative discrete + * events, and is assumed to be monotonic over the values of these events. + * Negative events *can* be recorded, but sum should not be filled out when + * doing so. This is specifically to enforce compatibility w/ OpenMetrics, + * see: https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#histogram + */ + double sum; + }; + Opentelemetry__Proto__Metrics__V1__HistogramDataPoint__MinCase _min_case; + union { + /* + * min is the minimum value over (start_time, end_time]. + */ + double min; + }; + Opentelemetry__Proto__Metrics__V1__HistogramDataPoint__MaxCase _max_case; + union { + /* + * max is the maximum value over (start_time, end_time]. + */ + double max; + }; }; #define OPENTELEMETRY__PROTO__METRICS__V1__HISTOGRAM_DATA_POINT__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__metrics__v1__histogram_data_point__descriptor) \ - , 0,NULL, 0, 0, 0, 0, 0,NULL, 0,NULL, 0,NULL, 0, 0, 0 } + , 0,NULL, 0, 0, 0, 0,NULL, 0,NULL, 0,NULL, 0, OPENTELEMETRY__PROTO__METRICS__V1__HISTOGRAM_DATA_POINT___SUM__NOT_SET, {0}, OPENTELEMETRY__PROTO__METRICS__V1__HISTOGRAM_DATA_POINT___MIN__NOT_SET, {0}, OPENTELEMETRY__PROTO__METRICS__V1__HISTOGRAM_DATA_POINT___MAX__NOT_SET, {0} } /* @@ -596,9 +661,9 @@ struct Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint__Bucket */ int32_t offset; /* - * Count is an array of counts, where count[i] carries the count - * of the bucket at index (offset+i). count[i] is the count of - * values greater than base^(offset+i) and less or equal to than + * bucket_counts is an array of count values, where bucket_counts[i] carries + * the count of the bucket at index (offset+i). bucket_counts[i] is the count + * of values greater than base^(offset+i) and less than or equal to * base^(offset+i+1). * Note: By contrast, the explicit HistogramDataPoint uses * fixed64. This field is expected to have many buckets, @@ -613,6 +678,24 @@ struct Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint__Bucket , 0, 0,NULL } +typedef enum { + OPENTELEMETRY__PROTO__METRICS__V1__EXPONENTIAL_HISTOGRAM_DATA_POINT___SUM__NOT_SET = 0, + OPENTELEMETRY__PROTO__METRICS__V1__EXPONENTIAL_HISTOGRAM_DATA_POINT___SUM_SUM = 5 + PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(OPENTELEMETRY__PROTO__METRICS__V1__EXPONENTIAL_HISTOGRAM_DATA_POINT___SUM__CASE) +} Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint__SumCase; + +typedef enum { + OPENTELEMETRY__PROTO__METRICS__V1__EXPONENTIAL_HISTOGRAM_DATA_POINT___MIN__NOT_SET = 0, + OPENTELEMETRY__PROTO__METRICS__V1__EXPONENTIAL_HISTOGRAM_DATA_POINT___MIN_MIN = 12 + PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(OPENTELEMETRY__PROTO__METRICS__V1__EXPONENTIAL_HISTOGRAM_DATA_POINT___MIN__CASE) +} Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint__MinCase; + +typedef enum { + OPENTELEMETRY__PROTO__METRICS__V1__EXPONENTIAL_HISTOGRAM_DATA_POINT___MAX__NOT_SET = 0, + OPENTELEMETRY__PROTO__METRICS__V1__EXPONENTIAL_HISTOGRAM_DATA_POINT___MAX_MAX = 13 + PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(OPENTELEMETRY__PROTO__METRICS__V1__EXPONENTIAL_HISTOGRAM_DATA_POINT___MAX__CASE) +} Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint__MaxCase; + /* * ExponentialHistogramDataPoint is a single data point in a timeseries that describes the * time-varying values of a ExponentialHistogram of double values. A ExponentialHistogram contains @@ -649,16 +732,6 @@ struct Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint * values in the positive and negative Buckets plus the "zero_count" field. */ uint64_t count; - /* - * sum of the values in the population. If count is zero then this field - * must be zero. - * Note: Sum should only be filled out when measuring non-negative discrete - * events, and is assumed to be monotonic over the values of these events. - * Negative events *can* be recorded, but sum should not be filled out when - * doing so. This is specifically to enforce compatibility w/ OpenMetrics, - * see: https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#histogram - */ - double sum; /* * scale describes the resolution of the histogram. Boundaries are * located at powers of the base, where: @@ -703,17 +776,45 @@ struct Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint size_t n_exemplars; Opentelemetry__Proto__Metrics__V1__Exemplar **exemplars; /* - * min is the minimum value over (start_time, end_time]. - */ - double min; - /* - * max is the maximum value over (start_time, end_time]. + * ZeroThreshold may be optionally set to convey the width of the zero + * region. Where the zero region is defined as the closed interval + * [-ZeroThreshold, ZeroThreshold]. + * When ZeroThreshold is 0, zero count bucket stores values that cannot be + * expressed using the standard exponential formula as well as values that + * have been rounded to zero. */ - double max; + double zero_threshold; + Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint__SumCase _sum_case; + union { + /* + * sum of the values in the population. If count is zero then this field + * must be zero. + * Note: Sum should only be filled out when measuring non-negative discrete + * events, and is assumed to be monotonic over the values of these events. + * Negative events *can* be recorded, but sum should not be filled out when + * doing so. This is specifically to enforce compatibility w/ OpenMetrics, + * see: https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#histogram + */ + double sum; + }; + Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint__MinCase _min_case; + union { + /* + * min is the minimum value over (start_time, end_time]. + */ + double min; + }; + Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint__MaxCase _max_case; + union { + /* + * max is the maximum value over (start_time, end_time]. + */ + double max; + }; }; #define OPENTELEMETRY__PROTO__METRICS__V1__EXPONENTIAL_HISTOGRAM_DATA_POINT__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__metrics__v1__exponential_histogram_data_point__descriptor) \ - , 0,NULL, 0, 0, 0, 0, 0, 0, NULL, NULL, 0, 0,NULL, 0, 0 } + , 0,NULL, 0, 0, 0, 0, 0, NULL, NULL, 0, 0,NULL, 0, OPENTELEMETRY__PROTO__METRICS__V1__EXPONENTIAL_HISTOGRAM_DATA_POINT___SUM__NOT_SET, {0}, OPENTELEMETRY__PROTO__METRICS__V1__EXPONENTIAL_HISTOGRAM_DATA_POINT___MIN__NOT_SET, {0}, OPENTELEMETRY__PROTO__METRICS__V1__EXPONENTIAL_HISTOGRAM_DATA_POINT___MAX__NOT_SET, {0} } /* diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/profiles/v1development/pprofextended.pb-c.c b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/profiles/v1development/pprofextended.pb-c.c new file mode 100644 index 00000000000..2d8fa3e10a2 --- /dev/null +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/profiles/v1development/pprofextended.pb-c.c @@ -0,0 +1,1525 @@ +/* Generated by the protocol buffer compiler. DO NOT EDIT! */ +/* Generated from: opentelemetry/proto/profiles/v1development/pprofextended.proto */ + +/* Do not generate deprecated warnings for self */ +#ifndef PROTOBUF_C__NO_DEPRECATED +#define PROTOBUF_C__NO_DEPRECATED +#endif + +#include "opentelemetry/proto/profiles/v1development/pprofextended.pb-c.h" +void opentelemetry__proto__profiles__v1development__profile__init + (Opentelemetry__Proto__Profiles__V1development__Profile *message) +{ + static const Opentelemetry__Proto__Profiles__V1development__Profile init_value = OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__PROFILE__INIT; + *message = init_value; +} +size_t opentelemetry__proto__profiles__v1development__profile__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Profile *message) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__profile__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t opentelemetry__proto__profiles__v1development__profile__pack + (const Opentelemetry__Proto__Profiles__V1development__Profile *message, + uint8_t *out) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__profile__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t opentelemetry__proto__profiles__v1development__profile__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Profile *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__profile__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +Opentelemetry__Proto__Profiles__V1development__Profile * + opentelemetry__proto__profiles__v1development__profile__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (Opentelemetry__Proto__Profiles__V1development__Profile *) + protobuf_c_message_unpack (&opentelemetry__proto__profiles__v1development__profile__descriptor, + allocator, len, data); +} +void opentelemetry__proto__profiles__v1development__profile__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Profile *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__profile__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void opentelemetry__proto__profiles__v1development__attribute_unit__init + (Opentelemetry__Proto__Profiles__V1development__AttributeUnit *message) +{ + static const Opentelemetry__Proto__Profiles__V1development__AttributeUnit init_value = OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__ATTRIBUTE_UNIT__INIT; + *message = init_value; +} +size_t opentelemetry__proto__profiles__v1development__attribute_unit__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__AttributeUnit *message) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__attribute_unit__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t opentelemetry__proto__profiles__v1development__attribute_unit__pack + (const Opentelemetry__Proto__Profiles__V1development__AttributeUnit *message, + uint8_t *out) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__attribute_unit__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t opentelemetry__proto__profiles__v1development__attribute_unit__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__AttributeUnit *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__attribute_unit__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +Opentelemetry__Proto__Profiles__V1development__AttributeUnit * + opentelemetry__proto__profiles__v1development__attribute_unit__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (Opentelemetry__Proto__Profiles__V1development__AttributeUnit *) + protobuf_c_message_unpack (&opentelemetry__proto__profiles__v1development__attribute_unit__descriptor, + allocator, len, data); +} +void opentelemetry__proto__profiles__v1development__attribute_unit__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__AttributeUnit *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__attribute_unit__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void opentelemetry__proto__profiles__v1development__link__init + (Opentelemetry__Proto__Profiles__V1development__Link *message) +{ + static const Opentelemetry__Proto__Profiles__V1development__Link init_value = OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__LINK__INIT; + *message = init_value; +} +size_t opentelemetry__proto__profiles__v1development__link__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Link *message) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__link__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t opentelemetry__proto__profiles__v1development__link__pack + (const Opentelemetry__Proto__Profiles__V1development__Link *message, + uint8_t *out) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__link__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t opentelemetry__proto__profiles__v1development__link__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Link *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__link__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +Opentelemetry__Proto__Profiles__V1development__Link * + opentelemetry__proto__profiles__v1development__link__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (Opentelemetry__Proto__Profiles__V1development__Link *) + protobuf_c_message_unpack (&opentelemetry__proto__profiles__v1development__link__descriptor, + allocator, len, data); +} +void opentelemetry__proto__profiles__v1development__link__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Link *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__link__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void opentelemetry__proto__profiles__v1development__value_type__init + (Opentelemetry__Proto__Profiles__V1development__ValueType *message) +{ + static const Opentelemetry__Proto__Profiles__V1development__ValueType init_value = OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__VALUE_TYPE__INIT; + *message = init_value; +} +size_t opentelemetry__proto__profiles__v1development__value_type__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__ValueType *message) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__value_type__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t opentelemetry__proto__profiles__v1development__value_type__pack + (const Opentelemetry__Proto__Profiles__V1development__ValueType *message, + uint8_t *out) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__value_type__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t opentelemetry__proto__profiles__v1development__value_type__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__ValueType *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__value_type__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +Opentelemetry__Proto__Profiles__V1development__ValueType * + opentelemetry__proto__profiles__v1development__value_type__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (Opentelemetry__Proto__Profiles__V1development__ValueType *) + protobuf_c_message_unpack (&opentelemetry__proto__profiles__v1development__value_type__descriptor, + allocator, len, data); +} +void opentelemetry__proto__profiles__v1development__value_type__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__ValueType *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__value_type__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void opentelemetry__proto__profiles__v1development__sample__init + (Opentelemetry__Proto__Profiles__V1development__Sample *message) +{ + static const Opentelemetry__Proto__Profiles__V1development__Sample init_value = OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__SAMPLE__INIT; + *message = init_value; +} +size_t opentelemetry__proto__profiles__v1development__sample__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Sample *message) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__sample__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t opentelemetry__proto__profiles__v1development__sample__pack + (const Opentelemetry__Proto__Profiles__V1development__Sample *message, + uint8_t *out) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__sample__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t opentelemetry__proto__profiles__v1development__sample__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Sample *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__sample__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +Opentelemetry__Proto__Profiles__V1development__Sample * + opentelemetry__proto__profiles__v1development__sample__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (Opentelemetry__Proto__Profiles__V1development__Sample *) + protobuf_c_message_unpack (&opentelemetry__proto__profiles__v1development__sample__descriptor, + allocator, len, data); +} +void opentelemetry__proto__profiles__v1development__sample__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Sample *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__sample__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void opentelemetry__proto__profiles__v1development__label__init + (Opentelemetry__Proto__Profiles__V1development__Label *message) +{ + static const Opentelemetry__Proto__Profiles__V1development__Label init_value = OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__LABEL__INIT; + *message = init_value; +} +size_t opentelemetry__proto__profiles__v1development__label__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Label *message) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__label__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t opentelemetry__proto__profiles__v1development__label__pack + (const Opentelemetry__Proto__Profiles__V1development__Label *message, + uint8_t *out) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__label__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t opentelemetry__proto__profiles__v1development__label__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Label *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__label__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +Opentelemetry__Proto__Profiles__V1development__Label * + opentelemetry__proto__profiles__v1development__label__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (Opentelemetry__Proto__Profiles__V1development__Label *) + protobuf_c_message_unpack (&opentelemetry__proto__profiles__v1development__label__descriptor, + allocator, len, data); +} +void opentelemetry__proto__profiles__v1development__label__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Label *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__label__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void opentelemetry__proto__profiles__v1development__mapping__init + (Opentelemetry__Proto__Profiles__V1development__Mapping *message) +{ + static const Opentelemetry__Proto__Profiles__V1development__Mapping init_value = OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__MAPPING__INIT; + *message = init_value; +} +size_t opentelemetry__proto__profiles__v1development__mapping__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Mapping *message) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__mapping__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t opentelemetry__proto__profiles__v1development__mapping__pack + (const Opentelemetry__Proto__Profiles__V1development__Mapping *message, + uint8_t *out) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__mapping__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t opentelemetry__proto__profiles__v1development__mapping__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Mapping *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__mapping__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +Opentelemetry__Proto__Profiles__V1development__Mapping * + opentelemetry__proto__profiles__v1development__mapping__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (Opentelemetry__Proto__Profiles__V1development__Mapping *) + protobuf_c_message_unpack (&opentelemetry__proto__profiles__v1development__mapping__descriptor, + allocator, len, data); +} +void opentelemetry__proto__profiles__v1development__mapping__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Mapping *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__mapping__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void opentelemetry__proto__profiles__v1development__location__init + (Opentelemetry__Proto__Profiles__V1development__Location *message) +{ + static const Opentelemetry__Proto__Profiles__V1development__Location init_value = OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__LOCATION__INIT; + *message = init_value; +} +size_t opentelemetry__proto__profiles__v1development__location__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Location *message) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__location__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t opentelemetry__proto__profiles__v1development__location__pack + (const Opentelemetry__Proto__Profiles__V1development__Location *message, + uint8_t *out) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__location__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t opentelemetry__proto__profiles__v1development__location__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Location *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__location__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +Opentelemetry__Proto__Profiles__V1development__Location * + opentelemetry__proto__profiles__v1development__location__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (Opentelemetry__Proto__Profiles__V1development__Location *) + protobuf_c_message_unpack (&opentelemetry__proto__profiles__v1development__location__descriptor, + allocator, len, data); +} +void opentelemetry__proto__profiles__v1development__location__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Location *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__location__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void opentelemetry__proto__profiles__v1development__line__init + (Opentelemetry__Proto__Profiles__V1development__Line *message) +{ + static const Opentelemetry__Proto__Profiles__V1development__Line init_value = OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__LINE__INIT; + *message = init_value; +} +size_t opentelemetry__proto__profiles__v1development__line__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Line *message) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__line__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t opentelemetry__proto__profiles__v1development__line__pack + (const Opentelemetry__Proto__Profiles__V1development__Line *message, + uint8_t *out) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__line__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t opentelemetry__proto__profiles__v1development__line__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Line *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__line__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +Opentelemetry__Proto__Profiles__V1development__Line * + opentelemetry__proto__profiles__v1development__line__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (Opentelemetry__Proto__Profiles__V1development__Line *) + protobuf_c_message_unpack (&opentelemetry__proto__profiles__v1development__line__descriptor, + allocator, len, data); +} +void opentelemetry__proto__profiles__v1development__line__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Line *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__line__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void opentelemetry__proto__profiles__v1development__function__init + (Opentelemetry__Proto__Profiles__V1development__Function *message) +{ + static const Opentelemetry__Proto__Profiles__V1development__Function init_value = OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__FUNCTION__INIT; + *message = init_value; +} +size_t opentelemetry__proto__profiles__v1development__function__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Function *message) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__function__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t opentelemetry__proto__profiles__v1development__function__pack + (const Opentelemetry__Proto__Profiles__V1development__Function *message, + uint8_t *out) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__function__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t opentelemetry__proto__profiles__v1development__function__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Function *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__function__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +Opentelemetry__Proto__Profiles__V1development__Function * + opentelemetry__proto__profiles__v1development__function__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (Opentelemetry__Proto__Profiles__V1development__Function *) + protobuf_c_message_unpack (&opentelemetry__proto__profiles__v1development__function__descriptor, + allocator, len, data); +} +void opentelemetry__proto__profiles__v1development__function__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Function *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__function__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__profile__field_descriptors[18] = +{ + { + "sample_type", + 1, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, n_sample_type), + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, sample_type), + &opentelemetry__proto__profiles__v1development__value_type__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "sample", + 2, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, n_sample), + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, sample), + &opentelemetry__proto__profiles__v1development__sample__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "mapping", + 3, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, n_mapping), + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, mapping), + &opentelemetry__proto__profiles__v1development__mapping__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "location", + 4, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, n_location), + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, location), + &opentelemetry__proto__profiles__v1development__location__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "function", + 5, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, n_function), + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, function), + &opentelemetry__proto__profiles__v1development__function__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "string_table", + 6, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_STRING, + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, n_string_table), + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, string_table), + NULL, + &protobuf_c_empty_string, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "drop_frames", + 7, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, drop_frames), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "keep_frames", + 8, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, keep_frames), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "time_nanos", + 9, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, time_nanos), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "duration_nanos", + 10, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, duration_nanos), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "period_type", + 11, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_MESSAGE, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, period_type), + &opentelemetry__proto__profiles__v1development__value_type__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "period", + 12, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, period), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "comment", + 13, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_INT64, + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, n_comment), + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, comment), + NULL, + NULL, + PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "default_sample_type", + 14, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, default_sample_type), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "location_indices", + 15, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_INT64, + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, n_location_indices), + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, location_indices), + NULL, + NULL, + PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "attribute_table", + 16, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, n_attribute_table), + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, attribute_table), + &opentelemetry__proto__common__v1__key_value__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "attribute_units", + 17, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, n_attribute_units), + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, attribute_units), + &opentelemetry__proto__profiles__v1development__attribute_unit__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "link_table", + 18, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, n_link_table), + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, link_table), + &opentelemetry__proto__profiles__v1development__link__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned opentelemetry__proto__profiles__v1development__profile__field_indices_by_name[] = { + 15, /* field[15] = attribute_table */ + 16, /* field[16] = attribute_units */ + 12, /* field[12] = comment */ + 13, /* field[13] = default_sample_type */ + 6, /* field[6] = drop_frames */ + 9, /* field[9] = duration_nanos */ + 4, /* field[4] = function */ + 7, /* field[7] = keep_frames */ + 17, /* field[17] = link_table */ + 3, /* field[3] = location */ + 14, /* field[14] = location_indices */ + 2, /* field[2] = mapping */ + 11, /* field[11] = period */ + 10, /* field[10] = period_type */ + 1, /* field[1] = sample */ + 0, /* field[0] = sample_type */ + 5, /* field[5] = string_table */ + 8, /* field[8] = time_nanos */ +}; +static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__profile__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 18 } +}; +const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__profile__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "opentelemetry.proto.profiles.v1development.Profile", + "Profile", + "Opentelemetry__Proto__Profiles__V1development__Profile", + "opentelemetry.proto.profiles.v1development", + sizeof(Opentelemetry__Proto__Profiles__V1development__Profile), + 18, + opentelemetry__proto__profiles__v1development__profile__field_descriptors, + opentelemetry__proto__profiles__v1development__profile__field_indices_by_name, + 1, opentelemetry__proto__profiles__v1development__profile__number_ranges, + (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__profile__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__attribute_unit__field_descriptors[2] = +{ + { + "attribute_key", + 1, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__AttributeUnit, attribute_key), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "unit", + 2, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__AttributeUnit, unit), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned opentelemetry__proto__profiles__v1development__attribute_unit__field_indices_by_name[] = { + 0, /* field[0] = attribute_key */ + 1, /* field[1] = unit */ +}; +static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__attribute_unit__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 2 } +}; +const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__attribute_unit__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "opentelemetry.proto.profiles.v1development.AttributeUnit", + "AttributeUnit", + "Opentelemetry__Proto__Profiles__V1development__AttributeUnit", + "opentelemetry.proto.profiles.v1development", + sizeof(Opentelemetry__Proto__Profiles__V1development__AttributeUnit), + 2, + opentelemetry__proto__profiles__v1development__attribute_unit__field_descriptors, + opentelemetry__proto__profiles__v1development__attribute_unit__field_indices_by_name, + 1, opentelemetry__proto__profiles__v1development__attribute_unit__number_ranges, + (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__attribute_unit__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__link__field_descriptors[2] = +{ + { + "trace_id", + 1, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_BYTES, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Link, trace_id), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "span_id", + 2, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_BYTES, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Link, span_id), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned opentelemetry__proto__profiles__v1development__link__field_indices_by_name[] = { + 1, /* field[1] = span_id */ + 0, /* field[0] = trace_id */ +}; +static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__link__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 2 } +}; +const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__link__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "opentelemetry.proto.profiles.v1development.Link", + "Link", + "Opentelemetry__Proto__Profiles__V1development__Link", + "opentelemetry.proto.profiles.v1development", + sizeof(Opentelemetry__Proto__Profiles__V1development__Link), + 2, + opentelemetry__proto__profiles__v1development__link__field_descriptors, + opentelemetry__proto__profiles__v1development__link__field_indices_by_name, + 1, opentelemetry__proto__profiles__v1development__link__number_ranges, + (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__link__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__value_type__field_descriptors[3] = +{ + { + "type", + 1, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__ValueType, type), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "unit", + 2, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__ValueType, unit), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "aggregation_temporality", + 3, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_ENUM, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__ValueType, aggregation_temporality), + &opentelemetry__proto__profiles__v1development__aggregation_temporality__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned opentelemetry__proto__profiles__v1development__value_type__field_indices_by_name[] = { + 2, /* field[2] = aggregation_temporality */ + 0, /* field[0] = type */ + 1, /* field[1] = unit */ +}; +static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__value_type__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 3 } +}; +const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__value_type__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "opentelemetry.proto.profiles.v1development.ValueType", + "ValueType", + "Opentelemetry__Proto__Profiles__V1development__ValueType", + "opentelemetry.proto.profiles.v1development", + sizeof(Opentelemetry__Proto__Profiles__V1development__ValueType), + 3, + opentelemetry__proto__profiles__v1development__value_type__field_descriptors, + opentelemetry__proto__profiles__v1development__value_type__field_indices_by_name, + 1, opentelemetry__proto__profiles__v1development__value_type__number_ranges, + (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__value_type__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__sample__field_descriptors[7] = +{ + { + "location_index", + 1, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_UINT64, + offsetof(Opentelemetry__Proto__Profiles__V1development__Sample, n_location_index), + offsetof(Opentelemetry__Proto__Profiles__V1development__Sample, location_index), + NULL, + NULL, + PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "value", + 2, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_INT64, + offsetof(Opentelemetry__Proto__Profiles__V1development__Sample, n_value), + offsetof(Opentelemetry__Proto__Profiles__V1development__Sample, value), + NULL, + NULL, + PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "locations_start_index", + 7, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_UINT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Sample, locations_start_index), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "locations_length", + 8, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_UINT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Sample, locations_length), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "attributes", + 10, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_UINT64, + offsetof(Opentelemetry__Proto__Profiles__V1development__Sample, n_attributes), + offsetof(Opentelemetry__Proto__Profiles__V1development__Sample, attributes), + NULL, + NULL, + PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "link", + 12, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_UINT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Sample, link), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "timestamps_unix_nano", + 13, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_UINT64, + offsetof(Opentelemetry__Proto__Profiles__V1development__Sample, n_timestamps_unix_nano), + offsetof(Opentelemetry__Proto__Profiles__V1development__Sample, timestamps_unix_nano), + NULL, + NULL, + PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned opentelemetry__proto__profiles__v1development__sample__field_indices_by_name[] = { + 4, /* field[4] = attributes */ + 5, /* field[5] = link */ + 0, /* field[0] = location_index */ + 3, /* field[3] = locations_length */ + 2, /* field[2] = locations_start_index */ + 6, /* field[6] = timestamps_unix_nano */ + 1, /* field[1] = value */ +}; +static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__sample__number_ranges[4 + 1] = +{ + { 1, 0 }, + { 7, 2 }, + { 10, 4 }, + { 12, 5 }, + { 0, 7 } +}; +const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__sample__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "opentelemetry.proto.profiles.v1development.Sample", + "Sample", + "Opentelemetry__Proto__Profiles__V1development__Sample", + "opentelemetry.proto.profiles.v1development", + sizeof(Opentelemetry__Proto__Profiles__V1development__Sample), + 7, + opentelemetry__proto__profiles__v1development__sample__field_descriptors, + opentelemetry__proto__profiles__v1development__sample__field_indices_by_name, + 4, opentelemetry__proto__profiles__v1development__sample__number_ranges, + (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__sample__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__label__field_descriptors[4] = +{ + { + "key", + 1, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Label, key), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "str", + 2, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Label, str), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "num", + 3, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Label, num), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "num_unit", + 4, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Label, num_unit), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned opentelemetry__proto__profiles__v1development__label__field_indices_by_name[] = { + 0, /* field[0] = key */ + 2, /* field[2] = num */ + 3, /* field[3] = num_unit */ + 1, /* field[1] = str */ +}; +static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__label__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 4 } +}; +const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__label__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "opentelemetry.proto.profiles.v1development.Label", + "Label", + "Opentelemetry__Proto__Profiles__V1development__Label", + "opentelemetry.proto.profiles.v1development", + sizeof(Opentelemetry__Proto__Profiles__V1development__Label), + 4, + opentelemetry__proto__profiles__v1development__label__field_descriptors, + opentelemetry__proto__profiles__v1development__label__field_indices_by_name, + 1, opentelemetry__proto__profiles__v1development__label__number_ranges, + (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__label__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__mapping__field_descriptors[10] = +{ + { + "id", + 1, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_UINT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Mapping, id), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "memory_start", + 2, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_UINT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Mapping, memory_start), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "memory_limit", + 3, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_UINT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Mapping, memory_limit), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "file_offset", + 4, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_UINT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Mapping, file_offset), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "filename", + 5, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Mapping, filename), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "has_functions", + 7, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_BOOL, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Mapping, has_functions), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "has_filenames", + 8, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_BOOL, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Mapping, has_filenames), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "has_line_numbers", + 9, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_BOOL, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Mapping, has_line_numbers), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "has_inline_frames", + 10, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_BOOL, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Mapping, has_inline_frames), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "attributes", + 12, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_UINT64, + offsetof(Opentelemetry__Proto__Profiles__V1development__Mapping, n_attributes), + offsetof(Opentelemetry__Proto__Profiles__V1development__Mapping, attributes), + NULL, + NULL, + PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned opentelemetry__proto__profiles__v1development__mapping__field_indices_by_name[] = { + 9, /* field[9] = attributes */ + 3, /* field[3] = file_offset */ + 4, /* field[4] = filename */ + 6, /* field[6] = has_filenames */ + 5, /* field[5] = has_functions */ + 8, /* field[8] = has_inline_frames */ + 7, /* field[7] = has_line_numbers */ + 0, /* field[0] = id */ + 2, /* field[2] = memory_limit */ + 1, /* field[1] = memory_start */ +}; +static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__mapping__number_ranges[3 + 1] = +{ + { 1, 0 }, + { 7, 5 }, + { 12, 9 }, + { 0, 10 } +}; +const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__mapping__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "opentelemetry.proto.profiles.v1development.Mapping", + "Mapping", + "Opentelemetry__Proto__Profiles__V1development__Mapping", + "opentelemetry.proto.profiles.v1development", + sizeof(Opentelemetry__Proto__Profiles__V1development__Mapping), + 10, + opentelemetry__proto__profiles__v1development__mapping__field_descriptors, + opentelemetry__proto__profiles__v1development__mapping__field_indices_by_name, + 3, opentelemetry__proto__profiles__v1development__mapping__number_ranges, + (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__mapping__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__location__field_descriptors[6] = +{ + { + "id", + 1, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_UINT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Location, id), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "mapping_index", + 2, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_UINT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Location, mapping_index), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "address", + 3, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_UINT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Location, address), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "line", + 4, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(Opentelemetry__Proto__Profiles__V1development__Location, n_line), + offsetof(Opentelemetry__Proto__Profiles__V1development__Location, line), + &opentelemetry__proto__profiles__v1development__line__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "is_folded", + 5, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_BOOL, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Location, is_folded), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "attributes", + 7, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_UINT64, + offsetof(Opentelemetry__Proto__Profiles__V1development__Location, n_attributes), + offsetof(Opentelemetry__Proto__Profiles__V1development__Location, attributes), + NULL, + NULL, + PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned opentelemetry__proto__profiles__v1development__location__field_indices_by_name[] = { + 2, /* field[2] = address */ + 5, /* field[5] = attributes */ + 0, /* field[0] = id */ + 4, /* field[4] = is_folded */ + 3, /* field[3] = line */ + 1, /* field[1] = mapping_index */ +}; +static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__location__number_ranges[2 + 1] = +{ + { 1, 0 }, + { 7, 5 }, + { 0, 6 } +}; +const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__location__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "opentelemetry.proto.profiles.v1development.Location", + "Location", + "Opentelemetry__Proto__Profiles__V1development__Location", + "opentelemetry.proto.profiles.v1development", + sizeof(Opentelemetry__Proto__Profiles__V1development__Location), + 6, + opentelemetry__proto__profiles__v1development__location__field_descriptors, + opentelemetry__proto__profiles__v1development__location__field_indices_by_name, + 2, opentelemetry__proto__profiles__v1development__location__number_ranges, + (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__location__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__line__field_descriptors[3] = +{ + { + "function_index", + 1, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_UINT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Line, function_index), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "line", + 2, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Line, line), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "column", + 3, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Line, column), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned opentelemetry__proto__profiles__v1development__line__field_indices_by_name[] = { + 2, /* field[2] = column */ + 0, /* field[0] = function_index */ + 1, /* field[1] = line */ +}; +static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__line__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 3 } +}; +const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__line__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "opentelemetry.proto.profiles.v1development.Line", + "Line", + "Opentelemetry__Proto__Profiles__V1development__Line", + "opentelemetry.proto.profiles.v1development", + sizeof(Opentelemetry__Proto__Profiles__V1development__Line), + 3, + opentelemetry__proto__profiles__v1development__line__field_descriptors, + opentelemetry__proto__profiles__v1development__line__field_indices_by_name, + 1, opentelemetry__proto__profiles__v1development__line__number_ranges, + (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__line__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__function__field_descriptors[5] = +{ + { + "id", + 1, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_UINT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Function, id), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "name", + 2, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Function, name), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "system_name", + 3, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Function, system_name), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "filename", + 4, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Function, filename), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "start_line", + 5, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Function, start_line), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned opentelemetry__proto__profiles__v1development__function__field_indices_by_name[] = { + 3, /* field[3] = filename */ + 0, /* field[0] = id */ + 1, /* field[1] = name */ + 4, /* field[4] = start_line */ + 2, /* field[2] = system_name */ +}; +static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__function__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 5 } +}; +const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__function__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "opentelemetry.proto.profiles.v1development.Function", + "Function", + "Opentelemetry__Proto__Profiles__V1development__Function", + "opentelemetry.proto.profiles.v1development", + sizeof(Opentelemetry__Proto__Profiles__V1development__Function), + 5, + opentelemetry__proto__profiles__v1development__function__field_descriptors, + opentelemetry__proto__profiles__v1development__function__field_indices_by_name, + 1, opentelemetry__proto__profiles__v1development__function__number_ranges, + (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__function__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCEnumValue opentelemetry__proto__profiles__v1development__aggregation_temporality__enum_values_by_number[3] = +{ + { "AGGREGATION_TEMPORALITY_UNSPECIFIED", "OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__AGGREGATION_TEMPORALITY__AGGREGATION_TEMPORALITY_UNSPECIFIED", 0 }, + { "AGGREGATION_TEMPORALITY_DELTA", "OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__AGGREGATION_TEMPORALITY__AGGREGATION_TEMPORALITY_DELTA", 1 }, + { "AGGREGATION_TEMPORALITY_CUMULATIVE", "OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__AGGREGATION_TEMPORALITY__AGGREGATION_TEMPORALITY_CUMULATIVE", 2 }, +}; +static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__aggregation_temporality__value_ranges[] = { +{0, 0},{0, 3} +}; +static const ProtobufCEnumValueIndex opentelemetry__proto__profiles__v1development__aggregation_temporality__enum_values_by_name[3] = +{ + { "AGGREGATION_TEMPORALITY_CUMULATIVE", 2 }, + { "AGGREGATION_TEMPORALITY_DELTA", 1 }, + { "AGGREGATION_TEMPORALITY_UNSPECIFIED", 0 }, +}; +const ProtobufCEnumDescriptor opentelemetry__proto__profiles__v1development__aggregation_temporality__descriptor = +{ + PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, + "opentelemetry.proto.profiles.v1development.AggregationTemporality", + "AggregationTemporality", + "Opentelemetry__Proto__Profiles__V1development__AggregationTemporality", + "opentelemetry.proto.profiles.v1development", + 3, + opentelemetry__proto__profiles__v1development__aggregation_temporality__enum_values_by_number, + 3, + opentelemetry__proto__profiles__v1development__aggregation_temporality__enum_values_by_name, + 1, + opentelemetry__proto__profiles__v1development__aggregation_temporality__value_ranges, + NULL,NULL,NULL,NULL /* reserved[1234] */ +}; diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/profiles/v1development/pprofextended.pb-c.h b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/profiles/v1development/pprofextended.pb-c.h new file mode 100644 index 00000000000..deec0afb116 --- /dev/null +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/profiles/v1development/pprofextended.pb-c.h @@ -0,0 +1,799 @@ +/* Generated by the protocol buffer compiler. DO NOT EDIT! */ +/* Generated from: opentelemetry/proto/profiles/v1development/pprofextended.proto */ + +#ifndef PROTOBUF_C_opentelemetry_2fproto_2fprofiles_2fv1development_2fpprofextended_2eproto__INCLUDED +#define PROTOBUF_C_opentelemetry_2fproto_2fprofiles_2fv1development_2fpprofextended_2eproto__INCLUDED + +#include + +PROTOBUF_C__BEGIN_DECLS + +#if PROTOBUF_C_VERSION_NUMBER < 1003000 +# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. +#elif 1005000 < PROTOBUF_C_MIN_COMPILER_VERSION +# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. +#endif + +#include "opentelemetry/proto/common/v1/common.pb-c.h" + +typedef struct Opentelemetry__Proto__Profiles__V1development__Profile Opentelemetry__Proto__Profiles__V1development__Profile; +typedef struct Opentelemetry__Proto__Profiles__V1development__AttributeUnit Opentelemetry__Proto__Profiles__V1development__AttributeUnit; +typedef struct Opentelemetry__Proto__Profiles__V1development__Link Opentelemetry__Proto__Profiles__V1development__Link; +typedef struct Opentelemetry__Proto__Profiles__V1development__ValueType Opentelemetry__Proto__Profiles__V1development__ValueType; +typedef struct Opentelemetry__Proto__Profiles__V1development__Sample Opentelemetry__Proto__Profiles__V1development__Sample; +typedef struct Opentelemetry__Proto__Profiles__V1development__Label Opentelemetry__Proto__Profiles__V1development__Label; +typedef struct Opentelemetry__Proto__Profiles__V1development__Mapping Opentelemetry__Proto__Profiles__V1development__Mapping; +typedef struct Opentelemetry__Proto__Profiles__V1development__Location Opentelemetry__Proto__Profiles__V1development__Location; +typedef struct Opentelemetry__Proto__Profiles__V1development__Line Opentelemetry__Proto__Profiles__V1development__Line; +typedef struct Opentelemetry__Proto__Profiles__V1development__Function Opentelemetry__Proto__Profiles__V1development__Function; + + +/* --- enums --- */ + +/* + * Specifies the method of aggregating metric values, either DELTA (change since last report) + * or CUMULATIVE (total since a fixed start time). + */ +typedef enum _Opentelemetry__Proto__Profiles__V1development__AggregationTemporality { + /* + * UNSPECIFIED is the default AggregationTemporality, it MUST not be used. + */ + OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__AGGREGATION_TEMPORALITY__AGGREGATION_TEMPORALITY_UNSPECIFIED = 0, + /* + ** DELTA is an AggregationTemporality for a profiler which reports + *changes since last report time. Successive metrics contain aggregation of + *values from continuous and non-overlapping intervals. + *The values for a DELTA metric are based only on the time interval + *associated with one measurement cycle. There is no dependency on + *previous measurements like is the case for CUMULATIVE metrics. + *For example, consider a system measuring the number of requests that + *it receives and reports the sum of these requests every second as a + *DELTA metric: + *1. The system starts receiving at time=t_0. + *2. A request is received, the system measures 1 request. + *3. A request is received, the system measures 1 request. + *4. A request is received, the system measures 1 request. + *5. The 1 second collection cycle ends. A metric is exported for the + *number of requests received over the interval of time t_0 to + *t_0+1 with a value of 3. + *6. A request is received, the system measures 1 request. + *7. A request is received, the system measures 1 request. + *8. The 1 second collection cycle ends. A metric is exported for the + *number of requests received over the interval of time t_0+1 to + *t_0+2 with a value of 2. + */ + OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__AGGREGATION_TEMPORALITY__AGGREGATION_TEMPORALITY_DELTA = 1, + /* + ** CUMULATIVE is an AggregationTemporality for a profiler which + *reports changes since a fixed start time. This means that current values + *of a CUMULATIVE metric depend on all previous measurements since the + *start time. Because of this, the sender is required to retain this state + *in some form. If this state is lost or invalidated, the CUMULATIVE metric + *values MUST be reset and a new fixed start time following the last + *reported measurement time sent MUST be used. + *For example, consider a system measuring the number of requests that + *it receives and reports the sum of these requests every second as a + *CUMULATIVE metric: + *1. The system starts receiving at time=t_0. + *2. A request is received, the system measures 1 request. + *3. A request is received, the system measures 1 request. + *4. A request is received, the system measures 1 request. + *5. The 1 second collection cycle ends. A metric is exported for the + *number of requests received over the interval of time t_0 to + *t_0+1 with a value of 3. + *6. A request is received, the system measures 1 request. + *7. A request is received, the system measures 1 request. + *8. The 1 second collection cycle ends. A metric is exported for the + *number of requests received over the interval of time t_0 to + *t_0+2 with a value of 5. + *9. The system experiences a fault and loses state. + *10. The system recovers and resumes receiving at time=t_1. + *11. A request is received, the system measures 1 request. + *12. The 1 second collection cycle ends. A metric is exported for the + *number of requests received over the interval of time t_1 to + *t_1+1 with a value of 1. + *Note: Even though, when reporting changes since last report time, using + *CUMULATIVE is valid, it is not recommended. + */ + OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__AGGREGATION_TEMPORALITY__AGGREGATION_TEMPORALITY_CUMULATIVE = 2 + PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__AGGREGATION_TEMPORALITY) +} Opentelemetry__Proto__Profiles__V1development__AggregationTemporality; + +/* --- messages --- */ + +/* + * Represents a complete profile, including sample types, samples, + * mappings to binaries, locations, functions, string table, and additional metadata. + */ +struct Opentelemetry__Proto__Profiles__V1development__Profile +{ + ProtobufCMessage base; + /* + * A description of the samples associated with each Sample.value. + * For a cpu profile this might be: + * [["cpu","nanoseconds"]] or [["wall","seconds"]] or [["syscall","count"]] + * For a heap profile, this might be: + * [["allocations","count"], ["space","bytes"]], + * If one of the values represents the number of events represented + * by the sample, by convention it should be at index 0 and use + * sample_type.unit == "count". + */ + size_t n_sample_type; + Opentelemetry__Proto__Profiles__V1development__ValueType **sample_type; + /* + * The set of samples recorded in this profile. + */ + size_t n_sample; + Opentelemetry__Proto__Profiles__V1development__Sample **sample; + /* + * Mapping from address ranges to the image/binary/library mapped + * into that address range. mapping[0] will be the main binary. + * If multiple binaries contribute to the Profile and no main + * binary can be identified, mapping[0] has no special meaning. + */ + size_t n_mapping; + Opentelemetry__Proto__Profiles__V1development__Mapping **mapping; + /* + * Locations referenced by samples via location_indices. + */ + size_t n_location; + Opentelemetry__Proto__Profiles__V1development__Location **location; + /* + * Array of locations referenced by samples. + */ + size_t n_location_indices; + int64_t *location_indices; + /* + * Functions referenced by locations. + */ + size_t n_function; + Opentelemetry__Proto__Profiles__V1development__Function **function; + /* + * Lookup table for attributes. + */ + size_t n_attribute_table; + Opentelemetry__Proto__Common__V1__KeyValue **attribute_table; + /* + * Represents a mapping between Attribute Keys and Units. + */ + size_t n_attribute_units; + Opentelemetry__Proto__Profiles__V1development__AttributeUnit **attribute_units; + /* + * Lookup table for links. + */ + size_t n_link_table; + Opentelemetry__Proto__Profiles__V1development__Link **link_table; + /* + * A common table for strings referenced by various messages. + * string_table[0] must always be "". + */ + size_t n_string_table; + char **string_table; + /* + * frames with Function.function_name fully matching the following + * regexp will be dropped from the samples, along with their successors. + */ + /* + * Index into string table. + */ + int64_t drop_frames; + /* + * frames with Function.function_name fully matching the following + * regexp will be kept, even if it matches drop_frames. + */ + /* + * Index into string table. + */ + int64_t keep_frames; + /* + * Time of collection (UTC) represented as nanoseconds past the epoch. + */ + int64_t time_nanos; + /* + * Duration of the profile, if a duration makes sense. + */ + int64_t duration_nanos; + /* + * The kind of events between sampled occurrences. + * e.g [ "cpu","cycles" ] or [ "heap","bytes" ] + */ + Opentelemetry__Proto__Profiles__V1development__ValueType *period_type; + /* + * The number of events between sampled occurrences. + */ + int64_t period; + /* + * Free-form text associated with the profile. The text is displayed as is + * to the user by the tools that read profiles (e.g. by pprof). This field + * should not be used to store any machine-readable information, it is only + * for human-friendly content. The profile must stay functional if this field + * is cleaned. + */ + /* + * Indices into string table. + */ + size_t n_comment; + int64_t *comment; + /* + * Index into the string table of the type of the preferred sample + * value. If unset, clients should default to the last sample value. + */ + int64_t default_sample_type; +}; +#define OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__PROFILE__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__profiles__v1development__profile__descriptor) \ + , 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0, 0, 0, 0, NULL, 0, 0,NULL, 0 } + + +/* + * Represents a mapping between Attribute Keys and Units. + */ +struct Opentelemetry__Proto__Profiles__V1development__AttributeUnit +{ + ProtobufCMessage base; + /* + * Index into string table. + */ + int64_t attribute_key; + /* + * Index into string table. + */ + int64_t unit; +}; +#define OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__ATTRIBUTE_UNIT__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__profiles__v1development__attribute_unit__descriptor) \ + , 0, 0 } + + +/* + * A pointer from a profile Sample to a trace Span. + * Connects a profile sample to a trace span, identified by unique trace and span IDs. + */ +struct Opentelemetry__Proto__Profiles__V1development__Link +{ + ProtobufCMessage base; + /* + * A unique identifier of a trace that this linked span is part of. The ID is a + * 16-byte array. + */ + ProtobufCBinaryData trace_id; + /* + * A unique identifier for the linked span. The ID is an 8-byte array. + */ + ProtobufCBinaryData span_id; +}; +#define OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__LINK__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__profiles__v1development__link__descriptor) \ + , {0,NULL}, {0,NULL} } + + +/* + * ValueType describes the type and units of a value, with an optional aggregation temporality. + */ +struct Opentelemetry__Proto__Profiles__V1development__ValueType +{ + ProtobufCMessage base; + /* + * Index into string table. + */ + int64_t type; + /* + * Index into string table. + */ + int64_t unit; + Opentelemetry__Proto__Profiles__V1development__AggregationTemporality aggregation_temporality; +}; +#define OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__VALUE_TYPE__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__profiles__v1development__value_type__descriptor) \ + , 0, 0, OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__AGGREGATION_TEMPORALITY__AGGREGATION_TEMPORALITY_UNSPECIFIED } + + +/* + * Each Sample records values encountered in some program + * context. The program context is typically a stack trace, perhaps + * augmented with auxiliary information like the thread-id, some + * indicator of a higher level request being handled etc. + */ +struct Opentelemetry__Proto__Profiles__V1development__Sample +{ + ProtobufCMessage base; + /* + * The indices recorded here correspond to locations in Profile.location. + * The leaf is at location_index[0]. [deprecated, superseded by locations_start_index / locations_length] + */ + size_t n_location_index; + uint64_t *location_index; + /* + * locations_start_index along with locations_length refers to to a slice of locations in Profile.location. + * Supersedes location_index. + */ + uint64_t locations_start_index; + /* + * locations_length along with locations_start_index refers to a slice of locations in Profile.location. + * Supersedes location_index. + */ + uint64_t locations_length; + /* + * The type and unit of each value is defined by the corresponding + * entry in Profile.sample_type. All samples must have the same + * number of values, the same as the length of Profile.sample_type. + * When aggregating multiple samples into a single sample, the + * result has a list of values that is the element-wise sum of the + * lists of the originals. + */ + size_t n_value; + int64_t *value; + /* + * References to attributes in Profile.attribute_table. [optional] + */ + size_t n_attributes; + uint64_t *attributes; + /* + * Reference to link in Profile.link_table. [optional] + */ + uint64_t link; + /* + * Timestamps associated with Sample represented in nanoseconds. These timestamps are expected + * to fall within the Profile's time range. [optional] + */ + size_t n_timestamps_unix_nano; + uint64_t *timestamps_unix_nano; +}; +#define OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__SAMPLE__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__profiles__v1development__sample__descriptor) \ + , 0,NULL, 0, 0, 0,NULL, 0,NULL, 0, 0,NULL } + + +/* + * Provides additional context for a sample, + * such as thread ID or allocation size, with optional units. [deprecated] + */ +struct Opentelemetry__Proto__Profiles__V1development__Label +{ + ProtobufCMessage base; + /* + * Index into string table + */ + int64_t key; + /* + * At most one of the following must be present + */ + /* + * Index into string table + */ + int64_t str; + int64_t num; + /* + * Should only be present when num is present. + * Specifies the units of num. + * Use arbitrary string (for example, "requests") as a custom count unit. + * If no unit is specified, consumer may apply heuristic to deduce the unit. + * Consumers may also interpret units like "bytes" and "kilobytes" as memory + * units and units like "seconds" and "nanoseconds" as time units, + * and apply appropriate unit conversions to these. + */ + /* + * Index into string table + */ + int64_t num_unit; +}; +#define OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__LABEL__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__profiles__v1development__label__descriptor) \ + , 0, 0, 0, 0 } + + +/* + * Describes the mapping of a binary in memory, including its address range, + * file offset, and metadata like build ID + */ +struct Opentelemetry__Proto__Profiles__V1development__Mapping +{ + ProtobufCMessage base; + /* + * Unique nonzero id for the mapping. [deprecated] + */ + uint64_t id; + /* + * Address at which the binary (or DLL) is loaded into memory. + */ + uint64_t memory_start; + /* + * The limit of the address range occupied by this mapping. + */ + uint64_t memory_limit; + /* + * Offset in the binary that corresponds to the first mapped address. + */ + uint64_t file_offset; + /* + * The object this entry is loaded from. This can be a filename on + * disk for the main binary and shared libraries, or virtual + * abstractions like "[vdso]". + */ + /* + * Index into string table + */ + int64_t filename; + /* + * References to attributes in Profile.attribute_table. [optional] + */ + size_t n_attributes; + uint64_t *attributes; + /* + * The following fields indicate the resolution of symbolic info. + */ + protobuf_c_boolean has_functions; + protobuf_c_boolean has_filenames; + protobuf_c_boolean has_line_numbers; + protobuf_c_boolean has_inline_frames; +}; +#define OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__MAPPING__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__profiles__v1development__mapping__descriptor) \ + , 0, 0, 0, 0, 0, 0,NULL, 0, 0, 0, 0 } + + +/* + * Describes function and line table debug information. + */ +struct Opentelemetry__Proto__Profiles__V1development__Location +{ + ProtobufCMessage base; + /* + * Unique nonzero id for the location. A profile could use + * instruction addresses or any integer sequence as ids. [deprecated] + */ + uint64_t id; + /* + * The index of the corresponding profile.Mapping for this location. + * It can be unset if the mapping is unknown or not applicable for + * this profile type. + */ + uint64_t mapping_index; + /* + * The instruction address for this location, if available. It + * should be within [Mapping.memory_start...Mapping.memory_limit] + * for the corresponding mapping. A non-leaf address may be in the + * middle of a call instruction. It is up to display tools to find + * the beginning of the instruction if necessary. + */ + uint64_t address; + /* + * Multiple line indicates this location has inlined functions, + * where the last entry represents the caller into which the + * preceding entries were inlined. + * E.g., if memcpy() is inlined into printf: + * line[0].function_name == "memcpy" + * line[1].function_name == "printf" + */ + size_t n_line; + Opentelemetry__Proto__Profiles__V1development__Line **line; + /* + * Provides an indication that multiple symbols map to this location's + * address, for example due to identical code folding by the linker. In that + * case the line information above represents one of the multiple + * symbols. This field must be recomputed when the symbolization state of the + * profile changes. + */ + protobuf_c_boolean is_folded; + /* + * References to attributes in Profile.attribute_table. [optional] + */ + size_t n_attributes; + uint64_t *attributes; +}; +#define OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__LOCATION__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__profiles__v1development__location__descriptor) \ + , 0, 0, 0, 0,NULL, 0, 0,NULL } + + +/* + * Details a specific line in a source code, linked to a function. + */ +struct Opentelemetry__Proto__Profiles__V1development__Line +{ + ProtobufCMessage base; + /* + * The index of the corresponding profile.Function for this line. + */ + uint64_t function_index; + /* + * Line number in source code. + */ + int64_t line; + /* + * Column number in source code. + */ + int64_t column; +}; +#define OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__LINE__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__profiles__v1development__line__descriptor) \ + , 0, 0, 0 } + + +/* + * Describes a function, including its human-readable name, system name, + * source file, and starting line number in the source. + */ +struct Opentelemetry__Proto__Profiles__V1development__Function +{ + ProtobufCMessage base; + /* + * Unique nonzero id for the function. [deprecated] + */ + uint64_t id; + /* + * Name of the function, in human-readable form if available. + */ + /* + * Index into string table + */ + int64_t name; + /* + * Name of the function, as identified by the system. + * For instance, it can be a C++ mangled name. + */ + /* + * Index into string table + */ + int64_t system_name; + /* + * Source file containing the function. + */ + /* + * Index into string table + */ + int64_t filename; + /* + * Line number in source file. + */ + int64_t start_line; +}; +#define OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__FUNCTION__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__profiles__v1development__function__descriptor) \ + , 0, 0, 0, 0, 0 } + + +/* Opentelemetry__Proto__Profiles__V1development__Profile methods */ +void opentelemetry__proto__profiles__v1development__profile__init + (Opentelemetry__Proto__Profiles__V1development__Profile *message); +size_t opentelemetry__proto__profiles__v1development__profile__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Profile *message); +size_t opentelemetry__proto__profiles__v1development__profile__pack + (const Opentelemetry__Proto__Profiles__V1development__Profile *message, + uint8_t *out); +size_t opentelemetry__proto__profiles__v1development__profile__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Profile *message, + ProtobufCBuffer *buffer); +Opentelemetry__Proto__Profiles__V1development__Profile * + opentelemetry__proto__profiles__v1development__profile__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void opentelemetry__proto__profiles__v1development__profile__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Profile *message, + ProtobufCAllocator *allocator); +/* Opentelemetry__Proto__Profiles__V1development__AttributeUnit methods */ +void opentelemetry__proto__profiles__v1development__attribute_unit__init + (Opentelemetry__Proto__Profiles__V1development__AttributeUnit *message); +size_t opentelemetry__proto__profiles__v1development__attribute_unit__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__AttributeUnit *message); +size_t opentelemetry__proto__profiles__v1development__attribute_unit__pack + (const Opentelemetry__Proto__Profiles__V1development__AttributeUnit *message, + uint8_t *out); +size_t opentelemetry__proto__profiles__v1development__attribute_unit__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__AttributeUnit *message, + ProtobufCBuffer *buffer); +Opentelemetry__Proto__Profiles__V1development__AttributeUnit * + opentelemetry__proto__profiles__v1development__attribute_unit__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void opentelemetry__proto__profiles__v1development__attribute_unit__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__AttributeUnit *message, + ProtobufCAllocator *allocator); +/* Opentelemetry__Proto__Profiles__V1development__Link methods */ +void opentelemetry__proto__profiles__v1development__link__init + (Opentelemetry__Proto__Profiles__V1development__Link *message); +size_t opentelemetry__proto__profiles__v1development__link__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Link *message); +size_t opentelemetry__proto__profiles__v1development__link__pack + (const Opentelemetry__Proto__Profiles__V1development__Link *message, + uint8_t *out); +size_t opentelemetry__proto__profiles__v1development__link__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Link *message, + ProtobufCBuffer *buffer); +Opentelemetry__Proto__Profiles__V1development__Link * + opentelemetry__proto__profiles__v1development__link__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void opentelemetry__proto__profiles__v1development__link__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Link *message, + ProtobufCAllocator *allocator); +/* Opentelemetry__Proto__Profiles__V1development__ValueType methods */ +void opentelemetry__proto__profiles__v1development__value_type__init + (Opentelemetry__Proto__Profiles__V1development__ValueType *message); +size_t opentelemetry__proto__profiles__v1development__value_type__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__ValueType *message); +size_t opentelemetry__proto__profiles__v1development__value_type__pack + (const Opentelemetry__Proto__Profiles__V1development__ValueType *message, + uint8_t *out); +size_t opentelemetry__proto__profiles__v1development__value_type__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__ValueType *message, + ProtobufCBuffer *buffer); +Opentelemetry__Proto__Profiles__V1development__ValueType * + opentelemetry__proto__profiles__v1development__value_type__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void opentelemetry__proto__profiles__v1development__value_type__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__ValueType *message, + ProtobufCAllocator *allocator); +/* Opentelemetry__Proto__Profiles__V1development__Sample methods */ +void opentelemetry__proto__profiles__v1development__sample__init + (Opentelemetry__Proto__Profiles__V1development__Sample *message); +size_t opentelemetry__proto__profiles__v1development__sample__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Sample *message); +size_t opentelemetry__proto__profiles__v1development__sample__pack + (const Opentelemetry__Proto__Profiles__V1development__Sample *message, + uint8_t *out); +size_t opentelemetry__proto__profiles__v1development__sample__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Sample *message, + ProtobufCBuffer *buffer); +Opentelemetry__Proto__Profiles__V1development__Sample * + opentelemetry__proto__profiles__v1development__sample__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void opentelemetry__proto__profiles__v1development__sample__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Sample *message, + ProtobufCAllocator *allocator); +/* Opentelemetry__Proto__Profiles__V1development__Label methods */ +void opentelemetry__proto__profiles__v1development__label__init + (Opentelemetry__Proto__Profiles__V1development__Label *message); +size_t opentelemetry__proto__profiles__v1development__label__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Label *message); +size_t opentelemetry__proto__profiles__v1development__label__pack + (const Opentelemetry__Proto__Profiles__V1development__Label *message, + uint8_t *out); +size_t opentelemetry__proto__profiles__v1development__label__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Label *message, + ProtobufCBuffer *buffer); +Opentelemetry__Proto__Profiles__V1development__Label * + opentelemetry__proto__profiles__v1development__label__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void opentelemetry__proto__profiles__v1development__label__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Label *message, + ProtobufCAllocator *allocator); +/* Opentelemetry__Proto__Profiles__V1development__Mapping methods */ +void opentelemetry__proto__profiles__v1development__mapping__init + (Opentelemetry__Proto__Profiles__V1development__Mapping *message); +size_t opentelemetry__proto__profiles__v1development__mapping__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Mapping *message); +size_t opentelemetry__proto__profiles__v1development__mapping__pack + (const Opentelemetry__Proto__Profiles__V1development__Mapping *message, + uint8_t *out); +size_t opentelemetry__proto__profiles__v1development__mapping__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Mapping *message, + ProtobufCBuffer *buffer); +Opentelemetry__Proto__Profiles__V1development__Mapping * + opentelemetry__proto__profiles__v1development__mapping__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void opentelemetry__proto__profiles__v1development__mapping__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Mapping *message, + ProtobufCAllocator *allocator); +/* Opentelemetry__Proto__Profiles__V1development__Location methods */ +void opentelemetry__proto__profiles__v1development__location__init + (Opentelemetry__Proto__Profiles__V1development__Location *message); +size_t opentelemetry__proto__profiles__v1development__location__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Location *message); +size_t opentelemetry__proto__profiles__v1development__location__pack + (const Opentelemetry__Proto__Profiles__V1development__Location *message, + uint8_t *out); +size_t opentelemetry__proto__profiles__v1development__location__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Location *message, + ProtobufCBuffer *buffer); +Opentelemetry__Proto__Profiles__V1development__Location * + opentelemetry__proto__profiles__v1development__location__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void opentelemetry__proto__profiles__v1development__location__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Location *message, + ProtobufCAllocator *allocator); +/* Opentelemetry__Proto__Profiles__V1development__Line methods */ +void opentelemetry__proto__profiles__v1development__line__init + (Opentelemetry__Proto__Profiles__V1development__Line *message); +size_t opentelemetry__proto__profiles__v1development__line__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Line *message); +size_t opentelemetry__proto__profiles__v1development__line__pack + (const Opentelemetry__Proto__Profiles__V1development__Line *message, + uint8_t *out); +size_t opentelemetry__proto__profiles__v1development__line__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Line *message, + ProtobufCBuffer *buffer); +Opentelemetry__Proto__Profiles__V1development__Line * + opentelemetry__proto__profiles__v1development__line__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void opentelemetry__proto__profiles__v1development__line__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Line *message, + ProtobufCAllocator *allocator); +/* Opentelemetry__Proto__Profiles__V1development__Function methods */ +void opentelemetry__proto__profiles__v1development__function__init + (Opentelemetry__Proto__Profiles__V1development__Function *message); +size_t opentelemetry__proto__profiles__v1development__function__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Function *message); +size_t opentelemetry__proto__profiles__v1development__function__pack + (const Opentelemetry__Proto__Profiles__V1development__Function *message, + uint8_t *out); +size_t opentelemetry__proto__profiles__v1development__function__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Function *message, + ProtobufCBuffer *buffer); +Opentelemetry__Proto__Profiles__V1development__Function * + opentelemetry__proto__profiles__v1development__function__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void opentelemetry__proto__profiles__v1development__function__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Function *message, + ProtobufCAllocator *allocator); +/* --- per-message closures --- */ + +typedef void (*Opentelemetry__Proto__Profiles__V1development__Profile_Closure) + (const Opentelemetry__Proto__Profiles__V1development__Profile *message, + void *closure_data); +typedef void (*Opentelemetry__Proto__Profiles__V1development__AttributeUnit_Closure) + (const Opentelemetry__Proto__Profiles__V1development__AttributeUnit *message, + void *closure_data); +typedef void (*Opentelemetry__Proto__Profiles__V1development__Link_Closure) + (const Opentelemetry__Proto__Profiles__V1development__Link *message, + void *closure_data); +typedef void (*Opentelemetry__Proto__Profiles__V1development__ValueType_Closure) + (const Opentelemetry__Proto__Profiles__V1development__ValueType *message, + void *closure_data); +typedef void (*Opentelemetry__Proto__Profiles__V1development__Sample_Closure) + (const Opentelemetry__Proto__Profiles__V1development__Sample *message, + void *closure_data); +typedef void (*Opentelemetry__Proto__Profiles__V1development__Label_Closure) + (const Opentelemetry__Proto__Profiles__V1development__Label *message, + void *closure_data); +typedef void (*Opentelemetry__Proto__Profiles__V1development__Mapping_Closure) + (const Opentelemetry__Proto__Profiles__V1development__Mapping *message, + void *closure_data); +typedef void (*Opentelemetry__Proto__Profiles__V1development__Location_Closure) + (const Opentelemetry__Proto__Profiles__V1development__Location *message, + void *closure_data); +typedef void (*Opentelemetry__Proto__Profiles__V1development__Line_Closure) + (const Opentelemetry__Proto__Profiles__V1development__Line *message, + void *closure_data); +typedef void (*Opentelemetry__Proto__Profiles__V1development__Function_Closure) + (const Opentelemetry__Proto__Profiles__V1development__Function *message, + void *closure_data); + +/* --- services --- */ + + +/* --- descriptors --- */ + +extern const ProtobufCEnumDescriptor opentelemetry__proto__profiles__v1development__aggregation_temporality__descriptor; +extern const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__profile__descriptor; +extern const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__attribute_unit__descriptor; +extern const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__link__descriptor; +extern const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__value_type__descriptor; +extern const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__sample__descriptor; +extern const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__label__descriptor; +extern const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__mapping__descriptor; +extern const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__location__descriptor; +extern const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__line__descriptor; +extern const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__function__descriptor; + +PROTOBUF_C__END_DECLS + + +#endif /* PROTOBUF_C_opentelemetry_2fproto_2fprofiles_2fv1development_2fpprofextended_2eproto__INCLUDED */ diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/profiles/v1development/profiles.pb-c.c b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/profiles/v1development/profiles.pb-c.c new file mode 100644 index 00000000000..1af8619d953 --- /dev/null +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/profiles/v1development/profiles.pb-c.c @@ -0,0 +1,484 @@ +/* Generated by the protocol buffer compiler. DO NOT EDIT! */ +/* Generated from: opentelemetry/proto/profiles/v1development/profiles.proto */ + +/* Do not generate deprecated warnings for self */ +#ifndef PROTOBUF_C__NO_DEPRECATED +#define PROTOBUF_C__NO_DEPRECATED +#endif + +#include "opentelemetry/proto/profiles/v1development/profiles.pb-c.h" +void opentelemetry__proto__profiles__v1development__profiles_data__init + (Opentelemetry__Proto__Profiles__V1development__ProfilesData *message) +{ + static const Opentelemetry__Proto__Profiles__V1development__ProfilesData init_value = OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__PROFILES_DATA__INIT; + *message = init_value; +} +size_t opentelemetry__proto__profiles__v1development__profiles_data__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__ProfilesData *message) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__profiles_data__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t opentelemetry__proto__profiles__v1development__profiles_data__pack + (const Opentelemetry__Proto__Profiles__V1development__ProfilesData *message, + uint8_t *out) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__profiles_data__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t opentelemetry__proto__profiles__v1development__profiles_data__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__ProfilesData *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__profiles_data__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +Opentelemetry__Proto__Profiles__V1development__ProfilesData * + opentelemetry__proto__profiles__v1development__profiles_data__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (Opentelemetry__Proto__Profiles__V1development__ProfilesData *) + protobuf_c_message_unpack (&opentelemetry__proto__profiles__v1development__profiles_data__descriptor, + allocator, len, data); +} +void opentelemetry__proto__profiles__v1development__profiles_data__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__ProfilesData *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__profiles_data__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void opentelemetry__proto__profiles__v1development__resource_profiles__init + (Opentelemetry__Proto__Profiles__V1development__ResourceProfiles *message) +{ + static const Opentelemetry__Proto__Profiles__V1development__ResourceProfiles init_value = OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__RESOURCE_PROFILES__INIT; + *message = init_value; +} +size_t opentelemetry__proto__profiles__v1development__resource_profiles__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__ResourceProfiles *message) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__resource_profiles__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t opentelemetry__proto__profiles__v1development__resource_profiles__pack + (const Opentelemetry__Proto__Profiles__V1development__ResourceProfiles *message, + uint8_t *out) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__resource_profiles__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t opentelemetry__proto__profiles__v1development__resource_profiles__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__ResourceProfiles *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__resource_profiles__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +Opentelemetry__Proto__Profiles__V1development__ResourceProfiles * + opentelemetry__proto__profiles__v1development__resource_profiles__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (Opentelemetry__Proto__Profiles__V1development__ResourceProfiles *) + protobuf_c_message_unpack (&opentelemetry__proto__profiles__v1development__resource_profiles__descriptor, + allocator, len, data); +} +void opentelemetry__proto__profiles__v1development__resource_profiles__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__ResourceProfiles *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__resource_profiles__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void opentelemetry__proto__profiles__v1development__scope_profiles__init + (Opentelemetry__Proto__Profiles__V1development__ScopeProfiles *message) +{ + static const Opentelemetry__Proto__Profiles__V1development__ScopeProfiles init_value = OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__SCOPE_PROFILES__INIT; + *message = init_value; +} +size_t opentelemetry__proto__profiles__v1development__scope_profiles__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__ScopeProfiles *message) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__scope_profiles__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t opentelemetry__proto__profiles__v1development__scope_profiles__pack + (const Opentelemetry__Proto__Profiles__V1development__ScopeProfiles *message, + uint8_t *out) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__scope_profiles__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t opentelemetry__proto__profiles__v1development__scope_profiles__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__ScopeProfiles *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__scope_profiles__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +Opentelemetry__Proto__Profiles__V1development__ScopeProfiles * + opentelemetry__proto__profiles__v1development__scope_profiles__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (Opentelemetry__Proto__Profiles__V1development__ScopeProfiles *) + protobuf_c_message_unpack (&opentelemetry__proto__profiles__v1development__scope_profiles__descriptor, + allocator, len, data); +} +void opentelemetry__proto__profiles__v1development__scope_profiles__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__ScopeProfiles *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__scope_profiles__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void opentelemetry__proto__profiles__v1development__profile_container__init + (Opentelemetry__Proto__Profiles__V1development__ProfileContainer *message) +{ + static const Opentelemetry__Proto__Profiles__V1development__ProfileContainer init_value = OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__PROFILE_CONTAINER__INIT; + *message = init_value; +} +size_t opentelemetry__proto__profiles__v1development__profile_container__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__ProfileContainer *message) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__profile_container__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t opentelemetry__proto__profiles__v1development__profile_container__pack + (const Opentelemetry__Proto__Profiles__V1development__ProfileContainer *message, + uint8_t *out) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__profile_container__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t opentelemetry__proto__profiles__v1development__profile_container__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__ProfileContainer *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__profile_container__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +Opentelemetry__Proto__Profiles__V1development__ProfileContainer * + opentelemetry__proto__profiles__v1development__profile_container__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (Opentelemetry__Proto__Profiles__V1development__ProfileContainer *) + protobuf_c_message_unpack (&opentelemetry__proto__profiles__v1development__profile_container__descriptor, + allocator, len, data); +} +void opentelemetry__proto__profiles__v1development__profile_container__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__ProfileContainer *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__profile_container__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__profiles_data__field_descriptors[1] = +{ + { + "resource_profiles", + 1, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(Opentelemetry__Proto__Profiles__V1development__ProfilesData, n_resource_profiles), + offsetof(Opentelemetry__Proto__Profiles__V1development__ProfilesData, resource_profiles), + &opentelemetry__proto__profiles__v1development__resource_profiles__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned opentelemetry__proto__profiles__v1development__profiles_data__field_indices_by_name[] = { + 0, /* field[0] = resource_profiles */ +}; +static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__profiles_data__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 1 } +}; +const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__profiles_data__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "opentelemetry.proto.profiles.v1development.ProfilesData", + "ProfilesData", + "Opentelemetry__Proto__Profiles__V1development__ProfilesData", + "opentelemetry.proto.profiles.v1development", + sizeof(Opentelemetry__Proto__Profiles__V1development__ProfilesData), + 1, + opentelemetry__proto__profiles__v1development__profiles_data__field_descriptors, + opentelemetry__proto__profiles__v1development__profiles_data__field_indices_by_name, + 1, opentelemetry__proto__profiles__v1development__profiles_data__number_ranges, + (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__profiles_data__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__resource_profiles__field_descriptors[3] = +{ + { + "resource", + 1, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_MESSAGE, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__ResourceProfiles, resource), + &opentelemetry__proto__resource__v1__resource__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "scope_profiles", + 2, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(Opentelemetry__Proto__Profiles__V1development__ResourceProfiles, n_scope_profiles), + offsetof(Opentelemetry__Proto__Profiles__V1development__ResourceProfiles, scope_profiles), + &opentelemetry__proto__profiles__v1development__scope_profiles__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "schema_url", + 3, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_STRING, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__ResourceProfiles, schema_url), + NULL, + &protobuf_c_empty_string, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned opentelemetry__proto__profiles__v1development__resource_profiles__field_indices_by_name[] = { + 0, /* field[0] = resource */ + 2, /* field[2] = schema_url */ + 1, /* field[1] = scope_profiles */ +}; +static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__resource_profiles__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 3 } +}; +const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__resource_profiles__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "opentelemetry.proto.profiles.v1development.ResourceProfiles", + "ResourceProfiles", + "Opentelemetry__Proto__Profiles__V1development__ResourceProfiles", + "opentelemetry.proto.profiles.v1development", + sizeof(Opentelemetry__Proto__Profiles__V1development__ResourceProfiles), + 3, + opentelemetry__proto__profiles__v1development__resource_profiles__field_descriptors, + opentelemetry__proto__profiles__v1development__resource_profiles__field_indices_by_name, + 1, opentelemetry__proto__profiles__v1development__resource_profiles__number_ranges, + (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__resource_profiles__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__scope_profiles__field_descriptors[3] = +{ + { + "scope", + 1, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_MESSAGE, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__ScopeProfiles, scope), + &opentelemetry__proto__common__v1__instrumentation_scope__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "profiles", + 2, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(Opentelemetry__Proto__Profiles__V1development__ScopeProfiles, n_profiles), + offsetof(Opentelemetry__Proto__Profiles__V1development__ScopeProfiles, profiles), + &opentelemetry__proto__profiles__v1development__profile_container__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "schema_url", + 3, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_STRING, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__ScopeProfiles, schema_url), + NULL, + &protobuf_c_empty_string, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned opentelemetry__proto__profiles__v1development__scope_profiles__field_indices_by_name[] = { + 1, /* field[1] = profiles */ + 2, /* field[2] = schema_url */ + 0, /* field[0] = scope */ +}; +static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__scope_profiles__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 3 } +}; +const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__scope_profiles__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "opentelemetry.proto.profiles.v1development.ScopeProfiles", + "ScopeProfiles", + "Opentelemetry__Proto__Profiles__V1development__ScopeProfiles", + "opentelemetry.proto.profiles.v1development", + sizeof(Opentelemetry__Proto__Profiles__V1development__ScopeProfiles), + 3, + opentelemetry__proto__profiles__v1development__scope_profiles__field_descriptors, + opentelemetry__proto__profiles__v1development__scope_profiles__field_indices_by_name, + 1, opentelemetry__proto__profiles__v1development__scope_profiles__number_ranges, + (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__scope_profiles__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__profile_container__field_descriptors[8] = +{ + { + "profile_id", + 1, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_BYTES, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__ProfileContainer, profile_id), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "start_time_unix_nano", + 2, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_FIXED64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__ProfileContainer, start_time_unix_nano), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "end_time_unix_nano", + 3, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_FIXED64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__ProfileContainer, end_time_unix_nano), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "attributes", + 4, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(Opentelemetry__Proto__Profiles__V1development__ProfileContainer, n_attributes), + offsetof(Opentelemetry__Proto__Profiles__V1development__ProfileContainer, attributes), + &opentelemetry__proto__common__v1__key_value__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "dropped_attributes_count", + 5, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_UINT32, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__ProfileContainer, dropped_attributes_count), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "original_payload_format", + 6, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_STRING, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__ProfileContainer, original_payload_format), + NULL, + &protobuf_c_empty_string, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "original_payload", + 7, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_BYTES, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__ProfileContainer, original_payload), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "profile", + 8, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_MESSAGE, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__ProfileContainer, profile), + &opentelemetry__proto__profiles__v1development__profile__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned opentelemetry__proto__profiles__v1development__profile_container__field_indices_by_name[] = { + 3, /* field[3] = attributes */ + 4, /* field[4] = dropped_attributes_count */ + 2, /* field[2] = end_time_unix_nano */ + 6, /* field[6] = original_payload */ + 5, /* field[5] = original_payload_format */ + 7, /* field[7] = profile */ + 0, /* field[0] = profile_id */ + 1, /* field[1] = start_time_unix_nano */ +}; +static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__profile_container__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 8 } +}; +const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__profile_container__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "opentelemetry.proto.profiles.v1development.ProfileContainer", + "ProfileContainer", + "Opentelemetry__Proto__Profiles__V1development__ProfileContainer", + "opentelemetry.proto.profiles.v1development", + sizeof(Opentelemetry__Proto__Profiles__V1development__ProfileContainer), + 8, + opentelemetry__proto__profiles__v1development__profile_container__field_descriptors, + opentelemetry__proto__profiles__v1development__profile_container__field_indices_by_name, + 1, opentelemetry__proto__profiles__v1development__profile_container__number_ranges, + (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__profile_container__init, + NULL,NULL,NULL /* reserved[123] */ +}; diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/profiles/v1development/profiles.pb-c.h b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/profiles/v1development/profiles.pb-c.h new file mode 100644 index 00000000000..cf597d6ad5b --- /dev/null +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/profiles/v1development/profiles.pb-c.h @@ -0,0 +1,290 @@ +/* Generated by the protocol buffer compiler. DO NOT EDIT! */ +/* Generated from: opentelemetry/proto/profiles/v1development/profiles.proto */ + +#ifndef PROTOBUF_C_opentelemetry_2fproto_2fprofiles_2fv1development_2fprofiles_2eproto__INCLUDED +#define PROTOBUF_C_opentelemetry_2fproto_2fprofiles_2fv1development_2fprofiles_2eproto__INCLUDED + +#include + +PROTOBUF_C__BEGIN_DECLS + +#if PROTOBUF_C_VERSION_NUMBER < 1003000 +# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. +#elif 1005000 < PROTOBUF_C_MIN_COMPILER_VERSION +# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. +#endif + +#include "opentelemetry/proto/common/v1/common.pb-c.h" +#include "opentelemetry/proto/resource/v1/resource.pb-c.h" +#include "opentelemetry/proto/profiles/v1development/pprofextended.pb-c.h" + +typedef struct Opentelemetry__Proto__Profiles__V1development__ProfilesData Opentelemetry__Proto__Profiles__V1development__ProfilesData; +typedef struct Opentelemetry__Proto__Profiles__V1development__ResourceProfiles Opentelemetry__Proto__Profiles__V1development__ResourceProfiles; +typedef struct Opentelemetry__Proto__Profiles__V1development__ScopeProfiles Opentelemetry__Proto__Profiles__V1development__ScopeProfiles; +typedef struct Opentelemetry__Proto__Profiles__V1development__ProfileContainer Opentelemetry__Proto__Profiles__V1development__ProfileContainer; + + +/* --- enums --- */ + + +/* --- messages --- */ + +/* + * ProfilesData represents the profiles data that can be stored in persistent storage, + * OR can be embedded by other protocols that transfer OTLP profiles data but do not + * implement the OTLP protocol. + * The main difference between this message and collector protocol is that + * in this message there will not be any "control" or "metadata" specific to + * OTLP protocol. + * When new fields are added into this message, the OTLP request MUST be updated + * as well. + */ +struct Opentelemetry__Proto__Profiles__V1development__ProfilesData +{ + ProtobufCMessage base; + /* + * An array of ResourceProfiles. + * For data coming from a single resource this array will typically contain + * one element. Intermediary nodes that receive data from multiple origins + * typically batch the data before forwarding further and in that case this + * array will contain multiple elements. + */ + size_t n_resource_profiles; + Opentelemetry__Proto__Profiles__V1development__ResourceProfiles **resource_profiles; +}; +#define OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__PROFILES_DATA__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__profiles__v1development__profiles_data__descriptor) \ + , 0,NULL } + + +/* + * A collection of ScopeProfiles from a Resource. + */ +struct Opentelemetry__Proto__Profiles__V1development__ResourceProfiles +{ + ProtobufCMessage base; + /* + * The resource for the profiles in this message. + * If this field is not set then no resource info is known. + */ + Opentelemetry__Proto__Resource__V1__Resource *resource; + /* + * A list of ScopeProfiles that originate from a resource. + */ + size_t n_scope_profiles; + Opentelemetry__Proto__Profiles__V1development__ScopeProfiles **scope_profiles; + /* + * The Schema URL, if known. This is the identifier of the Schema that the resource data + * is recorded in. To learn more about Schema URL see + * https://opentelemetry.io/docs/specs/otel/schemas/#schema-url + * This schema_url applies to the data in the "resource" field. It does not apply + * to the data in the "scope_profiles" field which have their own schema_url field. + */ + char *schema_url; +}; +#define OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__RESOURCE_PROFILES__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__profiles__v1development__resource_profiles__descriptor) \ + , NULL, 0,NULL, (char *)protobuf_c_empty_string } + + +/* + * A collection of ProfileContainers produced by an InstrumentationScope. + */ +struct Opentelemetry__Proto__Profiles__V1development__ScopeProfiles +{ + ProtobufCMessage base; + /* + * The instrumentation scope information for the profiles in this message. + * Semantically when InstrumentationScope isn't set, it is equivalent with + * an empty instrumentation scope name (unknown). + */ + Opentelemetry__Proto__Common__V1__InstrumentationScope *scope; + /* + * A list of ProfileContainers that originate from an instrumentation scope. + */ + size_t n_profiles; + Opentelemetry__Proto__Profiles__V1development__ProfileContainer **profiles; + /* + * The Schema URL, if known. This is the identifier of the Schema that the metric data + * is recorded in. To learn more about Schema URL see + * https://opentelemetry.io/docs/specs/otel/schemas/#schema-url + * This schema_url applies to all profiles in the "profiles" field. + */ + char *schema_url; +}; +#define OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__SCOPE_PROFILES__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__profiles__v1development__scope_profiles__descriptor) \ + , NULL, 0,NULL, (char *)protobuf_c_empty_string } + + +/* + * A ProfileContainer represents a single profile. It wraps pprof profile with OpenTelemetry specific metadata. + */ +struct Opentelemetry__Proto__Profiles__V1development__ProfileContainer +{ + ProtobufCMessage base; + /* + * A globally unique identifier for a profile. The ID is a 16-byte array. An ID with + * all zeroes is considered invalid. + * This field is required. + */ + ProtobufCBinaryData profile_id; + /* + * start_time_unix_nano is the start time of the profile. + * Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. + * This field is semantically required and it is expected that end_time >= start_time. + */ + uint64_t start_time_unix_nano; + /* + * end_time_unix_nano is the end time of the profile. + * Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. + * This field is semantically required and it is expected that end_time >= start_time. + */ + uint64_t end_time_unix_nano; + /* + * attributes is a collection of key/value pairs. Note, global attributes + * like server name can be set using the resource API. Examples of attributes: + * "/http/user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" + * "/http/server_latency": 300 + * "abc.com/myattribute": true + * "abc.com/score": 10.239 + * The OpenTelemetry API specification further restricts the allowed value types: + * https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/README.md#attribute + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). + */ + size_t n_attributes; + Opentelemetry__Proto__Common__V1__KeyValue **attributes; + /* + * dropped_attributes_count is the number of attributes that were discarded. Attributes + * can be discarded because their keys are too long or because there are too many + * attributes. If this value is 0, then no attributes were dropped. + */ + uint32_t dropped_attributes_count; + /* + * Specifies format of the original payload. Common values are defined in semantic conventions. [required if original_payload is present] + */ + char *original_payload_format; + /* + * Original payload can be stored in this field. This can be useful for users who want to get the original payload. + * Formats such as JFR are highly extensible and can contain more information than what is defined in this spec. + * Inclusion of original payload should be configurable by the user. Default behavior should be to not include the original payload. + * If the original payload is in pprof format, it SHOULD not be included in this field. + * The field is optional, however if it is present `profile` MUST be present and contain the same profiling information. + */ + ProtobufCBinaryData original_payload; + /* + * This is a reference to a pprof profile. Required, even when original_payload is present. + */ + Opentelemetry__Proto__Profiles__V1development__Profile *profile; +}; +#define OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__PROFILE_CONTAINER__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__profiles__v1development__profile_container__descriptor) \ + , {0,NULL}, 0, 0, 0,NULL, 0, (char *)protobuf_c_empty_string, {0,NULL}, NULL } + + +/* Opentelemetry__Proto__Profiles__V1development__ProfilesData methods */ +void opentelemetry__proto__profiles__v1development__profiles_data__init + (Opentelemetry__Proto__Profiles__V1development__ProfilesData *message); +size_t opentelemetry__proto__profiles__v1development__profiles_data__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__ProfilesData *message); +size_t opentelemetry__proto__profiles__v1development__profiles_data__pack + (const Opentelemetry__Proto__Profiles__V1development__ProfilesData *message, + uint8_t *out); +size_t opentelemetry__proto__profiles__v1development__profiles_data__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__ProfilesData *message, + ProtobufCBuffer *buffer); +Opentelemetry__Proto__Profiles__V1development__ProfilesData * + opentelemetry__proto__profiles__v1development__profiles_data__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void opentelemetry__proto__profiles__v1development__profiles_data__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__ProfilesData *message, + ProtobufCAllocator *allocator); +/* Opentelemetry__Proto__Profiles__V1development__ResourceProfiles methods */ +void opentelemetry__proto__profiles__v1development__resource_profiles__init + (Opentelemetry__Proto__Profiles__V1development__ResourceProfiles *message); +size_t opentelemetry__proto__profiles__v1development__resource_profiles__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__ResourceProfiles *message); +size_t opentelemetry__proto__profiles__v1development__resource_profiles__pack + (const Opentelemetry__Proto__Profiles__V1development__ResourceProfiles *message, + uint8_t *out); +size_t opentelemetry__proto__profiles__v1development__resource_profiles__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__ResourceProfiles *message, + ProtobufCBuffer *buffer); +Opentelemetry__Proto__Profiles__V1development__ResourceProfiles * + opentelemetry__proto__profiles__v1development__resource_profiles__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void opentelemetry__proto__profiles__v1development__resource_profiles__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__ResourceProfiles *message, + ProtobufCAllocator *allocator); +/* Opentelemetry__Proto__Profiles__V1development__ScopeProfiles methods */ +void opentelemetry__proto__profiles__v1development__scope_profiles__init + (Opentelemetry__Proto__Profiles__V1development__ScopeProfiles *message); +size_t opentelemetry__proto__profiles__v1development__scope_profiles__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__ScopeProfiles *message); +size_t opentelemetry__proto__profiles__v1development__scope_profiles__pack + (const Opentelemetry__Proto__Profiles__V1development__ScopeProfiles *message, + uint8_t *out); +size_t opentelemetry__proto__profiles__v1development__scope_profiles__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__ScopeProfiles *message, + ProtobufCBuffer *buffer); +Opentelemetry__Proto__Profiles__V1development__ScopeProfiles * + opentelemetry__proto__profiles__v1development__scope_profiles__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void opentelemetry__proto__profiles__v1development__scope_profiles__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__ScopeProfiles *message, + ProtobufCAllocator *allocator); +/* Opentelemetry__Proto__Profiles__V1development__ProfileContainer methods */ +void opentelemetry__proto__profiles__v1development__profile_container__init + (Opentelemetry__Proto__Profiles__V1development__ProfileContainer *message); +size_t opentelemetry__proto__profiles__v1development__profile_container__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__ProfileContainer *message); +size_t opentelemetry__proto__profiles__v1development__profile_container__pack + (const Opentelemetry__Proto__Profiles__V1development__ProfileContainer *message, + uint8_t *out); +size_t opentelemetry__proto__profiles__v1development__profile_container__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__ProfileContainer *message, + ProtobufCBuffer *buffer); +Opentelemetry__Proto__Profiles__V1development__ProfileContainer * + opentelemetry__proto__profiles__v1development__profile_container__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void opentelemetry__proto__profiles__v1development__profile_container__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__ProfileContainer *message, + ProtobufCAllocator *allocator); +/* --- per-message closures --- */ + +typedef void (*Opentelemetry__Proto__Profiles__V1development__ProfilesData_Closure) + (const Opentelemetry__Proto__Profiles__V1development__ProfilesData *message, + void *closure_data); +typedef void (*Opentelemetry__Proto__Profiles__V1development__ResourceProfiles_Closure) + (const Opentelemetry__Proto__Profiles__V1development__ResourceProfiles *message, + void *closure_data); +typedef void (*Opentelemetry__Proto__Profiles__V1development__ScopeProfiles_Closure) + (const Opentelemetry__Proto__Profiles__V1development__ScopeProfiles *message, + void *closure_data); +typedef void (*Opentelemetry__Proto__Profiles__V1development__ProfileContainer_Closure) + (const Opentelemetry__Proto__Profiles__V1development__ProfileContainer *message, + void *closure_data); + +/* --- services --- */ + + +/* --- descriptors --- */ + +extern const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__profiles_data__descriptor; +extern const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__resource_profiles__descriptor; +extern const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__scope_profiles__descriptor; +extern const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__profile_container__descriptor; + +PROTOBUF_C__END_DECLS + + +#endif /* PROTOBUF_C_opentelemetry_2fproto_2fprofiles_2fv1development_2fprofiles_2eproto__INCLUDED */ diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/resource/v1/resource.pb-c.h b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/resource/v1/resource.pb-c.h index f58b87f02f5..7def59296d0 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/resource/v1/resource.pb-c.h +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/resource/v1/resource.pb-c.h @@ -10,7 +10,7 @@ PROTOBUF_C__BEGIN_DECLS #if PROTOBUF_C_VERSION_NUMBER < 1003000 # error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. -#elif 1004001 < PROTOBUF_C_MIN_COMPILER_VERSION +#elif 1005000 < PROTOBUF_C_MIN_COMPILER_VERSION # error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. #endif diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/trace/v1/trace.pb-c.c b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/trace/v1/trace.pb-c.c index 56c2f173a4c..3a7f82cfe52 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/trace/v1/trace.pb-c.c +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/trace/v1/trace.pb-c.c @@ -487,7 +487,7 @@ const ProtobufCMessageDescriptor opentelemetry__proto__trace__v1__span__event__d (ProtobufCMessageInit) opentelemetry__proto__trace__v1__span__event__init, NULL,NULL,NULL /* reserved[123] */ }; -static const ProtobufCFieldDescriptor opentelemetry__proto__trace__v1__span__link__field_descriptors[5] = +static const ProtobufCFieldDescriptor opentelemetry__proto__trace__v1__span__link__field_descriptors[6] = { { "trace_id", @@ -549,10 +549,23 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__trace__v1__span__lin 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, + { + "flags", + 6, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_FIXED32, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Trace__V1__Span__Link, flags), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, }; static const unsigned opentelemetry__proto__trace__v1__span__link__field_indices_by_name[] = { 3, /* field[3] = attributes */ 4, /* field[4] = dropped_attributes_count */ + 5, /* field[5] = flags */ 1, /* field[1] = span_id */ 0, /* field[0] = trace_id */ 2, /* field[2] = trace_state */ @@ -560,7 +573,7 @@ static const unsigned opentelemetry__proto__trace__v1__span__link__field_indices static const ProtobufCIntRange opentelemetry__proto__trace__v1__span__link__number_ranges[1 + 1] = { { 1, 0 }, - { 0, 5 } + { 0, 6 } }; const ProtobufCMessageDescriptor opentelemetry__proto__trace__v1__span__link__descriptor = { @@ -570,7 +583,7 @@ const ProtobufCMessageDescriptor opentelemetry__proto__trace__v1__span__link__de "Opentelemetry__Proto__Trace__V1__Span__Link", "opentelemetry.proto.trace.v1", sizeof(Opentelemetry__Proto__Trace__V1__Span__Link), - 5, + 6, opentelemetry__proto__trace__v1__span__link__field_descriptors, opentelemetry__proto__trace__v1__span__link__field_indices_by_name, 1, opentelemetry__proto__trace__v1__span__link__number_ranges, @@ -613,7 +626,7 @@ const ProtobufCEnumDescriptor opentelemetry__proto__trace__v1__span__span_kind__ opentelemetry__proto__trace__v1__span__span_kind__value_ranges, NULL,NULL,NULL,NULL /* reserved[1234] */ }; -static const ProtobufCFieldDescriptor opentelemetry__proto__trace__v1__span__field_descriptors[15] = +static const ProtobufCFieldDescriptor opentelemetry__proto__trace__v1__span__field_descriptors[16] = { { "trace_id", @@ -795,6 +808,18 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__trace__v1__span__fie 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, + { + "flags", + 16, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_FIXED32, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Trace__V1__Span, flags), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, }; static const unsigned opentelemetry__proto__trace__v1__span__field_indices_by_name[] = { 8, /* field[8] = attributes */ @@ -803,6 +828,7 @@ static const unsigned opentelemetry__proto__trace__v1__span__field_indices_by_na 13, /* field[13] = dropped_links_count */ 7, /* field[7] = end_time_unix_nano */ 10, /* field[10] = events */ + 15, /* field[15] = flags */ 5, /* field[5] = kind */ 12, /* field[12] = links */ 4, /* field[4] = name */ @@ -816,7 +842,7 @@ static const unsigned opentelemetry__proto__trace__v1__span__field_indices_by_na static const ProtobufCIntRange opentelemetry__proto__trace__v1__span__number_ranges[1 + 1] = { { 1, 0 }, - { 0, 15 } + { 0, 16 } }; const ProtobufCMessageDescriptor opentelemetry__proto__trace__v1__span__descriptor = { @@ -826,7 +852,7 @@ const ProtobufCMessageDescriptor opentelemetry__proto__trace__v1__span__descript "Opentelemetry__Proto__Trace__V1__Span", "opentelemetry.proto.trace.v1", sizeof(Opentelemetry__Proto__Trace__V1__Span), - 15, + 16, opentelemetry__proto__trace__v1__span__field_descriptors, opentelemetry__proto__trace__v1__span__field_indices_by_name, 1, opentelemetry__proto__trace__v1__span__number_ranges, @@ -914,3 +940,35 @@ const ProtobufCMessageDescriptor opentelemetry__proto__trace__v1__status__descri (ProtobufCMessageInit) opentelemetry__proto__trace__v1__status__init, NULL,NULL,NULL /* reserved[123] */ }; +static const ProtobufCEnumValue opentelemetry__proto__trace__v1__span_flags__enum_values_by_number[4] = +{ + { "SPAN_FLAGS_DO_NOT_USE", "OPENTELEMETRY__PROTO__TRACE__V1__SPAN_FLAGS__SPAN_FLAGS_DO_NOT_USE", 0 }, + { "SPAN_FLAGS_TRACE_FLAGS_MASK", "OPENTELEMETRY__PROTO__TRACE__V1__SPAN_FLAGS__SPAN_FLAGS_TRACE_FLAGS_MASK", 255 }, + { "SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK", "OPENTELEMETRY__PROTO__TRACE__V1__SPAN_FLAGS__SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK", 256 }, + { "SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK", "OPENTELEMETRY__PROTO__TRACE__V1__SPAN_FLAGS__SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK", 512 }, +}; +static const ProtobufCIntRange opentelemetry__proto__trace__v1__span_flags__value_ranges[] = { +{0, 0},{255, 1},{512, 3},{0, 4} +}; +static const ProtobufCEnumValueIndex opentelemetry__proto__trace__v1__span_flags__enum_values_by_name[4] = +{ + { "SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK", 2 }, + { "SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK", 3 }, + { "SPAN_FLAGS_DO_NOT_USE", 0 }, + { "SPAN_FLAGS_TRACE_FLAGS_MASK", 1 }, +}; +const ProtobufCEnumDescriptor opentelemetry__proto__trace__v1__span_flags__descriptor = +{ + PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, + "opentelemetry.proto.trace.v1.SpanFlags", + "SpanFlags", + "Opentelemetry__Proto__Trace__V1__SpanFlags", + "opentelemetry.proto.trace.v1", + 4, + opentelemetry__proto__trace__v1__span_flags__enum_values_by_number, + 4, + opentelemetry__proto__trace__v1__span_flags__enum_values_by_name, + 3, + opentelemetry__proto__trace__v1__span_flags__value_ranges, + NULL,NULL,NULL,NULL /* reserved[1234] */ +}; diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/trace/v1/trace.pb-c.h b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/trace/v1/trace.pb-c.h index cfb6ee9b789..b0d699f4af7 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/trace/v1/trace.pb-c.h +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/trace/v1/trace.pb-c.h @@ -10,7 +10,7 @@ PROTOBUF_C__BEGIN_DECLS #if PROTOBUF_C_VERSION_NUMBER < 1003000 # error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. -#elif 1004001 < PROTOBUF_C_MIN_COMPILER_VERSION +#elif 1005000 < PROTOBUF_C_MIN_COMPILER_VERSION # error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. #endif @@ -87,6 +87,38 @@ typedef enum _Opentelemetry__Proto__Trace__V1__Status__StatusCode { OPENTELEMETRY__PROTO__TRACE__V1__STATUS__STATUS_CODE__STATUS_CODE_ERROR = 2 PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(OPENTELEMETRY__PROTO__TRACE__V1__STATUS__STATUS_CODE) } Opentelemetry__Proto__Trace__V1__Status__StatusCode; +/* + * SpanFlags represents constants used to interpret the + * Span.flags field, which is protobuf 'fixed32' type and is to + * be used as bit-fields. Each non-zero value defined in this enum is + * a bit-mask. To extract the bit-field, for example, use an + * expression like: + * (span.flags & SPAN_FLAGS_TRACE_FLAGS_MASK) + * See https://www.w3.org/TR/trace-context-2/#trace-flags for the flag definitions. + * Note that Span flags were introduced in version 1.1 of the + * OpenTelemetry protocol. Older Span producers do not set this + * field, consequently consumers should not rely on the absence of a + * particular flag bit to indicate the presence of a particular feature. + */ +typedef enum _Opentelemetry__Proto__Trace__V1__SpanFlags { + /* + * The zero value for the enum. Should not be used for comparisons. + * Instead use bitwise "and" with the appropriate mask as shown above. + */ + OPENTELEMETRY__PROTO__TRACE__V1__SPAN_FLAGS__SPAN_FLAGS_DO_NOT_USE = 0, + /* + * Bits 0-7 are used for trace flags. + */ + OPENTELEMETRY__PROTO__TRACE__V1__SPAN_FLAGS__SPAN_FLAGS_TRACE_FLAGS_MASK = 255, + /* + * Bits 8 and 9 are used to indicate that the parent span or link span is remote. + * Bit 8 (`HAS_IS_REMOTE`) indicates whether the value is known. + * Bit 9 (`IS_REMOTE`) indicates whether the span or link is remote. + */ + OPENTELEMETRY__PROTO__TRACE__V1__SPAN_FLAGS__SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK = 256, + OPENTELEMETRY__PROTO__TRACE__V1__SPAN_FLAGS__SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK = 512 + PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(OPENTELEMETRY__PROTO__TRACE__V1__SPAN_FLAGS) +} Opentelemetry__Proto__Trace__V1__SpanFlags; /* --- messages --- */ @@ -135,6 +167,9 @@ struct Opentelemetry__Proto__Trace__V1__ResourceSpans size_t n_scope_spans; Opentelemetry__Proto__Trace__V1__ScopeSpans **scope_spans; /* + * The Schema URL, if known. This is the identifier of the Schema that the resource data + * is recorded in. To learn more about Schema URL see + * https://opentelemetry.io/docs/specs/otel/schemas/#schema-url * This schema_url applies to the data in the "resource" field. It does not apply * to the data in the "scope_spans" field which have their own schema_url field. */ @@ -163,6 +198,9 @@ struct Opentelemetry__Proto__Trace__V1__ScopeSpans size_t n_spans; Opentelemetry__Proto__Trace__V1__Span **spans; /* + * The Schema URL, if known. This is the identifier of the Schema that the span data + * is recorded in. To learn more about Schema URL see + * https://opentelemetry.io/docs/specs/otel/schemas/#schema-url * This schema_url applies to all spans and span events in the "spans" field. */ char *schema_url; @@ -240,10 +278,25 @@ struct Opentelemetry__Proto__Trace__V1__Span__Link * then no attributes were dropped. */ uint32_t dropped_attributes_count; + /* + * Flags, a bit field. + * Bits 0-7 (8 least significant bits) are the trace flags as defined in W3C Trace + * Context specification. To read the 8-bit W3C trace flag, use + * `flags & SPAN_FLAGS_TRACE_FLAGS_MASK`. + * See https://www.w3.org/TR/trace-context-2/#trace-flags for the flag definitions. + * Bits 8 and 9 represent the 3 states of whether the link is remote. + * The states are (unknown, is not remote, is remote). + * To read whether the value is known, use `(flags & SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK) != 0`. + * To read whether the link is remote, use `(flags & SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK) != 0`. + * Readers MUST NOT assume that bits 10-31 (22 most significant bits) will be zero. + * When creating new spans, bits 10-31 (most-significant 22-bits) MUST be zero. + * [Optional]. + */ + uint32_t flags; }; #define OPENTELEMETRY__PROTO__TRACE__V1__SPAN__LINK__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__trace__v1__span__link__descriptor) \ - , {0,NULL}, {0,NULL}, (char *)protobuf_c_empty_string, 0,NULL, 0 } + , {0,NULL}, {0,NULL}, (char *)protobuf_c_empty_string, 0,NULL, 0, 0 } /* @@ -255,19 +308,17 @@ struct Opentelemetry__Proto__Trace__V1__Span ProtobufCMessage base; /* * A unique identifier for a trace. All spans from the same trace share - * the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes - * is considered invalid. - * This field is semantically required. Receiver should generate new - * random trace_id if empty or invalid trace_id was received. + * the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes OR + * of length other than 16 bytes is considered invalid (empty string in OTLP/JSON + * is zero-length and thus is also invalid). * This field is required. */ ProtobufCBinaryData trace_id; /* * A unique identifier for a span within a trace, assigned when the span - * is created. The ID is an 8-byte array. An ID with all zeroes is considered - * invalid. - * This field is semantically required. Receiver should generate new - * random span_id if empty or invalid span_id was received. + * is created. The ID is an 8-byte array. An ID with all zeroes OR of length + * other than 8 bytes is considered invalid (empty string in OTLP/JSON + * is zero-length and thus is also invalid). * This field is required. */ ProtobufCBinaryData span_id; @@ -282,6 +333,25 @@ struct Opentelemetry__Proto__Trace__V1__Span * field must be empty. The ID is an 8-byte array. */ ProtobufCBinaryData parent_span_id; + /* + * Flags, a bit field. + * Bits 0-7 (8 least significant bits) are the trace flags as defined in W3C Trace + * Context specification. To read the 8-bit W3C trace flag, use + * `flags & SPAN_FLAGS_TRACE_FLAGS_MASK`. + * See https://www.w3.org/TR/trace-context-2/#trace-flags for the flag definitions. + * Bits 8 and 9 represent the 3 states of whether a span's parent + * is remote. The states are (unknown, is not remote, is remote). + * To read whether the value is known, use `(flags & SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK) != 0`. + * To read whether the span is remote, use `(flags & SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK) != 0`. + * When creating span messages, if the message is logically forwarded from another source + * with an equivalent flags fields (i.e., usually another OTLP span message), the field SHOULD + * be copied as-is. If creating from a source that does not have an equivalent flags field + * (such as a runtime representation of an OpenTelemetry span), the high 22 bits MUST + * be set to zero. + * Readers MUST NOT assume that bits 10-31 (22 most significant bits) will be zero. + * [Optional]. + */ + uint32_t flags; /* * A description of the span's operation. * For example, the name can be a qualified method name or a file name @@ -320,8 +390,8 @@ struct Opentelemetry__Proto__Trace__V1__Span * like server name can be set using the resource API. Examples of attributes: * "/http/user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" * "/http/server_latency": 300 - * "abc.com/myattribute": true - * "abc.com/score": 10.239 + * "example.com/myattribute": true + * "example.com/score": 10.239 * The OpenTelemetry API specification further restricts the allowed value types: * https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/README.md#attribute * Attribute keys MUST be unique (it is not allowed to have more than one @@ -364,7 +434,7 @@ struct Opentelemetry__Proto__Trace__V1__Span }; #define OPENTELEMETRY__PROTO__TRACE__V1__SPAN__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__trace__v1__span__descriptor) \ - , {0,NULL}, {0,NULL}, (char *)protobuf_c_empty_string, {0,NULL}, (char *)protobuf_c_empty_string, OPENTELEMETRY__PROTO__TRACE__V1__SPAN__SPAN_KIND__SPAN_KIND_UNSPECIFIED, 0, 0, 0,NULL, 0, 0,NULL, 0, 0,NULL, 0, NULL } + , {0,NULL}, {0,NULL}, (char *)protobuf_c_empty_string, {0,NULL}, 0, (char *)protobuf_c_empty_string, OPENTELEMETRY__PROTO__TRACE__V1__SPAN__SPAN_KIND__SPAN_KIND_UNSPECIFIED, 0, 0, 0,NULL, 0, 0,NULL, 0, 0,NULL, 0, NULL } /* @@ -518,6 +588,7 @@ typedef void (*Opentelemetry__Proto__Trace__V1__Status_Closure) /* --- descriptors --- */ +extern const ProtobufCEnumDescriptor opentelemetry__proto__trace__v1__span_flags__descriptor; extern const ProtobufCMessageDescriptor opentelemetry__proto__trace__v1__traces_data__descriptor; extern const ProtobufCMessageDescriptor opentelemetry__proto__trace__v1__resource_spans__descriptor; extern const ProtobufCMessageDescriptor opentelemetry__proto__trace__v1__scope_spans__descriptor; diff --git a/lib/fluent-otel-proto/proto_c/protobuf-c/protobuf-c.c b/lib/fluent-otel-proto/proto_c/protobuf-c/protobuf-c.c index 0606cf677da..776ee4fb594 100644 --- a/lib/fluent-otel-proto/proto_c/protobuf-c/protobuf-c.c +++ b/lib/fluent-otel-proto/proto_c/protobuf-c/protobuf-c.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2022, Dave Benson and the protobuf-c authors. + * Copyright (c) 2008-2023, Dave Benson and the protobuf-c authors. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1888,7 +1888,6 @@ pack_buffer_packed_payload(const ProtobufCFieldDescriptor *field, for (i = 0; i < count; i++) { unsigned len = boolean_pack(((protobuf_c_boolean *) array)[i], scratch); buffer->append(buffer, len, scratch); - rv += len; } return count; default: @@ -1923,6 +1922,7 @@ repeated_field_pack_to_buffer(const ProtobufCFieldDescriptor *field, buffer->append(buffer, rv, scratch); tmp = pack_buffer_packed_payload(field, count, array, buffer); assert(tmp == payload_len); + (void)tmp; return rv + payload_len; } else { size_t siz; @@ -2556,7 +2556,7 @@ parse_required_member(ScannedMember *scanned_member, if (maybe_clear && *pstr != NULL) { const char *def = scanned_member->field->default_value; - if (*pstr != NULL && *pstr != def) + if (*pstr != def) do_free(allocator, *pstr); } *pstr = do_alloc(allocator, len - pref_len + 1); diff --git a/lib/fluent-otel-proto/proto_c/protobuf-c/protobuf-c.h b/lib/fluent-otel-proto/proto_c/protobuf-c/protobuf-c.h index 5fa52da626a..a0625117e8d 100755 --- a/lib/fluent-otel-proto/proto_c/protobuf-c/protobuf-c.h +++ b/lib/fluent-otel-proto/proto_c/protobuf-c/protobuf-c.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2022, Dave Benson and the protobuf-c authors. + * Copyright (c) 2008-2023, Dave Benson and the protobuf-c authors. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -794,13 +794,13 @@ protobuf_c_version_number(void); * The version of the protobuf-c headers, represented as a string using the same * format as protobuf_c_version(). */ -#define PROTOBUF_C_VERSION "1.4.1" +#define PROTOBUF_C_VERSION "1.5.0" /** * The version of the protobuf-c headers, represented as an integer using the * same format as protobuf_c_version_number(). */ -#define PROTOBUF_C_VERSION_NUMBER 1004001 +#define PROTOBUF_C_VERSION_NUMBER 1005000 /** * The minimum protoc-c version which works with the current version of the diff --git a/lib/fluent-otel-proto/src/CMakeLists.txt b/lib/fluent-otel-proto/src/CMakeLists.txt index 4b85b8347c8..2ace3ccda86 100644 --- a/lib/fluent-otel-proto/src/CMakeLists.txt +++ b/lib/fluent-otel-proto/src/CMakeLists.txt @@ -34,4 +34,9 @@ if (FLUENT_PROTO_METRICS) set(src ${src} ${OTEL_C_FILES}/proto/collector/metrics/v1/metrics_service.pb-c.c) endif() +if (FLUENT_PROTO_PROFILES) + set(src ${src} ${OTEL_C_FILES}/proto/profiles/v1development/profiles.pb-c.c) + set(src ${src} ${OTEL_C_FILES}/proto/profiles/v1development/pprofextended.pb-c.c) +endif() + add_library(fluent-otel-proto STATIC ${src}) diff --git a/lib/fluent-otel-proto/src/fluent-otel.c b/lib/fluent-otel-proto/src/fluent-otel.c index 49ff9a0998b..3fdf7b8335d 100644 --- a/lib/fluent-otel-proto/src/fluent-otel.c +++ b/lib/fluent-otel-proto/src/fluent-otel.c @@ -59,4 +59,10 @@ void fluent_otel_info() printf("%10s", "not found (enable it with -DFLUENT_PROTO_METRICS)\n"); #endif + printf("- opentelemetry proto 'profiles': "); +#ifdef FLUENT_OTEL_HAVE_PROFILES + printf("%10s", "found\n"); +#else + printf("%10s", "not found (enable it with -DFLUENT_PROTO_PROFILES)\n"); +#endif } From f4e318f53d063fc20e20e0ededdd0a496f9b8a9d Mon Sep 17 00:00:00 2001 From: Phillip Whelan Date: Thu, 26 Sep 2024 16:07:57 -0300 Subject: [PATCH 191/295] reload: do not call flb_stop when flb_start fails to avoid crash on RHEL/CentOS. Signed-off-by: Phillip Whelan --- src/flb_reload.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/flb_reload.c b/src/flb_reload.c index b66a4c80b3b..2f156bfdcf2 100644 --- a/src/flb_reload.c +++ b/src/flb_reload.c @@ -475,7 +475,6 @@ int flb_reload(flb_ctx_t *ctx, struct flb_cf *cf_opts) flb_sds_destroy(file); } flb_cf_destroy(new_cf); - flb_stop(new_ctx); flb_destroy(new_ctx); flb_error("[reload] reloaded config is invalid. Reloading is halted"); @@ -488,7 +487,6 @@ int flb_reload(flb_ctx_t *ctx, struct flb_cf *cf_opts) if (ret != 0) { flb_sds_destroy(file); flb_cf_destroy(new_cf); - flb_stop(new_ctx); flb_destroy(new_ctx); flb_error("[reload] reloaded config format is invalid. Reloading is halted"); @@ -501,7 +499,6 @@ int flb_reload(flb_ctx_t *ctx, struct flb_cf *cf_opts) if (ret != 0) { flb_sds_destroy(file); flb_cf_destroy(new_cf); - flb_stop(new_ctx); flb_destroy(new_ctx); flb_error("[reload] reloaded config is invalid. Reloading is halted"); @@ -530,7 +527,6 @@ int flb_reload(flb_ctx_t *ctx, struct flb_cf *cf_opts) ret = flb_start(new_ctx); if (ret != 0) { - flb_stop(new_ctx); flb_destroy(new_ctx); flb_error("[reload] loaded configuration contains error(s). Reloading is aborted"); From b12450a4437c16ac314650d175a795ba2f85026a Mon Sep 17 00:00:00 2001 From: lecaros Date: Mon, 2 Sep 2024 14:49:21 -0400 Subject: [PATCH 192/295] upstream: remove call to flb_errno(). The error is displayed by flb_utils_proxy_url_split() Signed-off-by: lecaros --- src/flb_upstream.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/flb_upstream.c b/src/flb_upstream.c index c172245813c..b68a5d8c876 100644 --- a/src/flb_upstream.c +++ b/src/flb_upstream.c @@ -290,7 +290,6 @@ struct flb_upstream *flb_upstream_create(struct flb_config *config, &proxy_username, &proxy_password, &proxy_host, &proxy_port); if (ret == -1) { - flb_errno(); flb_free(u); return NULL; } From 73259dc6e2bd93743d4213100581bd1c83396163 Mon Sep 17 00:00:00 2001 From: lecaros Date: Mon, 2 Sep 2024 14:51:54 -0400 Subject: [PATCH 193/295] utils: improve error messaging inside the flb_utils_proxy_url_split() Signed-off-by: lecaros --- src/flb_utils.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/flb_utils.c b/src/flb_utils.c index 37e89d28a4f..588136ccc1e 100644 --- a/src/flb_utils.c +++ b/src/flb_utils.c @@ -1128,7 +1128,7 @@ int flb_utils_url_split(const char *in_url, char **out_protocol, /* * flb_utils_proxy_url_split parses a proxy's information from a http_proxy URL. - * The URL is in the form like `http://username:password@myproxy.com:8080`. + * The URL is in the form like `http://[username:password@]myproxy.com:8080`. * Note: currently only HTTP is supported. */ int flb_utils_proxy_url_split(const char *in_url, char **out_protocol, @@ -1147,9 +1147,11 @@ int flb_utils_proxy_url_split(const char *in_url, char **out_protocol, /* Parse protocol */ proto_sep = strstr(in_url, "://"); if (!proto_sep) { + flb_error("HTTP_PROXY variable must be set in the form of 'http://[username:password@]host:port'"); return -1; } if (proto_sep == in_url) { + flb_error("HTTP_PROXY variable must be set in the form of 'http://[username:password@]host:port'"); return -1; } @@ -1160,6 +1162,7 @@ int flb_utils_proxy_url_split(const char *in_url, char **out_protocol, } /* Only HTTP proxy is supported for now. */ if (strcmp(protocol, "http") != 0) { + flb_error("only HTTP proxy is supported."); flb_free(protocol); return -1; } From ff8803f050bd2a7cfe9883676ac3b7ab7a829744 Mon Sep 17 00:00:00 2001 From: lecaros Date: Mon, 2 Sep 2024 17:00:45 -0400 Subject: [PATCH 194/295] utils: fix typos Signed-off-by: lecaros --- src/flb_utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/flb_utils.c b/src/flb_utils.c index 588136ccc1e..4a3ba02ad47 100644 --- a/src/flb_utils.c +++ b/src/flb_utils.c @@ -758,7 +758,7 @@ static inline void encoded_to_buf(char *out, const char *in, int len) /* * Write string pointed by 'str' to the destination buffer 'buf'. It's make sure - * to escape sepecial characters and convert utf-8 byte characters to string + * to escape special characters and convert utf-8 byte characters to string * representation. */ int flb_utils_write_str(char *buf, int *off, size_t size, @@ -1170,10 +1170,10 @@ int flb_utils_proxy_url_split(const char *in_url, char **out_protocol, /* Advance position after protocol */ proto_sep += 3; - /* Seperate `username:password` and `host:port` */ + /* Separate `username:password` and `host:port` */ at_sep = strrchr(proto_sep, '@'); if (at_sep) { - /* Parse username:passwrod part. */ + /* Parse username:password part. */ tmp = strchr(proto_sep, ':'); if (!tmp) { flb_free(protocol); From d35d71c790f9984303d578fb67349e2ff67aa8f3 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 16 Sep 2024 13:07:04 -0600 Subject: [PATCH 195/295] sched: add coroutine support to timer callback Signed-off-by: Eduardo Silva --- include/fluent-bit/flb_scheduler.h | 142 ++++++++++++++++- src/flb_scheduler.c | 237 ++++++++++++++++++++++++++++- 2 files changed, 366 insertions(+), 13 deletions(-) diff --git a/include/fluent-bit/flb_scheduler.h b/include/fluent-bit/flb_scheduler.h index 52c72c019d3..71213b100de 100644 --- a/include/fluent-bit/flb_scheduler.h +++ b/include/fluent-bit/flb_scheduler.h @@ -31,10 +31,13 @@ #define FLB_SCHED_REQUEST_FRAME 10 /* Timer types */ -#define FLB_SCHED_TIMER_REQUEST 1 /* timerfd */ -#define FLB_SCHED_TIMER_FRAME 2 /* timer frame checker */ -#define FLB_SCHED_TIMER_CB_ONESHOT 3 /* one-shot callback timer */ -#define FLB_SCHED_TIMER_CB_PERM 4 /* permanent callback timer */ +#define FLB_SCHED_TIMER_REQUEST 1 /* timerfd */ +#define FLB_SCHED_TIMER_FRAME 2 /* timer frame checker */ +#define FLB_SCHED_TIMER_CB_ONESHOT 3 /* one-shot callback timer */ +#define FLB_SCHED_TIMER_CB_PERM 4 /* permanent callback timer */ + +/* notifications through channels */ +#define FLB_SCHED_TIMER_CORO_RETURN 1 struct flb_sched; @@ -50,6 +53,7 @@ struct flb_sched_timer { struct mk_event event; int active; int type; + int coro; void *data; struct flb_sched *sched; @@ -58,9 +62,11 @@ struct flb_sched_timer { * * - timer_fd = timer file descriptor * - cb = callback to be triggerd upon expiration + * - cb_coroutine_wrapper = coroutine wrapper for the callback */ int timer_fd; void (*cb)(struct flb_config *, void *); + void (*cb_coroutine_wrapper)(struct flb_config *, void *); /* Parent context */ struct flb_config *config; @@ -81,6 +87,7 @@ struct flb_sched_request { /* Scheduler context */ struct flb_sched { + struct mk_event event; /* event context to associate events */ /* * Scheduler lists: @@ -112,13 +119,27 @@ struct flb_sched { */ struct mk_list timers_drop; + /* Linked list of timers*/ + struct cfl_list timer_coro_list; + struct cfl_list timer_coro_list_drop; + /* Frame timer context */ flb_pipefd_t frame_fd; struct mk_event_loop *evl; struct flb_config *config; + + /* + * Every scheduler context have it own file descriptor to receive + * custom notifications from other scheduler components. The primary use + * case is the use of timers running under a co-routine that needs to + * be handled in active event loop. + */ + flb_pipefd_t ch_events[2]; }; + + int flb_sched_request_create(struct flb_config *config, void *data, int tries); int flb_sched_request_destroy(struct flb_sched_request *req); @@ -137,11 +158,20 @@ int flb_sched_request_invalidate(struct flb_config *config, void *data); int flb_sched_timer_cb_create(struct flb_sched *sched, int type, int ms, void (*cb)(struct flb_config *, void *), void *data, struct flb_sched_timer **out_timer); +int flb_sched_timer_coro_cb_create(struct flb_sched *sched, int type, int64_t ms, + void (*cb)(struct flb_config *, void *), + void *data, struct flb_sched_timer **out_timer); + +struct flb_sched_timer_coro *flb_sched_timer_coro_create(struct flb_sched_timer *timer, + struct flb_config *config, + void *data); +int flb_sched_timer_coro_cleanup(struct flb_sched *sched); + int flb_sched_timer_cb_disable(struct flb_sched_timer *timer); int flb_sched_timer_cb_destroy(struct flb_sched_timer *timer); void flb_sched_timer_invalidate(struct flb_sched_timer *timer); int flb_sched_timer_cleanup(struct flb_sched *sched); -int flb_sched_retry_now(struct flb_config *config, +int flb_sched_retry_now(struct flb_config *config, struct flb_task_retry *retry); /* Sched context api for multithread environment */ @@ -149,4 +179,106 @@ void flb_sched_ctx_init(); struct flb_sched *flb_sched_ctx_get(); void flb_sched_ctx_set(struct flb_sched *sched); + +struct flb_sched_timer_coro { + uint32_t id; + struct flb_sched_timer *timer; + struct flb_config *config; + struct flb_coro *coro; + void *data; + + /* link to sched->timer_coro_list */ + struct cfl_list _head; +}; + +/* parameter for timer callback running under a co-routine */ +struct flb_sched_timer_coro_cb_params { + struct flb_sched_timer_coro *stc; + struct flb_config *config; + void *data; + struct flb_coro *coro; +}; + +extern FLB_TLS_DEFINE(struct flb_sched_timer_cb_coro_params, sched_timer_coro_cb_params); + + +struct flb_timer_cb_coro_params { + struct flb_config *config; + void *data; +}; + + +static FLB_INLINE void flb_sched_timer_cb_coro_return() +{ + int n; + uint64_t val; + struct flb_coro *coro; + struct flb_sched *sched; + struct flb_sched_timer_coro *stc; + + coro = flb_coro_get(); + + sched = flb_sched_ctx_get(); + if (!sched) { + flb_error("[sched] invalid scheduler context"); + return; + } + + stc = (struct flb_sched_timer_coro *) coro->data; + if (!stc) { + flb_error("[sched] invalid timer coro context"); + return; + } + + val = FLB_BITS_U64_SET(FLB_SCHED_TIMER_CORO_RETURN, stc->id); + n = flb_pipe_w(sched->ch_events[1], &val, sizeof(val)); + if (n == -1) { + flb_errno(); + } + + flb_coro_yield(coro, FLB_TRUE); +} + +static FLB_INLINE void sched_timer_cb_params_set(struct flb_sched_timer_coro *stc, + struct flb_coro *coro, struct flb_config *config, void *data) +{ + struct flb_sched_timer_coro_cb_params *params; + + params = (struct flb_sched_timer_coro_cb_params *) FLB_TLS_GET(sched_timer_coro_cb_params); + if (!params) { + params = flb_malloc(sizeof(struct flb_sched_timer_coro_cb_params)); + if (!params) { + flb_errno(); + return; + } + } + + params->stc = stc; + params->config = config; + params->data = data; + params->coro = coro; + + FLB_TLS_SET(sched_timer_coro_cb_params, params); + co_switch(coro->callee); +} + +static FLB_INLINE void sched_timer_coro_cb_run(void) +{ + struct flb_coro *coro; + struct flb_sched_timer *timer; + struct flb_sched_timer_coro_cb_params *params; + + params = (struct flb_sched_timer_coro_cb_params *) FLB_TLS_GET(sched_timer_coro_cb_params); + if (!params) { + return; + } + + coro = params->coro; + + co_switch(coro->caller); + + timer = params->stc->timer; + timer->cb(params->config, params->data); +} + #endif diff --git a/src/flb_scheduler.c b/src/flb_scheduler.c index 4bc88c272c1..8dab1fe3222 100644 --- a/src/flb_scheduler.c +++ b/src/flb_scheduler.c @@ -31,10 +31,12 @@ #include FLB_TLS_DEFINE(struct flb_sched, flb_sched_ctx); +FLB_TLS_DEFINE(struct flb_sched_timer_cb_params, sched_timer_coro_cb_params); void flb_sched_ctx_init() { FLB_TLS_INIT(flb_sched_ctx); + FLB_TLS_INIT(sched_timer_coro_cb_params); } struct flb_sched *flb_sched_ctx_get() @@ -393,7 +395,7 @@ int flb_sched_request_invalidate(struct flb_config *config, void *data) * * If we are NOT using kequeue, just read(2) the byte. */ -static inline int timer_consume_byte(int fd) +static inline int event_fd_consume_byte(int fd) { #ifndef FLB_EVENT_LOOP_KQUEUE return consume_byte(fd); @@ -402,14 +404,152 @@ static inline int timer_consume_byte(int fd) return 0; } +/* + * Lookup for the next available 'id' for a struct flb_sched_timer_coro. This is a slow search, + * however is expected we don't have more than a couple dozen active timer_coro contexts under + * the same scheduler context. + * + * We cap this as an uint32_t so we can use the sched->ch_events channels to send the id and + * link it to some notification. + */ +static inline uint32_t sched_timer_coro_get_id(struct flb_sched *sched) +{ + uint32_t id = 0; + int found = FLB_FALSE; + struct cfl_list *head; + struct flb_sched_timer_coro *stc; + + while (id < UINT32_MAX) { + /* check if the proposed id is in use already */ + cfl_list_foreach(head, &sched->timer_coro_list) { + stc = cfl_list_entry(head, struct flb_sched_timer_coro, _head); + if (stc->id == id) { + found = FLB_TRUE; + break; + } + } + + if (!found) { + break; + } + else { + id++; + found = FLB_FALSE; + } + } + + return id; +} + +/* context of a scheduled timer that holds a coroutine context */ +struct flb_sched_timer_coro *flb_sched_timer_coro_create(struct flb_sched_timer *timer, + struct flb_config *config, + void *data) +{ + size_t stack_size; + struct flb_coro *coro; + struct flb_sched *sched; + struct flb_sched_timer_coro *stc; + + /* get scheduler context */ + sched = flb_sched_ctx_get(); + if (!sched) { + flb_error("[sched] no scheduler context available"); + return NULL; + } + + stc = flb_malloc(sizeof(struct flb_sched_timer_coro)); + if (!stc) { + flb_errno(); + return NULL; + } + + stc->id = sched_timer_coro_get_id(sched); + stc->timer = timer; + stc->config = config; + stc->data = data; + + coro = flb_coro_create(stc); + if (!coro) { + flb_free(stc); + return NULL; + } + stc->coro = coro; + + coro->caller = co_active(); + coro->callee = co_create(config->coro_stack_size, + sched_timer_coro_cb_run, &stack_size); + +#ifdef FLB_HAVE_VALGRIND + coro->valgrind_stack_id = VALGRIND_STACK_REGISTER(coro->callee, ((char *) coro->callee) + stack_size); +#endif + cfl_list_add(&stc->_head, &sched->timer_coro_list); + + sched_timer_cb_params_set(stc, coro, config, data); + return stc; +} + +/* + * Create a timer that triggers the defined callback every N milliseconds. + */ +static void timer_cb_coro_trampoline(struct flb_config *config, + struct flb_sched_timer *timer, void *data) +{ + struct flb_sched_timer_coro *stc; + + stc = flb_sched_timer_coro_create(timer, config, data); + if (!stc) { + return; + } + + flb_coro_resume(stc->coro); +} + /* Handle a timeout event set by a previous flb_sched_request_create(...) */ int flb_sched_event_handler(struct flb_config *config, struct mk_event *event) { int ret; + uint64_t val; + uint32_t op; + uint32_t id; + struct flb_sched *sched; struct flb_sched_timer *timer; struct flb_sched_request *req; + struct flb_sched_timer_coro *stc; + + if (event->type == FLB_ENGINE_EV_SCHED_CORO) { + printf("CORO EVENT\n"); + stc = (struct flb_sched_timer_coro *) event; + if (!stc) { + flb_error("[sched] invalid timer coro context"); + return -1; + } + + /* consume the notification */ + val = flb_pipe_r(event->fd, &val, sizeof(val)); + if (val == -1) { + flb_errno(); + return -1; + } + + op = FLB_BITS_U64_HIGH(val); + id = FLB_BITS_U64_LOW(val); + if (op == FLB_SCHED_TIMER_CORO_RETURN) { + /* move stc to the drop list */ + sched = flb_sched_ctx_get(); + cfl_list_del(&stc->_head); + cfl_list_add(&stc->_head, &sched->timer_coro_list_drop); + } + else { + flb_error("[sched] unknown coro event operation %u", op); + } + + return 0; + } + + /* Everything else is just a normal timer handling */ timer = (struct flb_sched_timer *) event; if (timer->active == FLB_FALSE) { return 0; @@ -430,18 +570,24 @@ int flb_sched_event_handler(struct flb_config *config, struct mk_event *event) } else if (timer->type == FLB_SCHED_TIMER_FRAME) { sched = timer->data; - timer_consume_byte(sched->frame_fd); + event_fd_consume_byte(sched->frame_fd); schedule_request_promote(sched); } else if (timer->type == FLB_SCHED_TIMER_CB_ONESHOT) { - timer_consume_byte(timer->timer_fd); + event_fd_consume_byte(timer->timer_fd); flb_sched_timer_cb_disable(timer); timer->cb(config, timer->data); flb_sched_timer_cb_destroy(timer); } else if (timer->type == FLB_SCHED_TIMER_CB_PERM) { - timer_consume_byte(timer->timer_fd); - timer->cb(config, timer->data); + event_fd_consume_byte(timer->timer_fd); + + if (timer->coro == FLB_TRUE) { + timer_cb_coro_trampoline(config, timer, timer->data); + } + else { + timer->cb(config, timer->data); + } } return 0; @@ -511,12 +657,35 @@ int flb_sched_timer_cb_create(struct flb_sched *sched, int type, int ms, return 0; } +/* + * Creates a timer that triggers the defined callback every N milliseconds. The target + * function runs in a coroutine context. + */ +int flb_sched_timer_coro_cb_create(struct flb_sched *sched, int type, int64_t ms, + void (*cb)(struct flb_config *, void *), + void *data, struct flb_sched_timer **out_timer) + +{ + int ret; + struct flb_sched_timer *timer = NULL; + + ret = flb_sched_timer_cb_create(sched, type, ms, cb, data, &timer); + if (ret == -1) { + flb_error("[sched] cannot create timer for coroutine callback"); + return -1; + } + + /* mark that the callback will run inside a coroutine */ + timer->coro = FLB_TRUE; + + return 0; +} + /* Disable notifications, used before to destroy the context */ int flb_sched_timer_cb_disable(struct flb_sched_timer *timer) { if (timer->timer_fd != -1) { mk_event_timeout_destroy(timer->sched->evl, &timer->event); - timer->timer_fd = -1; } @@ -526,7 +695,6 @@ int flb_sched_timer_cb_disable(struct flb_sched_timer *timer) int flb_sched_timer_cb_destroy(struct flb_sched_timer *timer) { flb_sched_timer_destroy(timer); - return 0; } @@ -534,6 +702,7 @@ int flb_sched_timer_cb_destroy(struct flb_sched_timer *timer) struct flb_sched *flb_sched_create(struct flb_config *config, struct mk_event_loop *evl) { + int ret; flb_pipefd_t fd; struct mk_event *event; struct flb_sched *sched; @@ -554,6 +723,9 @@ struct flb_sched *flb_sched_create(struct flb_config *config, mk_list_init(&sched->timers); mk_list_init(&sched->timers_drop); + cfl_list_init(&sched->timer_coro_list); + cfl_list_init(&sched->timer_coro_list_drop); + /* Create the frame timer who enqueue 'requests' for future time */ timer = flb_sched_timer_create(sched); if (!timer) { @@ -580,6 +752,17 @@ struct flb_sched *flb_sched_create(struct flb_config *config, } sched->frame_fd = fd; + /* Creates a channel to handle notifications */ + ret = mk_event_channel_create(sched->evl, + &sched->ch_events[0], + &sched->ch_events[1], + sched); + if (ret == -1) { + flb_sched_destroy(sched); + return NULL; + } + sched->event.type = FLB_ENGINE_EV_SCHED; + /* * Note: mk_event_timeout_create() sets a type = MK_EVENT_NOTIFICATION by * default, we need to overwrite this value so we can do a clean check @@ -652,6 +835,7 @@ struct flb_sched_timer *flb_sched_timer_create(struct flb_sched *sched) timer->config = sched->config; timer->sched = sched; timer->data = NULL; + timer->coro = FLB_FALSE; /* Active timer (not invalidated) */ timer->active = FLB_TRUE; @@ -684,7 +868,8 @@ int flb_sched_timer_destroy(struct flb_sched_timer *timer) /* Used by the engine to cleanup pending timers waiting to be destroyed */ int flb_sched_timer_cleanup(struct flb_sched *sched) { - int c = 0; + int timer_count = 0; + int timer_coro_count = 0; struct mk_list *tmp; struct mk_list *head; struct flb_sched_timer *timer; @@ -692,6 +877,27 @@ int flb_sched_timer_cleanup(struct flb_sched *sched) mk_list_foreach_safe(head, tmp, &sched->timers_drop) { timer = mk_list_entry(head, struct flb_sched_timer, _head); flb_sched_timer_destroy(timer); + timer_count++; + } + + timer_coro_count = flb_sched_timer_coro_cleanup(sched); + flb_trace("[sched] %i timer coroutines destroyed", timer_coro_count); + + return timer_count + timer_coro_count; +} + +int flb_sched_timer_coro_cleanup(struct flb_sched *sched) +{ + int c = 0; + struct cfl_list *tmp; + struct cfl_list *head; + struct flb_sched_timer_coro *stc; + + cfl_list_foreach_safe(head, tmp, &sched->timer_coro_list_drop) { + stc = cfl_list_entry(head, struct flb_sched_timer_coro, _head); + flb_coro_destroy(stc->coro); + cfl_list_del(&stc->_head); + flb_free(stc); c++; } @@ -742,3 +948,18 @@ int flb_sched_retry_now(struct flb_config *config, } return 0; } + +struct flb_sched_timer_coro *flb_sched_timer_coro_get(struct flb_sched *sched, uint32_t id) +{ + struct cfl_list *head; + struct flb_sched_timer_coro *stc; + + cfl_list_foreach(head, &sched->timer_coro_list) { + stc = cfl_list_entry(head, struct flb_sched_timer_coro, _head); + if (stc->id == id) { + return stc; + } + } + + return NULL; +} \ No newline at end of file From 8d4b77747f797fc844b76d01c5b03d52d2f2b4a2 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 16 Sep 2024 13:08:07 -0600 Subject: [PATCH 196/295] input_event: add support for Blob signal Signed-off-by: Eduardo Silva --- include/fluent-bit/flb_input_event.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/fluent-bit/flb_input_event.h b/include/fluent-bit/flb_input_event.h index eae461310d6..ffef798670c 100644 --- a/include/fluent-bit/flb_input_event.h +++ b/include/fluent-bit/flb_input_event.h @@ -20,10 +20,10 @@ #ifndef FLB_INPUT_EVENT_H #define FLB_INPUT_EVENT_H -/* support event types by input plugins*/ - +/* support event types by input plugins */ #define FLB_INPUT_LOGS 0 #define FLB_INPUT_METRICS 1 #define FLB_INPUT_TRACES 2 +#define FLB_INPUT_BLOBS 3 #endif From 914280318016566b87f2cc2ac5e48cd879c5946f Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 16 Sep 2024 13:09:22 -0600 Subject: [PATCH 197/295] input_chunk: register chunks blob type Signed-off-by: Eduardo Silva --- include/fluent-bit/flb_input_chunk.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/fluent-bit/flb_input_chunk.h b/include/fluent-bit/flb_input_chunk.h index 8d9156ad002..d801b11e89f 100644 --- a/include/fluent-bit/flb_input_chunk.h +++ b/include/fluent-bit/flb_input_chunk.h @@ -50,6 +50,7 @@ #define FLB_INPUT_CHUNK_TYPE_LOGS 0 #define FLB_INPUT_CHUNK_TYPE_METRICS 1 #define FLB_INPUT_CHUNK_TYPE_TRACES 2 +#define FLB_INPUT_CHUNK_TYPE_BLOBS 3 #ifdef FLB_HAVE_CHUNK_TRACE #define FLB_INPUT_CHUNK_HAS_TRACE 1 << 31 From 273498c93867f7cf5696246ff1e07bb612e9772b Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 16 Sep 2024 13:10:22 -0600 Subject: [PATCH 198/295] input: use FLB_INLINE macro Signed-off-by: Eduardo Silva --- include/fluent-bit/flb_input.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/fluent-bit/flb_input.h b/include/fluent-bit/flb_input.h index 0b69f8cca9a..7fbb4ebefcb 100644 --- a/include/fluent-bit/flb_input.h +++ b/include/fluent-bit/flb_input.h @@ -577,7 +577,7 @@ static FLB_INLINE int flb_input_is_threaded(struct flb_input_instance *ins) * number of retries, if it has exceeded the 'retry_limit' option, an FLB_ERROR * will be returned instead. */ -static inline void flb_input_return(struct flb_coro *coro) { +static FLB_INLINE void flb_input_return(struct flb_coro *coro) { int n; uint64_t val; struct flb_input_coro *input_coro; @@ -599,7 +599,7 @@ static inline void flb_input_return(struct flb_coro *coro) { flb_input_coro_prepare_destroy(input_coro); } -static inline void flb_input_return_do(int ret) { +static FLB_INLINE void flb_input_return_do(int ret) { struct flb_coro *coro = flb_coro_get(); flb_input_return(coro); From 6b04f5c96a1693d20ecb5edf8a5e703688b38085 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 16 Sep 2024 13:10:58 -0600 Subject: [PATCH 199/295] engine_macros: adjust scheduler macros Signed-off-by: Eduardo Silva --- include/fluent-bit/flb_engine_macros.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/include/fluent-bit/flb_engine_macros.h b/include/fluent-bit/flb_engine_macros.h index 151dd5ad346..8b79634f7d2 100644 --- a/include/fluent-bit/flb_engine_macros.h +++ b/include/fluent-bit/flb_engine_macros.h @@ -26,16 +26,18 @@ /* Types of events handled by the Server engine */ #define FLB_ENGINE_EV_CORE MK_EVENT_NOTIFICATION #define FLB_ENGINE_EV_CUSTOM MK_EVENT_CUSTOM -#define FLB_ENGINE_EV_THREAD 1024 -#define FLB_ENGINE_EV_SCHED 2048 -#define FLB_ENGINE_EV_SCHED_FRAME (FLB_ENGINE_EV_SCHED + 4096) -#define FLB_ENGINE_EV_INPUT 8192 -#define FLB_ENGINE_EV_THREAD_INPUT 16384 /* reserved, not used yet */ +#define FLB_ENGINE_EV_THREAD (1 << 10) /* 1024 */ +#define FLB_ENGINE_EV_SCHED (1 << 11) /* 2048 */ +#define FLB_ENGINE_EV_SCHED_FRAME (FLB_ENGINE_EV_SCHED | (1 << 12)) /* 2048 | 4096 = 6144 */ +#define FLB_ENGINE_EV_SCHED_CORO (1 << 13) /* 8192 */ -#define FLB_ENGINE_EV_OUTPUT 32768 -#define FLB_ENGINE_EV_THREAD_OUTPUT 65536 -#define FLB_ENGINE_EV_THREAD_ENGINE 131072 +#define FLB_ENGINE_EV_INPUT (1 << 14) /* 16384 */ +#define FLB_ENGINE_EV_THREAD_INPUT (1 << 15) /* 32768 */ + +#define FLB_ENGINE_EV_OUTPUT (1 << 16) /* 65536 */ +#define FLB_ENGINE_EV_THREAD_OUTPUT (1 << 17) /* 131072 */ +#define FLB_ENGINE_EV_THREAD_ENGINE (1 << 18) /* 262144 */ /* Engine events: all engine events set the left 32 bits to '1' */ #define FLB_ENGINE_EV_STARTED FLB_BITS_U64_SET(1, 1) /* Engine started */ From 4f60a05eb7164eb558fdfa2f3b3c9d609b2c96e9 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 16 Sep 2024 13:12:05 -0600 Subject: [PATCH 200/295] event: map event type blobs as chunk type blobs Signed-off-by: Eduardo Silva --- include/fluent-bit/flb_event.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/fluent-bit/flb_event.h b/include/fluent-bit/flb_event.h index f2e44b57187..9b94ea4c980 100644 --- a/include/fluent-bit/flb_event.h +++ b/include/fluent-bit/flb_event.h @@ -28,6 +28,7 @@ #define FLB_EVENT_TYPE_LOGS FLB_INPUT_CHUNK_TYPE_LOGS #define FLB_EVENT_TYPE_METRICS FLB_INPUT_CHUNK_TYPE_METRICS #define FLB_EVENT_TYPE_TRACES FLB_INPUT_CHUNK_TYPE_TRACES +#define FLB_EVENT_TYPE_BLOBS FLB_INPUT_CHUNK_TYPE_BLOBS #define FLB_EVENT_TYPE_HAS_TRACE FLB_INPUT_CHUNK_HAS_TRACE From 991a1b7cf851ec34deb5515bdcc5b0eb74eb1f67 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 16 Sep 2024 13:13:30 -0600 Subject: [PATCH 201/295] output_thread: add plugin callback for worker initialization Signed-off-by: Eduardo Silva --- src/flb_output_thread.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/flb_output_thread.c b/src/flb_output_thread.c index cc75e623742..4baa5181b30 100644 --- a/src/flb_output_thread.c +++ b/src/flb_output_thread.c @@ -243,6 +243,10 @@ static void output_thread(void *data) } event_local.type = FLB_ENGINE_EV_OUTPUT; + if (ins->p->cb_worker_init) { + ret = ins->p->cb_worker_init(ins->context, ins->config); + } + flb_plg_info(th_ins->ins, "worker #%i started", thread_id); /* Thread event loop */ From f2e59b3442b374f6f5570dffbf7f7a0afa0a8ec0 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 16 Sep 2024 13:14:34 -0600 Subject: [PATCH 202/295] utils: add new function to read files by offset Signed-off-by: Eduardo Silva --- include/fluent-bit/flb_utils.h | 1 + src/flb_utils.c | 53 ++++++++++++++++++++++++++++------ 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/include/fluent-bit/flb_utils.h b/include/fluent-bit/flb_utils.h index f1424d78842..b1f06592278 100644 --- a/include/fluent-bit/flb_utils.h +++ b/include/fluent-bit/flb_utils.h @@ -67,6 +67,7 @@ int flb_utils_proxy_url_split(const char *in_url, char **out_protocol, char **out_username, char **out_password, char **out_host, char **out_port); int flb_utils_read_file(char *path, char **out_buf, size_t *out_size); +int flb_utils_read_file_offset(char *path, off_t offset_start, off_t offset_end, char **out_buf, size_t *out_size); char *flb_utils_get_os_name(); int flb_utils_uuid_v4_gen(char *buf); int flb_utils_get_machine_id(char **out_id, size_t *out_size); diff --git a/src/flb_utils.c b/src/flb_utils.c index 4a3ba02ad47..010254f23c5 100644 --- a/src/flb_utils.c +++ b/src/flb_utils.c @@ -1285,10 +1285,17 @@ int flb_utils_uuid_v4_gen(char *buf) #endif int flb_utils_read_file(char *path, char **out_buf, size_t *out_size) +{ + return flb_utils_read_file_offset(path, 0, 0, out_buf, out_size); +} + +int flb_utils_read_file_offset(char *path, off_t offset_start, off_t offset_end, char **out_buf, size_t *out_size) { int fd; int ret; size_t bytes; + size_t bytes_to_read; + size_t total_bytes_read = 0; struct stat st; flb_sds_t buf; FILE *fp; @@ -1306,26 +1313,54 @@ int flb_utils_read_file(char *path, char **out_buf, size_t *out_size) return -1; } - buf = flb_calloc(1, st.st_size + 1); - if (!buf) { - flb_errno(); + if (offset_start > st.st_size || offset_end > st.st_size) { + flb_error("offsets exceed file size (%jd bytes)", (intmax_t) st.st_size); fclose(fp); return -1; } - bytes = fread(buf, st.st_size, 1, fp); - if (bytes < 1) { - if (ferror(fp)) { + if (offset_start > 0) { + ret = fseek(fp, offset_start, SEEK_SET); + if (ret != 0) { flb_errno(); + fclose(fp); + return -1; } - flb_free(buf); + } + + if (offset_end == 0) { + offset_end = st.st_size; + } + + bytes_to_read = offset_end - offset_start; + + buf = flb_calloc(1, bytes_to_read + 1); + if (!buf) { + flb_errno(); fclose(fp); return -1; } + + while (total_bytes_read < bytes_to_read) { + bytes = fread(buf + total_bytes_read, 1, bytes_to_read - total_bytes_read, fp); + if (bytes < 1) { + if (feof(fp)) { + break; + } + if (ferror(fp)) { + flb_errno(); + free(buf); + fclose(fp); + return -1; + } + } + total_bytes_read += bytes; + } fclose(fp); *out_buf = buf; - *out_size = st.st_size; + *out_size = total_bytes_read; + return 0; } @@ -1429,7 +1464,7 @@ int flb_utils_get_machine_id(char **out_id, size_t *out_size) memcpy(*out_id, buf, dwBufSize); - /* RegQueryValueEx sets dwBufSize to strlen()+1 for the NULL + /* RegQueryValueEx sets dwBufSize to strlen()+1 for the NULL * terminator, but we only need strlen(). */ *out_size = dwBufSize-1; return 0; From ade896eb7a3920a71513e77df6aeea4f254e6ae9 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 16 Sep 2024 13:15:33 -0600 Subject: [PATCH 203/295] router: allow routing for blob input types Signed-off-by: Eduardo Silva --- include/fluent-bit/flb_router.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/fluent-bit/flb_router.h b/include/fluent-bit/flb_router.h index 2fcd7d6e2f6..dd7efca6bad 100644 --- a/include/fluent-bit/flb_router.h +++ b/include/fluent-bit/flb_router.h @@ -44,6 +44,10 @@ static inline int flb_router_match_type(int in_event_type, !(o_ins->event_type & FLB_OUTPUT_TRACES)) { return FLB_FALSE; } + else if (in_event_type == FLB_INPUT_BLOBS && + !(o_ins->event_type & FLB_OUTPUT_BLOBS)) { + return FLB_FALSE; + } return FLB_TRUE; } From c28cd54e69cdeb2dd7f535dfedd3d460f46c262e Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 16 Sep 2024 13:16:29 -0600 Subject: [PATCH 204/295] sqldb: commit before closing handler Signed-off-by: Eduardo Silva --- src/flb_sqldb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/flb_sqldb.c b/src/flb_sqldb.c index 79c44ad65ad..a4a5df2f490 100644 --- a/src/flb_sqldb.c +++ b/src/flb_sqldb.c @@ -99,6 +99,7 @@ int flb_sqldb_close(struct flb_sqldb *db) parent->users--; } else { + sqlite3_exec(db->handler, "COMMIT;", NULL, NULL, NULL); sqlite3_close(db->handler); } mk_list_del(&db->_head); From a40cec54cc6090f8164aee9e84223ada0693667e Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 16 Sep 2024 13:17:04 -0600 Subject: [PATCH 205/295] output: register output blob Signed-off-by: Eduardo Silva --- include/fluent-bit/flb_output.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/fluent-bit/flb_output.h b/include/fluent-bit/flb_output.h index 58433fcb0d5..dd928450c99 100644 --- a/include/fluent-bit/flb_output.h +++ b/include/fluent-bit/flb_output.h @@ -89,6 +89,7 @@ int flb_chunk_trace_output(struct flb_chunk_trace *trace, struct flb_output_inst #define FLB_OUTPUT_LOGS 1 #define FLB_OUTPUT_METRICS 2 #define FLB_OUTPUT_TRACES 4 +#define FLB_OUTPUT_BLOBS 8 #define FLB_OUTPUT_FLUSH_COMPAT_OLD_18() \ const void *data = event_chunk->data; \ @@ -232,6 +233,8 @@ struct flb_output_plugin { /* Default number of worker threads */ int workers; + int (*cb_worker_init) (void *, struct flb_config *); + /* Tests */ struct flb_test_out_formatter test_formatter; From 88fecd31202ad674fa84613019a6114587266bba Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 16 Sep 2024 13:18:02 -0600 Subject: [PATCH 206/295] input_blob: add new interface to register blobs Signed-off-by: Eduardo Silva --- include/fluent-bit/flb_input_blob.h | 36 ++++++ src/flb_input_blob.c | 177 ++++++++++++++++++++++++++++ 2 files changed, 213 insertions(+) create mode 100644 include/fluent-bit/flb_input_blob.h create mode 100644 src/flb_input_blob.c diff --git a/include/fluent-bit/flb_input_blob.h b/include/fluent-bit/flb_input_blob.h new file mode 100644 index 00000000000..859468230cc --- /dev/null +++ b/include/fluent-bit/flb_input_blob.h @@ -0,0 +1,36 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* Fluent Bit + * ========== + * Copyright (C) 2015-2024 The Fluent Bit Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FLB_INPUT_BLOB_H +#define FLB_INPUT_BLOB_H + +#include +#include +#include + +struct flb_blob_file { + cfl_sds_t path; +}; + +int flb_input_blob_file_get_info(msgpack_object map, cfl_sds_t *file_path, size_t *size); +int flb_input_blob_file_register(struct flb_input_instance *ins, + struct flb_log_event_encoder *encoder, + const char *tag, size_t tag_len, + char *file_path, size_t size); +#endif diff --git a/src/flb_input_blob.c b/src/flb_input_blob.c new file mode 100644 index 00000000000..06d97e8f566 --- /dev/null +++ b/src/flb_input_blob.c @@ -0,0 +1,177 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* Fluent Bit + * ========== + * Copyright (C) 2015-2024 The Fluent Bit Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include +#include +#include +#include +#include +#include +#include + +#include + +int flb_input_blob_file_get_info(msgpack_object map, cfl_sds_t *file_path, size_t *size) +{ + cfl_sds_t tmp_file_path; + msgpack_object o; + + if (map.type != MSGPACK_OBJECT_MAP) { + return -1; + } + + if (map.via.map.size < 2) { + return -1; + } + + /* get file_path */ + o = map.via.map.ptr[0].key; + if (o.type != MSGPACK_OBJECT_STR) { + return -1; + } + if (o.via.str.size != 9 || strncmp(o.via.str.ptr, "file_path", 9) != 0) { + return -1; + } + + o = map.via.map.ptr[0].val; + if (o.type != MSGPACK_OBJECT_STR) { + return -1; + } + + tmp_file_path = cfl_sds_create_len(o.via.str.ptr, o.via.str.size); + if (tmp_file_path == NULL) { + return -1; + } + + /* get size */ + o = map.via.map.ptr[1].key; + if (o.type != MSGPACK_OBJECT_STR) { + cfl_sds_destroy(tmp_file_path); + return -1; + } + if (o.via.str.size != 4 || strncmp(o.via.str.ptr, "size", 4) != 0) { + cfl_sds_destroy(tmp_file_path); + return -1; + } + + o = map.via.map.ptr[1].val; + if (o.type != MSGPACK_OBJECT_POSITIVE_INTEGER) { + cfl_sds_destroy(tmp_file_path); + return -1; + } + + *size = o.via.u64; + *file_path = tmp_file_path; + + return 0; +} + +int flb_input_blob_file_register(struct flb_input_instance *ins, + struct flb_log_event_encoder *encoder, + const char *tag, size_t tag_len, + char *file_path, size_t size) +{ + int ret; + struct stat st; + + /* check if the file is readable */ + ret = access(file_path, R_OK); + if (ret == -1) { + flb_plg_error(ins, "file %s is not readable", file_path); + return -1; + } + + /* get file information */ + ret = stat(file_path, &st); + if (ret == -1) { + flb_errno(); + return -1; + } + + /* is the requested file size valid ? */ + if (size > st.st_size) { + flb_error("[blob file registration] requested size %zu for file %s is greater than the file size %zu", + size, file_path, st.st_size); + return -1; + } + + /* Encode the blob file info in msgpack by using the log encoder wrapper */ + ret = flb_log_event_encoder_begin_record(encoder); + if (ret != FLB_EVENT_ENCODER_SUCCESS) { + flb_error("[blob file registration] could not begin blob record"); + return -1; + } + + /* add timestamp */ + ret = flb_log_event_encoder_set_current_timestamp(encoder); + if (ret != FLB_EVENT_ENCODER_SUCCESS) { + flb_error("[blob file registration] could not set timestamp"); + flb_log_event_encoder_reset(encoder); + return -1; + } + + ret = flb_log_event_encoder_append_body_cstring(encoder, "file_path"); + if (ret != FLB_EVENT_ENCODER_SUCCESS) { + flb_error("[blob file registration] could not append path"); + flb_log_event_encoder_reset(encoder); + return -1; + } + ret = flb_log_event_encoder_append_body_cstring(encoder, file_path); + if (ret != FLB_EVENT_ENCODER_SUCCESS) { + flb_error("[blob file registration] could not append path"); + flb_log_event_encoder_reset(encoder); + return -1; + } + + ret = flb_log_event_encoder_append_body_cstring(encoder, "size"); + if (ret != FLB_EVENT_ENCODER_SUCCESS) { + flb_error("[blob file registration] could not append path"); + flb_log_event_encoder_reset(encoder); + return -1; + } + + ret = flb_log_event_encoder_append_body_uint64(encoder, size); + if (ret != FLB_EVENT_ENCODER_SUCCESS) { + flb_error("[blob file registration] could not append size"); + flb_log_event_encoder_reset(encoder); + return -1; + } + + ret = flb_log_event_encoder_commit_record(encoder); + if (ret != FLB_EVENT_ENCODER_SUCCESS) { + flb_error("[blob file registration] could not commit record"); + flb_log_event_encoder_reset(encoder); + return -1; + } + + /* register entry as a chunk */ + ret = flb_input_chunk_append_raw(ins, FLB_INPUT_BLOBS, 0, + tag, tag_len, + encoder->output_buffer, + encoder->output_length); + if (ret != 0) { + flb_error("[blob file registration] could not append blob record"); + flb_log_event_encoder_reset(encoder); + return -1; + } + + flb_log_event_encoder_reset(encoder); + return ret; +} From df9b9d39fd1a1bff6148c1f371191a57ae0f7465 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 16 Sep 2024 13:20:07 -0600 Subject: [PATCH 207/295] input_chunk: event type blob support Signed-off-by: Eduardo Silva --- src/CMakeLists.txt | 1 + src/flb_input_chunk.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 084f2c57d52..ea7403f7b6c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,6 +27,7 @@ set(src flb_input_log.c flb_input_metric.c flb_input_trace.c + flb_input_blob.c flb_input_thread.c flb_filter.c flb_output.c diff --git a/src/flb_input_chunk.c b/src/flb_input_chunk.c index ca02e6fca68..1e8a4a09d75 100644 --- a/src/flb_input_chunk.c +++ b/src/flb_input_chunk.c @@ -2049,6 +2049,9 @@ int flb_input_chunk_get_event_type(struct flb_input_chunk *ic) else if (buf[2] == FLB_INPUT_CHUNK_TYPE_TRACES) { type = FLB_INPUT_TRACES; } + else if (buf[2] == FLB_INPUT_CHUNK_TYPE_BLOBS) { + type = FLB_INPUT_BLOBS; + } } else { type = FLB_INPUT_LOGS; From 66943dcec6bcb8057d5877ff9ac6e8e2fe7347e0 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 16 Sep 2024 13:21:14 -0600 Subject: [PATCH 208/295] in_blob: new plugin to support large binary files Recent patch series add support to process/route large binary files through a zero-copy strategy. This new in_blob plugin allows to scan a path from the file system and register files that matched the pattern. service: flush: 1 log_level: info pipeline: inputs: - name: blob path: '~/logs/blob/*' database_file: blob.db outputs: - name: stdout match: '*' - name: azure_blob match: '*' path: kubernetes container_name: blobs auto_create_container: on database_file: azure.db part_size: 4M upload_parts_timeout: 1s workers: 10 Signed-off-by: Eduardo Silva --- plugins/CMakeLists.txt | 2 + plugins/in_blob/CMakeLists.txt | 12 ++ plugins/in_blob/blob.c | 359 +++++++++++++++++++++++++++++++++ plugins/in_blob/blob.h | 75 +++++++ plugins/in_blob/blob_db.c | 203 +++++++++++++++++++ plugins/in_blob/blob_db.h | 47 +++++ plugins/in_blob/blob_file.c | 123 +++++++++++ plugins/in_blob/blob_file.h | 31 +++ 8 files changed, 852 insertions(+) create mode 100644 plugins/in_blob/CMakeLists.txt create mode 100644 plugins/in_blob/blob.c create mode 100644 plugins/in_blob/blob.h create mode 100644 plugins/in_blob/blob_db.c create mode 100644 plugins/in_blob/blob_db.h create mode 100644 plugins/in_blob/blob_file.c create mode 100644 plugins/in_blob/blob_file.h diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index ce8cae64d97..200a09b449c 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -193,6 +193,8 @@ endmacro() # Custom Plugins REGISTER_CUSTOM_PLUGIN("custom_calyptia") +REGISTER_IN_PLUGIN("in_blob") + # These plugins works only on Linux if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") REGISTER_IN_PLUGIN("in_cpu") diff --git a/plugins/in_blob/CMakeLists.txt b/plugins/in_blob/CMakeLists.txt new file mode 100644 index 00000000000..ef8547ec67c --- /dev/null +++ b/plugins/in_blob/CMakeLists.txt @@ -0,0 +1,12 @@ +# FIXME: there is something wrong when linking objects and this +# static plugin, I should not require to link to a specific symbol +# if the object was already linked from fluent-bit core on src/, also +# jsmn should not be required. + +set(src + blob.c + blob_db.c + blob_file.c + ) + +FLB_PLUGIN(in_blob "${src}" "") diff --git a/plugins/in_blob/blob.c b/plugins/in_blob/blob.c new file mode 100644 index 00000000000..223aa4a13c8 --- /dev/null +++ b/plugins/in_blob/blob.c @@ -0,0 +1,359 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* Fluent Bit + * ========== + * Copyright (C) 2015-2024 The Fluent Bit Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "blob.h" +#include "blob_db.h" +#include "blob_file.h" + +/* Define missing GLOB_TILDE if not exists */ +#ifndef GLOB_TILDE +#define GLOB_TILDE 1<<2 /* use GNU Libc value */ +#define UNSUP_TILDE 1 + +/* we need these extra headers for path resolution */ +#include +#include +#include + +static char *expand_tilde(const char *path) +{ + int len; + char user[256]; + char *p = NULL; + char *dir = NULL; + char *tmp = NULL; + struct passwd *uinfo = NULL; + + if (path[0] == '~') { + p = strchr(path, '/'); + + if (p) { + /* check case '~/' */ + if ((p - path) == 1) { + dir = getenv("HOME"); + if (!dir) { + return path; + } + } + else { + /* + * it refers to a different user: ~user/abc, first step grab + * the user name. + */ + len = (p - path) - 1; + memcpy(user, path + 1, len); + user[len] = '\0'; + + /* use getpwnam() to resolve user information */ + uinfo = getpwnam(user); + if (!uinfo) { + return path; + } + + dir = uinfo->pw_dir; + } + } + else { + dir = getenv("HOME"); + if (!dir) { + return path; + } + } + + if (p) { + tmp = flb_malloc(PATH_MAX); + if (!tmp) { + flb_errno(); + return NULL; + } + snprintf(tmp, PATH_MAX - 1, "%s%s", dir, p); + } + else { + dir = getenv("HOME"); + if (!dir) { + return path; + } + + tmp = flb_strdup(dir); + if (!tmp) { + return path; + } + } + + return tmp; + } + + return path; +} +#endif + + +static inline int do_glob(const char *pattern, int flags, + void *not_used, glob_t *pglob) +{ + int ret; + int new_flags; + char *tmp = NULL; + int tmp_needs_free = FLB_FALSE; + (void) not_used; + + /* Save current values */ + new_flags = flags; + + if (flags & GLOB_TILDE) { +#ifdef UNSUP_TILDE + /* + * Some libc libraries like Musl do not support GLOB_TILDE for tilde + * expansion. A workaround is to use wordexp(3) but looking at it + * implementation in Musl it looks quite expensive: + * + * http://git.musl-libc.org/cgit/musl/tree/src/misc/wordexp.c + * + * the workaround is to do our own tilde expansion in a temporary buffer. + */ + + /* Look for a tilde */ + tmp = expand_tilde(pattern); + if (tmp != pattern) { + /* the path was expanded */ + pattern = tmp; + tmp_needs_free = FLB_TRUE; + } + + /* remove unused flag */ + new_flags &= ~GLOB_TILDE; +#endif + } + + /* invoke glob with new parameters */ + ret = glob(pattern, new_flags, NULL, pglob); + + /* remove temporary buffer, if allocated by expand_tilde above. + * Note that this buffer is only used for libc implementations + * that do not support the GLOB_TILDE flag, like musl. */ + if ((tmp != NULL) && (tmp_needs_free == FLB_TRUE)) { + flb_free(tmp); + } + + return ret; +} + +static int scan_path(struct blob_ctx *ctx) +{ + int i; + int ret; + int count = 0; + glob_t globbuf; + struct stat st; + + flb_plg_debug(ctx->ins, "scanning path %s", ctx->path); + + /* Safe reset for globfree() */ + globbuf.gl_pathv = NULL; + + /* Scan the given path */ + ret = do_glob(ctx->path, GLOB_TILDE | GLOB_ERR, NULL, &globbuf); + if (ret != 0) { + switch (ret) { + case GLOB_NOSPACE: + flb_plg_error(ctx->ins, "no memory space available"); + return -1; + case GLOB_ABORTED: + flb_plg_error(ctx->ins, "read error, check permissions: %s", ctx->path); + return -1; + case GLOB_NOMATCH: + ret = stat(ctx->path, &st); + if (ret == -1) { + flb_plg_debug(ctx->ins, "cannot read info from: %s", ctx->path); + } + else { + ret = access(ctx->path, R_OK); + if (ret == -1 && errno == EACCES) { + flb_plg_error(ctx->ins, "NO read access for path: %s", ctx->path); + } + else { + flb_plg_debug(ctx->ins, "NO matches for path: %s", ctx->path); + } + } + return 0; + } + } + + /* For every entry found, generate an output list */ + for (i = 0; i < globbuf.gl_pathc; i++) { + ret = stat(globbuf.gl_pathv[i], &st); + if (ret != 0) { + flb_plg_debug(ctx->ins, "skip entry=%s", globbuf.gl_pathv[i]); + continue; + } + + if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) { + ret = blob_file_append(ctx, globbuf.gl_pathv[i], &st); + if (ret == 0) { + flb_plg_debug(ctx->ins, "blob scan add: %s, inode %" PRIu64, + globbuf.gl_pathv[i], (uint64_t) st.st_ino); + } + else { + flb_plg_debug(ctx->ins, "blob scan skip: %s", globbuf.gl_pathv[i]); + } + } + else { + flb_plg_debug(ctx->ins, "skip entry=%s", globbuf.gl_pathv[i]); + } + } + + globfree(&globbuf); + return count; +} + +static int cb_scan_path(struct flb_input_instance *ins, + struct flb_config *config, void *in_context) +{ + struct blob_ctx *ctx = in_context; + + return scan_path(ctx); +} + +/* Initialize plugin */ +static int in_blob_init(struct flb_input_instance *ins, + struct flb_config *config, void *data) +{ + int ret; + struct blob_ctx *ctx; + + /* Allocate space for the configuration context */ + ctx = flb_calloc(1, sizeof(struct blob_ctx)); + if (!ctx) { + return -1; + } + ctx->ins = ins; + ctx->config = config; + cfl_list_init(&ctx->files); + + /* laod the config map */ + ret = flb_input_config_map_set(ins, ctx); + if (ret == -1) { + flb_free(ctx); + return -1; + } + + /* associate the context with the instance */ + flb_input_set_context(ins, ctx); + + /* 'path' must be set */ + if (!ctx->path) { + flb_plg_error(ins, "'path' configuration property is not set"); + flb_free(ctx); + return -1; + } + +#ifdef FLB_HAVE_SQLDB + if (ctx->database_file) { + ctx->db = blob_db_open(ctx, ctx->database_file); + if (!ctx->db) { + return -1; + } + } +#endif + + /* create a collector to scan the path of files */ + ret = flb_input_set_collector_time(ins, + cb_scan_path, + ctx->scan_refresh_interval, 0, + config); + if (ret == -1) { + flb_plg_error(ins, "could not create collector"); + return -1; + } + ctx->coll_fd = ret; + + /* initialize the encoder */ + ctx->log_encoder = flb_log_event_encoder_create(FLB_LOG_EVENT_FORMAT_DEFAULT); + if (ctx->log_encoder == NULL) { + flb_plg_error(ins, "could not initialize event encoder"); + return -1; + } + + return 0; +} + +/* Cleanup serial input */ +static int in_blob_exit(void *in_context, struct flb_config *config) +{ + struct blob_ctx *ctx = in_context; + + if (!ctx) { + return 0; + } + + blob_db_close(ctx); + blob_file_list_remove_all(ctx); + flb_log_event_encoder_destroy(ctx->log_encoder); + flb_free(ctx); + + return 0; +} + +static struct flb_config_map config_map[] = { + { + FLB_CONFIG_MAP_STR, "path", NULL, + 0, FLB_TRUE, offsetof(struct blob_ctx, path), + "Path to scan for blob/binary files" + }, + +#ifdef FLB_HAVE_SQLDB + { + FLB_CONFIG_MAP_STR, "database_file", NULL, + 0, FLB_TRUE, offsetof(struct blob_ctx, database_file), + }, +#endif + + { + FLB_CONFIG_MAP_TIME, "scan_refresh_interval", "2s", + 0, FLB_TRUE, offsetof(struct blob_ctx, scan_refresh_interval), + "Set the interval time to scan for new files" + }, + + /* EOF */ + {0} +}; + +/* Plugin reference */ +struct flb_input_plugin in_blob_plugin = { + .name = "blob", + .description = "Blob (binary) files", + .cb_init = in_blob_init, + .cb_pre_run = NULL, + .cb_collect = NULL, + .cb_flush_buf = NULL, + .cb_exit = in_blob_exit, + .config_map = config_map +}; diff --git a/plugins/in_blob/blob.h b/plugins/in_blob/blob.h new file mode 100644 index 00000000000..13b932e5d5e --- /dev/null +++ b/plugins/in_blob/blob.h @@ -0,0 +1,75 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* Fluent Bit + * ========== + * Copyright (C) 2015-2024 The Fluent Bit Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FLB_IN_BLOB_H +#define FLB_IN_BLOB_H + +#include +#include +#include +#include + +struct blob_file { + /* database reference (id) */ + uint64_t db_id; + + /* file path */ + flb_sds_t path; + + /* file size found when registered */ + size_t size; + + /* link to parent list blob_ctx->files */ + struct cfl_list _head; +}; + +struct blob_ctx { + /* collector for scan_refresh_interval */ + int coll_fd; + + /* + * list of files that has been found and being processed: file as soon as they are found are + * registered with the flb_input_blob_file_register() function. + */ + struct cfl_list files; + + /* Fluent Bit context */ + struct flb_config *config; + + /* input instance */ + struct flb_input_instance *ins; + + /* log encoder */ + struct flb_log_event_encoder *log_encoder; + + /* database */ +#ifdef FLB_HAVE_SQLDB + struct flb_sqldb *db; + sqlite3_stmt *stmt_insert_file; + sqlite3_stmt *stmt_delete_file; + sqlite3_stmt *stmt_get_file; +#endif + + /* config map options */ + flb_sds_t path; + flb_sds_t database_file; + time_t scan_refresh_interval; +}; + +#endif diff --git a/plugins/in_blob/blob_db.c b/plugins/in_blob/blob_db.c new file mode 100644 index 00000000000..df96769212c --- /dev/null +++ b/plugins/in_blob/blob_db.c @@ -0,0 +1,203 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* Fluent Bit + * ========== + * Copyright (C) 2015-2024 The Fluent Bit Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifdef FLB_HAVE_SQLDB + +#include + +#include "blob.h" +#include "blob_db.h" + +static int prepare_stmts(struct flb_sqldb *db, struct blob_ctx *ctx) +{ + int ret; + + /* insert */ + ret = sqlite3_prepare_v2(db->handler, SQL_INSERT_FILE, -1, + &ctx->stmt_insert_file, NULL); + if (ret != SQLITE_OK) { + flb_plg_error(ctx->ins, "cannot prepare SQL statement: %s", + SQL_INSERT_FILE); + return -1; + } + + /* delete */ + ret = sqlite3_prepare_v2(db->handler, SQL_DELETE_FILE, -1, + &ctx->stmt_delete_file, NULL); + if (ret != SQLITE_OK) { + flb_plg_error(ctx->ins, "cannot prepare SQL statement: %s", + SQL_DELETE_FILE); + return -1; + } + + /* get */ + ret = sqlite3_prepare_v2(db->handler, SQL_GET_FILE, -1, + &ctx->stmt_get_file, NULL); + if (ret != SQLITE_OK) { + flb_plg_error(ctx->ins, "cannot prepare SQL statement: %s", + SQL_GET_FILE); + return -1; + } + + return 0; +} +// static int my_special_callback(void *unused, int count, char **data, char **columns) +// { +// int idx; + +// printf("There are %d column(s)\n", count); + +// for (idx = 0; idx < count; idx++) { +// printf("The data in column \"%s\" is: %s\n", columns[idx], data[idx]); +// } + +// printf("\n"); + +// return 0; +// } + +struct flb_sqldb *blob_db_open(struct blob_ctx *ctx, char *db_path) +{ + int ret; + struct flb_sqldb *db; + struct flb_input_instance *ins; + + ins = ctx->ins; + + db = flb_sqldb_open(db_path, ins->name, ctx->config); + if (!db) { + flb_plg_error(ctx->ins, "cannot open database %s", db_path); + return NULL; + } + + ret = flb_sqldb_query(db, SQL_CREATE_BLOB_FILES, NULL, NULL); + if (ret != FLB_OK) { + flb_plg_error(ctx->ins, "cannot create table 'in_blob_files'"); + flb_sqldb_close(db); + return NULL; + } + + ret = prepare_stmts(db, ctx); + if (ret == -1) { + flb_sqldb_close(db); + return NULL; + } + + return db; +} + +int blob_db_close(struct blob_ctx *ctx) +{ + /* finalize prepared statements */ + sqlite3_finalize(ctx->stmt_get_file); + sqlite3_finalize(ctx->stmt_insert_file); + sqlite3_finalize(ctx->stmt_delete_file); + + return flb_sqldb_close(ctx->db); +} + +int blob_db_file_exists(struct blob_ctx *ctx, char *path, uint64_t *id) +{ + int ret; + int exists = FLB_FALSE; + + /* Bind parameters */ + sqlite3_bind_text(ctx->stmt_get_file, 1, path, -1, 0); + ret = sqlite3_step(ctx->stmt_get_file); + if (ret == SQLITE_ROW) { + exists = FLB_TRUE; + + /* id: column 0 */ + *id = sqlite3_column_int64(ctx->stmt_get_file, 0); + } + else if (ret == SQLITE_DONE) { + /* all good */ + } + else { + exists = -1; + } + + sqlite3_clear_bindings(ctx->stmt_get_file); + sqlite3_reset(ctx->stmt_get_file); + + return exists; +} + +int64_t blob_db_file_insert(struct blob_ctx *ctx, char *path, size_t size) +{ + int ret; + int64_t id; + time_t created; + + /* Register the file */ + created = time(NULL); + + /* Bind parameters */ + sqlite3_bind_text(ctx->stmt_insert_file, 1, path, -1, 0); + sqlite3_bind_int64(ctx->stmt_insert_file, 2, size); + sqlite3_bind_int64(ctx->stmt_insert_file, 3, created); + + /* Run the insert */ + ret = sqlite3_step(ctx->stmt_insert_file); + if (ret != SQLITE_DONE) { + sqlite3_clear_bindings(ctx->stmt_insert_file); + sqlite3_reset(ctx->stmt_insert_file); + flb_plg_error(ctx->ins, "cannot execute insert file '%s'", path); + return -1; + } + + /* Get the database ID for this file */ + id = flb_sqldb_last_id(ctx->db); + + sqlite3_clear_bindings(ctx->stmt_insert_file); + sqlite3_reset(ctx->stmt_insert_file); + + + flb_plg_trace(ctx->ins, "db: file '%s' inserted with id=%ld", path, id); + return id; +} + +int blob_db_file_delete(struct blob_ctx *ctx, uint64_t id, char *path) +{ + int ret; + + /* Bind parameters */ + sqlite3_bind_int64(ctx->stmt_delete_file, 1, id); + ret = sqlite3_step(ctx->stmt_delete_file); + if (ret != SQLITE_DONE) { + return -1; + } + + sqlite3_clear_bindings(ctx->stmt_delete_file); + sqlite3_reset(ctx->stmt_delete_file); + + if (ret != SQLITE_DONE) { + flb_plg_error(ctx->ins, "db: error deleting entry id=%" PRIu64 + ", path='%s' from database", id, path); + return -1; + } + + flb_plg_debug(ctx->ins, "db: file id=%" PRIu64 + ", path='%s' deleted from database", id, path); + return 0; +} + +#endif \ No newline at end of file diff --git a/plugins/in_blob/blob_db.h b/plugins/in_blob/blob_db.h new file mode 100644 index 00000000000..714dbdb6eac --- /dev/null +++ b/plugins/in_blob/blob_db.h @@ -0,0 +1,47 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* Fluent Bit + * ========== + * Copyright (C) 2015-2024 The Fluent Bit Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef IN_BLOB_DB_H +#define IN_BLOB_DB_H + +#define SQL_CREATE_BLOB_FILES \ + "CREATE TABLE IF NOT EXISTS in_blob_files (" \ + " id INTEGER PRIMARY KEY," \ + " path TEXT NOT NULL," \ + " size INTEGER," \ + " created INTEGER" \ + ");" + +#define SQL_INSERT_FILE \ + "INSERT INTO in_blob_files (path, size, created)" \ + " VALUES (@path, @size, @created);" + +#define SQL_DELETE_FILE \ + "DELETE FROM in_blob_files WHERE id=@id;" + +#define SQL_GET_FILE \ + "SELECT * from in_blob_files WHERE path=@path order by id desc;" + +struct flb_sqldb *blob_db_open(struct blob_ctx *ctx, char *db_path); +int blob_db_close(struct blob_ctx *ctx); +int blob_db_file_exists(struct blob_ctx *ctx, char *path, uint64_t *id); +int64_t blob_db_file_insert(struct blob_ctx *ctx, char *path, size_t size); +int blob_db_file_delete(struct blob_ctx *ctx, uint64_t id, char *path); + +#endif \ No newline at end of file diff --git a/plugins/in_blob/blob_file.c b/plugins/in_blob/blob_file.c new file mode 100644 index 00000000000..bf5aaf5caca --- /dev/null +++ b/plugins/in_blob/blob_file.c @@ -0,0 +1,123 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* Fluent Bit + * ========== + * Copyright (C) 2015-2024 The Fluent Bit Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include +#include + +#include "blob.h" +#include "blob_db.h" + +int blob_file_append(struct blob_ctx *ctx, char *path, struct stat *st) +{ + int fd; + int ret; + uint64_t id_found; + struct cfl_list *head; + struct blob_file *bfile; + struct flb_input_instance *ins = ctx->ins; + + /* check if the file already exists in the linked list in memory */ + cfl_list_foreach(head, &ctx->files) { + bfile = cfl_list_entry(head, struct blob_file, _head); + if (strcmp(bfile->path, path) == 0) { + /* file already exists */ + return -1; + } + } + +#ifdef FLB_HAVE_SQLDB + if (ctx->database_file) { + /* the file was already registered, just skipt it */ + if (blob_db_file_exists(ctx, path, &id_found) == FLB_TRUE) { + return 0; + } + } +#endif + + /* try to open the file */ + fd = open(path, O_RDONLY); + if (fd == -1) { + flb_errno(); + flb_plg_error(ctx->ins, "cannot open %s", path); + return -1; + } + close(fd); + + /* create the reference entry */ + bfile = flb_calloc(1, sizeof(struct blob_file)); + if (!bfile) { + flb_errno(); + return -1; + } + + bfile->path = cfl_sds_create(path); + if (!bfile->path) { + flb_free(bfile); + return -1; + } + bfile->size = st->st_size; + +#ifdef FLB_HAVE_SQLDB + /* insert the entry into the database */ + bfile->db_id = blob_db_file_insert(ctx, path, st->st_size); + if (bfile->db_id < 0) { + cfl_sds_destroy(bfile->path); + flb_free(bfile); + return -1; + } +#endif + + ret = flb_input_blob_file_register(ctx->ins, ctx->log_encoder, + ins->tag, ins->tag_len, + bfile->path, bfile->size); + if (ret == -1) { + cfl_sds_destroy(bfile->path); + flb_free(bfile); + return -1; + } + + cfl_list_add(&bfile->_head, &ctx->files); + return 0; +} + +/* release resources of a blob_file */ +void blob_file_list_remove(struct blob_file *bfile) +{ + if (bfile->path) { + cfl_sds_destroy(bfile->path); + } + flb_free(bfile); +} + +/* release all blob_files from the context list */ +void blob_file_list_remove_all(struct blob_ctx *ctx) +{ + struct cfl_list *head; + struct cfl_list *tmp; + struct blob_file *bfile; + + cfl_list_foreach_safe(head, tmp, &ctx->files) { + bfile = cfl_list_entry(head, struct blob_file, _head); + cfl_list_del(&bfile->_head); + blob_file_list_remove(bfile); + } +} \ No newline at end of file diff --git a/plugins/in_blob/blob_file.h b/plugins/in_blob/blob_file.h new file mode 100644 index 00000000000..2c2c5ecfc2e --- /dev/null +++ b/plugins/in_blob/blob_file.h @@ -0,0 +1,31 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* Fluent Bit + * ========== + * Copyright (C) 2015-2024 The Fluent Bit Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef IN_BLOB_FILE_H +#define IN_BLOB_FILE_H + +#include + +#include "blob.h" + +int blob_file_append(struct blob_ctx *ctx, char *path, struct stat *st); +void blob_file_list_remove(struct blob_file *bfile); +void blob_file_list_remove_all(struct blob_ctx *ctx); + +#endif \ No newline at end of file From 6df3149517c78a16161c2b7bffd328027fa9b409 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 16 Sep 2024 13:24:35 -0600 Subject: [PATCH 209/295] out_azure_blob: add support to upload large binary files The recent changes in Fluent Bit, allows to process Blob signal types which represents large binary files. When a blob arrives to the plugin, it's enqueued and processed through parts and uploaded as a Block Blob. Part sizes are configurable and survives service restart. example usage: service: flush: 1 log_level: info pipeline: inputs: - name: blob path: '~/logs/blob/*' database_file: blob.db outputs: - name: stdout match: '*' - name: azure_blob match: '*' path: kubernetes container_name: blobs auto_create_container: on database_file: azure.db part_size: 4M upload_parts_timeout: 1s workers: 10 account_name: abcdefghijk shared_key: asdkljaskldjaskldjaskldjasioduasoudaskldjaskld tls: on Signed-off-by: Eduardo Silva --- plugins/out_azure_blob/CMakeLists.txt | 1 + plugins/out_azure_blob/azure_blob.c | 650 ++++++++++++++---- plugins/out_azure_blob/azure_blob.h | 34 + plugins/out_azure_blob/azure_blob_blockblob.c | 254 +++++-- plugins/out_azure_blob/azure_blob_blockblob.h | 10 +- plugins/out_azure_blob/azure_blob_conf.c | 14 + plugins/out_azure_blob/azure_blob_db.c | 499 ++++++++++++++ plugins/out_azure_blob/azure_blob_db.h | 128 ++++ 8 files changed, 1403 insertions(+), 187 deletions(-) create mode 100644 plugins/out_azure_blob/azure_blob_db.c create mode 100644 plugins/out_azure_blob/azure_blob_db.h diff --git a/plugins/out_azure_blob/CMakeLists.txt b/plugins/out_azure_blob/CMakeLists.txt index 3624480e64a..f9e2a370741 100644 --- a/plugins/out_azure_blob/CMakeLists.txt +++ b/plugins/out_azure_blob/CMakeLists.txt @@ -3,6 +3,7 @@ set(src azure_blob_uri.c azure_blob_conf.c azure_blob_http.c + azure_blob_db.c azure_blob_appendblob.c azure_blob_blockblob.c ) diff --git a/plugins/out_azure_blob/azure_blob.c b/plugins/out_azure_blob/azure_blob.c index f35667fb378..b3ecf5dc874 100644 --- a/plugins/out_azure_blob/azure_blob.c +++ b/plugins/out_azure_blob/azure_blob.c @@ -25,10 +25,14 @@ #include #include #include +#include +#include +#include #include #include "azure_blob.h" +#include "azure_blob_db.h" #include "azure_blob_uri.h" #include "azure_blob_conf.h" #include "azure_blob_appendblob.h" @@ -37,6 +41,14 @@ #define CREATE_BLOB 1337 +/* thread_local_storage for workers */ + +struct worker_info { + int active_upload; +}; + +FLB_TLS_DEFINE(struct worker_info, worker_info); + static int azure_blob_format(struct flb_config *config, struct flb_input_instance *ins, void *plugin_context, @@ -62,40 +74,16 @@ static int azure_blob_format(struct flb_config *config, return 0; } -static int send_blob(struct flb_config *config, - struct flb_input_instance *i_ins, - struct flb_azure_blob *ctx, char *name, - char *tag, int tag_len, void *data, size_t bytes) +static int create_blob(struct flb_azure_blob *ctx, char *name) { int ret; - int compressed = FLB_FALSE; - int content_encoding = FLB_FALSE; - int content_type = FLB_FALSE; - uint64_t ms = 0; size_t b_sent; - void *out_buf; - size_t out_size; flb_sds_t uri = NULL; - flb_sds_t blockid = NULL; - void *payload_buf; - size_t payload_size; struct flb_http_client *c; struct flb_connection *u_conn; - if (ctx->btype == AZURE_BLOB_APPENDBLOB) { - uri = azb_append_blob_uri(ctx, tag); - } - else if (ctx->btype == AZURE_BLOB_BLOCKBLOB) { - blockid = azb_block_blob_id(&ms); - if (!blockid) { - flb_plg_error(ctx->ins, "could not generate block id"); - return FLB_RETRY; - } - uri = azb_block_blob_uri(ctx, tag, blockid, ms); - } - + uri = azb_uri_create_blob(ctx, name); if (!uri) { - flb_free(blockid); return FLB_RETRY; } @@ -103,44 +91,107 @@ static int send_blob(struct flb_config *config, u_conn = flb_upstream_conn_get(ctx->u); if (!u_conn) { flb_plg_error(ctx->ins, - "cannot create upstream connection for append_blob"); + "cannot create upstream connection for create_append_blob"); flb_sds_destroy(uri); - flb_free(blockid); return FLB_RETRY; } - /* Format the data */ - ret = azure_blob_format(config, i_ins, - ctx, NULL, - FLB_EVENT_TYPE_LOGS, - tag, tag_len, - data, bytes, - &out_buf, &out_size); - if (ret != 0) { + /* Create HTTP client context */ + c = flb_http_client(u_conn, FLB_HTTP_PUT, + uri, + NULL, 0, NULL, 0, NULL, 0); + if (!c) { + flb_plg_error(ctx->ins, "cannot create HTTP client context"); flb_upstream_conn_release(u_conn); flb_sds_destroy(uri); - flb_free(blockid); return FLB_RETRY; } - /* Map buffer */ - payload_buf = out_buf; - payload_size = out_size; + /* Prepare headers and authentication */ + azb_http_client_setup(ctx, c, -1, FLB_TRUE, + AZURE_BLOB_CT_NONE, AZURE_BLOB_CE_NONE); - if (ctx->compress_gzip == FLB_TRUE || ctx->compress_blob == FLB_TRUE) { - ret = flb_gzip_compress((void *) out_buf, out_size, - &payload_buf, &payload_size); - if (ret == -1) { - flb_plg_error(ctx->ins, - "cannot gzip payload, disabling compression"); + /* Send HTTP request */ + ret = flb_http_do(c, &b_sent); + flb_sds_destroy(uri); + + if (ret == -1) { + flb_plg_error(ctx->ins, "error sending append_blob"); + flb_http_client_destroy(c); + flb_upstream_conn_release(u_conn); + return FLB_RETRY; + } + + if (c->resp.status == 201) { + /* delete "&sig=..." in the c->uri for security */ + char *p = strstr(c->uri, "&sig="); + if (p) { + *p = '\0'; + } + flb_plg_info(ctx->ins, "blob created successfully: %s", c->uri); + } + else { + if (c->resp.payload_size > 0) { + flb_plg_error(ctx->ins, "http_status=%i cannot create append blob\n%s", + c->resp.status, c->resp.payload); } else { + flb_plg_error(ctx->ins, "http_status=%i cannot create append blob", + c->resp.status); + } + flb_http_client_destroy(c); + flb_upstream_conn_release(u_conn); + return FLB_RETRY; + } + + flb_http_client_destroy(c); + flb_upstream_conn_release(u_conn); + return FLB_OK; +} + +static int http_send_blob(struct flb_config *config, struct flb_azure_blob *ctx, + flb_sds_t ref_name, + flb_sds_t uri, + flb_sds_t block_id, + int event_type, + void *data, size_t bytes) +{ + int ret; + int compressed = FLB_FALSE; + int content_encoding = FLB_FALSE; + int content_type = FLB_FALSE; + size_t b_sent; + void *payload_buf; + size_t payload_size; + struct flb_http_client *c; + struct flb_connection *u_conn; + + /* Get upstream connection */ + u_conn = flb_upstream_conn_get(ctx->u); + if (!u_conn) { + flb_plg_error(ctx->ins, + "cannot create TCP upstream connection"); + return FLB_RETRY; + } + + payload_buf = data; + payload_size = bytes; + + /* Handle compression requests */ + if (ctx->compress_gzip == FLB_TRUE || ctx->compress_blob == FLB_TRUE) { + ret = flb_gzip_compress((void *) data, bytes, &payload_buf, &payload_size); + if (ret == 0) { compressed = FLB_TRUE; - /* JSON buffer is not longer needed */ - flb_sds_destroy(out_buf); + } + else { + flb_plg_warn(ctx->ins, + "cannot gzip payload, disabling compression"); + payload_buf = data; + payload_size = bytes; } } + /* set http header flags */ if (ctx->compress_blob == FLB_TRUE) { content_encoding = AZURE_BLOB_CE_NONE; content_type = AZURE_BLOB_CT_GZIP; @@ -156,9 +207,10 @@ static int send_blob(struct flb_config *config, payload_buf, payload_size, NULL, 0, NULL, 0); if (!c) { flb_plg_error(ctx->ins, "cannot create HTTP client context"); - flb_sds_destroy(out_buf); + if (compressed == FLB_TRUE) { + flb_free(payload_buf); + } flb_upstream_conn_release(u_conn); - flb_free(blockid); return FLB_RETRY; } @@ -168,13 +220,9 @@ static int send_blob(struct flb_config *config, /* Send HTTP request */ ret = flb_http_do(c, &b_sent); - flb_sds_destroy(uri); - /* Release */ - if (compressed == FLB_FALSE) { - flb_sds_destroy(out_buf); - } - else { + /* Release compressed buffer */ + if (compressed == FLB_TRUE) { flb_free(payload_buf); } @@ -182,21 +230,13 @@ static int send_blob(struct flb_config *config, /* Validate HTTP status */ if (ret == -1) { - flb_plg_error(ctx->ins, "error sending append_blob"); - flb_free(blockid); + flb_plg_error(ctx->ins, "error sending append_blob for %s", ref_name); return FLB_RETRY; } if (c->resp.status == 201) { - flb_plg_info(ctx->ins, "content appended to blob successfully"); + flb_plg_info(ctx->ins, "content uploaded successfully: %s", ref_name); flb_http_client_destroy(c); - - if (ctx->btype == AZURE_BLOB_BLOCKBLOB) { - ret = azb_block_blob_commit(ctx, blockid, tag, ms); - flb_free(blockid); - return ret; - } - flb_free(blockid); return FLB_OK; } else if (c->resp.status == 404) { @@ -211,94 +251,115 @@ static int send_blob(struct flb_config *config, return CREATE_BLOB; } else if (c->resp.payload_size > 0) { - flb_plg_error(ctx->ins, "cannot append content to blob\n%s", - c->resp.payload); + flb_plg_error(ctx->ins, "http_status=%i cannot append content to blob\n%s", + c->resp.status, c->resp.payload); if (strstr(c->resp.payload, "must be 0 for Create Append")) { flb_http_client_destroy(c); return CREATE_BLOB; } } else { - flb_plg_error(ctx->ins, "cannot append content to blob"); + flb_plg_error(ctx->ins, "cannot upload %s content to blob (http_status=%i)", + ref_name, c->resp.status); } flb_http_client_destroy(c); return FLB_RETRY; } -static int create_blob(struct flb_azure_blob *ctx, char *name) +static int send_blob(struct flb_config *config, + struct flb_input_instance *i_ins, + struct flb_azure_blob *ctx, + int event_type, + int blob_type, char *name, uint64_t part_id, + char *tag, int tag_len, void *data, size_t bytes) { int ret; - size_t b_sent; + uint64_t ms = 0; flb_sds_t uri = NULL; - struct flb_http_client *c; - struct flb_connection *u_conn; + flb_sds_t block_id = NULL; + flb_sds_t ref_name = NULL; + void *payload_buf = data; + size_t payload_size = bytes; - uri = azb_uri_create_blob(ctx, name); - if (!uri) { + ref_name = flb_sds_create_size(256); + if (!ref_name) { return FLB_RETRY; } - /* Get upstream connection */ - u_conn = flb_upstream_conn_get(ctx->u); - if (!u_conn) { - flb_plg_error(ctx->ins, - "cannot create upstream connection for create_append_blob"); - flb_sds_destroy(uri); - return FLB_RETRY; + if (blob_type == AZURE_BLOB_APPENDBLOB) { + uri = azb_append_blob_uri(ctx, tag); + } + else if (blob_type == AZURE_BLOB_BLOCKBLOB) { + if (event_type == FLB_EVENT_TYPE_LOGS) { + block_id = azb_block_blob_id_logs(&ms); + if (!block_id) { + flb_plg_error(ctx->ins, "could not generate block id"); + return FLB_RETRY; + } + uri = azb_block_blob_uri(ctx, tag, block_id, ms); + ref_name = flb_sds_printf(&ref_name, "file=%s.%" PRIu64, name, ms); + } + else if (event_type == FLB_EVENT_TYPE_BLOBS) { + block_id = azb_block_blob_id_blob(ctx, name, part_id); + uri = azb_block_blob_uri(ctx, name, block_id, 0); + ref_name = flb_sds_printf(&ref_name, "file=%s:%" PRIu64, name, part_id); + } } - /* Create HTTP client context */ - c = flb_http_client(u_conn, FLB_HTTP_PUT, - uri, - NULL, 0, NULL, 0, NULL, 0); - if (!c) { - flb_plg_error(ctx->ins, "cannot create HTTP client context"); - flb_upstream_conn_release(u_conn); - flb_sds_destroy(uri); + if (!uri) { + flb_free(block_id); + flb_sds_destroy(ref_name); return FLB_RETRY; } - /* Prepare headers and authentication */ - azb_http_client_setup(ctx, c, -1, FLB_TRUE, - AZURE_BLOB_CT_NONE, AZURE_BLOB_CE_NONE); + /* Logs: Format the data (msgpack -> JSON) */ + if (event_type == FLB_EVENT_TYPE_LOGS) { + ret = azure_blob_format(config, i_ins, + ctx, NULL, + FLB_EVENT_TYPE_LOGS, + tag, tag_len, + data, bytes, + &payload_buf, &payload_size); + if (ret != 0) { + flb_sds_destroy(uri); + flb_free(block_id); + flb_sds_destroy(ref_name); + return FLB_ERROR; + } + } + else if (event_type == FLB_EVENT_TYPE_BLOBS) { + payload_buf = data; + payload_size = bytes; + } - /* Send HTTP request */ - ret = flb_http_do(c, &b_sent); - flb_sds_destroy(uri); - if (ret == -1) { - flb_plg_error(ctx->ins, "error sending append_blob"); - flb_http_client_destroy(c); - flb_upstream_conn_release(u_conn); - return FLB_RETRY; - } + ret = http_send_blob(config, ctx, ref_name, uri, block_id, event_type, payload_buf, payload_size); + flb_plg_debug(ctx->ins, "http_send_blob()=%i", ret); - if (c->resp.status == 201) { - /* delete "&sig=..." in the c->uri for security */ - char *p = strstr(c->uri, "&sig="); - if (p) { - *p = '\0'; + if (ret == FLB_OK) { + /* For Logs type, we need to commit the block right away */ + if (event_type == FLB_EVENT_TYPE_LOGS) { + ret = azb_block_blob_commit_block(ctx, block_id, tag, ms); + flb_free(block_id); } - flb_plg_info(ctx->ins, "blob created successfully: %s", c->uri); } - else { - if (c->resp.payload_size > 0) { - flb_plg_error(ctx->ins, "http_status=%i cannot create append blob\n%s", - c->resp.status, c->resp.payload); - } - else { - flb_plg_error(ctx->ins, "http_status=%i cannot create append blob", - c->resp.status); + else if (ret == CREATE_BLOB) { + ret = create_blob(ctx, name); + if (ret == FLB_OK) { + ret = http_send_blob(config, ctx, ref_name, uri, block_id, event_type, payload_buf, payload_size); } - flb_http_client_destroy(c); - flb_upstream_conn_release(u_conn); - return FLB_RETRY; } + flb_sds_destroy(ref_name); - flb_http_client_destroy(c); - flb_upstream_conn_release(u_conn); - return FLB_OK; + if (payload_buf != data) { + flb_sds_destroy(payload_buf); + } + + flb_sds_destroy(uri); + flb_free(block_id); + + return ret; } static int create_container(struct flb_azure_blob *ctx, char *name) @@ -456,6 +517,8 @@ static int cb_azure_blob_init(struct flb_output_instance *ins, (void) config; (void) data; + FLB_TLS_INIT(worker_info); + ctx = flb_azure_blob_conf_create(ins, config); if (!ctx) { return -1; @@ -465,36 +528,284 @@ static int cb_azure_blob_init(struct flb_output_instance *ins, return 0; } +static int blob_chunk_register_parts(struct flb_azure_blob *ctx, uint64_t file_id, size_t total_size) +{ + int ret; + int64_t parts = 0; + int64_t id; + size_t offset_start = 0; + size_t offset_end = 0; + + /* generate file parts */ + while (offset_start < total_size) { + offset_end = offset_start + ctx->part_size; + + /* do not exceed maximum size */ + if (offset_end > total_size) { + offset_end = total_size; + } + + /* insert part */ + ret = azb_db_file_part_insert(ctx, file_id, parts, offset_start, offset_end, &id); + if (ret == -1) { + flb_plg_error(ctx->ins, "cannot insert blob file part into database"); + return -1; + } + offset_start = offset_end; + parts++; + } + + return parts; +} + +static int process_blob_chunk(struct flb_azure_blob *ctx, struct flb_event_chunk *event_chunk) +{ + int64_t ret; + int64_t file_id; + cfl_sds_t file_path = NULL; + size_t file_size; + msgpack_object map; + + struct flb_log_event_decoder log_decoder; + struct flb_log_event log_event; + + ret = flb_log_event_decoder_init(&log_decoder, + (char *) event_chunk->data, + event_chunk->size); + + if (ret != FLB_EVENT_DECODER_SUCCESS) { + flb_plg_error(ctx->ins, + "Log event decoder initialization error : %i", (int) ret); + return -1; + + } + + while (flb_log_event_decoder_next(&log_decoder, &log_event) == FLB_EVENT_DECODER_SUCCESS) { + map = *log_event.body; + ret = flb_input_blob_file_get_info(map, &file_path, &file_size); + if (ret == -1) { + flb_plg_error(ctx->ins, "cannot get file info from blob record, skipping"); + continue; + } + + ret = azb_db_file_insert(ctx, file_path, file_size); + if (ret == -1) { + flb_plg_error(ctx->ins, "cannot insert blob file into database: %s (size=%lu)", + file_path, file_size); + cfl_sds_destroy(file_path); + continue; + } + cfl_sds_destroy(file_path); + + /* generate the parts by using the newest id created (ret) */ + file_id = ret; + ret = blob_chunk_register_parts(ctx, file_id, file_size); + if (ret == -1) { + flb_plg_error(ctx->ins, "cannot register blob file '%s 'parts into database", + file_path); + return -1; + } + + flb_plg_debug(ctx->ins, "blob file '%s' (id=%zu) registered with %zu parts", + file_path, file_id, ret); + + + } + + flb_log_event_decoder_destroy(&log_decoder); + return 0; +} + +static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context) +{ + int ret; + char *out_buf = NULL; + size_t out_size; + uint64_t id; + uint64_t file_id; + uint64_t part_id; + off_t offset_start; + off_t offset_end; + cfl_sds_t file_path = NULL; + cfl_sds_t part_ids = NULL; + struct flb_azure_blob *ctx = out_context; + struct worker_info *info; + + info = FLB_TLS_GET(worker_info); + if (info->active_upload) { + flb_plg_trace(ctx->ins, "[worker: file upload] upload already in progress..."); + flb_sched_timer_cb_coro_return(); + } + + info->active_upload = FLB_TRUE; + + /* + * Check if is there any file which has been fully uploaded and we need to commit it with + * the Put Block List operation + */ + + pthread_mutex_lock(&ctx->file_upload_commit_file_parts); + + ret = azb_db_file_oldest_ready(ctx, &file_id, &file_path, &part_ids); + if (ret == 0) { + flb_plg_trace(ctx->ins, "no blob files ready to commit"); + } + else if (ret == -1) { + flb_plg_error(ctx->ins, "cannot get oldest blob file ready to upload"); + } + else if (ret == 1) { + /* one file is ready to be committed */ + flb_plg_debug(ctx->ins, "blob file '%s' (id=%" PRIu64 ") ready to upload", file_path, file_id); + ret = azb_block_blob_commit_file_parts(ctx, file_id, file_path, part_ids); + if (ret == -1) { + flb_plg_error(ctx->ins, "cannot commit blob file parts for file id=%" PRIu64 " path=%s", + file_id, file_path); + + } + else { + flb_plg_info(ctx->ins, "blob file '%s' (id=%" PRIu64 ") committed successfully", file_path, file_id); + /* notify the engine the blob file has been processed */ + /* FIXME! */ + + /* remove the file entry from the database */ + ret = azb_db_file_delete(ctx, file_id, file_path); + if (ret == -1) { + flb_plg_error(ctx->ins, "cannot delete blob file '%s' (id=%" PRIu64 ") from the database", + file_path, file_id); + } + } + } + pthread_mutex_unlock(&ctx->file_upload_commit_file_parts); + + if (file_path) { + cfl_sds_destroy(file_path); + } + if (part_ids) { + cfl_sds_destroy(part_ids); + } + + /* check for a next part file and lock it */ + ret = azb_db_file_part_get_next(ctx, &id, &file_id, &part_id, &offset_start, &offset_end, &file_path); + if (ret == -1) { + flb_plg_error(ctx->ins, "cannot get next blob file part"); + info->active_upload = FLB_FALSE; + flb_sched_timer_cb_coro_return(); + } + else if (ret == 0) { + flb_plg_trace(ctx->ins, "no more blob file parts to process"); + info->active_upload = FLB_FALSE; + flb_sched_timer_cb_coro_return(); + } + else if (ret == 1) { + /* just continue, the row info was retrieved */ + } + + /* read the file content */ + ret = flb_utils_read_file_offset(file_path, offset_start, offset_end, &out_buf, &out_size); + if (ret == -1) { + flb_plg_error(ctx->ins, "cannot read file part %s", file_path); + cfl_sds_destroy(file_path); + info->active_upload = FLB_FALSE; + flb_sched_timer_cb_coro_return(); + } + + flb_plg_debug(ctx->ins, "sending part file %s (id=%" PRIu64 " part_id=%" PRIu64 ")", file_path, id, part_id); + ret = send_blob(config, NULL, ctx, FLB_EVENT_TYPE_BLOBS, + AZURE_BLOB_BLOCKBLOB, file_path, part_id, NULL, 0, out_buf, out_size); + if (ret == FLB_OK) { + ret = azb_db_file_part_uploaded(ctx, id); + if (ret == -1) { + info->active_upload = FLB_FALSE; + flb_sched_timer_cb_coro_return(); + } + } + else if (ret == FLB_RETRY) { + /* FIXME */ + } + info->active_upload = FLB_FALSE; + + if (out_buf) { + flb_free(out_buf); + } + cfl_sds_destroy(file_path); + flb_sched_timer_cb_coro_return(); +} + +static int azb_timer_create(struct flb_azure_blob *ctx) +{ + int ret; + int64_t ms; + struct flb_sched *sched; + + sched = flb_sched_ctx_get(); + + /* convert from seconds to milliseconds (scheduler needs ms) */ + ms = ctx->upload_parts_timeout * 1000; + + ret = flb_sched_timer_coro_cb_create(sched, FLB_SCHED_TIMER_CB_PERM, ms, + cb_azb_blob_file_upload, ctx, NULL); + if (ret == -1) { + flb_plg_error(ctx->ins, "failed to create upload timer"); + return -1; + } + + return 0; +} + static void cb_azure_blob_flush(struct flb_event_chunk *event_chunk, struct flb_output_flush *out_flush, struct flb_input_instance *i_ins, void *out_context, struct flb_config *config) { - int ret; + int ret = FLB_OK; struct flb_azure_blob *ctx = out_context; (void) i_ins; (void) config; - /* Validate the container exists, otherwise just create it */ + /* + * Azure blob requires a container. The following function validate that the container exists, + * otherwise it will be created. Note that that container name is specified by the user + * in the configuration file. + * + * https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-container-create#about-container-naming + */ ret = ensure_container(ctx); if (ret == FLB_FALSE) { FLB_OUTPUT_RETURN(FLB_RETRY); } - ret = send_blob(config, i_ins, ctx, - (char *) event_chunk->tag, /* use tag as 'name' */ - (char *) event_chunk->tag, flb_sds_len(event_chunk->tag), - (char *) event_chunk->data, event_chunk->size); - - if (ret == CREATE_BLOB) { - ret = create_blob(ctx, event_chunk->tag); - if (ret == FLB_OK) { - ret = send_blob(config, i_ins, ctx, - (char *) event_chunk->tag, /* use tag as 'name' */ - (char *) event_chunk->tag, - flb_sds_len(event_chunk->tag), - (char *) event_chunk->data, event_chunk->size); + if (event_chunk->type == FLB_EVENT_TYPE_LOGS) { + ret = send_blob(config, i_ins, ctx, + FLB_EVENT_TYPE_LOGS, + ctx->btype, /* blob type per user configuration */ + (char *) event_chunk->tag, /* use tag as 'name' */ + 0, /* part id */ + (char *) event_chunk->tag, flb_sds_len(event_chunk->tag), + (char *) event_chunk->data, event_chunk->size); + + if (ret == CREATE_BLOB) { + ret = create_blob(ctx, event_chunk->tag); + if (ret == FLB_OK) { + ret = send_blob(config, i_ins, ctx, + FLB_EVENT_TYPE_LOGS, + ctx->btype, /* blob type per user configuration */ + (char *) event_chunk->tag, /* use tag as 'name' */ + 0, /* part id */ + (char *) event_chunk->tag, /* use tag as 'name' */ + flb_sds_len(event_chunk->tag), + (char *) event_chunk->data, event_chunk->size); + } + } + } + else if (event_chunk->type == FLB_EVENT_TYPE_BLOBS) { + /* + * For Blob types, we use the flush callback to enqueue the file, then cb_azb_blob_file_upload() + * takes care of the rest like reading the file and uploading it to Azure. + */ + ret = process_blob_chunk(ctx, event_chunk); + if (ret == -1) { + FLB_OUTPUT_RETURN(FLB_RETRY); } } @@ -514,6 +825,36 @@ static int cb_azure_blob_exit(void *data, struct flb_config *config) return 0; } +/* worker initialization, used for our internal timers */ +static int cb_worker_init(void *data, struct flb_config *config) +{ + int ret; + struct worker_info *info; + struct flb_azure_blob *ctx = data; + + flb_plg_info(ctx->ins, "initializing worker"); + + info = FLB_TLS_GET(worker_info); + if (!info) { + /* initialize worker global info */ + info = flb_malloc(sizeof(struct worker_info)); + if (!info) { + flb_errno(); + return -1; + } + info->active_upload = FLB_FALSE; + FLB_TLS_SET(worker_info, info); + } + + ret = azb_timer_create(ctx); + if (ret == -1) { + flb_plg_error(ctx->ins, "failed to create upload timer"); + return -1; + } + + return 0; +} + /* Configuration properties map */ static struct flb_config_map config_map[] = { { @@ -595,23 +936,42 @@ static struct flb_config_map config_map[] = { "Azure Blob SAS token" }, + { + FLB_CONFIG_MAP_STR, "database_file", NULL, + 0, FLB_TRUE, offsetof(struct flb_azure_blob, database_file), + "Absolute path to a database file to be used to store blob files contexts" + }, + + { + FLB_CONFIG_MAP_SIZE, "part_size", "25M", + 0, FLB_TRUE, offsetof(struct flb_azure_blob, part_size), + "Size of each part when uploading blob files" + }, + + { + FLB_CONFIG_MAP_TIME, "upload_parts_timeout", "10M", + 0, FLB_TRUE, offsetof(struct flb_azure_blob, upload_parts_timeout), + "Timeout to upload parts of a blob file" + }, + /* EOF */ {0} }; /* Plugin registration */ struct flb_output_plugin out_azure_blob_plugin = { - .name = "azure_blob", - .description = "Azure Blob Storage", - .cb_init = cb_azure_blob_init, - .cb_flush = cb_azure_blob_flush, - .cb_exit = cb_azure_blob_exit, + .name = "azure_blob", + .description = "Azure Blob Storage", + .cb_init = cb_azure_blob_init, + .cb_flush = cb_azure_blob_flush, + .cb_exit = cb_azure_blob_exit, + .cb_worker_init = cb_worker_init, /* Test */ .test_formatter.callback = azure_blob_format, + .flags = FLB_OUTPUT_NET | FLB_IO_OPT_TLS, + .event_type = FLB_OUTPUT_LOGS | FLB_OUTPUT_BLOBS, .config_map = config_map, - - /* Plugin flags */ - .flags = FLB_OUTPUT_NET | FLB_IO_OPT_TLS, + .workers = 1, }; diff --git a/plugins/out_azure_blob/azure_blob.h b/plugins/out_azure_blob/azure_blob.h index b1812927adb..68784f0f9fc 100644 --- a/plugins/out_azure_blob/azure_blob.h +++ b/plugins/out_azure_blob/azure_blob.h @@ -23,6 +23,7 @@ #include #include #include +#include /* Content-Type */ #define AZURE_BLOB_CT "Content-Type" @@ -58,6 +59,9 @@ struct flb_azure_blob { flb_sds_t date_key; flb_sds_t auth_type; flb_sds_t sas_token; + flb_sds_t database_file; + size_t part_size; + time_t upload_parts_timeout; /* * Internal use @@ -72,9 +76,39 @@ struct flb_azure_blob { unsigned char *decoded_sk; /* decoded shared key */ size_t decoded_sk_size; /* size of decoded shared key */ +#ifdef FLB_HAVE_SQLDB + /* + * SQLite by default is not built with multi-threading enabled, and + * since we aim to share the database connection and prepared statements + * in the output workers, we need to protect the access to these + * resources using a mutex. + */ + pthread_mutex_t db_lock; + + pthread_mutex_t file_upload_commit_file_parts; + + /* database context */ + struct flb_sqldb *db; + + /* prepared statements: files */ + sqlite3_stmt *stmt_insert_file; + sqlite3_stmt *stmt_delete_file; + sqlite3_stmt *stmt_get_file; + + /* prepared statement: file parts */ + sqlite3_stmt *stmt_insert_file_part; + sqlite3_stmt *stmt_update_file_part_uploaded; + + sqlite3_stmt *stmt_get_next_file_part; + sqlite3_stmt *stmt_update_file_part_in_progress; + sqlite3_stmt *stmt_get_oldest_file_with_parts; +#endif + /* Upstream connection */ struct flb_upstream *u; + struct flb_output_instance *ins; + struct flb_config *config; }; #endif diff --git a/plugins/out_azure_blob/azure_blob_blockblob.c b/plugins/out_azure_blob/azure_blob_blockblob.c index 8a47a700967..5acb03689b9 100644 --- a/plugins/out_azure_blob/azure_blob_blockblob.c +++ b/plugins/out_azure_blob/azure_blob_blockblob.c @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include @@ -29,7 +31,31 @@ #include "azure_blob_uri.h" #include "azure_blob_http.h" -flb_sds_t azb_block_blob_uri(struct flb_azure_blob *ctx, char *tag, +flb_sds_t azb_block_blob_blocklist_uri(struct flb_azure_blob *ctx, char *name) +{ + flb_sds_t uri; + + uri = azb_uri_container(ctx); + if (!uri) { + return NULL; + } + + if (ctx->path) { + flb_sds_printf(&uri, "/%s/%s?comp=blocklist", + ctx->path, name); + } + else { + flb_sds_printf(&uri, "/%s?comp=blocklist", name); + } + + if (ctx->atype == AZURE_BLOB_AUTH_SAS && ctx->sas_token) { + flb_sds_printf(&uri, "&%s", ctx->sas_token); + } + + return uri; +} + +flb_sds_t azb_block_blob_uri(struct flb_azure_blob *ctx, char *name, char *blockid, uint64_t ms) { int len; @@ -57,12 +83,24 @@ flb_sds_t azb_block_blob_uri(struct flb_azure_blob *ctx, char *tag, } if (ctx->path) { - flb_sds_printf(&uri, "/%s/%s.%" PRIu64 "%s?blockid=%s&comp=block", - ctx->path, tag, ms, ext, encoded_blockid); + if (ms > 0) { + flb_sds_printf(&uri, "/%s/%s.%" PRIu64 "%s?blockid=%s&comp=block", + ctx->path, name, ms, ext, encoded_blockid); + } + else { + flb_sds_printf(&uri, "/%s/%s%s?blockid=%s&comp=block", + ctx->path, name, ext, encoded_blockid); + } } else { - flb_sds_printf(&uri, "/%s.%" PRIu64 "%s?blockid=%s&comp=block", - tag, ms, ext, encoded_blockid); + if (ms > 0) { + flb_sds_printf(&uri, "/%s.%" PRIu64 "%s?blockid=%s&comp=block", + name, ms, ext, encoded_blockid); + } + else { + flb_sds_printf(&uri, "/%s%s?blockid=%s&comp=block", + name, ext, encoded_blockid); + } } if (ctx->atype == AZURE_BLOB_AUTH_SAS && ctx->sas_token) { @@ -106,8 +144,11 @@ flb_sds_t azb_block_blob_uri_commit(struct flb_azure_blob *ctx, return uri; } -/* Generate a block id */ -char *azb_block_blob_id(uint64_t *ms) +/* + * Generate a block id for log type events, we always submit one chunk as a block, so + * we just use the current time in milliseconds as a suffix. + */ +char *azb_block_blob_id_logs(uint64_t *ms) { int len; int ret; @@ -148,13 +189,72 @@ char *azb_block_blob_id(uint64_t *ms) return b64; } -int azb_block_blob_commit(struct flb_azure_blob *ctx, char *blockid, char *tag, - uint64_t ms) +/* + * Generate a block id for blob type events: + * + * Azure Blob requires that Blobs IDs do not exceed 64 bytes, so we generate a MD5 + * of the path and append the part number to it, we add some zeros for padding since + * all blocks id MUST have the same length. + */ +char *azb_block_blob_id_blob(struct flb_azure_blob *ctx, char *path, int64_t part_id) +{ + int i; + int len; + int ret; + unsigned char md5[16] = {0}; + char tmp[128]; + flb_sds_t md5_hex; + size_t size; + size_t o_len; + char *b64; + + /* + * block ids in base64 cannot exceed 64 bytes, so we hash the path to avoid + * exceeding the lenght and then just append the part number. + */ + ret = flb_hash_simple(FLB_HASH_MD5, (unsigned char *) path, strlen(path), + md5, sizeof(md5)); + if (ret != 0) { + flb_plg_error(ctx->ins, "cannot hash block id for path %s", path); + return NULL; + } + + /* convert md5 to hex string (32 byte hex string) */ + md5_hex = flb_sds_create_size(32); + if (!md5_hex) { + return NULL; + } + + for (i = 0; i < 16; i++) { + snprintf(md5_hex + (i * 2), 3, "%02x", md5[i]); + } + flb_sds_len_set(md5_hex, 32); + + /* append part number */ + len = snprintf(tmp, sizeof(tmp) - 1, "%s.flb-part.%06ld", md5_hex, part_id); + flb_sds_destroy(md5_hex); + + size = 64 + 1; + b64 = flb_calloc(1, size); + if (!b64) { + return NULL; + } + + /* base64 encode block id */ + ret = flb_base64_encode((unsigned char *) b64, size, &o_len, + (unsigned char *) tmp, len); + if (ret != 0) { + flb_free(b64); + return NULL; + } + + return b64; +} + +int azb_block_blob_put_block_list(struct flb_azure_blob *ctx, flb_sds_t uri, flb_sds_t payload) { int ret; size_t b_sent; - flb_sds_t uri = NULL; - flb_sds_t payload; struct flb_http_client *c; struct flb_connection *u_conn; @@ -166,35 +266,12 @@ int azb_block_blob_commit(struct flb_azure_blob *ctx, char *blockid, char *tag, return FLB_RETRY; } - /* Compose commit URI */ - uri = azb_block_blob_uri_commit(ctx, tag, ms); - if (!uri) { - flb_upstream_conn_release(u_conn); - return FLB_ERROR; - } - - payload = flb_sds_create_size(256); - if (!payload) { - flb_sds_destroy(uri); - flb_upstream_conn_release(u_conn); - return FLB_ERROR; - } - - flb_sds_printf(&payload, - "" - "" - " %s" - "", - blockid); - /* Create HTTP client context */ c = flb_http_client(u_conn, FLB_HTTP_PUT, uri, payload, flb_sds_len(payload), NULL, 0, NULL, 0); if (!c) { flb_plg_error(ctx->ins, "cannot create HTTP client context"); - flb_sds_destroy(payload); - flb_sds_destroy(uri); flb_upstream_conn_release(u_conn); return FLB_RETRY; } @@ -206,8 +283,6 @@ int azb_block_blob_commit(struct flb_azure_blob *ctx, char *blockid, char *tag, /* Send HTTP request */ ret = flb_http_do(c, &b_sent); - flb_sds_destroy(uri); - flb_sds_destroy(payload); /* Validate HTTP status */ if (ret == -1) { @@ -216,7 +291,6 @@ int azb_block_blob_commit(struct flb_azure_blob *ctx, char *blockid, char *tag, } if (c->resp.status == 201) { - flb_plg_info(ctx->ins, "blob id %s committed successfully", blockid); flb_http_client_destroy(c); flb_upstream_conn_release(u_conn); return FLB_OK; @@ -234,8 +308,8 @@ int azb_block_blob_commit(struct flb_azure_blob *ctx, char *blockid, char *tag, return FLB_RETRY; } else if (c->resp.payload_size > 0) { - flb_plg_error(ctx->ins, "cannot commit blob id %s\n%s", - blockid, c->resp.payload); + // flb_plg_error(ctx->ins, "cannot commit blob id %s\n%s", + // blockid, c->resp.payload); if (strstr(c->resp.payload, "must be 0 for Create Append")) { flb_http_client_destroy(c); flb_upstream_conn_release(u_conn); @@ -250,3 +324,105 @@ int azb_block_blob_commit(struct flb_azure_blob *ctx, char *blockid, char *tag, return FLB_OK; } + +/* Commit a single block */ +int azb_block_blob_commit_block(struct flb_azure_blob *ctx, char *blockid, char *tag, uint64_t ms) +{ + int ret; + flb_sds_t uri = NULL; + flb_sds_t payload; + + /* Compose commit URI */ + uri = azb_block_blob_uri_commit(ctx, tag, ms); + if (!uri) { + return FLB_ERROR; + } + + payload = flb_sds_create_size(256); + if (!payload) { + flb_sds_destroy(uri); + return FLB_ERROR; + } + + flb_sds_printf(&payload, + "" + "" + " %s" + "", + blockid); + + ret = azb_block_blob_put_block_list(ctx, uri, payload); + flb_sds_destroy(uri); + flb_sds_destroy(payload); + + if (ret == FLB_OK) { + flb_plg_info(ctx->ins, "blob id %s committed successfully", blockid); + } + + return ret; +} + +int azb_block_blob_commit_file_parts(struct flb_azure_blob *ctx, uint64_t file_id, cfl_sds_t path, cfl_sds_t part_ids) +{ + int ret; + uint64_t id; + char *block_id; + cfl_sds_t payload; + flb_sds_t uri; + struct mk_list *list; + struct mk_list *head; + struct flb_split_entry *sentry; + + /* split parts in a list */ + list = flb_utils_split(part_ids, ',', -1); + if (!list) { + flb_plg_error(ctx->ins, "cannot split parts list for file id=%" PRIu64 " name %s", file_id, path); + return -1; + } + + payload = flb_sds_create_size(1024); + if (!payload) { + flb_utils_split_free(list); + return -1; + } + + /* + * Compose XML with list of blocks + * https://learn.microsoft.com/en-us/rest/api/storageservices/put-block-list?tabs=microsoft-entra-id#request-body + */ + cfl_sds_printf(&payload, + "\n" + "\n" + "\n", + path); + + mk_list_foreach(head, list) { + sentry = mk_list_entry(head, struct flb_split_entry, _head); + + id = atol(sentry->value); + block_id = azb_block_blob_id_blob(ctx, path, id); + + cfl_sds_cat_safe(&payload, " ", 2); + cfl_sds_cat_safe(&payload, "", 13); + cfl_sds_cat_safe(&payload, block_id, strlen(block_id)); + cfl_sds_cat_safe(&payload, "", 14); + cfl_sds_cat_safe(&payload, "\n", 1); + + flb_free(block_id); + } + + cfl_sds_cat_safe(&payload, "", 12); + flb_utils_split_free(list); + + uri = azb_block_blob_blocklist_uri(ctx, path); + if (!uri) { + flb_sds_destroy(payload); + return -1; + } + + ret = azb_block_blob_put_block_list(ctx, uri, payload); + flb_sds_destroy(uri); + flb_sds_destroy(payload); + + return ret; +} diff --git a/plugins/out_azure_blob/azure_blob_blockblob.h b/plugins/out_azure_blob/azure_blob_blockblob.h index 741265b59d5..42d6a970428 100644 --- a/plugins/out_azure_blob/azure_blob_blockblob.h +++ b/plugins/out_azure_blob/azure_blob_blockblob.h @@ -23,10 +23,14 @@ #include #include "azure_blob.h" +flb_sds_t azb_block_blob_blocklist_uri(struct flb_azure_blob *ctx, char *name); flb_sds_t azb_block_blob_uri(struct flb_azure_blob *ctx, char *tag, char *blockid, uint64_t ms); -char *azb_block_blob_id(uint64_t *ms); -int azb_block_blob_commit(struct flb_azure_blob *ctx, char *blockid, char *tag, - uint64_t ms); +char *azb_block_blob_id_logs(uint64_t *ms); +char *azb_block_blob_id_blob(struct flb_azure_blob *ctx, char *path, uint64_t part_id); + +int azb_block_blob_commit_block(struct flb_azure_blob *ctx, char *blockid, char *tag, uint64_t ms); +int azb_block_blob_commit_file_parts(struct flb_azure_blob *ctx, uint64_t file_id, + cfl_sds_t path, cfl_sds_t part_ids); #endif diff --git a/plugins/out_azure_blob/azure_blob_conf.c b/plugins/out_azure_blob/azure_blob_conf.c index f0f7d420714..c376def322d 100644 --- a/plugins/out_azure_blob/azure_blob_conf.c +++ b/plugins/out_azure_blob/azure_blob_conf.c @@ -22,6 +22,7 @@ #include "azure_blob.h" #include "azure_blob_conf.h" +#include "azure_blob_db.h" #include #include @@ -70,6 +71,7 @@ struct flb_azure_blob *flb_azure_blob_conf_create(struct flb_output_instance *in return NULL; } ctx->ins = ins; + ctx->config = config; /* Set context */ flb_output_set_context(ins, ctx); @@ -243,6 +245,16 @@ struct flb_azure_blob *flb_azure_blob_conf_create(struct flb_output_instance *in } } + /* database file for blob signal handling */ + if (ctx->database_file) { + ctx->db = azb_db_open(ctx, ctx->database_file); + if (!ctx->db) { + return NULL; + } + } + + pthread_mutex_init(&ctx->file_upload_commit_file_parts, NULL); + flb_plg_info(ctx->ins, "account_name=%s, container_name=%s, blob_type=%s, emulator_mode=%s, endpoint=%s, auth_type=%s", ctx->account_name, ctx->container_name, @@ -275,5 +287,7 @@ void flb_azure_blob_conf_destroy(struct flb_azure_blob *ctx) flb_upstream_destroy(ctx->u); } + + azb_db_close(ctx); flb_free(ctx); } diff --git a/plugins/out_azure_blob/azure_blob_db.c b/plugins/out_azure_blob/azure_blob_db.c new file mode 100644 index 00000000000..f6239f1660a --- /dev/null +++ b/plugins/out_azure_blob/azure_blob_db.c @@ -0,0 +1,499 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* Fluent Bit + * ========== + * Copyright (C) 2015-2024 The Fluent Bit Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifdef FLB_HAVE_SQLDB + +#include + +#include "azure_blob_db.h" + +static int prepare_stmts(struct flb_sqldb *db, struct flb_azure_blob *ctx) +{ + int ret; + + /* insert */ + ret = sqlite3_prepare_v2(db->handler, SQL_INSERT_FILE, -1, + &ctx->stmt_insert_file, NULL); + if (ret != SQLITE_OK) { + flb_plg_error(ctx->ins, "cannot prepare SQL statement: %s", + SQL_INSERT_FILE); + return -1; + } + + /* delete */ + ret = sqlite3_prepare_v2(db->handler, SQL_DELETE_FILE, -1, + &ctx->stmt_delete_file, NULL); + if (ret != SQLITE_OK) { + flb_plg_error(ctx->ins, "cannot prepare SQL statement: %s", + SQL_DELETE_FILE); + return -1; + } + + /* get */ + ret = sqlite3_prepare_v2(db->handler, SQL_GET_FILE, -1, + &ctx->stmt_get_file, NULL); + if (ret != SQLITE_OK) { + flb_plg_error(ctx->ins, "cannot prepare SQL statement: %s", + SQL_GET_FILE); + return -1; + } + + /* insert blob file part */ + ret = sqlite3_prepare_v2(db->handler, SQL_INSERT_FILE_PART, -1, + &ctx->stmt_insert_file_part, NULL); + if (ret != SQLITE_OK) { + flb_plg_error(ctx->ins, "cannot prepare SQL statement: %s", + SQL_INSERT_FILE_PART); + return -1; + } + + /* update blob part uploaded */ + ret = sqlite3_prepare_v2(db->handler, SQL_UPDATE_FILE_PART_UPLOADED, -1, + &ctx->stmt_update_file_part_uploaded, NULL); + if (ret != SQLITE_OK) { + flb_plg_error(ctx->ins, "cannot prepare SQL statement: %s", + SQL_UPDATE_FILE_PART_UPLOADED); + return -1; + } + + ret = sqlite3_prepare_v2(db->handler, SQL_GET_NEXT_FILE_PART, -1, + &ctx->stmt_get_next_file_part, NULL); + if (ret != SQLITE_OK) { + flb_plg_error(ctx->ins, "cannot prepare SQL statement: %s", + SQL_GET_NEXT_FILE_PART); + return -1; + } + + ret = sqlite3_prepare_v2(db->handler, SQL_UPDATE_FILE_PART_IN_PROGRESS, -1, + &ctx->stmt_update_file_part_in_progress, NULL); + if (ret != SQLITE_OK) { + flb_plg_error(ctx->ins, "cannot prepare SQL statement: %s", + SQL_UPDATE_FILE_PART_IN_PROGRESS); + return -1; + } + + + ret = sqlite3_prepare_v2(db->handler, SQL_GET_OLDEST_FILE_WITH_PARTS_CONCAT, -1, + &ctx->stmt_get_oldest_file_with_parts, NULL); + if (ret != SQLITE_OK) { + flb_plg_error(ctx->ins, "cannot prepare SQL statement: %s", + SQL_GET_OLDEST_FILE_WITH_PARTS_CONCAT); + return -1; + } + + return 0; +} + +static int azb_db_lock(struct flb_azure_blob *ctx) +{ + int ret; + + ret = pthread_mutex_lock(&ctx->db_lock); + if (ret != 0) { + flb_plg_error(ctx->ins, "cannot lock database mutex"); + return -1; + } + + return 0; +} + +static int azb_db_unlock(struct flb_azure_blob *ctx) +{ + int ret; + + ret = pthread_mutex_unlock(&ctx->db_lock); + if (ret != 0) { + flb_plg_error(ctx->ins, "cannot unlock database mutex"); + return -1; + } + + return 0; +} + +struct flb_sqldb *azb_db_open(struct flb_azure_blob *ctx, char *db_path) +{ + int ret; + struct flb_sqldb *db; + struct flb_output_instance *ins; + + ins = ctx->ins; + + db = flb_sqldb_open(db_path, ins->name, ctx->config); + if (!db) { + flb_plg_error(ctx->ins, "cannot open database %s", db_path); + return NULL; + } + + ret = flb_sqldb_query(db, SQL_CREATE_AZURE_BLOB_FILES, NULL, NULL); + if (ret != FLB_OK) { + flb_plg_error(ctx->ins, "cannot create database tables"); + flb_sqldb_close(db); + return NULL; + } + + ret = flb_sqldb_query(db, SQL_CREATE_AZURE_BLOB_PARTS, NULL, NULL); + if (ret != FLB_OK) { + flb_plg_error(ctx->ins, "cannot create database table for parts"); + flb_sqldb_close(db); + return NULL; + } + + ret = flb_sqldb_query(db, SQL_PRAGMA_FOREIGN_KEYS, NULL, NULL); + if (ret != FLB_OK) { + flb_plg_error(ctx->ins, "cannot enable foreign keys"); + flb_sqldb_close(db); + return NULL; + } + + ret = prepare_stmts(db, ctx); + if (ret == -1) { + flb_sqldb_close(db); + return NULL; + } + + pthread_mutex_init(&ctx->db_lock, NULL); + return db; +} + +int azb_db_close(struct flb_azure_blob *ctx) +{ + /* finalize prepared statements */ + sqlite3_finalize(ctx->stmt_insert_file); + sqlite3_finalize(ctx->stmt_delete_file); + sqlite3_finalize(ctx->stmt_get_file); + + sqlite3_finalize(ctx->stmt_insert_file_part); + sqlite3_finalize(ctx->stmt_update_file_part_uploaded); + sqlite3_finalize(ctx->stmt_update_file_part_in_progress); + + sqlite3_finalize(ctx->stmt_get_next_file_part); + sqlite3_finalize(ctx->stmt_get_oldest_file_with_parts); + + pthread_mutex_destroy(&ctx->db_lock); + return flb_sqldb_close(ctx->db); +} + +int azb_db_file_exists(struct flb_azure_blob *ctx, char *path, uint64_t *id) +{ + int ret; + int exists = FLB_FALSE; + + azb_db_lock(ctx); + + /* Bind parameters */ + sqlite3_bind_text(ctx->stmt_get_file, 1, path, -1, 0); + ret = sqlite3_step(ctx->stmt_get_file); + if (ret == SQLITE_ROW) { + exists = FLB_TRUE; + + /* id: column 0 */ + *id = sqlite3_column_int64(ctx->stmt_get_file, 0); + } + else if (ret == SQLITE_DONE) { + /* all good */ + } + else { + exists = -1; + } + + sqlite3_clear_bindings(ctx->stmt_get_file); + sqlite3_reset(ctx->stmt_get_file); + + azb_db_unlock(ctx); + + return exists; +} + +int64_t azb_db_file_insert(struct flb_azure_blob *ctx, char *path, size_t size) +{ + int ret; + int64_t id; + time_t created; + + /* Register the file */ + created = time(NULL); + + azb_db_lock(ctx); + + /* Bind parameters */ + sqlite3_bind_text(ctx->stmt_insert_file, 1, path, -1, 0); + sqlite3_bind_int64(ctx->stmt_insert_file, 2, size); + sqlite3_bind_int64(ctx->stmt_insert_file, 3, created); + + /* Run the insert */ + ret = sqlite3_step(ctx->stmt_insert_file); + if (ret != SQLITE_DONE) { + sqlite3_clear_bindings(ctx->stmt_insert_file); + sqlite3_reset(ctx->stmt_insert_file); + flb_plg_error(ctx->ins, "cannot execute insert file '%s'", path); + + azb_db_unlock(ctx); + return -1; + } + + sqlite3_clear_bindings(ctx->stmt_insert_file); + sqlite3_reset(ctx->stmt_insert_file); + + /* Get the database ID for this file */ + id = flb_sqldb_last_id(ctx->db); + flb_plg_trace(ctx->ins, "db: file '%s' inserted with id=%ld", path, id); + + azb_db_unlock(ctx); + + return id; +} + +int azb_db_file_delete(struct flb_azure_blob *ctx, uint64_t id, char *path) +{ + int ret; + + azb_db_lock(ctx); + + /* Bind parameters */ + sqlite3_bind_int64(ctx->stmt_delete_file, 1, id); + ret = sqlite3_step(ctx->stmt_delete_file); + if (ret != SQLITE_DONE) { + sqlite3_clear_bindings(ctx->stmt_delete_file); + sqlite3_reset(ctx->stmt_delete_file); + azb_db_unlock(ctx); + return -1; + } + + sqlite3_clear_bindings(ctx->stmt_delete_file); + sqlite3_reset(ctx->stmt_delete_file); + + if (ret != SQLITE_DONE) { + flb_plg_error(ctx->ins, "db: error deleting entry id=%" PRIu64 + ", path='%s' from database", id, path); + azb_db_unlock(ctx); + return -1; + } + + flb_plg_debug(ctx->ins, "db: file id=%" PRIu64 + ", path='%s' deleted from database", id, path); + + azb_db_unlock(ctx); + return 0; +} + +int azb_db_file_part_insert(struct flb_azure_blob *ctx, uint64_t file_id, + uint64_t part_id, + size_t offset_start, size_t offset_end, + int64_t *out_id) +{ + int ret; + + azb_db_lock(ctx); + + /* Bind parameters */ + sqlite3_bind_int64(ctx->stmt_insert_file_part, 1, file_id); + sqlite3_bind_int64(ctx->stmt_insert_file_part, 2, part_id); + sqlite3_bind_int64(ctx->stmt_insert_file_part, 3, offset_start); + sqlite3_bind_int64(ctx->stmt_insert_file_part, 4, offset_end); + + /* Run the insert */ + ret = sqlite3_step(ctx->stmt_insert_file_part); + if (ret != SQLITE_DONE) { + sqlite3_clear_bindings(ctx->stmt_insert_file_part); + sqlite3_reset(ctx->stmt_insert_file_part); + flb_plg_error(ctx->ins, "cannot execute insert part for file_id=%" PRIu64, + file_id); + + azb_db_unlock(ctx); + return -1; + } + + sqlite3_clear_bindings(ctx->stmt_insert_file_part); + sqlite3_reset(ctx->stmt_insert_file_part); + + azb_db_unlock(ctx); + return 0; +} + +int azb_db_file_part_in_progress(struct flb_azure_blob *ctx, int in_progress, uint64_t id) +{ + int ret; + + /* Bind parameters */ + sqlite3_bind_int(ctx->stmt_update_file_part_in_progress, 1, in_progress); + sqlite3_bind_int64(ctx->stmt_update_file_part_in_progress, 2, id); + + /* Run the update */ + ret = sqlite3_step(ctx->stmt_update_file_part_in_progress); + if (ret != SQLITE_DONE) { + sqlite3_clear_bindings(ctx->stmt_update_file_part_in_progress); + sqlite3_reset(ctx->stmt_update_file_part_in_progress); + flb_plg_error(ctx->ins, "cannot update part with id=%" PRIu64, id); + return -1; + } + + sqlite3_clear_bindings(ctx->stmt_update_file_part_in_progress); + sqlite3_reset(ctx->stmt_update_file_part_in_progress); + + return 0; +} + +/* + * Retrieve the next part file that must be processed. Note tha this function will also lock + * the file into the database to avoid any concurrency issue if multi workers are in use + */ +int azb_db_file_part_get_next(struct flb_azure_blob *ctx, + uint64_t *id, uint64_t *file_id, uint64_t *part_id, + off_t *offset_start, off_t *offset_end, + cfl_sds_t *file_path) +{ + int ret; + char *tmp = NULL; + cfl_sds_t path; + + if (azb_db_lock(ctx) != 0) { + return -1; + } + + *file_path = NULL; + + /* Run the query */ + ret = sqlite3_step(ctx->stmt_get_next_file_part); + if (ret == SQLITE_ROW) { + *id = sqlite3_column_int64(ctx->stmt_get_next_file_part, 0); + *file_id = sqlite3_column_int64(ctx->stmt_get_next_file_part, 1); + *part_id = sqlite3_column_int64(ctx->stmt_get_next_file_part, 2); + *offset_start = sqlite3_column_int64(ctx->stmt_get_next_file_part, 3); + *offset_end = sqlite3_column_int64(ctx->stmt_get_next_file_part, 4); + tmp = (char *) sqlite3_column_text(ctx->stmt_get_next_file_part, 5); + } + else if (ret == SQLITE_DONE) { + /* no records */ + sqlite3_clear_bindings(ctx->stmt_get_next_file_part); + sqlite3_reset(ctx->stmt_get_next_file_part); + azb_db_unlock(ctx); + return 0; + } + else { + sqlite3_clear_bindings(ctx->stmt_get_next_file_part); + sqlite3_reset(ctx->stmt_get_next_file_part); + azb_db_unlock(ctx); + return -1; + } + + path = cfl_sds_create(tmp); + + sqlite3_clear_bindings(ctx->stmt_get_next_file_part); + sqlite3_reset(ctx->stmt_get_next_file_part); + + if (!path) { + azb_db_unlock(ctx); + return -1; + } + + /* set the part flag 'in_progress' to '1' */ + ret = azb_db_file_part_in_progress(ctx, 1, *id); + if (ret == -1) { + cfl_sds_destroy(path); + azb_db_unlock(ctx); + return -1; + } + + *file_path = path; + azb_db_unlock(ctx); + + return 1; +} + +int azb_db_file_part_uploaded(struct flb_azure_blob *ctx, uint64_t id) +{ + int ret; + + azb_db_lock(ctx); + + /* Bind parameters */ + sqlite3_bind_int64(ctx->stmt_update_file_part_uploaded, 1, id); + + /* Run the update */ + ret = sqlite3_step(ctx->stmt_update_file_part_uploaded); + if (ret != SQLITE_DONE) { + sqlite3_clear_bindings(ctx->stmt_update_file_part_uploaded); + sqlite3_reset(ctx->stmt_update_file_part_uploaded); + flb_plg_error(ctx->ins, "cannot update part id=%" PRIu64, id); + azb_db_unlock(ctx); + return -1; + } + + sqlite3_clear_bindings(ctx->stmt_update_file_part_uploaded); + sqlite3_reset(ctx->stmt_update_file_part_uploaded); + + azb_db_unlock(ctx); + + return 0; +} + +int azb_db_file_oldest_ready(struct flb_azure_blob *ctx, + uint64_t *file_id, cfl_sds_t *path, cfl_sds_t *part_ids) +{ + int ret; + char *tmp = NULL; + + azb_db_lock(ctx); + + /* Run the query */ + ret = sqlite3_step(ctx->stmt_get_oldest_file_with_parts); + if (ret == SQLITE_ROW) { + /* file_id */ + *file_id = sqlite3_column_int64(ctx->stmt_get_oldest_file_with_parts, 0); + tmp = (char *) sqlite3_column_text(ctx->stmt_get_oldest_file_with_parts, 1); + + /* path */ + *path = cfl_sds_create(tmp); + if (!*path) { + sqlite3_clear_bindings(ctx->stmt_get_oldest_file_with_parts); + sqlite3_reset(ctx->stmt_get_oldest_file_with_parts); + azb_db_unlock(ctx); + return -1; + } + + /* part_ids */ + tmp = (char *) sqlite3_column_text(ctx->stmt_get_oldest_file_with_parts, 2); + *part_ids = cfl_sds_create(tmp); + if (!*part_ids) { + cfl_sds_destroy(*path); + sqlite3_clear_bindings(ctx->stmt_get_oldest_file_with_parts); + sqlite3_reset(ctx->stmt_get_oldest_file_with_parts); + azb_db_unlock(ctx); + return -1; + } + } + else if (ret == SQLITE_DONE) { + /* no records */ + sqlite3_clear_bindings(ctx->stmt_get_oldest_file_with_parts); + sqlite3_reset(ctx->stmt_get_oldest_file_with_parts); + azb_db_unlock(ctx); + return 0; + } + else { + azb_db_unlock(ctx); + return -1; + } + + azb_db_unlock(ctx); + return 1; +} + +#endif \ No newline at end of file diff --git a/plugins/out_azure_blob/azure_blob_db.h b/plugins/out_azure_blob/azure_blob_db.h new file mode 100644 index 00000000000..d238349bae2 --- /dev/null +++ b/plugins/out_azure_blob/azure_blob_db.h @@ -0,0 +1,128 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* Fluent Bit + * ========== + * Copyright (C) 2015-2024 The Fluent Bit Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OUT_AZURE_BLOB_DB_H +#define OUT_AZURE_BLOB_DB_H + +#include +#include "azure_blob.h" + +#define SQL_PRAGMA_FOREIGN_KEYS "PRAGMA foreign_keys = ON;" + +#define SQL_CREATE_AZURE_BLOB_FILES \ + "CREATE TABLE IF NOT EXISTS out_azure_blob_files (" \ + " id INTEGER PRIMARY KEY," \ + " path TEXT NOT NULL," \ + " size INTEGER," \ + " created INTEGER" \ + ");" + +#define SQL_CREATE_AZURE_BLOB_PARTS \ + "CREATE TABLE IF NOT EXISTS out_azure_blob_parts (" \ + " id INTEGER PRIMARY KEY," \ + " file_id INTEGER NOT NULL," \ + " part_id INTEGER NOT NULL," \ + " uploaded INTEGER DEFAULT 0," \ + " in_progress INTEGER DEFAULT 0," \ + " offset_start INTEGER," \ + " offset_end INTEGER," \ + " FOREIGN KEY (file_id) REFERENCES out_azure_blob_files(id) " \ + " ON DELETE CASCADE" \ + ");" + +#define SQL_INSERT_FILE \ + "INSERT INTO out_azure_blob_files (path, size, created)" \ + " VALUES (@path, @size, @created);" + +/* DELETE a registered file and all it parts */ +#define SQL_DELETE_FILE \ + "DELETE FROM out_azure_blob_files WHERE id=@id;" + +#define SQL_GET_FILE \ + "SELECT * from out_azure_blob_files WHERE path=@path order by id desc;" + +#define SQL_INSERT_FILE_PART \ + "INSERT INTO out_azure_blob_parts (file_id, part_id, offset_start, offset_end)" \ + " VALUES (@file_id, @part_id, @offset_start, @offset_end);" + +#define SQL_UPDATE_FILE_PART_UPLOADED \ + "UPDATE out_azure_blob_parts SET uploaded=1, in_progress=0 WHERE id=@id;" + +#define SQL_UPDATE_FILE_PART_IN_PROGRESS \ + "UPDATE out_azure_blob_parts SET in_progress=@status WHERE id=@id;" + +/* Find the oldest files and retrieve the oldest part ready to be uploaded */ +#define SQL_GET_NEXT_FILE_PART \ + "SELECT p.id, " \ + " p.file_id, " \ + " p.part_id, " \ + " p.offset_start, " \ + " p.offset_end, " \ + " f.path " \ + "FROM out_azure_blob_parts p " \ + " JOIN out_azure_blob_files f " \ + " ON p.file_id = f.id " \ + "WHERE p.uploaded = 0 " \ + " AND p.in_progress = 0 " \ + "ORDER BY f.created ASC, " \ + " p.part_id ASC " \ + "LIMIT 1;" + + +/* + * Query to retrieve the oldest file which all it parts are mark as uploaded, this + * query will group the results in a single record, e.g: + * +* path part_ids + * ---------------- ---------- ------------------------------------------------------------ + * /.../alice29.txt 1726423769 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18, + * 19,20,21,22,23,24,25,26,27,28,29,30 + * + * this query is used to compose + */ +#define SQL_GET_OLDEST_FILE_WITH_PARTS_CONCAT \ + "SELECT f.id, f.path, GROUP_CONCAT(p.part_id ORDER BY p.part_id ASC) AS part_ids " \ + "FROM out_azure_blob_files f " \ + "JOIN out_azure_blob_parts p ON f.id = p.file_id " \ + "WHERE p.uploaded = 1 " \ + "GROUP BY f.id " \ + "HAVING COUNT(p.id) = (SELECT COUNT(p2.id) FROM out_azure_blob_parts p2 WHERE p2.file_id = f.id) " \ + "ORDER BY f.created ASC " \ + "LIMIT 1;" + +struct flb_sqldb *azb_db_open(struct flb_azure_blob *ctx, char *db_path); +int azb_db_close(struct flb_azure_blob *ctx); +int azb_db_file_exists(struct flb_azure_blob *ctx, char *path, uint64_t *id); +int64_t azb_db_file_insert(struct flb_azure_blob *ctx, char *path, size_t size); +int azb_db_file_delete(struct flb_azure_blob *ctx, uint64_t id, char *path); + +int azb_db_file_part_insert(struct flb_azure_blob *ctx, uint64_t file_id, + uint64_t part_id, + size_t offset_start, size_t offset_end, + int64_t *out_id); +int azb_db_file_part_in_progress(struct flb_azure_blob *ctx, int in_progress, uint64_t id); +int azb_db_file_part_get_next(struct flb_azure_blob *ctx, + uint64_t *id, uint64_t *file_id, uint64_t *part_id, + off_t *offset_start, off_t *offset_end, + cfl_sds_t *file_path); +int azb_db_file_part_uploaded(struct flb_azure_blob *ctx, uint64_t id); + +int azb_db_file_oldest_ready(struct flb_azure_blob *ctx, + uint64_t *file_id, cfl_sds_t *path, cfl_sds_t *part_ids); +#endif \ No newline at end of file From c50178badd26683fe7cff349c013395d0096443f Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 16 Sep 2024 13:29:00 -0600 Subject: [PATCH 210/295] build: register in_blob Signed-off-by: Eduardo Silva --- cmake/plugins_options.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/plugins_options.cmake b/cmake/plugins_options.cmake index 5a63bbc7d68..4292ef204b5 100644 --- a/cmake/plugins_options.cmake +++ b/cmake/plugins_options.cmake @@ -11,6 +11,7 @@ option(FLB_MINIMAL "Enable minimal build configuration" No) # Inputs (sources, data collectors) # ================================= +DEFINE_OPTION(FLB_IN_BLOB "Enable Blob input plugin" ON) DEFINE_OPTION(FLB_IN_CALYPTIA_FLEET "Enable Calyptia Fleet input plugin" ON) DEFINE_OPTION(FLB_IN_COLLECTD "Enable Collectd input plugin" ON) DEFINE_OPTION(FLB_IN_CPU "Enable CPU input plugin" ON) From 489e6dfb84e7c6c100aa6ff071d94ab00d6e6969 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 16 Sep 2024 13:29:21 -0600 Subject: [PATCH 211/295] out_stdout: support blob type (print targe file name) Signed-off-by: Eduardo Silva --- plugins/out_stdout/stdout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/out_stdout/stdout.c b/plugins/out_stdout/stdout.c index 5c126fa075b..625d3d3ec89 100644 --- a/plugins/out_stdout/stdout.c +++ b/plugins/out_stdout/stdout.c @@ -305,6 +305,6 @@ struct flb_output_plugin out_stdout_plugin = { .cb_exit = cb_stdout_exit, .flags = 0, .workers = 1, - .event_type = FLB_OUTPUT_LOGS | FLB_OUTPUT_METRICS | FLB_OUTPUT_TRACES, + .event_type = FLB_OUTPUT_LOGS | FLB_OUTPUT_METRICS | FLB_OUTPUT_TRACES | FLB_OUTPUT_BLOBS, .config_map = config_map }; From 72fceee43133d51f2d06fc1716f2bb0593469359 Mon Sep 17 00:00:00 2001 From: leonardo-albertovich Date: Tue, 17 Sep 2024 14:32:23 +0200 Subject: [PATCH 212/295] scheduler: fixed typo Signed-off-by: leonardo-albertovich --- src/flb_scheduler.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/flb_scheduler.c b/src/flb_scheduler.c index 8dab1fe3222..bacc5083e01 100644 --- a/src/flb_scheduler.c +++ b/src/flb_scheduler.c @@ -31,7 +31,7 @@ #include FLB_TLS_DEFINE(struct flb_sched, flb_sched_ctx); -FLB_TLS_DEFINE(struct flb_sched_timer_cb_params, sched_timer_coro_cb_params); +FLB_TLS_DEFINE(struct flb_sched_timer_coro_cb_params, sched_timer_coro_cb_params); void flb_sched_ctx_init() { @@ -962,4 +962,4 @@ struct flb_sched_timer_coro *flb_sched_timer_coro_get(struct flb_sched *sched, u } return NULL; -} \ No newline at end of file +} From 1df51611f96303015bc080ffd168692f615fb26d Mon Sep 17 00:00:00 2001 From: leonardo-albertovich Date: Tue, 17 Sep 2024 14:33:04 +0200 Subject: [PATCH 213/295] scheduler: fixed typo Signed-off-by: leonardo-albertovich --- include/fluent-bit/flb_scheduler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fluent-bit/flb_scheduler.h b/include/fluent-bit/flb_scheduler.h index 71213b100de..c76cda60290 100644 --- a/include/fluent-bit/flb_scheduler.h +++ b/include/fluent-bit/flb_scheduler.h @@ -199,7 +199,7 @@ struct flb_sched_timer_coro_cb_params { struct flb_coro *coro; }; -extern FLB_TLS_DEFINE(struct flb_sched_timer_cb_coro_params, sched_timer_coro_cb_params); +extern FLB_TLS_DEFINE(struct flb_sched_timer_coro_cb_params, sched_timer_coro_cb_params); struct flb_timer_cb_coro_params { From 3eb6846bba4427ceea4939d17021a99e2d3f1b71 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Fri, 20 Sep 2024 13:07:30 +0200 Subject: [PATCH 214/295] http_client: added DELETE support --- include/fluent-bit/flb_http_client.h | 1 + src/flb_http_client.c | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/include/fluent-bit/flb_http_client.h b/include/fluent-bit/flb_http_client.h index 5be84039b07..8d7058622e0 100644 --- a/include/fluent-bit/flb_http_client.h +++ b/include/fluent-bit/flb_http_client.h @@ -36,6 +36,7 @@ #define FLB_HTTP_HEAD 3 #define FLB_HTTP_CONNECT 4 #define FLB_HTTP_PATCH 5 +#define FLB_HTTP_DELETE 6 /* HTTP Flags */ #define FLB_HTTP_10 1 diff --git a/src/flb_http_client.c b/src/flb_http_client.c index cf9bce55064..72a1fadbbd1 100644 --- a/src/flb_http_client.c +++ b/src/flb_http_client.c @@ -385,7 +385,7 @@ static int process_chunked_data(struct flb_http_client *c) if (found_full_chunk == FLB_TRUE) { return FLB_HTTP_CHUNK_AVAILABLE; } - return FLB_HTTP_MORE; + return FLB_HTTP_MORE; } static int process_data(struct flb_http_client *c) @@ -665,6 +665,9 @@ struct flb_http_client *flb_http_client(struct flb_connection *u_conn, case FLB_HTTP_PUT: str_method = "PUT"; break; + case FLB_HTTP_DELETE: + str_method = "DELETE"; + break; case FLB_HTTP_HEAD: str_method = "HEAD"; break; @@ -1182,10 +1185,10 @@ int flb_http_bearer_auth(struct flb_http_client *c, const char *token) /* flb_http_do_request only sends the http request the data. * This is useful for processing the chunked responses on your own. -* If you do not want to process the response on your own or expect +* If you do not want to process the response on your own or expect * all response data before you process data, use flb_http_do instead. */ -int flb_http_do_request(struct flb_http_client *c, size_t *bytes) +int flb_http_do_request(struct flb_http_client *c, size_t *bytes) { int ret; int crlf = 2; @@ -1261,24 +1264,24 @@ int flb_http_do_request(struct flb_http_client *c, size_t *bytes) return FLB_HTTP_MORE; } -int flb_http_get_response_data(struct flb_http_client *c, size_t bytes_consumed) +int flb_http_get_response_data(struct flb_http_client *c, size_t bytes_consumed) { - /* returns + /* returns * FLB_HTTP_MORE - if we are waiting for more data to be received * FLB_HTTP_CHUNK_AVAILABLE - if this is a chunked transfer and one or more chunks * have been received and it is not the end of the stream - * FLB_HTTP_OK - if we have collected all response data and no errors were thrown - * (in chunked transfers this means we've received the end chunk + * FLB_HTTP_OK - if we have collected all response data and no errors were thrown + * (in chunked transfers this means we've received the end chunk * and any remaining data to process from the end of stream, will be * contained in the response payload) * FLB_HTTP_ERROR - for any error */ int ret = FLB_HTTP_MORE; - int r_bytes; + int r_bytes; ssize_t available; size_t out_size; - // if the caller has consumed some of the payload (via bytes_consumed) + // if the caller has consumed some of the payload (via bytes_consumed) // we consume those bytes off the payload if( bytes_consumed > 0 ) { if(bytes_consumed > c->resp.payload_size) { From 87fdc7f245b335449ea198a90895e361efa053ca Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Fri, 20 Sep 2024 13:07:59 +0200 Subject: [PATCH 215/295] input_blob: added source tracking field --- include/fluent-bit/flb_input_blob.h | 3 +- src/flb_input_blob.c | 44 +++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/include/fluent-bit/flb_input_blob.h b/include/fluent-bit/flb_input_blob.h index 859468230cc..0691b8f29aa 100644 --- a/include/fluent-bit/flb_input_blob.h +++ b/include/fluent-bit/flb_input_blob.h @@ -28,7 +28,8 @@ struct flb_blob_file { cfl_sds_t path; }; -int flb_input_blob_file_get_info(msgpack_object map, cfl_sds_t *file_path, size_t *size); +int flb_input_blob_file_get_info(msgpack_object map, cfl_sds_t *source, + cfl_sds_t *file_path, size_t *size); int flb_input_blob_file_register(struct flb_input_instance *ins, struct flb_log_event_encoder *encoder, const char *tag, size_t tag_len, diff --git a/src/flb_input_blob.c b/src/flb_input_blob.c index 06d97e8f566..f0958c215d0 100644 --- a/src/flb_input_blob.c +++ b/src/flb_input_blob.c @@ -28,8 +28,9 @@ #include -int flb_input_blob_file_get_info(msgpack_object map, cfl_sds_t *file_path, size_t *size) +int flb_input_blob_file_get_info(msgpack_object map, cfl_sds_t *source, cfl_sds_t *file_path, size_t *size) { + cfl_sds_t tmp_source; cfl_sds_t tmp_file_path; msgpack_object o; @@ -37,7 +38,7 @@ int flb_input_blob_file_get_info(msgpack_object map, cfl_sds_t *file_path, size_ return -1; } - if (map.via.map.size < 2) { + if (map.via.map.size < 3) { return -1; } @@ -77,8 +78,32 @@ int flb_input_blob_file_get_info(msgpack_object map, cfl_sds_t *file_path, size_ return -1; } + /* get source plugin */ + o = map.via.map.ptr[2].key; + if (o.type != MSGPACK_OBJECT_STR) { + cfl_sds_destroy(tmp_file_path); + return -1; + } + if (o.via.str.size != 6 || strncmp(o.via.str.ptr, "source", 6) != 0) { + cfl_sds_destroy(tmp_file_path); + return -1; + } + + o = map.via.map.ptr[2].val; + if (o.type != MSGPACK_OBJECT_STR) { + cfl_sds_destroy(tmp_file_path); + return -1; + } + + tmp_source = cfl_sds_create_len(o.via.str.ptr, o.via.str.size); + if (tmp_source == NULL) { + cfl_sds_destroy(tmp_file_path); + return -1; + } + *size = o.via.u64; *file_path = tmp_file_path; + *source = tmp_source; return 0; } @@ -133,6 +158,7 @@ int flb_input_blob_file_register(struct flb_input_instance *ins, flb_log_event_encoder_reset(encoder); return -1; } + ret = flb_log_event_encoder_append_body_cstring(encoder, file_path); if (ret != FLB_EVENT_ENCODER_SUCCESS) { flb_error("[blob file registration] could not append path"); @@ -154,6 +180,20 @@ int flb_input_blob_file_register(struct flb_input_instance *ins, return -1; } + ret = flb_log_event_encoder_append_body_cstring(encoder, "source"); + if (ret != FLB_EVENT_ENCODER_SUCCESS) { + flb_error("[blob file registration] could not append path"); + flb_log_event_encoder_reset(encoder); + return -1; + } + + ret = flb_log_event_encoder_append_body_cstring(encoder, flb_input_name(ins)); + if (ret != FLB_EVENT_ENCODER_SUCCESS) { + flb_error("[blob file registration] could not append source plugin name"); + flb_log_event_encoder_reset(encoder); + return -1; + } + ret = flb_log_event_encoder_commit_record(encoder); if (ret != FLB_EVENT_ENCODER_SUCCESS) { flb_error("[blob file registration] could not commit record"); From 54b1cef171c0cec3cd5c6856e9b53c7803775d9a Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Fri, 20 Sep 2024 13:08:58 +0200 Subject: [PATCH 216/295] out_azure_blob: added blob delete function and both file and part retry mechanism --- plugins/out_azure_blob/azure_blob.c | 168 +++++++++++++++++++++++++++- plugins/out_azure_blob/azure_blob.h | 13 +++ 2 files changed, 176 insertions(+), 5 deletions(-) diff --git a/plugins/out_azure_blob/azure_blob.c b/plugins/out_azure_blob/azure_blob.c index b3ecf5dc874..7817b11a3a0 100644 --- a/plugins/out_azure_blob/azure_blob.c +++ b/plugins/out_azure_blob/azure_blob.c @@ -149,6 +149,81 @@ static int create_blob(struct flb_azure_blob *ctx, char *name) return FLB_OK; } +static int delete_blob(struct flb_azure_blob *ctx, char *name) +{ + int ret; + size_t b_sent; + flb_sds_t uri = NULL; + struct flb_http_client *c; + struct flb_connection *u_conn; + + uri = azb_uri_create_blob(ctx, name); + if (!uri) { + return FLB_RETRY; + } + + /* Get upstream connection */ + u_conn = flb_upstream_conn_get(ctx->u); + if (!u_conn) { + flb_plg_error(ctx->ins, + "cannot create upstream connection for create_append_blob"); + flb_sds_destroy(uri); + return FLB_RETRY; + } + + /* Create HTTP client context */ + c = flb_http_client(u_conn, FLB_HTTP_DELETE, + uri, + NULL, 0, NULL, 0, NULL, 0); + if (!c) { + flb_plg_error(ctx->ins, "cannot create HTTP client context"); + flb_upstream_conn_release(u_conn); + flb_sds_destroy(uri); + return FLB_RETRY; + } + + /* Prepare headers and authentication */ + azb_http_client_setup(ctx, c, -1, FLB_TRUE, + AZURE_BLOB_CT_NONE, AZURE_BLOB_CE_NONE); + + /* Send HTTP request */ + ret = flb_http_do(c, &b_sent); + flb_sds_destroy(uri); + + if (ret == -1) { + flb_plg_error(ctx->ins, "error sending append_blob"); + flb_http_client_destroy(c); + flb_upstream_conn_release(u_conn); + return FLB_RETRY; + } + + if (c->resp.status == 201) { + /* delete "&sig=..." in the c->uri for security */ + char *p = strstr(c->uri, "&sig="); + if (p) { + *p = '\0'; + } + flb_plg_info(ctx->ins, "blob deleted successfully: %s", c->uri); + } + else { + if (c->resp.payload_size > 0) { + flb_plg_error(ctx->ins, "http_status=%i cannot delete append blob\n%s", + c->resp.status, c->resp.payload); + } + else { + flb_plg_error(ctx->ins, "http_status=%i cannot delete append blob", + c->resp.status); + } + flb_http_client_destroy(c); + flb_upstream_conn_release(u_conn); + return FLB_RETRY; + } + + flb_http_client_destroy(c); + flb_upstream_conn_release(u_conn); + return FLB_OK; +} + static int http_send_blob(struct flb_config *config, struct flb_azure_blob *ctx, flb_sds_t ref_name, flb_sds_t uri, @@ -563,6 +638,7 @@ static int process_blob_chunk(struct flb_azure_blob *ctx, struct flb_event_chunk int64_t ret; int64_t file_id; cfl_sds_t file_path = NULL; + cfl_sds_t source = NULL; size_t file_size; msgpack_object map; @@ -582,20 +658,22 @@ static int process_blob_chunk(struct flb_azure_blob *ctx, struct flb_event_chunk while (flb_log_event_decoder_next(&log_decoder, &log_event) == FLB_EVENT_DECODER_SUCCESS) { map = *log_event.body; - ret = flb_input_blob_file_get_info(map, &file_path, &file_size); + ret = flb_input_blob_file_get_info(map, &source, &file_path, &file_size); if (ret == -1) { flb_plg_error(ctx->ins, "cannot get file info from blob record, skipping"); continue; } - ret = azb_db_file_insert(ctx, file_path, file_size); + ret = azb_db_file_insert(ctx, source, file_path, file_size); if (ret == -1) { flb_plg_error(ctx->ins, "cannot insert blob file into database: %s (size=%lu)", file_path, file_size); cfl_sds_destroy(file_path); + cfl_sds_destroy(source); continue; } cfl_sds_destroy(file_path); + cfl_sds_destroy(source); /* generate the parts by using the newest id created (ret) */ file_id = ret; @@ -608,8 +686,6 @@ static int process_blob_chunk(struct flb_azure_blob *ctx, struct flb_event_chunk flb_plg_debug(ctx->ins, "blob file '%s' (id=%zu) registered with %zu parts", file_path, file_id, ret); - - } flb_log_event_decoder_destroy(&log_decoder); @@ -624,10 +700,13 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context uint64_t id; uint64_t file_id; uint64_t part_id; + uint64_t part_delivery_attempts; + uint64_t file_delivery_attempts; off_t offset_start; off_t offset_end; cfl_sds_t file_path = NULL; cfl_sds_t part_ids = NULL; + cfl_sds_t source = NULL; struct flb_azure_blob *ctx = out_context; struct worker_info *info; @@ -646,6 +725,30 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context pthread_mutex_lock(&ctx->file_upload_commit_file_parts); + ret = azb_db_file_get_next_aborted(ctx, + &file_id, + &file_delivery_attempts, + &file_path, + &source); + + if (ret == 1) { + ret = delete_blob(ctx, file_path); + + if (ctx->file_delivery_attempt_limit != FLB_OUT_RETRY_UNLIMITED && + file_delivery_attempts < ctx->file_delivery_attempt_limit) { + azb_db_file_reset_upload_states(ctx, file_id, file_path); + azb_db_file_set_aborted_state(ctx, file_id, file_path, 0); + } + else { + /* notify the input plugin + */ + ret = azb_db_file_delete(ctx, file_id, file_path); + } + + cfl_sds_destroy(file_path); + cfl_sds_destroy(source); + } + ret = azb_db_file_oldest_ready(ctx, &file_id, &file_path, &part_ids); if (ret == 0) { flb_plg_trace(ctx->ins, "no blob files ready to commit"); @@ -685,7 +788,11 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context } /* check for a next part file and lock it */ - ret = azb_db_file_part_get_next(ctx, &id, &file_id, &part_id, &offset_start, &offset_end, &file_path); + ret = azb_db_file_part_get_next(ctx, &id, &file_id, &part_id, + &offset_start, &offset_end, + &part_delivery_attempts, + &file_delivery_attempts, + &file_path); if (ret == -1) { flb_plg_error(ctx->ins, "cannot get next blob file part"); info->active_upload = FLB_FALSE; @@ -700,6 +807,13 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context /* just continue, the row info was retrieved */ } + /* since this is the first part we want to increment the files + * delivery attempt counter. + */ + if (part_id == 0) { + ret = azb_db_file_delivery_attempts(ctx, file_id, ++file_delivery_attempts); + } + /* read the file content */ ret = flb_utils_read_file_offset(file_path, offset_start, offset_end, &out_buf, &out_size); if (ret == -1) { @@ -709,6 +823,8 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context flb_sched_timer_cb_coro_return(); } + azb_db_file_part_delivery_attempts(ctx, part_id, ++part_delivery_attempts); + flb_plg_debug(ctx->ins, "sending part file %s (id=%" PRIu64 " part_id=%" PRIu64 ")", file_path, id, part_id); ret = send_blob(config, NULL, ctx, FLB_EVENT_TYPE_BLOBS, AZURE_BLOB_BLOCKBLOB, file_path, part_id, NULL, 0, out_buf, out_size); @@ -720,6 +836,12 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context } } else if (ret == FLB_RETRY) { + azb_db_file_part_in_progress(ctx, 0, id); + + if (ctx->part_delivery_attempt_limit != FLB_OUT_RETRY_UNLIMITED && + part_delivery_attempts >= ctx->part_delivery_attempt_limit) { + azb_db_file_set_aborted_state(ctx, file_id, file_path, 1); + } /* FIXME */ } info->active_upload = FLB_FALSE; @@ -948,12 +1070,48 @@ static struct flb_config_map config_map[] = { "Size of each part when uploading blob files" }, + { + FLB_CONFIG_MAP_INT, "file_delivery_attempt_limit", "1", + 0, FLB_TRUE, offsetof(struct flb_azure_blob, file_delivery_attempt_limit), + "File delivery attempt limit" + }, + + { + FLB_CONFIG_MAP_INT, "part_delivery_attempt_limit", "1", + 0, FLB_TRUE, offsetof(struct flb_azure_blob, part_delivery_attempt_limit), + "File part delivery attempt limit" + }, + { FLB_CONFIG_MAP_TIME, "upload_parts_timeout", "10M", 0, FLB_TRUE, offsetof(struct flb_azure_blob, upload_parts_timeout), "Timeout to upload parts of a blob file" }, + { + FLB_CONFIG_MAP_STR, "configuration_endpoint_url", NULL, + 0, FLB_TRUE, offsetof(struct flb_azure_blob, configuration_endpoint_url), + "Configuration endpoint URL" + }, + + { + FLB_CONFIG_MAP_STR, "configuration_endpoint_username", NULL, + 0, FLB_TRUE, offsetof(struct flb_azure_blob, configuration_endpoint_username), + "Configuration endpoint basic authentication username" + }, + + { + FLB_CONFIG_MAP_STR, "configuration_endpoint_password", NULL, + 0, FLB_TRUE, offsetof(struct flb_azure_blob, configuration_endpoint_password), + "Configuration endpoint basic authentication password" + }, + + { + FLB_CONFIG_MAP_STR, "configuration_endpoint_bearer_token", NULL, + 0, FLB_TRUE, offsetof(struct flb_azure_blob, configuration_endpoint_bearer_token), + "Configuration endpoint bearer token" + }, + /* EOF */ {0} }; diff --git a/plugins/out_azure_blob/azure_blob.h b/plugins/out_azure_blob/azure_blob.h index 68784f0f9fc..8b3009e978d 100644 --- a/plugins/out_azure_blob/azure_blob.h +++ b/plugins/out_azure_blob/azure_blob.h @@ -62,6 +62,12 @@ struct flb_azure_blob { flb_sds_t database_file; size_t part_size; time_t upload_parts_timeout; + int file_delivery_attempt_limit; + int part_delivery_attempt_limit; + flb_sds_t configuration_endpoint_url; + flb_sds_t configuration_endpoint_username; + flb_sds_t configuration_endpoint_password; + flb_sds_t configuration_endpoint_bearer_token; /* * Internal use @@ -93,11 +99,18 @@ struct flb_azure_blob { /* prepared statements: files */ sqlite3_stmt *stmt_insert_file; sqlite3_stmt *stmt_delete_file; + sqlite3_stmt *stmt_abort_file; sqlite3_stmt *stmt_get_file; + sqlite3_stmt *stmt_update_file_delivery_attempt_count; + sqlite3_stmt *stmt_set_file_aborted_state; + sqlite3_stmt *stmt_get_next_aborted_file; + sqlite3_stmt *stmt_reset_file_upload_states; + /* prepared statement: file parts */ sqlite3_stmt *stmt_insert_file_part; sqlite3_stmt *stmt_update_file_part_uploaded; + sqlite3_stmt *stmt_update_file_part_delivery_attempt_count; sqlite3_stmt *stmt_get_next_file_part; sqlite3_stmt *stmt_update_file_part_in_progress; From fb471aeb7f80a1d41678ffacc62117f0800d75f0 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Fri, 20 Sep 2024 13:09:31 +0200 Subject: [PATCH 217/295] out_azure_blob: added remote configuration retrieval functionality --- plugins/out_azure_blob/azure_blob_conf.c | 468 ++++++++++++++++++++++- 1 file changed, 465 insertions(+), 3 deletions(-) diff --git a/plugins/out_azure_blob/azure_blob_conf.c b/plugins/out_azure_blob/azure_blob_conf.c index c376def322d..c6cb7e978aa 100644 --- a/plugins/out_azure_blob/azure_blob_conf.c +++ b/plugins/out_azure_blob/azure_blob_conf.c @@ -19,6 +19,7 @@ #include #include +#include #include "azure_blob.h" #include "azure_blob_conf.h" @@ -56,6 +57,452 @@ static int set_shared_key(struct flb_azure_blob *ctx) return 0; } +static int find_map_entry_by_key(msgpack_object_map *map, + char *key, + size_t match_index, + int case_insensitive) +{ + size_t match_count; + int result; + int index; + + match_count = 0; + + for (index = 0 ; index < (int) map->size ; index++) { + if (map->ptr[index].key.type == MSGPACK_OBJECT_STR) { + if (case_insensitive) { + result = strncasecmp(map->ptr[index].key.via.str.ptr, + key, + map->ptr[index].key.via.str.size); + } + else { + result = strncmp(map->ptr[index].key.via.str.ptr, + key, + map->ptr[index].key.via.str.size); + } + + if (result == 0) { + if (match_count == match_index) { + return index; + } + + match_count++; + } + } + } + + return -1; +} + +static int extract_map_string_entry_by_key(flb_sds_t *output, + msgpack_object_map *map, + char *key, + size_t match_index, + int case_insensitive) +{ + int index; + int result; + + index = find_map_entry_by_key(map, + key, + match_index, + case_insensitive); + + if (index == -1) { + return -1; + } + + if (map->ptr[index].val.type != MSGPACK_OBJECT_STR) { + return -2; + } + + if (*output == NULL) { + *output = flb_sds_create_len(map->ptr[index].val.via.str.ptr, + map->ptr[index].val.via.str.size); + + if (*output == NULL) { + return -3; + } + } + else { + (*output)[0] = '\0'; + + flb_sds_len_set(*output, 0); + + result = flb_sds_cat_safe(output, + map->ptr[index].val.via.str.ptr, + map->ptr[index].val.via.str.size); + + if (result != 0) { + return -4; + } + } + + return 0; +} + +static int flb_azure_blob_process_remote_configuration_payload( + struct flb_azure_blob *context, + char *payload, + size_t payload_size) +{ + size_t msgpack_body_length; + msgpack_object_map *configuration_map; + msgpack_unpacked unpacked_root; + char *msgpack_body; + int root_type; + size_t offset; + int result; + + result = flb_pack_json(payload, + payload_size, + &msgpack_body, + &msgpack_body_length, + &root_type, + NULL); + + if (result != 0) { + flb_plg_error(context->ins, + "JSON to msgpack conversion error"); + + result = -1; + } + else { + msgpack_unpacked_init(&unpacked_root); + + offset = 0; + result = msgpack_unpack_next(&unpacked_root, + msgpack_body, + msgpack_body_length, + &offset); + + if (result != MSGPACK_UNPACK_SUCCESS) { + flb_plg_error(context->ins, "corrupted msgpack data"); + + result = -1; + + goto cleanup; + } + + if (unpacked_root.data.type != MSGPACK_OBJECT_MAP) { + flb_plg_error(context->ins, "unexpected root object type"); + + result = -1; + + goto cleanup; + } + + configuration_map = &unpacked_root.data.via.map; + + result = extract_map_string_entry_by_key(&context->endpoint, + configuration_map, + "host", 0, FLB_TRUE); + + if (result != 0) { + flb_plg_error(context->ins, + "endpoint extraction error : %d", result); + + goto cleanup; + } + + if (context->atype == AZURE_BLOB_AUTH_KEY) { + result = extract_map_string_entry_by_key(&context->shared_key, + configuration_map, + "shared_key", 0, FLB_TRUE); + + if (result != 0) { + flb_plg_error(context->ins, + "neither sas_token nor shared_key " \ + "could be extracted : %d", result); + + goto cleanup; + } + } + else if (context->atype == AZURE_BLOB_AUTH_SAS) { + result = extract_map_string_entry_by_key(&context->sas_token, + configuration_map, + "sas_token", 0, FLB_TRUE); + + if (result != 0) { + flb_plg_error(context->ins, + "sas_token extraction error : %d", result); + + goto cleanup; + } + } + + result = extract_map_string_entry_by_key(&context->container_name, + configuration_map, + "container", 0, FLB_TRUE); + + if (result != 0) { + flb_plg_error(context->ins, + "container extraction error : %d", result); + + goto cleanup; + } + + result = extract_map_string_entry_by_key(&context->path, + configuration_map, + "path", 0, FLB_TRUE); + + if (result != 0) { + flb_plg_error(context->ins, + "path extraction error : %d", result); + + goto cleanup; + } + +cleanup: + if (result != 0) { + result = -1; + } + + msgpack_unpacked_destroy(&unpacked_root); + + flb_free(msgpack_body); + } + + return result; +} + +static int flb_azure_blob_apply_remote_configuration(struct flb_azure_blob *context) +{ + int ret; + size_t b_sent; + struct flb_http_client *http_client; + struct flb_connection *connection; + struct flb_upstream *upstream; + struct flb_tls *tls_context; + char *scheme = NULL; + char *host = NULL; + char *port = NULL; + char *uri = NULL; + uint16_t port_as_short; + + /* Parse and split URL */ + ret = flb_utils_url_split(context->configuration_endpoint_url, + &scheme, &host, &port, &uri); + if (ret == -1) { + flb_plg_error(context->ins, + "Invalid URL: %s", + context->configuration_endpoint_url); + + return -1; + } + + if (port != NULL) { + port_as_short = (uint16_t) strtoul(port, NULL, 10); + } + else { + if (scheme != NULL) { + if (strcasecmp(scheme, "https") == 0) { + port_as_short = 443; + } + else { + port_as_short = 80; + } + } + } + + if (scheme != NULL) { + flb_free(scheme); + scheme = NULL; + } + + if (port != NULL) { + flb_free(port); + port = NULL; + } + + if (host == NULL || uri == NULL) { + flb_plg_error(context->ins, + "Invalid URL: %s", + context->configuration_endpoint_url); + + if (host != NULL) { + flb_free(host); + } + + if (uri != NULL) { + flb_free(uri); + } + + return -2; + } + + tls_context = flb_tls_create(FLB_TLS_CLIENT_MODE, + FLB_FALSE, + FLB_FALSE, + host, + NULL, + NULL, + NULL, + NULL, + NULL); + + if (tls_context == NULL) { + flb_free(host); + flb_free(uri); + + flb_plg_error(context->ins, + "TLS context creation errror"); + + return -2; + } + + upstream = flb_upstream_create_url(context->config, + context->configuration_endpoint_url, + FLB_IO_TCP, + tls_context); + + if (upstream == NULL) { + flb_tls_destroy(tls_context); + flb_free(host); + flb_free(uri); + + flb_plg_error(context->ins, + "Upstream creation errror"); + + return -3; + } + + flb_stream_disable_async_mode(&upstream->base); + + /* Get upstream connection */ + connection = flb_upstream_conn_get(upstream); + if (connection == NULL) { + flb_upstream_destroy(upstream); + flb_tls_destroy(tls_context); + flb_free(host); + flb_free(uri); + + flb_plg_error(context->ins, + "cannot create connection"); + + return -3; + } + + /* Create HTTP client context */ + http_client = flb_http_client(connection, + FLB_HTTP_GET, + uri, + NULL, 0, + host, + (int) port_as_short, + NULL, 0); + if (http_client == NULL) { + flb_upstream_conn_release(connection); + flb_upstream_destroy(upstream); + flb_tls_destroy(tls_context); + flb_free(host); + flb_free(uri); + + flb_plg_error(context->ins, + "cannot create HTTP client"); + + return -4; + } + + flb_http_add_header(http_client, + "Accept", + strlen("Accept"), + "application/json", + 16); + + /* User Agent */ + flb_http_add_header(http_client, + "User-Agent", 10, + "Fluent-Bit", 10); + + if (context->configuration_endpoint_username != NULL && + context->configuration_endpoint_password != NULL) { + flb_http_basic_auth(http_client, + context->configuration_endpoint_username, + context->configuration_endpoint_password); + } + else if (context->configuration_endpoint_bearer_token != NULL) { + flb_http_bearer_auth(http_client, + context->configuration_endpoint_bearer_token); + } + + /* Send HTTP request */ + ret = flb_http_do(http_client, &b_sent); + + if (ret == -1) { + flb_http_client_destroy(http_client); + flb_upstream_conn_release(connection); + flb_upstream_destroy(upstream); + flb_tls_destroy(tls_context); + flb_free(host); + flb_free(uri); + + flb_plg_error(context->ins, + "Error sending configuration request"); + + return -5; + } + + if (http_client->resp.status == 200) { + flb_plg_info(context->ins, + "Configuration retrieved successfully"); + + ret = flb_azure_blob_process_remote_configuration_payload( + context, + http_client->resp.payload, + http_client->resp.payload_size); + + if (ret != 0) { + flb_plg_error(context->ins, + "Configuration payload processing error %d", + ret); + + flb_http_client_destroy(http_client); + flb_upstream_conn_release(connection); + flb_upstream_destroy(upstream); + flb_tls_destroy(tls_context); + flb_free(host); + flb_free(uri); + + return -7; + } + + flb_plg_info(context->ins, + "Configuration applied successfully"); + } + else { + if (http_client->resp.payload_size > 0) { + flb_plg_error(context->ins, + "Configuration retrieval failed with status %i\n%s", + http_client->resp.status, + http_client->resp.payload); + } + else { + flb_plg_error(context->ins, + "Configuration retrieval failed with status %i", + http_client->resp.status); + } + + flb_http_client_destroy(http_client); + flb_upstream_conn_release(connection); + flb_upstream_destroy(upstream); + flb_tls_destroy(tls_context); + flb_free(host); + flb_free(uri); + + return -6; + } + + flb_http_client_destroy(http_client); + flb_upstream_conn_release(connection); + flb_upstream_destroy(upstream); + flb_tls_destroy(tls_context); + flb_free(host); + flb_free(uri); + + return 0; +} + struct flb_azure_blob *flb_azure_blob_conf_create(struct flb_output_instance *ins, struct flb_config *config) { @@ -79,9 +526,21 @@ struct flb_azure_blob *flb_azure_blob_conf_create(struct flb_output_instance *in /* Load config map */ ret = flb_output_config_map_set(ins, (void *) ctx); if (ret == -1) { + flb_free(ctx); + return NULL; } + if (ctx->configuration_endpoint_url != NULL) { + ret = flb_azure_blob_apply_remote_configuration(ctx); + + if (ret != 0) { + flb_free(ctx); + + return NULL; + } + } + if (!ctx->container_name) { flb_plg_error(ctx->ins, "'container_name' has not been set"); return NULL; @@ -104,12 +563,14 @@ struct flb_azure_blob *flb_azure_blob_conf_create(struct flb_output_instance *in return NULL; } } - if (ctx->atype == AZURE_BLOB_AUTH_KEY && !ctx->shared_key) { + if (ctx->atype == AZURE_BLOB_AUTH_KEY && + ctx->shared_key == NULL) { flb_plg_error(ctx->ins, "'shared_key' has not been set"); return NULL; } + if (ctx->atype == AZURE_BLOB_AUTH_SAS) { - if (!ctx->sas_token) { + if (ctx->sas_token == NULL) { flb_plg_error(ctx->ins, "'sas_token' has not been set"); return NULL; } @@ -119,7 +580,8 @@ struct flb_azure_blob *flb_azure_blob_conf_create(struct flb_output_instance *in } /* If the shared key is set decode it */ - if (ctx->atype == AZURE_BLOB_AUTH_KEY && ctx->shared_key) { + if (ctx->atype == AZURE_BLOB_AUTH_KEY && + ctx->shared_key != NULL) { ret = set_shared_key(ctx); if (ret == -1) { return NULL; From 257a91acfabd6dd10030d293eef5d247cf3b4453 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Fri, 20 Sep 2024 13:09:56 +0200 Subject: [PATCH 218/295] out_azure_blob: added retry and source tracking related functionality --- plugins/out_azure_blob/azure_blob_db.c | 257 ++++++++++++++++++++++++- plugins/out_azure_blob/azure_blob_db.h | 78 ++++++-- 2 files changed, 313 insertions(+), 22 deletions(-) diff --git a/plugins/out_azure_blob/azure_blob_db.c b/plugins/out_azure_blob/azure_blob_db.c index f6239f1660a..b218a3b9dfc 100644 --- a/plugins/out_azure_blob/azure_blob_db.c +++ b/plugins/out_azure_blob/azure_blob_db.c @@ -47,6 +47,26 @@ static int prepare_stmts(struct flb_sqldb *db, struct flb_azure_blob *ctx) return -1; } + /* abort */ + ret = sqlite3_prepare_v2(db->handler, SQL_SET_FILE_ABORTED_STATE, -1, + &ctx->stmt_set_file_aborted_state, NULL); + if (ret != SQLITE_OK) { + flb_plg_error(ctx->ins, "cannot prepare SQL statement: %s", + SQL_SET_FILE_ABORTED_STATE); + return -1; + } + + /* delivery attempt counter update */ + ret = sqlite3_prepare_v2(db->handler, + SQL_UPDATE_FILE_DELIVERY_ATTEMPT_COUNT, -1, + &ctx->stmt_update_file_delivery_attempt_count, + NULL); + if (ret != SQLITE_OK) { + flb_plg_error(ctx->ins, "cannot prepare SQL statement: %s", + SQL_UPDATE_FILE_DELIVERY_ATTEMPT_COUNT); + return -1; + } + /* get */ ret = sqlite3_prepare_v2(db->handler, SQL_GET_FILE, -1, &ctx->stmt_get_file, NULL); @@ -56,6 +76,23 @@ static int prepare_stmts(struct flb_sqldb *db, struct flb_azure_blob *ctx) return -1; } + /* get next aborted file */ + ret = sqlite3_prepare_v2(db->handler, SQL_GET_NEXT_ABORTED_FILE, -1, + &ctx->stmt_get_next_aborted_file, NULL); + if (ret != SQLITE_OK) { + flb_plg_error(ctx->ins, "cannot prepare SQL statement: %s", + SQL_GET_NEXT_ABORTED_FILE); + return -1; + } + + ret = sqlite3_prepare_v2(db->handler, SQL_RESET_FILE_UPLOAD_STATES, -1, + &ctx->stmt_reset_file_upload_states, NULL); + if (ret != SQLITE_OK) { + flb_plg_error(ctx->ins, "cannot prepare SQL statement: %s", + SQL_RESET_FILE_UPLOAD_STATES); + return -1; + } + /* insert blob file part */ ret = sqlite3_prepare_v2(db->handler, SQL_INSERT_FILE_PART, -1, &ctx->stmt_insert_file_part, NULL); @@ -90,6 +127,15 @@ static int prepare_stmts(struct flb_sqldb *db, struct flb_azure_blob *ctx) return -1; } + ret = sqlite3_prepare_v2(db->handler, + SQL_UPDATE_FILE_PART_DELIVERY_ATTEMPT_COUNT, -1, + &ctx->stmt_update_file_part_delivery_attempt_count, + NULL); + if (ret != SQLITE_OK) { + flb_plg_error(ctx->ins, "cannot prepare SQL statement: %s", + SQL_UPDATE_FILE_PART_DELIVERY_ATTEMPT_COUNT); + return -1; + } ret = sqlite3_prepare_v2(db->handler, SQL_GET_OLDEST_FILE_WITH_PARTS_CONCAT, -1, &ctx->stmt_get_oldest_file_with_parts, NULL); @@ -178,11 +224,16 @@ int azb_db_close(struct flb_azure_blob *ctx) /* finalize prepared statements */ sqlite3_finalize(ctx->stmt_insert_file); sqlite3_finalize(ctx->stmt_delete_file); + sqlite3_finalize(ctx->stmt_set_file_aborted_state); sqlite3_finalize(ctx->stmt_get_file); + sqlite3_finalize(ctx->stmt_update_file_delivery_attempt_count); + sqlite3_finalize(ctx->stmt_get_next_aborted_file); + sqlite3_finalize(ctx->stmt_reset_file_upload_states); sqlite3_finalize(ctx->stmt_insert_file_part); sqlite3_finalize(ctx->stmt_update_file_part_uploaded); sqlite3_finalize(ctx->stmt_update_file_part_in_progress); + sqlite3_finalize(ctx->stmt_update_file_part_delivery_attempt_count); sqlite3_finalize(ctx->stmt_get_next_file_part); sqlite3_finalize(ctx->stmt_get_oldest_file_with_parts); @@ -222,7 +273,8 @@ int azb_db_file_exists(struct flb_azure_blob *ctx, char *path, uint64_t *id) return exists; } -int64_t azb_db_file_insert(struct flb_azure_blob *ctx, char *path, size_t size) +int64_t azb_db_file_insert(struct flb_azure_blob *ctx, + char *source, char *path, size_t size) { int ret; int64_t id; @@ -234,9 +286,10 @@ int64_t azb_db_file_insert(struct flb_azure_blob *ctx, char *path, size_t size) azb_db_lock(ctx); /* Bind parameters */ - sqlite3_bind_text(ctx->stmt_insert_file, 1, path, -1, 0); - sqlite3_bind_int64(ctx->stmt_insert_file, 2, size); - sqlite3_bind_int64(ctx->stmt_insert_file, 3, created); + sqlite3_bind_text(ctx->stmt_insert_file, 1, source, -1, 0); + sqlite3_bind_text(ctx->stmt_insert_file, 2, path, -1, 0); + sqlite3_bind_int64(ctx->stmt_insert_file, 3, size); + sqlite3_bind_int64(ctx->stmt_insert_file, 4, created); /* Run the insert */ ret = sqlite3_step(ctx->stmt_insert_file); @@ -294,6 +347,166 @@ int azb_db_file_delete(struct flb_azure_blob *ctx, uint64_t id, char *path) return 0; } +int azb_db_file_set_aborted_state(struct flb_azure_blob *ctx, + uint64_t id, char *path, + uint64_t state) +{ + int ret; + + azb_db_lock(ctx); + + /* Bind parameters */ + sqlite3_bind_int64(ctx->stmt_set_file_aborted_state, 1, state); + sqlite3_bind_int64(ctx->stmt_set_file_aborted_state, 2, id); + ret = sqlite3_step(ctx->stmt_set_file_aborted_state); + if (ret != SQLITE_DONE) { + sqlite3_clear_bindings(ctx->stmt_set_file_aborted_state); + sqlite3_reset(ctx->stmt_set_file_aborted_state); + azb_db_unlock(ctx); + return -1; + } + + sqlite3_clear_bindings(ctx->stmt_set_file_aborted_state); + sqlite3_reset(ctx->stmt_set_file_aborted_state); + + if (ret != SQLITE_DONE) { + flb_plg_error(ctx->ins, "db: error aborting entry id=%" PRIu64 + ", path='%s' from database", id, path); + azb_db_unlock(ctx); + return -1; + } + + flb_plg_debug(ctx->ins, "db: file id=%" PRIu64 + ", path='%s' marked as aborted in the database", id, path); + + azb_db_unlock(ctx); + return 0; +} + +int azb_db_file_delivery_attempts(struct flb_azure_blob *ctx, + uint64_t id, uint64_t attempts) +{ + int ret; + + azb_db_lock(ctx); + + /* Bind parameters */ + sqlite3_bind_int64(ctx->stmt_update_file_delivery_attempt_count, 1, attempts); + sqlite3_bind_int64(ctx->stmt_update_file_delivery_attempt_count, 2, id); + + /* Run the update */ + ret = sqlite3_step(ctx->stmt_update_file_delivery_attempt_count); + + sqlite3_clear_bindings(ctx->stmt_update_file_delivery_attempt_count); + sqlite3_reset(ctx->stmt_update_file_delivery_attempt_count); + + azb_db_unlock(ctx); + + if (ret != SQLITE_DONE) { + flb_plg_error(ctx->ins, + "cannot update delivery attempt " + "count for file id=%" PRIu64, id); + + return -1; + } + + return 0; +} + +int azb_db_file_get_next_aborted(struct flb_azure_blob *ctx, + uint64_t *id, + uint64_t *delivery_attempts, + cfl_sds_t *path, + cfl_sds_t *source) +{ + int ret; + char *tmp_source; + char *tmp_path; + int exists = FLB_FALSE; + + azb_db_lock(ctx); + + /* Bind parameters */ + ret = sqlite3_step(ctx->stmt_get_next_aborted_file); + if (ret == SQLITE_ROW) { + exists = FLB_TRUE; + + /* id: column 0 */ + *id = sqlite3_column_int64(ctx->stmt_get_next_aborted_file, 0); + *delivery_attempts = sqlite3_column_int64(ctx->stmt_get_next_file_part, 1); + tmp_source = (char *) sqlite3_column_text(ctx->stmt_get_next_file_part, 2); + tmp_path = (char *) sqlite3_column_text(ctx->stmt_get_next_file_part, 3); + + *path = cfl_sds_create(tmp_path); + + if (*path == NULL) { + exists = -1; + } + else { + *source = cfl_sds_create(tmp_source); + if (*source == NULL) { + cfl_sds_destroy(*path); + exists = -1; + } + } + } + else if (ret == SQLITE_DONE) { + /* all good */ + } + else { + exists = -1; + } + + sqlite3_clear_bindings(ctx->stmt_get_next_aborted_file); + sqlite3_reset(ctx->stmt_get_next_aborted_file); + + azb_db_unlock(ctx); + + if (exists == -1) { + *id = 0; + *delivery_attempts = 0; + *path = NULL; + *source = NULL; + } + + return exists; +} + +int azb_db_file_reset_upload_states(struct flb_azure_blob *ctx, uint64_t id, char *path) +{ + int ret; + + azb_db_lock(ctx); + + /* Bind parameters */ + sqlite3_bind_int64(ctx->stmt_reset_file_upload_states, 1, id); + ret = sqlite3_step(ctx->stmt_reset_file_upload_states); + if (ret != SQLITE_DONE) { + sqlite3_clear_bindings(ctx->stmt_reset_file_upload_states); + sqlite3_reset(ctx->stmt_reset_file_upload_states); + azb_db_unlock(ctx); + return -1; + } + + sqlite3_clear_bindings(ctx->stmt_reset_file_upload_states); + sqlite3_reset(ctx->stmt_reset_file_upload_states); + + if (ret != SQLITE_DONE) { + flb_plg_error(ctx->ins, "db: error reseting upload " + "states for entry id=%" PRIu64 + ", path='%s'", id, path); + azb_db_unlock(ctx); + return -1; + } + + flb_plg_debug(ctx->ins, "db: file id=%" PRIu64 + ", path='%s' upload states reset", id, path); + + azb_db_unlock(ctx); + + return 0; +} + int azb_db_file_part_insert(struct flb_azure_blob *ctx, uint64_t file_id, uint64_t part_id, size_t offset_start, size_t offset_end, @@ -358,6 +571,8 @@ int azb_db_file_part_in_progress(struct flb_azure_blob *ctx, int in_progress, ui int azb_db_file_part_get_next(struct flb_azure_blob *ctx, uint64_t *id, uint64_t *file_id, uint64_t *part_id, off_t *offset_start, off_t *offset_end, + uint64_t *part_delivery_attempts, + uint64_t *file_delivery_attempts, cfl_sds_t *file_path) { int ret; @@ -378,7 +593,9 @@ int azb_db_file_part_get_next(struct flb_azure_blob *ctx, *part_id = sqlite3_column_int64(ctx->stmt_get_next_file_part, 2); *offset_start = sqlite3_column_int64(ctx->stmt_get_next_file_part, 3); *offset_end = sqlite3_column_int64(ctx->stmt_get_next_file_part, 4); - tmp = (char *) sqlite3_column_text(ctx->stmt_get_next_file_part, 5); + *part_delivery_attempts = sqlite3_column_int64(ctx->stmt_get_next_file_part, 5); + tmp = (char *) sqlite3_column_text(ctx->stmt_get_next_file_part, 6); + *file_delivery_attempts = sqlite3_column_int64(ctx->stmt_get_next_file_part, 7); } else if (ret == SQLITE_DONE) { /* no records */ @@ -445,6 +662,36 @@ int azb_db_file_part_uploaded(struct flb_azure_blob *ctx, uint64_t id) return 0; } +int azb_db_file_part_delivery_attempts(struct flb_azure_blob *ctx, + uint64_t id, uint64_t attempts) +{ + int ret; + + azb_db_lock(ctx); + + /* Bind parameters */ + sqlite3_bind_int64(ctx->stmt_update_file_part_delivery_attempt_count, 1, attempts); + sqlite3_bind_int64(ctx->stmt_update_file_part_delivery_attempt_count, 2, id); + + /* Run the update */ + ret = sqlite3_step(ctx->stmt_update_file_part_delivery_attempt_count); + + sqlite3_clear_bindings(ctx->stmt_update_file_part_delivery_attempt_count); + sqlite3_reset(ctx->stmt_update_file_part_delivery_attempt_count); + + azb_db_unlock(ctx); + + if (ret != SQLITE_DONE) { + flb_plg_error(ctx->ins, + "cannot update delivery attempt " + "count for part id=%" PRIu64, id); + + return -1; + } + + return 0; +} + int azb_db_file_oldest_ready(struct flb_azure_blob *ctx, uint64_t *file_id, cfl_sds_t *path, cfl_sds_t *part_ids) { diff --git a/plugins/out_azure_blob/azure_blob_db.h b/plugins/out_azure_blob/azure_blob_db.h index d238349bae2..1009d08733c 100644 --- a/plugins/out_azure_blob/azure_blob_db.h +++ b/plugins/out_azure_blob/azure_blob_db.h @@ -27,35 +27,56 @@ #define SQL_CREATE_AZURE_BLOB_FILES \ "CREATE TABLE IF NOT EXISTS out_azure_blob_files (" \ - " id INTEGER PRIMARY KEY," \ - " path TEXT NOT NULL," \ - " size INTEGER," \ - " created INTEGER" \ + " id INTEGER PRIMARY KEY," \ + " source TEXT NOT NULL," \ + " path TEXT NOT NULL," \ + " size INTEGER," \ + " created INTEGER," \ + " delivery_attempts INTEGER DEFAULT 0," \ + " aborted INTEGER DEFAULT 0" \ ");" #define SQL_CREATE_AZURE_BLOB_PARTS \ "CREATE TABLE IF NOT EXISTS out_azure_blob_parts (" \ - " id INTEGER PRIMARY KEY," \ - " file_id INTEGER NOT NULL," \ - " part_id INTEGER NOT NULL," \ - " uploaded INTEGER DEFAULT 0," \ - " in_progress INTEGER DEFAULT 0," \ - " offset_start INTEGER," \ - " offset_end INTEGER," \ + " id INTEGER PRIMARY KEY," \ + " file_id INTEGER NOT NULL," \ + " part_id INTEGER NOT NULL," \ + " uploaded INTEGER DEFAULT 0," \ + " in_progress INTEGER DEFAULT 0," \ + " offset_start INTEGER," \ + " offset_end INTEGER," \ + " delivery_attempts INTEGER DEFAULT 0," \ " FOREIGN KEY (file_id) REFERENCES out_azure_blob_files(id) " \ " ON DELETE CASCADE" \ ");" #define SQL_INSERT_FILE \ - "INSERT INTO out_azure_blob_files (path, size, created)" \ - " VALUES (@path, @size, @created);" + "INSERT INTO out_azure_blob_files (source, path, size, created)" \ + " VALUES (@source, @path, @size, @created);" /* DELETE a registered file and all it parts */ #define SQL_DELETE_FILE \ "DELETE FROM out_azure_blob_files WHERE id=@id;" +#define SQL_SET_FILE_ABORTED_STATE \ + "UPDATE out_azure_blob_files SET aborted=@state WHERE id=@id;" + +#define SQL_UPDATE_FILE_DELIVERY_ATTEMPT_COUNT \ + "UPDATE out_azure_blob_files SET delivery_attempts=@delivery_attempts WHERE id=@id;" + #define SQL_GET_FILE \ - "SELECT * from out_azure_blob_files WHERE path=@path order by id desc;" + "SELECT * FROM out_azure_blob_files WHERE path=@path ORDER BY id DESC;" + +#define SQL_GET_NEXT_ABORTED_FILE \ + "SELECT id, delivery_attempts, source, path " \ + " FROM out_azure_blob_files azbf " \ + " WHERE aborted = 1 " \ + " AND (SELECT COUNT(*) " \ + " FROM out_azure_blob_parts azbp " \ + " WHERE azbp.file_id = azbf.id " \ + " AND in_progress = 1) = 0 " \ + "ORDER BY id DESC " \ + "LIMIT 1;" #define SQL_INSERT_FILE_PART \ "INSERT INTO out_azure_blob_parts (file_id, part_id, offset_start, offset_end)" \ @@ -67,6 +88,12 @@ #define SQL_UPDATE_FILE_PART_IN_PROGRESS \ "UPDATE out_azure_blob_parts SET in_progress=@status WHERE id=@id;" +#define SQL_UPDATE_FILE_PART_DELIVERY_ATTEMPT_COUNT \ + "UPDATE out_azure_blob_parts SET delivery_attempts=@delivery_attempts WHERE id=@id;" + +#define SQL_RESET_FILE_UPLOAD_STATES \ + "UPDATE out_azure_blob_parts SET delivery_attempts=0, uploaded=0, in_progress=0 WHERE file_id=@id;" + /* Find the oldest files and retrieve the oldest part ready to be uploaded */ #define SQL_GET_NEXT_FILE_PART \ "SELECT p.id, " \ @@ -74,12 +101,15 @@ " p.part_id, " \ " p.offset_start, " \ " p.offset_end, " \ - " f.path " \ + " p.delivery_attempts, " \ + " f.path, " \ + " f.delivery_attempts " \ "FROM out_azure_blob_parts p " \ " JOIN out_azure_blob_files f " \ " ON p.file_id = f.id " \ "WHERE p.uploaded = 0 " \ - " AND p.in_progress = 0 " \ + " AND p.in_progress = 0 " \ + " AND f.aborted = 0 " \ "ORDER BY f.created ASC, " \ " p.part_id ASC " \ "LIMIT 1;" @@ -109,8 +139,19 @@ struct flb_sqldb *azb_db_open(struct flb_azure_blob *ctx, char *db_path); int azb_db_close(struct flb_azure_blob *ctx); int azb_db_file_exists(struct flb_azure_blob *ctx, char *path, uint64_t *id); -int64_t azb_db_file_insert(struct flb_azure_blob *ctx, char *path, size_t size); +int64_t azb_db_file_insert(struct flb_azure_blob *ctx, + char *source, char *path, size_t size); int azb_db_file_delete(struct flb_azure_blob *ctx, uint64_t id, char *path); +int azb_db_file_set_aborted_state(struct flb_azure_blob *ctx, + uint64_t id, char *path, + uint64_t state); +int azb_db_file_delivery_attempts(struct flb_azure_blob *ctx, uint64_t id, uint64_t attempts); +int azb_db_file_get_next_aborted(struct flb_azure_blob *ctx, + uint64_t *id, + uint64_t *delivery_attempts, + cfl_sds_t *path, + cfl_sds_t *source); +int azb_db_file_reset_upload_states(struct flb_azure_blob *ctx, uint64_t id, char *path); int azb_db_file_part_insert(struct flb_azure_blob *ctx, uint64_t file_id, uint64_t part_id, @@ -120,8 +161,11 @@ int azb_db_file_part_in_progress(struct flb_azure_blob *ctx, int in_progress, ui int azb_db_file_part_get_next(struct flb_azure_blob *ctx, uint64_t *id, uint64_t *file_id, uint64_t *part_id, off_t *offset_start, off_t *offset_end, + uint64_t *part_delivery_attempts, + uint64_t *file_delivery_attempts, cfl_sds_t *file_path); int azb_db_file_part_uploaded(struct flb_azure_blob *ctx, uint64_t id); +int azb_db_file_part_delivery_attempts(struct flb_azure_blob *ctx, uint64_t id, uint64_t attempts); int azb_db_file_oldest_ready(struct flb_azure_blob *ctx, uint64_t *file_id, cfl_sds_t *path, cfl_sds_t *part_ids); From 2c3ea3ac8e1224a5ba607a69bcad586caee191ac Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Sat, 21 Sep 2024 19:29:50 +0200 Subject: [PATCH 219/295] in_blob: added fluentd style recursive file discovery Signed-off-by: Leonardo Alminana --- plugins/in_blob/blob.c | 261 ++++++++++++++++++++++++++++++++++------- 1 file changed, 217 insertions(+), 44 deletions(-) diff --git a/plugins/in_blob/blob.c b/plugins/in_blob/blob.c index 223aa4a13c8..895d08c4f29 100644 --- a/plugins/in_blob/blob.c +++ b/plugins/in_blob/blob.c @@ -115,9 +115,10 @@ static char *expand_tilde(const char *path) } #endif - -static inline int do_glob(const char *pattern, int flags, - void *not_used, glob_t *pglob) +static inline int do_glob(const char *pattern, + int flags, + void *not_used, + glob_t *pglob) { int ret; int new_flags; @@ -166,80 +167,252 @@ static inline int do_glob(const char *pattern, int flags, return ret; } -static int scan_path(struct blob_ctx *ctx) +/* This function recursively searches a directory tree using + * a glob compatible pattern that implements the fluentd style + * recursion wildcard **. + * + * Result values : + * - Negative values identify error conditions + * - Zero and positive values represent the match count + * + * Known issues : + * - This function is only able to handle one recursion + * wildcard in its pattern. + * - This function does not follow directory links + * - Pattern generation needs to be optimized to + * minimize garbage pattern generation + */ +static ssize_t recursive_file_search(struct blob_ctx *ctx, + const char *path, + const char *pattern) { - int i; - int ret; - int count = 0; - glob_t globbuf; - struct stat st; + char *recursive_search_token; + int recursive_search_flag; + struct stat fs_entry_metadata; + ssize_t recursion_result; + cfl_sds_t local_pattern; + glob_t glob_context; + ssize_t match_count; + cfl_sds_t local_path; + cfl_sds_t sds_result; + int result; + size_t index; + match_count = 0; + + if (path != NULL) { + local_path = cfl_sds_create(path); + } + else { + local_path = cfl_sds_create(""); + } + + if (local_path == NULL) { + return -1; + } + + if (pattern != NULL) { + local_pattern = cfl_sds_create(pattern); + } + else { + local_pattern = cfl_sds_create(""); + } + + if (local_pattern == NULL) { + cfl_sds_destroy(local_path); + + return -2; + } + + recursive_search_flag = FLB_TRUE; + recursive_search_token = strstr(local_pattern, "/**/"); + + if (recursive_search_token != NULL) { + if (strstr(&recursive_search_token[4], "/**/") != NULL) { + flb_plg_error(ctx->ins, + "a search path with multiple recursivity " \ + "wildcards was provided which is not " \ + "supported. \"%s\"", local_pattern); - flb_plg_debug(ctx->ins, "scanning path %s", ctx->path); + cfl_sds_destroy(local_pattern); + cfl_sds_destroy(local_path); - /* Safe reset for globfree() */ - globbuf.gl_pathv = NULL; + return -3; + } + + recursive_search_token[0] = '\0'; + + sds_result = cfl_sds_cat(local_path, + local_pattern, + strlen(local_pattern)); + + if (sds_result == NULL) { + cfl_sds_destroy(local_pattern); + cfl_sds_destroy(local_path); + + return -4; + } + + local_path = sds_result; + + memmove(local_pattern, + &recursive_search_token[3], + strlen(&recursive_search_token[3]) + 1); + + cfl_sds_len_set(local_pattern, + strlen(&recursive_search_token[3])); + } + else if (cfl_sds_len(local_pattern) == 0) { + recursive_search_flag = FLB_FALSE; + } + + memset(&glob_context, 0, sizeof(glob_t)); /* Scan the given path */ - ret = do_glob(ctx->path, GLOB_TILDE | GLOB_ERR, NULL, &globbuf); - if (ret != 0) { - switch (ret) { + result = do_glob(local_path, GLOB_TILDE | GLOB_ERR, NULL, &glob_context); + if (result != 0) { + switch (result) { case GLOB_NOSPACE: flb_plg_error(ctx->ins, "no memory space available"); - return -1; + return -5; case GLOB_ABORTED: - flb_plg_error(ctx->ins, "read error, check permissions: %s", ctx->path); - return -1; + return 0; case GLOB_NOMATCH: - ret = stat(ctx->path, &st); - if (ret == -1) { - flb_plg_debug(ctx->ins, "cannot read info from: %s", ctx->path); + result = stat(local_path, &fs_entry_metadata); + + if (result == -1) { + flb_plg_debug(ctx->ins, "cannot read info from: %s", local_path); } else { - ret = access(ctx->path, R_OK); - if (ret == -1 && errno == EACCES) { - flb_plg_error(ctx->ins, "NO read access for path: %s", ctx->path); + result = access(local_path, R_OK); + if (result == -1 && errno == EACCES) { + flb_plg_error(ctx->ins, "NO read access for path: %s", local_path); } else { - flb_plg_debug(ctx->ins, "NO matches for path: %s", ctx->path); + flb_plg_debug(ctx->ins, "NO matches for path: %s", local_path); } } - return 0; + + return 6; } } - /* For every entry found, generate an output list */ - for (i = 0; i < globbuf.gl_pathc; i++) { - ret = stat(globbuf.gl_pathv[i], &st); - if (ret != 0) { - flb_plg_debug(ctx->ins, "skip entry=%s", globbuf.gl_pathv[i]); + for (index = 0; index < glob_context.gl_pathc; index++) { + result = stat(glob_context.gl_pathv[index], &fs_entry_metadata); + + if (result != 0) { + flb_plg_debug(ctx->ins, "skip entry=%s", glob_context.gl_pathv[index]); + continue; } - if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) { - ret = blob_file_append(ctx, globbuf.gl_pathv[i], &st); - if (ret == 0) { - flb_plg_debug(ctx->ins, "blob scan add: %s, inode %" PRIu64, - globbuf.gl_pathv[i], (uint64_t) st.st_ino); + if (S_ISDIR(fs_entry_metadata.st_mode)) { + local_path[0] = '\0'; + + cfl_sds_len_set(local_path, 0); + + sds_result = cfl_sds_printf(&local_path, + "%s/*", + glob_context.gl_pathv[index]); + + if (sds_result == NULL) { + cfl_sds_destroy(local_pattern); + cfl_sds_destroy(local_path); + + return -7; } - else { - flb_plg_debug(ctx->ins, "blob scan skip: %s", globbuf.gl_pathv[i]); + + recursion_result = recursive_file_search(ctx, + local_path, + local_pattern); + + if (recursion_result < 0) { + cfl_sds_destroy(local_pattern); + cfl_sds_destroy(local_path); + + return -8; + } + + match_count += recursion_result; + + local_path[0] = '\0'; + + cfl_sds_len_set(local_path, 0); + + sds_result = cfl_sds_printf(&local_path, + "%s%s", + glob_context.gl_pathv[index], + local_pattern); + + if (sds_result == NULL) { + cfl_sds_destroy(local_pattern); + cfl_sds_destroy(local_path); + + return -9; + } + + recursion_result = recursive_file_search(ctx, + local_path, + NULL); + + if (recursion_result < 0) { + cfl_sds_destroy(local_pattern); + cfl_sds_destroy(local_path); + + return -10; } + + match_count += recursion_result; } - else { - flb_plg_debug(ctx->ins, "skip entry=%s", globbuf.gl_pathv[i]); + else if (recursive_search_flag == FLB_FALSE && + (S_ISREG(fs_entry_metadata.st_mode) || + S_ISLNK(fs_entry_metadata.st_mode))) { + result = blob_file_append(ctx, + glob_context.gl_pathv[index], + &fs_entry_metadata); + + if (result == 0) { + flb_plg_debug(ctx->ins, + "blob scan add: %s, inode %" PRIu64, + glob_context.gl_pathv[index], + (uint64_t) fs_entry_metadata.st_ino); + } + else { + flb_plg_debug(ctx->ins, + "blob scan skip: %s", + glob_context.gl_pathv[index]); + } + + match_count++; } } - globfree(&globbuf); - return count; + globfree(&glob_context); + + cfl_sds_destroy(local_pattern); + cfl_sds_destroy(local_path); + + return match_count; } static int cb_scan_path(struct flb_input_instance *ins, struct flb_config *config, void *in_context) { - struct blob_ctx *ctx = in_context; + ssize_t result; + struct blob_ctx *ctx;; + + ctx = (struct blob_ctx *) in_context; + + flb_plg_info(ctx->ins, "scanning path %s", ctx->path); - return scan_path(ctx); + result = recursive_file_search(ctx, NULL, ctx->path); + + if (result < 0) { + flb_plg_trace(ctx->ins, + "path scanning returned error code : %zd", + result); + } + + return 0; } /* Initialize plugin */ From 0c17636aa1dc9fb90720eacb3b8eeaae20916761 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Sun, 22 Sep 2024 01:26:13 +0200 Subject: [PATCH 220/295] config: added plugin notification channel Signed-off-by: Leonardo Alminana --- include/fluent-bit/flb_config.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/include/fluent-bit/flb_config.h b/include/fluent-bit/flb_config.h index 82003386d6e..1cfc6301ff8 100644 --- a/include/fluent-bit/flb_config.h +++ b/include/fluent-bit/flb_config.h @@ -48,11 +48,11 @@ struct flb_config { int is_running; /* service running ? */ double flush; /* Flush timeout */ - /* - * Maximum grace time on shutdown. If set to -1, the engine will + /* + * Maximum grace time on shutdown. If set to -1, the engine will * shutdown when all remaining tasks are flushed */ - int grace; + int grace; int grace_count; /* Count of grace shutdown tries */ flb_pipefd_t flush_fd; /* Timer FD associated to flush */ int convert_nan_to_null; /* convert null to nan ? */ @@ -71,6 +71,10 @@ struct flb_config { flb_pipefd_t ch_self_events[2]; /* channel to recieve thread tasks */ + int notification_channels_initialized; + flb_pipefd_t notification_channels[2]; + struct mk_event notification_event; + /* Channel event loop (just for ch_notif) */ struct mk_event_loop *ch_evl; From dffc98a7e4d1c53ed82aa319475fc780ef318e3c Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Sun, 22 Sep 2024 01:26:31 +0200 Subject: [PATCH 221/295] engine_macros: added plugin notification event type Signed-off-by: Leonardo Alminana --- include/fluent-bit/flb_engine_macros.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/fluent-bit/flb_engine_macros.h b/include/fluent-bit/flb_engine_macros.h index 8b79634f7d2..348387e3386 100644 --- a/include/fluent-bit/flb_engine_macros.h +++ b/include/fluent-bit/flb_engine_macros.h @@ -39,6 +39,8 @@ #define FLB_ENGINE_EV_THREAD_OUTPUT (1 << 17) /* 131072 */ #define FLB_ENGINE_EV_THREAD_ENGINE (1 << 18) /* 262144 */ +#define FLB_ENGINE_EV_NOTIFICATION (1 << 19) /* 524288 */ + /* Engine events: all engine events set the left 32 bits to '1' */ #define FLB_ENGINE_EV_STARTED FLB_BITS_U64_SET(1, 1) /* Engine started */ #define FLB_ENGINE_EV_FAILED FLB_BITS_U64_SET(1, 2) /* Engine started */ From af42eb2a6f451a9ee96e08393a9b04912a52d993 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Sun, 22 Sep 2024 01:27:02 +0200 Subject: [PATCH 222/295] filter: added plugin notification feature Signed-off-by: Leonardo Alminana --- include/fluent-bit/flb_filter.h | 4 ++++ src/flb_filter.c | 3 +++ 2 files changed, 7 insertions(+) diff --git a/include/fluent-bit/flb_filter.h b/include/fluent-bit/flb_filter.h index 1b6c2ee7b16..a7e71e0e933 100644 --- a/include/fluent-bit/flb_filter.h +++ b/include/fluent-bit/flb_filter.h @@ -74,6 +74,9 @@ struct flb_filter_plugin { void *, struct flb_config *); int (*cb_exit) (void *, struct flb_config *); + /* Notification: this callback will be invoked anytime a notification is received*/ + int (*cb_notification) (struct flb_filter_instance *, struct flb_config *, void *); + struct mk_list _head; /* Link to parent list (config->filters) */ }; @@ -110,6 +113,7 @@ struct flb_filter_instance { #ifdef FLB_HAVE_METRICS struct flb_metrics *metrics; /* metrics */ #endif + flb_pipefd_t notification_channel; /* Keep a reference to the original context this instance belongs to */ struct flb_config *config; diff --git a/src/flb_filter.c b/src/flb_filter.c index e344336dbad..83b2a1b3328 100644 --- a/src/flb_filter.c +++ b/src/flb_filter.c @@ -614,6 +614,9 @@ int flb_filter_init_all(struct flb_config *config) flb_filter_instance_destroy(ins); return -1; } + + ins->notification_channel = \ + config->notification_channels[1]; } return 0; From 72bece5da8b830d736e529b6d503dc72815086be Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Sun, 22 Sep 2024 01:27:16 +0200 Subject: [PATCH 223/295] input: added plugin notification feature Signed-off-by: Leonardo Alminana --- include/fluent-bit/flb_input.h | 6 ++++++ src/flb_input.c | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/fluent-bit/flb_input.h b/include/fluent-bit/flb_input.h index 7fbb4ebefcb..0b7be267c20 100644 --- a/include/fluent-bit/flb_input.h +++ b/include/fluent-bit/flb_input.h @@ -102,6 +102,9 @@ struct flb_input_plugin { /* Collect: every certain amount of time, Fluent Bit trigger this callback */ int (*cb_collect) (struct flb_input_instance *, struct flb_config *, void *); + /* Notification: this callback will be invoked anytime a notification is received*/ + int (*cb_notification) (struct flb_input_instance *, struct flb_config *, void *); + /* * Flush: each plugin during a collection, it does some buffering, * when the Flush timer takes place on the Engine, it will trigger @@ -381,6 +384,8 @@ struct flb_input_instance { struct mk_list *net_config_map; struct mk_list net_properties; + flb_pipefd_t notification_channel; + /* Keep a reference to the original context this instance belongs to */ struct flb_config *config; }; @@ -735,6 +740,7 @@ int flb_input_upstream_set(struct flb_upstream *u, struct flb_input_instance *in int flb_input_downstream_set(struct flb_downstream *stream, struct flb_input_instance *ins); + /* processors */ int flb_input_instance_processors_load(struct flb_input_instance *ins, struct flb_cf_group *processors); diff --git a/src/flb_input.c b/src/flb_input.c index 7b7390b40e8..8b147b4d5ca 100644 --- a/src/flb_input.c +++ b/src/flb_input.c @@ -808,6 +808,7 @@ void flb_input_instance_destroy(struct flb_input_instance *ins) if (ins->processor) { flb_processor_destroy(ins->processor); } + flb_free(ins); } @@ -1201,6 +1202,8 @@ int flb_input_instance_init(struct flb_input_instance *ins, return -1; } + //ins->notification_channel = ins->thi->notification_channels[1]; + /* register the ring buffer */ ret = flb_ring_buffer_add_event_loop(ins->rb, config->evl, FLB_INPUT_RING_BUFFER_WINDOW); if (ret) { @@ -1216,6 +1219,9 @@ int flb_input_instance_init(struct flb_input_instance *ins, flb_error("failed initialize channel events on input %s", ins->name); } + + ins->notification_channel = config->notification_channels[1]; + ret = p->cb_init(ins, config, ins->data); if (ret != 0) { flb_error("failed initialize input %s", @@ -1225,6 +1231,8 @@ int flb_input_instance_init(struct flb_input_instance *ins, } } + ins->processor->notification_channel = ins->notification_channel; + /* initialize processors */ ret = flb_processor_init(ins->processor); if (ret == -1) { @@ -2016,3 +2024,8 @@ int flb_input_downstream_set(struct flb_downstream *stream, return 0; } + +int flb_input_handle_notification(struct flb_input_instance *ins) +{ + return 0; +} From 3aa2794887aacfef60b7f4c636dc60efa849f297 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Sun, 22 Sep 2024 01:27:29 +0200 Subject: [PATCH 224/295] input: added plugin notification feature Signed-off-by: Leonardo Alminana --- src/flb_input_thread.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/flb_input_thread.c b/src/flb_input_thread.c index bf073296de2..43eb1ec905e 100644 --- a/src/flb_input_thread.c +++ b/src/flb_input_thread.c @@ -31,6 +31,7 @@ #include #include #include +#include static int input_thread_instance_set_status(struct flb_input_instance *ins, uint32_t status); static int input_thread_instance_get_status(struct flb_input_instance *ins); @@ -208,6 +209,15 @@ static void input_thread_instance_destroy(struct flb_input_thread_instance *thi) mk_event_closesocket(thi->ch_thread_events[1]); } + if (thi->notification_channels_initialized == FLB_TRUE) { + mk_event_channel_destroy(thi->evl, + thi->notification_channels[0], + thi->notification_channels[1], + &thi->notification_event); + + thi->notification_channels_initialized = FLB_FALSE; + } + flb_tp_destroy(thi->tp); flb_free(thi); } @@ -270,6 +280,24 @@ static struct flb_input_thread_instance *input_thread_instance_create(struct flb } thi->event_local.type = FLB_ENGINE_EV_THREAD_INPUT; + ret = mk_event_channel_create(thi->evl, + &thi->notification_channels[0], + &thi->notification_channels[1], + &thi->notification_event); + if (ret == -1) { + flb_error("could not create notification channel for %s", + flb_input_name(ins)); + + input_thread_instance_destroy(thi); + + return NULL; + } + + thi->notification_channels_initialized = FLB_TRUE; + thi->notification_event.type = FLB_ENGINE_EV_NOTIFICATION; + + ins->notification_channel = thi->notification_channels[1]; + /* create thread pool, just one worker */ thi->tp = flb_tp_create(ins->config); if (!thi->tp) { @@ -296,6 +324,7 @@ static void input_thread(void *data) struct flb_input_plugin *p; struct flb_sched *sched = NULL; struct flb_net_dns dns_ctx = {0}; + struct flb_notification *notification; thi = (struct flb_input_thread_instance *) data; ins = thi->ins; @@ -432,6 +461,15 @@ static void input_thread(void *data) else if (event->type == FLB_ENGINE_EV_THREAD_INPUT) { handle_input_thread_event(event->fd, ins->config); } + else if(event->type == FLB_ENGINE_EV_NOTIFICATION) { + ret = flb_notification_receive(event->fd, ¬ification); + + if (ret == 0) { + ret = flb_notification_deliver(notification); + + flb_notification_cleanup(notification); + } + } } flb_net_dns_lookup_context_cleanup(&dns_ctx); From 3d3427c72eeeb08b73883161138c7056cb3d55d6 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Sun, 22 Sep 2024 01:27:47 +0200 Subject: [PATCH 225/295] output: added plugin notification feature Signed-off-by: Leonardo Alminana --- include/fluent-bit/flb_output.h | 5 +++ include/fluent-bit/flb_output_thread.h | 3 ++ src/flb_output.c | 8 +++-- src/flb_output_thread.c | 46 ++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 2 deletions(-) diff --git a/include/fluent-bit/flb_output.h b/include/fluent-bit/flb_output.h index dd928450c99..bf93381b789 100644 --- a/include/fluent-bit/flb_output.h +++ b/include/fluent-bit/flb_output.h @@ -235,6 +235,9 @@ struct flb_output_plugin { int (*cb_worker_init) (void *, struct flb_config *); + /* Notification: this callback will be invoked anytime a notification is received*/ + int (*cb_notification) (struct flb_output_instance *, struct flb_config *, void *); + /* Tests */ struct flb_test_out_formatter test_formatter; @@ -448,6 +451,8 @@ struct flb_output_instance { struct mk_list flush_list; struct mk_list flush_list_destroy; + flb_pipefd_t notification_channel; + /* Keep a reference to the original context this instance belongs to */ struct flb_config *config; }; diff --git a/include/fluent-bit/flb_output_thread.h b/include/fluent-bit/flb_output_thread.h index 2bf4ca11d77..51cc20465fd 100644 --- a/include/fluent-bit/flb_output_thread.h +++ b/include/fluent-bit/flb_output_thread.h @@ -63,6 +63,9 @@ struct flb_out_thread_instance { struct flb_bucket_queue *evl_bktq; /* bucket queue for evl track event priority */ flb_pipefd_t ch_parent_events[2]; /* channel to receive parent notifications */ flb_pipefd_t ch_thread_events[2]; /* channel to send messages local event loop */ + int notification_channels_initialized; + flb_pipefd_t notification_channels[2]; + struct mk_event notification_event; struct flb_output_instance *ins; /* output plugin instance */ struct flb_config *config; struct flb_tp_thread *th; diff --git a/src/flb_output.c b/src/flb_output.c index 0c9a7cc1333..365708e10ea 100644 --- a/src/flb_output.c +++ b/src/flb_output.c @@ -279,7 +279,7 @@ int flb_output_task_singleplex_enqueue(struct flb_task_queue *queue, if (is_empty) { return flb_output_task_queue_flush_one(out_ins->singleplex_queue); } - + return 0; } @@ -300,7 +300,7 @@ int flb_output_task_singleplex_flush_next(struct flb_task_queue *queue) mk_list_del(&ended_task->_head); flb_free(ended_task); } - + /* Flush if there is a pending task queued */ is_empty = mk_list_is_empty(&queue->pending) == 0; if (!is_empty) { @@ -1311,6 +1311,8 @@ int flb_output_init_all(struct flb_config *config) return -1; } + ins->notification_channel = config->notification_channels[1]; + /* Multi-threading enabled if configured */ ret = flb_output_enable_multi_threading(ins, config); if (ret == -1) { @@ -1319,6 +1321,8 @@ int flb_output_init_all(struct flb_config *config) return -1; } + ins->processor->notification_channel = ins->notification_channel; + /* initialize processors */ ret = flb_processor_init(ins->processor); if (ret == -1) { diff --git a/src/flb_output_thread.c b/src/flb_output_thread.c index 4baa5181b30..330ff4feeec 100644 --- a/src/flb_output_thread.c +++ b/src/flb_output_thread.c @@ -25,6 +25,7 @@ #include #include #include +#include static pthread_once_t local_thread_instance_init = PTHREAD_ONCE_INIT; FLB_TLS_DEFINE(struct flb_out_thread_instance, local_thread_instance); @@ -182,6 +183,7 @@ static void output_thread(void *data) struct flb_out_thread_instance *th_ins = data; struct flb_out_flush_params *params; struct flb_net_dns dns_ctx; + struct flb_notification *notification; /* Register thread instance */ flb_output_thread_instance_set(th_ins); @@ -326,6 +328,15 @@ static void output_thread(void *data) */ handle_output_event(th_ins->config, ins->ch_events[1], event->fd); } + else if(event->type == FLB_ENGINE_EV_NOTIFICATION) { + ret = flb_notification_receive(event->fd, ¬ification); + + if (ret == 0) { + ret = flb_notification_deliver(notification); + + flb_notification_cleanup(notification); + } + } else { flb_plg_warn(ins, "unhandled event type => %i\n", event->type); } @@ -379,6 +390,15 @@ static void output_thread(void *data) th_ins->ch_parent_events[1], th_ins); + if (th_ins->notification_channels_initialized == FLB_TRUE) { + mk_event_channel_destroy(th_ins->evl, + th_ins->notification_channels[0], + th_ins->notification_channels[1], + &th_ins->notification_event); + + th_ins->notification_channels_initialized = FLB_FALSE; + } + mk_event_loop_destroy(th_ins->evl); flb_bucket_queue_destroy(th_ins->evl_bktq); @@ -499,6 +519,32 @@ int flb_output_thread_pool_create(struct flb_config *config, th_ins->event.type = FLB_ENGINE_EV_THREAD_OUTPUT; th_ins->event.priority = FLB_ENGINE_PRIORITY_THREAD; + if (i == 0) { + ret = mk_event_channel_create(th_ins->evl, + &th_ins->notification_channels[0], + &th_ins->notification_channels[1], + &th_ins->notification_event); + if (ret == -1) { + flb_plg_error(th_ins->ins, "could not create notification channel"); + + mk_event_channel_destroy(th_ins->evl, + th_ins->ch_parent_events[0], + th_ins->ch_parent_events[1], + th_ins); + + mk_event_loop_destroy(th_ins->evl); + flb_bucket_queue_destroy(th_ins->evl_bktq); + flb_free(th_ins); + + continue; + } + + th_ins->notification_channels_initialized = FLB_TRUE; + th_ins->notification_event.type = FLB_ENGINE_EV_NOTIFICATION; + + ins->notification_channel = th_ins->notification_channels[1]; + } + /* Spawn the thread */ th = flb_tp_thread_create(tp, output_thread, th_ins, config); if (!th) { From 82574c8020a9be15423db8d1b3f6d17f4b9fce70 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Sun, 22 Sep 2024 01:28:00 +0200 Subject: [PATCH 226/295] input: added plugin notification feature Signed-off-by: Leonardo Alminana --- include/fluent-bit/flb_input_thread.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/fluent-bit/flb_input_thread.h b/include/fluent-bit/flb_input_thread.h index abc16123106..4abfc1511ea 100644 --- a/include/fluent-bit/flb_input_thread.h +++ b/include/fluent-bit/flb_input_thread.h @@ -64,6 +64,9 @@ struct flb_input_thread_instance { struct mk_event_loop *evl; /* thread event loop context */ flb_pipefd_t ch_parent_events[2]; /* communication between parent and thread */ flb_pipefd_t ch_thread_events[2]; /* local messages in the thread event loop */ + int notification_channels_initialized; + flb_pipefd_t notification_channels[2]; + struct mk_event notification_event; struct flb_input_instance *ins; /* output plugin instance */ struct flb_tp *tp; struct flb_tp_thread *th; From 084bbd568f64c134283417d4f0bd2f4caadc1f3e Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Sun, 22 Sep 2024 01:28:31 +0200 Subject: [PATCH 227/295] processor: added plugin notification feature Signed-off-by: Leonardo Alminana --- include/fluent-bit/flb_processor.h | 7 +++++++ src/flb_processor.c | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/include/fluent-bit/flb_processor.h b/include/fluent-bit/flb_processor.h index c4abd7b43a0..bc7a9338371 100644 --- a/include/fluent-bit/flb_processor.h +++ b/include/fluent-bit/flb_processor.h @@ -119,6 +119,8 @@ struct flb_processor { void *data; int source_plugin_type; + flb_pipefd_t notification_channel; + /* Fluent Bit context */ struct flb_config *config; }; @@ -155,6 +157,9 @@ struct flb_processor_plugin { int (*cb_exit) (struct flb_processor_instance *, void *); + /* Notification: this callback will be invoked anytime a notification is received*/ + int (*cb_notification) (struct flb_processor_instance *, struct flb_config *, void *); + struct mk_list _head; /* Link to parent list (config->filters) */ }; @@ -179,6 +184,8 @@ struct flb_processor_instance { */ struct cmt *cmt; /* parent context */ + flb_pipefd_t notification_channel; + /* Keep a reference to the original context this instance belongs to */ struct flb_config *config; }; diff --git a/src/flb_processor.c b/src/flb_processor.c index a756940861a..00c892491f4 100644 --- a/src/flb_processor.c +++ b/src/flb_processor.c @@ -342,6 +342,9 @@ int flb_processor_unit_init(struct flb_processor_unit *pu) flb_error("[processor] error initializing unit filter %s", pu->name); return -1; } + + ((struct flb_filter_instance *) pu->ctx)->notification_channel = \ + proc->notification_channel; } else { ret = flb_processor_instance_init( @@ -356,6 +359,9 @@ int flb_processor_unit_init(struct flb_processor_unit *pu) return -1; } + + ((struct flb_processor_instance *) pu->ctx)->notification_channel = \ + proc->notification_channel; } return ret; From 637e11ff67762d423d35aae55b2645a927d7aa8c Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Sun, 22 Sep 2024 01:28:50 +0200 Subject: [PATCH 228/295] build: added plugin notification feature Signed-off-by: Leonardo Alminana --- src/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ea7403f7b6c..e24666484a7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -81,6 +81,7 @@ set(src flb_processor.c flb_reload.c flb_msgpack_append_message.c + flb_notification.c ) # Config format From 736b56084ae8999bc795a83352a06c1a174d611c Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Sun, 22 Sep 2024 01:29:09 +0200 Subject: [PATCH 229/295] engine: added plugin notification feature Signed-off-by: Leonardo Alminana --- src/flb_engine.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/flb_engine.c b/src/flb_engine.c index 960ecf41567..f8faab8a3bf 100644 --- a/src/flb_engine.c +++ b/src/flb_engine.c @@ -692,6 +692,7 @@ int flb_engine_start(struct flb_config *config) struct flb_bucket_queue *evl_bktq; struct flb_sched *sched; struct flb_net_dns dns_ctx; + struct flb_notification *notification; /* Initialize the networking layer */ flb_net_lib_init(); @@ -771,6 +772,19 @@ int flb_engine_start(struct flb_config *config) return -1; } + ret = mk_event_channel_create(config->evl, + &config->notification_channels[0], + &config->notification_channels[1], + &config->notification_event); + if (ret == -1) { + flb_error("could not create main notification channel"); + + return -1; + } + + config->notification_channels_initialized = FLB_TRUE; + config->notification_event.type = FLB_ENGINE_EV_NOTIFICATION; + /* Initialize custom plugins */ ret = flb_custom_init_all(config); if (ret == -1) { @@ -1072,6 +1086,15 @@ int flb_engine_start(struct flb_config *config) rb_flush_flag = FLB_TRUE; } + else if(event->type == FLB_ENGINE_EV_NOTIFICATION) { + ret = flb_notification_receive(event->fd, ¬ification); + + if (ret == 0) { + ret = flb_notification_deliver(notification); + + flb_notification_cleanup(notification); + } + } } if (rb_flush_flag) { @@ -1142,6 +1165,15 @@ int flb_engine_shutdown(struct flb_config *config) &config->event_thread_init); } + if (config->notification_channels_initialized == FLB_TRUE) { + mk_event_channel_destroy(config->evl, + config->notification_channels[0], + config->notification_channels[1], + &config->notification_event); + + config->notification_channels_initialized = FLB_FALSE; + } + return 0; } From a164999f9f99aeb3529acdbb5c1f061985bdeea6 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Sun, 22 Sep 2024 01:29:40 +0200 Subject: [PATCH 230/295] input_blob: added delivery notification structure and cleanup function Signed-off-by: Leonardo Alminana --- include/fluent-bit/flb_input_blob.h | 10 ++++++++++ src/flb_input_blob.c | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/fluent-bit/flb_input_blob.h b/include/fluent-bit/flb_input_blob.h index 0691b8f29aa..4d66ab1d624 100644 --- a/include/fluent-bit/flb_input_blob.h +++ b/include/fluent-bit/flb_input_blob.h @@ -22,12 +22,22 @@ #include #include +#include #include +struct flb_blob_delivery_notification { + struct flb_notification base; + cfl_sds_t path; + int success; +}; + + struct flb_blob_file { cfl_sds_t path; }; +void flb_input_blob_delivery_notification_destroy(void *instance); + int flb_input_blob_file_get_info(msgpack_object map, cfl_sds_t *source, cfl_sds_t *file_path, size_t *size); int flb_input_blob_file_register(struct flb_input_instance *ins, diff --git a/src/flb_input_blob.c b/src/flb_input_blob.c index f0958c215d0..2e74e07fe40 100644 --- a/src/flb_input_blob.c +++ b/src/flb_input_blob.c @@ -215,3 +215,14 @@ int flb_input_blob_file_register(struct flb_input_instance *ins, flb_log_event_encoder_reset(encoder); return ret; } + +void flb_input_blob_delivery_notification_destroy(void *instance) +{ + struct flb_blob_delivery_notification *local_instance; + + local_instance = (struct flb_blob_delivery_notification *) instance; + + if (local_instance->path != NULL) { + cfl_sds_destroy(local_instance->path); + } +} From 65152a125b4834e91a91a40cfd9c9eba35255b88 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Sun, 22 Sep 2024 01:30:00 +0200 Subject: [PATCH 231/295] in_blob: added notification handler Signed-off-by: Leonardo Alminana --- plugins/in_blob/blob.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/plugins/in_blob/blob.c b/plugins/in_blob/blob.c index 895d08c4f29..967a0bfa6fc 100644 --- a/plugins/in_blob/blob.c +++ b/plugins/in_blob/blob.c @@ -402,7 +402,7 @@ static int cb_scan_path(struct flb_input_instance *ins, ctx = (struct blob_ctx *) in_context; - flb_plg_info(ctx->ins, "scanning path %s", ctx->path); + flb_plg_debug(ctx->ins, "scanning path %s", ctx->path); result = recursive_file_search(ctx, NULL, ctx->path); @@ -519,14 +519,25 @@ static struct flb_config_map config_map[] = { {0} }; +static int in_blob_notification(struct flb_input_instance *in_context, + struct flb_config *config, + void *notification) +{ + printf("INPUT PLUGIN : NOTIFICATION RECEIVED %p\n", notification); + return 0; +} + + + /* Plugin reference */ struct flb_input_plugin in_blob_plugin = { - .name = "blob", - .description = "Blob (binary) files", - .cb_init = in_blob_init, - .cb_pre_run = NULL, - .cb_collect = NULL, - .cb_flush_buf = NULL, - .cb_exit = in_blob_exit, - .config_map = config_map + .name = "blob", + .description = "Blob (binary) files", + .cb_init = in_blob_init, + .cb_pre_run = NULL, + .cb_collect = NULL, + .cb_flush_buf = NULL, + .cb_exit = in_blob_exit, + .cb_notification = in_blob_notification, + .config_map = config_map }; From 7b5c5dfd3bd5cd8a8b6c109d3bb9c5e5918e950a Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Sun, 22 Sep 2024 01:30:28 +0200 Subject: [PATCH 232/295] out_azure_blob: added delivery notification feature Signed-off-by: Leonardo Alminana --- plugins/out_azure_blob/azure_blob.c | 54 +++++++++++++++++++++++++- plugins/out_azure_blob/azure_blob_db.c | 14 ++++++- plugins/out_azure_blob/azure_blob_db.h | 4 +- 3 files changed, 68 insertions(+), 4 deletions(-) diff --git a/plugins/out_azure_blob/azure_blob.c b/plugins/out_azure_blob/azure_blob.c index 7817b11a3a0..435e620fff4 100644 --- a/plugins/out_azure_blob/azure_blob.c +++ b/plugins/out_azure_blob/azure_blob.c @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include @@ -709,6 +711,7 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context cfl_sds_t source = NULL; struct flb_azure_blob *ctx = out_context; struct worker_info *info; + struct flb_blob_delivery_notification *notification; info = FLB_TLS_GET(worker_info); if (info->active_upload) { @@ -747,9 +750,12 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context cfl_sds_destroy(file_path); cfl_sds_destroy(source); + + file_path = NULL; + source = NULL; } - ret = azb_db_file_oldest_ready(ctx, &file_id, &file_path, &part_ids); + ret = azb_db_file_oldest_ready(ctx, &file_id, &file_path, &part_ids, &source); if (ret == 0) { flb_plg_trace(ctx->ins, "no blob files ready to commit"); } @@ -764,12 +770,55 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context flb_plg_error(ctx->ins, "cannot commit blob file parts for file id=%" PRIu64 " path=%s", file_id, file_path); + notification = flb_calloc(1, + sizeof( + struct flb_blob_delivery_notification)); + + if (notification != NULL) { + notification->base.dynamically_allocated = FLB_TRUE; + notification->base.destructor = flb_input_blob_delivery_notification_destroy; + notification->success = FLB_TRUE; + notification->path = cfl_sds_create(file_path); + + ret = flb_notification_enqueue(FLB_PLUGIN_INPUT, + source, + ¬ification->base, + config); + + if (ret != 0) { + flb_plg_error(ctx->ins, + "blob file '%s' (id=%" PRIu64 ") notification " \ + "delivery error %d", file_path, file_id, ret); + } + } } else { flb_plg_info(ctx->ins, "blob file '%s' (id=%" PRIu64 ") committed successfully", file_path, file_id); /* notify the engine the blob file has been processed */ /* FIXME! */ + notification = flb_calloc(1, + sizeof( + struct flb_blob_delivery_notification)); + + if (notification != NULL) { + notification->base.dynamically_allocated = FLB_TRUE; + notification->base.destructor = flb_input_blob_delivery_notification_destroy; + notification->success = FLB_FALSE; + notification->path = cfl_sds_create(file_path); + + ret = flb_notification_enqueue(FLB_PLUGIN_INPUT, + source, + ¬ification->base, + config); + + if (ret != 0) { + flb_plg_error(ctx->ins, + "blob file '%s' (id=%" PRIu64 ") notification " \ + "delivery error %d", file_path, file_id, ret); + } + } + /* remove the file entry from the database */ ret = azb_db_file_delete(ctx, file_id, file_path); if (ret == -1) { @@ -786,6 +835,9 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context if (part_ids) { cfl_sds_destroy(part_ids); } + if (source) { + cfl_sds_destroy(source); + } /* check for a next part file and lock it */ ret = azb_db_file_part_get_next(ctx, &id, &file_id, &part_id, diff --git a/plugins/out_azure_blob/azure_blob_db.c b/plugins/out_azure_blob/azure_blob_db.c index b218a3b9dfc..586df720744 100644 --- a/plugins/out_azure_blob/azure_blob_db.c +++ b/plugins/out_azure_blob/azure_blob_db.c @@ -693,7 +693,7 @@ int azb_db_file_part_delivery_attempts(struct flb_azure_blob *ctx, } int azb_db_file_oldest_ready(struct flb_azure_blob *ctx, - uint64_t *file_id, cfl_sds_t *path, cfl_sds_t *part_ids) + uint64_t *file_id, cfl_sds_t *path, cfl_sds_t *part_ids, cfl_sds_t *source) { int ret; char *tmp = NULL; @@ -726,6 +726,18 @@ int azb_db_file_oldest_ready(struct flb_azure_blob *ctx, azb_db_unlock(ctx); return -1; } + + /* source */ + tmp = (char *) sqlite3_column_text(ctx->stmt_get_oldest_file_with_parts, 3); + *source = cfl_sds_create(tmp); + if (!*part_ids) { + cfl_sds_destroy(*part_ids); + cfl_sds_destroy(*path); + sqlite3_clear_bindings(ctx->stmt_get_oldest_file_with_parts); + sqlite3_reset(ctx->stmt_get_oldest_file_with_parts); + azb_db_unlock(ctx); + return -1; + } } else if (ret == SQLITE_DONE) { /* no records */ diff --git a/plugins/out_azure_blob/azure_blob_db.h b/plugins/out_azure_blob/azure_blob_db.h index 1009d08733c..0cd682f1b33 100644 --- a/plugins/out_azure_blob/azure_blob_db.h +++ b/plugins/out_azure_blob/azure_blob_db.h @@ -127,7 +127,7 @@ * this query is used to compose */ #define SQL_GET_OLDEST_FILE_WITH_PARTS_CONCAT \ - "SELECT f.id, f.path, GROUP_CONCAT(p.part_id ORDER BY p.part_id ASC) AS part_ids " \ + "SELECT f.id, f.path, GROUP_CONCAT(p.part_id ORDER BY p.part_id ASC) AS part_ids, f.source " \ "FROM out_azure_blob_files f " \ "JOIN out_azure_blob_parts p ON f.id = p.file_id " \ "WHERE p.uploaded = 1 " \ @@ -168,5 +168,5 @@ int azb_db_file_part_uploaded(struct flb_azure_blob *ctx, uint64_t id); int azb_db_file_part_delivery_attempts(struct flb_azure_blob *ctx, uint64_t id, uint64_t attempts); int azb_db_file_oldest_ready(struct flb_azure_blob *ctx, - uint64_t *file_id, cfl_sds_t *path, cfl_sds_t *part_ids); + uint64_t *file_id, cfl_sds_t *path, cfl_sds_t *part_ids, cfl_sds_t *source); #endif \ No newline at end of file From d22b6c23fe1f7cfbb2e60b6a8a6748418507d621 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Sun, 22 Sep 2024 01:30:55 +0200 Subject: [PATCH 233/295] notification: initial commit of the notification feature Signed-off-by: Leonardo Alminana --- include/fluent-bit/flb_notification.h | 49 ++++ src/flb_notification.c | 381 ++++++++++++++++++++++++++ 2 files changed, 430 insertions(+) create mode 100644 include/fluent-bit/flb_notification.h create mode 100644 src/flb_notification.c diff --git a/include/fluent-bit/flb_notification.h b/include/fluent-bit/flb_notification.h new file mode 100644 index 00000000000..539a557199c --- /dev/null +++ b/include/fluent-bit/flb_notification.h @@ -0,0 +1,49 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* Fluent Bit + * ========== + * Copyright (C) 2015-2024 The Fluent Bit Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FLB_NOTIFICATION_H +#define FLB_NOTIFICATION_H + +#include +#include +#include +#include +#include + +struct flb_notification { + int plugin_type; + void *plugin_instance; + int dynamically_allocated; + + void (*destructor)(void *); +}; + +int flb_notification_enqueue(int plugin_type, + char *instance_name, + struct flb_notification *notification, + struct flb_config *config); + +int flb_notification_receive(flb_pipefd_t channel, + struct flb_notification **notification); + +int flb_notification_deliver(struct flb_notification *notification); + +void flb_notification_cleanup(struct flb_notification *notification); + +#endif diff --git a/src/flb_notification.c b/src/flb_notification.c new file mode 100644 index 00000000000..4d546dea9b1 --- /dev/null +++ b/src/flb_notification.c @@ -0,0 +1,381 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* Fluent Bit + * ========== + * Copyright (C) 2015-2024 The Fluent Bit Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +union generic_plugin_instance { + struct flb_input_instance *input; + struct flb_output_instance *output; + struct flb_filter_instance *filter; + struct flb_processor_instance *processor; + void *generic; +}; + +static struct flb_input_instance *find_input_instance( + char *name, + struct flb_config *config) +{ + struct mk_list *iterator; + struct flb_input_instance *instance; + + mk_list_foreach(iterator, &config->inputs) { + instance = mk_list_entry(iterator, + struct flb_input_instance, + _head); + + if (strcmp(flb_input_name(instance), name) == 0) { + return instance; + } + } + + return NULL; +} + +static struct flb_output_instance *find_output_instance( + char *name, + struct flb_config *config) +{ + struct mk_list *iterator; + struct flb_output_instance *instance; + + mk_list_foreach(iterator, &config->outputs) { + instance = mk_list_entry(iterator, + struct flb_output_instance, + _head); + + if (strcmp(flb_output_name(instance), name) == 0) { + return instance; + } + } + + return NULL; +} + +static struct flb_filter_instance *find_filter_instance( + char *name, + struct flb_config *config) +{ + struct mk_list *iterator; + struct flb_filter_instance *instance; + + mk_list_foreach(iterator, &config->filters) { + instance = mk_list_entry(iterator, + struct flb_filter_instance, + _head); + + if (strcmp(flb_filter_name(instance), name) == 0) { + return instance; + } + } + + return NULL; +} + +static void *find_processor_instance_internal_unit_level( + char *name, + int *plugin_type, + struct mk_list *processor_unit_list) +{ + struct mk_list *iterator; + struct flb_processor_unit *processor_unit; + struct flb_filter_instance *filter_instance; + struct flb_processor_instance *processor_instance; + + mk_list_foreach(iterator, processor_unit_list) { + processor_unit = mk_list_entry(iterator, + struct flb_processor_unit, + _head); + + if (processor_unit->unit_type == FLB_PROCESSOR_UNIT_FILTER) { + filter_instance = (struct flb_filter_instance *) \ + processor_unit->ctx; + + if (strcmp(flb_filter_name(filter_instance), name) == 0) { + *plugin_type = FLB_PLUGIN_FILTER; + + return (void *) filter_instance; + } + } + else if (processor_unit->unit_type == FLB_PROCESSOR_UNIT_NATIVE) { + processor_instance = (struct flb_processor_instance *) \ + processor_unit->ctx; + + if (strcmp(flb_processor_instance_get_name(processor_instance), + name) == 0) { + *plugin_type = FLB_PLUGIN_PROCESSOR; + + return (void *) processor_instance; + } + } + } + + return NULL; +} + + +static void *find_processor_instance_internal_processor_level( + char *name, + int *plugin_type, + struct flb_processor *processor) +{ + void *result; + + result = find_processor_instance_internal_unit_level( + name, + plugin_type, + &processor->logs); + + if (result == NULL) { + result = find_processor_instance_internal_unit_level( + name, + plugin_type, + &processor->metrics); + } + + if (result == NULL) { + result = find_processor_instance_internal_unit_level( + name, + plugin_type, + &processor->traces); + } + + return result; +} + +static void *find_processor_instance( + char *name, + int *plugin_type, + struct flb_config *config) +{ + struct flb_output_instance *output_instance; + struct flb_input_instance *input_instance; + struct mk_list *iterator; + void *result; + + mk_list_foreach(iterator, &config->inputs) { + input_instance = mk_list_entry(iterator, + struct flb_input_instance, + _head); + + result = find_processor_instance_internal_processor_level( + name, + plugin_type, + input_instance->processor); + + if (result != NULL) { + return result; + } + } + + mk_list_foreach(iterator, &config->outputs) { + output_instance = mk_list_entry(iterator, + struct flb_output_instance, + _head); + + result = find_processor_instance_internal_processor_level( + name, + plugin_type, + output_instance->processor); + + if (result != NULL) { + return result; + } + } + + return NULL; +} + +int flb_notification_enqueue(int plugin_type, + char *instance_name, + struct flb_notification *notification, + struct flb_config *config) +{ + flb_pipefd_t notification_channel; + union generic_plugin_instance plugin_instance; + int result; + + plugin_instance.generic = NULL; + + if (plugin_instance.generic == NULL && + (plugin_type == FLB_PLUGIN_INPUT || + plugin_type == -1)) { + plugin_instance.input = find_input_instance(instance_name, config); + notification_channel = plugin_instance.input->notification_channel; + plugin_type = FLB_PLUGIN_INPUT; + } + + if (plugin_instance.generic == NULL && + (plugin_type == FLB_PLUGIN_OUTPUT || + plugin_type == -1)) { + plugin_instance.output = find_output_instance(instance_name, config); + notification_channel = plugin_instance.output->notification_channel; + plugin_type = FLB_PLUGIN_OUTPUT; + } + + if (plugin_instance.generic == NULL && + (plugin_type == FLB_PLUGIN_FILTER || + plugin_type == -1)) { + plugin_instance.filter = find_filter_instance(instance_name, config); + notification_channel = plugin_instance.filter->notification_channel; + plugin_type = FLB_PLUGIN_FILTER; + } + + if (plugin_instance.generic == NULL && + (plugin_type == FLB_PLUGIN_FILTER || + plugin_type == -1)) { + plugin_instance.generic = find_processor_instance(instance_name, + &plugin_type, + config); + + if (plugin_instance.generic != NULL) { + if (plugin_type == FLB_PLUGIN_FILTER) { + notification_channel = plugin_instance.filter->notification_channel; + } + else if (plugin_type == FLB_PLUGIN_PROCESSOR) { + notification_channel = plugin_instance.processor->notification_channel; + } + } + } + + if (plugin_instance.generic == NULL) { + flb_error("cannot enqueue notification for plugin \"%s\" with type %d", + instance_name, plugin_type); + + return -1; + } + + notification->plugin_type = plugin_type; + notification->plugin_instance = plugin_instance.generic; + + result = flb_pipe_w(notification_channel, + ¬ification, + sizeof(void *)); + + if (result == -1) { + flb_errno(); + + return -1; + } + + return 0; +} + +int flb_notification_receive(flb_pipefd_t channel, + struct flb_notification **notification) +{ + int result; + + result = flb_pipe_r(channel, notification, sizeof(struct flb_notification *)); + + if (result <= 0) { + flb_errno(); + return -1;; + } + + return 0; +} + +int flb_notification_deliver(struct flb_notification *notification) +{ + int result; + union generic_plugin_instance instance; + + if (notification == NULL) { + flb_error("cannot deliver NULL notification instance"); + + return -1; + } + + instance.generic = notification->plugin_instance; + result = -2; + + switch(notification->plugin_type) { + case FLB_PLUGIN_INPUT: + if (instance.input->p->cb_notification != NULL) { + result = instance.input->p->cb_notification( + instance.input, + instance.input->config, + (void *) notification); + } + else { + result = -3; + } + + break; + + case FLB_PLUGIN_OUTPUT: + if (instance.output->p->cb_notification != NULL) { + result = instance.output->p->cb_notification( + instance.output, + instance.output->config, + (void *) notification); + } + else { + result = -3; + } + + break; + + case FLB_PLUGIN_FILTER: + if (instance.filter->p->cb_notification != NULL) { + result = instance.filter->p->cb_notification( + instance.filter, + instance.filter->config, + (void *) notification); + } + else { + result = -3; + } + + break; + + case FLB_PLUGIN_PROCESSOR: + if (instance.processor->p->cb_notification != NULL) { + result = instance.processor->p->cb_notification( + instance.processor, + instance.processor->config, + (void *) notification); + } + else { + result = -3; + } + + break; + } + + return result; +} + +void flb_notification_cleanup(struct flb_notification *notification) +{ + if (notification->destructor != NULL) { + notification->destructor((void *) notification); + } + + if (notification->dynamically_allocated == FLB_TRUE) { + flb_free(notification); + } +} From 31a6dc7e060a784dd1cd80d151cec3c1d6caa497 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Sun, 22 Sep 2024 18:08:10 +0200 Subject: [PATCH 234/295] notification: added notification type field and global list Also fixed the context pointer provided by the notification callback Signed-off-by: Leonardo Alminana --- include/fluent-bit/flb_notification.h | 5 +++++ src/flb_notification.c | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/fluent-bit/flb_notification.h b/include/fluent-bit/flb_notification.h index 539a557199c..e634c2d30a9 100644 --- a/include/fluent-bit/flb_notification.h +++ b/include/fluent-bit/flb_notification.h @@ -26,9 +26,14 @@ #include #include + +#define FLB_NOTIFICATION_TYPE_BLOB_DELIVERY 1 + + struct flb_notification { int plugin_type; void *plugin_instance; + int notification_type; int dynamically_allocated; void (*destructor)(void *); diff --git a/src/flb_notification.c b/src/flb_notification.c index 4d546dea9b1..b6e575c4974 100644 --- a/src/flb_notification.c +++ b/src/flb_notification.c @@ -316,7 +316,7 @@ int flb_notification_deliver(struct flb_notification *notification) case FLB_PLUGIN_INPUT: if (instance.input->p->cb_notification != NULL) { result = instance.input->p->cb_notification( - instance.input, + instance.input->context, instance.input->config, (void *) notification); } @@ -329,7 +329,7 @@ int flb_notification_deliver(struct flb_notification *notification) case FLB_PLUGIN_OUTPUT: if (instance.output->p->cb_notification != NULL) { result = instance.output->p->cb_notification( - instance.output, + instance.output->context, instance.output->config, (void *) notification); } @@ -342,7 +342,7 @@ int flb_notification_deliver(struct flb_notification *notification) case FLB_PLUGIN_FILTER: if (instance.filter->p->cb_notification != NULL) { result = instance.filter->p->cb_notification( - instance.filter, + instance.filter->context, instance.filter->config, (void *) notification); } @@ -355,7 +355,7 @@ int flb_notification_deliver(struct flb_notification *notification) case FLB_PLUGIN_PROCESSOR: if (instance.processor->p->cb_notification != NULL) { result = instance.processor->p->cb_notification( - instance.processor, + instance.processor->context, instance.processor->config, (void *) notification); } From 6d52c66a27c96884b84e66d40b9859d02db8fb8b Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Sun, 22 Sep 2024 18:08:37 +0200 Subject: [PATCH 235/295] in_blob: added file upload result notification handling Signed-off-by: Leonardo Alminana --- plugins/in_blob/blob.c | 331 +++++++++++++++++++++++++++++++++++++++-- plugins/in_blob/blob.h | 15 ++ 2 files changed, 336 insertions(+), 10 deletions(-) diff --git a/plugins/in_blob/blob.c b/plugins/in_blob/blob.c index 967a0bfa6fc..d9d50ffa547 100644 --- a/plugins/in_blob/blob.c +++ b/plugins/in_blob/blob.c @@ -23,11 +23,14 @@ #include #include #include +#include +#include #include #include #include #include +#include #include "blob.h" #include "blob_db.h" @@ -457,6 +460,68 @@ static int in_blob_init(struct flb_input_instance *ins, } #endif + ctx->upload_success_action = POST_UPLOAD_ACTION_NONE; + + if (ctx->upload_success_action_str != NULL) { + if (strcasecmp(ctx->upload_success_action_str, + "delete") == 0) { + ctx->upload_success_action = POST_UPLOAD_ACTION_DELETE; + } + else if (strcasecmp(ctx->upload_success_action_str, + "emit_log") == 0) { + ctx->upload_success_action = POST_UPLOAD_ACTION_EMIT_LOG; + } + else if (strcasecmp(ctx->upload_success_action_str, + "add_suffix") == 0) { + if (ctx->upload_success_suffix == NULL) { + flb_plg_error(ins, + "'upload_success_suffix' configuration " \ + "property is not set"); +#ifdef FLB_HAVE_SQLDB + if (ctx->db != NULL) { + blob_db_close(ctx); + ctx->db = NULL; + } +#endif + flb_free(ctx); + + return -1; + } + ctx->upload_success_action = POST_UPLOAD_ACTION_ADD_SUFFIX; + } + } + + ctx->upload_failure_action = POST_UPLOAD_ACTION_NONE; + + if (ctx->upload_failure_action_str != NULL) { + if (strcasecmp(ctx->upload_failure_action_str, + "delete") == 0) { + ctx->upload_failure_action = POST_UPLOAD_ACTION_DELETE; + } + else if (strcasecmp(ctx->upload_failure_action_str, + "emit_log") == 0) { + ctx->upload_failure_action = POST_UPLOAD_ACTION_EMIT_LOG; + } + else if (strcasecmp(ctx->upload_failure_action_str, + "add_suffix") == 0) { + if (ctx->upload_failure_suffix == NULL) { + flb_plg_error(ins, + "'upload_failure_suffix' configuration " \ + "property is not set"); +#ifdef FLB_HAVE_SQLDB + if (ctx->db != NULL) { + blob_db_close(ctx); + ctx->db = NULL; + } +#endif + flb_free(ctx); + + return -1; + } + ctx->upload_failure_action = POST_UPLOAD_ACTION_ADD_SUFFIX; + } + } + /* create a collector to scan the path of files */ ret = flb_input_set_collector_time(ins, cb_scan_path, @@ -495,6 +560,232 @@ static int in_blob_exit(void *in_context, struct flb_config *config) return 0; } + +static int in_blob_notification(struct flb_input_instance *in_context, + struct flb_config *config, + void *untyped_notification) +{ + struct flb_blob_delivery_notification *notification; + cfl_sds_t new_filename; + cfl_sds_t sds_result; + struct blob_ctx *context; + int result; + + context = (struct blob_ctx *) in_context; + + notification = (struct flb_blob_delivery_notification *) untyped_notification; + + if (notification->base.notification_type != + FLB_NOTIFICATION_TYPE_BLOB_DELIVERY) { + flb_plg_error(context->ins, + "unexpected notification type received : %d", + notification->base.notification_type); + + return -1; + } + + if (notification->success == FLB_TRUE) { + switch (context->upload_success_action) { + case POST_UPLOAD_ACTION_DELETE: + result = unlink(notification->path); + + if (result == -1) { + flb_errno(); + + flb_plg_error(context->ins, + "successfully uploaded file \"%s\" could not be deleted", + notification->path); + } + + break; + + case POST_UPLOAD_ACTION_EMIT_LOG: + flb_log_event_encoder_begin_record(context->log_encoder); + + flb_log_event_encoder_set_current_timestamp(context->log_encoder); + + result = flb_log_event_encoder_append_metadata_values( + context->log_encoder, + FLB_LOG_EVENT_CSTRING_VALUE("path"), + FLB_LOG_EVENT_CSTRING_VALUE(notification->path)); + + if (result != FLB_EVENT_ENCODER_SUCCESS) { + flb_log_event_encoder_rollback_record(context->log_encoder); + + break; + } + + result = flb_log_event_encoder_append_body_values( + context->log_encoder, + FLB_LOG_EVENT_CSTRING_VALUE("message"), + FLB_LOG_EVENT_CSTRING_VALUE(context->upload_success_message)); + + if (result != FLB_EVENT_ENCODER_SUCCESS) { + flb_log_event_encoder_rollback_record(context->log_encoder); + + break; + } + + result = flb_log_event_encoder_commit_record(context->log_encoder); + + if (result != FLB_EVENT_ENCODER_SUCCESS) { + flb_log_event_encoder_rollback_record(context->log_encoder); + + break; + } + + flb_input_log_append(context->ins, NULL, 0, + context->log_encoder->output_buffer, + context->log_encoder->output_length); + + flb_log_event_encoder_reset_record(context->log_encoder); + + break; + + case POST_UPLOAD_ACTION_ADD_SUFFIX: + new_filename = cfl_sds_create(notification->path); + + if (new_filename == NULL) { + flb_plg_error(context->ins, + "successfully uploaded file \"%s\" could not be renamed " \ + "(new filename buffer allocation error)", + notification->path); + + break; + } + + sds_result = cfl_sds_cat(new_filename, + context->upload_success_suffix, + strlen(context->upload_success_suffix)); + + if (sds_result == NULL) { + flb_plg_error(context->ins, + "successfully uploaded file \"%s\" could not be renamed " \ + "(filename suffix concatentation error)", + notification->path); + + break; + } + + new_filename = sds_result; + + result = rename(notification->path, new_filename); + + if (result == -1) { + flb_errno(); + + flb_plg_error(context->ins, + "successfully uploaded file \"%s\" could not be renamed " \ + "(rename operation error)", + notification->path); + } + + break; + } + } + else if (notification->success == FLB_FALSE) { + switch (context->upload_failure_action) { + case POST_UPLOAD_ACTION_DELETE: + result = unlink(notification->path); + + if (result == -1) { + flb_errno(); + + flb_plg_error(context->ins, + "failed to upload file \"%s\" could not be deleted", + notification->path); + } + + break; + + case POST_UPLOAD_ACTION_EMIT_LOG: + flb_log_event_encoder_begin_record(context->log_encoder); + + flb_log_event_encoder_set_current_timestamp(context->log_encoder); + + result = flb_log_event_encoder_append_metadata_values( + context->log_encoder, + FLB_LOG_EVENT_CSTRING_VALUE("path"), + FLB_LOG_EVENT_CSTRING_VALUE(notification->path)); + + if (result != FLB_EVENT_ENCODER_SUCCESS) { + flb_log_event_encoder_rollback_record(context->log_encoder); + + break; + } + + result = flb_log_event_encoder_append_body_values( + context->log_encoder, + FLB_LOG_EVENT_CSTRING_VALUE("message"), + FLB_LOG_EVENT_CSTRING_VALUE(context->upload_failure_message)); + + if (result != FLB_EVENT_ENCODER_SUCCESS) { + flb_log_event_encoder_rollback_record(context->log_encoder); + + break; + } + + result = flb_log_event_encoder_commit_record(context->log_encoder); + + if (result != FLB_EVENT_ENCODER_SUCCESS) { + flb_log_event_encoder_rollback_record(context->log_encoder); + + break; + } + + flb_input_log_append(context->ins, NULL, 0, + context->log_encoder->output_buffer, + context->log_encoder->output_length); + + flb_log_event_encoder_reset_record(context->log_encoder); + + break; + + case POST_UPLOAD_ACTION_ADD_SUFFIX: + new_filename = cfl_sds_create(notification->path); + + if (new_filename == NULL) { + flb_plg_error(context->ins, + "failed to upload file \"%s\" could not be renamed " \ + "(new filename buffer allocation error)", + notification->path); + + break; + } + + sds_result = cfl_sds_cat(new_filename, + context->upload_failure_suffix, + strlen(context->upload_failure_suffix)); + + if (sds_result == NULL) { + flb_plg_error(context->ins, + "failed to upload file \"%s\" could not be renamed " \ + "(filename suffix concatentation error)", + notification->path); + + break; + } + + new_filename = sds_result; + + result = rename(notification->path, new_filename); + + if (result == -1) { + flb_errno(); + + flb_plg_error(context->ins, + "failed to upload file \"%s\" could not be renamed " \ + "(rename operation error)", + notification->path); + } + + break; + } + } + + return 0; +} + static struct flb_config_map config_map[] = { { FLB_CONFIG_MAP_STR, "path", NULL, @@ -515,19 +806,39 @@ static struct flb_config_map config_map[] = { "Set the interval time to scan for new files" }, - /* EOF */ - {0} -}; + { + FLB_CONFIG_MAP_STR, "upload_success_action", NULL, + 0, FLB_TRUE, offsetof(struct blob_ctx, upload_success_action_str), + }, -static int in_blob_notification(struct flb_input_instance *in_context, - struct flb_config *config, - void *notification) -{ - printf("INPUT PLUGIN : NOTIFICATION RECEIVED %p\n", notification); - return 0; -} + { + FLB_CONFIG_MAP_STR, "upload_success_suffix", NULL, + 0, FLB_TRUE, offsetof(struct blob_ctx, upload_success_suffix), + }, + + { + FLB_CONFIG_MAP_STR, "upload_success_message", NULL, + 0, FLB_TRUE, offsetof(struct blob_ctx, upload_success_message), + }, + + { + FLB_CONFIG_MAP_STR, "upload_failure_action", NULL, + 0, FLB_TRUE, offsetof(struct blob_ctx, upload_failure_action_str), + }, + { + FLB_CONFIG_MAP_STR, "upload_failure_suffix", NULL, + 0, FLB_TRUE, offsetof(struct blob_ctx, upload_failure_suffix), + }, + { + FLB_CONFIG_MAP_STR, "upload_failure_message", NULL, + 0, FLB_TRUE, offsetof(struct blob_ctx, upload_failure_message), + }, + + /* EOF */ + {0} +}; /* Plugin reference */ struct flb_input_plugin in_blob_plugin = { diff --git a/plugins/in_blob/blob.h b/plugins/in_blob/blob.h index 13b932e5d5e..adedce21d79 100644 --- a/plugins/in_blob/blob.h +++ b/plugins/in_blob/blob.h @@ -25,6 +25,11 @@ #include #include +#define POST_UPLOAD_ACTION_NONE 0 +#define POST_UPLOAD_ACTION_DELETE 1 +#define POST_UPLOAD_ACTION_EMIT_LOG 2 +#define POST_UPLOAD_ACTION_ADD_SUFFIX 3 + struct blob_file { /* database reference (id) */ uint64_t db_id; @@ -70,6 +75,16 @@ struct blob_ctx { flb_sds_t path; flb_sds_t database_file; time_t scan_refresh_interval; + + int upload_success_action; + flb_sds_t upload_success_action_str; + flb_sds_t upload_success_suffix; + flb_sds_t upload_success_message; + + int upload_failure_action; + flb_sds_t upload_failure_action_str; + flb_sds_t upload_failure_suffix; + flb_sds_t upload_failure_message; }; #endif From 94f1e6df3ee88d74c031f4d7e5d231b6e9fd3aef Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Sun, 22 Sep 2024 18:09:01 +0200 Subject: [PATCH 236/295] input_blob: fixed erroneous file size unpacking Signed-off-by: Leonardo Alminana --- src/flb_input_blob.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/flb_input_blob.c b/src/flb_input_blob.c index 2e74e07fe40..b4a5f8b654c 100644 --- a/src/flb_input_blob.c +++ b/src/flb_input_blob.c @@ -33,6 +33,7 @@ int flb_input_blob_file_get_info(msgpack_object map, cfl_sds_t *source, cfl_sds_ cfl_sds_t tmp_source; cfl_sds_t tmp_file_path; msgpack_object o; + size_t tmp_size; if (map.type != MSGPACK_OBJECT_MAP) { return -1; @@ -78,6 +79,8 @@ int flb_input_blob_file_get_info(msgpack_object map, cfl_sds_t *source, cfl_sds_ return -1; } + tmp_size = o.via.u64; + /* get source plugin */ o = map.via.map.ptr[2].key; if (o.type != MSGPACK_OBJECT_STR) { @@ -101,7 +104,7 @@ int flb_input_blob_file_get_info(msgpack_object map, cfl_sds_t *source, cfl_sds_ return -1; } - *size = o.via.u64; + *size = tmp_size; *file_path = tmp_file_path; *source = tmp_source; From d51c87d48453cfcce613ac24c7af65393ea49670 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Sun, 22 Sep 2024 18:09:46 +0200 Subject: [PATCH 237/295] out_azure_blob: fixed stored erroneous procedure references and code Signed-off-by: Leonardo Alminana --- plugins/out_azure_blob/azure_blob_db.c | 6 +++--- plugins/out_azure_blob/azure_blob_db.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/out_azure_blob/azure_blob_db.c b/plugins/out_azure_blob/azure_blob_db.c index 586df720744..2a7fd68ad7f 100644 --- a/plugins/out_azure_blob/azure_blob_db.c +++ b/plugins/out_azure_blob/azure_blob_db.c @@ -433,9 +433,9 @@ int azb_db_file_get_next_aborted(struct flb_azure_blob *ctx, /* id: column 0 */ *id = sqlite3_column_int64(ctx->stmt_get_next_aborted_file, 0); - *delivery_attempts = sqlite3_column_int64(ctx->stmt_get_next_file_part, 1); - tmp_source = (char *) sqlite3_column_text(ctx->stmt_get_next_file_part, 2); - tmp_path = (char *) sqlite3_column_text(ctx->stmt_get_next_file_part, 3); + *delivery_attempts = sqlite3_column_int64(ctx->stmt_get_next_aborted_file, 1); + tmp_source = (char *) sqlite3_column_text(ctx->stmt_get_next_aborted_file, 2); + tmp_path = (char *) sqlite3_column_text(ctx->stmt_get_next_aborted_file, 3); *path = cfl_sds_create(tmp_path); diff --git a/plugins/out_azure_blob/azure_blob_db.h b/plugins/out_azure_blob/azure_blob_db.h index 0cd682f1b33..fe067f35013 100644 --- a/plugins/out_azure_blob/azure_blob_db.h +++ b/plugins/out_azure_blob/azure_blob_db.h @@ -68,7 +68,7 @@ "SELECT * FROM out_azure_blob_files WHERE path=@path ORDER BY id DESC;" #define SQL_GET_NEXT_ABORTED_FILE \ - "SELECT id, delivery_attempts, source, path " \ + "SELECT id, azbf.delivery_attempts, source, path " \ " FROM out_azure_blob_files azbf " \ " WHERE aborted = 1 " \ " AND (SELECT COUNT(*) " \ @@ -89,7 +89,7 @@ "UPDATE out_azure_blob_parts SET in_progress=@status WHERE id=@id;" #define SQL_UPDATE_FILE_PART_DELIVERY_ATTEMPT_COUNT \ - "UPDATE out_azure_blob_parts SET delivery_attempts=@delivery_attempts WHERE id=@id;" + "UPDATE out_azure_blob_parts SET delivery_attempts=@delivery_attempts WHERE part_id=@id;" #define SQL_RESET_FILE_UPLOAD_STATES \ "UPDATE out_azure_blob_parts SET delivery_attempts=0, uploaded=0, in_progress=0 WHERE file_id=@id;" From 102110e97f384cac4daef7521fa18c6e8861d862 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Sun, 22 Sep 2024 18:10:13 +0200 Subject: [PATCH 238/295] out_azure_blob: fixed failure notification producer Signed-off-by: Leonardo Alminana --- plugins/out_azure_blob/azure_blob.c | 59 ++++++++++++++--------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/plugins/out_azure_blob/azure_blob.c b/plugins/out_azure_blob/azure_blob.c index 435e620fff4..32dceb839ca 100644 --- a/plugins/out_azure_blob/azure_blob.c +++ b/plugins/out_azure_blob/azure_blob.c @@ -410,7 +410,6 @@ static int send_blob(struct flb_config *config, payload_size = bytes; } - ret = http_send_blob(config, ctx, ref_name, uri, block_id, event_type, payload_buf, payload_size); flb_plg_debug(ctx->ins, "http_send_blob()=%i", ret); @@ -729,10 +728,10 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context pthread_mutex_lock(&ctx->file_upload_commit_file_parts); ret = azb_db_file_get_next_aborted(ctx, - &file_id, - &file_delivery_attempts, - &file_path, - &source); + &file_id, + &file_delivery_attempts, + &file_path, + &source); if (ret == 1) { ret = delete_blob(ctx, file_path); @@ -743,9 +742,30 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context azb_db_file_set_aborted_state(ctx, file_id, file_path, 0); } else { - /* notify the input plugin - */ ret = azb_db_file_delete(ctx, file_id, file_path); + + notification = flb_calloc(1, + sizeof( + struct flb_blob_delivery_notification)); + + if (notification != NULL) { + notification->base.dynamically_allocated = FLB_TRUE; + notification->base.notification_type = FLB_NOTIFICATION_TYPE_BLOB_DELIVERY; + notification->base.destructor = flb_input_blob_delivery_notification_destroy; + notification->success = FLB_FALSE; + notification->path = cfl_sds_create(file_path); + + ret = flb_notification_enqueue(FLB_PLUGIN_INPUT, + source, + ¬ification->base, + config); + + if (ret != 0) { + flb_plg_error(ctx->ins, + "blob file '%s' (id=%" PRIu64 ") notification " \ + "delivery error %d", file_path, file_id, ret); + } + } } cfl_sds_destroy(file_path); @@ -769,28 +789,6 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context if (ret == -1) { flb_plg_error(ctx->ins, "cannot commit blob file parts for file id=%" PRIu64 " path=%s", file_id, file_path); - - notification = flb_calloc(1, - sizeof( - struct flb_blob_delivery_notification)); - - if (notification != NULL) { - notification->base.dynamically_allocated = FLB_TRUE; - notification->base.destructor = flb_input_blob_delivery_notification_destroy; - notification->success = FLB_TRUE; - notification->path = cfl_sds_create(file_path); - - ret = flb_notification_enqueue(FLB_PLUGIN_INPUT, - source, - ¬ification->base, - config); - - if (ret != 0) { - flb_plg_error(ctx->ins, - "blob file '%s' (id=%" PRIu64 ") notification " \ - "delivery error %d", file_path, file_id, ret); - } - } } else { flb_plg_info(ctx->ins, "blob file '%s' (id=%" PRIu64 ") committed successfully", file_path, file_id); @@ -803,8 +801,9 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context if (notification != NULL) { notification->base.dynamically_allocated = FLB_TRUE; + notification->base.notification_type = FLB_NOTIFICATION_TYPE_BLOB_DELIVERY; notification->base.destructor = flb_input_blob_delivery_notification_destroy; - notification->success = FLB_FALSE; + notification->success = FLB_TRUE; notification->path = cfl_sds_create(file_path); ret = flb_notification_enqueue(FLB_PLUGIN_INPUT, From 049391029d9fc8072a1c88d7b96a4715fe208a27 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Tue, 24 Sep 2024 13:15:20 +0200 Subject: [PATCH 239/295] output: added worker cleanup callback missing initialization call Signed-off-by: Leonardo Alminana --- include/fluent-bit/flb_output.h | 1 + src/flb_output.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/fluent-bit/flb_output.h b/include/fluent-bit/flb_output.h index bf93381b789..0dab6a8604d 100644 --- a/include/fluent-bit/flb_output.h +++ b/include/fluent-bit/flb_output.h @@ -234,6 +234,7 @@ struct flb_output_plugin { int workers; int (*cb_worker_init) (void *, struct flb_config *); + int (*cb_worker_exit) (void *, struct flb_config *); /* Notification: this callback will be invoked anytime a notification is received*/ int (*cb_notification) (struct flb_output_instance *, struct flb_config *, void *); diff --git a/src/flb_output.c b/src/flb_output.c index 365708e10ea..90593905960 100644 --- a/src/flb_output.c +++ b/src/flb_output.c @@ -464,6 +464,12 @@ void flb_output_exit(struct flb_config *config) ins = mk_list_entry(head, struct flb_output_instance, _head); p = ins->p; + if (ins->is_threaded == FLB_FALSE) { + if (ins->p->cb_worker_exit) { + ins->p->cb_worker_exit(ins->context, ins->config); + } + } + /* Stop any worker thread */ if (flb_output_is_threaded(ins) == FLB_TRUE) { flb_output_thread_pool_destroy(ins); @@ -479,6 +485,7 @@ void flb_output_exit(struct flb_config *config) params = FLB_TLS_GET(out_flush_params); if (params) { flb_free(params); + FLB_TLS_SET(out_flush_params, NULL); } } @@ -1321,6 +1328,12 @@ int flb_output_init_all(struct flb_config *config) return -1; } + if (ins->is_threaded == FLB_FALSE) { + if (ins->p->cb_worker_init) { + ret = ins->p->cb_worker_init(ins->context, ins->config); + } + } + ins->processor->notification_channel = ins->notification_channel; /* initialize processors */ From e86b58992b74c0e8d70fc317f3e554a99ab7d46b Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Tue, 24 Sep 2024 13:21:30 +0200 Subject: [PATCH 240/295] scheduler: improved timer coroutine return signal handling Signed-off-by: Leonardo Alminana --- include/fluent-bit/flb_scheduler.h | 7 +++- src/flb_scheduler.c | 61 +++++++++++++++++++++++------- 2 files changed, 52 insertions(+), 16 deletions(-) diff --git a/include/fluent-bit/flb_scheduler.h b/include/fluent-bit/flb_scheduler.h index c76cda60290..952d23c3d85 100644 --- a/include/fluent-bit/flb_scheduler.h +++ b/include/fluent-bit/flb_scheduler.h @@ -56,6 +56,7 @@ struct flb_sched_timer { int coro; void *data; struct flb_sched *sched; + void *cb_params; /* * Custom timer specific data: @@ -138,7 +139,7 @@ struct flb_sched { flb_pipefd_t ch_events[2]; }; - +struct flb_sched_timer_coro; int flb_sched_request_create(struct flb_config *config, void *data, int tries); @@ -162,6 +163,7 @@ int flb_sched_timer_coro_cb_create(struct flb_sched *sched, int type, int64_t ms void (*cb)(struct flb_config *, void *), void *data, struct flb_sched_timer **out_timer); +void flb_sched_timer_coro_destroy(struct flb_sched_timer_coro *instance); struct flb_sched_timer_coro *flb_sched_timer_coro_create(struct flb_sched_timer *timer, struct flb_config *config, void *data); @@ -246,7 +248,8 @@ static FLB_INLINE void sched_timer_cb_params_set(struct flb_sched_timer_coro *st params = (struct flb_sched_timer_coro_cb_params *) FLB_TLS_GET(sched_timer_coro_cb_params); if (!params) { - params = flb_malloc(sizeof(struct flb_sched_timer_coro_cb_params)); + params = flb_calloc(1, sizeof(struct flb_sched_timer_coro_cb_params)); + if (!params) { flb_errno(); return; diff --git a/src/flb_scheduler.c b/src/flb_scheduler.c index bacc5083e01..fc91c967391 100644 --- a/src/flb_scheduler.c +++ b/src/flb_scheduler.c @@ -441,6 +441,25 @@ static inline uint32_t sched_timer_coro_get_id(struct flb_sched *sched) return id; } +static inline struct flb_sched_timer_coro *sched_timer_coro_get_by_id( + struct flb_sched *sched, + uint32_t id) +{ + struct cfl_list *head; + struct flb_sched_timer_coro *stc; + + /* check if the proposed id is in use already */ + cfl_list_foreach(head, &sched->timer_coro_list) { + stc = cfl_list_entry(head, struct flb_sched_timer_coro, _head); + if (stc->id == id) { + return stc; + } + } + + return NULL; +} + + /* context of a scheduled timer that holds a coroutine context */ struct flb_sched_timer_coro *flb_sched_timer_coro_create(struct flb_sched_timer *timer, struct flb_config *config, @@ -458,7 +477,7 @@ struct flb_sched_timer_coro *flb_sched_timer_coro_create(struct flb_sched_timer return NULL; } - stc = flb_malloc(sizeof(struct flb_sched_timer_coro)); + stc = flb_calloc(1, sizeof(struct flb_sched_timer_coro)); if (!stc) { flb_errno(); return NULL; @@ -489,6 +508,21 @@ struct flb_sched_timer_coro *flb_sched_timer_coro_create(struct flb_sched_timer return stc; } +void flb_sched_timer_coro_destroy(struct flb_sched_timer_coro *instance) +{ + if (instance == NULL) { + return; + } + + if (instance->coro != NULL) { + flb_coro_destroy(instance->coro); + } + + cfl_list_del(&instance->_head); + + flb_free(instance); +} + /* * Create a timer that triggers the defined callback every N milliseconds. */ @@ -519,16 +553,11 @@ int flb_sched_event_handler(struct flb_config *config, struct mk_event *event) struct flb_sched_timer_coro *stc; if (event->type == FLB_ENGINE_EV_SCHED_CORO) { - printf("CORO EVENT\n"); - stc = (struct flb_sched_timer_coro *) event; - if (!stc) { - flb_error("[sched] invalid timer coro context"); - return -1; - } + sched = flb_sched_ctx_get(); /* consume the notification */ - val = flb_pipe_r(event->fd, &val, sizeof(val)); - if (val == -1) { + ret = flb_pipe_r(event->fd, &val, sizeof(val)); + if (ret == -1) { flb_errno(); return -1; } @@ -536,9 +565,15 @@ int flb_sched_event_handler(struct flb_config *config, struct mk_event *event) op = FLB_BITS_U64_HIGH(val); id = FLB_BITS_U64_LOW(val); + stc = sched_timer_coro_get_by_id(sched, id); + + if (stc == NULL) { + flb_error("[sched] invalid timer coroutine id %u", id); + return -1; + } + if (op == FLB_SCHED_TIMER_CORO_RETURN) { /* move stc to the drop list */ - sched = flb_sched_ctx_get(); cfl_list_del(&stc->_head); cfl_list_add(&stc->_head, &sched->timer_coro_list_drop); } @@ -761,7 +796,7 @@ struct flb_sched *flb_sched_create(struct flb_config *config, flb_sched_destroy(sched); return NULL; } - sched->event.type = FLB_ENGINE_EV_SCHED; + sched->event.type = FLB_ENGINE_EV_SCHED_CORO; /* * Note: mk_event_timeout_create() sets a type = MK_EVENT_NOTIFICATION by @@ -895,9 +930,7 @@ int flb_sched_timer_coro_cleanup(struct flb_sched *sched) cfl_list_foreach_safe(head, tmp, &sched->timer_coro_list_drop) { stc = cfl_list_entry(head, struct flb_sched_timer_coro, _head); - flb_coro_destroy(stc->coro); - cfl_list_del(&stc->_head); - flb_free(stc); + flb_sched_timer_coro_destroy(stc); c++; } From de0d758414cacb6f68bc395d9897ade716b9b0be Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Tue, 24 Sep 2024 13:22:08 +0200 Subject: [PATCH 241/295] scheduler: removed erroneously added field Signed-off-by: Leonardo Alminana --- include/fluent-bit/flb_scheduler.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/fluent-bit/flb_scheduler.h b/include/fluent-bit/flb_scheduler.h index 952d23c3d85..891d35195f3 100644 --- a/include/fluent-bit/flb_scheduler.h +++ b/include/fluent-bit/flb_scheduler.h @@ -56,7 +56,6 @@ struct flb_sched_timer { int coro; void *data; struct flb_sched *sched; - void *cb_params; /* * Custom timer specific data: From f880a2ce9104aedd0bfb43ac93b970ef21872607 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Tue, 24 Sep 2024 13:22:36 +0200 Subject: [PATCH 242/295] engine: added missing scheduler coroutine cleanup Signed-off-by: Leonardo Alminana --- src/flb_engine.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/flb_engine.c b/src/flb_engine.c index f8faab8a3bf..85a9f461eb4 100644 --- a/src/flb_engine.c +++ b/src/flb_engine.c @@ -1124,6 +1124,7 @@ int flb_engine_start(struct flb_config *config) /* Release all resources associated to the engine */ int flb_engine_shutdown(struct flb_config *config) { + struct flb_sched_timer_coro_cb_params *sched_params; config->is_running = FLB_FALSE; flb_input_pause_all(config); @@ -1143,6 +1144,13 @@ int flb_engine_shutdown(struct flb_config *config) flb_custom_exit(config); flb_input_exit_all(config); + /* scheduler */ + sched_params = (struct flb_sched_timer_coro_cb_params *) FLB_TLS_GET(sched_timer_coro_cb_params); + if (sched_params != NULL) { + flb_free(sched_params); + FLB_TLS_SET(sched_timer_coro_cb_params, NULL); + } + /* Destroy the storage context */ flb_storage_destroy(config); From 7532bada77508fd0d350dfb6b5da37a1e083bd0a Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Tue, 24 Sep 2024 13:22:59 +0200 Subject: [PATCH 243/295] output_thread: added missing scheduler coroutine cleanup Signed-off-by: Leonardo Alminana --- src/flb_output_thread.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/flb_output_thread.c b/src/flb_output_thread.c index 330ff4feeec..7e094551b62 100644 --- a/src/flb_output_thread.c +++ b/src/flb_output_thread.c @@ -182,6 +182,7 @@ static void output_thread(void *data) struct flb_output_flush *out_flush; struct flb_out_thread_instance *th_ins = data; struct flb_out_flush_params *params; + struct flb_sched_timer_coro_cb_params *sched_params; struct flb_net_dns dns_ctx; struct flb_notification *notification; @@ -274,6 +275,16 @@ static void output_thread(void *data) */ flb_sched_event_handler(sched->config, event); } + else if (event->type & FLB_ENGINE_EV_SCHED_CORO) { + /* + * Note that this scheduler event handler has more features + * designed to be used from the parent thread, on this specific + * use case we just care about simple timers created on this + * thread or threaded by some output plugin. + */ + flb_sched_event_handler(sched->config, event); + + } else if (event->type == FLB_ENGINE_EV_THREAD_OUTPUT) { /* Read the task reference */ n = flb_pipe_r(event->fd, &task, sizeof(struct flb_task *)); @@ -361,6 +372,10 @@ static void output_thread(void *data) } } + if (ins->p->cb_worker_exit) { + ret = ins->p->cb_worker_exit(ins->context, ins->config); + } + mk_event_channel_destroy(th_ins->evl, th_ins->ch_thread_events[0], th_ins->ch_thread_events[1], @@ -383,8 +398,16 @@ static void output_thread(void *data) params = FLB_TLS_GET(out_flush_params); if (params) { flb_free(params); + FLB_TLS_SET(out_flush_params, NULL); } + sched_params = (struct flb_sched_timer_coro_cb_params *) FLB_TLS_GET(sched_timer_coro_cb_params); + if (sched_params != NULL) { + flb_free(sched_params); + FLB_TLS_SET(sched_timer_coro_cb_params, NULL); + } + + mk_event_channel_destroy(th_ins->evl, th_ins->ch_parent_events[0], th_ins->ch_parent_events[1], From a0b7c98d0e9f20dbee04e81fa3530dff7aa1c1ac Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Tue, 24 Sep 2024 13:23:42 +0200 Subject: [PATCH 244/295] out_azure_blob: added worker context cleanup and stale file remediation Signed-off-by: Leonardo Alminana --- plugins/out_azure_blob/azure_blob.c | 120 ++++++++++++++++++++-------- plugins/out_azure_blob/azure_blob.h | 9 +++ 2 files changed, 95 insertions(+), 34 deletions(-) diff --git a/plugins/out_azure_blob/azure_blob.c b/plugins/out_azure_blob/azure_blob.c index 32dceb839ca..88d07fff3f3 100644 --- a/plugins/out_azure_blob/azure_blob.c +++ b/plugins/out_azure_blob/azure_blob.c @@ -713,6 +713,7 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context struct flb_blob_delivery_notification *notification; info = FLB_TLS_GET(worker_info); + if (info->active_upload) { flb_plg_trace(ctx->ins, "[worker: file upload] upload already in progress..."); flb_sched_timer_cb_coro_return(); @@ -727,52 +728,77 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context pthread_mutex_lock(&ctx->file_upload_commit_file_parts); - ret = azb_db_file_get_next_aborted(ctx, - &file_id, - &file_delivery_attempts, - &file_path, - &source); + while (1) { + ret = azb_db_file_get_next_stale(ctx, + &file_id, + &file_path); - if (ret == 1) { - ret = delete_blob(ctx, file_path); + if (ret == 1) { + delete_blob(ctx, file_path); - if (ctx->file_delivery_attempt_limit != FLB_OUT_RETRY_UNLIMITED && - file_delivery_attempts < ctx->file_delivery_attempt_limit) { azb_db_file_reset_upload_states(ctx, file_id, file_path); azb_db_file_set_aborted_state(ctx, file_id, file_path, 0); + + cfl_sds_destroy(file_path); + + file_path = NULL; } else { - ret = azb_db_file_delete(ctx, file_id, file_path); - - notification = flb_calloc(1, - sizeof( - struct flb_blob_delivery_notification)); + break; + } + } - if (notification != NULL) { - notification->base.dynamically_allocated = FLB_TRUE; - notification->base.notification_type = FLB_NOTIFICATION_TYPE_BLOB_DELIVERY; - notification->base.destructor = flb_input_blob_delivery_notification_destroy; - notification->success = FLB_FALSE; - notification->path = cfl_sds_create(file_path); + while (1) { + ret = azb_db_file_get_next_aborted(ctx, + &file_id, + &file_delivery_attempts, + &file_path, + &source); - ret = flb_notification_enqueue(FLB_PLUGIN_INPUT, - source, - ¬ification->base, - config); + if (ret == 1) { + ret = delete_blob(ctx, file_path); - if (ret != 0) { - flb_plg_error(ctx->ins, - "blob file '%s' (id=%" PRIu64 ") notification " \ - "delivery error %d", file_path, file_id, ret); + if (ctx->file_delivery_attempt_limit != FLB_OUT_RETRY_UNLIMITED && + file_delivery_attempts < ctx->file_delivery_attempt_limit) { + azb_db_file_reset_upload_states(ctx, file_id, file_path); + azb_db_file_set_aborted_state(ctx, file_id, file_path, 0); + } + else { + ret = azb_db_file_delete(ctx, file_id, file_path); + + notification = flb_calloc(1, + sizeof( + struct flb_blob_delivery_notification)); + + if (notification != NULL) { + notification->base.dynamically_allocated = FLB_TRUE; + notification->base.notification_type = FLB_NOTIFICATION_TYPE_BLOB_DELIVERY; + notification->base.destructor = flb_input_blob_delivery_notification_destroy; + notification->success = FLB_FALSE; + notification->path = cfl_sds_create(file_path); + + ret = flb_notification_enqueue(FLB_PLUGIN_INPUT, + source, + ¬ification->base, + config); + + if (ret != 0) { + flb_plg_error(ctx->ins, + "blob file '%s' (id=%" PRIu64 ") notification " \ + "delivery error %d", file_path, file_id, ret); + } } } - } - cfl_sds_destroy(file_path); - cfl_sds_destroy(source); + cfl_sds_destroy(file_path); + cfl_sds_destroy(source); - file_path = NULL; - source = NULL; + file_path = NULL; + source = NULL; + } + else { + break; + } } ret = azb_db_file_oldest_ready(ctx, &file_id, &file_path, &part_ids, &source); @@ -874,7 +900,7 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context flb_sched_timer_cb_coro_return(); } - azb_db_file_part_delivery_attempts(ctx, part_id, ++part_delivery_attempts); + azb_db_file_part_delivery_attempts(ctx, file_id, part_id, ++part_delivery_attempts); flb_plg_debug(ctx->ins, "sending part file %s (id=%" PRIu64 " part_id=%" PRIu64 ")", file_path, id, part_id); ret = send_blob(config, NULL, ctx, FLB_EVENT_TYPE_BLOBS, @@ -901,6 +927,7 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context flb_free(out_buf); } cfl_sds_destroy(file_path); + flb_sched_timer_cb_coro_return(); } @@ -1028,6 +1055,24 @@ static int cb_worker_init(void *data, struct flb_config *config) return 0; } +/* worker teardown */ +static int cb_worker_exit(void *data, struct flb_config *config) +{ + int ret; + struct worker_info *info; + struct flb_azure_blob *ctx = data; + + flb_plg_info(ctx->ins, "initializing worker"); + + info = FLB_TLS_GET(worker_info); + if (info != NULL) { + flb_free(info); + FLB_TLS_SET(worker_info, NULL); + } + + return 0; +} + /* Configuration properties map */ static struct flb_config_map config_map[] = { { @@ -1139,6 +1184,12 @@ static struct flb_config_map config_map[] = { "Timeout to upload parts of a blob file" }, + { + FLB_CONFIG_MAP_TIME, "upload_part_freshness_limit", "6D", + 0, FLB_TRUE, offsetof(struct flb_azure_blob, upload_parts_freshness_threshold), + "Maximum lifespan of an uncommitted file part" + }, + { FLB_CONFIG_MAP_STR, "configuration_endpoint_url", NULL, 0, FLB_TRUE, offsetof(struct flb_azure_blob, configuration_endpoint_url), @@ -1175,6 +1226,7 @@ struct flb_output_plugin out_azure_blob_plugin = { .cb_flush = cb_azure_blob_flush, .cb_exit = cb_azure_blob_exit, .cb_worker_init = cb_worker_init, + .cb_worker_exit = cb_worker_exit, /* Test */ .test_formatter.callback = azure_blob_format, diff --git a/plugins/out_azure_blob/azure_blob.h b/plugins/out_azure_blob/azure_blob.h index 8b3009e978d..43cb5035792 100644 --- a/plugins/out_azure_blob/azure_blob.h +++ b/plugins/out_azure_blob/azure_blob.h @@ -62,6 +62,7 @@ struct flb_azure_blob { flb_sds_t database_file; size_t part_size; time_t upload_parts_timeout; + time_t upload_parts_freshness_threshold; int file_delivery_attempt_limit; int part_delivery_attempt_limit; flb_sds_t configuration_endpoint_url; @@ -69,6 +70,12 @@ struct flb_azure_blob { flb_sds_t configuration_endpoint_password; flb_sds_t configuration_endpoint_bearer_token; + int endpoint_overriden_flag; + int shared_key_overriden_flag; + int sas_token_overriden_flag; + int container_name_overriden_flag; + int path_overriden_flag; + /* * Internal use */ @@ -104,7 +111,9 @@ struct flb_azure_blob { sqlite3_stmt *stmt_update_file_delivery_attempt_count; sqlite3_stmt *stmt_set_file_aborted_state; sqlite3_stmt *stmt_get_next_aborted_file; + sqlite3_stmt *stmt_get_next_stale_file; sqlite3_stmt *stmt_reset_file_upload_states; + sqlite3_stmt *stmt_reset_file_part_upload_states; /* prepared statement: file parts */ From 06aa46e5efb80d2bcc0a1239febf422eb41e6e28 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Tue, 24 Sep 2024 13:24:10 +0200 Subject: [PATCH 245/295] out_azure_blob: fixed leak and double free Signed-off-by: Leonardo Alminana --- plugins/out_azure_blob/azure_blob_conf.c | 66 ++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 4 deletions(-) diff --git a/plugins/out_azure_blob/azure_blob_conf.c b/plugins/out_azure_blob/azure_blob_conf.c index c6cb7e978aa..a66af75933a 100644 --- a/plugins/out_azure_blob/azure_blob_conf.c +++ b/plugins/out_azure_blob/azure_blob_conf.c @@ -150,6 +150,7 @@ static int flb_azure_blob_process_remote_configuration_payload( msgpack_object_map *configuration_map; msgpack_unpacked unpacked_root; char *msgpack_body; + char *value_backup; int root_type; size_t offset; int result; @@ -194,65 +195,100 @@ static int flb_azure_blob_process_remote_configuration_payload( configuration_map = &unpacked_root.data.via.map; + value_backup = context->endpoint; + context->endpoint = NULL; + result = extract_map_string_entry_by_key(&context->endpoint, configuration_map, "host", 0, FLB_TRUE); if (result != 0) { + context->endpoint = value_backup; + flb_plg_error(context->ins, "endpoint extraction error : %d", result); goto cleanup; } + context->endpoint_overriden_flag = FLB_TRUE; + if (context->atype == AZURE_BLOB_AUTH_KEY) { + value_backup = context->shared_key; + context->shared_key = NULL; + result = extract_map_string_entry_by_key(&context->shared_key, - configuration_map, - "shared_key", 0, FLB_TRUE); + configuration_map, + "shared_key", 0, FLB_TRUE); if (result != 0) { + context->shared_key = value_backup; + flb_plg_error(context->ins, - "neither sas_token nor shared_key " \ - "could be extracted : %d", result); + "neither sas_token nor shared_key " \ + "could be extracted : %d", result); goto cleanup; } + + context->shared_key_overriden_flag = FLB_TRUE; } else if (context->atype == AZURE_BLOB_AUTH_SAS) { + value_backup = context->sas_token; + context->sas_token = NULL; + result = extract_map_string_entry_by_key(&context->sas_token, configuration_map, "sas_token", 0, FLB_TRUE); if (result != 0) { + context->sas_token = value_backup; + flb_plg_error(context->ins, "sas_token extraction error : %d", result); goto cleanup; } + + context->sas_token_overriden_flag = FLB_TRUE; } + value_backup = context->container_name; + context->container_name = NULL; + result = extract_map_string_entry_by_key(&context->container_name, configuration_map, "container", 0, FLB_TRUE); if (result != 0) { + context->container_name = value_backup; + flb_plg_error(context->ins, "container extraction error : %d", result); goto cleanup; } + context->container_name_overriden_flag = FLB_TRUE; + + value_backup = context->path; + context->path = NULL; + result = extract_map_string_entry_by_key(&context->path, configuration_map, "path", 0, FLB_TRUE); if (result != 0) { + context->path = value_backup; + flb_plg_error(context->ins, "path extraction error : %d", result); goto cleanup; } + context->path_overriden_flag = FLB_TRUE; + cleanup: if (result != 0) { result = -1; @@ -729,6 +765,28 @@ struct flb_azure_blob *flb_azure_blob_conf_create(struct flb_output_instance *in void flb_azure_blob_conf_destroy(struct flb_azure_blob *ctx) { + + if (ctx->endpoint_overriden_flag == FLB_TRUE) { + flb_sds_destroy(ctx->endpoint); + ctx->endpoint = NULL; + } + if (ctx->shared_key_overriden_flag == FLB_TRUE) { + flb_sds_destroy(ctx->shared_key); + ctx->shared_key = NULL; + } + if (ctx->sas_token_overriden_flag == FLB_TRUE) { + flb_sds_destroy(ctx->sas_token); + ctx->sas_token = NULL; + } + if (ctx->container_name_overriden_flag == FLB_TRUE) { + flb_sds_destroy(ctx->container_name); + ctx->container_name = NULL; + } + if (ctx->path_overriden_flag == FLB_TRUE) { + flb_sds_destroy(ctx->path); + ctx->path = NULL; + } + if (ctx->decoded_sk) { flb_free(ctx->decoded_sk); } From 4a1d8a36c25eb9651f71e5ec04bd41b1e80ac645 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Tue, 24 Sep 2024 13:24:53 +0200 Subject: [PATCH 246/295] out_azure_blob: added stale file remediation Signed-off-by: Leonardo Alminana --- plugins/out_azure_blob/azure_blob_db.c | 118 ++++++++++++++++++++++++- plugins/out_azure_blob/azure_blob_db.h | 65 +++++++++++--- 2 files changed, 167 insertions(+), 16 deletions(-) diff --git a/plugins/out_azure_blob/azure_blob_db.c b/plugins/out_azure_blob/azure_blob_db.c index 2a7fd68ad7f..3de48b15dea 100644 --- a/plugins/out_azure_blob/azure_blob_db.c +++ b/plugins/out_azure_blob/azure_blob_db.c @@ -85,6 +85,16 @@ static int prepare_stmts(struct flb_sqldb *db, struct flb_azure_blob *ctx) return -1; } + /* get next stale file */ + ret = sqlite3_prepare_v2(db->handler, SQL_GET_NEXT_STALE_FILE, -1, + &ctx->stmt_get_next_stale_file, NULL); + if (ret != SQLITE_OK) { + flb_plg_error(ctx->ins, "cannot prepare SQL statement: %s", + SQL_GET_NEXT_STALE_FILE); + return -1; + } + + /* reset file upload progress */ ret = sqlite3_prepare_v2(db->handler, SQL_RESET_FILE_UPLOAD_STATES, -1, &ctx->stmt_reset_file_upload_states, NULL); if (ret != SQLITE_OK) { @@ -93,6 +103,15 @@ static int prepare_stmts(struct flb_sqldb *db, struct flb_azure_blob *ctx) return -1; } + /* reset file part upload progress */ + ret = sqlite3_prepare_v2(db->handler, SQL_RESET_FILE_PART_UPLOAD_STATES, -1, + &ctx->stmt_reset_file_part_upload_states, NULL); + if (ret != SQLITE_OK) { + flb_plg_error(ctx->ins, "cannot prepare SQL statement: %s", + SQL_RESET_FILE_PART_UPLOAD_STATES); + return -1; + } + /* insert blob file part */ ret = sqlite3_prepare_v2(db->handler, SQL_INSERT_FILE_PART, -1, &ctx->stmt_insert_file_part, NULL); @@ -228,7 +247,9 @@ int azb_db_close(struct flb_azure_blob *ctx) sqlite3_finalize(ctx->stmt_get_file); sqlite3_finalize(ctx->stmt_update_file_delivery_attempt_count); sqlite3_finalize(ctx->stmt_get_next_aborted_file); + sqlite3_finalize(ctx->stmt_get_next_stale_file); sqlite3_finalize(ctx->stmt_reset_file_upload_states); + sqlite3_finalize(ctx->stmt_reset_file_part_upload_states); sqlite3_finalize(ctx->stmt_insert_file_part); sqlite3_finalize(ctx->stmt_update_file_part_uploaded); @@ -413,6 +434,56 @@ int azb_db_file_delivery_attempts(struct flb_azure_blob *ctx, return 0; } +int azb_db_file_get_next_stale(struct flb_azure_blob *ctx, + uint64_t *id, + cfl_sds_t *path) +{ + int ret; + char *tmp_path; + int exists = FLB_FALSE; + time_t freshness_threshold; + + freshness_threshold = time(NULL); + freshness_threshold -= ctx->upload_parts_freshness_threshold; + + azb_db_lock(ctx); + + /* Bind parameters */ + sqlite3_bind_int64(ctx->stmt_get_next_stale_file, 1, freshness_threshold); + ret = sqlite3_step(ctx->stmt_get_next_stale_file); + if (ret == SQLITE_ROW) { + exists = FLB_TRUE; + + /* id: column 0 */ + *id = sqlite3_column_int64(ctx->stmt_get_next_stale_file, 0); + tmp_path = (char *) sqlite3_column_text(ctx->stmt_get_next_stale_file, 1); + + *path = cfl_sds_create(tmp_path); + + if (*path == NULL) { + exists = -1; + } + } + else if (ret == SQLITE_DONE) { + /* all good */ + } + else { + exists = -1; + } + + sqlite3_clear_bindings(ctx->stmt_get_next_stale_file); + sqlite3_reset(ctx->stmt_get_next_stale_file); + + azb_db_unlock(ctx); + + if (exists == -1) { + *id = 0; + *path = NULL; + } + + return exists; +} + int azb_db_file_get_next_aborted(struct flb_azure_blob *ctx, uint64_t *id, uint64_t *delivery_attempts, @@ -472,6 +543,42 @@ int azb_db_file_get_next_aborted(struct flb_azure_blob *ctx, return exists; } + +static int azb_db_file_reset_part_upload_states(struct flb_azure_blob *ctx, uint64_t id, char *path) +{ + int ret; + + azb_db_lock(ctx); + + /* Bind parameters */ + sqlite3_bind_int64(ctx->stmt_reset_file_part_upload_states, 1, id); + ret = sqlite3_step(ctx->stmt_reset_file_part_upload_states); + if (ret != SQLITE_DONE) { + sqlite3_clear_bindings(ctx->stmt_reset_file_part_upload_states); + sqlite3_reset(ctx->stmt_reset_file_part_upload_states); + azb_db_unlock(ctx); + return -1; + } + + sqlite3_clear_bindings(ctx->stmt_reset_file_part_upload_states); + sqlite3_reset(ctx->stmt_reset_file_part_upload_states); + + if (ret != SQLITE_DONE) { + flb_plg_error(ctx->ins, "db: error reseting upload " + "states for entry id=%" PRIu64 + ", path='%s'", id, path); + azb_db_unlock(ctx); + return -1; + } + + flb_plg_debug(ctx->ins, "db: file id=%" PRIu64 + ", path='%s' upload states reset", id, path); + + azb_db_unlock(ctx); + + return 0; +} + int azb_db_file_reset_upload_states(struct flb_azure_blob *ctx, uint64_t id, char *path) { int ret; @@ -504,7 +611,7 @@ int azb_db_file_reset_upload_states(struct flb_azure_blob *ctx, uint64_t id, cha azb_db_unlock(ctx); - return 0; + return azb_db_file_reset_part_upload_states(ctx, id, path); } int azb_db_file_part_insert(struct flb_azure_blob *ctx, uint64_t file_id, @@ -663,7 +770,8 @@ int azb_db_file_part_uploaded(struct flb_azure_blob *ctx, uint64_t id) } int azb_db_file_part_delivery_attempts(struct flb_azure_blob *ctx, - uint64_t id, uint64_t attempts) + uint64_t file_id, + uint64_t part_id, uint64_t attempts) { int ret; @@ -671,7 +779,8 @@ int azb_db_file_part_delivery_attempts(struct flb_azure_blob *ctx, /* Bind parameters */ sqlite3_bind_int64(ctx->stmt_update_file_part_delivery_attempt_count, 1, attempts); - sqlite3_bind_int64(ctx->stmt_update_file_part_delivery_attempt_count, 2, id); + sqlite3_bind_int64(ctx->stmt_update_file_part_delivery_attempt_count, 2, file_id); + sqlite3_bind_int64(ctx->stmt_update_file_part_delivery_attempt_count, 3, part_id); /* Run the update */ ret = sqlite3_step(ctx->stmt_update_file_part_delivery_attempt_count); @@ -684,7 +793,8 @@ int azb_db_file_part_delivery_attempts(struct flb_azure_blob *ctx, if (ret != SQLITE_DONE) { flb_plg_error(ctx->ins, "cannot update delivery attempt " - "count for part id=%" PRIu64, id); + "count for part %" PRIu64 ".%" PRIu64, + file_id, part_id); return -1; } diff --git a/plugins/out_azure_blob/azure_blob_db.h b/plugins/out_azure_blob/azure_blob_db.h index fe067f35013..475d5ba9301 100644 --- a/plugins/out_azure_blob/azure_blob_db.h +++ b/plugins/out_azure_blob/azure_blob_db.h @@ -27,13 +27,14 @@ #define SQL_CREATE_AZURE_BLOB_FILES \ "CREATE TABLE IF NOT EXISTS out_azure_blob_files (" \ - " id INTEGER PRIMARY KEY," \ - " source TEXT NOT NULL," \ - " path TEXT NOT NULL," \ - " size INTEGER," \ - " created INTEGER," \ - " delivery_attempts INTEGER DEFAULT 0," \ - " aborted INTEGER DEFAULT 0" \ + " id INTEGER PRIMARY KEY," \ + " source TEXT NOT NULL," \ + " path TEXT NOT NULL," \ + " size INTEGER," \ + " created INTEGER," \ + " delivery_attempts INTEGER DEFAULT 0," \ + " aborted INTEGER DEFAULT 0," \ + " last_delivery_attempt INTEGER DEFAULT 0" \ ");" #define SQL_CREATE_AZURE_BLOB_PARTS \ @@ -62,7 +63,10 @@ "UPDATE out_azure_blob_files SET aborted=@state WHERE id=@id;" #define SQL_UPDATE_FILE_DELIVERY_ATTEMPT_COUNT \ - "UPDATE out_azure_blob_files SET delivery_attempts=@delivery_attempts WHERE id=@id;" + "UPDATE out_azure_blob_files " \ + " SET delivery_attempts=@delivery_attempts, " \ + " last_delivery_attempt=UNIXEPOCH() " \ + " WHERE id=@id;" #define SQL_GET_FILE \ "SELECT * FROM out_azure_blob_files WHERE path=@path ORDER BY id DESC;" @@ -78,6 +82,16 @@ "ORDER BY id DESC " \ "LIMIT 1;" + +#define SQL_GET_NEXT_STALE_FILE \ + "SELECT id, path " \ + " FROM out_azure_blob_files azbf " \ + " WHERE aborted = 0 " \ + " AND last_delivery_attempt > 0 " \ + " AND last_delivery_attempt < @freshness_threshold " \ + "ORDER BY id DESC " \ + "LIMIT 1;" + #define SQL_INSERT_FILE_PART \ "INSERT INTO out_azure_blob_parts (file_id, part_id, offset_start, offset_end)" \ " VALUES (@file_id, @part_id, @offset_start, @offset_end);" @@ -89,10 +103,22 @@ "UPDATE out_azure_blob_parts SET in_progress=@status WHERE id=@id;" #define SQL_UPDATE_FILE_PART_DELIVERY_ATTEMPT_COUNT \ - "UPDATE out_azure_blob_parts SET delivery_attempts=@delivery_attempts WHERE part_id=@id;" + "UPDATE out_azure_blob_parts " \ + " SET delivery_attempts=@delivery_attempts " \ + " WHERE file_id=@file_id " \ + " AND part_id=@part_id;" #define SQL_RESET_FILE_UPLOAD_STATES \ - "UPDATE out_azure_blob_parts SET delivery_attempts=0, uploaded=0, in_progress=0 WHERE file_id=@id;" + "UPDATE out_azure_blob_files " \ + " SET last_delivery_attempt=0 " \ + " WHERE id=@id;" + +#define SQL_RESET_FILE_PART_UPLOAD_STATES \ + "UPDATE out_azure_blob_parts " \ + " SET delivery_attempts=0, " \ + " uploaded=0, " \ + " in_progress=0 " \ + " WHERE file_id=@id;" /* Find the oldest files and retrieve the oldest part ready to be uploaded */ #define SQL_GET_NEXT_FILE_PART \ @@ -103,7 +129,8 @@ " p.offset_end, " \ " p.delivery_attempts, " \ " f.path, " \ - " f.delivery_attempts " \ + " f.delivery_attempts, " \ + " f.last_delivery_attempt " \ "FROM out_azure_blob_parts p " \ " JOIN out_azure_blob_files f " \ " ON p.file_id = f.id " \ @@ -139,18 +166,29 @@ struct flb_sqldb *azb_db_open(struct flb_azure_blob *ctx, char *db_path); int azb_db_close(struct flb_azure_blob *ctx); int azb_db_file_exists(struct flb_azure_blob *ctx, char *path, uint64_t *id); + int64_t azb_db_file_insert(struct flb_azure_blob *ctx, char *source, char *path, size_t size); + int azb_db_file_delete(struct flb_azure_blob *ctx, uint64_t id, char *path); + int azb_db_file_set_aborted_state(struct flb_azure_blob *ctx, uint64_t id, char *path, uint64_t state); + int azb_db_file_delivery_attempts(struct flb_azure_blob *ctx, uint64_t id, uint64_t attempts); + int azb_db_file_get_next_aborted(struct flb_azure_blob *ctx, uint64_t *id, uint64_t *delivery_attempts, cfl_sds_t *path, cfl_sds_t *source); + + +int azb_db_file_get_next_stale(struct flb_azure_blob *ctx, + uint64_t *id, + cfl_sds_t *path); + int azb_db_file_reset_upload_states(struct flb_azure_blob *ctx, uint64_t id, char *path); int azb_db_file_part_insert(struct flb_azure_blob *ctx, uint64_t file_id, @@ -165,7 +203,10 @@ int azb_db_file_part_get_next(struct flb_azure_blob *ctx, uint64_t *file_delivery_attempts, cfl_sds_t *file_path); int azb_db_file_part_uploaded(struct flb_azure_blob *ctx, uint64_t id); -int azb_db_file_part_delivery_attempts(struct flb_azure_blob *ctx, uint64_t id, uint64_t attempts); +int azb_db_file_part_delivery_attempts(struct flb_azure_blob *ctx, + uint64_t file_id, + uint64_t part_id, + uint64_t attempts); int azb_db_file_oldest_ready(struct flb_azure_blob *ctx, uint64_t *file_id, cfl_sds_t *path, cfl_sds_t *part_ids, cfl_sds_t *source); From 277b2e9e21e8ccac7eea3fd73a8bc149a176125c Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Tue, 24 Sep 2024 13:25:11 +0200 Subject: [PATCH 247/295] out_azure_blob: fixed missing http verb support Signed-off-by: Leonardo Alminana --- plugins/out_azure_blob/azure_blob_http.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/out_azure_blob/azure_blob_http.c b/plugins/out_azure_blob/azure_blob_http.c index 5d97d5e25ad..af891c165c0 100644 --- a/plugins/out_azure_blob/azure_blob_http.c +++ b/plugins/out_azure_blob/azure_blob_http.c @@ -179,6 +179,9 @@ flb_sds_t azb_http_canonical_request(struct flb_azure_blob *ctx, case FLB_HTTP_PUT: tmp = flb_sds_cat(can_req, "PUT\n", 4); break; + case FLB_HTTP_DELETE: + tmp = flb_sds_cat(can_req, "DELETE\n", 4); + break; }; if (!tmp) { From 27c01866cfc5819ffd220483b94a8b1d11f0c9cd Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Tue, 24 Sep 2024 13:25:25 +0200 Subject: [PATCH 248/295] in_blob: fixed memory leaks Signed-off-by: Leonardo Alminana --- plugins/in_blob/blob.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/in_blob/blob.c b/plugins/in_blob/blob.c index d9d50ffa547..3aa50021a37 100644 --- a/plugins/in_blob/blob.c +++ b/plugins/in_blob/blob.c @@ -276,8 +276,15 @@ static ssize_t recursive_file_search(struct blob_ctx *ctx, switch (result) { case GLOB_NOSPACE: flb_plg_error(ctx->ins, "no memory space available"); + + cfl_sds_destroy(local_pattern); + cfl_sds_destroy(local_path); + return -5; case GLOB_ABORTED: + cfl_sds_destroy(local_pattern); + cfl_sds_destroy(local_path); + return 0; case GLOB_NOMATCH: result = stat(local_path, &fs_entry_metadata); @@ -295,6 +302,9 @@ static ssize_t recursive_file_search(struct blob_ctx *ctx, } } + cfl_sds_destroy(local_pattern); + cfl_sds_destroy(local_path); + return 6; } } From fb4dc24a4ca7d39f0c5b2479af2ed0f6f8acb5bc Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 25 Sep 2024 17:29:03 +0200 Subject: [PATCH 249/295] in_blob: fixed memory leaks and added temporary win32 compatibility shim Signed-off-by: Leonardo Alminana --- plugins/in_blob/blob.c | 13 + plugins/in_blob/win32_glob.c | 599 +++++++++++++++++++++++++++++++++++ 2 files changed, 612 insertions(+) create mode 100644 plugins/in_blob/win32_glob.c diff --git a/plugins/in_blob/blob.c b/plugins/in_blob/blob.c index 3aa50021a37..206d58947f7 100644 --- a/plugins/in_blob/blob.c +++ b/plugins/in_blob/blob.c @@ -36,6 +36,8 @@ #include "blob_db.h" #include "blob_file.h" +#include "win32_glob.c" + /* Define missing GLOB_TILDE if not exists */ #ifndef GLOB_TILDE #define GLOB_TILDE 1<<2 /* use GNU Libc value */ @@ -200,8 +202,11 @@ static ssize_t recursive_file_search(struct blob_ctx *ctx, cfl_sds_t sds_result; int result; size_t index; + match_count = 0; + memset(&glob_context, 0, sizeof(glob_t)); + if (path != NULL) { local_path = cfl_sds_create(path); } @@ -331,6 +336,8 @@ static ssize_t recursive_file_search(struct blob_ctx *ctx, cfl_sds_destroy(local_pattern); cfl_sds_destroy(local_path); + globfree(&glob_context); + return -7; } @@ -342,6 +349,8 @@ static ssize_t recursive_file_search(struct blob_ctx *ctx, cfl_sds_destroy(local_pattern); cfl_sds_destroy(local_path); + globfree(&glob_context); + return -8; } @@ -360,6 +369,8 @@ static ssize_t recursive_file_search(struct blob_ctx *ctx, cfl_sds_destroy(local_pattern); cfl_sds_destroy(local_path); + globfree(&glob_context); + return -9; } @@ -371,6 +382,8 @@ static ssize_t recursive_file_search(struct blob_ctx *ctx, cfl_sds_destroy(local_pattern); cfl_sds_destroy(local_path); + globfree(&glob_context); + return -10; } diff --git a/plugins/in_blob/win32_glob.c b/plugins/in_blob/win32_glob.c new file mode 100644 index 00000000000..b3828587c0f --- /dev/null +++ b/plugins/in_blob/win32_glob.c @@ -0,0 +1,599 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* Fluent Bit + * ========== + * Copyright (C) 2019-2021 The Fluent Bit Authors + * Copyright (C) 2015-2018 Treasure Data Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined(FLB_SYSTEM_WINDOWS) && !defined(FLB_FILE_GLOB_ERROR_SUCCESS) + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define FLB_FILE_GLOB_ABORT_ON_ERROR (((uint64_t) 1) << 0) +#define FLB_FILE_GLOB_MARK_DIRECTORIES (((uint64_t) 1) << 1) +#define FLB_FILE_GLOB_DO_NOT_SORT (((uint64_t) 1) << 2) +#define FLB_FILE_GLOB_EXPAND_TILDE (((uint64_t) 1) << 3) + +#define FLB_FILE_GLOB_ERROR_SUCCESS 0 +#define FLB_FILE_GLOB_ERROR_ABORTED 1 +#define FLB_FILE_GLOB_ERROR_NO_MEMORY 2 +#define FLB_FILE_GLOB_ERROR_NO_FILE 3 +#define FLB_FILE_GLOB_ERROR_NO_ACCESS 4 +#define FLB_FILE_GLOB_ERROR_NO_MATCHES 5 +#define FLB_FILE_GLOB_ERROR_NO_MORE_RESULTS 6 +#define FLB_FILE_GLOB_ERROR_OVERSIZED_PATH 7 +#define FLB_FILE_GLOB_ERROR_INVALID_ARGUMENT 8 + +#ifndef GLOB_NOSPACE +#define GLOB_NOSPACE FLB_FILE_GLOB_ERROR_NO_MEMORY +#endif + +#ifndef GLOB_ABORTED +#define GLOB_ABORTED FLB_FILE_GLOB_ERROR_ABORTED +#endif + +#ifndef GLOB_NOMATCH +#define GLOB_NOMATCH FLB_FILE_GLOB_ERROR_NO_MATCHES +#endif + +struct flb_file_glob_inner_entry { + char *path; + struct cfl_list _head; +}; + +struct flb_file_glob_inner_context { + struct flb_file_glob_inner_entry *current_entry; + struct cfl_list results; + size_t entries; + size_t index; + uint64_t flags; +}; + +struct flb_file_glob_context { + struct flb_file_glob_inner_context *inner_context; + uint64_t flags; + char *path; +}; + +typedef struct glob_t { + struct flb_file_glob_context inner_context; + char **gl_pathv; + size_t gl_pathc; + +} + +static int flb_file_glob_start(struct flb_file_glob_context *context, + const char *path, + uint64_t flags); + +static void flb_file_glob_clean(struct flb_file_glob_context *context); + +static int flb_file_glob_fetch(struct flb_file_glob_context *context, + char **result); + +static void globfree(glob_t *context) +{ + size_t index; + + if (context->gl_pathv != NULL) { + flb_free(context->gl_pathv); + context->gl_pathv = NULL; + } + + flb_file_glob_clean(context->inner_context); +} + +static int glob(const char *path, + uint64_t flags, + void *unused, + glob_t *context) +{ + size_t entries; + int result; + size_t index; + + (void) unused; + + result = flb_file_glob_start(context, path, flags); + + if (result == FLB_FILE_GLOB_ERROR_SUCCESS) { + entries = cfl_list_size(context->inner_context->results); + + context->gl_pathv = flb_calloc(entries, sizeof(char *)); + + if (context->gl_pathv == NULL) { + globfree(context); + + return FLB_FILE_GLOB_ERROR_NO_MEMORY; + } + + for (index = 0 ; index < entries ; index++) { + result = flb_file_glob_fetch(context->internal_context, + &context->gl_pathv[index]); + + if (result != FLB_FILE_GLOB_ERROR_SUCCESS) { + globfree(context); + + return result; + } + } + } + + return result; +} + + +static void reset_errno() +{ + errno = 0; +} + +static void propagate_last_error_to_errno() +{ + DWORD error_code; + + error_code = GetLastError(); + + switch (error_code) { + case ERROR_INVALID_TARGET_HANDLE: + case ERROR_INVALID_HANDLE: + errno = EBADF; + break; + + case ERROR_TOO_MANY_OPEN_FILES: + errno = EMFILE; + break; + + case ERROR_INVALID_FLAG_NUMBER: + case ERROR_INVALID_PARAMETER: + errno = EINVAL; + break; + + case ERROR_NOT_ENOUGH_MEMORY: + case ERROR_OUTOFMEMORY: + errno = ENOMEM; + break; + + case ERROR_SHARING_VIOLATION: + case ERROR_LOCK_VIOLATION: + case ERROR_PATH_BUSY: + case ERROR_BUSY: + errno = EBUSY; + break; + + case ERROR_HANDLE_DISK_FULL: + case ERROR_DISK_FULL: + errno = ENOSPC; + break; + + case ERROR_INVALID_ADDRESS: + errno = EFAULT; + break; + + case ERROR_FILE_TOO_LARGE: + errno = EFBIG; + break; + + case ERROR_ALREADY_EXISTS: + case ERROR_FILE_EXISTS: + errno = EEXIST; + break; + + case ERROR_FILE_NOT_FOUND: + case ERROR_PATH_NOT_FOUND: + case ERROR_INVALID_DRIVE: + case ERROR_BAD_PATHNAME: + case ERROR_INVALID_NAME: + case ERROR_BAD_UNIT: + errno = ENOENT; + break; + + case ERROR_SEEK_ON_DEVICE: + errno = ESPIPE; + break; + + case ERROR_NEGATIVE_SEEK: + errno = EINVAL; + break; + + case ERROR_ACCESS_DENIED: + errno = EACCES; + break; + + case ERROR_DIR_NOT_EMPTY: + errno = ENOTEMPTY; + break; + + case ERROR_BROKEN_PIPE: + errno = EPIPE; + break; + + case ERROR_GEN_FAILURE: + errno = EIO; + break; + + case ERROR_OPEN_FAILED: + errno = EIO; + break; + + case ERROR_SUCCESS: + errno = 0; + break; + + default: + /* This is just a canary, if you find this + * error then it means we need to expand the + * translation list. + */ + + errno = EOWNERDEAD; + break; + } +} + +static int limited_win32_glob_append_entry( + struct flb_file_glob_inner_context *context, + char *path, + uint16_t mode_filter) +{ + char entry_path_buffer[FLB_FILE_MAX_PATH_LENGTH]; + char *entry_path; + struct flb_file_stat entry_info; + int result; + struct flb_file_glob_inner_entry *entry; + + result = flb_file_stat(path, &entry_info); + + if (result != 0) { + result = FLB_FILE_GLOB_ERROR_NO_FILE; + } + else { + result = FLB_FILE_GLOB_ERROR_SUCCESS; + + if (mode_filter != 0) { + if (!FLB_FILE_ISTYPE(entry_info.mode, mode_filter)) { + result = FLB_FILE_GLOB_ERROR_NO_MATCHES; + } + } + } + + if (result == FLB_FILE_GLOB_ERROR_SUCCESS) { + entry_path = _fullpath(entry_path_buffer, + path, + FLB_FILE_MAX_PATH_LENGTH); + + if (entry_path == NULL) { + result = FLB_FILE_GLOB_ERROR_OVERSIZED_PATH; + } + } + + if (result == FLB_FILE_GLOB_ERROR_SUCCESS) { + entry = flb_calloc(1, sizeof(struct flb_file_glob_inner_entry)); + + if (entry == NULL) { + return FLB_FILE_GLOB_ERROR_NO_MEMORY; + } + + entry->path = flb_strdup(entry_path); + + if (entry->path == NULL) { + flb_free(entry); + + return FLB_FILE_GLOB_ERROR_NO_MEMORY; + } + + cfl_list_append(&entry->_head, &context->results); + + context->entries++; + } + + return result; +} + +/* + * Perform patern match on the given path string. This function + * supports patterns with "nested" wildcards like below. + * + * tail_scan_pattern("C:\fluent-bit\*\*.txt", ctx); + * + * On success, the number of files found is returned (zero indicates + * "no file found"). On error, -1 is returned. + */ +static int limited_win32_glob(struct flb_file_glob_inner_context *context, + char *path) +{ + char *star, *p0, *p1; + char pattern[FLB_FILE_MAX_PATH_LENGTH]; + char buf[FLB_FILE_MAX_PATH_LENGTH]; + int ret; + int n_added = 0; + time_t now; + int64_t mtime; + HANDLE h; + WIN32_FIND_DATA data; + struct flb_file_glob_inner_entry *entry; + int transverse_directory; + struct flb_file_stat entry_info; + + if (strlen(path) >= FLB_FILE_MAX_PATH_LENGTH) { + return FLB_FILE_GLOB_ERROR_OVERSIZED_PATH; + } + + star = strchr(path, '*'); + + if (star == NULL) { + return limited_win32_glob_append_entry(context, path, 0); + } + + /* + * C:\data\tmp\input_*.conf + * 0<-----| + */ + p0 = star; + while (path <= p0 && *p0 != '\\') { + p0--; + } + + /* + * C:\data\tmp\input_*.conf + * |---->1 + */ + p1 = star; + while (*p1 && *p1 != '\\') { + p1++; + } + + memcpy(pattern, path, (p1 - path)); + pattern[p1 - path] = '\0'; + + h = FindFirstFileA(pattern, &data); + + if (h == INVALID_HANDLE_VALUE) { + return FLB_FILE_GLOB_ERROR_NO_MATCHES; + } + + ret = FLB_FILE_GLOB_ERROR_SUCCESS; + + do { + /* Ignore the current and parent dirs */ + if (!strcmp(".", data.cFileName) || + !strcmp("..", data.cFileName)) { + continue; + } + + /* Avoid an infinite loop */ + if (strchr(data.cFileName, '*')) { + continue; + } + + /* Create a path (prefix + filename + suffix) */ + memcpy(buf, path, p0 - path + 1); + buf[p0 - path + 1] = '\0'; + + if ((strlen(buf) + + strlen(data.cFileName) + + strlen(p1)) >= FLB_FILE_MAX_PATH_LENGTH) { + if (context->flags & + FLB_FILE_GLOB_ABORT_ON_ERROR) { + ret = FLB_FILE_GLOB_ERROR_OVERSIZED_PATH; + + break; + } + else { + continue; + } + } + + strcat(buf, data.cFileName); + + if (strchr(p1, '*')) { + transverse_directory = FLB_FALSE; + + if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + transverse_directory = FLB_TRUE; + } + else if (data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { + ret = flb_file_stat(data.cFileName, + &entry_info); + + if (ret != 0) { + if (context->flags & + FLB_FILE_GLOB_ABORT_ON_ERROR) { + ret = FLB_FILE_GLOB_ERROR_NO_FILE; + + break; + } + } + + if (FLB_FILE_ISDIR(entry_info.mode)) { + transverse_directory = FLB_TRUE; + } + } + + if (transverse_directory) { + strcat(buf, p1); + + ret = limited_win32_glob(context, buf); + + if (ret != FLB_FILE_GLOB_ERROR_SUCCESS && + ret != FLB_FILE_GLOB_ERROR_NO_FILE && + ret != FLB_FILE_GLOB_ERROR_NO_MATCHES) { + if (context->flags & + FLB_FILE_GLOB_ABORT_ON_ERROR) { + break; + } + } + + continue; + } + } + + strcat(buf, p1); + + ret = limited_win32_glob_append_entry(context, buf, 0); + + if (ret != FLB_FILE_GLOB_ERROR_SUCCESS && + ret != FLB_FILE_GLOB_ERROR_NO_FILE) { + if (context->flags & + FLB_FILE_GLOB_ABORT_ON_ERROR) { + break; + } + } + + ret = FLB_FILE_GLOB_ERROR_SUCCESS; + } while (FindNextFileA(h, &data) != 0); + + FindClose(h); + + if (!(context->flags & + FLB_FILE_GLOB_ABORT_ON_ERROR)) { + ret = FLB_FILE_GLOB_ERROR_SUCCESS; + } + + return ret; +} + +int flb_file_glob_start(struct flb_file_glob_context *context, + const char *path, + uint64_t flags) +{ + + int tilde_expansion_attempted; + struct flb_file_stat path_stat; + int result; + + if (context == NULL) { + return -1; + } + + memset(context, 0, sizeof(struct flb_file_glob_context)); + + context->inner_context = + flb_calloc(1, sizeof(struct flb_file_glob_inner_context)); + + if (context->inner_context == NULL) { + return -2; + } + + cfl_list_init(&context->inner_context->results); + + context->inner_context->flags = 0; + context->flags = flags; + + if (flags & FLB_FILE_GLOB_ABORT_ON_ERROR) { + context->inner_context->flags |= FLB_FILE_GLOB_ABORT_ON_ERROR; + } + + context->path = flb_strdup(path); + + if (context->path == NULL) { + flb_file_glob_clean(context); + + return -3; + } + + return limited_win32_glob(context->inner_context, + context->path); +} + +void flb_file_glob_clean(struct flb_file_glob_context *context) +{ + struct cfl_list *iterator_backup; + struct cfl_list *iterator; + struct flb_file_glob_inner_entry *entry; + + if (context != NULL) { + if (context->path != NULL) { + flb_free(context->path); + } + + if (context->inner_context != NULL) { + cfl_list_foreach_safe(iterator, + iterator_backup, + &context->inner_context->results) { + entry = cfl_list_entry(iterator, + struct flb_file_glob_inner_entry, + _head); + + if (entry->path != NULL) { + flb_free(entry->path); + } + + cfl_list_del(&entry->_head); + + flb_free(entry); + } + + flb_free(context->inner_context); + } + + memset(context, 0, sizeof(struct flb_file_glob_context)); + } + +} + +int flb_file_glob_fetch(struct flb_file_glob_context *context, + char **result) +{ + + if (context == NULL) { + return FLB_FILE_GLOB_ERROR_NO_MEMORY; + } + + if (result == NULL) { + return FLB_FILE_GLOB_ERROR_NO_MEMORY; + } + + *result = NULL; + + if (context->inner_context->index >= + context->inner_context->entries) { + return FLB_FILE_GLOB_ERROR_NO_MORE_RESULTS; + } + + if (context->inner_context->current_entry == NULL) { + context->inner_context->current_entry = + cfl_list_entry_first(&context->inner_context->results, + struct flb_file_glob_inner_entry, + _head); + } + else { + context->inner_context->current_entry = + cfl_list_entry_next(&context->inner_context->current_entry->_head, + struct flb_file_glob_inner_entry, + _head, + &context->inner_context->results); + } + + *result = context->inner_context->current_entry->path; + + context->inner_context->index++; + + return FLB_FILE_GLOB_ERROR_SUCCESS; +} + +#endif \ No newline at end of file From e5df92691bd6bc5934ad452b5863472123432307 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 25 Sep 2024 17:55:46 +0200 Subject: [PATCH 250/295] input_thread: fixed use after free (CID 509982) Signed-off-by: Leonardo Alminana --- src/flb_input_thread.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/flb_input_thread.c b/src/flb_input_thread.c index 43eb1ec905e..52966121759 100644 --- a/src/flb_input_thread.c +++ b/src/flb_input_thread.c @@ -189,6 +189,15 @@ static FLB_INLINE int engine_handle_event(flb_pipefd_t fd, int mask, static void input_thread_instance_destroy(struct flb_input_thread_instance *thi) { + if (thi->notification_channels_initialized == FLB_TRUE) { + mk_event_channel_destroy(thi->evl, + thi->notification_channels[0], + thi->notification_channels[1], + &thi->notification_event); + + thi->notification_channels_initialized = FLB_FALSE; + } + if (thi->evl) { mk_event_loop_destroy(thi->evl); } @@ -209,15 +218,6 @@ static void input_thread_instance_destroy(struct flb_input_thread_instance *thi) mk_event_closesocket(thi->ch_thread_events[1]); } - if (thi->notification_channels_initialized == FLB_TRUE) { - mk_event_channel_destroy(thi->evl, - thi->notification_channels[0], - thi->notification_channels[1], - &thi->notification_event); - - thi->notification_channels_initialized = FLB_FALSE; - } - flb_tp_destroy(thi->tp); flb_free(thi); } From 0778f4f5914eba8674e317673326dda806c1df50 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 25 Sep 2024 18:01:44 +0200 Subject: [PATCH 251/295] in_blob: fixed leak (CID 509979) Signed-off-by: Leonardo Alminana --- plugins/in_blob/blob.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/in_blob/blob.c b/plugins/in_blob/blob.c index 206d58947f7..66d982ba91d 100644 --- a/plugins/in_blob/blob.c +++ b/plugins/in_blob/blob.c @@ -687,6 +687,8 @@ static int in_blob_notification(struct flb_input_instance *in_context, "(filename suffix concatentation error)", notification->path); + cfl_sds_destroy(new_filename); + break; } @@ -703,6 +705,8 @@ static int in_blob_notification(struct flb_input_instance *in_context, notification->path); } + cfl_sds_destroy(new_filename); + break; } } @@ -786,6 +790,8 @@ static int in_blob_notification(struct flb_input_instance *in_context, "(filename suffix concatentation error)", notification->path); + cfl_sds_destroy(new_filename); + break; } @@ -802,6 +808,8 @@ static int in_blob_notification(struct flb_input_instance *in_context, notification->path); } + cfl_sds_destroy(new_filename); + break; } } From ef3084f06aea542123cff2e5f56b74231de41135 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 25 Sep 2024 18:05:27 +0200 Subject: [PATCH 252/295] out_azure_blob: fixed leak (CID 509977) Signed-off-by: Leonardo Alminana --- plugins/out_azure_blob/azure_blob.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/out_azure_blob/azure_blob.c b/plugins/out_azure_blob/azure_blob.c index 88d07fff3f3..e0a5af56ed8 100644 --- a/plugins/out_azure_blob/azure_blob.c +++ b/plugins/out_azure_blob/azure_blob.c @@ -786,6 +786,8 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context flb_plg_error(ctx->ins, "blob file '%s' (id=%" PRIu64 ") notification " \ "delivery error %d", file_path, file_id, ret); + + flb_notification_cleanup(notification); } } } @@ -841,6 +843,8 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context flb_plg_error(ctx->ins, "blob file '%s' (id=%" PRIu64 ") notification " \ "delivery error %d", file_path, file_id, ret); + + flb_notification_cleanup(notification); } } From 133340318c24668dbbb0fe2979424183c411580c Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 25 Sep 2024 18:08:19 +0200 Subject: [PATCH 253/295] out_azure_blob: fixed leak (CID 509970) Signed-off-by: Leonardo Alminana --- plugins/out_azure_blob/azure_blob.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/out_azure_blob/azure_blob.c b/plugins/out_azure_blob/azure_blob.c index e0a5af56ed8..91247eea305 100644 --- a/plugins/out_azure_blob/azure_blob.c +++ b/plugins/out_azure_blob/azure_blob.c @@ -372,6 +372,9 @@ static int send_blob(struct flb_config *config, block_id = azb_block_blob_id_logs(&ms); if (!block_id) { flb_plg_error(ctx->ins, "could not generate block id"); + + cfl_sds_destroy(ref_name); + return FLB_RETRY; } uri = azb_block_blob_uri(ctx, tag, block_id, ms); From fd5db52a4c056ecac6b8100a8b6e6b0a47d047d7 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Thu, 26 Sep 2024 00:09:22 +0200 Subject: [PATCH 254/295] in_blob: fixed windows compatibility issues Signed-off-by: Leonardo Alminana --- plugins/in_blob/blob.c | 15 +++++++++++++-- plugins/in_blob/win32_glob.c | 32 ++++++++++++++++---------------- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/plugins/in_blob/blob.c b/plugins/in_blob/blob.c index 66d982ba91d..ab6bff72b48 100644 --- a/plugins/in_blob/blob.c +++ b/plugins/in_blob/blob.c @@ -28,8 +28,12 @@ #include #include + +#ifndef FLB_SYSTEM_WINDOWS #include #include +#endif + #include #include "blob.h" @@ -43,6 +47,7 @@ #define GLOB_TILDE 1<<2 /* use GNU Libc value */ #define UNSUP_TILDE 1 +#ifndef FLB_SYSTEM_WINDOWS /* we need these extra headers for path resolution */ #include #include @@ -118,6 +123,12 @@ static char *expand_tilde(const char *path) return path; } +#else +static char* expand_tilde(const char* path) +{ + return NULL; +} +#endif #endif static inline int do_glob(const char *pattern, @@ -134,8 +145,8 @@ static inline int do_glob(const char *pattern, /* Save current values */ new_flags = flags; +#if defined(UNSUP_TILDE) && !defined(FLB_SYSTEM_WINDOWS) if (flags & GLOB_TILDE) { -#ifdef UNSUP_TILDE /* * Some libc libraries like Musl do not support GLOB_TILDE for tilde * expansion. A workaround is to use wordexp(3) but looking at it @@ -156,8 +167,8 @@ static inline int do_glob(const char *pattern, /* remove unused flag */ new_flags &= ~GLOB_TILDE; -#endif } +#endif /* invoke glob with new parameters */ ret = glob(pattern, new_flags, NULL, pglob); diff --git a/plugins/in_blob/win32_glob.c b/plugins/in_blob/win32_glob.c index b3828587c0f..ef042b34452 100644 --- a/plugins/in_blob/win32_glob.c +++ b/plugins/in_blob/win32_glob.c @@ -60,6 +60,10 @@ #define GLOB_NOMATCH FLB_FILE_GLOB_ERROR_NO_MATCHES #endif +#ifndef GLOB_ERR +#define GLOB_ERR FLB_FILE_GLOB_ABORT_ON_ERROR +#endif + struct flb_file_glob_inner_entry { char *path; struct cfl_list _head; @@ -83,8 +87,9 @@ typedef struct glob_t { struct flb_file_glob_context inner_context; char **gl_pathv; size_t gl_pathc; +}; -} +typedef struct glob_t glob_t; static int flb_file_glob_start(struct flb_file_glob_context *context, const char *path, @@ -104,7 +109,7 @@ static void globfree(glob_t *context) context->gl_pathv = NULL; } - flb_file_glob_clean(context->inner_context); + flb_file_glob_clean(&context->inner_context); } static int glob(const char *path, @@ -121,7 +126,7 @@ static int glob(const char *path, result = flb_file_glob_start(context, path, flags); if (result == FLB_FILE_GLOB_ERROR_SUCCESS) { - entries = cfl_list_size(context->inner_context->results); + entries = cfl_list_size(&context->inner_context.inner_context->results); context->gl_pathv = flb_calloc(entries, sizeof(char *)); @@ -132,7 +137,7 @@ static int glob(const char *path, } for (index = 0 ; index < entries ; index++) { - result = flb_file_glob_fetch(context->internal_context, + result = flb_file_glob_fetch(&context->inner_context, &context->gl_pathv[index]); if (result != FLB_FILE_GLOB_ERROR_SUCCESS) { @@ -262,11 +267,11 @@ static int limited_win32_glob_append_entry( { char entry_path_buffer[FLB_FILE_MAX_PATH_LENGTH]; char *entry_path; - struct flb_file_stat entry_info; + struct stat entry_info; int result; struct flb_file_glob_inner_entry *entry; - result = flb_file_stat(path, &entry_info); + result = stat(path, &entry_info); if (result != 0) { result = FLB_FILE_GLOB_ERROR_NO_FILE; @@ -337,7 +342,7 @@ static int limited_win32_glob(struct flb_file_glob_inner_context *context, WIN32_FIND_DATA data; struct flb_file_glob_inner_entry *entry; int transverse_directory; - struct flb_file_stat entry_info; + struct stat entry_info; if (strlen(path) >= FLB_FILE_MAX_PATH_LENGTH) { return FLB_FILE_GLOB_ERROR_OVERSIZED_PATH; @@ -417,8 +422,7 @@ static int limited_win32_glob(struct flb_file_glob_inner_context *context, transverse_directory = FLB_TRUE; } else if (data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { - ret = flb_file_stat(data.cFileName, - &entry_info); + ret = stat(data.cFileName, &entry_info); if (ret != 0) { if (context->flags & @@ -428,10 +432,6 @@ static int limited_win32_glob(struct flb_file_glob_inner_context *context, break; } } - - if (FLB_FILE_ISDIR(entry_info.mode)) { - transverse_directory = FLB_TRUE; - } } if (transverse_directory) { @@ -482,9 +482,9 @@ int flb_file_glob_start(struct flb_file_glob_context *context, uint64_t flags) { - int tilde_expansion_attempted; - struct flb_file_stat path_stat; - int result; + int tilde_expansion_attempted; + struct stat path_stat; + int result; if (context == NULL) { return -1; From aed530bb8b59416d6e645d5f42e34fb7a6b3deda Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Thu, 26 Sep 2024 00:10:37 +0200 Subject: [PATCH 255/295] out_azure_blob: fixed warnings Signed-off-by: Leonardo Alminana --- plugins/out_azure_blob/azure_blob.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/out_azure_blob/azure_blob.c b/plugins/out_azure_blob/azure_blob.c index 91247eea305..ec82ee9278c 100644 --- a/plugins/out_azure_blob/azure_blob.c +++ b/plugins/out_azure_blob/azure_blob.c @@ -790,7 +790,7 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context "blob file '%s' (id=%" PRIu64 ") notification " \ "delivery error %d", file_path, file_id, ret); - flb_notification_cleanup(notification); + flb_notification_cleanup(¬ification->base); } } } @@ -847,7 +847,7 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context "blob file '%s' (id=%" PRIu64 ") notification " \ "delivery error %d", file_path, file_id, ret); - flb_notification_cleanup(notification); + flb_notification_cleanup(¬ification->base); } } @@ -1065,7 +1065,6 @@ static int cb_worker_init(void *data, struct flb_config *config) /* worker teardown */ static int cb_worker_exit(void *data, struct flb_config *config) { - int ret; struct worker_info *info; struct flb_azure_blob *ctx = data; From b84d01936a4dc432af326e53e0e59741bd77e181 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Thu, 26 Sep 2024 18:25:15 +0200 Subject: [PATCH 256/295] out_azure_blob: added missing function Signed-off-by: Leonardo Alminana --- plugins/in_blob/blob.c | 12 +++++++++++- plugins/in_blob/win32_glob.c | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/plugins/in_blob/blob.c b/plugins/in_blob/blob.c index ab6bff72b48..54e4fe6ece7 100644 --- a/plugins/in_blob/blob.c +++ b/plugins/in_blob/blob.c @@ -131,6 +131,15 @@ static char* expand_tilde(const char* path) #endif #endif + + +#ifndef FLB_SYSTEM_WINDOWS +static int is_directory(char *path, struct stat *fs_entry_metadata) +{ + return S_ISDIR(fs_entry_metadata->st_mode); +} +#endif + static inline int do_glob(const char *pattern, int flags, void *not_used, @@ -334,7 +343,8 @@ static ssize_t recursive_file_search(struct blob_ctx *ctx, continue; } - if (S_ISDIR(fs_entry_metadata.st_mode)) { + if (is_directory(glob_context.gl_pathv[index], + fs_entry_metadata.st_mode)) { local_path[0] = '\0'; cfl_sds_len_set(local_path, 0); diff --git a/plugins/in_blob/win32_glob.c b/plugins/in_blob/win32_glob.c index ef042b34452..5c7453f5aaf 100644 --- a/plugins/in_blob/win32_glob.c +++ b/plugins/in_blob/win32_glob.c @@ -151,6 +151,10 @@ static int glob(const char *path, return result; } +static int is_directory(char* path, struct stat* fs_entry_metadata) +{ + return (fs_entry_metadata->st_mode & S_IFDIR != 0); +} static void reset_errno() { From 9c0a9557bf887d03a762b138abc01398431c8ad1 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Thu, 26 Sep 2024 18:40:08 +0200 Subject: [PATCH 257/295] out_azure_blob: fixed typo and added missing constant Signed-off-by: Leonardo Alminana --- plugins/in_blob/win32_glob.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/in_blob/win32_glob.c b/plugins/in_blob/win32_glob.c index 5c7453f5aaf..af2bf774b09 100644 --- a/plugins/in_blob/win32_glob.c +++ b/plugins/in_blob/win32_glob.c @@ -64,6 +64,8 @@ #define GLOB_ERR FLB_FILE_GLOB_ABORT_ON_ERROR #endif +#define FLB_FILE_MAX_PATH_LENGTH PATH_MAX + struct flb_file_glob_inner_entry { char *path; struct cfl_list _head; @@ -83,7 +85,7 @@ struct flb_file_glob_context { char *path; }; -typedef struct glob_t { +struct glob_t { struct flb_file_glob_context inner_context; char **gl_pathv; size_t gl_pathc; @@ -284,7 +286,7 @@ static int limited_win32_glob_append_entry( result = FLB_FILE_GLOB_ERROR_SUCCESS; if (mode_filter != 0) { - if (!FLB_FILE_ISTYPE(entry_info.mode, mode_filter)) { + if (!FLB_FILE_ISTYPE(entry_info.st_mode, mode_filter)) { result = FLB_FILE_GLOB_ERROR_NO_MATCHES; } } From 781af7c588f3851ec9f7077d9e395f00cd8366a3 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Thu, 26 Sep 2024 18:45:00 +0200 Subject: [PATCH 258/295] out_azure_blob: added missing macro Signed-off-by: Leonardo Alminana --- plugins/in_blob/win32_glob.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/in_blob/win32_glob.c b/plugins/in_blob/win32_glob.c index af2bf774b09..3efa3532152 100644 --- a/plugins/in_blob/win32_glob.c +++ b/plugins/in_blob/win32_glob.c @@ -66,6 +66,8 @@ #define FLB_FILE_MAX_PATH_LENGTH PATH_MAX +#define FLB_FILE_ISTYPE(m, t) (((m) & 0170000) == t) + struct flb_file_glob_inner_entry { char *path; struct cfl_list _head; From db01ab8bfdf63e35b5c1d0fb06fc4a3059c1616e Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Fri, 27 Sep 2024 09:37:41 +0200 Subject: [PATCH 259/295] engine: added missing header Signed-off-by: Leonardo Alminana --- src/flb_engine.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/flb_engine.c b/src/flb_engine.c index 85a9f461eb4..911c1389a79 100644 --- a/src/flb_engine.c +++ b/src/flb_engine.c @@ -53,6 +53,7 @@ #include #include #include +#include #ifdef FLB_HAVE_METRICS #include From 766bbc111b949f8278fac57aaead7f01a98f7939 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Fri, 27 Sep 2024 09:37:58 +0200 Subject: [PATCH 260/295] in_blob: fixed typos Signed-off-by: Leonardo Alminana --- plugins/in_blob/blob.c | 4 +--- plugins/in_blob/win32_glob.c | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/plugins/in_blob/blob.c b/plugins/in_blob/blob.c index 54e4fe6ece7..c4f5175425d 100644 --- a/plugins/in_blob/blob.c +++ b/plugins/in_blob/blob.c @@ -131,8 +131,6 @@ static char* expand_tilde(const char* path) #endif #endif - - #ifndef FLB_SYSTEM_WINDOWS static int is_directory(char *path, struct stat *fs_entry_metadata) { @@ -344,7 +342,7 @@ static ssize_t recursive_file_search(struct blob_ctx *ctx, } if (is_directory(glob_context.gl_pathv[index], - fs_entry_metadata.st_mode)) { + &fs_entry_metadata)) { local_path[0] = '\0'; cfl_sds_len_set(local_path, 0); diff --git a/plugins/in_blob/win32_glob.c b/plugins/in_blob/win32_glob.c index 3efa3532152..9bba4ca1e1c 100644 --- a/plugins/in_blob/win32_glob.c +++ b/plugins/in_blob/win32_glob.c @@ -155,7 +155,7 @@ static int glob(const char *path, return result; } -static int is_directory(char* path, struct stat* fs_entry_metadata) +static int is_directory(char *path, struct stat *fs_entry_metadata) { return (fs_entry_metadata->st_mode & S_IFDIR != 0); } From d29cc8c9efeec9da275b5e9d6b55c3d85479884a Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Fri, 27 Sep 2024 09:39:35 +0200 Subject: [PATCH 261/295] input_blob: fixed warning Signed-off-by: Leonardo Alminana --- src/flb_input_blob.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/flb_input_blob.c b/src/flb_input_blob.c index b4a5f8b654c..cef22bae680 100644 --- a/src/flb_input_blob.c +++ b/src/flb_input_blob.c @@ -190,7 +190,7 @@ int flb_input_blob_file_register(struct flb_input_instance *ins, return -1; } - ret = flb_log_event_encoder_append_body_cstring(encoder, flb_input_name(ins)); + ret = flb_log_event_encoder_append_body_cstring(encoder, (char *) flb_input_name(ins)); if (ret != FLB_EVENT_ENCODER_SUCCESS) { flb_error("[blob file registration] could not append source plugin name"); flb_log_event_encoder_reset(encoder); From e414972f43317fcdeb232d09a5bbcba23dd93f53 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Fri, 27 Sep 2024 12:06:27 -0600 Subject: [PATCH 262/295] tests: runtime: config_map_opts: initialize scheduler Signed-off-by: Eduardo Silva --- tests/runtime/config_map_opts.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/runtime/config_map_opts.c b/tests/runtime/config_map_opts.c index 57b396bb421..378588e9ffa 100644 --- a/tests/runtime/config_map_opts.c +++ b/tests/runtime/config_map_opts.c @@ -1,5 +1,6 @@ /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ #include +#include #include "flb_tests_runtime.h" /* Test functions */ @@ -17,6 +18,7 @@ void flb_test_config_map_opts(void) int in_ffd, r; flb_init_env(); + flb_sched_ctx_init(); ctx = flb_create(); in_ffd = flb_input(ctx, (char *) "tail", NULL); From 19754f807dc3154c70e6dc59eaaff548fea066be Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Fri, 27 Sep 2024 13:14:39 -0600 Subject: [PATCH 263/295] tests: runtime: filter_stdout: initialize scheduler Signed-off-by: Eduardo Silva --- tests/runtime/filter_stdout.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/runtime/filter_stdout.c b/tests/runtime/filter_stdout.c index 835ad8eda7a..21e5c98fbcc 100644 --- a/tests/runtime/filter_stdout.c +++ b/tests/runtime/filter_stdout.c @@ -1,6 +1,8 @@ /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ #include +#include + #include "flb_tests_runtime.h" /* Test data */ @@ -16,7 +18,7 @@ TEST_LIST = { {NULL, NULL} }; -/* +/* * This test case is to check if fluent-bit allows case-insensitive plugin name. * This test is not unique to filter_stdout, but we test here :) , */ @@ -39,6 +41,7 @@ void flb_test_filter_stdout_case_insensitive(void) * In general, macOS requests surely initialization for pthread stuffs. */ flb_init_env(); + flb_sched_ctx_init(); flb_destroy(ctx); } From eba9f73f33428df2505dc15b4831b20f5e9ea022 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Fri, 27 Sep 2024 13:16:06 -0600 Subject: [PATCH 264/295] tests: runtime: custom_calyptia: initialize scheduler Signed-off-by: Eduardo Silva --- tests/runtime/custom_calyptia_test.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/runtime/custom_calyptia_test.c b/tests/runtime/custom_calyptia_test.c index 5ad30e7a0bf..7a13fa48dd1 100644 --- a/tests/runtime/custom_calyptia_test.c +++ b/tests/runtime/custom_calyptia_test.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ #include +#include #include #include "flb_tests_runtime.h" @@ -17,6 +18,8 @@ void flb_custom_calyptia_pipeline_config_get_test() flb_sds_t cfg; ctx = flb_create(); + flb_sched_ctx_init(); + flb_service_set(ctx, "flush", "1", "grace", "1", NULL); in_ffd_dummy = flb_input(ctx, (char *) "dummy", NULL); @@ -36,7 +39,7 @@ void flb_custom_calyptia_pipeline_config_get_test() calyptia = flb_custom_new(ctx->config, (char *)"calyptia", NULL); TEST_CHECK(calyptia != NULL); - flb_custom_set_property(calyptia, "api_key", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); + flb_custom_set_property(calyptia, "api_key", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); flb_custom_set_property(calyptia, "log_level", "debug"); flb_custom_set_property(calyptia, "log_level", "7DDD2941-3ED6-4B8C-9F84-DD04C4A018A4"); flb_custom_set_property(calyptia, "add_label", "pipeline_id 7DDD2941-3ED6-4B8C-9F84-DD04C4A018A4"); From b3475eb88014600c0c95d9dc79a40b70e4949648 Mon Sep 17 00:00:00 2001 From: Pat Date: Mon, 30 Sep 2024 11:10:15 +0100 Subject: [PATCH 265/295] workflows: update for 3.1 branch (#9444) Signed-off-by: Patrick Stephens --- .github/workflows/staging-release.yaml | 34 ++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/.github/workflows/staging-release.yaml b/.github/workflows/staging-release.yaml index b87633a50af..303d60d5b92 100644 --- a/.github/workflows/staging-release.yaml +++ b/.github/workflows/staging-release.yaml @@ -504,6 +504,7 @@ jobs: staging-release-images-latest-tags: # Only update latest tags for 3.1 releases if: startsWith(github.event.inputs.version, '3.1') + # if: startsWith(github.event.inputs.version, '4.0') name: Release latest Linux container images runs-on: ubuntu-latest needs: @@ -804,6 +805,7 @@ jobs: make_latest: false - name: Release 3.1 and latest + # TODO: change to 3.1 branch once 4.0 series is ready uses: softprops/action-gh-release@v2 if: startsWith(inputs.version, '3.1') with: @@ -814,6 +816,17 @@ jobs: tag_name: v${{ inputs.version }} make_latest: true + # - name: Release 4.0 and latest + # uses: softprops/action-gh-release@v2 + # if: startsWith(inputs.version, '4.0') + # with: + # body: "https://fluentbit.io/announcements/v${{ inputs.version }}/" + # draft: false + # generate_release_notes: true + # name: "Fluent Bit ${{ inputs.version }}" + # tag_name: v${{ inputs.version }} + # make_latest: true + staging-release-windows-checksums: name: Get Windows checksums for new release runs-on: ubuntu-22.04 @@ -903,15 +916,24 @@ jobs: uses: actions/checkout@v4 with: repository: fluent/fluent-bit-docs + ref: 3.0 token: ${{ secrets.GH_PA_TOKEN }} - name: Release 3.1 and latest + # TODO: change to 3.1 branch once 4.0 series is ready if: startsWith(inputs.version, '3.1') uses: actions/checkout@v4 with: repository: fluent/fluent-bit-docs token: ${{ secrets.GH_PA_TOKEN }} + # - name: Release 4.0 and latest + # if: startsWith(inputs.version, '4.0') + # uses: actions/checkout@v4 + # with: + # repository: fluent/fluent-bit-docs + # token: ${{ secrets.GH_PA_TOKEN }} + - name: Ensure we have the script we need run: | if [[ ! -f update-release-version-docs.sh ]] ; then @@ -984,15 +1006,23 @@ jobs: with: ref: 2.2 - - name: Release 3.0 not latest + - name: Release 3.0 if: startsWith(inputs.version, '3.0') uses: actions/checkout@v4 with: ref: 3.0 - - name: Release 3.1 latest + - name: Release 3.1 if: startsWith(inputs.version, '3.1') uses: actions/checkout@v4 + with: + ref: 3.1 + + - name: Release 4.0 + if: startsWith(inputs.version, '4.0') + uses: actions/checkout@v4 + with: + ref: master # Get the new version to use - name: 'Get next minor version' From 48684cf21ad9027b3e412c09b00530f8acab1c28 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Sun, 29 Sep 2024 13:35:32 -0600 Subject: [PATCH 266/295] motd: v3.2 Signed-off-by: Eduardo Silva --- include/fluent-bit/flb_motd.h | 57 ++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/include/fluent-bit/flb_motd.h b/include/fluent-bit/flb_motd.h index a21ddd93138..a9e8503fbbf 100644 --- a/include/fluent-bit/flb_motd.h +++ b/include/fluent-bit/flb_motd.h @@ -26,34 +26,35 @@ static unsigned char flb_motd_text[] = { 0x20, 0x20, 0x5f, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x20, 0x5f, 0x20, 0x5f, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x20, 0x20, 0x5f, - 0x5f, 0x20, 0x20, 0x0a, 0x7c, 0x20, 0x20, 0x5f, 0x5f, 0x5f, 0x7c, 0x20, - 0x7c, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x7c, 0x20, 0x7c, 0x20, 0x20, 0x20, 0x7c, - 0x20, 0x5f, 0x5f, 0x5f, 0x20, 0x28, 0x5f, 0x29, 0x20, 0x7c, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7c, 0x5f, 0x5f, 0x5f, 0x5f, - 0x20, 0x7c, 0x2f, 0x20, 0x20, 0x7c, 0x20, 0x0a, 0x7c, 0x20, 0x7c, 0x5f, - 0x20, 0x20, 0x7c, 0x20, 0x7c, 0x5f, 0x20, 0x20, 0x20, 0x5f, 0x20, 0x20, - 0x5f, 0x5f, 0x5f, 0x20, 0x5f, 0x20, 0x5f, 0x5f, 0x20, 0x7c, 0x20, 0x7c, - 0x5f, 0x20, 0x20, 0x7c, 0x20, 0x7c, 0x5f, 0x2f, 0x20, 0x2f, 0x5f, 0x7c, - 0x20, 0x7c, 0x5f, 0x20, 0x20, 0x5f, 0x5f, 0x20, 0x20, 0x20, 0x5f, 0x5f, - 0x20, 0x20, 0x20, 0x2f, 0x20, 0x2f, 0x60, 0x7c, 0x20, 0x7c, 0x20, 0x0a, - 0x7c, 0x20, 0x20, 0x5f, 0x7c, 0x20, 0x7c, 0x20, 0x7c, 0x20, 0x7c, 0x20, - 0x7c, 0x20, 0x7c, 0x2f, 0x20, 0x5f, 0x20, 0x5c, 0x20, 0x27, 0x5f, 0x20, - 0x5c, 0x7c, 0x20, 0x5f, 0x5f, 0x7c, 0x20, 0x7c, 0x20, 0x5f, 0x5f, 0x5f, - 0x20, 0x5c, 0x20, 0x7c, 0x20, 0x5f, 0x5f, 0x7c, 0x20, 0x5c, 0x20, 0x5c, - 0x20, 0x2f, 0x20, 0x2f, 0x20, 0x20, 0x20, 0x5c, 0x20, 0x5c, 0x20, 0x7c, - 0x20, 0x7c, 0x20, 0x0a, 0x7c, 0x20, 0x7c, 0x20, 0x20, 0x20, 0x7c, 0x20, - 0x7c, 0x20, 0x7c, 0x5f, 0x7c, 0x20, 0x7c, 0x20, 0x20, 0x5f, 0x5f, 0x2f, - 0x20, 0x7c, 0x20, 0x7c, 0x20, 0x7c, 0x20, 0x7c, 0x5f, 0x20, 0x20, 0x7c, - 0x20, 0x7c, 0x5f, 0x2f, 0x20, 0x2f, 0x20, 0x7c, 0x20, 0x7c, 0x5f, 0x20, - 0x20, 0x20, 0x5c, 0x20, 0x56, 0x20, 0x2f, 0x2e, 0x5f, 0x5f, 0x5f, 0x2f, - 0x20, 0x2f, 0x5f, 0x7c, 0x20, 0x7c, 0x5f, 0x0a, 0x5c, 0x5f, 0x7c, 0x20, - 0x20, 0x20, 0x7c, 0x5f, 0x7c, 0x5c, 0x5f, 0x5f, 0x2c, 0x5f, 0x7c, 0x5c, - 0x5f, 0x5f, 0x5f, 0x7c, 0x5f, 0x7c, 0x20, 0x7c, 0x5f, 0x7c, 0x5c, 0x5f, - 0x5f, 0x7c, 0x20, 0x5c, 0x5f, 0x5f, 0x5f, 0x5f, 0x2f, 0x7c, 0x5f, 0x7c, - 0x5c, 0x5f, 0x5f, 0x7c, 0x20, 0x20, 0x20, 0x5c, 0x5f, 0x2f, 0x20, 0x5c, - 0x5f, 0x5f, 0x5f, 0x5f, 0x28, 0x5f, 0x29, 0x5f, 0x5f, 0x5f, 0x2f, 0x0a, - 0x0a, 0x00 + 0x5f, 0x5f, 0x5f, 0x5f, 0x20, 0x0a, 0x7c, 0x20, 0x20, 0x5f, 0x5f, 0x5f, + 0x7c, 0x20, 0x7c, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7c, 0x20, 0x7c, 0x20, 0x20, + 0x20, 0x7c, 0x20, 0x5f, 0x5f, 0x5f, 0x20, 0x28, 0x5f, 0x29, 0x20, 0x7c, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7c, 0x5f, 0x5f, + 0x5f, 0x5f, 0x20, 0x7c, 0x2f, 0x20, 0x5f, 0x5f, 0x20, 0x20, 0x5c, 0x0a, + 0x7c, 0x20, 0x7c, 0x5f, 0x20, 0x20, 0x7c, 0x20, 0x7c, 0x5f, 0x20, 0x20, + 0x20, 0x5f, 0x20, 0x20, 0x5f, 0x5f, 0x5f, 0x20, 0x5f, 0x20, 0x5f, 0x5f, + 0x20, 0x7c, 0x20, 0x7c, 0x5f, 0x20, 0x20, 0x7c, 0x20, 0x7c, 0x5f, 0x2f, + 0x20, 0x2f, 0x5f, 0x7c, 0x20, 0x7c, 0x5f, 0x20, 0x20, 0x5f, 0x5f, 0x20, + 0x20, 0x20, 0x5f, 0x5f, 0x20, 0x20, 0x20, 0x2f, 0x20, 0x2f, 0x60, 0x27, + 0x20, 0x2f, 0x20, 0x2f, 0x27, 0x0a, 0x7c, 0x20, 0x20, 0x5f, 0x7c, 0x20, + 0x7c, 0x20, 0x7c, 0x20, 0x7c, 0x20, 0x7c, 0x20, 0x7c, 0x2f, 0x20, 0x5f, + 0x20, 0x5c, 0x20, 0x27, 0x5f, 0x20, 0x5c, 0x7c, 0x20, 0x5f, 0x5f, 0x7c, + 0x20, 0x7c, 0x20, 0x5f, 0x5f, 0x5f, 0x20, 0x5c, 0x20, 0x7c, 0x20, 0x5f, + 0x5f, 0x7c, 0x20, 0x5c, 0x20, 0x5c, 0x20, 0x2f, 0x20, 0x2f, 0x20, 0x20, + 0x20, 0x5c, 0x20, 0x5c, 0x20, 0x20, 0x2f, 0x20, 0x2f, 0x20, 0x20, 0x0a, + 0x7c, 0x20, 0x7c, 0x20, 0x20, 0x20, 0x7c, 0x20, 0x7c, 0x20, 0x7c, 0x5f, + 0x7c, 0x20, 0x7c, 0x20, 0x20, 0x5f, 0x5f, 0x2f, 0x20, 0x7c, 0x20, 0x7c, + 0x20, 0x7c, 0x20, 0x7c, 0x5f, 0x20, 0x20, 0x7c, 0x20, 0x7c, 0x5f, 0x2f, + 0x20, 0x2f, 0x20, 0x7c, 0x20, 0x7c, 0x5f, 0x20, 0x20, 0x20, 0x5c, 0x20, + 0x56, 0x20, 0x2f, 0x2e, 0x5f, 0x5f, 0x5f, 0x2f, 0x20, 0x2f, 0x2e, 0x2f, + 0x20, 0x2f, 0x5f, 0x5f, 0x5f, 0x0a, 0x5c, 0x5f, 0x7c, 0x20, 0x20, 0x20, + 0x7c, 0x5f, 0x7c, 0x5c, 0x5f, 0x5f, 0x2c, 0x5f, 0x7c, 0x5c, 0x5f, 0x5f, + 0x5f, 0x7c, 0x5f, 0x7c, 0x20, 0x7c, 0x5f, 0x7c, 0x5c, 0x5f, 0x5f, 0x7c, + 0x20, 0x5c, 0x5f, 0x5f, 0x5f, 0x5f, 0x2f, 0x7c, 0x5f, 0x7c, 0x5c, 0x5f, + 0x5f, 0x7c, 0x20, 0x20, 0x20, 0x5c, 0x5f, 0x2f, 0x20, 0x5c, 0x5f, 0x5f, + 0x5f, 0x5f, 0x28, 0x5f, 0x29, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x2f, 0x0a, + 0x0a, 0x0a, }; #endif From 8fc1d25873ecbd430448e050ae2579a99fca1deb Mon Sep 17 00:00:00 2001 From: Stewart Webb Date: Thu, 23 May 2024 08:52:31 +1000 Subject: [PATCH 267/295] in_opentelemetry: add tag_from_uri support to http2 codepath tags are still v1_logs/v1_metrics/v1_traces even in gRPC cases Signed-off-by: Stewart Webb --- plugins/in_opentelemetry/opentelemetry_prot.c | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/plugins/in_opentelemetry/opentelemetry_prot.c b/plugins/in_opentelemetry/opentelemetry_prot.c index c1a45c41967..791db4d3f6b 100644 --- a/plugins/in_opentelemetry/opentelemetry_prot.c +++ b/plugins/in_opentelemetry/opentelemetry_prot.c @@ -2423,6 +2423,7 @@ int opentelemetry_prot_handle_ng(struct flb_http_request *request, int grpc_request; struct flb_opentelemetry *context; int result = -1; + flb_sds_t tag; context = (struct flb_opentelemetry *) response->stream->user_data; @@ -2466,19 +2467,37 @@ int opentelemetry_prot_handle_ng(struct flb_http_request *request, strcmp(request->path, "/opentelemetry.proto.collector.metric.v1.MetricService/Export") == 0 || strcmp(request->path, "/opentelemetry.proto.collector.metrics.v1.MetricsService/Export") == 0) { payload_type = 'M'; - result = process_payload_metrics_ng(context, context->ins->tag, request, response); + if (context->tag_from_uri == FLB_TRUE) { + tag = flb_sds_create("v1_metrics"); + } + else { + tag = flb_sds_create(context->ins->tag); + } + result = process_payload_metrics_ng(context, tag, request, response); } else if (strcmp(request->path, "/v1/traces") == 0 || strcmp(request->path, "/opentelemetry.proto.collector.trace.v1.TraceService/Export") == 0 || strcmp(request->path, "/opentelemetry.proto.collector.traces.v1.TracesService/Export") == 0) { payload_type = 'T'; - result = process_payload_traces_ng(context, context->ins->tag, request, response); + if (context->tag_from_uri == FLB_TRUE) { + tag = flb_sds_create("v1_traces"); + } + else { + tag = flb_sds_create(context->ins->tag); + } + result = process_payload_traces_ng(context, tag, request, response); } else if (strcmp(request->path, "/v1/logs") == 0 || strcmp(request->path, "/opentelemetry.proto.collector.log.v1.LogService/Export") == 0 || strcmp(request->path, "/opentelemetry.proto.collector.logs.v1.LogsService/Export") == 0) { payload_type = 'L'; - result = process_payload_logs_ng(context, context->ins->tag, request, response); + if (context->tag_from_uri == FLB_TRUE) { + tag = flb_sds_create("v1_logs"); + } + else { + tag = flb_sds_create(context->ins->tag); + } + result = process_payload_logs_ng(context, tag, request, response); } if (grpc_request) { @@ -2493,5 +2512,7 @@ int opentelemetry_prot_handle_ng(struct flb_http_request *request, } } + flb_sds_destroy(tag); + return result; } From 7869189100709b4d74a70e5603ac54a8496888ad Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Tue, 8 Oct 2024 21:27:36 -0600 Subject: [PATCH 268/295] motd: add missing null character Signed-off-by: Eduardo Silva --- include/fluent-bit/flb_motd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fluent-bit/flb_motd.h b/include/fluent-bit/flb_motd.h index a9e8503fbbf..da5392e494e 100644 --- a/include/fluent-bit/flb_motd.h +++ b/include/fluent-bit/flb_motd.h @@ -54,7 +54,7 @@ static unsigned char flb_motd_text[] = { 0x20, 0x5c, 0x5f, 0x5f, 0x5f, 0x5f, 0x2f, 0x7c, 0x5f, 0x7c, 0x5c, 0x5f, 0x5f, 0x7c, 0x20, 0x20, 0x20, 0x5c, 0x5f, 0x2f, 0x20, 0x5c, 0x5f, 0x5f, 0x5f, 0x5f, 0x28, 0x5f, 0x29, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x2f, 0x0a, - 0x0a, 0x0a, + 0x0a, 0x0a, 0x00, }; #endif From d26ac5a1b4ccf5fb324c47fb6f5d26a70848603d Mon Sep 17 00:00:00 2001 From: Patrick Stephens Date: Mon, 23 Sep 2024 10:57:53 +0100 Subject: [PATCH 269/295] cmake: update emails and urls for Chronosphere Signed-off-by: Patrick Stephens --- CMakeLists.txt | 4 ++-- MAINTAINERS.md | 8 ++++---- dockerfiles/Dockerfile | 8 ++++---- dockerfiles/Dockerfile.windows | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e42d4faffc..9e6c5ac2613 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1149,8 +1149,8 @@ set(CPACK_PACKAGE_VERSION ${FLB_VERSION_STR}) set(CPACK_PACKAGE_NAME "fluent-bit") set(CPACK_PACKAGE_RELEASE 1) -set(CPACK_PACKAGE_CONTACT "Eduardo Silva ") -set(CPACK_PACKAGE_VENDOR "Calyptia Inc.") +set(CPACK_PACKAGE_CONTACT "Eduardo Silva ") +set(CPACK_PACKAGE_VENDOR "Chronosphere Inc.") set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") set(CPACK_PACKAGING_INSTALL_PREFIX "/") diff --git a/MAINTAINERS.md b/MAINTAINERS.md index a97bc49ad34..3866eaef5c0 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -4,12 +4,12 @@ Fluent Bit is developed and supported by many individuals and companies. The fo | Maintainer Name | Components | Company | | :---------------------------------------------------- | ------------------------ | ------------------------------------------------- | -| [Eduardo Silva](https://github.com/edsiper) | All | [Calyptia](https://calyptia.com) | -| [Leonardo Alminana](https://github.com/leonardo-albertovich) | All | [Calyptia](https://calyptia.com) | +| [Eduardo Silva](https://github.com/edsiper) | All | [Chronosphere](https://chronosphere.io) | +| [Leonardo Alminana](https://github.com/leonardo-albertovich) | All | [Chronosphere](https://chronosphere.io) | | [Masoud Koleini](https://github.com/koleini) | Stream Processor | [Arm](https://www.arm.com/) | -| [Hiroshi Hatake](https://github.com/cosmo0920) | All | [Calyptia](https://calyptia.com) | +| [Hiroshi Hatake](https://github.com/cosmo0920) | All | [Chronosphere](https://chronosphere.io) | | [Fujimoto Seiji](https://github.com/fujimotos) | Windows Platform | Individual | | [Wesley Pettit](https://github.com/PettitWesley) | Amazon Plugins (AWS) | [Amazon Web Services](https://aws.amazon.com/) | | [Cedric Lamoriniere](https://github.com/clamoriniere) | Datadog Output Plugin | [Datadog](https://www.datadoghq.com/) | | [Jonathan Gonzalez V.](https://github.com/sxd) | PostgreSQL Output Plugin | [2ndQuadrant](https://www.2ndquadrant.com/en/) | -| [Jorge Niedbalski](https://github.com/niedbalski) | CI && Containers | [Calyptia](https://calyptia.com/) | +| [Jorge Niedbalski](https://github.com/niedbalski) | CI && Containers | [Chronosphere](https://chronosphere.io/) | diff --git a/dockerfiles/Dockerfile b/dockerfiles/Dockerfile index f068611e654..ba84ff7202d 100644 --- a/dockerfiles/Dockerfile +++ b/dockerfiles/Dockerfile @@ -162,7 +162,7 @@ ENV FLUENT_BIT_VERSION=${RELEASE_VERSION} LABEL description="Fluent Bit multi-architecture container image" \ vendor="Fluent Organization" \ version="${RELEASE_VERSION}" \ - author="Eduardo Silva " \ + author="Eduardo Silva " \ org.opencontainers.image.description="Fluent Bit container image" \ org.opencontainers.image.title="Fluent Bit" \ org.opencontainers.image.licenses="Apache-2.0" \ @@ -170,7 +170,7 @@ LABEL description="Fluent Bit multi-architecture container image" \ org.opencontainers.image.version="${RELEASE_VERSION}" \ org.opencontainers.image.source="https://github.com/fluent/fluent-bit" \ org.opencontainers.image.documentation="https://docs.fluentbit.io/" \ - org.opencontainers.image.authors="Eduardo Silva " + org.opencontainers.image.authors="Eduardo Silva " # Copy the libraries from the extractor stage into root COPY --from=deb-extractor /dpkg / @@ -193,7 +193,7 @@ ENV FLUENT_BIT_VERSION=${RELEASE_VERSION} LABEL description="Fluent Bit multi-architecture debug container image" \ vendor="Fluent Organization" \ version="${RELEASE_VERSION}-debug" \ - author="Eduardo Silva " \ + author="Eduardo Silva " \ org.opencontainers.image.description="Fluent Bit debug container image" \ org.opencontainers.image.title="Fluent Bit Debug" \ org.opencontainers.image.licenses="Apache-2.0" \ @@ -201,7 +201,7 @@ LABEL description="Fluent Bit multi-architecture debug container image" \ org.opencontainers.image.version="${RELEASE_VERSION}-debug" \ org.opencontainers.image.source="https://github.com/fluent/fluent-bit" \ org.opencontainers.image.documentation="https://docs.fluentbit.io/" \ - org.opencontainers.image.authors="Eduardo Silva " + org.opencontainers.image.authors="Eduardo Silva " COPY --from=qemu-arm32 /usr/bin/qemu-arm-static /usr/bin/ COPY --from=qemu-arm64 /usr/bin/qemu-aarch64-static /usr/bin/ diff --git a/dockerfiles/Dockerfile.windows b/dockerfiles/Dockerfile.windows index 14c901c4776..fceac524ecb 100644 --- a/dockerfiles/Dockerfile.windows +++ b/dockerfiles/Dockerfile.windows @@ -99,7 +99,7 @@ LABEL org.opencontainers.image.title="Fluent Bit" ` org.opencontainers.image.description="Fluent Bit is an open source and multi-platform Log Processor and Forwarder which allows you to collect data/logs from different sources, unify and send them to multiple destinations. It's fully compatible with Docker and Kubernetes environments." ` org.opencontainers.image.created=$IMAGE_CREATE_DATE ` org.opencontainers.image.version=$FLUENTBIT_VERSION ` - org.opencontainers.image.authors="Eduardo Silva " ` + org.opencontainers.image.authors="Eduardo Silva " ` org.opencontainers.image.url="https://hub.docker.com/r/fluent/fluent-bit" ` org.opencontainers.image.documentation="https://docs.fluentbit.io/manual/" ` org.opencontainers.image.vendor="Fluent Organization" ` From 91e987a7ab75505c9d332e39080c86f22ddcd3b2 Mon Sep 17 00:00:00 2001 From: Patrick Stephens Date: Mon, 23 Sep 2024 12:53:32 +0100 Subject: [PATCH 270/295] Update with review comments Signed-off-by: Patrick Stephens --- MAINTAINERS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINERS.md b/MAINTAINERS.md index 3866eaef5c0..9a4a68f5a14 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -12,4 +12,4 @@ Fluent Bit is developed and supported by many individuals and companies. The fo | [Wesley Pettit](https://github.com/PettitWesley) | Amazon Plugins (AWS) | [Amazon Web Services](https://aws.amazon.com/) | | [Cedric Lamoriniere](https://github.com/clamoriniere) | Datadog Output Plugin | [Datadog](https://www.datadoghq.com/) | | [Jonathan Gonzalez V.](https://github.com/sxd) | PostgreSQL Output Plugin | [2ndQuadrant](https://www.2ndquadrant.com/en/) | -| [Jorge Niedbalski](https://github.com/niedbalski) | CI && Containers | [Chronosphere](https://chronosphere.io/) | +| [Jorge Niedbalski](https://github.com/niedbalski) | CI && Containers | [Personal Blog](https://niedbalski.dev/) | From 380b9911ac85e579c0e251d2859a8216e07092ab Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Fri, 4 Oct 2024 16:11:47 -0600 Subject: [PATCH 271/295] in_opentelemetry: add support for HTTP/1.1 chunked transfer encoding Signed-off-by: Eduardo Silva --- plugins/in_opentelemetry/opentelemetry_prot.c | 42 ++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/plugins/in_opentelemetry/opentelemetry_prot.c b/plugins/in_opentelemetry/opentelemetry_prot.c index 791db4d3f6b..451ceeab3c9 100644 --- a/plugins/in_opentelemetry/opentelemetry_prot.c +++ b/plugins/in_opentelemetry/opentelemetry_prot.c @@ -1785,14 +1785,16 @@ int opentelemetry_prot_handle(struct flb_opentelemetry *ctx, struct http_conn *c int len; char *uri; char *qs; + char *out_chunked = NULL; + size_t out_chunked_size = 0; off_t diff; + size_t tag_len; flb_sds_t tag; - struct mk_http_header *header; - char *original_data; + char *original_data = NULL; size_t original_data_size; - char *uncompressed_data; + char *uncompressed_data = NULL; size_t uncompressed_data_size; - size_t tag_len; + struct mk_http_header *header; if (request->uri.data[0] != '/') { send_response(conn, 400, "error: invalid request\n"); @@ -1902,6 +1904,32 @@ int opentelemetry_prot_handle(struct flb_opentelemetry *ctx, struct http_conn *c request->data.len = uncompressed_data_size; } + /* check if the request comes with chunked transfer encoding */ + if (mk_http_parser_is_content_chunked(&session->parser)) { + out_chunked = NULL; + out_chunked_size = 0; + + /* decode the chunks */ + ret = mk_http_parser_chunked_decode(&session->parser, + request->data.data, + request->data.len, + &out_chunked, + &out_chunked_size); + if (ret == -1) { + flb_sds_destroy(tag); + mk_mem_free(uri); + send_response(conn, 400, "error: invalid chunked data\n"); + if (uncompressed_data != NULL) { + flb_free(uncompressed_data); + } + return -1; + } + else { + request->data.data = out_chunked; + request->data.len = out_chunked_size; + } + } + if (strcmp(uri, "/v1/metrics") == 0) { ret = process_payload_metrics(ctx, conn, tag, tag_len, session, request); } @@ -1919,6 +1947,10 @@ int opentelemetry_prot_handle(struct flb_opentelemetry *ctx, struct http_conn *c request->data.data = original_data; request->data.len = original_data_size; + if (out_chunked != NULL) { + mk_mem_free(out_chunked); + } + mk_mem_free(uri); flb_sds_destroy(tag); @@ -2423,7 +2455,7 @@ int opentelemetry_prot_handle_ng(struct flb_http_request *request, int grpc_request; struct flb_opentelemetry *context; int result = -1; - flb_sds_t tag; + flb_sds_t tag = NULL; context = (struct flb_opentelemetry *) response->stream->user_data; From 229d566b9db1adf840f6e9ff27ac0c9c5baa9385 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Fri, 4 Oct 2024 16:54:00 -0600 Subject: [PATCH 272/295] in_splunk: add support for HTTP/1.1 chunked transfer encoding Signed-off-by: Eduardo Silva --- plugins/in_splunk/splunk_conn.c | 7 +++- plugins/in_splunk/splunk_prot.c | 62 ++++++++++++++++++++++++++++++--- 2 files changed, 64 insertions(+), 5 deletions(-) diff --git a/plugins/in_splunk/splunk_conn.c b/plugins/in_splunk/splunk_conn.c index 13bf4f0e16c..8294b1112b3 100644 --- a/plugins/in_splunk/splunk_conn.c +++ b/plugins/in_splunk/splunk_conn.c @@ -29,6 +29,7 @@ static void splunk_conn_request_init(struct mk_http_session *session, static int splunk_conn_event(void *data) { + int ret; int status; size_t size; ssize_t available; @@ -95,7 +96,11 @@ static int splunk_conn_event(void *data) if (status == MK_HTTP_PARSER_OK) { /* Do more logic parsing and checks for this request */ - splunk_prot_handle(ctx, conn, &conn->session, &conn->request); + ret = splunk_prot_handle(ctx, conn, &conn->session, &conn->request); + if (ret == -1) { + splunk_conn_del(conn); + return -1; + } /* Evict the processed request from the connection buffer and reinitialize * the HTTP parser. diff --git a/plugins/in_splunk/splunk_prot.c b/plugins/in_splunk/splunk_prot.c index cf614b06679..b550452ff73 100644 --- a/plugins/in_splunk/splunk_prot.c +++ b/plugins/in_splunk/splunk_prot.c @@ -592,7 +592,7 @@ static int process_hec_payload(struct flb_splunk *ctx, struct splunk_conn *conn, type = HTTP_CONTENT_UNKNOWN; } - if (request->data.len <= 0) { + if (request->data.len <= 0 && !mk_http_parser_is_content_chunked(&session->parser)) { send_response(conn, 400, "error: no payload found\n"); return -2; } @@ -658,8 +658,8 @@ static int process_hec_raw_payload(struct flb_splunk *ctx, struct splunk_conn *c flb_plg_debug(ctx->ins, "Mark as unknown type for ingested payloads"); } - if (request->data.len <= 0) { - send_response(conn, 400, "error: no payload found\n"); + if (request->data.len <= 0 && !mk_http_parser_is_content_chunked(&session->parser)) { + send_response(conn, 400, "2 error: no payload found\n"); return -1; } @@ -709,6 +709,10 @@ int splunk_prot_handle(struct flb_splunk *ctx, struct splunk_conn *conn, int len; char *uri; char *qs; + char *original_data = NULL; + size_t original_data_size; + char *out_chunked = NULL; + size_t out_chunked_size = 0; off_t diff; flb_sds_t tag; struct mk_http_header *header; @@ -830,6 +834,32 @@ int splunk_prot_handle(struct flb_splunk *ctx, struct splunk_conn *conn, return -1; } + /* If the request contains chunked transfer encoded data, decode it */\ + if (mk_http_parser_is_content_chunked(&session->parser)) { + ret = mk_http_parser_chunked_decode(&session->parser, + conn->buf_data, + conn->buf_len, + &out_chunked, + &out_chunked_size); + if (ret == -1) { + flb_plg_error(ctx->ins, "failed to decode chunked data"); + send_response(conn, 400, "error: invalid chunked data\n"); + + flb_sds_destroy(tag); + mk_mem_free(uri); + + return -1; + } + + /* Update the request data */ + original_data = request->data.data; + original_data_size = request->data.len; + + /* assign the chunked one */ + request->data.data = out_chunked; + request->data.len = out_chunked_size; + } + /* Handle every ingested payload cleanly */ flb_log_event_encoder_reset(&ctx->log_encoder); @@ -846,12 +876,18 @@ int splunk_prot_handle(struct flb_splunk *ctx, struct splunk_conn *conn, else if (strcasecmp(uri, "/services/collector/event/1.0") == 0 || strcasecmp(uri, "/services/collector/event") == 0 || strcasecmp(uri, "/services/collector") == 0) { - ret = process_hec_payload(ctx, conn, tag, session, request); + ret = process_hec_payload(ctx, conn, tag, session, request); if (ret == -2) { flb_sds_destroy(tag); mk_mem_free(uri); + if (out_chunked) { + mk_mem_free(out_chunked); + } + request->data.data = original_data; + request->data.len = original_data_size; + return -1; } @@ -866,6 +902,12 @@ int splunk_prot_handle(struct flb_splunk *ctx, struct splunk_conn *conn, flb_sds_destroy(tag); mk_mem_free(uri); + if (out_chunked) { + mk_mem_free(out_chunked); + } + request->data.data = original_data; + request->data.len = original_data_size; + return -1; } } @@ -875,6 +917,12 @@ int splunk_prot_handle(struct flb_splunk *ctx, struct splunk_conn *conn, flb_sds_destroy(tag); mk_mem_free(uri); + if (out_chunked) { + mk_mem_free(out_chunked); + } + request->data.data = original_data; + request->data.len = original_data_size; + send_response(conn, 400, "error: invalid HTTP method\n"); return -1; } @@ -882,6 +930,12 @@ int splunk_prot_handle(struct flb_splunk *ctx, struct splunk_conn *conn, flb_sds_destroy(tag); mk_mem_free(uri); + if (out_chunked) { + mk_mem_free(out_chunked); + } + request->data.data = original_data; + request->data.len = original_data_size; + return ret; } From c0d8bcb444386b08c8cf6209863529bbe5172551 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Sat, 5 Oct 2024 10:23:30 -0600 Subject: [PATCH 273/295] in_http: add support for HTTP/1.1 chunked transfer encoding Signed-off-by: Eduardo Silva --- plugins/in_http/http_prot.c | 42 +++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/plugins/in_http/http_prot.c b/plugins/in_http/http_prot.c index e5a3b6bee99..7c3a96f6c9b 100644 --- a/plugins/in_http/http_prot.c +++ b/plugins/in_http/http_prot.c @@ -276,6 +276,8 @@ int process_pack(struct flb_http *ctx, flb_sds_t tag, char *buf, size_t size) msgpack_unpacked_init(&result); while (msgpack_unpack_next(&result, buf, size, &off) == MSGPACK_UNPACK_SUCCESS) { + obj = &result.data; + if (result.data.type == MSGPACK_OBJECT_MAP) { tag_from_record = NULL; if (ctx->tag_key) { @@ -301,7 +303,6 @@ int process_pack(struct flb_http *ctx, flb_sds_t tag, char *buf, size_t size) flb_log_event_encoder_reset(&ctx->log_encoder); } else if (result.data.type == MSGPACK_OBJECT_ARRAY) { - obj = &result.data; for (i = 0; i < obj->via.array.size; i++) { record = obj->via.array.ptr[i]; @@ -382,6 +383,7 @@ static ssize_t parse_payload_json(struct flb_http *ctx, flb_sds_t tag, return -1; } else if (ret == -1) { + flb_plg_warn(ctx->ins, "error parsing JSON message, skipping"); return -1; } @@ -515,6 +517,10 @@ static int process_payload(struct flb_http *ctx, struct http_conn *conn, { int ret = -1; int type = -1; + char *original_data; + size_t original_data_size; + char *out_chunked = NULL; + size_t out_chunked_size; struct mk_http_header *header; header = &session->parser.headers[MK_HEADER_CONTENT_TYPE]; @@ -523,8 +529,8 @@ static int process_payload(struct flb_http *ctx, struct http_conn *conn, return -1; } - if ((header->val.len == 16 && strncasecmp(header->val.data, "application/json", 16) == 0) || - (header->val.len > 16 && (strncasecmp(header->val.data, "application/json ", 17) == 0) || + if (((header->val.len == 16 && strncasecmp(header->val.data, "application/json", 16) == 0)) || + ((header->val.len > 16 && (strncasecmp(header->val.data, "application/json ", 17) == 0)) || strncasecmp(header->val.data, "application/json;", 17) == 0)) { type = HTTP_CONTENT_JSON; } @@ -539,11 +545,33 @@ static int process_payload(struct flb_http *ctx, struct http_conn *conn, return -1; } - if (request->data.len <= 0) { + if (request->data.len <= 0 && !mk_http_parser_is_content_chunked(&session->parser)) { send_response(conn, 400, "error: no payload found\n"); return -1; } + /* content: check if the data comes in chunks (transfer-encoding: chunked) */ + if (mk_http_parser_is_content_chunked(&session->parser)) { + ret = mk_http_parser_chunked_decode(&session->parser, + conn->buf_data, + conn->buf_len, + &out_chunked, + &out_chunked_size); + + if (ret == -1) { + send_response(conn, 400, "error: invalid chunked data\n"); + return -1; + } + + /* link the decoded data */ + original_data = request->data.data; + original_data_size = request->data.len; + + request->data.data = out_chunked; + request->data.len = out_chunked_size; + } + + if (type == HTTP_CONTENT_JSON) { ret = parse_payload_json(ctx, tag, request->data.data, request->data.len); } @@ -551,6 +579,12 @@ static int process_payload(struct flb_http *ctx, struct http_conn *conn, ret = parse_payload_urlencoded(ctx, tag, request->data.data, request->data.len); } + if (out_chunked) { + mk_mem_free(out_chunked); + request->data.data = original_data; + request->data.len = original_data_size; + } + if (ret != 0) { send_response(conn, 400, "error: invalid payload\n"); return -1; From e880324b6f689dc4f8af0f0fd6f46348c7f1db50 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Wed, 9 Oct 2024 12:31:41 -0600 Subject: [PATCH 274/295] http_server: http1: add chunked transfer encoding support Signed-off-by: Eduardo Silva --- src/http_server/flb_http_server_http1.c | 134 +++++++++++++++--------- 1 file changed, 87 insertions(+), 47 deletions(-) diff --git a/src/http_server/flb_http_server_http1.c b/src/http_server/flb_http_server_http1.c index 6a61d2a3e93..e5fcba9114d 100644 --- a/src/http_server/flb_http_server_http1.c +++ b/src/http_server/flb_http_server_http1.c @@ -21,7 +21,7 @@ /* PRIVATE */ -static void dummy_mk_http_session_init(struct mk_http_session *session, +static void dummy_mk_http_session_init(struct mk_http_session *session, struct mk_server *server) { session->_sched_init = MK_TRUE; @@ -94,7 +94,7 @@ static int http1_evict_request(struct flb_http1_server_session *session) request_end += content_length; } else { - request_end = (uintptr_t) strstr(session_buffer, + request_end = (uintptr_t) strstr(session_buffer, "\r\n\r\n"); if(request_end != 0) { @@ -119,7 +119,7 @@ static int http1_evict_request(struct flb_http1_server_session *session) else { session_buffer_length -= request_length; - memmove(session_buffer, + memmove(session_buffer, &session_buffer[request_length], session_buffer_length); @@ -137,6 +137,8 @@ static int http1_session_process_request(struct flb_http1_server_session *sessio struct mk_list *iterator; struct mk_http_header *header; int result; + size_t chunked_size; + size_t written_bytes = 0; result = flb_http_request_init(&session->stream.request); @@ -148,16 +150,16 @@ static int http1_session_process_request(struct flb_http1_server_session *sessio if (session->inner_request.uri_processed.data != NULL) { session->stream.request.path = \ - cfl_sds_create_len(session->inner_request.uri_processed.data, + cfl_sds_create_len(session->inner_request.uri_processed.data, session->inner_request.uri_processed.len); } else { session->stream.request.path = \ - cfl_sds_create_len(session->inner_request.uri.data, + cfl_sds_create_len(session->inner_request.uri.data, session->inner_request.uri.len); } - if (session->stream.request.path == NULL) { + if (session->stream.request.path == NULL) { return -1; } @@ -201,7 +203,7 @@ static int http1_session_process_request(struct flb_http1_server_session *sessio session->stream.request.content_length = session->inner_request.content_length; - mk_list_foreach(iterator, + mk_list_foreach(iterator, &session->inner_parser.header_list) { header = mk_list_entry(iterator, struct mk_http_header, _head); @@ -209,34 +211,34 @@ static int http1_session_process_request(struct flb_http1_server_session *sessio header->val.data != NULL && header->val.len > 0) { if (flb_http_server_strncasecmp( - (const uint8_t *) header->key.data, - header->key.len, + (const uint8_t *) header->key.data, + header->key.len, "host", 0) == 0) { session->stream.request.host = \ - cfl_sds_create_len((const char *) header->val.data, + cfl_sds_create_len((const char *) header->val.data, header->val.len); - + if (session->stream.request.host == NULL) { return -1; } } else if (flb_http_server_strncasecmp( - (const uint8_t *) header->key.data, - header->key.len, + (const uint8_t *) header->key.data, + header->key.len, "content-type", 0) == 0) { session->stream.request.content_type = \ - cfl_sds_create_len((const char *) header->val.data, + cfl_sds_create_len((const char *) header->val.data, header->val.len); - + if (session->stream.request.content_type == NULL) { return -1; } } - result = flb_http_request_set_header(&session->stream.request, - header->key.data, - header->key.len, - (void *) header->val.data, + result = flb_http_request_set_header(&session->stream.request, + header->key.data, + header->key.len, + (void *) header->val.data, header->val.len); if (result != 0) { @@ -253,9 +255,41 @@ static int http1_session_process_request(struct flb_http1_server_session *sessio } } - if (session->inner_request.data.data != NULL) { + /* If the content comes in chunks (transfer-encoding: chunked) */ + if (mk_http_parser_is_content_chunked(&session->inner_parser)) { + /* Get the total size of all the chunks */ + chunked_size = mk_http_parser_content_length(&session->inner_parser); + if (chunked_size == 0) { + session->stream.status = HTTP_STREAM_STATUS_ERROR; + return -1; + } + + /* allocate a buffer to get a copy of the decoded chunks */ + session->stream.request.body = cfl_sds_create_size(chunked_size); + if (!session->stream.request.body) { + session->stream.status = HTTP_STREAM_STATUS_ERROR; + return -1; + } + + /* decode the data into the new buffer */ + result = mk_http_parser_chunked_decode_buf(&session->inner_parser, + session->parent->incoming_data, + cfl_sds_len(session->parent->incoming_data), + session->stream.request.body, + chunked_size, + &written_bytes); + if (result == -1) { + session->stream.status = HTTP_STREAM_STATUS_ERROR; + cfl_sds_destroy(session->stream.request.body); + session->stream.request.body = NULL; + return -1; + } + + cfl_sds_len_set(session->stream.request.body, written_bytes); + } + else if (session->inner_request.data.data != NULL) { session->stream.request.body = \ - cfl_sds_create_len(session->inner_request.data.data, + cfl_sds_create_len(session->inner_request.data.data, session->inner_request.data.len); if (session->stream.request.body == NULL) { @@ -271,7 +305,7 @@ static int http1_session_process_request(struct flb_http1_server_session *sessio cfl_list_del(&session->stream.request._head); } - cfl_list_add(&session->stream.request._head, + cfl_list_add(&session->stream.request._head, &session->parent->request_queue); return 0; @@ -280,7 +314,7 @@ static int http1_session_process_request(struct flb_http1_server_session *sessio /* RESPONSE */ struct flb_http_response *flb_http1_response_begin( - struct flb_http1_server_session *session, + struct flb_http1_server_session *session, struct flb_http_stream *stream) { int result; @@ -344,8 +378,8 @@ int flb_http1_response_commit(struct flb_http_response *response) } mk_list_foreach(header_iterator, &response->headers->entries) { - header_entry = mk_list_entry(header_iterator, - struct flb_hash_table_entry, + header_entry = mk_list_entry(header_iterator, + struct flb_hash_table_entry, _head_parent); if (header_entry == NULL) { @@ -354,11 +388,11 @@ int flb_http1_response_commit(struct flb_http_response *response) return -5; } - sds_result = cfl_sds_printf(&response_buffer, - "%.*s: %.*s\r\n", - (int) header_entry->key_len, - (const char *) header_entry->key, - (int) header_entry->val_size, + sds_result = cfl_sds_printf(&response_buffer, + "%.*s: %.*s\r\n", + (int) header_entry->key_len, + (const char *) header_entry->key, + (int) header_entry->val_size, (const char *) header_entry->val); if (sds_result == NULL) { @@ -377,7 +411,7 @@ int flb_http1_response_commit(struct flb_http_response *response) } if (response->body != NULL) { - sds_result = cfl_sds_cat(response_buffer, + sds_result = cfl_sds_cat(response_buffer, response->body, cfl_sds_len(response->body)); @@ -386,12 +420,12 @@ int flb_http1_response_commit(struct flb_http_response *response) return -8; } - + response_buffer = sds_result; } - sds_result = cfl_sds_cat(session->parent->outgoing_data, - response_buffer, + sds_result = cfl_sds_cat(session->parent->outgoing_data, + response_buffer, cfl_sds_len(response_buffer)); cfl_sds_destroy(response_buffer); @@ -406,13 +440,13 @@ int flb_http1_response_commit(struct flb_http_response *response) } -int flb_http1_response_set_header(struct flb_http_response *response, +int flb_http1_response_set_header(struct flb_http_response *response, char *name, size_t name_length, char *value, size_t value_length) { int result; - result = flb_hash_table_add(response->headers, + result = flb_hash_table_add(response->headers, (const char *) name, (int) name_length, (void *) value, (ssize_t) value_length); @@ -423,13 +457,13 @@ int flb_http1_response_set_header(struct flb_http_response *response, return 0; } -int flb_http1_response_set_status(struct flb_http_response *response, +int flb_http1_response_set_status(struct flb_http_response *response, int status) { return 0; } -int flb_http1_response_set_body(struct flb_http_response *response, +int flb_http1_response_set_body(struct flb_http_response *response, unsigned char *body, size_t body_length) { return 0; @@ -437,7 +471,7 @@ int flb_http1_response_set_body(struct flb_http_response *response, /* SESSION */ -int flb_http1_server_session_init(struct flb_http1_server_session *session, +int flb_http1_server_session_init(struct flb_http1_server_session *session, struct flb_http_server_session *parent) { void *user_data; @@ -486,15 +520,15 @@ void flb_http1_server_session_destroy(struct flb_http1_server_session *session) } int flb_http1_server_session_ingest(struct flb_http1_server_session *session, - unsigned char *buffer, - size_t length) + unsigned char *buffer, + size_t length) { int result; - result = mk_http_parser(&session->inner_request, - &session->inner_parser, - session->parent->incoming_data, - cfl_sds_len(session->parent->incoming_data), + result = mk_http_parser(&session->inner_request, + &session->inner_parser, + session->parent->incoming_data, + cfl_sds_len(session->parent->incoming_data), &session->inner_server); if (result == MK_HTTP_PARSER_OK) { @@ -508,10 +542,16 @@ int flb_http1_server_session_ingest(struct flb_http1_server_session *session, http1_evict_request(session); } + else if (result == MK_HTTP_PARSER_PENDING) { + /* + * If the parser is still in a pending state, we just return a success + * status and wait for more data + */ + return HTTP_SERVER_SUCCESS; + } dummy_mk_http_request_init(&session->inner_session, &session->inner_request); - mk_http_parser_init(&session->inner_parser); - return HTTP_SERVER_SUCCESS; + return HTTP_SERVER_SUCCESS; } From 60492b51d370caef3c8051cde481cdf7578defb9 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Wed, 9 Oct 2024 16:09:45 -0600 Subject: [PATCH 275/295] in_splunk: adjust HTTP/1.1 buffer based on the request size Signed-off-by: Eduardo Silva --- plugins/in_splunk/splunk_conn.c | 64 ++++++++++++++++----------------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/plugins/in_splunk/splunk_conn.c b/plugins/in_splunk/splunk_conn.c index 8294b1112b3..4c25f8d8e5a 100644 --- a/plugins/in_splunk/splunk_conn.c +++ b/plugins/in_splunk/splunk_conn.c @@ -35,7 +35,6 @@ static int splunk_conn_event(void *data) ssize_t available; ssize_t bytes; char *tmp; - char *request_end; size_t request_len; struct flb_connection *connection; struct splunk_conn *conn; @@ -102,47 +101,44 @@ static int splunk_conn_event(void *data) return -1; } - /* Evict the processed request from the connection buffer and reinitialize + /* + * Evict the processed request from the connection buffer and reinitialize * the HTTP parser. */ - request_end = NULL; + /* Use the last parser position as the request length */ + request_len = mk_http_parser_request_size(&conn->session.parser, + conn->buf_data, + conn->buf_len); - if (NULL != conn->request.data.data) { - request_end = &conn->request.data.data[conn->request.data.len]; + if (request_len == -1 || (request_len > conn->buf_len)) { + /* Unexpected but let's make sure things are safe */ + conn->buf_len = 0; + flb_plg_debug(ctx->ins, "request length exceeds buffer length, closing connection"); + splunk_conn_del(conn); + return -1; } - else { - request_end = strstr(conn->buf_data, "\r\n\r\n"); - if(NULL != request_end) { - request_end = &request_end[4]; - } - } + /* If we have extra bytes in our bytes, adjust the extra bytes */ + if (0 < (conn->buf_len - request_len)) { + memmove(conn->buf_data, &conn->buf_data[request_len], + conn->buf_len - request_len); - if (NULL != request_end) { - request_len = (size_t)(request_end - conn->buf_data); - - if (0 < (conn->buf_len - request_len)) { - memmove(conn->buf_data, &conn->buf_data[request_len], - conn->buf_len - request_len); - - conn->buf_data[conn->buf_len - request_len] = '\0'; - conn->buf_len -= request_len; - } - else { - memset(conn->buf_data, 0, request_len); - - conn->buf_len = 0; - } - - /* Reinitialize the parser so the next request is properly - * handled, the additional memset intends to wipe any left over data - * from the headers parsed in the previous request. - */ - memset(&conn->session.parser, 0, sizeof(struct mk_http_parser)); - mk_http_parser_init(&conn->session.parser); - splunk_conn_request_init(&conn->session, &conn->request); + conn->buf_data[conn->buf_len - request_len] = '\0'; + conn->buf_len -= request_len; + } + else { + memset(conn->buf_data, 0, request_len); + conn->buf_len = 0; } + + /* Reinitialize the parser so the next request is properly + * handled, the additional memset intends to wipe any left over data + * from the headers parsed in the previous request. + */ + memset(&conn->session.parser, 0, sizeof(struct mk_http_parser)); + mk_http_parser_init(&conn->session.parser); + splunk_conn_request_init(&conn->session, &conn->request); } else if (status == MK_HTTP_PARSER_ERROR) { splunk_prot_handle_error(ctx, conn, &conn->session, &conn->request); From 8eb41828b5d9c063ab2eae75e6bcdb4e35a425d2 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Wed, 9 Oct 2024 16:09:59 -0600 Subject: [PATCH 276/295] in_opentelemetry: adjust HTTP/1.1 buffer based on the request size Signed-off-by: Eduardo Silva --- plugins/in_opentelemetry/http_conn.c | 64 +++++++++---------- plugins/in_opentelemetry/opentelemetry_prot.c | 28 ++++---- 2 files changed, 44 insertions(+), 48 deletions(-) diff --git a/plugins/in_opentelemetry/http_conn.c b/plugins/in_opentelemetry/http_conn.c index 89410244bba..9d2865c2f71 100644 --- a/plugins/in_opentelemetry/http_conn.c +++ b/plugins/in_opentelemetry/http_conn.c @@ -35,7 +35,6 @@ static int opentelemetry_conn_event(void *data) ssize_t available; ssize_t bytes; char *tmp; - char *request_end; size_t request_len; struct http_conn *conn; struct mk_event *event; @@ -98,47 +97,44 @@ static int opentelemetry_conn_event(void *data) /* Do more logic parsing and checks for this request */ opentelemetry_prot_handle(ctx, conn, &conn->session, &conn->request); - /* Evict the processed request from the connection buffer and reinitialize + /* + * Evict the processed request from the connection buffer and reinitialize * the HTTP parser. */ - request_end = NULL; + /* Use the last parser position as the request length */ + request_len = mk_http_parser_request_size(&conn->session.parser, + conn->buf_data, + conn->buf_len); - if (NULL != conn->request.data.data) { - request_end = &conn->request.data.data[conn->request.data.len]; + if (request_len == -1 || (request_len > conn->buf_len)) { + /* Unexpected but let's make sure things are safe */ + conn->buf_len = 0; + flb_plg_debug(ctx->ins, "request length exceeds buffer length, closing connection"); + opentelemetry_conn_del(conn); + return -1; } - else { - request_end = strstr(conn->buf_data, "\r\n\r\n"); - if(NULL != request_end) { - request_end = &request_end[4]; - } - } + /* If we have extra bytes in our bytes, adjust the extra bytes */ + if (0 < (conn->buf_len - request_len)) { + memmove(conn->buf_data, &conn->buf_data[request_len], + conn->buf_len - request_len); - if (NULL != request_end) { - request_len = (size_t)(request_end - conn->buf_data); - - if (0 < (conn->buf_len - request_len)) { - memmove(conn->buf_data, &conn->buf_data[request_len], - conn->buf_len - request_len); - - conn->buf_data[conn->buf_len - request_len] = '\0'; - conn->buf_len -= request_len; - } - else { - memset(conn->buf_data, 0, request_len); - - conn->buf_len = 0; - } - - /* Reinitialize the parser so the next request is properly - * handled, the additional memset intends to wipe any left over data - * from the headers parsed in the previous request. - */ - memset(&conn->session.parser, 0, sizeof(struct mk_http_parser)); - mk_http_parser_init(&conn->session.parser); - opentelemetry_conn_request_init(&conn->session, &conn->request); + conn->buf_data[conn->buf_len - request_len] = '\0'; + conn->buf_len -= request_len; + } + else { + memset(conn->buf_data, 0, request_len); + conn->buf_len = 0; } + + /* Reinitialize the parser so the next request is properly + * handled, the additional memset intends to wipe any left over data + * from the headers parsed in the previous request. + */ + memset(&conn->session.parser, 0, sizeof(struct mk_http_parser)); + mk_http_parser_init(&conn->session.parser); + opentelemetry_conn_request_init(&conn->session, &conn->request); } else if (status == MK_HTTP_PARSER_ERROR) { opentelemetry_prot_handle_error(ctx, conn, &conn->session, &conn->request); diff --git a/plugins/in_opentelemetry/opentelemetry_prot.c b/plugins/in_opentelemetry/opentelemetry_prot.c index 451ceeab3c9..3a2180387e7 100644 --- a/plugins/in_opentelemetry/opentelemetry_prot.c +++ b/plugins/in_opentelemetry/opentelemetry_prot.c @@ -1895,15 +1895,6 @@ int opentelemetry_prot_handle(struct flb_opentelemetry *ctx, struct http_conn *c original_data = request->data.data; original_data_size = request->data.len; - ret = opentelemetry_prot_uncompress(session, request, - &uncompressed_data, - &uncompressed_data_size); - - if (ret > 0) { - request->data.data = uncompressed_data; - request->data.len = uncompressed_data_size; - } - /* check if the request comes with chunked transfer encoding */ if (mk_http_parser_is_content_chunked(&session->parser)) { out_chunked = NULL; @@ -1911,8 +1902,8 @@ int opentelemetry_prot_handle(struct flb_opentelemetry *ctx, struct http_conn *c /* decode the chunks */ ret = mk_http_parser_chunked_decode(&session->parser, - request->data.data, - request->data.len, + conn->buf_data, + conn->buf_len, &out_chunked, &out_chunked_size); if (ret == -1) { @@ -1930,6 +1921,15 @@ int opentelemetry_prot_handle(struct flb_opentelemetry *ctx, struct http_conn *c } } + ret = opentelemetry_prot_uncompress(session, request, + &uncompressed_data, + &uncompressed_data_size); + + if (ret > 0) { + request->data.data = uncompressed_data; + request->data.len = uncompressed_data_size; + } + if (strcmp(uri, "/v1/metrics") == 0) { ret = process_payload_metrics(ctx, conn, tag, tag_len, session, request); } @@ -1940,13 +1940,13 @@ int opentelemetry_prot_handle(struct flb_opentelemetry *ctx, struct http_conn *c ret = process_payload_logs(ctx, conn, tag, tag_len, session, request); } + request->data.data = original_data; + request->data.len = original_data_size; + if (uncompressed_data != NULL) { flb_free(uncompressed_data); } - request->data.data = original_data; - request->data.len = original_data_size; - if (out_chunked != NULL) { mk_mem_free(out_chunked); } From 241f1c96db4f6d693ba9f47650a4678e03281356 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Wed, 9 Oct 2024 16:10:09 -0600 Subject: [PATCH 277/295] in_http: adjust HTTP/1.1 buffer based on the request size Signed-off-by: Eduardo Silva --- plugins/in_http/http_conn.c | 64 +++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/plugins/in_http/http_conn.c b/plugins/in_http/http_conn.c index 9513605402f..7b59f5c63ad 100644 --- a/plugins/in_http/http_conn.c +++ b/plugins/in_http/http_conn.c @@ -93,7 +93,6 @@ static int http_conn_event(void *data) size_t size; ssize_t available; ssize_t bytes; - char *request_end; size_t request_len; struct flb_connection *connection; struct http_conn *conn; @@ -153,47 +152,44 @@ static int http_conn_event(void *data) /* Do more logic parsing and checks for this request */ http_prot_handle(ctx, conn, &conn->session, &conn->request); - /* Evict the processed request from the connection buffer and reinitialize + /* + * Evict the processed request from the connection buffer and reinitialize * the HTTP parser. */ - request_end = NULL; + /* Use the last parser position as the request length */ + request_len = mk_http_parser_request_size(&conn->session.parser, + conn->buf_data, + conn->buf_len); - if (NULL != conn->request.data.data) { - request_end = &conn->request.data.data[conn->request.data.len]; + if (request_len == -1 || (request_len > conn->buf_len)) { + /* Unexpected but let's make sure things are safe */ + conn->buf_len = 0; + flb_plg_debug(ctx->ins, "request length exceeds buffer length, closing connection"); + http_conn_del(conn); + return -1; } - else { - request_end = strstr(conn->buf_data, "\r\n\r\n"); - if(NULL != request_end) { - request_end = &request_end[4]; - } - } + /* If we have extra bytes in our bytes, adjust the extra bytes */ + if (0 < (conn->buf_len - request_len)) { + memmove(conn->buf_data, &conn->buf_data[request_len], + conn->buf_len - request_len); - if (NULL != request_end) { - request_len = (size_t)(request_end - conn->buf_data); - - if (0 < (conn->buf_len - request_len)) { - memmove(conn->buf_data, &conn->buf_data[request_len], - conn->buf_len - request_len); - - conn->buf_data[conn->buf_len - request_len] = '\0'; - conn->buf_len -= request_len; - } - else { - memset(conn->buf_data, 0, request_len); - - conn->buf_len = 0; - } - - /* Reinitialize the parser so the next request is properly - * handled, the additional memset intends to wipe any left over data - * from the headers parsed in the previous request. - */ - memset(&conn->session.parser, 0, sizeof(struct mk_http_parser)); - mk_http_parser_init(&conn->session.parser); - http_conn_request_init(&conn->session, &conn->request); + conn->buf_data[conn->buf_len - request_len] = '\0'; + conn->buf_len -= request_len; + } + else { + memset(conn->buf_data, 0, request_len); + conn->buf_len = 0; } + + /* Reinitialize the parser so the next request is properly + * handled, the additional memset intends to wipe any left over data + * from the headers parsed in the previous request. + */ + memset(&conn->session.parser, 0, sizeof(struct mk_http_parser)); + mk_http_parser_init(&conn->session.parser); + http_conn_request_init(&conn->session, &conn->request); } else if (status == MK_HTTP_PARSER_ERROR) { http_prot_handle_error(ctx, conn, &conn->session, &conn->request); From 6a0ef2b59c59643189d9c9cd5d2af4ed4a157ed6 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Wed, 9 Oct 2024 16:10:51 -0600 Subject: [PATCH 278/295] in_elasticsearch: add support for chunked transfer encoding Signed-off-by: Eduardo Silva --- .../in_elasticsearch_bulk_conn.c | 65 +++++++++---------- .../in_elasticsearch_bulk_prot.c | 43 ++++++++++-- 2 files changed, 70 insertions(+), 38 deletions(-) diff --git a/plugins/in_elasticsearch/in_elasticsearch_bulk_conn.c b/plugins/in_elasticsearch/in_elasticsearch_bulk_conn.c index fe6e46fb657..980c227ff93 100644 --- a/plugins/in_elasticsearch/in_elasticsearch_bulk_conn.c +++ b/plugins/in_elasticsearch/in_elasticsearch_bulk_conn.c @@ -34,7 +34,6 @@ static int in_elasticsearch_bulk_conn_event(void *data) ssize_t available; ssize_t bytes; char *tmp; - char *request_end; size_t request_len; struct flb_connection *connection; struct in_elasticsearch_bulk_conn *conn; @@ -98,47 +97,45 @@ static int in_elasticsearch_bulk_conn_event(void *data) /* Do more logic parsing and checks for this request */ in_elasticsearch_bulk_prot_handle(ctx, conn, &conn->session, &conn->request); - /* Evict the processed request from the connection buffer and reinitialize + /* + * Evict the processed request from the connection buffer and reinitialize * the HTTP parser. */ - request_end = NULL; + /* Use the last parser position as the request length */ + request_len = mk_http_parser_request_size(&conn->session.parser, + conn->buf_data, + conn->buf_len); - if (NULL != conn->request.data.data) { - request_end = &conn->request.data.data[conn->request.data.len]; + if (request_len == -1 || (request_len > conn->buf_len)) { + /* Unexpected but let's make sure things are safe */ + conn->buf_len = 0; + flb_plg_debug(ctx->ins, "request length exceeds buffer length, closing connection"); + in_elasticsearch_bulk_conn_del(conn); + return -1; } - else { - request_end = strstr(conn->buf_data, "\r\n\r\n"); - if(NULL != request_end) { - request_end = &request_end[4]; - } - } + /* If we have extra bytes in our bytes, adjust the extra bytes */ + if (0 < (conn->buf_len - request_len)) { + memmove(conn->buf_data, &conn->buf_data[request_len], + conn->buf_len - request_len); - if (NULL != request_end) { - request_len = (size_t)(request_end - conn->buf_data); - - if (0 < (conn->buf_len - request_len)) { - memmove(conn->buf_data, &conn->buf_data[request_len], - conn->buf_len - request_len); - - conn->buf_data[conn->buf_len - request_len] = '\0'; - conn->buf_len -= request_len; - } - else { - memset(conn->buf_data, 0, request_len); - - conn->buf_len = 0; - } - - /* Reinitialize the parser so the next request is properly - * handled, the additional memset intends to wipe any left over data - * from the headers parsed in the previous request. - */ - memset(&conn->session.parser, 0, sizeof(struct mk_http_parser)); - mk_http_parser_init(&conn->session.parser); - in_elasticsearch_bulk_conn_request_init(&conn->session, &conn->request); + conn->buf_data[conn->buf_len - request_len] = '\0'; + conn->buf_len -= request_len; } + else { + memset(conn->buf_data, 0, request_len); + conn->buf_len = 0; + } + + /* + * Reinitialize the parser so the next request is properly + * handled, the additional memset intends to wipe any left over data + * from the headers parsed in the previous request. + */ + memset(&conn->session.parser, 0, sizeof(struct mk_http_parser)); + mk_http_parser_init(&conn->session.parser); + in_elasticsearch_bulk_conn_request_init(&conn->session, &conn->request); } else if (status == MK_HTTP_PARSER_ERROR) { in_elasticsearch_bulk_prot_handle_error(ctx, conn, &conn->session, &conn->request); diff --git a/plugins/in_elasticsearch/in_elasticsearch_bulk_prot.c b/plugins/in_elasticsearch/in_elasticsearch_bulk_prot.c index c705af60d81..a2424413e19 100644 --- a/plugins/in_elasticsearch/in_elasticsearch_bulk_prot.c +++ b/plugins/in_elasticsearch/in_elasticsearch_bulk_prot.c @@ -621,6 +621,10 @@ static int process_payload(struct flb_in_elasticsearch *ctx, struct in_elasticse int gzip_compressed = FLB_FALSE; void *gz_data = NULL; size_t gz_size = -1; + char *out_chunked = NULL; + size_t out_chunked_size = 0; + char *payload_buf; + size_t payload_size; header = &session->parser.headers[MK_HEADER_CONTENT_TYPE]; if (header->key.data == NULL) { @@ -643,7 +647,7 @@ static int process_payload(struct flb_in_elasticsearch *ctx, struct in_elasticse return -1; } - if (request->data.len <= 0) { + if (request->data.len <= 0 && !mk_http_parser_is_content_chunked(&session->parser)) { send_response(conn, 400, "error: no payload found\n"); return -1; } @@ -664,8 +668,32 @@ static int process_payload(struct flb_in_elasticsearch *ctx, struct in_elasticse } if (type == HTTP_CONTENT_NDJSON || type == HTTP_CONTENT_JSON) { + /* Check if the data is chunked */ + payload_buf = NULL; + payload_size = 0; + + if (mk_http_parser_is_content_chunked(&session->parser)) { + ret = mk_http_parser_chunked_decode(&session->parser, + conn->buf_data, + conn->buf_len, + &out_chunked, + &out_chunked_size); + + if (ret == -1) { + send_response(conn, 400, "error: invalid chunked data\n"); + return -1; + } + + payload_buf = out_chunked; + payload_size = out_chunked_size; + } + else { + payload_buf = request->data.data; + payload_size = request->data.len; + } + if (gzip_compressed == FLB_TRUE) { - ret = flb_gzip_uncompress((void *) request->data.data, request->data.len, + ret = flb_gzip_uncompress((void *) payload_buf, payload_size, &gz_data, &gz_size); if (ret == -1) { flb_error("[elasticsearch_bulk_prot] gzip uncompress is failed"); @@ -675,10 +703,15 @@ static int process_payload(struct flb_in_elasticsearch *ctx, struct in_elasticse flb_free(gz_data); } else { - parse_payload_ndjson(ctx, tag, request->data.data, request->data.len, bulk_statuses); + parse_payload_ndjson(ctx, tag, payload_buf, payload_size, bulk_statuses); } } + /* release chunked data if has been set */ + if (out_chunked) { + mk_mem_free(out_chunked); + } + return 0; } @@ -856,7 +889,8 @@ int in_elasticsearch_bulk_prot_handle(struct flb_in_elasticsearch *ctx, mk_mem_free(uri); return -1; } - } else { + } + else { flb_sds_destroy(tag); mk_mem_free(uri); @@ -1056,6 +1090,7 @@ static int process_payload_ng(struct flb_http_request *request, return -1; } + printf("Processing payload 2 : %s\n", request->body); parse_payload_ndjson(context, tag, request->body, cfl_sds_len(request->body), bulk_statuses); return 0; From ac00d58af53dcc566e08e46f220f1e5993f2f55f Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Wed, 9 Oct 2024 16:20:46 -0600 Subject: [PATCH 279/295] lib: monkey: upgrade to v1.8.1 Signed-off-by: Eduardo Silva --- lib/monkey/CMakeLists.txt | 4 +- lib/monkey/api/test.c | 6 +- lib/monkey/include/monkey/mk_http_parser.h | 85 ++++- lib/monkey/mk_core/mk_event_select.c | 4 +- lib/monkey/mk_server/mk_http.c | 3 + lib/monkey/mk_server/mk_http_parser.c | 364 ++++++++++++++++++++- lib/monkey/plugins/logger/logger.c | 4 +- 7 files changed, 451 insertions(+), 19 deletions(-) diff --git a/lib/monkey/CMakeLists.txt b/lib/monkey/CMakeLists.txt index 95d8cc1e618..028240bcc44 100644 --- a/lib/monkey/CMakeLists.txt +++ b/lib/monkey/CMakeLists.txt @@ -22,8 +22,8 @@ endif() # Monkey Version set(MK_VERSION_MAJOR 1) -set(MK_VERSION_MINOR 7) -set(MK_VERSION_PATCH 2) +set(MK_VERSION_MINOR 8) +set(MK_VERSION_PATCH 1) set(MK_VERSION_STR "${MK_VERSION_MAJOR}.${MK_VERSION_MINOR}.${MK_VERSION_PATCH}") # Output paths diff --git a/lib/monkey/api/test.c b/lib/monkey/api/test.c index ffb96f1352f..6ed0fe0e0a2 100644 --- a/lib/monkey/api/test.c +++ b/lib/monkey/api/test.c @@ -8,7 +8,7 @@ #include #define API_ADDR "127.0.0.1" -#define API_PORT "8080" +#define API_PORT "9080" /* Main context set as global so the signal handler can use it */ mk_ctx_t *ctx; @@ -153,9 +153,9 @@ int main() "Name", "monotop", NULL); - mk_vhost_handler(ctx, vid, "/api/v1/stream_processor/task/[A-Za-z_][0-9A-Za-z_\\-]*", + mk_vhost_handler(ctx, vid, "/api/v1/stream_processor/task/[A-Za-z_][0-9A-Za-z_\\-]*", cb_sp_test_task_detail, NULL); - + mk_vhost_handler(ctx, vid, "/api/v1/stream_processor/task", cb_sp_test_task_main, NULL); diff --git a/lib/monkey/include/monkey/mk_http_parser.h b/lib/monkey/include/monkey/mk_http_parser.h index 6d45c39414c..9e3b365eef7 100644 --- a/lib/monkey/include/monkey/mk_http_parser.h +++ b/lib/monkey/include/monkey/mk_http_parser.h @@ -45,6 +45,16 @@ #define MK_HTTP_PARSER_UPGRADE_H2 1 #define MK_HTTP_PARSER_UPGRADE_H2C 2 +/* Transfer encoding */ +#define MK_HTTP_PARSER_TRANSFER_ENCODING_NONE (0) +#define MK_HTTP_PARSER_TRANSFER_ENCODING_CHUNKED (1 << 0) +#define MK_HTTP_PARSER_TRANSFER_ENCODING_GZIP (1 << 1) + +/* Transfer encoding (almost not used) */ +#define MK_HTTP_PARSER_TRANSFER_ENCODING_COMPRESS (1 << 2) +#define MK_HTTP_PARSER_TRANSFER_ENCODING_DEFLATE (1 << 3) +#define MK_HTTP_PARSER_TRANSFER_ENCODING_IDENTITY (1 << 4) + #define MK_HEADER_EXTRA_SIZE 50 /* Request levels @@ -118,6 +128,7 @@ enum mk_request_headers { MK_HEADER_LAST_MODIFIED_SINCE , MK_HEADER_RANGE , MK_HEADER_REFERER , + MK_HEADER_TRANSFER_ENCODING , MK_HEADER_UPGRADE , MK_HEADER_USER_AGENT , MK_HEADER_SIZEOF , @@ -193,6 +204,21 @@ struct mk_http_parser { */ int header_upgrade; + + /* + * Transfer-Encoding + * ------------------ + * we support the following values (bitwise): + * + * - MK_HTTP_PARSER_TRANSFER_ENCODING_NONE + * - MK_HTTP_PARSER_TRANSFER_ENCODING_CHUNKED + * - MK_HTTP_PARSER_TRANSFER_ENCODING_GZIP + * - MK_HTTP_PARSER_TRANSFER_ENCODING_COMPRESS + * - MK_HTTP_PARSER_TRANSFER_ENCODING_DEFLATE + * - MK_HTTP_PARSER_TRANSFER_ENCODING_IDENTITY + */ + int header_transfer_encoding; + /* probable current header, fly parsing */ int header_key; int header_sep; @@ -210,6 +236,20 @@ struct mk_http_parser { /* Extra headers */ struct mk_http_header headers_extra[MK_HEADER_EXTRA_SIZE]; + + + /* + * total size of bytes received as chunked data; this don't count the + * hex strings + */ + size_t chunk_total_size_received; + + /* Transfer chunked encoding: state for active chunk being processed */ + char *chunk_expected_start; /* pointer to the expected very first chunk in the payload */ + + size_t chunk_expected_size; /* expected size of a chunk being read */ + char *chunk_processed_start; /* beginning of a chunk being read */ + char *chunk_processed_end; /* last position of a chunk that is complete */ }; @@ -333,6 +373,20 @@ static inline void mk_http_parser_init(struct mk_http_parser *p) mk_list_init(&p->header_list); } +int mk_http_parser(struct mk_http_request *req, struct mk_http_parser *p, + char *buffer, int buf_len, struct mk_server *server); + +size_t mk_http_parser_content_length(struct mk_http_parser *p); +int mk_http_parser_is_content_chunked(struct mk_http_parser *p); + +int mk_http_parser_chunked_decode(struct mk_http_parser *p, + char *buf_request, size_t buf_request_len, + char **out_buf, size_t *out_buf_size); + +int mk_http_parser_chunked_decode_buf(struct mk_http_parser *p, + char *buf_request, size_t buf_request_len, + char *out_buf, size_t out_buf_size, size_t *out_buf_len); + static inline int mk_http_parser_more(struct mk_http_parser *p, int len) { if (abs(len - p->i) - 1 > 0) { @@ -342,7 +396,34 @@ static inline int mk_http_parser_more(struct mk_http_parser *p, int len) return MK_FALSE; } -int mk_http_parser(struct mk_http_request *req, struct mk_http_parser *p, - char *buffer, int buf_len, struct mk_server *server); +/* Returns the full size of the HTTP request in bytes "If" mk_http_parser() has returned MK_HTTP_PARSER_OK */ +static inline size_t mk_http_parser_request_size(struct mk_http_parser *p, char *buf_request, size_t buf_request_len) +{ + size_t bytes; + + /* + * if the request is chunked encoded, p->i points to the beginning of the last chunk + * found, so we need to check if the last chunk is complete, if so we can return the + * size of the request + */ + if (mk_http_parser_is_content_chunked(p)) { + if (p->chunk_processed_start < buf_request) { + return -1; + } + + /* Look at the last chunk processed (0\r\n\r\n) */ + bytes = p->chunk_processed_start - buf_request + 5; + if (bytes > buf_request_len) { + return -1; + } + return bytes; + } + else if (p->header_content_length > 0) { + /* p->i points to the last byte after the content body */ + return p->i; + } + + return -1; +} #endif /* MK_HTTP_H */ diff --git a/lib/monkey/mk_core/mk_event_select.c b/lib/monkey/mk_core/mk_event_select.c index e326ba85b0b..f23dafc7352 100644 --- a/lib/monkey/mk_core/mk_event_select.c +++ b/lib/monkey/mk_core/mk_event_select.c @@ -367,7 +367,7 @@ static inline int _mk_event_inject(struct mk_event_loop *loop, if (prevent_duplication) { for (index = 0 ; index < loop->n_events ; index++) { - if (ctx->fired[index]->fd == event->fd) { + if (ctx->fired[index].data == event) { return 0; } } @@ -375,7 +375,7 @@ static inline int _mk_event_inject(struct mk_event_loop *loop, event->mask = mask; - ctx->fired[loop->n_events] = event; + ctx->fired[loop->n_events].data = event; loop->n_events++; diff --git a/lib/monkey/mk_server/mk_http.c b/lib/monkey/mk_server/mk_http.c index 1e2d219ded5..184a695a811 100644 --- a/lib/monkey/mk_server/mk_http.c +++ b/lib/monkey/mk_server/mk_http.c @@ -1150,6 +1150,7 @@ int mk_http_request_end(struct mk_http_session *cs, struct mk_server *server) mk_http_parser_init(&cs->parser); status = mk_http_parser(sr, &cs->parser, cs->body, cs->body_length, server); + if (status == MK_HTTP_PARSER_OK) { ret = mk_http_request_prepare(cs, sr, server); if (ret == MK_EXIT_ABORT) { @@ -1564,8 +1565,10 @@ int mk_http_sched_read(struct mk_sched_conn *conn, else { sr = mk_list_entry_first(&cs->request_list, struct mk_http_request, _head); } + status = mk_http_parser(sr, &cs->parser, cs->body, cs->body_length, server); + if (status == MK_HTTP_PARSER_OK) { MK_TRACE("[FD %i] HTTP_PARSER_OK", socket); if (mk_http_status_completed(cs, conn) == -1) { diff --git a/lib/monkey/mk_server/mk_http_parser.c b/lib/monkey/mk_server/mk_http_parser.c index 4e7aa31616d..f973571e9ed 100644 --- a/lib/monkey/mk_server/mk_http_parser.c +++ b/lib/monkey/mk_server/mk_http_parser.c @@ -74,8 +74,9 @@ struct row_entry mk_headers_table[] = { { 19, "last-modified-since" }, { 5, "range" }, { 7, "referer" }, + { 17, "transfer-encoding" }, { 7, "upgrade" }, - { 10, "user-agent" } + { 10, "user-agent" }, }; static inline void reverse_char_lookup(char *buf, char c, int len, struct mk_http_parser *p) @@ -226,6 +227,7 @@ static inline int header_lookup(struct mk_http_parser *p, char *buffer) p->header_count++; mk_list_add(&header->_head, &p->header_list); + if (i == MK_HEADER_HOST) { /* Handle a possible port number in the Host header */ int sep = str_searchr(header->val.data, ':', header->val.len); @@ -314,6 +316,52 @@ static inline int header_lookup(struct mk_http_parser *p, char *buffer) } } } + else if (i == MK_HEADER_TRANSFER_ENCODING) { + /* Check Transfer-Encoding: chunked */ + pos = mk_string_search_n(header->val.data, + "chunked", + MK_STR_INSENSITIVE, + header->val.len); + if (pos >= 0) { + p->header_transfer_encoding |= MK_HTTP_PARSER_TRANSFER_ENCODING_CHUNKED; + } + + /* Check Transfer-Encoding: gzip */ + pos = mk_string_search_n(header->val.data, + "gzip", + MK_STR_INSENSITIVE, + header->val.len); + if (pos >= 0) { + p->header_transfer_encoding |= MK_HTTP_PARSER_TRANSFER_ENCODING_GZIP; + } + + /* Check Transfer-Encoding: compress */ + pos = mk_string_search_n(header->val.data, + "compress", + MK_STR_INSENSITIVE, + header->val.len); + if (pos >= 0) { + p->header_transfer_encoding |= MK_HTTP_PARSER_TRANSFER_ENCODING_COMPRESS; + } + + /* Check Transfer-Encoding: deflate */ + pos = mk_string_search_n(header->val.data, + "deflate", + MK_STR_INSENSITIVE, + header->val.len); + if (pos >= 0) { + p->header_transfer_encoding |= MK_HTTP_PARSER_TRANSFER_ENCODING_DEFLATE; + } + + /* Check Transfer-Encoding: identity */ + pos = mk_string_search_n(header->val.data, + "identity", + MK_STR_INSENSITIVE, + header->val.len); + if (pos >= 0) { + p->header_transfer_encoding |= MK_HTTP_PARSER_TRANSFER_ENCODING_IDENTITY; + } + } else if (i == MK_HEADER_UPGRADE) { if (header_cmp(MK_UPGRADE_H2C, header->val.data, header->val.len) == 0) { @@ -354,6 +402,290 @@ static inline int header_lookup(struct mk_http_parser *p, char *buffer) return -MK_CLIENT_REQUEST_ENTITY_TOO_LARGE; } + +/* check if the HTTP content is chunked so it contain hexa string length headers */ +int mk_http_parser_is_content_chunked(struct mk_http_parser *p) +{ + return p->header_transfer_encoding & MK_HTTP_PARSER_TRANSFER_ENCODING_CHUNKED; +} + +size_t mk_http_parser_content_length(struct mk_http_parser *p) +{ + /* + * returns the content length of the payload. If the content-length header was + * set, it will return the value of the header. If the content-length header was + * not set and instead the transfer-encoding header was set to chunked, it will + * return the length of the payload withouto counting the chunked headers. + */ + + if (!mk_http_parser_is_content_chunked(p)) { + return p->header_content_length; + } + else { + return p->chunk_total_size_received; + } + + return 0; +} + + +int cb_debug_chunk_complete(char *in, size_t in_len, char *out, size_t out_len, size_t *out_len_processed) +{ + (void) out; + (void) out_len; + char *buf; + + /* copy the chunked content into the buffer */ + buf = mk_mem_alloc(in_len + 1); + if (!buf) { + return -1; + } + + memcpy(buf, in, in_len); + buf[in_len] = '\0'; + + printf("==CHUNK DETECTED CONTENT (length=%zu)==\n'%s'\n---\n", in_len, buf); + mk_mem_free(buf); + + *out_len_processed = in_len; + + return 0; +} + +/* + * Check if the request body is complete, incomplete or if it has an error while processing + * the chunks for a chunked transfer encoded payload + */ +static int http_parser_transfer_encoding_chunked(struct mk_http_parser *p, + char *buf_request, size_t buf_request_len, + int (*cb_chunk_complete)(char *in, size_t in_len, char *out, size_t out_len, size_t *out_len_processed), + char *out_buf, size_t out_buf_size, size_t *out_buf_len) +{ + int64_t len; + int64_t chunk_len; + int64_t pos; + char tmp[32]; + char *ptr; + char *content_start; + size_t available_bytes; + + p->level = REQ_LEVEL_BODY; + +parse_more: + + /* read the payload and check if the request has finished based on the logic of transfer encoding chunked */ + if (!p->chunk_processed_start) { + /* + * if p->chunk_processed_start is not set, it means we are parsing from the beginning. Note that + * p->chunk_expected_start is set, it means the content was already processed before, so we just + * adjust the pointer, otherwise we use the parser iterator index (p->i) for it. + */ + if (p->chunk_expected_start) { + p->chunk_processed_start = p->chunk_expected_start; + } + else { + p->chunk_processed_start = buf_request + p->i; + + /* Mark the very first chunk */ + p->chunk_expected_start = p->chunk_processed_start; + } + + len = buf_request_len - p->i; + if (len == 0) { + return MK_HTTP_PARSER_PENDING; + } + + if (p->chunk_processed_start[0] != '\n') { + return MK_HTTP_PARSER_ERROR; + } + + /* we are at the beginning of a chunk, we need to find the end */ + p->chunk_processed_start++; + len--; + + } + else { + len = buf_request_len - (p->chunk_processed_end - buf_request); + } + + /* find the end of the 'chunk header' (e.g: ffae\r\n\r\n) */ + pos = mk_string_search_n(p->chunk_processed_start, "\r\n", MK_STR_SENSITIVE, len); + if (pos < 0) { + return MK_HTTP_PARSER_PENDING; + } + + /* length of the hex string */ + len = (p->chunk_processed_start + pos) - p->chunk_processed_start; + if (((unsigned long) len > sizeof(tmp) - 1) || len == 0) { + return MK_HTTP_PARSER_ERROR; + } + + /* copy the hex string to a temporary buffer */ + memcpy(tmp, p->chunk_processed_start, len); + tmp[len] = '\0'; + + /* convert the hex string to a number */ + errno = 0; + chunk_len = strtol(tmp, &ptr, 16); + if ((errno == ERANGE && (chunk_len == LONG_MAX || chunk_len == LONG_MIN)) || + (errno != 0)) { + return MK_HTTP_PARSER_ERROR; + } + + if (chunk_len < 0) { + return MK_HTTP_PARSER_ERROR; + } + else if (chunk_len == 0) { + /* we have reached the end of the request, validate the last \r\n\r\n exists */ + len = buf_request_len - (p->chunk_processed_start - buf_request); + + if (len < 5) { + return MK_HTTP_PARSER_PENDING; + } + + /* all or nothing */ + if (strncmp(p->chunk_processed_start, "0\r\n\r\n", 5) != 0) { + return MK_HTTP_PARSER_ERROR; + } + + return MK_HTTP_PARSER_OK; + } + else { + /* set the new markers: required size and start position after the hex string length */ + p->chunk_expected_size = chunk_len; + + /* the content starts after the hex_str_length\r\n */ + content_start = p->chunk_processed_start + pos + 2; + + /* calculate the amount of available bytes 'after' content_start */ + available_bytes = buf_request_len - (content_start - buf_request); + + /* do we have all the remaining data needed in our buffer ? */ + if (available_bytes >= p->chunk_expected_size + 2 /* \r\n */) { + /* we have all the data needed */ + p->chunk_processed_end = content_start + p->chunk_expected_size; + + /* check for delimiter \r\n */ + if (p->chunk_processed_end[0] != '\r' || p->chunk_processed_end[1] != '\n') { + return MK_HTTP_PARSER_ERROR; + } + + /* + * If the callback function has been set, invoke it: this callback might be useful for + * debugging and/or provide a way to copy the chunked content into a buffer + */ + if (cb_chunk_complete) { + cb_chunk_complete(content_start, chunk_len, out_buf, out_buf_size, out_buf_len); + } + + /* set the new start for the new chunk */ + p->chunk_processed_start = p->chunk_processed_end + 2; + p->chunk_total_size_received += chunk_len; + goto parse_more; + } + else { + /* we need more data */ + return MK_HTTP_PARSER_PENDING; + } + + } + /* is our chunk complete ? */ + return MK_HTTP_PARSER_PENDING; + +} + +/* Read the chunked content and invoke callback if it has been set */ +int mk_http_parser_read_chunked_content(struct mk_http_parser *p, + char *buf_request, size_t buf_request_len, + int (*cb_chunk_complete)(char *in, size_t in_len, char *out, size_t out_size, size_t *out_len), + char *out_buf, size_t out_buf_size, size_t *out_buf_len) +{ + p->chunk_processed_start = NULL; + p->chunk_processed_end = NULL; + + return http_parser_transfer_encoding_chunked(p, + buf_request, buf_request_len, + cb_chunk_complete, + out_buf, out_buf_size, out_buf_len); +} + +/* + * Callback function used by mk_http_parser_chunked_decode to provide a new buffer with the content + * of the payload decoded + */ +static int cb_copy_chunk(char *in, size_t in_len, char *out, size_t out_size, size_t *out_len_processed) +{ + (void) out_size; + + /* check we don't overflow the buffer */ + if (*out_len_processed + in_len > out_size) { + return -1; + } + + /* copy the chunk */ + memcpy(out + *out_len_processed, in, in_len); + *out_len_processed += in_len; + + return 0; +} + +/* + * This function assumes that the output buffer size has enough space to copy the desired + * chunked content. We do some sanity checks but if the buffer is smaller the data will + * be truncated. + */ +int mk_http_parser_chunked_decode_buf(struct mk_http_parser *p, + char *buf_request, size_t buf_request_len, + char *out_buf, size_t out_buf_size, size_t *out_buf_len) +{ + int ret; + size_t written_bytes = 0; + + ret = mk_http_parser_read_chunked_content(p, + buf_request, buf_request_len, + cb_copy_chunk, + out_buf, out_buf_size, &written_bytes); + if (ret == MK_HTTP_PARSER_OK) { + *out_buf_len = written_bytes; + return 0; + } + + return -1; +} + +int mk_http_parser_chunked_decode(struct mk_http_parser *p, + char *buf_request, size_t buf_request_len, + char **out_buf, size_t *out_buf_size) +{ + int ret; + char *tmp_buf; + size_t tmp_buf_size = 0; + size_t tmp_written_bytes = 0; + + tmp_buf_size = mk_http_parser_content_length(p); + if (tmp_buf_size == 0) { + return -1; + } + + tmp_buf = mk_mem_alloc(tmp_buf_size); + if (!tmp_buf) { + return -1; + } + + ret = mk_http_parser_chunked_decode_buf(p, + buf_request, buf_request_len, + tmp_buf, tmp_buf_size, &tmp_written_bytes); + if (ret == -1) { + mk_mem_free(tmp_buf); + return -1; + } + + *out_buf = tmp_buf; + *out_buf_size = tmp_written_bytes; + + return 0; +} + /* * This function is invoked everytime the parser evaluate the request is * OK. Here we perform some extra validations mostly based on some logic @@ -361,8 +693,11 @@ static inline int header_lookup(struct mk_http_parser *p, char *buffer) */ static inline int mk_http_parser_ok(struct mk_http_request *req, struct mk_http_parser *p, + char *buf_request, size_t buf_request_len, struct mk_server *server) { + int ret; + /* Validate HTTP Version */ if (req->protocol == MK_HTTP_PROTOCOL_UNKNOWN) { mk_http_error(MK_SERVER_HTTP_VERSION_UNSUP, req->session, req, server); @@ -371,10 +706,20 @@ static inline int mk_http_parser_ok(struct mk_http_request *req, /* POST checks */ if (req->method == MK_METHOD_POST || req->method == MK_METHOD_PUT) { - /* validate Content-Length exists */ - if (p->headers[MK_HEADER_CONTENT_LENGTH].type == 0) { - mk_http_error(MK_CLIENT_LENGTH_REQUIRED, req->session, req, server); - return MK_HTTP_PARSER_ERROR; + /* validate Content-Length exists for non-chunked requests */ + if (mk_http_parser_is_content_chunked(p)) { + p->level = REQ_LEVEL_BODY; + + ret = http_parser_transfer_encoding_chunked(p, + buf_request, buf_request_len, + NULL, NULL, 0, NULL); + return ret; + } + else { + if (p->headers[MK_HEADER_CONTENT_LENGTH].type == 0) { + mk_http_error(MK_CLIENT_LENGTH_REQUIRED, req->session, req, server); + return MK_HTTP_PARSER_ERROR; + } } } @@ -543,7 +888,7 @@ int mk_http_parser(struct mk_http_request *req, struct mk_http_parser *p, break; case MK_ST_BLOCK_END: if (buffer[p->i] == '\n') { - return mk_http_parser_ok(req, p, server); + return mk_http_parser_ok(req, p, buffer, buf_len, server); } else { return MK_HTTP_PARSER_ERROR; @@ -614,6 +959,9 @@ int mk_http_parser(struct mk_http_request *req, struct mk_http_parser *p, p->header_min = MK_HEADER_UPGRADE; p->header_max = MK_HEADER_USER_AGENT; break; + case 't': + header_scope_eq(p, MK_HEADER_TRANSFER_ENCODING); + break; default: p->header_key = -1; p->header_sep = -1; @@ -710,7 +1058,7 @@ int mk_http_parser(struct mk_http_request *req, struct mk_http_parser *p, start_next(); } else { - return mk_http_parser_ok(req, p, server); + return mk_http_parser_ok(req, p, buffer, buf_len, server); } } else { @@ -736,7 +1084,7 @@ int mk_http_parser(struct mk_http_request *req, struct mk_http_parser *p, req->data.len = p->body_received; req->data.data = (buffer + p->start); } - return mk_http_parser_ok(req, p, server); + return mk_http_parser_ok(req, p, buffer, buf_len, server); } } diff --git a/lib/monkey/plugins/logger/logger.c b/lib/monkey/plugins/logger/logger.c index 4dfcfb00192..271b39e1e9b 100644 --- a/lib/monkey/plugins/logger/logger.c +++ b/lib/monkey/plugins/logger/logger.c @@ -197,7 +197,7 @@ static void mk_logger_start_worker(void *args) timeout = clk + mk_logger_timeout; - flog = open(target, O_WRONLY | O_CREAT | O_CLOEXEC, 0644); + flog = open(target, O_WRONLY | O_CREAT | O_CLOEXEC, 0600); if (mk_unlikely(flog == -1)) { mk_warn("Could not open logfile '%s' (%s)", target, strerror(errno)); @@ -327,7 +327,7 @@ int mk_logger_plugin_init(struct plugin_api **api, char *confdir) /* Check masterlog */ if (mk_logger_master_path) { - fd = open(mk_logger_master_path, O_WRONLY | O_CREAT | O_CLOEXEC, 0644); + fd = open(mk_logger_master_path, O_WRONLY | O_CREAT | O_CLOEXEC, 0600); if (fd == -1) { mk_err("Could not open/create master logfile %s", mk_logger_master_path); exit(EXIT_FAILURE); From a1c51f6ca0b285c0219cdf30a10ab37cb52eff69 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 2 Oct 2024 22:29:42 +0200 Subject: [PATCH 280/295] in_blob: added pattern based file exclusion Signed-off-by: Leonardo Alminana --- plugins/in_blob/blob.c | 175 +++++++++++++++++++++++++++++++++++++---- plugins/in_blob/blob.h | 1 + 2 files changed, 160 insertions(+), 16 deletions(-) diff --git a/plugins/in_blob/blob.c b/plugins/in_blob/blob.c index c4f5175425d..3dfcbec4d86 100644 --- a/plugins/in_blob/blob.c +++ b/plugins/in_blob/blob.c @@ -28,6 +28,7 @@ #include #include +#include #ifndef FLB_SYSTEM_WINDOWS #include @@ -190,6 +191,128 @@ static inline int do_glob(const char *pattern, return ret; } +#define MATCHING_METHOD_PRESENCE 0 +#define MATCHING_METHOD_EXACT 1 + +static int apply_glob_pattern(flb_sds_t pattern, char *path) { + int matching_method; + char *strtok_context; + cfl_sds_t local_pattern; + char *filename_part; + char *pattern_part; + char *filename; + int result; + size_t index; + + if (pattern == NULL || pattern[0] == '\0') { + return FLB_FALSE; + } + + if (path == NULL || path[0] == '\0') { + return FLB_FALSE; + } + + filename = NULL; + +#ifdef FLB_SYSTEM_WINDOWS + filename = strrchr(path, '\\'); +#endif + + if (filename == NULL) { + filename = strrchr(path, '/'); + } + + if (filename != NULL) { + filename = &filename[1]; + } + else { + filename = path; + } + + if (filename[0] == '\0') { + return FLB_FALSE; + } + + local_pattern = cfl_sds_create(pattern); + + if (local_pattern == NULL) { + return FLB_FALSE; + } + + result = FLB_FALSE; + + if (strrchr(local_pattern, '*') != NULL) { + index = 0; + pattern_part = strtok_r(local_pattern, "*", &strtok_context); + + if (local_pattern[0] == '*') { + matching_method = MATCHING_METHOD_PRESENCE; + } + else { + matching_method = MATCHING_METHOD_EXACT; + } + + filename_part = filename; + + + while (pattern_part != NULL && filename_part != NULL) { + if (matching_method == MATCHING_METHOD_PRESENCE) { + filename_part = strstr(filename_part, pattern_part); + } + else { + result = strncmp(filename_part, pattern_part, strlen(pattern_part)); + + if (result != 0) { + filename_part = NULL; + } + + matching_method = MATCHING_METHOD_PRESENCE; + } + + if (filename_part != NULL) { + filename_part = &filename_part[strlen(pattern_part)]; + } + + index++; + pattern_part = strtok_r(NULL, "*", &strtok_context); + } + + result = FLB_FALSE; + + if (pattern_part == NULL) { + if (pattern[strlen(pattern) - 1] != '*') { + if (filename_part != NULL) { + if (filename_part[0] == '\0') { + result = FLB_TRUE; + } + } + } + else { + if (filename_part != NULL) { + result = FLB_TRUE; + } + } + } + else { + result = FLB_FALSE; + } + } + else { + result = strcmp(filename, local_pattern); + + if (result == 0) { + result = FLB_TRUE; + } + else { + result = FLB_FALSE; + } + } + + cfl_sds_destroy(local_pattern); + + return result; +} + /* This function recursively searches a directory tree using * a glob compatible pattern that implements the fluentd style * recursion wildcard **. @@ -290,11 +413,20 @@ static ssize_t recursive_file_search(struct blob_ctx *ctx, else if (cfl_sds_len(local_pattern) == 0) { recursive_search_flag = FLB_FALSE; } + else if (cfl_sds_len(local_path) == 0) { + recursive_search_flag = FLB_FALSE; + } memset(&glob_context, 0, sizeof(glob_t)); /* Scan the given path */ - result = do_glob(local_path, GLOB_TILDE | GLOB_ERR, NULL, &glob_context); + if (local_path[0] != '\0') { + result = do_glob(local_path, GLOB_TILDE | GLOB_ERR, NULL, &glob_context); + } + else { + result = do_glob(local_pattern, GLOB_TILDE | GLOB_ERR, NULL, &glob_context); + } + if (result != 0) { switch (result) { case GLOB_NOSPACE: @@ -411,23 +543,29 @@ static ssize_t recursive_file_search(struct blob_ctx *ctx, else if (recursive_search_flag == FLB_FALSE && (S_ISREG(fs_entry_metadata.st_mode) || S_ISLNK(fs_entry_metadata.st_mode))) { - result = blob_file_append(ctx, - glob_context.gl_pathv[index], - &fs_entry_metadata); - if (result == 0) { - flb_plg_debug(ctx->ins, - "blob scan add: %s, inode %" PRIu64, - glob_context.gl_pathv[index], - (uint64_t) fs_entry_metadata.st_ino); - } - else { - flb_plg_debug(ctx->ins, - "blob scan skip: %s", - glob_context.gl_pathv[index]); - } + result = apply_glob_pattern(ctx->exclude_pattern, + (char *) glob_context.gl_pathv[index]); - match_count++; + if (result == FLB_FALSE) { + result = blob_file_append(ctx, + glob_context.gl_pathv[index], + &fs_entry_metadata); + + if (result == 0) { + flb_plg_debug(ctx->ins, + "blob scan add: %s, inode %" PRIu64, + glob_context.gl_pathv[index], + (uint64_t) fs_entry_metadata.st_ino); + } + else { + flb_plg_debug(ctx->ins, + "blob scan skip: %s", + glob_context.gl_pathv[index]); + } + + match_count++; + } } } @@ -843,6 +981,11 @@ static struct flb_config_map config_map[] = { "Path to scan for blob/binary files" }, + { + FLB_CONFIG_MAP_STR, "exclude_pattern", NULL, + 0, FLB_TRUE, offsetof(struct blob_ctx, exclude_pattern), + }, + #ifdef FLB_HAVE_SQLDB { FLB_CONFIG_MAP_STR, "database_file", NULL, diff --git a/plugins/in_blob/blob.h b/plugins/in_blob/blob.h index adedce21d79..5f18ca23b93 100644 --- a/plugins/in_blob/blob.h +++ b/plugins/in_blob/blob.h @@ -73,6 +73,7 @@ struct blob_ctx { /* config map options */ flb_sds_t path; + flb_sds_t exclude_pattern; flb_sds_t database_file; time_t scan_refresh_interval; From 500ea4aaed9d7ea64d2f452dc2d554158e8acf4e Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 2 Oct 2024 22:30:27 +0200 Subject: [PATCH 281/295] out_azure_blob: added blob destination tracking and stickiness Signed-off-by: Leonardo Alminana --- plugins/out_azure_blob/azure_blob.c | 42 +++++++++++++-- plugins/out_azure_blob/azure_blob.h | 1 + plugins/out_azure_blob/azure_blob_db.c | 73 +++++++++++++++++++++++--- plugins/out_azure_blob/azure_blob_db.h | 62 ++++++++++++++-------- 4 files changed, 145 insertions(+), 33 deletions(-) diff --git a/plugins/out_azure_blob/azure_blob.c b/plugins/out_azure_blob/azure_blob.c index ec82ee9278c..de4ee41beaf 100644 --- a/plugins/out_azure_blob/azure_blob.c +++ b/plugins/out_azure_blob/azure_blob.c @@ -668,7 +668,7 @@ static int process_blob_chunk(struct flb_azure_blob *ctx, struct flb_event_chunk continue; } - ret = azb_db_file_insert(ctx, source, file_path, file_size); + ret = azb_db_file_insert(ctx, source, ctx->endpoint, file_path, file_size); if (ret == -1) { flb_plg_error(ctx->ins, "cannot insert blob file into database: %s (size=%lu)", file_path, file_size); @@ -708,6 +708,7 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context uint64_t file_delivery_attempts; off_t offset_start; off_t offset_end; + cfl_sds_t file_destination = NULL; cfl_sds_t file_path = NULL; cfl_sds_t part_ids = NULL; cfl_sds_t source = NULL; @@ -876,7 +877,8 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context &offset_start, &offset_end, &part_delivery_attempts, &file_delivery_attempts, - &file_path); + &file_path, + &file_destination); if (ret == -1) { flb_plg_error(ctx->ins, "cannot get next blob file part"); info->active_upload = FLB_FALSE; @@ -891,6 +893,25 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context /* just continue, the row info was retrieved */ } + if (strcmp(file_destination, ctx->endpoint) != 0) { + flb_plg_info(ctx->ins, + "endpoint change detected, restarting file : %s", + file_path); + + info->active_upload = FLB_FALSE; + + /* we need to set the aborted state flag to wait for existing uploads + * to finish and then wipe the slate and start again but we don't want + * to increment the failure count in this case. + */ + azb_db_file_set_aborted_state(ctx, file_id, file_path, 1); + + cfl_sds_destroy(file_path); + cfl_sds_destroy(file_destination); + + flb_sched_timer_cb_coro_return(); + } + /* since this is the first part we want to increment the files * delivery attempt counter. */ @@ -902,20 +923,31 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context ret = flb_utils_read_file_offset(file_path, offset_start, offset_end, &out_buf, &out_size); if (ret == -1) { flb_plg_error(ctx->ins, "cannot read file part %s", file_path); - cfl_sds_destroy(file_path); + info->active_upload = FLB_FALSE; + + cfl_sds_destroy(file_path); + cfl_sds_destroy(file_destination); + flb_sched_timer_cb_coro_return(); } azb_db_file_part_delivery_attempts(ctx, file_id, part_id, ++part_delivery_attempts); flb_plg_debug(ctx->ins, "sending part file %s (id=%" PRIu64 " part_id=%" PRIu64 ")", file_path, id, part_id); + ret = send_blob(config, NULL, ctx, FLB_EVENT_TYPE_BLOBS, AZURE_BLOB_BLOCKBLOB, file_path, part_id, NULL, 0, out_buf, out_size); + if (ret == FLB_OK) { ret = azb_db_file_part_uploaded(ctx, id); + if (ret == -1) { info->active_upload = FLB_FALSE; + + cfl_sds_destroy(file_path); + cfl_sds_destroy(file_destination); + flb_sched_timer_cb_coro_return(); } } @@ -926,14 +958,16 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context part_delivery_attempts >= ctx->part_delivery_attempt_limit) { azb_db_file_set_aborted_state(ctx, file_id, file_path, 1); } - /* FIXME */ } + info->active_upload = FLB_FALSE; if (out_buf) { flb_free(out_buf); } + cfl_sds_destroy(file_path); + cfl_sds_destroy(file_destination); flb_sched_timer_cb_coro_return(); } diff --git a/plugins/out_azure_blob/azure_blob.h b/plugins/out_azure_blob/azure_blob.h index 43cb5035792..361e348de79 100644 --- a/plugins/out_azure_blob/azure_blob.h +++ b/plugins/out_azure_blob/azure_blob.h @@ -108,6 +108,7 @@ struct flb_azure_blob { sqlite3_stmt *stmt_delete_file; sqlite3_stmt *stmt_abort_file; sqlite3_stmt *stmt_get_file; + sqlite3_stmt *stmt_update_file_destination; sqlite3_stmt *stmt_update_file_delivery_attempt_count; sqlite3_stmt *stmt_set_file_aborted_state; sqlite3_stmt *stmt_get_next_aborted_file; diff --git a/plugins/out_azure_blob/azure_blob_db.c b/plugins/out_azure_blob/azure_blob_db.c index 3de48b15dea..9ba5e0948d3 100644 --- a/plugins/out_azure_blob/azure_blob_db.c +++ b/plugins/out_azure_blob/azure_blob_db.c @@ -56,6 +56,17 @@ static int prepare_stmts(struct flb_sqldb *db, struct flb_azure_blob *ctx) return -1; } + /* file destination update */ + ret = sqlite3_prepare_v2(db->handler, + SQL_UPDATE_FILE_DESTINATION, -1, + &ctx->stmt_update_file_destination, + NULL); + if (ret != SQLITE_OK) { + flb_plg_error(ctx->ins, "cannot prepare SQL statement: %s", + SQL_UPDATE_FILE_DESTINATION); + return -1; + } + /* delivery attempt counter update */ ret = sqlite3_prepare_v2(db->handler, SQL_UPDATE_FILE_DELIVERY_ATTEMPT_COUNT, -1, @@ -245,6 +256,7 @@ int azb_db_close(struct flb_azure_blob *ctx) sqlite3_finalize(ctx->stmt_delete_file); sqlite3_finalize(ctx->stmt_set_file_aborted_state); sqlite3_finalize(ctx->stmt_get_file); + sqlite3_finalize(ctx->stmt_update_file_destination); sqlite3_finalize(ctx->stmt_update_file_delivery_attempt_count); sqlite3_finalize(ctx->stmt_get_next_aborted_file); sqlite3_finalize(ctx->stmt_get_next_stale_file); @@ -295,7 +307,10 @@ int azb_db_file_exists(struct flb_azure_blob *ctx, char *path, uint64_t *id) } int64_t azb_db_file_insert(struct flb_azure_blob *ctx, - char *source, char *path, size_t size) + char *source, + char *destination, + char *path, + size_t size) { int ret; int64_t id; @@ -308,9 +323,10 @@ int64_t azb_db_file_insert(struct flb_azure_blob *ctx, /* Bind parameters */ sqlite3_bind_text(ctx->stmt_insert_file, 1, source, -1, 0); - sqlite3_bind_text(ctx->stmt_insert_file, 2, path, -1, 0); - sqlite3_bind_int64(ctx->stmt_insert_file, 3, size); - sqlite3_bind_int64(ctx->stmt_insert_file, 4, created); + sqlite3_bind_text(ctx->stmt_insert_file, 2, destination, -1, 0); + sqlite3_bind_text(ctx->stmt_insert_file, 3, path, -1, 0); + sqlite3_bind_int64(ctx->stmt_insert_file, 4, size); + sqlite3_bind_int64(ctx->stmt_insert_file, 5, created); /* Run the insert */ ret = sqlite3_step(ctx->stmt_insert_file); @@ -404,6 +420,35 @@ int azb_db_file_set_aborted_state(struct flb_azure_blob *ctx, return 0; } +int azb_db_file_change_destination(struct flb_azure_blob *ctx, uint64_t id, cfl_sds_t destination) +{ + int ret; + + azb_db_lock(ctx); + + /* Bind parameters */ + sqlite3_bind_text(ctx->stmt_update_file_destination, 1, destination, -1, 0); + sqlite3_bind_int64(ctx->stmt_update_file_destination, 2, id); + + /* Run the update */ + ret = sqlite3_step(ctx->stmt_update_file_destination); + + sqlite3_clear_bindings(ctx->stmt_update_file_destination); + sqlite3_reset(ctx->stmt_update_file_destination); + + azb_db_unlock(ctx); + + if (ret != SQLITE_DONE) { + flb_plg_error(ctx->ins, + "cannot update file destination " + "count for file id=%" PRIu64, id); + + return -1; + } + + return 0; +} + int azb_db_file_delivery_attempts(struct flb_azure_blob *ctx, uint64_t id, uint64_t attempts) { @@ -680,11 +725,14 @@ int azb_db_file_part_get_next(struct flb_azure_blob *ctx, off_t *offset_start, off_t *offset_end, uint64_t *part_delivery_attempts, uint64_t *file_delivery_attempts, - cfl_sds_t *file_path) + cfl_sds_t *file_path, + cfl_sds_t *destination) { int ret; char *tmp = NULL; + char *tmp_destination = NULL; cfl_sds_t path; + cfl_sds_t local_destination; if (azb_db_lock(ctx) != 0) { return -1; @@ -703,6 +751,7 @@ int azb_db_file_part_get_next(struct flb_azure_blob *ctx, *part_delivery_attempts = sqlite3_column_int64(ctx->stmt_get_next_file_part, 5); tmp = (char *) sqlite3_column_text(ctx->stmt_get_next_file_part, 6); *file_delivery_attempts = sqlite3_column_int64(ctx->stmt_get_next_file_part, 7); + tmp_destination = (char *) sqlite3_column_text(ctx->stmt_get_next_file_part, 8); } else if (ret == SQLITE_DONE) { /* no records */ @@ -719,11 +768,20 @@ int azb_db_file_part_get_next(struct flb_azure_blob *ctx, } path = cfl_sds_create(tmp); + local_destination = cfl_sds_create(tmp_destination); sqlite3_clear_bindings(ctx->stmt_get_next_file_part); sqlite3_reset(ctx->stmt_get_next_file_part); - if (!path) { + if (path == NULL || local_destination == NULL) { + if (path != NULL) { + cfl_sds_destroy(path); + } + + if (local_destination != NULL) { + cfl_sds_destroy(local_destination); + } + azb_db_unlock(ctx); return -1; } @@ -732,11 +790,14 @@ int azb_db_file_part_get_next(struct flb_azure_blob *ctx, ret = azb_db_file_part_in_progress(ctx, 1, *id); if (ret == -1) { cfl_sds_destroy(path); + cfl_sds_destroy(local_destination); azb_db_unlock(ctx); return -1; } *file_path = path; + *destination = local_destination; + azb_db_unlock(ctx); return 1; diff --git a/plugins/out_azure_blob/azure_blob_db.h b/plugins/out_azure_blob/azure_blob_db.h index 475d5ba9301..bbdbc66f1a3 100644 --- a/plugins/out_azure_blob/azure_blob_db.h +++ b/plugins/out_azure_blob/azure_blob_db.h @@ -29,6 +29,7 @@ "CREATE TABLE IF NOT EXISTS out_azure_blob_files (" \ " id INTEGER PRIMARY KEY," \ " source TEXT NOT NULL," \ + " destination TEXT NOT NULL," \ " path TEXT NOT NULL," \ " size INTEGER," \ " created INTEGER," \ @@ -52,8 +53,8 @@ ");" #define SQL_INSERT_FILE \ - "INSERT INTO out_azure_blob_files (source, path, size, created)" \ - " VALUES (@source, @path, @size, @created);" + "INSERT INTO out_azure_blob_files (source, destination, path, size, created)" \ + " VALUES (@source, @destination, @path, @size, @created);" /* DELETE a registered file and all it parts */ #define SQL_DELETE_FILE \ @@ -62,6 +63,9 @@ #define SQL_SET_FILE_ABORTED_STATE \ "UPDATE out_azure_blob_files SET aborted=@state WHERE id=@id;" +#define SQL_UPDATE_FILE_DESTINATION \ + "UPDATE out_azure_blob_files SET destination=@destination WHERE id=@id;" + #define SQL_UPDATE_FILE_DELIVERY_ATTEMPT_COUNT \ "UPDATE out_azure_blob_files " \ " SET delivery_attempts=@delivery_attempts, " \ @@ -121,25 +125,31 @@ " WHERE file_id=@id;" /* Find the oldest files and retrieve the oldest part ready to be uploaded */ -#define SQL_GET_NEXT_FILE_PART \ - "SELECT p.id, " \ - " p.file_id, " \ - " p.part_id, " \ - " p.offset_start, " \ - " p.offset_end, " \ - " p.delivery_attempts, " \ - " f.path, " \ - " f.delivery_attempts, " \ - " f.last_delivery_attempt " \ - "FROM out_azure_blob_parts p " \ - " JOIN out_azure_blob_files f " \ - " ON p.file_id = f.id " \ - "WHERE p.uploaded = 0 " \ - " AND p.in_progress = 0 " \ - " AND f.aborted = 0 " \ - "ORDER BY f.created ASC, " \ - " p.part_id ASC " \ - "LIMIT 1;" +#define SQL_GET_NEXT_FILE_PART \ + " SELECT p.id, " \ + " p.file_id, " \ + " p.part_id, " \ + " p.offset_start, " \ + " p.offset_end, " \ + " p.delivery_attempts, " \ + " f.path, " \ + " f.delivery_attempts, " \ + " f.last_delivery_attempt, " \ + " f.destination " \ + " FROM out_azure_blob_parts p " \ + " JOIN out_azure_blob_files f " \ + " ON p.file_id = f.id " \ + " WHERE p.uploaded = 0 " \ + " AND p.in_progress = 0 " \ + " AND f.aborted = 0 " \ + " AND (p.part_id = 0 OR " \ + " (SELECT sp.uploaded " \ + " FROM out_azure_blob_parts sp " \ + " WHERE sp.part_id = 0 " \ + " AND sp.file_id = p.file_id) = 1) " \ + "ORDER BY f.created ASC, " \ + " p.part_id ASC " \ + " LIMIT 1;" /* @@ -168,7 +178,10 @@ int azb_db_close(struct flb_azure_blob *ctx); int azb_db_file_exists(struct flb_azure_blob *ctx, char *path, uint64_t *id); int64_t azb_db_file_insert(struct flb_azure_blob *ctx, - char *source, char *path, size_t size); + char *source, + char *destination, + char *path, + size_t size); int azb_db_file_delete(struct flb_azure_blob *ctx, uint64_t id, char *path); @@ -176,6 +189,8 @@ int azb_db_file_set_aborted_state(struct flb_azure_blob *ctx, uint64_t id, char *path, uint64_t state); +int azb_db_file_change_destination(struct flb_azure_blob *ctx, uint64_t id, cfl_sds_t destination); + int azb_db_file_delivery_attempts(struct flb_azure_blob *ctx, uint64_t id, uint64_t attempts); int azb_db_file_get_next_aborted(struct flb_azure_blob *ctx, @@ -201,7 +216,8 @@ int azb_db_file_part_get_next(struct flb_azure_blob *ctx, off_t *offset_start, off_t *offset_end, uint64_t *part_delivery_attempts, uint64_t *file_delivery_attempts, - cfl_sds_t *file_path); + cfl_sds_t *file_path, + cfl_sds_t *destination); int azb_db_file_part_uploaded(struct flb_azure_blob *ctx, uint64_t id); int azb_db_file_part_delivery_attempts(struct flb_azure_blob *ctx, uint64_t file_id, From c7f9cf66750e18990de70fbdd6b1a02f35edd137 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 2 Oct 2024 22:30:42 +0200 Subject: [PATCH 282/295] out_azure_blob: fixed DELETE request signature generation Signed-off-by: Leonardo Alminana --- plugins/out_azure_blob/azure_blob_http.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/out_azure_blob/azure_blob_http.c b/plugins/out_azure_blob/azure_blob_http.c index af891c165c0..c5d26554adb 100644 --- a/plugins/out_azure_blob/azure_blob_http.c +++ b/plugins/out_azure_blob/azure_blob_http.c @@ -180,7 +180,7 @@ flb_sds_t azb_http_canonical_request(struct flb_azure_blob *ctx, tmp = flb_sds_cat(can_req, "PUT\n", 4); break; case FLB_HTTP_DELETE: - tmp = flb_sds_cat(can_req, "DELETE\n", 4); + tmp = flb_sds_cat(can_req, "DELETE\n", 7); break; }; From 2834552d1d86810659f116b5e476444529d39203 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Wed, 9 Oct 2024 23:52:35 +0200 Subject: [PATCH 283/295] in_blob: fixed windows compatibility issue Signed-off-by: Leonardo Alminana --- plugins/in_blob/blob.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/in_blob/blob.c b/plugins/in_blob/blob.c index 3dfcbec4d86..8081a9a42fe 100644 --- a/plugins/in_blob/blob.c +++ b/plugins/in_blob/blob.c @@ -33,6 +33,8 @@ #ifndef FLB_SYSTEM_WINDOWS #include #include +#else +#define strtok_r strtok_s #endif #include From d94857f43ec2ff2741a0bdf7acd65a796c9132b5 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Thu, 10 Oct 2024 10:27:25 -0600 Subject: [PATCH 284/295] http_server: http1: always reset the parser context on pending status Signed-off-by: Eduardo Silva --- src/http_server/flb_http_server_http1.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/http_server/flb_http_server_http1.c b/src/http_server/flb_http_server_http1.c index e5fcba9114d..74993b6b572 100644 --- a/src/http_server/flb_http_server_http1.c +++ b/src/http_server/flb_http_server_http1.c @@ -544,10 +544,13 @@ int flb_http1_server_session_ingest(struct flb_http1_server_session *session, } else if (result == MK_HTTP_PARSER_PENDING) { /* - * If the parser is still in a pending state, we just return a success - * status and wait for more data + * No significant actions are taken here until we reach MK_HTTP_PARSER_OK. + * The primary reason is that the caller may need to expand the buffer size + * when payloads exceed the current buffer's capacity. In such cases, parser + * pointers could end up referencing incorrect memory locations. + * To prevent this, we reset the parser state, which introduces a minimal + * performance overhead in exchange for ensuring safety. */ - return HTTP_SERVER_SUCCESS; } dummy_mk_http_request_init(&session->inner_session, &session->inner_request); From 80884002749013084a8fb68055d7f65771e8b8d4 Mon Sep 17 00:00:00 2001 From: Phillip Whelan Date: Thu, 10 Oct 2024 20:34:50 -0300 Subject: [PATCH 285/295] tests: internal: fix use-after-free for input_chunks test input_chunk_dropping_chunks. (#9472) Signed-off-by: Phillip Whelan --- tests/internal/input_chunk.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/tests/internal/input_chunk.c b/tests/internal/input_chunk.c index 2e2b5d04bef..945ddbbf13b 100644 --- a/tests/internal/input_chunk.c +++ b/tests/internal/input_chunk.c @@ -304,19 +304,6 @@ void flb_test_input_chunk_dropping_chunks() TEST_CHECK(ret == 0); } - /* FORCE clean up test tasks*/ - mk_list_foreach_safe(head, tmp, &i_ins->tasks) { - task = mk_list_entry(head, struct flb_task, _head); - flb_info("[task] cleanup test task"); - flb_task_destroy(task, FLB_TRUE); - } - - /* clean up test chunks */ - mk_list_foreach_safe(head, tmp, &i_ins->chunks) { - ic = mk_list_entry(head, struct flb_input_chunk, _head); - flb_input_chunk_destroy(ic, FLB_TRUE); - } - flb_time_msleep(2100); flb_stop(ctx); flb_destroy(ctx); From 0160741ab0ecbe553a84ab27f772a0752e6f27f0 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Thu, 10 Oct 2024 14:04:09 -0600 Subject: [PATCH 286/295] out_opentelemetry: fix check for uri sanitization when exiting Signed-off-by: Eduardo Silva --- plugins/out_opentelemetry/opentelemetry.c | 2 +- plugins/out_opentelemetry/opentelemetry_conf.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/out_opentelemetry/opentelemetry.c b/plugins/out_opentelemetry/opentelemetry.c index cc5680ba3b2..8471c8102f6 100644 --- a/plugins/out_opentelemetry/opentelemetry.c +++ b/plugins/out_opentelemetry/opentelemetry.c @@ -312,7 +312,7 @@ static int process_metrics(struct flb_event_chunk *event_chunk, diff = off; /* concat buffer */ - flb_sds_cat_safe(&buf, encoded_chunk, flb_sds_len(encoded_chunk)); + flb_sds_cat_safe(&buf, encoded_chunk, cfl_sds_len(encoded_chunk)); /* release */ cmt_encode_opentelemetry_destroy(encoded_chunk); diff --git a/plugins/out_opentelemetry/opentelemetry_conf.c b/plugins/out_opentelemetry/opentelemetry_conf.c index 80a193d37b5..f6c8b40ba9c 100644 --- a/plugins/out_opentelemetry/opentelemetry_conf.c +++ b/plugins/out_opentelemetry/opentelemetry_conf.c @@ -555,15 +555,15 @@ void flb_opentelemetry_context_destroy(struct opentelemetry_context *ctx) flb_upstream_destroy(ctx->u); } - if (ctx->logs_uri_sanitized != NULL) { + if (ctx->logs_uri_sanitized != NULL && ctx->logs_uri_sanitized != ctx->logs_uri) { flb_free(ctx->logs_uri_sanitized); } - if (ctx->traces_uri_sanitized != NULL) { + if (ctx->traces_uri_sanitized != NULL && ctx->traces_uri_sanitized != ctx->traces_uri) { flb_free(ctx->traces_uri_sanitized); } - if (ctx->metrics_uri_sanitized != NULL) { + if (ctx->metrics_uri_sanitized != NULL && ctx->metrics_uri_sanitized != ctx->metrics_uri) { flb_free(ctx->metrics_uri_sanitized); } From 50ff1fabdcbc222edca8c4668f5e529f015bf77d Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Thu, 10 Oct 2024 17:06:16 -0600 Subject: [PATCH 287/295] lib: cmetrics: upgrade to v0.9.7 Signed-off-by: Eduardo Silva --- lib/cmetrics/CMakeLists.txt | 2 +- lib/cmetrics/src/cmt_encode_opentelemetry.c | 73 +++++++++------------ 2 files changed, 31 insertions(+), 44 deletions(-) diff --git a/lib/cmetrics/CMakeLists.txt b/lib/cmetrics/CMakeLists.txt index 4f298910674..6583856fa28 100644 --- a/lib/cmetrics/CMakeLists.txt +++ b/lib/cmetrics/CMakeLists.txt @@ -6,7 +6,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # CMetrics Version set(CMT_VERSION_MAJOR 0) set(CMT_VERSION_MINOR 9) -set(CMT_VERSION_PATCH 6) +set(CMT_VERSION_PATCH 7) set(CMT_VERSION_STR "${CMT_VERSION_MAJOR}.${CMT_VERSION_MINOR}.${CMT_VERSION_PATCH}") # Include helpers diff --git a/lib/cmetrics/src/cmt_encode_opentelemetry.c b/lib/cmetrics/src/cmt_encode_opentelemetry.c index 8378bc8694d..af7605f7e73 100644 --- a/lib/cmetrics/src/cmt_encode_opentelemetry.c +++ b/lib/cmetrics/src/cmt_encode_opentelemetry.c @@ -33,8 +33,7 @@ static Opentelemetry__Proto__Metrics__V1__ScopeMetrics ** static void destroy_scope_metric_list( Opentelemetry__Proto__Metrics__V1__ScopeMetrics **metric_list); -struct cfl_kvlist *fetch_metadata_kvlist_key( - struct cfl_kvlist *kvlist, char *key) +struct cfl_kvlist *fetch_metadata_kvlist_key(struct cfl_kvlist *kvlist, char *key) { struct cfl_variant *entry_variant; struct cfl_kvlist *entry_kvlist; @@ -1015,16 +1014,6 @@ static Opentelemetry__Proto__Metrics__V1__ResourceMetrics ** return metric_list; } -static void destroy_scope_metrics( - Opentelemetry__Proto__Metrics__V1__ScopeMetrics *metric) -{ - if (metric != NULL) { - destroy_metric_list(metric->metrics); - - free(metric); - } -} - void destroy_instrumentation_scope(Opentelemetry__Proto__Common__V1__InstrumentationScope *scope) { if (scope->name != NULL) { @@ -1042,6 +1031,21 @@ void destroy_instrumentation_scope(Opentelemetry__Proto__Common__V1__Instrumenta free(scope); } +static void destroy_scope_metrics(Opentelemetry__Proto__Metrics__V1__ScopeMetrics *metric) +{ + if (metric != NULL) { + if (is_string_releaseable(metric->schema_url)) { + cfl_sds_destroy(metric->schema_url); + metric->schema_url = NULL; + } + if (metric->scope != NULL) { + destroy_instrumentation_scope(metric->scope); + } + destroy_metric_list(metric->metrics); + free(metric); + } +} + static Opentelemetry__Proto__Common__V1__InstrumentationScope * initialize_instrumentation_scope( struct cfl_kvlist *scope_root, @@ -1065,9 +1069,7 @@ static Opentelemetry__Proto__Common__V1__InstrumentationScope * return NULL; } - scope = \ - calloc(1, sizeof(Opentelemetry__Proto__Common__V1__InstrumentationScope)); - + scope = calloc(1, sizeof(Opentelemetry__Proto__Common__V1__InstrumentationScope)); if (scope == NULL) { *error_detection_flag = CMT_TRUE; @@ -1109,10 +1111,9 @@ static Opentelemetry__Proto__Common__V1__InstrumentationScope * return scope; } -static Opentelemetry__Proto__Metrics__V1__ScopeMetrics * - initialize_scope_metrics( - struct cfl_kvlist *scope_metrics_root, - size_t metric_element_count) +static Opentelemetry__Proto__Metrics__V1__ScopeMetrics *initialize_scope_metrics( + struct cfl_kvlist *scope_metrics_root, + size_t metric_element_count) { int error_detection_flag; Opentelemetry__Proto__Metrics__V1__ScopeMetrics *scope_metrics; @@ -1120,9 +1121,7 @@ static Opentelemetry__Proto__Metrics__V1__ScopeMetrics * metadata = fetch_metadata_kvlist_key(scope_metrics_root, "metadata"); - scope_metrics = \ - calloc(1, sizeof(Opentelemetry__Proto__Metrics__V1__ScopeMetrics)); - + scope_metrics = calloc(1, sizeof(Opentelemetry__Proto__Metrics__V1__ScopeMetrics)); if (scope_metrics == NULL) { return NULL; } @@ -1132,9 +1131,7 @@ static Opentelemetry__Proto__Metrics__V1__ScopeMetrics * error_detection_flag = CMT_FALSE; if (metric_element_count > 0) { - scope_metrics->metrics = \ - initialize_metric_list(metric_element_count); - + scope_metrics->metrics = initialize_metric_list(metric_element_count); if (scope_metrics->metrics == NULL) { error_detection_flag = CMT_TRUE; } @@ -1145,12 +1142,11 @@ static Opentelemetry__Proto__Metrics__V1__ScopeMetrics * if (!error_detection_flag && metadata != NULL) { scope_metrics->schema_url = fetch_metadata_string_key(metadata, "schema_url", &error_detection_flag); + } - if (error_detection_flag && - scope_metrics != NULL) { + if (error_detection_flag && scope_metrics != NULL) { destroy_scope_metrics(scope_metrics); - scope_metrics = NULL; } @@ -1195,9 +1191,7 @@ static void destroy_scope_metric_list( } } -static Opentelemetry__Proto__Metrics__V1__ScopeMetrics ** - initialize_scope_metrics_list( - size_t element_count) +static Opentelemetry__Proto__Metrics__V1__ScopeMetrics **initialize_scope_metrics_list(size_t element_count) { Opentelemetry__Proto__Metrics__V1__ScopeMetrics **metric_list; @@ -1207,8 +1201,7 @@ static Opentelemetry__Proto__Metrics__V1__ScopeMetrics ** return metric_list; } -static void destroy_attribute( - Opentelemetry__Proto__Common__V1__KeyValue *attribute) +static void destroy_attribute(Opentelemetry__Proto__Common__V1__KeyValue *attribute) { if (attribute != NULL) { if (attribute->value != NULL) { @@ -2078,10 +2071,8 @@ static void destroy_opentelemetry_context( } } -static Opentelemetry__Proto__Resource__V1__Resource * - initialize_resource( - struct cfl_kvlist *resource_root, - int *error_detection_flag) +static Opentelemetry__Proto__Resource__V1__Resource *initialize_resource(struct cfl_kvlist *resource_root, + int *error_detection_flag) { struct cfl_kvlist *attributes; struct cfl_kvlist *metadata; @@ -2096,17 +2087,13 @@ static Opentelemetry__Proto__Resource__V1__Resource * attributes = fetch_metadata_kvlist_key(resource_root, "attributes"); metadata = fetch_metadata_kvlist_key(resource_root, "metadata"); - if (cfl_kvlist_count(attributes) == 0 && - cfl_kvlist_count(metadata) == 0) { + if (cfl_kvlist_count(attributes) == 0 && cfl_kvlist_count(metadata) == 0) { return NULL; } - resource = \ - calloc(1, sizeof(Opentelemetry__Proto__Resource__V1__Resource)); - + resource = calloc(1, sizeof(Opentelemetry__Proto__Resource__V1__Resource)); if (resource == NULL) { *error_detection_flag = CMT_TRUE; - return NULL; } From aa304e97c252bf5080266d827cf6c87491ba7a57 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 14 Oct 2024 12:14:13 -0600 Subject: [PATCH 288/295] lib: cmetrics: upgrade to v0.9.8 Signed-off-by: Eduardo Silva --- lib/cmetrics/CMakeLists.txt | 2 +- .../include/cmetrics/cmt_decode_prometheus.h | 1 + lib/cmetrics/src/cmt_cat.c | 4 +- lib/cmetrics/src/cmt_decode_msgpack.c | 10 ++-- lib/cmetrics/src/cmt_decode_prometheus.c | 58 +++++++++++++++---- lib/cmetrics/src/cmt_encode_prometheus.c | 2 +- lib/cmetrics/src/cmt_encode_splunk_hec.c | 16 +++-- 7 files changed, 68 insertions(+), 25 deletions(-) diff --git a/lib/cmetrics/CMakeLists.txt b/lib/cmetrics/CMakeLists.txt index 6583856fa28..55d02dc8619 100644 --- a/lib/cmetrics/CMakeLists.txt +++ b/lib/cmetrics/CMakeLists.txt @@ -6,7 +6,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # CMetrics Version set(CMT_VERSION_MAJOR 0) set(CMT_VERSION_MINOR 9) -set(CMT_VERSION_PATCH 7) +set(CMT_VERSION_PATCH 8) set(CMT_VERSION_STR "${CMT_VERSION_MAJOR}.${CMT_VERSION_MINOR}.${CMT_VERSION_PATCH}") # Include helpers diff --git a/lib/cmetrics/include/cmetrics/cmt_decode_prometheus.h b/lib/cmetrics/include/cmetrics/cmt_decode_prometheus.h index 7500469d25a..5087981e00e 100644 --- a/lib/cmetrics/include/cmetrics/cmt_decode_prometheus.h +++ b/lib/cmetrics/include/cmetrics/cmt_decode_prometheus.h @@ -33,6 +33,7 @@ #define CMT_DECODE_PROMETHEUS_CMT_CREATE_ERROR 50 #define CMT_DECODE_PROMETHEUS_PARSE_VALUE_FAILED 60 #define CMT_DECODE_PROMETHEUS_PARSE_TIMESTAMP_FAILED 70 +#define CMT_DECODE_PROMETHEUS_SAMPLE_VALUE_TOO_LONG 80 #define CMT_DECODE_PROMETHEUS_MAX_LABEL_COUNT 128 diff --git a/lib/cmetrics/src/cmt_cat.c b/lib/cmetrics/src/cmt_cat.c index 5ef28d4f831..dcd941bdb81 100644 --- a/lib/cmetrics/src/cmt_cat.c +++ b/lib/cmetrics/src/cmt_cat.c @@ -36,7 +36,7 @@ int cmt_cat_copy_label_keys(struct cmt_map *map, char **out) /* labels array */ s = map->label_count; - if (s == 0) { + if (s <= 0) { *out = NULL; return 0; } @@ -242,7 +242,7 @@ static inline int cmt_opts_compare(struct cmt_opts *a, struct cmt_opts *b) { int ret; - ret = strcmp(a->ns, a->ns); + ret = strcmp(a->ns, b->ns); if (ret != 0) { return ret; } diff --git a/lib/cmetrics/src/cmt_decode_msgpack.c b/lib/cmetrics/src/cmt_decode_msgpack.c index 25942b354ab..3730af8a294 100644 --- a/lib/cmetrics/src/cmt_decode_msgpack.c +++ b/lib/cmetrics/src/cmt_decode_msgpack.c @@ -227,15 +227,15 @@ static int unpack_opts(mpack_reader_t *reader, struct cmt_opts *opts) } if (cfl_sds_len(opts->ns) > 0) { - cfl_sds_cat(opts->fqname, opts->ns, cfl_sds_len(opts->ns)); - cfl_sds_cat(opts->fqname, "_", 1); + cfl_sds_cat_safe(&opts->fqname, opts->ns, cfl_sds_len(opts->ns)); + cfl_sds_cat_safe(&opts->fqname, "_", 1); } if (cfl_sds_len(opts->subsystem) > 0) { - cfl_sds_cat(opts->fqname, opts->subsystem, cfl_sds_len(opts->subsystem)); - cfl_sds_cat(opts->fqname, "_", 1); + cfl_sds_cat_safe(&opts->fqname, opts->subsystem, cfl_sds_len(opts->subsystem)); + cfl_sds_cat_safe(&opts->fqname, "_", 1); } - cfl_sds_cat(opts->fqname, opts->name, cfl_sds_len(opts->name)); + cfl_sds_cat_safe(&opts->fqname, opts->name, cfl_sds_len(opts->name)); } return result; diff --git a/lib/cmetrics/src/cmt_decode_prometheus.c b/lib/cmetrics/src/cmt_decode_prometheus.c index 134cb92a54c..ba7ec47b381 100644 --- a/lib/cmetrics/src/cmt_decode_prometheus.c +++ b/lib/cmetrics/src/cmt_decode_prometheus.c @@ -456,14 +456,22 @@ static int add_metric_histogram(struct cmt_decode_prometheus_context *context) cfl_sds_t *labels_without_le = NULL; cfl_sds_t *values_without_le = NULL; int label_i; - uint64_t timestamp; + uint64_t timestamp = 0; + + if (cfl_list_size(&context->metric.samples) < 3) { + return report_error(context, + CMT_DECODE_PROMETHEUS_SYNTAX_ERROR, + "not enough samples for histogram"); + } /* bucket_count = sample count - 3: * - "Inf" bucket * - sum * - count */ bucket_count = cfl_list_size(&context->metric.samples) - 3; - timestamp = context->opts.override_timestamp; + if (context->opts.override_timestamp) { + timestamp = context->opts.override_timestamp; + } bucket_defaults = calloc(bucket_count + 1, sizeof(*bucket_defaults)); if (!bucket_defaults) { @@ -627,6 +635,7 @@ static int add_metric_histogram(struct cmt_decode_prometheus_context *context) context->current.histogram = h; } + if (cmt_histogram_set_default(h, timestamp, bucket_defaults, sum, count, label_i, label_i ? values_without_le : NULL)) { @@ -661,7 +670,7 @@ static int add_metric_summary(struct cmt_decode_prometheus_context *context) size_t quantile_index; double *quantiles = NULL; double *quantile_defaults = NULL; - double sum; + double sum = 0.0; double count_dbl; size_t label_count; uint64_t count = 0; @@ -673,13 +682,21 @@ static int add_metric_summary(struct cmt_decode_prometheus_context *context) cfl_sds_t *labels_without_quantile = NULL; cfl_sds_t *values_without_quantile = NULL; int label_i; - uint64_t timestamp; + uint64_t timestamp = 0; + + if (cfl_list_size(&context->metric.samples) < 2) { + return report_error(context, + CMT_DECODE_PROMETHEUS_SYNTAX_ERROR, + "not enough samples for summary"); + } /* quantile_count = sample count - 2: * - sum * - count */ quantile_count = cfl_list_size(&context->metric.samples) - 2; - timestamp = context->opts.override_timestamp; + if (context->opts.override_timestamp) { + timestamp = context->opts.override_timestamp; + } quantile_defaults = calloc(quantile_count, sizeof(*quantile_defaults)); if (!quantile_defaults) { @@ -1143,17 +1160,36 @@ static int sample_start(struct cmt_decode_prometheus_context *context) return 0; } -static int parse_sample( - struct cmt_decode_prometheus_context *context, - const char *value1, - const char *value2) +static int parse_sample(struct cmt_decode_prometheus_context *context, + const char *value1, + const char *value2) { + int len; struct cmt_decode_prometheus_context_sample *sample; sample = cfl_list_entry_last(&context->metric.samples, struct cmt_decode_prometheus_context_sample, _head); - strcpy(sample->value1, value1); - strcpy(sample->value2, value2); + /* value1 */ + len = strlen(value1); + if (len >= sizeof(sample->value1) - 1) { + return report_error(context, + CMT_DECODE_PROMETHEUS_SAMPLE_VALUE_TOO_LONG, + "sample value is too long (max %zu characters)", sizeof(sample->value1) - 1); + } + + strncpy(sample->value1, value1, len); + sample->value1[len] = 0; + + /* value2 */ + len = strlen(value2); + if (len >= sizeof(sample->value2) - 1) { + return report_error(context, + CMT_DECODE_PROMETHEUS_SAMPLE_VALUE_TOO_LONG, + "sample value is too long (max %zu characters)", sizeof(sample->value2) - 1); + } + strncpy(sample->value2, value2, len); + sample->value2[len] = 0; + return 0; } diff --git a/lib/cmetrics/src/cmt_encode_prometheus.c b/lib/cmetrics/src/cmt_encode_prometheus.c index 287d701bccc..f020288323b 100644 --- a/lib/cmetrics/src/cmt_encode_prometheus.c +++ b/lib/cmetrics/src/cmt_encode_prometheus.c @@ -139,7 +139,7 @@ static void append_metric_value(cfl_sds_t *buf, struct prom_fmt *fmt, int add_timestamp) { int len; - double val; + double val = 0.0; uint64_t ts; char tmp[128]; diff --git a/lib/cmetrics/src/cmt_encode_splunk_hec.c b/lib/cmetrics/src/cmt_encode_splunk_hec.c index 3cbc9663396..49def335fa3 100644 --- a/lib/cmetrics/src/cmt_encode_splunk_hec.c +++ b/lib/cmetrics/src/cmt_encode_splunk_hec.c @@ -121,12 +121,15 @@ static void append_metric_value(cfl_sds_t *buf, struct cmt_map *map, static void format_context_common(struct cmt_splunk_hec_context *context, cfl_sds_t *buf, struct cmt_map *map, struct cmt_metric *metric) { - int len, tlen; + int len; + int tlen; + int result = CMT_ENCODE_SPLUNK_HEC_ALLOCATION_ERROR; + uint64_t ts; char hostname[256], timestamp[128]; - char *index = NULL, *source = NULL, *source_type = NULL; + char *index = NULL; + char *source = NULL; + char *source_type = NULL; struct timespec tms; - uint64_t ts; - int result = CMT_ENCODE_SPLUNK_HEC_ALLOCATION_ERROR; /* Open parenthesis */ cfl_sds_cat_safe(buf, "{", 1); @@ -159,6 +162,7 @@ static void format_context_common(struct cmt_splunk_hec_context *context, cfl_sd len = snprintf(index, tlen, "\"index\":\"%s\",", context->index); cfl_sds_cat_safe(buf, index, len); free(index); + index = NULL; } /* source */ @@ -174,13 +178,14 @@ static void format_context_common(struct cmt_splunk_hec_context *context, cfl_sd len = snprintf(source, tlen, "\"source\":\"%s\",", context->source); cfl_sds_cat_safe(buf, source, len); free(source); + source = NULL; } /* sourcetype */ if (context->source_type != NULL) { tlen = strlen(context->source_type) + 18; /* adding snprintf template character length */ source_type = malloc(tlen); - if (source == NULL) { + if (source_type == NULL) { cmt_errno(); result = CMT_ENCODE_SPLUNK_HEC_ALLOCATION_ERROR; @@ -189,6 +194,7 @@ static void format_context_common(struct cmt_splunk_hec_context *context, cfl_sd len = snprintf(source_type, tlen, "\"sourcetype\":\"%s\",", context->source_type); cfl_sds_cat_safe(buf, source_type, len); free(source_type); + source_type = NULL; } return; From 987cccd0e8b78bfc12d7bb3851bf60b94b672cd6 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 14 Oct 2024 13:12:25 -0600 Subject: [PATCH 289/295] lib: ctraces: upgrade to v0.5.7 Signed-off-by: Eduardo Silva --- lib/ctraces/CMakeLists.txt | 2 +- lib/ctraces/src/ctr_encode_opentelemetry.c | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/ctraces/CMakeLists.txt b/lib/ctraces/CMakeLists.txt index e92834e0611..e47ba022da1 100644 --- a/lib/ctraces/CMakeLists.txt +++ b/lib/ctraces/CMakeLists.txt @@ -27,7 +27,7 @@ endif() # CTraces Version set(CTR_VERSION_MAJOR 0) set(CTR_VERSION_MINOR 5) -set(CTR_VERSION_PATCH 6) +set(CTR_VERSION_PATCH 7) set(CTR_VERSION_STR "${CTR_VERSION_MAJOR}.${CTR_VERSION_MINOR}.${CTR_VERSION_PATCH}") # Define __FILENAME__ consistently across Operating Systems diff --git a/lib/ctraces/src/ctr_encode_opentelemetry.c b/lib/ctraces/src/ctr_encode_opentelemetry.c index 8a78f81a7fc..8ec3ad5e922 100644 --- a/lib/ctraces/src/ctr_encode_opentelemetry.c +++ b/lib/ctraces/src/ctr_encode_opentelemetry.c @@ -34,6 +34,8 @@ static inline void otlp_array_destroy(Opentelemetry__Proto__Common__V1__ArrayVal static inline void otlp_kvpair_list_destroy(Opentelemetry__Proto__Common__V1__KeyValue **pair_list, size_t entry_count); +static void destroy_spans(Opentelemetry__Proto__Trace__V1__Span **spans, size_t count); + static inline void otlp_kvpair_destroy(Opentelemetry__Proto__Common__V1__KeyValue *kvpair) { if (kvpair != NULL) { @@ -425,8 +427,7 @@ static inline Opentelemetry__Proto__Common__V1__AnyValue *ctr_variant_string_to_ if (result->string_value == NULL) { otlp_any_value_destroy(result); - - result = NULL; + return NULL; } } @@ -484,8 +485,8 @@ static inline Opentelemetry__Proto__Common__V1__AnyValue *ctr_variant_binary_to_ if (result->bytes_value.data == NULL) { otlp_any_value_destroy(result); - result = NULL; + } memcpy(result->bytes_value.data, value->data.as_bytes, result->bytes_value.len); @@ -884,6 +885,9 @@ static Opentelemetry__Proto__Trace__V1__Span **set_spans(struct ctrace_scope_spa otel_span = initialize_span(); if (!otel_span) { + if (span_index > 0) { + destroy_spans(spans, span_index); + } return NULL; } @@ -992,9 +996,7 @@ static Opentelemetry__Proto__Trace__V1__ScopeSpans **set_scope_spans(struct ctra if (scope_span_index > 0) { destroy_scope_spans(scope_spans, scope_span_index - 1); } - - free(scope_spans); - + /* note: scope_spans is freed inside destroy_scope_spans() */ return NULL; } From 9bf2c51ebe5c519ad70f16f6da5e81d6e85b5f80 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 14 Oct 2024 13:33:53 -0600 Subject: [PATCH 290/295] in_splunk: small fixes on return values (CID 508015 508060 510619) Signed-off-by: Eduardo Silva --- plugins/in_splunk/splunk_prot.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/plugins/in_splunk/splunk_prot.c b/plugins/in_splunk/splunk_prot.c index b550452ff73..c312d2623b8 100644 --- a/plugins/in_splunk/splunk_prot.c +++ b/plugins/in_splunk/splunk_prot.c @@ -524,10 +524,10 @@ static int validate_auth_header(struct flb_splunk *ctx, struct mk_http_request * ret = SPLUNK_AUTH_UNAUTHORIZED; flb_sds_destroy(authorization); - return ret; } else { + flb_sds_destroy(authorization); return SPLUNK_AUTH_MISSING_CRED; } @@ -710,7 +710,7 @@ int splunk_prot_handle(struct flb_splunk *ctx, struct splunk_conn *conn, char *uri; char *qs; char *original_data = NULL; - size_t original_data_size; + size_t original_data_size = 0; char *out_chunked = NULL; size_t out_chunked_size = 0; off_t diff; @@ -1145,7 +1145,7 @@ int splunk_prot_handle_ng(struct flb_http_request *request, struct flb_http_response *response) { struct flb_splunk *context; - int ret; + int ret = -1; flb_sds_t tag; context = (struct flb_splunk *) response->stream->user_data; @@ -1210,40 +1210,33 @@ int splunk_prot_handle_ng(struct flb_http_request *request, if (strcasecmp(request->path, "/services/collector/raw/1.0") == 0 || strcasecmp(request->path, "/services/collector/raw") == 0) { ret = process_hec_raw_payload_ng(request, response, tag, context); - if (ret != 0) { send_json_message_response_ng(response, 400, "{\"text\":\"Invalid data format\",\"code\":6}"); + ret = -1; } else { send_json_message_response_ng(response, 200, "{\"text\":\"Success\",\"code\":0}"); + ret = 0; } - - ret = 0; } else if (strcasecmp(request->path, "/services/collector/event/1.0") == 0 || strcasecmp(request->path, "/services/collector/event") == 0 || strcasecmp(request->path, "/services/collector") == 0) { ret = process_hec_payload_ng(request, response, tag, context); - if (ret != 0) { send_json_message_response_ng(response, 400, "{\"text\":\"Invalid data format\",\"code\":6}"); - ret = -1; } else { send_json_message_response_ng(response, 200, "{\"text\":\"Success\",\"code\":0}"); + ret = 0; } - - ret = 0; } else { send_response_ng(response, 400, "error: invalid HTTP endpoint\n"); - ret = -1; } flb_sds_destroy(tag); - - return ret; } \ No newline at end of file From a6f9c51f592c5d2ee98a07f41ee1e0a935078e37 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 14 Oct 2024 13:35:59 -0600 Subject: [PATCH 291/295] in_forward: release shared salt on exception (CID 507596) Signed-off-by: Eduardo Silva --- plugins/in_forward/fw_prot.c | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/in_forward/fw_prot.c b/plugins/in_forward/fw_prot.c index 1949f254f60..12dc38d2496 100644 --- a/plugins/in_forward/fw_prot.c +++ b/plugins/in_forward/fw_prot.c @@ -621,6 +621,7 @@ static int check_ping(struct flb_input_instance *ins, flb_plg_error(ins, "Invalid username type message"); flb_free(serverside); flb_free(hostname); + flb_free(shared_key_salt); msgpack_unpacked_destroy(&result); return -1; } From cad2476fa76f18e24dd14380cea82537871a71eb Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 14 Oct 2024 13:40:30 -0600 Subject: [PATCH 292/295] in_forward: validate return value when ingesting data (CID 507683) Signed-off-by: Eduardo Silva --- plugins/in_forward/fw_prot.c | 37 +++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/plugins/in_forward/fw_prot.c b/plugins/in_forward/fw_prot.c index 12dc38d2496..aaac5edec2a 100644 --- a/plugins/in_forward/fw_prot.c +++ b/plugins/in_forward/fw_prot.c @@ -1113,34 +1113,49 @@ static int append_log(struct flb_input_instance *ins, struct fw_conn *conn, struct ctrace *ctr; if (event_type == FLB_EVENT_TYPE_LOGS) { - flb_input_log_append(conn->in, - out_tag, flb_sds_len(out_tag), - data, len); + ret = flb_input_log_append(conn->in, + out_tag, flb_sds_len(out_tag), + data, len); + if (ret != 0) { + flb_plg_error(ins, "could not append logs. ret=%d", ret); + return -1; + } return 0; } else if (event_type == FLB_EVENT_TYPE_METRICS) { ret = cmt_decode_msgpack_create(&cmt, (char *) data, len, &off); if (ret != CMT_DECODE_MSGPACK_SUCCESS) { - flb_error("cmt_decode_msgpack_create failed. ret=%d", ret); + flb_plg_error(ins, "cmt_decode_msgpack_create failed. ret=%d", ret); + return -1; + } + + ret = flb_input_metrics_append(conn->in, + out_tag, flb_sds_len(out_tag), + cmt); + if (ret != 0) { + flb_plg_error(ins, "could not append metrics. ret=%d", ret); + cmt_decode_msgpack_destroy(cmt); return -1; } - flb_input_metrics_append(conn->in, - out_tag, flb_sds_len(out_tag), - cmt); cmt_decode_msgpack_destroy(cmt); } else if (event_type == FLB_EVENT_TYPE_TRACES) { off = 0; ret = ctr_decode_msgpack_create(&ctr, (char *) data, len, &off); if (ret == -1) { + flb_error("could not decode trace message. ret=%d", ret); return -1; } - flb_input_trace_append(ins, - out_tag, flb_sds_len(out_tag), - ctr); - + ret = flb_input_trace_append(ins, + out_tag, flb_sds_len(out_tag), + ctr); + if (ret != 0) { + flb_plg_error(ins, "could not append traces. ret=%d", ret); + ctr_decode_msgpack_destroy(ctr); + return -1; + } ctr_decode_msgpack_destroy(ctr); } From c22e7db6bfdd7f06bf69ef79bdf821f26f2c1256 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 14 Oct 2024 13:50:54 -0600 Subject: [PATCH 293/295] in_forward: fix leaks on exception (CID 507786 507954 508064) Signed-off-by: Eduardo Silva --- plugins/in_forward/fw_prot.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/in_forward/fw_prot.c b/plugins/in_forward/fw_prot.c index aaac5edec2a..d5062c365c8 100644 --- a/plugins/in_forward/fw_prot.c +++ b/plugins/in_forward/fw_prot.c @@ -599,6 +599,7 @@ static int check_ping(struct flb_input_instance *ins, if (o.type != MSGPACK_OBJECT_STR) { flb_plg_error(ins, "Invalid shared_key_salt type message"); flb_free(serverside); + flb_free(hostname); msgpack_unpacked_destroy(&result); return -1; } @@ -609,7 +610,9 @@ static int check_ping(struct flb_input_instance *ins, if (o.type != MSGPACK_OBJECT_STR) { flb_plg_error(ins, "Invalid shared_key_digest type message"); flb_free(serverside); + flb_free(hostname); msgpack_unpacked_destroy(&result); + return -1; } shared_key_digest = flb_sds_create_len(o.via.str.ptr, o.via.str.size); @@ -635,6 +638,7 @@ static int check_ping(struct flb_input_instance *ins, flb_free(hostname); flb_free(shared_key_salt); flb_free(shared_key_digest); + flb_free(username); msgpack_unpacked_destroy(&result); return -1; } @@ -649,7 +653,10 @@ static int check_ping(struct flb_input_instance *ins, flb_free(serverside); flb_free(username); flb_free(password_digest); - flb_plg_error(ctx->ins, "failed to hash shard_key"); + flb_free(shared_key_salt); + flb_free(shared_key_digest); + flb_free(hostname); + flb_plg_error(ctx->ins, "failed to hash shared_key"); return -1; } From 562fc809586f5f084b3c9597e0ad9e727f8050eb Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 14 Oct 2024 13:51:58 -0600 Subject: [PATCH 294/295] out_s3: fix buffered data on exception (CID 309438) Signed-off-by: Eduardo Silva --- plugins/out_s3/s3_multipart.c | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/out_s3/s3_multipart.c b/plugins/out_s3/s3_multipart.c index f8cc4d13b47..967a27420f2 100644 --- a/plugins/out_s3/s3_multipart.c +++ b/plugins/out_s3/s3_multipart.c @@ -192,6 +192,7 @@ static struct multipart_upload *upload_from_file(struct flb_s3 *ctx, if (ret == -1) { flb_plg_error(ctx->ins, "Could not read file metadata: %s", fsf->name); + flb_free(buffered_data); return NULL; } From cbfc240231ef40c835c129aa85f50172ccf22bbe Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 14 Oct 2024 13:54:30 -0600 Subject: [PATCH 295/295] out_s3: release context on mock client excepion (CID 310831) Signed-off-by: Eduardo Silva --- plugins/out_s3/s3.c | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/out_s3/s3.c b/plugins/out_s3/s3.c index b8fe80f0dd2..3b1edafbdab 100644 --- a/plugins/out_s3/s3.c +++ b/plugins/out_s3/s3.c @@ -247,6 +247,7 @@ struct flb_http_client *mock_s3_call(char *error_env_var, char *api) c->resp.data = flb_calloc(len + 1, sizeof(char)); if (!c->resp.data) { flb_errno(); + flb_free(c); return NULL; } memcpy(c->resp.data, resp, len);