KNET_LINK_GET_STATUS(3)

okay bestie, so this is knet_link_get_status from the Kronosnet Programmer's Manual β€” section 3, the library functions section, iykyk ✨


✨ NAME ✨

knet_link_get_status β€” get the status (and the statistics, because we love receipts πŸ‘‘) for a link.


🌸 SYNOPSIS 🌸

#include <libknet.h>

int knet_link_get_status(
    knet_handle_t              knet_h,
    knet_node_id_t             host_id,
    uint8_t                    link_id,
    struct knet_link_status   *status,
    size_t                     struct_size
);

πŸ¦‹ DESCRIPTION πŸ¦‹

knet_link_get_status β€” yes that's the whole first line, she's the main character and she knows it πŸ’…

here's the cast of characters, one by one:

  • knet_h β€” pointer to knet_handle_t 🫢
  • host_id β€” go peek at knet_host_add(3) for this one
  • link_id β€” and this one lives over in knet_link_set_config(3)
  • status β€” pointer to a knet_link_status struct (the good stuff goes in here ✨)
  • struct_size β€” max size of knet_link_status. this is the sneaky-genius part: it lets the library add fields later without an ABI change. the returned structure gets truncated to this length, and the .size member tells you the full size. iconic behaviour honestly 🌈

πŸŽ€ STRUCTURES πŸŽ€

this is the status of a knet link, exactly as it comes back from knet_link_get_status():

struct knet_link_status {
    /*
     * Size of the structure for ABI checking, set this to
     * sizeof(knet_link_status) before calling knet_link_get_status()
     */
    size_t              size;
    char                src_ipaddr[KNET_MAX_HOST_LEN];  /* Local IP address as a string */
    char                src_port[KNET_MAX_PORT_LEN];    /* Local IP port as a string */
    char                dst_ipaddr[KNET_MAX_HOST_LEN];  /* Remote IP address as a string */
    char                dst_port[KNET_MAX_PORT_LEN];    /* Remote IP port as a string */
    uint8_t             enabled;                        /* Link is configured and admin enabled for traffic */
    uint8_t             connected;                      /* Link is connected for data (local view) */
    uint8_t             dynconnected;                   /* Link has been activated by remote dynip */
    unsigned long long  latency;                        /* average latency computed by fix/exp */
    struct timespec     pong_last;                      /* Timestamp of the past pong received */
    unsigned int        mtu;                            /* Currently detected MTU on this link */
    /*
     * Contains the size of the IP protocol, knet headers and crypto headers
     * (if configured). This value is filled in ONLY after the first PMTUd run on
     * that given link, and can change if link configuration or crypto configuration
     * changes at runtime. WARNING: in general mtu + proto_overhead might or might not
     * match the output of ifconfig mtu due to crypto requirements to pad packets to
     * some specific boundaries.
     */
    unsigned int        proto_overhead;
    struct              stats;                          /* Link statistics */
};
⚠️ bestie listen to me about proto_overhead: it is filled in ONLY after the first PMTUd run on that given link, and it can change if the link config or the crypto config changes at runtime. and here's the warning, no cap β€” in general mtu + proto_overhead might or might not match the output of ifconfig mtu, because crypto has requirements to pad packets to some specific boundaries. so don't come for her when the numbers don't line up πŸ™ˆ

⭐ RETURN VALUE ⭐

knet_link_get_status returns 0 on success, -1 on error, and errno is set. that's it, that's the deal 🫢


πŸ’œ SEE ALSO πŸ’œ

the whole girl gang, in order, exactly as she listed them:

like… that's a whole friend group 😭 they all showed up to the function call, obsessed with them fr fr πŸ’–


Copyright (C) 2010-2026 Red Hat, Inc. All rights reserved.


and that's the tea, bestie πŸ“ this whole page is from the kronosnet manual, dated 2026-07-20, and yeah she's filed under KNET_LINK_GET_STATUS(3) β€” go read the whole thing again, you ate it up πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from