[PATCH] Updates struct tcp_info and TCP_AO_XX corresponding struct from 6.17 to netinet/tcp.h

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Fri Nov 14 14:21:02 GMT 2025



On 29/10/25 04:09, Jiayuan Chen wrote:
> This patch updates struct tcp_info to include new fields from Linux 6.17:
> - tcpi_pacing_rate, tcpi_max_pacing_rate
> - tcpi_bytes_acked, tcpi_bytes_received
> - tcpi_delivery_rate, tcpi_busy_time
> - tcpi_delivered, tcpi_delivered_ce
> - and many other TCP metrics
> 
> Additionally, this patch adds:
> - TCP_AO_* definitions (Authentication Option)
> - struct tcp_diag_md5sig for INET_DIAG_MD5SIG
> - Netlink attribute types for SCM_TIMESTAMPING_OPT_STATS
> 
> All changes are synchronized from the Linux kernel's tcp.h without
> functional modifications, only code style changes.
> 
> Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>

Looks good, just a minor indentation fix.

> ---
>  sysdeps/gnu/netinet/tcp.h | 196 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 196 insertions(+)
> 
> diff --git a/sysdeps/gnu/netinet/tcp.h b/sysdeps/gnu/netinet/tcp.h
> index a4e7674de1..1c53e79fdf 100644
> --- a/sysdeps/gnu/netinet/tcp.h
> +++ b/sysdeps/gnu/netinet/tcp.h
> @@ -267,8 +267,96 @@ struct tcp_info
>    uint32_t	tcpi_rcv_space;
>  
>    uint32_t	tcpi_total_retrans;
> +
> +  uint64_t  tcpi_pacing_rate;

Could you math the previosu indentation to use tab instead of space?

