Skip to content

Commit 795adbe

Browse files
committed
Auto merge of #2889 - phi-gamma:rtnetlink-mcast-groups, r=JohnTitor
linux: add rtnetlink mcast group definitions These come in two flavors: - RTNLGRP_* are bit indexes (arguments to setsockopt(2)) as used in the kernel with test_bit() but also userspace (see libnl examples). - RTMGRP_* are bitmasks not used in the kernel; their use seems to be deprecated, at least according to comments in libnl, but documentation still references them. The rationale for adding these definitions is that they're needed to subscribe to kernel events via Netlink multicast groups.
2 parents f1c3cfe + d2e04b9 commit 795adbe

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

libc-test/build.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3213,6 +3213,12 @@ fn test_linux(target: &str) {
32133213
| "NFULA_VLAN_UNSPEC" // v5.4+
32143214
| "NFULA_VLAN_PROTO" // v5.4+
32153215
| "NFULA_VLAN_TCI" => true, // v5.4+
3216+
| "RTNLGRP_NEXTHOP" // linux v5.3+
3217+
| "RTNLGRP_BRVLAN" // linux v5.6+
3218+
| "RTNLGRP_MCTP_IFADDR" // linux v5.17+
3219+
| "RTNLGRP_TUNNEL" // linux v5.18+
3220+
| "RTNLGRP_STATS" // linux v5.18+
3221+
=> true,
32163222

32173223
_ => false,
32183224
}

src/unix/linux_like/linux/mod.rs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2669,6 +2669,62 @@ pub const ARPD_LOOKUP: ::c_ushort = 0x02;
26692669
pub const ARPD_FLUSH: ::c_ushort = 0x03;
26702670
pub const ATF_MAGIC: ::c_int = 0x80;
26712671

2672+
// userspace compat definitions for RTNLGRP_*
2673+
pub const RTMGRP_LINK: ::c_int = 0x00001;
2674+
pub const RTMGRP_NOTIFY: ::c_int = 0x00002;
2675+
pub const RTMGRP_NEIGH: ::c_int = 0x00004;
2676+
pub const RTMGRP_TC: ::c_int = 0x00008;
2677+
pub const RTMGRP_IPV4_IFADDR: ::c_int = 0x00010;
2678+
pub const RTMGRP_IPV4_MROUTE: ::c_int = 0x00020;
2679+
pub const RTMGRP_IPV4_ROUTE: ::c_int = 0x00040;
2680+
pub const RTMGRP_IPV4_RULE: ::c_int = 0x00080;
2681+
pub const RTMGRP_IPV6_IFADDR: ::c_int = 0x00100;
2682+
pub const RTMGRP_IPV6_MROUTE: ::c_int = 0x00200;
2683+
pub const RTMGRP_IPV6_ROUTE: ::c_int = 0x00400;
2684+
pub const RTMGRP_IPV6_IFINFO: ::c_int = 0x00800;
2685+
pub const RTMGRP_DECnet_IFADDR: ::c_int = 0x01000;
2686+
pub const RTMGRP_DECnet_ROUTE: ::c_int = 0x04000;
2687+
pub const RTMGRP_IPV6_PREFIX: ::c_int = 0x20000;
2688+
2689+
// enum rtnetlink_groups
2690+
pub const RTNLGRP_NONE: ::c_uint = 0x00;
2691+
pub const RTNLGRP_LINK: ::c_uint = 0x01;
2692+
pub const RTNLGRP_NOTIFY: ::c_uint = 0x02;
2693+
pub const RTNLGRP_NEIGH: ::c_uint = 0x03;
2694+
pub const RTNLGRP_TC: ::c_uint = 0x04;
2695+
pub const RTNLGRP_IPV4_IFADDR: ::c_uint = 0x05;
2696+
pub const RTNLGRP_IPV4_MROUTE: ::c_uint = 0x06;
2697+
pub const RTNLGRP_IPV4_ROUTE: ::c_uint = 0x07;
2698+
pub const RTNLGRP_IPV4_RULE: ::c_uint = 0x08;
2699+
pub const RTNLGRP_IPV6_IFADDR: ::c_uint = 0x09;
2700+
pub const RTNLGRP_IPV6_MROUTE: ::c_uint = 0x0a;
2701+
pub const RTNLGRP_IPV6_ROUTE: ::c_uint = 0x0b;
2702+
pub const RTNLGRP_IPV6_IFINFO: ::c_uint = 0x0c;
2703+
pub const RTNLGRP_DECnet_IFADDR: ::c_uint = 0x0d;
2704+
pub const RTNLGRP_NOP2: ::c_uint = 0x0e;
2705+
pub const RTNLGRP_DECnet_ROUTE: ::c_uint = 0x0f;
2706+
pub const RTNLGRP_DECnet_RULE: ::c_uint = 0x10;
2707+
pub const RTNLGRP_NOP4: ::c_uint = 0x11;
2708+
pub const RTNLGRP_IPV6_PREFIX: ::c_uint = 0x12;
2709+
pub const RTNLGRP_IPV6_RULE: ::c_uint = 0x13;
2710+
pub const RTNLGRP_ND_USEROPT: ::c_uint = 0x14;
2711+
pub const RTNLGRP_PHONET_IFADDR: ::c_uint = 0x15;
2712+
pub const RTNLGRP_PHONET_ROUTE: ::c_uint = 0x16;
2713+
pub const RTNLGRP_DCB: ::c_uint = 0x17;
2714+
pub const RTNLGRP_IPV4_NETCONF: ::c_uint = 0x18;
2715+
pub const RTNLGRP_IPV6_NETCONF: ::c_uint = 0x19;
2716+
pub const RTNLGRP_MDB: ::c_uint = 0x1a;
2717+
pub const RTNLGRP_MPLS_ROUTE: ::c_uint = 0x1b;
2718+
pub const RTNLGRP_NSID: ::c_uint = 0x1c;
2719+
pub const RTNLGRP_MPLS_NETCONF: ::c_uint = 0x1d;
2720+
pub const RTNLGRP_IPV4_MROUTE_R: ::c_uint = 0x1e;
2721+
pub const RTNLGRP_IPV6_MROUTE_R: ::c_uint = 0x1f;
2722+
pub const RTNLGRP_NEXTHOP: ::c_uint = 0x20;
2723+
pub const RTNLGRP_BRVLAN: ::c_uint = 0x21;
2724+
pub const RTNLGRP_MCTP_IFADDR: ::c_uint = 0x22;
2725+
pub const RTNLGRP_TUNNEL: ::c_uint = 0x23;
2726+
pub const RTNLGRP_STATS: ::c_uint = 0x24;
2727+
26722728
// linux/module.h
26732729
pub const MODULE_INIT_IGNORE_MODVERSIONS: ::c_uint = 0x0001;
26742730
pub const MODULE_INIT_IGNORE_VERMAGIC: ::c_uint = 0x0002;

0 commit comments

Comments
 (0)