Skip to content

Commit 692dc54

Browse files
committed
Auto merge of #1462 - jbaublitz:musl-netlink-support, r=gnzlbg
Move musl-compatible constants to linux/mod.rs This is a continuation of #1452. I think CI is ready to run fully and the PR is ready to be merged if the pipelines pass based on the CI I've done using musl libc in my own projects.
2 parents 9b09188 + 903a28b commit 692dc54

File tree

2 files changed

+62
-63
lines changed

2 files changed

+62
-63
lines changed

src/unix/linux_like/linux/gnu/mod.rs

-63
Original file line numberDiff line numberDiff line change
@@ -611,65 +611,8 @@ pub const IFA_F_NOPREFIXROUTE: u32 = 0x200;
611611
pub const IFA_F_MCAUTOJOIN: u32 = 0x400;
612612
pub const IFA_F_STABLE_PRIVACY: u32 = 0x800;
613613

614-
pub const NETLINK_ROUTE: ::c_int = 0;
615-
pub const NETLINK_UNUSED: ::c_int = 1;
616-
pub const NETLINK_USERSOCK: ::c_int = 2;
617-
pub const NETLINK_FIREWALL: ::c_int = 3;
618-
pub const NETLINK_SOCK_DIAG: ::c_int = 4;
619-
pub const NETLINK_NFLOG: ::c_int = 5;
620-
pub const NETLINK_XFRM: ::c_int = 6;
621-
pub const NETLINK_SELINUX: ::c_int = 7;
622-
pub const NETLINK_ISCSI: ::c_int = 8;
623-
pub const NETLINK_AUDIT: ::c_int = 9;
624-
pub const NETLINK_FIB_LOOKUP: ::c_int = 10;
625-
pub const NETLINK_CONNECTOR: ::c_int = 11;
626-
pub const NETLINK_NETFILTER: ::c_int = 12;
627-
pub const NETLINK_IP6_FW: ::c_int = 13;
628-
pub const NETLINK_DNRTMSG: ::c_int = 14;
629-
pub const NETLINK_KOBJECT_UEVENT: ::c_int = 15;
630-
pub const NETLINK_GENERIC: ::c_int = 16;
631-
pub const NETLINK_SCSITRANSPORT: ::c_int = 18;
632-
pub const NETLINK_ECRYPTFS: ::c_int = 19;
633-
pub const NETLINK_RDMA: ::c_int = 20;
634-
pub const NETLINK_CRYPTO: ::c_int = 21;
635-
pub const NETLINK_INET_DIAG: ::c_int = NETLINK_SOCK_DIAG;
636-
637614
pub const MAX_LINKS: ::c_int = 32;
638615

639-
pub const NLM_F_REQUEST: ::c_int = 1;
640-
pub const NLM_F_MULTI: ::c_int = 2;
641-
pub const NLM_F_ACK: ::c_int = 4;
642-
pub const NLM_F_ECHO: ::c_int = 8;
643-
pub const NLM_F_DUMP_INTR: ::c_int = 16;
644-
pub const NLM_F_DUMP_FILTERED: ::c_int = 32;
645-
646-
pub const NLM_F_ROOT: ::c_int = 0x100;
647-
pub const NLM_F_MATCH: ::c_int = 0x200;
648-
pub const NLM_F_ATOMIC: ::c_int = 0x400;
649-
pub const NLM_F_DUMP: ::c_int = NLM_F_ROOT | NLM_F_MATCH;
650-
651-
pub const NLM_F_REPLACE: ::c_int = 0x100;
652-
pub const NLM_F_EXCL: ::c_int = 0x200;
653-
pub const NLM_F_CREATE: ::c_int = 0x400;
654-
pub const NLM_F_APPEND: ::c_int = 0x800;
655-
656-
pub const NETLINK_ADD_MEMBERSHIP: ::c_int = 1;
657-
pub const NETLINK_DROP_MEMBERSHIP: ::c_int = 2;
658-
pub const NETLINK_PKTINFO: ::c_int = 3;
659-
pub const NETLINK_BROADCAST_ERROR: ::c_int = 4;
660-
pub const NETLINK_NO_ENOBUFS: ::c_int = 5;
661-
pub const NETLINK_RX_RING: ::c_int = 6;
662-
pub const NETLINK_TX_RING: ::c_int = 7;
663-
pub const NETLINK_LISTEN_ALL_NSID: ::c_int = 8;
664-
pub const NETLINK_LIST_MEMBERSHIPS: ::c_int = 9;
665-
pub const NETLINK_CAP_ACK: ::c_int = 10;
666-
667-
pub const NLA_F_NESTED: ::c_int = 1 << 15;
668-
pub const NLA_F_NET_BYTEORDER: ::c_int = 1 << 14;
669-
pub const NLA_TYPE_MASK: ::c_int = !(NLA_F_NESTED | NLA_F_NET_BYTEORDER);
670-
671-
pub const NLA_ALIGNTO: ::c_int = 4;
672-
673616
pub const GENL_UNS_ADMIN_PERM: ::c_int = 0x10;
674617

675618
pub const GENL_ID_VFS_DQUOT: ::c_int = ::NLMSG_MIN_TYPE + 1;
@@ -929,12 +872,6 @@ cfg_if! {
929872
}
930873
pub const PTHREAD_MUTEX_ADAPTIVE_NP: ::c_int = 3;
931874

