STRUCT LANDLOCK_NET_PORT_ATTR(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… struct landlock_net_port_attr(9) β€” like, the network port definition one

okay so you're in the Kernel API Manual bestie, and we're talking about struct landlock_net_port_attr β€” literally the network port definition, that's the whole vibe ✨


🌸 NAME 🌸

struct landlock_net_port_attr β€” network port definition. that's it, that's the girl πŸŽ€


✨ SYNOPSIS ✨

struct landlock_net_port_attr {
    __u64 allowed_access;
    __u64 port;
 };

she's small, she's cute, she has exactly two fields, no notes πŸ’…


🫢 Members 🫢

  • allowed_access β€” a bitmask of the allowed network actions for a port (cf. Network flags_). so like, what's actually permitted on this port, encoded as bits πŸ’–
  • port β€” the network port, in host endianness. don't get weird with byte order, ok? πŸ™ˆ
ok important note, do NOT skip this one: a port of 0 passed to :manpage:bind(2) will bind to an available port from the ephemeral port range. you can configure that range with the /proc/sys/net/ipv4/ip_local_port_range sysctl (also used for IPv6), and within that range, on a per-socket basis with setsockopt(IP_LOCAL_PORT_RANGE) πŸ”₯

and second note, also lowkey essential: a Landlock rule with port 0 and the LANDLOCK_ACCESS_NET_BIND_TCP or LANDLOCK_ACCESS_NET_BIND_UDP right means that requesting to bind on port 0 is allowed, and it will automatically translate to binding on a kernel-assigned ephemeral port πŸ‘‘ no cap, the kernel picks for you.


⭐ Description ⭐

she's the argument of sys_landlock_add_rule. that's the whole description. iconic behaviour, honestly 🌈


πŸ¦‹ SEE ALSO πŸ¦‹

go read these next, i'm obsessed with all of them fr fr:


πŸ’€ reminder bestie: everything above is exactly what the page says, i'm just louder about it.

and that's the page! coming to you from ./include/uapi/linux, dated October 2026, titled struct land...et_port_attr(9) (yes the truncation is real, we love her anyway) β€” mwah, bye πŸ‘‘πŸ’–πŸ§š

πŸ“¦ where this page comes from