1.\" 2.\" Copyright (C) 2022 Alexander Chernikov <melifaro@FreeBSD.org>. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23.\" SUCH DAMAGE. 24.\" 25.Dd September 9, 2026 26.Dt RTNETLINK 4 27.Os 28.Sh NAME 29.Nm RTNetlink 30.Nd Network configuration-specific Netlink family 31.Sh SYNOPSIS 32.In netlink/netlink.h 33.In netlink/netlink_route.h 34.Ft int 35.Fn socket AF_NETLINK SOCK_RAW NETLINK_ROUTE 36.Sh DESCRIPTION 37The 38.Dv NETLINK_ROUTE 39family aims to be the primary configuration mechanism for all 40network-related tasks. 41Currently it supports configuring interfaces, interface addresses, routes, 42nexthops and arp/ndp neighbors. 43.Sh ROUTES 44All route configuration messages share the common header: 45.Bd -literal 46struct rtmsg { 47 unsigned char rtm_family; /* address family */ 48 unsigned char rtm_dst_len; /* Prefix length */ 49 unsigned char rtm_src_len; /* Deprecated, set to 0 */ 50 unsigned char rtm_tos; /* Type of service (not used) */ 51 unsigned char rtm_table; /* deprecated, set to 0 */ 52 unsigned char rtm_protocol; /* Routing protocol id (RTPROT_) */ 53 unsigned char rtm_scope; /* Route distance (RT_SCOPE_) */ 54 unsigned char rtm_type; /* Route type (RTN_) */ 55 unsigned rtm_flags; /* Route flags (not supported) */ 56}; 57.Ed 58.Pp 59The 60.Va rtm_family 61specifies the route family to be operated on. 62Currently, 63.Dv AF_INET6 64and 65.Dv AF_INET 66are the only supported families. 67The route prefix length is stored in 68.Va rtm_dst_len 69. 70The caller should set the originator identity (one of the 71.Dv RTPROT_ 72values) in 73.Va rtm_protocol 74. 75It is useful for users and for the application itself, allowing for easy 76identification of self-originated routes. 77The route scope has to be set via 78.Va rtm_scope 79field. 80The supported values are: 81.Bd -literal -offset indent -compact 82RT_SCOPE_UNIVERSE Global scope 83RT_SCOPE_LINK Link scope 84.Ed 85.Pp 86Route type needs to be set. 87The defined values are: 88.Bd -literal -offset indent -compact 89RTN_UNICAST Unicast route 90RTN_MULTICAST Multicast route 91RTN_BLACKHOLE Drops traffic towards destination 92RTN_PROHIBIT Drops traffic and sends reject 93.Ed 94.Pp 95The following messages are supported: 96.Ss RTM_NEWROUTE 97Adds a new route. 98All NL flags are supported. 99Extending a multipath route requires NLM_F_APPEND flag. 100.Ss RTM_DELROUTE 101Tries to delete a route. 102The route is specified using a combination of 103.Dv RTA_DST 104TLV and 105.Va rtm_dst_len . 106.Ss RTM_GETROUTE 107Fetches a single route or all routes in the current VNET, depending on the 108.Dv NLM_F_DUMP 109flag. 110Each route is reported as 111.Dv RTM_NEWROUTE 112message. 113The following filters are recognised by the kernel: 114.Pp 115.Bd -literal -offset indent -compact 116rtm_family required family or AF_UNSPEC 117RTA_TABLE fib number or RT_TABLE_UNSPEC to return all fibs 118.Ed 119.Ss TLVs 120.Bl -tag -width indent 121.It Dv RTA_DST 122(binary) IPv4/IPv6 address, depending on the 123.Va rtm_family . 124.It Dv RTA_OIF 125(uint32_t) transmit interface index. 126.It Dv RTA_GATEWAY 127(binary) IPv4/IPv6 gateway address, depending on the 128.Va rtm_family . 129.It Dv RTA_PREFSRC 130(binary) IPv4/IPv6 preferred address, depending on the 131.Va rtm_family . 132.It Dv RTA_METRICS 133(nested) Container attribute, listing route properties. 134The only supported sub-attribute is 135.Dv RTAX_MTU , 136which stores path MTU as uint32_t. 137.It Dv RTA_MULTIPATH 138This attribute contains multipath route nexthops with their weights. 139These nexthops are represented as a sequence of 140.Va rtnexthop 141structures, each followed by 142.Dv RTA_GATEWAY 143or 144.Dv RTA_VIA 145attributes. 146.Bd -literal 147struct rtnexthop { 148 unsigned short rtnh_len; 149 unsigned char rtnh_flags; 150 unsigned char rtnh_hops; /* nexthop weight */ 151 int rtnh_ifindex; 152}; 153.Ed 154.Pp 155The 156.Va rtnh_len 157field specifies the total nexthop info length, including both 158.Va struct rtnexthop 159and the following TLVs. 160The 161.Va rtnh_hops 162field stores relative nexthop weight, used for load balancing between group 163members. 164The 165.Va rtnh_ifindex 166field contains the index of the transmit interface. 167.Pp 168The following TLVs can follow the structure: 169.Bd -literal -offset indent -compact 170RTA_GATEWAY IPv4/IPv6 nexthop address of the gateway 171RTA_VIA IPv6 nexthop address for IPv4 route 172RTA_KNH_ID Kernel-specific index of the nexthop 173.Ed 174.It Dv RTA_KNH_ID 175(uint32_t) (FreeBSD-specific) Auto-allocated kernel index of the nexthop. 176.It Dv RTA_RTFLAGS 177(uint32_t) (FreeBSD-specific) rtsock route flags. 178.It Dv RTA_TABLE 179(uint32_t) Fib number of the route. 180Default route table is 181.Dv RT_TABLE_MAIN . 182To explicitly specify "all tables" one needs to set the value to 183.Dv RT_TABLE_UNSPEC . 184.It Dv RTA_PRIORITY 185(uint32_t) metric of the nexthop. 186.It Dv RTA_EXPIRES 187(uint32_t) seconds till path expiration. 188.It Dv RTA_NH_ID 189(uint32_t) useland nexthop or nexthop group index. 190.El 191.Ss Groups 192The following groups are defined: 193.Bd -literal -offset indent -compact 194RTNLGRP_IPV4_ROUTE Notifies on IPv4 route arrival/removal/change 195RTNLGRP_IPV6_ROUTE Notifies on IPv6 route arrival/removal/change 196.Ed 197.Sh NEXTHOPS 198All nexthop/nexthop group configuration messages share the common header: 199.Bd -literal 200struct nhmsg { 201 unsigned char nh_family; /* transport family */ 202 unsigned char nh_scope; /* ignored on RX, filled by kernel */ 203 unsigned char nh_protocol; /* Routing protocol that installed nh */ 204 unsigned char resvd; 205 unsigned int nh_flags; /* RTNH_F_* flags from route.h */ 206}; 207.Ed 208The 209.Va nh_family 210specifies the gateway address family. 211It can be different from route address family for IPv4 routes with IPv6 212nexthops. 213The 214.Va nh_protocol 215is similar to 216.Va rtm_protocol 217field, which designates originator application identity. 218.Pp 219The following messages are supported: 220.Ss RTM_NEWNEXTHOP 221Creates a new nexthop or nexthop group. 222.Ss RTM_DELNEXTHOP 223Deletes nexthop or nexthhop group. 224The required object is specified by the 225.Dv RTA_NH_ID 226attribute. 227.Ss RTM_GETNEXTHOP 228Fetches a single nexthop or all nexthops/nexthop groups, depending on the 229.Dv NLM_F_DUMP 230flag. 231The following filters are recognised by the kernel: 232.Pp 233.Bd -literal -offset indent -compact 234RTA_NH_ID nexthop or nexthtop group id 235NHA_GROUPS match only nexthtop groups 236.Ed 237.Ss TLVs 238.Bl -tag -width indent 239.It Dv RTA_NH_ID 240(uint32_t) Nexthhop index used to identify particular nexthop or nexthop group. 241Should be provided by userland at the nexthtop creation time. 242.It Dv NHA_GROUP 243This attribute designates the nexthtop group and contains all of its nexthtops 244and their relative weights. 245The attribute consists of a list of 246.Va nexthop_grp 247structures: 248.Bd -literal 249struct nexthop_grp { 250 uint32_t id; /* nexhop userland index */ 251 uint8_t weight; /* weight of this nexthop */ 252 uint8_t resvd1; 253 uint16_t resvd2; 254}; 255.Ed 256.It Dv NHA_GROUP_TYPE 257(uint16_t) Nexthtop group type, set to one of the following types: 258.Bd -literal -offset indent -compact 259NEXTHOP_GRP_TYPE_MPATH default multipath group 260.Ed 261.It Dv NHA_BLACKHOLE 262(flag) Marks the nexthtop as blackhole. 263.It Dv NHA_OIF 264(uint32_t) Transmit interface index of the nexthtop. 265.It Dv NHA_GATEWAY 266(binary) IPv4/IPv6 gateway address 267.It Dv NHA_GROUPS 268(flag) Matches nexthtop groups during dump. 269.El 270.Ss Groups 271The following groups are defined: 272.Bd -literal -offset indent -compact 273RTNLGRP_NEXTHOP Notifies on nexthop/groups arrival/removal/change 274.Ed 275.Sh INTERFACES 276All interface configuration messages share the common header: 277.Bd -literal 278struct ifinfomsg { 279 unsigned char ifi_family; /* not used, set to 0 */ 280 unsigned char __ifi_pad; 281 unsigned short ifi_type; /* IFT_* */ 282 int ifi_index; /* Interface index */ 283 unsigned ifi_flags; /* IFF_* flags */ 284 unsigned ifi_change; /* IFF_* change mask */ 285}; 286.Ed 287.Pp 288.Sy Note : 289On 290.Fx 291the 292.Va ifi_type 293field uses 294.Dv IFT_* 295constants from 296.In net/if_types.h 297rather than 298.Dv ARPHRD_* 299as on Linux. 300.Ss RTM_NEWLINK 301Creates a new interface. 302The only mandatory TLV is 303.Dv IFLA_IFNAME . 304The following attributes are returned inside the nested 305.Dv NLMSGERR_ATTR_COOKIE : 306.Pp 307.Bd -literal -offset indent -compact 308IFLA_NEW_IFINDEX (uint32) created interface index 309IFLA_IFNAME (string) created interface name 310.Ed 311.Ss RTM_DELLINK 312Deletes the interface specified by 313.Dv IFLA_IFNAME . 314.Ss RTM_GETLINK 315Fetches a single interface or all interfaces in the current VNET, 316depending on the 317.Dv NLM_F_DUMP 318flag. 319Each interface is reported as a 320.Dv RTM_NEWLINK 321message. 322The following filters are recognised by the kernel: 323.Pp 324.Bd -literal -offset indent -compact 325ifi_index interface index 326IFLA_IFNAME interface name 327IFLA_ALT_IFNAME interface name 328IFLA_EXT_MASK extended information selection bitmap 329.Ed 330.Pp 331Setting the 332.Dv RTEXT_FILTER_VF 333bit in 334.Dv IFLA_EXT_MASK 335requests SR-IOV VF status. 336The query is opt-in because obtaining status can require entering the PF 337driver. 338VF status is not included in unsolicited link notifications. 339.Ss TLVs 340.Bl -tag -width indent 341.It Dv IFLA_ADDRESS 342(binary) Llink-level interface address (MAC). 343.It Dv IFLA_BROADCAST 344(binary) (readonly) Link-level broadcast address. 345.It Dv IFLA_IFNAME 346(string) New interface name. 347.It Dv IFLA_IFALIAS 348(string) Interface description. 349.It Dv IFLA_LINK 350(uint32_t) (readonly) Interface index. 351.It Dv IFLA_MASTER 352(uint32_t) Parent interface index. 353.It Dv IFLA_NUM_VF 354(uint32_t) (readonly) Number of VF records returned. 355This attribute is returned with a successful 356.Dv RTEXT_FILTER_VF 357query. 358.It Dv IFLA_FREEBSD 359(nested) Local interface attributes. 360When requested, 361.Dv IFLAF_VF_STATUS 362contains the following nested attributes: 363.Bd -literal -offset indent -compact 364IFLAF_VFS_ERROR (uint32_t) errno if the PF query failed 365IFLAF_VFS_PF_LINK_STATE (uint8_t) IFLAF_VF_LINK_* 366IFLAF_VFS_PF_LINK_SPEED (uint64_t) bits per second 367.Ed 368.Pp 369If the PF status provider does not implement this query, the status block is 370omitted. 371If an implemented PF status query fails, 372.Dv IFLAF_VFS_ERROR 373contains the errno value and the other status attributes are omitted. 374An empty status snapshot reports 375.Dv IFLA_NUM_VF 376as zero and contains no 377.Dv IFLA_FREEBSD_VF 378attributes. 379.Pp 380Invalid or oversized data returned by a provider is reported through 381.Dv IFLAF_VFS_ERROR . 382Allocation failures while encoding the reply terminate the requested 383.Dv RTM_GETLINK 384operation with an error. 385For a multipart dump, valid interface records may precede the terminating 386error. 387.It Dv IFLA_FREEBSD_VF 388(nested) (readonly) One VF record containing 389.Dv IFLAF_VF_* 390attributes. 391The attribute is repeated once for every VF in a successful status snapshot. 392Keeping each VF in an independent attribute permits the complete Netlink 393message to exceed the 16-bit length limit of an individual attribute. 394Each 395.Dv IFLA_FREEBSD_VF 396may contain the following attributes: 397.Bd -literal -offset indent -compact 398IFLAF_VF_INDEX (uint32_t) PF-local VF index 399IFLAF_VF_CONFIGURED (bool) PF accepted configuration 400IFLAF_VF_INITIALIZED (bool) VF handshake completed 401IFLAF_VF_MAC (binary) PF-known primary MAC address 402IFLAF_VF_VLAN_MODE (uint8_t) IFLAF_VF_VLAN_* 403IFLAF_VF_VLAN (uint16_t) access VLAN identifier 404IFLAF_VF_VLAN_PCP (uint8_t) PF-administered priority code point 405IFLAF_VF_VLAN_PROTO (uint16_t) host-order access VLAN EtherType 406IFLAF_VF_VLAN_COUNT (uint32_t) explicit VLAN filters 407IFLAF_VF_VLAN_LIMIT (uint32_t) explicit VLAN-filter limit 408IFLAF_VF_NUM_TX_QUEUES (uint16_t) allocated transmit queues 409IFLAF_VF_NUM_RX_QUEUES (uint16_t) allocated receive queues 410IFLAF_VF_MIN_TX_RATE (uint64_t) minimum transmit bits per second 411IFLAF_VF_MAX_TX_RATE (uint64_t) maximum transmit bits per second 412IFLAF_VF_ALLOW_SET_MAC (bool) administrative permission 413IFLAF_VF_ALLOW_SET_VLAN (bool) administrative permission 414IFLAF_VF_MAC_ANTI_SPOOF (bool) MAC anti-spoofing enabled 415IFLAF_VF_ALLOW_PROMISC (bool) administrative permission 416IFLAF_VF_TRAFFIC_ALLOWED (bool) PF permits VF data traffic 417IFLAF_VF_FAULT_BLOCKED (bool) fault-containment block active 418IFLAF_VF_QUARANTINED (bool) persistent quarantine active 419IFLAF_VF_API_VERSION (string) negotiated mailbox API 420IFLAF_VF_LINK_STATE_POLICY (uint8_t) IFLAF_VF_LINK_* 421IFLAF_VF_DRIVER (nested) driver namespace; repeated 422.Ed 423.Pp 424.Dv IFLAF_VF_INDEX 425is required in every list entry. 426Other fields are optional and are omitted when the PF driver cannot observe 427them; omission does not mean false or zero. 428Boolean attributes contain a native Netlink boolean value. 429.Dv IFLAF_VF_CONFIGURED 430means that the PF accepted the VF configuration, while 431.Dv IFLAF_VF_INITIALIZED 432means that the VF completed its driver or mailbox handshake since its last 433reset. 434.Pp 435.Dv IFLAF_VF_TRAFFIC_ALLOWED 436means that the PF currently permits the VF to send and receive data traffic. 437It does not imply that the VF completed initialization, enabled queues, has 438link, or is actively passing packets. 439.Dv IFLAF_VF_FAULT_BLOCKED 440means that the PF isolated the VF because of a detected fault or abusive 441behavior. 442It does not include ordinary unconfigured, reset, or link-down states. 443When present, a driver namespace may describe the particular cause and 444recovery policy. 445When both fields are present, a fault block implies that traffic is not 446allowed. 447.Dv IFLAF_VF_QUARANTINED 448describes a persistent form of containment and, when both fields are present, 449implies that a fault block is active. 450.Pp 451.Dv IFLAF_VF_NUM_TX_QUEUES 452and 453.Dv IFLAF_VF_NUM_RX_QUEUES 454are the numbers of transmit and receive queues allocated to the VF, not 455necessarily the numbers currently used by its driver. 456The transmit-rate attributes describe configured aggregate VF policy. 457A present zero minimum means no guaranteed allocation; a present zero maximum 458means no rate limit. 459When both are present and the maximum is nonzero, the minimum does not exceed 460the maximum. 461Access VLAN mode means that the PF imposes a single port VLAN policy. 462The optional 463.Dv IFLAF_VF_VLAN 464and 465.Dv IFLAF_VF_VLAN_PROTO 466attributes describe its VLAN identifier and host-order tag EtherType, 467respectively, and are present only in access mode. 468A present zero VLAN identifier can represent a priority-only access tag. 469Trunk mode means that no access VLAN is imposed and does not promise unlimited 470filter capacity. 471.Dv IFLAF_VF_VLAN_PCP 472describes the PF-administered IEEE 802.1p priority code point (0 through 7). 473It may be present in access or trunk mode, including priority-only tagging 474with VID 0. 475A present zero priority is distinct from an omitted priority. 476These attributes do not describe individual trunk filters or priorities 477selected by the VF. 478.Dv IFLAF_VF_VLAN_COUNT 479counts explicit filters recorded by the PF. 480It excludes untagged or priority-tag membership installed implicitly by the 481PF. 482The permission attributes describe requests the VF may make, not requests it 483has made. 484The top-level PF link state and speed are values normally advertised to VFs, 485not evidence that a VF driver is operational. 486.Pp 487Link-state values are: 488.Bd -literal -offset indent -compact 489IFLAF_VF_LINK_UNKNOWN state is unavailable 490IFLAF_VF_LINK_DOWN link is forced or observed down 491IFLAF_VF_LINK_UP link is forced or observed up 492IFLAF_VF_LINK_AUTO VF follows PF link state 493.Ed 494.Pp 495VLAN-mode values are: 496.Bd -literal -offset indent -compact 497IFLAF_VF_VLAN_UNKNOWN mode is unavailable 498IFLAF_VF_VLAN_ACCESS PF imposes an access VLAN 499IFLAF_VF_VLAN_TRUNK no access VLAN is imposed 500.Ed 501.Pp 502Driver-specific data is returned under 503.Dv IFLAF_VF_DRIVER , 504which may be repeated directly in a VF record. 505Each driver object contains: 506.Bd -literal -offset indent -compact 507IFLAF_VFD_NAME (string) stable namespace name 508IFLAF_VFD_VERSION (uint32_t) namespace schema version 509IFLAF_VFD_FIELD (nested) namespace field; repeated 510.Ed 511.Pp 512Each field contains its namespace-local name in 513.Dv IFLAF_VFDF_NAME 514and exactly one of 515.Dv IFLAF_VFDF_BOOL , 516.Dv IFLAF_VFDF_NUMBER , 517.Dv IFLAF_VFDF_STRING , 518or 519.Dv IFLAF_VFDF_BINARY . 520The namespace defines the types and meanings of its fields. 521The named, typed form permits generic consumers to carry or display an 522extension without knowing its driver-specific schema. 523Consumers that interpret extensions must ignore unknown namespaces and 524fields. 525Each attribute, including each containing nested attribute, is limited to 52665535 bytes by the Netlink encoding. 527If an individual VF record, driver extension, or field cannot be encoded 528within that limit, 529.Dv IFLAF_VFS_ERROR 530reports 531.Er EMSGSIZE . 532The enclosing 533.Dv RTM_NEWLINK 534message may exceed 65535 bytes. 535.It Dv IFLA_LINKINFO 536(nested) Interface type-specific attributes: 537.Bd -literal -offset indent -compact 538IFLA_INFO_KIND (string) interface type ("vlan") 539IFLA_INFO_DATA (nested) custom attributes 540.Ed 541The following types and attributes are supported: 542.Bl -tag -width indent 543.It Dv vlan 544.Bd -literal -offset indent -compact 545IFLA_VLAN_ID (uint16_t) 802.1Q vlan id 546IFLA_VLAN_PROTOCOL (uint16_t) Protocol: ETHERTYPE_VLAN or ETHERTYPE_QINQ 547.Ed 548.El 549.It Dv IFLA_OPERSTATE 550(uint8_t) Interface operational state per RFC 2863. 551Can be one of the following: 552.Bd -literal -offset indent -compact 553IF_OPER_UNKNOWN status can not be determined 554IF_OPER_NOTPRESENT some (hardware) component not present 555IF_OPER_DOWN down 556IF_OPER_LOWERLAYERDOWN some lower-level interface is down 557IF_OPER_TESTING in some test mode 558IF_OPER_DORMANT "up" but waiting for some condition (802.1X) 559IF_OPER_UP ready to pass packets 560.Ed 561.It Dv IFLA_STATS64 562(readonly) Consists of the following 64-bit counters structure: 563.Bd -literal 564struct rtnl_link_stats64 { 565 uint64_t rx_packets; /* total RX packets (IFCOUNTER_IPACKETS) */ 566 uint64_t tx_packets; /* total TX packets (IFCOUNTER_OPACKETS) */ 567 uint64_t rx_bytes; /* total RX bytes (IFCOUNTER_IBYTES) */ 568 uint64_t tx_bytes; /* total TX bytes (IFCOUNTER_OBYTES) */ 569 uint64_t rx_errors; /* RX errors (IFCOUNTER_IERRORS) */ 570 uint64_t tx_errors; /* RX errors (IFCOUNTER_OERRORS) */ 571 uint64_t rx_dropped; /* RX drop (no space in ring/no bufs) (IFCOUNTER_IQDROPS) */ 572 uint64_t tx_dropped; /* TX drop (IFCOUNTER_OQDROPS) */ 573 uint64_t multicast; /* RX multicast packets (IFCOUNTER_IMCASTS) */ 574 uint64_t collisions; /* not supported */ 575 uint64_t rx_length_errors; /* not supported */ 576 uint64_t rx_over_errors; /* not supported */ 577 uint64_t rx_crc_errors; /* not supported */ 578 uint64_t rx_frame_errors; /* not supported */ 579 uint64_t rx_fifo_errors; /* not supported */ 580 uint64_t rx_missed_errors; /* not supported */ 581 uint64_t tx_aborted_errors; /* not supported */ 582 uint64_t tx_carrier_errors; /* not supported */ 583 uint64_t tx_fifo_errors; /* not supported */ 584 uint64_t tx_heartbeat_errors; /* not supported */ 585 uint64_t tx_window_errors; /* not supported */ 586 uint64_t rx_compressed; /* not supported */ 587 uint64_t tx_compressed; /* not supported */ 588 uint64_t rx_nohandler; /* dropped due to no proto handler (IFCOUNTER_NOPROTO) */ 589}; 590.Ed 591.El 592.Ss Groups 593The following groups are defined: 594.Bd -literal -offset indent -compact 595RTNLGRP_LINK Notifies on interface arrival/removal/change 596.Ed 597.Sh INTERFACE ADDRESSES 598All interface address configuration messages share the common header: 599.Bd -literal 600struct ifaddrmsg { 601 uint8_t ifa_family; /* Address family */ 602 uint8_t ifa_prefixlen; /* Prefix length */ 603 uint8_t ifa_flags; /* Address-specific flags */ 604 uint8_t ifa_scope; /* Address scope */ 605 uint32_t ifa_index; /* Link ifindex */ 606}; 607.Ed 608.Pp 609The 610.Va ifa_family 611specifies the address family of the interface address. 612The 613.Va ifa_prefixlen 614specifies the prefix length if applicable for the address family. 615The 616.Va ifa_index 617specifies the interface index of the target interface. 618.Ss RTM_NEWADDR 619Not supported 620.Ss RTM_DELADDR 621Not supported 622.Ss RTM_GETADDR 623Fetches interface addresses in the current VNET matching conditions. 624Each address is reported as a 625.Dv RTM_NEWADDR 626message. 627The following filters are recognised by the kernel: 628.Pp 629.Bd -literal -offset indent -compact 630ifa_family required family or AF_UNSPEC 631ifa_index matching interface index or 0 632.Ed 633.Ss TLVs 634.Bl -tag -width indent 635.It Dv IFA_ADDRESS 636(binary) masked interface address or destination address for p2p interfaces. 637.It Dv IFA_LOCAL 638(binary) local interface address. 639Set for IPv4 and p2p addresses. 640.It Dv IFA_LABEL 641(string) interface name. 642.It Dv IFA_BROADCAST 643(binary) broadcast interface address. 644.El 645.Ss Groups 646The following groups are defined: 647.Bd -literal -offset indent -compact 648RTNLGRP_IPV4_IFADDR Notifies on IPv4 ifaddr arrival/removal/change 649RTNLGRP_IPV6_IFADDR Notifies on IPv6 ifaddr arrival/removal/change 650.Ed 651.Sh NEIGHBORS 652All neighbor configuration messages share the common header: 653.Bd -literal 654struct ndmsg { 655 uint8_t ndm_family; 656 uint8_t ndm_pad1; 657 uint16_t ndm_pad2; 658 int32_t ndm_ifindex; 659 uint16_t ndm_state; 660 uint8_t ndm_flags; 661 uint8_t ndm_type; 662}; 663.Ed 664.Pp 665The 666.Va ndm_family 667field specifies the address family (IPv4 or IPv6) of the neighbor. 668The 669.Va ndm_ifindex 670specifies the interface to operate on. 671The 672.Va ndm_state 673represents the entry state according to the neighbor model. 674The state can be one of the following: 675.Bd -literal -offset indent -compact 676NUD_INCOMPLETE No lladdr, address resolution in progress 677NUD_REACHABLE reachable & recently resolved 678NUD_STALE has lladdr but it's stale 679NUD_DELAY has lladdr, is stale, probes delayed 680NUD_PROBE has lladdr, is stale, probes sent 681NUD_FAILED unused 682.Ed 683.Pp 684The 685.Va ndm_flags 686field stores the options specific to this entry. 687Available flags: 688.Bd -literal -offset indent -compact 689NTF_SELF local station (LLE_IFADDR) 690NTF_PROXY proxy entry (LLE_PUB) 691NTF_STICKY permanent entry (LLE_STATIC) 692NTF_ROUTER dst indicated itself as a router 693.Ed 694.Ss RTM_NEWNEIGH 695Creates new neighbor entry. 696The mandatory options are 697.Dv NDA_DST , 698.Dv NDA_LLADDR 699and 700.Dv NDA_IFINDEX . 701.Ss RTM_DELNEIGH 702Deletes the neighbor entry. 703The entry is specified by the combination of 704.Dv NDA_DST 705and 706.Dv NDA_IFINDEX . 707.Ss RTM_GETNEIGH 708Fetches a single neighbor or all neighbors in the current VNET, depending on the 709.Dv NLM_F_DUMP 710flag. 711Each entry is reported as 712.Dv RTM_NEWNEIGH 713message. 714The following filters are recognised by the kernel: 715.Pp 716.Bd -literal -offset indent -compact 717ndm_family required family or AF_UNSPEC 718ndm_ifindex target ifindex 719NDA_IFINDEX target ifindex 720.Ed 721.Ss TLVs 722.Bl -tag -width indent 723.It Dv NDA_DST 724(binary) neighbor IPv4/IPv6 address. 725.It Dv NDA_LLADDR 726(binary) neighbor link-level address. 727.It Dv NDA_IFINDEX 728(uint32_t) interface index. 729.It Dv NDA_FLAGS_EXT 730(uint32_t) extended version of 731.Va ndm_flags . 732.El 733.Ss Groups 734The following groups are defined: 735.Bd -literal -offset indent -compact 736RTNLGRP_NEIGH Notifies on ARP/NDP neighbor arrival/removal/change 737.Ed 738.Sh SEE ALSO 739.Xr snl 3 , 740.Xr netlink 4 , 741.Xr route 4 742.Sh HISTORY 743The 744.Dv NETLINK_ROUTE 745protocol family appeared in 746.Fx 13.2 . 747.Sh AUTHORS 748The netlink was implemented by 749.An -nosplit 750.An Alexander Chernikov Aq Mt melifaro@FreeBSD.org . 751It was derived from the Google Summer of Code 2021 project by 752.An Ng Peng Nam Sean . 753