932-
f! {
933-
pub fn NLA_ALIGN(len: ::c_int) -> ::c_int {
934-
return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1)
935-
}
936-
}
937-
938875
extern {
939876
pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
940877
flags: ::c_int) -> ::c_int;

src/unix/linux_like/linux/mod.rs

+62
Original file line numberDiff line numberDiff line change
@@ -1897,6 +1897,64 @@ pub const NDA_PORT: ::c_ushort = 6;
18971897
pub const NDA_VNI: ::c_ushort = 7;
18981898
pub const NDA_IFINDEX: ::c_ushort = 8;
18991899

1900+
// linux/netlink.h
1901+
pub const NLA_ALIGNTO: ::c_int = 4;
1902+
1903+
pub const NETLINK_ROUTE: ::c_int = 0;
1904+
pub const NETLINK_UNUSED: ::c_int = 1;
1905+
pub const NETLINK_USERSOCK: ::c_int = 2;
1906+
pub const NETLINK_FIREWALL: ::c_int = 3;
1907+
pub const NETLINK_SOCK_DIAG: ::c_int = 4;
1908+
pub const NETLINK_NFLOG: ::c_int = 5;
1909+
pub const NETLINK_XFRM: ::c_int = 6;
1910+
pub const NETLINK_SELINUX: ::c_int = 7;
1911+
pub const NETLINK_ISCSI: ::c_int = 8;
1912+
pub const NETLINK_AUDIT: ::c_int = 9;
1913+
pub const NETLINK_FIB_LOOKUP: ::c_int = 10;
1914+
pub const NETLINK_CONNECTOR: ::c_int = 11;
1915+
pub const NETLINK_NETFILTER: ::c_int = 12;
1916+
pub const NETLINK_IP6_FW: ::c_int = 13;
1917+
pub const NETLINK_DNRTMSG: ::c_int = 14;
1918+
pub const NETLINK_KOBJECT_UEVENT: ::c_int = 15;
1919+
pub const NETLINK_GENERIC: ::c_int = 16;
1920+
pub const NETLINK_SCSITRANSPORT: ::c_int = 18;
1921+
pub const NETLINK_ECRYPTFS: ::c_int = 19;
1922+
pub const NETLINK_RDMA: ::c_int = 20;
1923+
pub const NETLINK_CRYPTO: ::c_int = 21;
1924+
pub const NETLINK_INET_DIAG: ::c_int = NETLINK_SOCK_DIAG;
1925+
1926+
pub const NLM_F_REQUEST: ::c_int = 1;
1927+
pub const NLM_F_MULTI: ::c_int = 2;
1928+
pub const NLM_F_ACK: ::c_int = 4;
1929+
pub const NLM_F_ECHO: ::c_int = 8;
1930+
pub const NLM_F_DUMP_INTR: ::c_int = 16;
1931+
pub const NLM_F_DUMP_FILTERED: ::c_int = 32;
1932+
1933+
pub const NLM_F_ROOT: ::c_int = 0x100;
1934+
pub const NLM_F_MATCH: ::c_int = 0x200;
1935+
pub const NLM_F_ATOMIC: ::c_int = 0x400;
1936+
pub const NLM_F_DUMP: ::c_int = NLM_F_ROOT | NLM_F_MATCH;
1937+
1938+
pub const NLM_F_REPLACE: ::c_int = 0x100;
1939+
pub const NLM_F_EXCL: ::c_int = 0x200;
1940+
pub const NLM_F_CREATE: ::c_int = 0x400;
1941+
pub const NLM_F_APPEND: ::c_int = 0x800;
1942+
1943+
pub const NETLINK_ADD_MEMBERSHIP: ::c_int = 1;
1944+
pub const NETLINK_DROP_MEMBERSHIP: ::c_int = 2;
1945+
pub const NETLINK_PKTINFO: ::c_int = 3;
1946+
pub const NETLINK_BROADCAST_ERROR: ::c_int = 4;
1947+
pub const NETLINK_NO_ENOBUFS: ::c_int = 5;
1948+
pub const NETLINK_RX_RING: ::c_int = 6;
1949+
pub const NETLINK_TX_RING: ::c_int = 7;
1950+
pub const NETLINK_LISTEN_ALL_NSID: ::c_int = 8;
1951+
pub const NETLINK_LIST_MEMBERSHIPS: ::c_int = 9;
1952+
pub const NETLINK_CAP_ACK: ::c_int = 10;
1953+
1954+
pub const NLA_F_NESTED: ::c_int = 1 << 15;
1955+
pub const NLA_F_NET_BYTEORDER: ::c_int = 1 << 14;
1956+
pub const NLA_TYPE_MASK: ::c_int = !(NLA_F_NESTED | NLA_F_NET_BYTEORDER);
1957+
19001958
// linux/rtnetlink.h
19011959
pub const TCA_UNSPEC: ::c_ushort = 0;
19021960
pub const TCA_KIND: ::c_ushort = 1;
@@ -2121,6 +2179,10 @@ pub const FUTEX_CMD_MASK: ::c_int =
21212179
!(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME);
21222180

21232181
f! {
2182+
pub fn NLA_ALIGN(len: ::c_int) -> ::c_int {
2183+
return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1)
2184+
}
2185+
21242186
pub fn CMSG_NXTHDR(mhdr: *const msghdr,
21252187
cmsg: *const cmsghdr) -> *mut cmsghdr {
21262188
if ((*cmsg).cmsg_len as usize) < ::mem::size_of::<cmsghdr>() {

0 commit comments

Comments
 (0)