> +  uint64_t  tcpi_max_pacing_rate;
> +  uint64_t  tcpi_bytes_acked;    /* RFC4898 tcpEStatsAppHCThruOctetsAcked */
> +  uint64_t  tcpi_bytes_received; /* RFC4898 tcpEStatsAppHCThruOctetsReceived
> +                                  */
> +  uint32_t  tcpi_segs_out;       /* RFC4898 tcpEStatsPerfSegsOut */
> +  uint32_t  tcpi_segs_in;        /* RFC4898 tcpEStatsPerfSegsIn */
> +
> +  uint32_t  tcpi_notsent_bytes;
> +  uint32_t  tcpi_min_rtt;
> +  uint32_t  tcpi_data_segs_in;    /* RFC4898 tcpEStatsDataSegsIn */
> +  uint32_t  tcpi_data_segs_out;   /* RFC4898 tcpEStatsDataSegsOut */
> +
> +  uint64_t  tcpi_delivery_rate;
> +
> +  uint64_t  tcpi_busy_time;       /* Time (usec) busy sending data */
> +  uint64_t  tcpi_rwnd_limited;    /* Time (usec) limited by receive window */
> +  uint64_t  tcpi_sndbuf_limited;  /* Time (usec) limited by send buffer */
> +
> +  uint32_t  tcpi_delivered;
> +  uint32_t  tcpi_delivered_ce;
> +
> +  uint64_t  tcpi_bytes_sent;    /* RFC4898 tcpEStatsPerfHCDataOctetsOut */
> +  uint64_t  tcpi_bytes_retrans; /* RFC4898 tcpEStatsPerfOctetsRetrans */
> +  uint32_t  tcpi_dsack_dups;    /* RFC4898 tcpEStatsStackDSACKDups */
> +  uint32_t  tcpi_reord_seen;    /* reordering events seen */
> +
> +
> +  uint32_t  tcpi_rcv_ooopack; /* Out-of-order packets received */
> +  uint32_t  tcpi_snd_wnd;     /* Peer's advertised receive window after
> +                               * scaling (bytes)
> +                               */
> +  uint32_t  tcpi_rcv_wnd;     /* Local advertised receive window after
> +                               * scaling (bytes)
> +                               */
> +
> +  uint32_t  tcpi_rehash;      /* PLB or timeout triggered rehash attempts */
> +  uint16_t  tcpi_total_rto;   /* Total number of RTO timeouts, including
> +                               * SYN/SYN-ACK and recurring timeouts
> +                               */
> +  uint16_t  tcpi_total_rto_recoveries; /* Total number of RTO recoveries,
> +                                        * including any unfinished recovery.
> +                                        */
> +  uint32_t  tcpi_total_rto_time;       /* Total time spent in RTO recoveries
> +                                        * in milliseconds, including any
> +                                        * unfinished recovery.
> +                                        */
> +  uint32_t  tcpi_received_ce;          /* # of CE marks received */
> +  uint32_t  tcpi_delivered_e1_bytes;   /* Accurate ECN byte counters */
> +  uint32_t  tcpi_delivered_e0_bytes;
> +  uint32_t  tcpi_delivered_ce_bytes;
> +  uint32_t  tcpi_received_e1_bytes;
> +  uint32_t  tcpi_received_e0_bytes;
> +  uint32_t  tcpi_received_ce_bytes;
> +  uint16_t  tcpi_accecn_fail_mode;
> +  uint16_t  tcpi_accecn_opt_seen;
>  };
>  
> +/* Netlink attributes types for SCM_TIMESTAMPING_OPT_STATS */
> +enum {
> +  TCP_NLA_PAD,
> +  TCP_NLA_BUSY,                   /* Time (usec) busy sending data */
> +  TCP_NLA_RWND_LIMITED,           /* Time (usec) limited by receive window */
> +  TCP_NLA_SNDBUF_LIMITED,         /* Time (usec) limited by send buffer */
> +  TCP_NLA_DATA_SEGS_OUT,          /* Data pkts sent including retransmission */
> +  TCP_NLA_TOTAL_RETRANS,          /* Data pkts retransmitted */
> +  TCP_NLA_PACING_RATE,            /* Pacing rate in bytes per second */
> +  TCP_NLA_DELIVERY_RATE,          /* Delivery rate in bytes per second */
> +  TCP_NLA_SND_CWND,               /* Sending congestion window */
> +  TCP_NLA_REORDERING,             /* Reordering metric */
> +  TCP_NLA_MIN_RTT,                /* minimum RTT */
> +  TCP_NLA_RECUR_RETRANS,          /* Recurring retransmits for the current pkt */
> +  TCP_NLA_DELIVERY_RATE_APP_LMT,  /* delivery rate application limited ? */
> +  TCP_NLA_SNDQ_SIZE,              /* Data (bytes) pending in send queue */
> +  TCP_NLA_CA_STATE,               /* ca_state of socket */
> +  TCP_NLA_SND_SSTHRESH,           /* Slow start size threshold */
> +  TCP_NLA_DELIVERED,              /* Data pkts delivered incl. out-of-order */
> +  TCP_NLA_DELIVERED_CE,           /* Like above but only ones w/ CE marks */
> +  TCP_NLA_BYTES_SENT,             /* Data bytes sent including retransmission */
> +  TCP_NLA_BYTES_RETRANS,          /* Data bytes retransmitted */
> +  TCP_NLA_DSACK_DUPS,             /* DSACK blocks received */
> +  TCP_NLA_REORD_SEEN,             /* reordering events seen */
> +  TCP_NLA_SRTT,                   /* smoothed RTT in usecs */
> +  TCP_NLA_TIMEOUT_REHASH,         /* Timeout-triggered rehash attempts */
> +  TCP_NLA_BYTES_NOTSENT,          /* Bytes in write queue not yet sent */
> +  TCP_NLA_EDT,                    /* Earliest departure time (CLOCK_MONOTONIC) */
> +  TCP_NLA_TTL,                    /* TTL or hop limit of a packet received */
> +  TCP_NLA_REHASH,                 /* PLB and timeout triggered rehash attempts */
> +};
>  
>  /* For TCP_MD5SIG socket option.  */
>  #define TCP_MD5SIG_MAXKEYLEN	80
> @@ -287,6 +375,114 @@ struct tcp_md5sig
>    uint8_t	tcpm_key[TCP_MD5SIG_MAXKEYLEN];	/* Key (binary).  */
>  };
>  
> +/* INET_DIAG_MD5SIG */
> +struct tcp_diag_md5sig {
> +  uint8_t   tcpm_family;
> +  uint8_t   tcpm_prefixlen;
> +  uint16_t  tcpm_keylen;
> +  uint32_t  tcpm_addr[4];

Ok, the kernels defines as __be32 but I think we do have/need similar
distinction. 

> +  uint8_t   tcpm_key[TCP_MD5SIG_MAXKEYLEN];
> +};
> +
> +#define TCP_AO_MAXKEYLEN  80
> +
> +#define TCP_AO_KEYF_IFINDEX  (1 << 0)     /* L3 ifindex for VRF */
> +#define TCP_AO_KEYF_EXCLUDE_OPT  (1 << 1) /* Indicates whether TCP options
> +                                           * other than TCP-AO are included
> +                                           * in the MAC calculation
> +                                           */
> +
> +struct tcp_ao_add { /* setsockopt(TCP_AO_ADD_KEY) */
> +  struct sockaddr_storage addr;   /* Peer's address for the key */
> +  int8_t    alg_name[64];         /* Crypto hash algorithm to use */
> +  int32_t   ifindex;              /* L3 dev index for VRF */
> +  uint32_t  set_current  :1,      /* Set key as Current_key at once */
> +            set_rnext    :1,      /* Request it from peer with RNext_key */
> +            reserved     :30;     /* Must be 0 */
> +  uint16_t  reserved2;            /* Padding, must be 0 */
> +  uint8_t   prefix;               /* Peer's address prefix */
> +  uint8_t   sndid;                /* SendID for outgoing segments */
> +  uint8_t   rcvid;                /* RecvID to match for incoming seg */
> +  uint8_t   maclen;               /* length of authentication code (hash) */
> +  uint8_t   keyflags;             /* See TCP_AO_KEYF_ */
> +  uint8_t   keylen;               /* Length of ::key */
> +  uint8_t   key[TCP_AO_MAXKEYLEN];
> +} __attribute__((aligned(8)));
> +
> +struct tcp_ao_del { /* setsockopt(TCP_AO_DEL_KEY) */
> +  struct sockaddr_storage addr;   /* Peer's address for the key */
> +  int32_t  ifindex;               /* L3 dev index for VRF */
> +  uint32_t set_current  :1,       /* Corresponding ::current_key */
> +           set_rnext    :1,       /* Corresponding ::rnext */
> +           del_async    :1,       /* Only valid for listen sockets */
> +           reserved     :29;      /* Must be 0 */
> +  uint16_t reserved2;             /* Padding, must be 0 */
> +  uint8_t  prefix;                /* Peer's address prefix */
> +  uint8_t  sndid;                 /* SendID for outgoing segments */
> +  uint8_t  rcvid;                 /* RecvID to match for incoming seg */
> +  uint8_t  current_key;           /* KeyID to set as Current_key */
> +  uint8_t  rnext;                 /* KeyID to set as Rnext_key */
> +  uint8_t  keyflags;              /* See TCP_AO_KEYF_ */
> +} __attribute__((aligned(8)));
> +
> +struct tcp_ao_info_opt { /* setsockopt(TCP_AO_INFO), getsockopt(TCP_AO_INFO)
> +                          */
> +  /* Here 'in' is for setsockopt(), 'out' is for getsockopt() */
> +  uint32_t  set_current   :1,   /* In/out: corresponding ::current_key */
> +            set_rnext     :1,   /* In/out: corresponding ::rnext */
> +            ao_required   :1,   /* In/out: don't accept non-AO connects */
> +            set_counters  :1,   /* In: set/clear ::pkt_* counters */
> +            accept_icmps  :1,   /* In/out: accept incoming ICMPs */
> +            reserved      :27;  /* must be 0 */
> +  uint16_t  reserved2;          /* Padding, must be 0 */
> +  uint8_t   current_key;        /* In/out: KeyID of Current_key */
> +  uint8_t   rnext;              /* In/out: keyid of RNext_key */
> +  uint64_t  pkt_good;           /* In/out: verified segments */
> +  uint64_t  pkt_bad;            /* In/out: failed verification */
> +  uint64_t  pkt_key_not_found;  /* In/out: could not find a key to verify */
> +  uint64_t  pkt_ao_required;    /* In/out: segments missing TCP-AO sign */
> +  uint64_t  pkt_dropped_icmp;   /* In/out: ICMPs that were ignored */
> +} __attribute__((aligned(8)));
> +
> +struct tcp_ao_getsockopt { /* getsockopt(TCP_AO_GET_KEYS) */
> +  struct sockaddr_storage addr;   /* In/out: dump keys for peer
> +                                   * with this address/prefix
> +                                   */
> +  uint8_t   alg_name[64];         /* out: crypto hash algorithm */
> +  uint8_t   key[TCP_AO_MAXKEYLEN];
> +  uint32_t  nkeys;                /* In: size of the userspace buffer
> +                                   * @optval, measured in @optlen - the
> +                                   * sizeof(struct tcp_ao_getsockopt)
> +                                   * Out: number of keys that matched
> +                                   */
> +  uint16_t  is_current  :1,       /* In: match and dump Current_key,
> +                                   * Out: the dumped key is Current_key
> +                                   */
> +            is_rnext    :1,       /* In: match and dump RNext_key,
> +                                   * Out: the dumped key is RNext_key
> +                                   */
> +            get_all     :1,       /* In: dump all keys */
> +            reserved    :13;      /* Padding, must be 0 */
> +  uint8_t  sndid;                 /* In/out: dump keys with SendID */
> +  uint8_t  rcvid;                 /* In/out: dump keys with RecvID */
> +  uint8_t  prefix;                /* In/out: dump keys with address/prefix */
> +  uint8_t  maclen;                /* Out: key's length of authentication
> +                                   * code (hash)
> +                                  */
> +  uint8_t  keyflags;              /* In/out: see TCP_AO_KEYF_ */
> +  uint8_t  keylen;                /* Out: length of ::key */
> +  int32_t  ifindex;               /* In/out: L3 dev index for VRF */
> +  uint64_t  pkt_good;             /* Out: verified segments */
> +  uint64_t  pkt_bad;              /* Out: segments that failed verification */
> +} __attribute__((aligned(8)));
> +
> +struct tcp_ao_repair { /* {s,g}etsockopt(TCP_AO_REPAIR) */
> +  uint32_t      snt_isn;
> +  uint32_t      rcv_isn;
> +  uint32_t      snd_sne;
> +  uint32_t      rcv_sne;
> +} __attribute__((aligned(8)));
> +
>  /* For socket repair options.  */
>  struct tcp_repair_opt
>  {



More information about the Libc-alpha mailing list