Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Netlink support for FreeBSD 13.2 #3201

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2072,6 +2072,8 @@ fn test_freebsd(target: &str) {
"netinet/sctp.h",
"netinet/tcp.h",
"netinet/udp.h",
[freebsd13]:"netlink/netlink.h",
[freebsd13]:"netlink/netlink_generic.h",
"poll.h",
"pthread.h",
"pthread_np.h",
Expand Down Expand Up @@ -2312,6 +2314,91 @@ fn test_freebsd(target: &str) {
// Added in FreeBSD 13.0 (r367776 and r367287)
"SCM_CREDS2" | "LOCAL_CREDS_PERSISTENT" if Some(13) > freebsd_ver => true,

// Added in FreeBSD 13.2
"AF_NETLINK"
| "PF_NETLINK"
| "SOL_NETLINK"
| "NETLINK_ADD_MEMBERSHIP"
| "NETLINK_DROP_MEMBERSHIP"
| "NETLINK_PKTINFO"
| "NETLINK_BROADCAST_ERROR"
| "NETLINK_NO_ENOBUFS"
| "NETLINK_RX_RING"
| "NETLINK_TX_RING"
| "NETLINK_LISTEN_ALL_NSID"
| "NETLINK_LIST_MEMBERSHIPS"
| "NETLINK_CAP_ACK"
| "NETLINK_EXT_ACK"
| "NETLINK_GET_STRICT_CHK"
| "NLM_F_REQUEST"
| "NLM_F_MULTI"
| "NLM_F_ACK"
| "NLM_F_ECHO"
| "NLM_F_DUMP_INTR"
| "NLM_F_DUMP_FILTERED"
| "NLM_F_ROOT"
| "NLM_F_MATCH"
| "NLM_F_ATOMIC"
| "NLM_F_DUMP"
| "NLM_F_REPLACE"
| "NLM_F_EXCL"
| "NLM_F_CREATE"
| "NLM_F_APPEND"
| "NLM_F_NONREC"
| "NLM_F_CAPPED"
| "NLM_F_ACK_TLVS"
| "NLMSG_NOOP"
| "NLMSG_ERROR"
| "NLMSG_DONE"
| "NLMSG_OVERRUN"
| "NETLINK_ROUTE"
| "NETLINK_UNUSED"
| "NETLINK_USERSOCK"
| "NETLINK_FIREWALL"
| "NETLINK_SOCK_DIAG"
| "NETLINK_NFLOG"
| "NETLINK_XFRM"
| "NETLINK_SELINUX"
| "NETLINK_ISCSI"
| "NETLINK_AUDIT"
| "NETLINK_FIB_LOOKUP"
| "NETLINK_CONNECTOR"
| "NETLINK_NETFILTER"
| "NETLINK_IP6_FW"
| "NETLINK_DNRTMSG"
| "NETLINK_KOBJECT_UEVENT"
| "NETLINK_GENERIC"
| "NLMSG_ALIGNTO"
| "CTRL_CMD_UNSPEC"
| "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"
| "CTRL_CMD_GETPOLICY"
| "CTRL_ATTR_UNSPEC"
| "CTRL_ATTR_FAMILY_ID"
| "CTRL_ATTR_FAMILY_NAME"
| "CTRL_ATTR_VERSION"
| "CTRL_ATTR_HDRSIZE"
| "CTRL_ATTR_MAXATTR"
| "CTRL_ATTR_OPS"
| "CTRL_ATTR_MCAST_GROUPS"
| "CTRL_ATTR_POLICY"
| "CTRL_ATTR_OP_POLICY"
| "CTRL_ATTR_OP"
| "CTRL_ATTR_MCAST_GRP_UNSPEC"
| "CTRL_ATTR_MCAST_GRP_NAME"
| "CTRL_ATTR_MCAST_GRP_ID"
if Some(13) > freebsd_ver =>
{
true
}

// Added in FreeBSD 14
"SPACECTL_DEALLOC" if Some(14) > freebsd_ver => true,

Expand Down Expand Up @@ -2453,6 +2540,33 @@ fn test_freebsd(target: &str) {
// FIXME: The values has been changed in FreeBSD 15:
"CLOCK_BOOTTIME" if Some(15) <= freebsd_ver => true,

// submodule ifmib, cannot be checked today
"DOT3COMPLIANCE_STATS"
| "DOT3COMPLIANCE_COLLS"
| "IFDATA_GENERAL"
| "IFDATA_LINKSPECIFIC"
| "IFDATA_DRIVERNAME"
| "IFMIB_IFCOUNT"
| "IFMIB_IFDATA"
| "IFMIB_SYSTEM"
| "NETLINK_GENERIC"
| "dot3ChipSetAMD7990"
| "dot3ChipSetAMD79900"
| "dot3ChipSetAMD79C940"
| "dot3ChipSetIntel82586"
| "dot3ChipSetIntel82596"
| "dot3ChipSetIntel82557"
| "dot3ChipSetNational8390"
| "dot3ChipSetNationalSonic"
| "dot3ChipSetFujitsu86950"
| "dot3ChipSetDigitalDC21040"
| "dot3ChipSetDigitalDC21140"
| "dot3ChipSetDigitalDC21041"
| "dot3ChipSetDigitalDC21140A"
| "dot3ChipSetDigitalDC21142"
| "dot3ChipSetWesternDigital83C690"
| "dot3ChipSetWesternDigital83C790" => true,

_ => false,
}
});
Expand Down Expand Up @@ -2490,6 +2604,9 @@ fn test_freebsd(target: &str) {
// `shm_largepage_conf` was introduced in FreeBSD 13.
"shm_largepage_conf" if Some(13) > freebsd_ver => true,

// `sockaddr_nl` introduced in FreeBSD 13.2
"sockaddr_nl" if Some(13) > freebsd_ver => true,

// Those are private types
"memory_type" => true,
"memory_type_list" => true,
Expand Down
44 changes: 44 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/ifmib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// sys/net/if_mib.h

/// non-interface-specific
pub const IFMIB_SYSTEM: ::c_int = 1;
/// per-interface data table
pub const IFMIB_IFDATA: ::c_int = 2;

/// generic stats for all kinds of ifaces
pub const IFDATA_GENERAL: ::c_int = 1;
/// specific to the type of interface
pub const IFDATA_LINKSPECIFIC: ::c_int = 2;
/// driver name and unit
pub const IFDATA_DRIVERNAME: ::c_int = 3;

/// number of interfaces configured
pub const IFMIB_IFCOUNT: ::c_int = 1;

/// functions not specific to a type of iface
pub const NETLINK_GENERIC: ::c_int = 0;

pub const DOT3COMPLIANCE_STATS: ::c_int = 1;
pub const DOT3COMPLIANCE_COLLS: ::c_int = 2;

pub const dot3ChipSetAMD7990: ::c_int = 1;
pub const dot3ChipSetAMD79900: ::c_int = 2;
pub const dot3ChipSetAMD79C940: ::c_int = 3;

pub const dot3ChipSetIntel82586: ::c_int = 1;
pub const dot3ChipSetIntel82596: ::c_int = 2;
pub const dot3ChipSetIntel82557: ::c_int = 3;

pub const dot3ChipSetNational8390: ::c_int = 1;
pub const dot3ChipSetNationalSonic: ::c_int = 2;

pub const dot3ChipSetFujitsu86950: ::c_int = 1;

pub const dot3ChipSetDigitalDC21040: ::c_int = 1;
pub const dot3ChipSetDigitalDC21140: ::c_int = 2;
pub const dot3ChipSetDigitalDC21041: ::c_int = 3;
pub const dot3ChipSetDigitalDC21140A: ::c_int = 4;
pub const dot3ChipSetDigitalDC21142: ::c_int = 5;

pub const dot3ChipSetWesternDigital83C690: ::c_int = 1;
pub const dot3ChipSetWesternDigital83C790: ::c_int = 2;
Loading