[DTrace-devel] [PATCH 6/7] tcp: support non-libctf environments

Eugene Loh eugene.loh at oracle.com
Tue Nov 18 19:49:57 UTC 2025


Okay but we should also handle these compiler warnings in the not-HAVE case:

* unused variable:  rc fi sym dtp
* (potentially) uninitialized variable:  skarg_maybe_null

On 11/18/25 11:38, Kris Van Hees wrote:
> Commit 0fa93b3ac ("tcp: new provider") and commit c08a5fcf2
> ("tcp provider: support tcp:::accept-established in absence of skb") both
> introduced code that uses ctf_func_type_info() without a pre-processor
> conditional to also support the case when libctf is not present on the
> system.
>
> When libctf is not present, it is assumed that the system is quite old
> and therefore is running an older kernel.  Use of libdtrace-ctf (which
> has been deprecated in favour of libctf) on systems with recent kernels
> is not supported and may lead to unexpected results.
>
> Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
> ---
>   libdtrace/dt_prov_tcp.c | 11 +++++++++++
>   1 file changed, 11 insertions(+)
>
> diff --git a/libdtrace/dt_prov_tcp.c b/libdtrace/dt_prov_tcp.c
> index 44ed2bc9..319a84f9 100644
> --- a/libdtrace/dt_prov_tcp.c
> +++ b/libdtrace/dt_prov_tcp.c
> @@ -262,6 +262,7 @@ static int trampoline(dt_pcb_t *pcb, uint_t exitlbl)
>   
>   	if (strcmp(prp->desc->prb, "accept-established") == 0) {
>   		direction = NET_PROBE_INBOUND;
> +#ifdef HAVE_LIBCTF
>   		have_iphdr = 1;
>   		/* on older (5.4) kernels, tcp_init_transfer() only has 2
>   		 * args, i.e. no struct skb * third argument.
> @@ -279,6 +280,10 @@ static int trampoline(dt_pcb_t *pcb, uint_t exitlbl)
>   			have_skb = 0;
>   			have_iphdr = 0;
>   		}
> +#else
> +		have_skb = 0;
> +		have_iphdr = 0;
> +#endif
>   		/* ensure arg1 is BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB */
>   		emit(dlp, BPF_LOAD(BPF_DW, BPF_REG_6, BPF_REG_7, DMST_ARG(1)));
>   		emit(dlp, BPF_BRANCH_IMM(BPF_JNE, BPF_REG_6,
> @@ -305,6 +310,7 @@ static int trampoline(dt_pcb_t *pcb, uint_t exitlbl)
>   	} else {
>   		direction = NET_PROBE_OUTBOUND;
>   		if (strcmp(uprp->desc->fun, "ip_send_unicast_reply") == 0) {
> +#ifdef HAVE_LIBCTF
>   			/* Newer kernels pass the original socket as second
>   			 * arg to ip_send_unicast_reply(); if that function
>   			 * has an extra (> 9) argument we know we have to
> @@ -329,6 +335,11 @@ static int trampoline(dt_pcb_t *pcb, uint_t exitlbl)
>   				skbarg = 1;
>   				tcparg = 5;
>   			}
> +#else
> +			skarg = 0;
> +			skbarg = 1;
> +			tcparg = 5;
> +#endif
>   			have_iphdr = 1;
>   			tcparg = 6;
>   			skarg_maybe_null = 1;



More information about the DTrace-devel mailing list