From b470dafc83e78f83f61a03538d5a7ad6d8e8e032 Mon Sep 17 00:00:00 2001 From: tangce Date: Fri, 25 Jul 2025 17:28:19 +0800 Subject: [PATCH] add print options --- add-print-options.patch | 226 ++++++++++++++++++++++++++++++++++++++++ glibc.spec | 8 +- 2 files changed, 232 insertions(+), 2 deletions(-) create mode 100644 add-print-options.patch diff --git a/add-print-options.patch b/add-print-options.patch new file mode 100644 index 0000000..81175c5 --- /dev/null +++ b/add-print-options.patch @@ -0,0 +1,226 @@ +From c6d1a6e1615e0fd276e37e967a198ea9b81e1178 Mon Sep 17 00:00:00 2001 +From: tangce +Date: Mon, 28 Jul 2025 15:32:51 +0800 +Subject: [PATCH] add + +--- + resolv/nss_dns/dns-host.c | 6 +++++- + resolv/resolv_context.c | 37 +++++++++++++++++++++++++++++++++---- + sysdeps/posix/getaddrinfo.c | 28 +++++++++++++++++++++++++--- + 3 files changed, 63 insertions(+), 8 deletions(-) + +diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c +index c45344a0..23f63771 100644 +--- a/resolv/nss_dns/dns-host.c ++++ b/resolv/nss_dns/dns-host.c +@@ -79,7 +79,7 @@ + #include + #include + #include +- ++#include + #include "nsswitch.h" + #include + #include +@@ -371,6 +371,8 @@ _nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, + int ans2p_malloced = 0; + + int olderr = errno; ++ openlog("getaddrinfo", LOG_PID | LOG_CONS, LOG_USER); ++ syslog(LOG_INFO, "_res_context_session result n:%d\n", n); + int n = __res_context_search (ctx, name, C_IN, T_QUERY_A_AND_AAAA, + host_buffer.buf->buf, 2048, &host_buffer.ptr, + &ans2p, &nans2p, &resplen2, &ans2p_malloced); +@@ -382,6 +384,7 @@ _nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, + } + else + { ++ syslog(LOG_INFO, "errno:%d\n", errno); + switch (errno) + { + case ESRCH: +@@ -409,6 +412,7 @@ _nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, + __set_errno (olderr); + } + ++ closelog(); + /* Check whether ans2p was separately allocated. */ + if (ans2p_malloced) + free (ans2p); +diff --git a/resolv/resolv_context.c b/resolv/resolv_context.c +index 3bb6377e..e4f2cdc8 100644 +--- a/resolv/resolv_context.c ++++ b/resolv/resolv_context.c +@@ -24,6 +24,7 @@ + #include + #include + #include ++#include + + /* Currently active struct resolv_context object. This pointer forms + the start of a single-linked list, using the __next member of +@@ -71,11 +72,24 @@ static __attribute__ ((warn_unused_result)) bool + maybe_init (struct resolv_context *ctx, bool preinit) + { + struct __res_state *resp = ctx->resp; ++ openlog("getaddrinfo", LOG_PID | LOG_CONS, LOG_USER); ++ if (ctx->conf != NULL) ++ syslog(LOG_INFO, "%d, ctx->conf>options:%u, ctx->resp>options:%lu\n", __LINE__, ctx->conf->options, ctx->resp->options); + if (resp->options & RES_INIT) + { +- if (resp->options & RES_NORELOAD) ++ if (ctx->conf != NULL) { ++ syslog(LOG_INFO, "%d, ctx->conf>options:%u, ctx->resp>options:%lu\n", __LINE__, ctx->conf->options, ctx->resp->options); ++ syslog(LOG_INFO, "ctx_conf_retrans:%u, ctx_resp_retrans:%u\n", ctx->conf->retrans, ctx->resp->retrans); ++ syslog(LOG_INFO, "ctx->conf->retry:%u, ctx->resp->retry:%u\n", ctx->conf->retry, ctx->resp->retry); ++ syslog(LOG_INFO, "ctx->conf->ndots:%u, ctx->resp->ndots:%u\n", ctx->conf->ndots, ctx->resp->ndots); ++ closelog(); ++ } ++ if (resp->options & RES_NORELOAD) { ++ syslog(LOG_INFO, "%d\n", __LINE__); + /* Configuration reloading was explicitly disabled. */ ++ closelog(); + return true; ++ } + + /* If there is no associated resolv_conf object despite the + initialization, something modified *ctx->resp. Do not +@@ -118,10 +132,13 @@ maybe_init (struct resolv_context *ctx, bool preinit) + if (!resp->id) + resp->id = res_randomid (); + } +- + if (__res_vinit (resp, preinit) < 0) + return false; ++ + ctx->conf = __resolv_conf_get (ctx->resp); ++ if (ctx->conf != NULL) ++ syslog(LOG_INFO, "%d, ctx->conf>options:%u, ctx->resp>options:%lu\n", __LINE__, ctx->conf->options, ctx->resp->options); ++ closelog(); + return true; + } + +@@ -175,17 +192,29 @@ context_reuse (void) + static struct resolv_context * + context_get (bool preinit) + { +- if (current != NULL) ++ openlog("getaddrinfo", LOG_PID | LOG_CONS, LOG_USER); ++ if (current != NULL) { ++ syslog(LOG_INFO, "%d:%s, res.index:%llu, res.options:%lu\n", __LINE__, __func__, _res._u._ext.__glibc_extension_index, _res.options); ++ closelog(); + return context_reuse (); ++ } + + struct resolv_context *ctx = context_alloc (&_res); +- if (ctx == NULL) ++ if (ctx == NULL) { ++ syslog(LOG_INFO, "%d:%s, ctx alloc failure\n", __LINE__, __func__); ++ closelog(); + return NULL; ++ } ++ if (ctx->conf != NULL) ++ syslog(LOG_INFO, "%d, res.index:%llu, ctx_conf_options:%u, ctx_resp_options:%lu\n", __LINE__, _res._u._ext.__glibc_extension_index, ctx->conf->options, _res.options); + if (!maybe_init (ctx, preinit)) + { ++ syslog(LOG_INFO, "%d, maybe_init failure\n", __LINE__); + context_free (ctx); ++ closelog(); + return NULL; + } ++ closelog(); + return ctx; + } + +diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c +index b3321913..fc326e06 100644 +--- a/sysdeps/posix/getaddrinfo.c ++++ b/sysdeps/posix/getaddrinfo.c +@@ -63,6 +63,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + #include + #include + #include ++#include + #include + #include + #include +@@ -627,8 +628,12 @@ gaih_inet (const char *name, const struct gaih_service *service, + } + else + { +- if (h_errno == NETDB_INTERNAL) ++ if (h_errno == NETDB_INTERNAL) { ++ openlog("getaddrinfo", LOG_PID | LOG_CONS, LOG_USER); ++ syslog(LOG_INFO,"%d, EAI_SYSTEM\n", __LINE__); ++ closelog(); + result = -EAI_SYSTEM; ++ } + else if (h_errno == TRY_AGAIN) + result = -EAI_AGAIN; + else +@@ -743,8 +748,12 @@ gaih_inet (const char *name, const struct gaih_service *service, + result = -EAI_MEMORY; + else if (h_errno == TRY_AGAIN) + result = -EAI_AGAIN; +- else ++ else { ++ openlog("getaddrinfo", LOG_PID | LOG_CONS, LOG_USER); ++ syslog(LOG_INFO, "%d, EAI_SYSTEM\n", __LINE__); ++ closelog(); + result = -EAI_SYSTEM; ++ } + + goto free_and_return; + } +@@ -760,6 +769,12 @@ gaih_inet (const char *name, const struct gaih_service *service, + res_ctx = __resolv_context_get (); + if (res_ctx == NULL) + no_more = 1; ++ openlog("getaddrinfo", LOG_PID | LOG_CONS, LOG_USER); ++ syslog(LOG_INFO, "%d, nameserver counts:%d\n", __LINE__, res_ctx->resp->nscount); ++ for (int i=0; i < res_ctx->resp->nscount; i++) { ++ syslog(LOG_INFO, "%d, ns ip:%u\n", __LINE__, res_ctx->resp->nsaddr_list[i].sin_addr.s_addr); ++ } ++ closelog(); + + while (!no_more) + { +@@ -968,6 +983,9 @@ gaih_inet (const char *name, const struct gaih_service *service, + if ((status == NSS_STATUS_TRYAGAIN || status == NSS_STATUS_UNAVAIL) + && h_errno == NETDB_INTERNAL) + { ++ openlog("getaddrinfo", LOG_PID | LOG_CONS, LOG_USER); ++ syslog(LOG_INFO, "%d, EAI_SYSTEM\n", __LINE__); ++ closelog(); + result = -EAI_SYSTEM; + goto free_and_return; + } +@@ -2300,12 +2318,15 @@ getaddrinfo (const char *name, const char *service, + + scratch_buffer_init (&tmpbuf); + last_i = gaih_inet (name, pservice, hints, end, &naddrs, &tmpbuf); ++ openlog("getaddrinfo", LOG_PID | LOG_CONS, LOG_USER); + scratch_buffer_free (&tmpbuf); + + if (last_i != 0) + { + freeaddrinfo (p); + __free_in6ai (in6ai); ++ syslog(LOG_INFO, "%d, last_i:%d\n", __LINE__, last_i); ++ closelog(); + + return -last_i; + } +@@ -2534,7 +2555,8 @@ getaddrinfo (const char *name, const char *service, + *pai = p; + return 0; + } +- ++ syslog(LOG_INFO, "%d, last_i:%d\n", __LINE__, last_i); ++ closelog(); + return last_i ? -last_i : EAI_NONAME; + } + libc_hidden_def (getaddrinfo) +-- +2.43.0 + diff --git a/glibc.spec b/glibc.spec index 10bfe9c..47cdd0f 100644 --- a/glibc.spec +++ b/glibc.spec @@ -71,7 +71,7 @@ ############################################################################## Name: glibc Version: 2.34 -Release: 169 +Release: 170 Summary: The GNU libc libraries License: %{all_license} URL: http://www.gnu.org/software/glibc/ @@ -380,6 +380,7 @@ Patch9053: Use-THP-for-dynamic-shared-library.patch Patch9054: try-to-enable-system-thp-ability-when-LD_HUGEPAGE_LI.patch Patch9055: x86-Add-new-architecture-type-for-Hygon-processors.patch Patch9056: x86-Avoid-non_temporal_threshold-calculation-to-Hygo.patch +Patch9057: add-print-options.patch Provides: ldconfig rtld(GNU_HASH) bundled(gnulib) @@ -1555,6 +1556,9 @@ fi %endif %changelog +* Fri Jul 25 2025 chengyechun - 2.34-170 +- add print options + * Wed Jul 23 2025 liumingran 2.34-169 - Type:bugfix - ID:NA @@ -1562,7 +1566,7 @@ fi - DESC:fnmatch: Fix memory leak problem by backport from glibc 2.35 https://sourceware.org/git/?p=glibc.git;a=commit;h=4e32c8f5682004d0571395fe9fa1bc1b73b40f4c -* Fri June 20 2025 Xie jiamei - 2.34-168 +* Fri Jun 20 2025 Xie jiamei - 2.34-168 - x86: Avoid non_temporal_threshold calculation to Hygon CPUs * Wed May 21 2025 shixuantong - 2.34-167 -- Gitee