Socket...eneric(3pm)
π Socket::Netlink::Generic β no cap, it's giving netlink π
so bestieβ¦ welcome to the manual page for Socket::Netlink::Generic, a User Contributed Perl Documentation page (manual section 3pm, she's iconic like that). This is the low-level β¨interfaceβ¨ to Linux's NETLINK_GENERIC netlink socket protocol. Let's get into it. π¦
πΈ NAME πΈ
Socket::Netlink::Generic β interface to Linux's NETLINK_GENERIC netlink socket protocol. periodt. π
β¨ SYNOPSIS β¨
okay so here's the whole vibe, in code, verbatim, don't touch a single character bestie:
use Socket;
use Socket::Netlink qw( :DEFAULT
pack_nlmsghdr unpack_nlmsghdr pack_nlattrs unpack_nlattrs );
use Socket::Netlink::Generic qw( :DEFAULT pack_genlmsghdr unpack_genlmsghdr );
socket( my $sock, PF_NETLINK, SOCK_RAW, NETLINK_GENERIC ) or die "socket: $!";
send( $sock, pack_nlmsghdr( NETLINK_GENERIC, NLM_F_REQUEST, 0, 0,
pack_genlmsghdr( CTRL_CMD_GETFAMILY, 0,
pack_nlattrs( CTRL_ATTR_FAMILY_NAME, "TASKSTATS\0" )
),
),
0 ) or die "send: $!";
recv( $sock, my $buffer, 65536, 0 ) or die "recv: $!";
my %attrs = unpack_nlattrs(
(unpack_genlmsghdr( (unpack_nlmsghdr $buffer )[4] ) )[2]
);
printf "TASKSTATS family ID is %d\n",
unpack( "S", $attrs{CTRL_ATTR_FAMILY_ID()} );
look at her go π she really did that. π
π«Ά DESCRIPTION π«Ά
So basically, this module is holding all the low-level constants and the structure handling functions you need to actually use the NETLINK_GENERIC protocol from Linux's PF_NETLINK socket family. That's the whole job. πͺ
But ngl bestie β the module itself literally suggests you use the high-level object interface instead. See IO::Socket::Netlink::Generic. She said "I'm the internals, go talk to my more polished sister." π
π CONSTANTS π
The following sets of constants are exported. Yes, all of them. We're not skipping. the way that I listed every single oneβ¦
π The netlink protocol constant π
NETLINK_GENERIC
that's her. the moment. the icon. β
π Control commands π
CTRL_CMD_NEWFAMILY CTRL_CMD_DELFAMILY CTRL_CMD_GETFAMILY
CTRL_CMD_NEWOPS CTRL_CMD_DELOPS CTRL_CMD_GETOPS
CTRL_CMD_NEWMCAST_GRP CTRL_CMD_DELMCAST_GRP CTRL_CMD_GETMCAST_GRP
π¦ Attribute IDs π¦
CTRL_ATTR_FAMILY_ID CTRL_ATTR_FAMILY_NAME CTRL_ATTR_VERSION
CTRL_ATTR_HDRSIZE CTRL_ATTR_MAXATTR CTRL_ATTR_OPS
CTRL_ATTR_MCAST_GROUPS
π Nested attribute IDs π
CTRL_ATTR_OP_ID CTRL_ATTR_OP_FLAGS
CTRL_ATTR_MCAST_GRP_NAME CTRL_ATTR_MCAST_GRP_ID
β οΈ heads up bestie, this one's important: if your kernel headers are particularly old, not all of these constants may be available. And if they're unavailable at compile time, no constant functions will be generated. so likeβ¦ keep your headers updated, fr fr. π
π§ STRUCTURE FUNCTIONS π§
β¨ pack_genlmsghdr β¨
$buffer = pack_genlmsghdr( $cmd, $version, $body )
π unpack_genlmsghdr π
( $cmd, $version, $body ) = unpack_genlmsghdr( $buffer )
Pack or unpack a struct genlmsghdr and its payload body. that's it. that's the whole function. she's simple, she's effective, she ate. π₯
π SEE ALSO π
Socket::Netlinkβ interface to Linux'sPF_NETLINKsocket familyIO::Socket::Netlink::Genericβ Object interface toNETLINK_GENERICnetlink protocol sockets
go read those too bestie, iykyk π
π AUTHOR π
Paul Evans <leonerd@leonerd.org.uk> β shoutout to the main character who wrote this. π«Ά
and that's the whole page, bestie!! β¨ππ
signing off: this was perl v5.42.0, dated 2025-07-25, and she came to you as Socket...eneric(3pm). slay, bye!! π
πΈπ¦
π¦ where this page comes from
- fedora 43: perl-Socket-Netlink 0.05-32.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms