xref: /freebsd/share/man/man9/ifnet.9 (revision 1323ec57)
1.\" -*- Nroff -*-
2.\" Copyright 1996, 1997 Massachusetts Institute of Technology
3.\"
4.\" Permission to use, copy, modify, and distribute this software and
5.\" its documentation for any purpose and without fee is hereby
6.\" granted, provided that both the above copyright notice and this
7.\" permission notice appear in all copies, that both the above
8.\" copyright notice and this permission notice appear in all
9.\" supporting documentation, and that the name of M.I.T. not be used
10.\" in advertising or publicity pertaining to distribution of the
11.\" software without specific, written prior permission.  M.I.T. makes
12.\" no representations about the suitability of this software for any
13.\" purpose.  It is provided "as is" without express or implied
14.\" warranty.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''.  M.I.T. DISCLAIMS
17.\" ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
18.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
20.\" SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23.\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24.\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27.\" SUCH DAMAGE.
28.\"
29.\" $FreeBSD$
30.\"
31.Dd September 28, 2020
32.Dt IFNET 9
33.Os
34.Sh NAME
35.Nm ifnet ,
36.Nm ifaddr ,
37.Nm ifqueue ,
38.Nm if_data
39.Nd kernel interfaces for manipulating network interfaces
40.Sh SYNOPSIS
41.In sys/param.h
42.In sys/time.h
43.In sys/socket.h
44.In net/if.h
45.In net/if_var.h
46.In net/if_types.h
47.\"
48.Ss "Interface Manipulation Functions"
49.Ft "struct ifnet *"
50.Fn if_alloc "u_char type"
51.Ft "struct ifnet *"
52.Fn if_alloc_dev "u_char type" "device_t dev"
53.Ft "struct ifnet *"
54.Fn if_alloc_domain "u_char type" "int numa_domain"
55.Ft void
56.Fn if_attach "struct ifnet *ifp"
57.Ft void
58.Fn if_detach "struct ifnet *ifp"
59.Ft void
60.Fn if_free "struct ifnet *ifp"
61.Ft void
62.Fn if_free_type "struct ifnet *ifp" "u_char type"
63.Ft void
64.Fn if_down "struct ifnet *ifp"
65.Ft int
66.Fn ifioctl "struct socket *so" "u_long cmd" "caddr_t data" "struct thread *td"
67.Ft int
68.Fn ifpromisc "struct ifnet *ifp" "int pswitch"
69.Ft int
70.Fn if_allmulti "struct ifnet *ifp" "int amswitch"
71.Ft "struct ifnet *"
72.Fn ifunit "const char *name"
73.Ft "struct ifnet *"
74.Fn ifunit_ref "const char *name"
75.Ft void
76.Fn if_up "struct ifnet *ifp"
77.\"
78.Ss "Interface Address Functions"
79.Ft "struct ifaddr *"
80.Fn ifaddr_byindex "u_short idx"
81.Ft "struct ifaddr *"
82.Fn ifa_ifwithaddr "struct sockaddr *addr"
83.Ft "struct ifaddr *"
84.Fn ifa_ifwithdstaddr "struct sockaddr *addr" "int fib"
85.Ft "struct ifaddr *"
86.Fn ifa_ifwithnet "struct sockaddr *addr" "int ignore_ptp" "int fib"
87.Ft "struct ifaddr *"
88.Fn ifaof_ifpforaddr "struct sockaddr *addr" "struct ifnet *ifp"
89.Ft void
90.Fn ifa_ref "struct ifaddr *ifa"
91.Ft void
92.Fn ifa_free "struct ifaddr *ifa"
93.\"
94.Ss "Interface Multicast Address Functions"
95.Ft int
96.Fn if_addmulti "struct ifnet *ifp" "struct sockaddr *sa" "struct ifmultiaddr **ifmap"
97.Ft int
98.Fn if_delmulti "struct ifnet *ifp" "struct sockaddr *sa"
99.Ft "struct ifmultiaddr *"
100.Fn if_findmulti "struct ifnet *ifp" "struct sockaddr *sa"
101.Ss "Output queue macros"
102.Fn IF_DEQUEUE "struct ifqueue *ifq" "struct mbuf *m"
103.\"
104.Ss "struct ifnet Member Functions"
105.Ft void
106.Fn \*(lp*if_input\*(rp "struct ifnet *ifp" "struct mbuf *m"
107.Ft int
108.Fo \*(lp*if_output\*(rp
109.Fa "struct ifnet *ifp" "struct mbuf *m"
110.Fa "const struct sockaddr *dst" "struct route *ro"
111.Fc
112.Ft void
113.Fn \*(lp*if_start\*(rp "struct ifnet *ifp"
114.Ft int
115.Fn \*(lp*if_transmit\*(rp "struct ifnet *ifp" "struct mbuf *m"
116.Ft void
117.Fn \*(lp*if_qflush\*(rp "struct ifnet *ifp"
118.Ft int
119.Fn \*(lp*if_ioctl\*(rp "struct ifnet *ifp" "u_long cmd" "caddr_t data"
120.Ft void
121.Fn \*(lp*if_init\*(rp "void *if_softc"
122.Ft int
123.Fo \*(lp*if_resolvemulti\*(rp
124.Fa "struct ifnet *ifp" "struct sockaddr **retsa" "struct sockaddr *addr"
125.Fc
126.Ss "struct ifaddr member function"
127.Ft void
128.Fo \*(lp*ifa_rtrequest\*(rp
129.Fa "int cmd" "struct rtentry *rt" "struct rt_addrinfo *info"
130.Fc
131.\"
132.Ss "Global Variables"
133.Vt extern struct ifnethead ifnet ;
134.\" extern struct ifindex_entry *ifindex_table ;
135.Vt extern int if_index ;
136.Vt extern int ifqmaxlen ;
137.Sh DATA STRUCTURES
138The kernel mechanisms for handling network interfaces reside primarily
139in the
140.Vt ifnet , if_data , ifaddr ,
141and
142.Vt ifmultiaddr
143structures in
144.In net/if.h
145and
146.In net/if_var.h
147and the functions named above and defined in
148.Pa /sys/net/if.c .
149Those interfaces which are intended to be used by user programs
150are defined in
151.In net/if.h ;
152these include the interface flags, the
153.Vt if_data
154structure, and the structures defining the appearance of
155interface-related messages on the
156.Xr route 4
157routing socket and in
158.Xr sysctl 3 .
159The header file
160.In net/if_var.h
161defines the kernel-internal interfaces, including the
162.Vt ifnet , ifaddr ,
163and
164.Vt ifmultiaddr
165structures and the functions which manipulate them.
166(A few user programs will need
167.In net/if_var.h
168because it is the prerequisite of some other header file like
169.In netinet/if_ether.h .
170Most references to those two files in particular can be replaced by
171.In net/ethernet.h . )
172.Pp
173The system keeps a linked list of interfaces using the
174.Li TAILQ
175macros defined in
176.Xr queue 3 ;
177this list is headed by a
178.Vt "struct ifnethead"
179called
180.Va ifnet .
181The elements of this list are of type
182.Vt "struct ifnet" ,
183and most kernel routines which manipulate interface as such accept or
184return pointers to these structures.
185Each interface structure
186contains an
187.Vt if_data
188structure used for statistics and information.
189Each interface also has a
190.Li TAILQ
191of interface addresses, described by
192.Vt ifaddr
193structures.
194An
195.Dv AF_LINK
196address
197(see
198.Xr link_addr 3 )
199describing the link layer implemented by the interface (if any)
200is accessed by the
201.Fn ifaddr_byindex
202function or
203.Va if_addr
204structure.
205(Some trivial interfaces do not provide any link layer addresses;
206this structure, while still present, serves only to identify the
207interface name and index.)
208.Pp
209Finally, those interfaces supporting reception of multicast datagrams
210have a
211.Li TAILQ
212of multicast group memberships, described by
213.Vt ifmultiaddr
214structures.
215These memberships are reference-counted.
216.Pp
217Interfaces are also associated with an output queue, defined as a
218.Vt "struct ifqueue" ;
219this structure is used to hold packets while the interface is in the
220process of sending another.
221.Ss The ifnet Structure
222The fields of
223.Vt "struct ifnet"
224are as follows:
225.Bl -tag -width ".Va if_capabilities" -offset indent
226.It Va if_softc
227.Pq Vt "void *"
228A pointer to the driver's private state block.
229(Initialized by driver.)
230.It Va if_l2com
231.Pq Vt "void *"
232A pointer to the common data for the interface's layer 2 protocol.
233(Initialized by
234.Fn if_alloc . )
235.It Va if_vnet
236.Pq Vt "struct vnet *"
237A pointer to the virtual network stack instance.
238(Initialized by
239.Fn if_attach . )
240.It Va if_home_vnet
241.Pq Vt "struct vnet *"
242A pointer to the parent virtual network stack, where this
243.Vt "struct ifnet"
244originates from.
245(Initialized by
246.Fn if_attach . )
247.It Va if_link
248.Pq Fn TAILQ_ENTRY ifnet
249.Xr queue 3
250macro glue.
251.It Va if_xname
252.Pq Vt "char *"
253The name of the interface,
254(e.g.,
255.Dq Li fxp0
256or
257.Dq Li lo0 ) .
258(Initialized by driver
259(usually via
260.Fn if_initname ) . )
261.It Va if_dname
262.Pq Vt "const char *"
263The name of the driver.
264(Initialized by driver
265(usually via
266.Fn if_initname ) . )
267.It Va if_dunit
268.Pq Vt int
269A unique number assigned to each interface managed by a particular
270driver.
271Drivers may choose to set this to
272.Dv IF_DUNIT_NONE
273if a unit number is not associated with the device.
274(Initialized by driver
275(usually via
276.Fn if_initname ) . )
277.It Va if_refcount
278.Pq Vt u_int
279The reference count.
280(Initialized by
281.Fn if_alloc . )
282.It Va if_addrhead
283.Pq Vt "struct ifaddrhead"
284The head of the
285.Xr queue 3
286.Li TAILQ
287containing the list of addresses assigned to this interface.
288.It Va if_pcount
289.Pq Vt int
290A count of promiscuous listeners on this interface, used to
291reference-count the
292.Dv IFF_PROMISC
293flag.
294.It Va if_carp
295.Pq Vt "struct carp_if *"
296A pointer to the CARP interface structure,
297.Xr carp 4 .
298(Initialized by the driver-specific
299.Fn if_ioctl
300routine.)
301.It Va if_bpf
302.Pq Vt "struct bpf_if *"
303Opaque per-interface data for the packet filter,
304.Xr bpf 4 .
305(Initialized by
306.Fn bpf_attach . )
307.It Va if_index
308.Pq Vt u_short
309A unique number assigned to each interface in sequence as it is
310attached.
311This number can be used in a
312.Vt "struct sockaddr_dl"
313to refer to a particular interface by index
314(see
315.Xr link_addr 3 ) .
316(Initialized by
317.Fn if_alloc . )
318.It Va if_vlantrunk
319.Pq Vt struct ifvlantrunk *
320A pointer to 802.1Q trunk structure,
321.Xr vlan 4 .
322(Initialized by the driver-specific
323.Fn if_ioctl
324routine.)
325.It Va if_flags
326.Pq Vt int
327Flags describing operational parameters of this interface (see below).
328(Manipulated by generic code.)
329.It Va if_drv_flags
330.Pq Vt int
331Flags describing operational status of this interface (see below).
332(Manipulated by driver.)
333.It Va if_capabilities
334.Pq Vt int
335Flags describing the capabilities the interface supports (see below).
336.It Va if_capenable
337.Pq Vt int
338Flags describing the enabled capabilities of the interface (see below).
339.It Va if_linkmib
340.Pq Vt "void *"
341A pointer to an interface-specific MIB structure exported by
342.Xr ifmib 4 .
343(Initialized by driver.)
344.It Va if_linkmiblen
345.Pq Vt size_t
346The size of said structure.
347(Initialized by driver.)
348.It Va if_data
349.Pq Vt "struct if_data"
350More statistics and information; see
351.Sx "The if_data structure" ,
352below.
353(Initialized by driver, manipulated by both driver and generic
354code.)
355.It Va if_multiaddrs
356.Pq Vt struct ifmultihead
357The head of the
358.Xr queue 3
359.Li TAILQ
360containing the list of multicast addresses assigned to this interface.
361.It Va if_amcount
362.Pq Vt int
363A number of multicast requests on this interface, used to
364reference-count the
365.Dv IFF_ALLMULTI
366flag.
367.It Va if_addr
368.Pq Vt "struct ifaddr *"
369A pointer to the link-level interface address.
370(Initialized by
371.Fn if_alloc . )
372.\" .It Va if_llsoftc
373.\" .Pq Vt "void *"
374.\" The purpose of the field is unclear.
375.It Va if_snd
376.Pq Vt "struct ifaltq"
377The output queue.
378(Manipulated by driver.)
379.It Va if_broadcastaddr
380.Pq Vt "const u_int8_t *"
381A link-level broadcast bytestring for protocols with variable address
382length.
383.It Va if_bridge
384.Pq Vt "void *"
385A pointer to the bridge interface structure,
386.Xr if_bridge 4 .
387(Initialized by the driver-specific
388.Fn if_ioctl
389routine.)
390.It Va if_label
391.Pq Vt "struct label *"
392A pointer to the MAC Framework label structure,
393.Xr mac 4 .
394(Initialized by
395.Fn if_alloc . )
396.It Va if_afdata
397.Pq Vt "void *"
398An address family dependent data region.
399.It Va if_afdata_initialized
400.Pq Vt int
401Used to track the current state of address family initialization.
402.It Va if_afdata_lock
403.Pq Vt "struct rwlock"
404An
405.Xr rwlock 9
406lock used to protect
407.Va if_afdata
408internals.
409.It Va if_linktask
410.Pq Vt "struct task"
411A
412.Xr taskqueue 9
413task scheduled for link state change events of the interface.
414.It Va if_addr_lock
415.Pq Vt "struct rwlock"
416An
417.Xr rwlock 9
418lock used to protect interface-related address lists.
419.It Va if_clones
420.Pq Fn LIST_ENTRY ifnet
421.Xr queue 3
422macro glue for the list of clonable network interfaces.
423.It Va if_groups
424.Pq Fn TAILQ_HEAD "" "ifg_list"
425The head of the
426.Xr queue 3
427.Li TAILQ
428containing the list of groups per interface.
429.It Va if_pf_kif
430.Pq Vt "void *"
431A pointer to the structure used for interface abstraction by
432.Xr pf 4 .
433.It Va if_lagg
434.Pq Vt "void *"
435A pointer to the
436.Xr lagg 4
437interface structure.
438.It Va if_alloctype
439.Pq Vt u_char
440The type of the interface as it was at the time of its allocation.
441It is used to cache the type passed to
442.Fn if_alloc ,
443but unlike
444.Va if_type ,
445it would not be changed by drivers.
446.It Va if_numa_domain
447.Pq Vt uint8_t
448The NUMA domain of the hardware device associated with the interface.
449This is filled in with a wildcard value unless the kernel is NUMA
450aware, the system is a NUMA system, and the ifnet is allocated
451using
452.Fn if_alloc_dev
453or
454.Fn if_alloc_domain .
455.El
456.Pp
457References to
458.Vt ifnet
459structures are gained by calling the
460.Fn if_ref
461function and released by calling the
462.Fn if_rele
463function.
464They are used to allow kernel code walking global interface lists
465to release the
466.Vt ifnet
467lock yet keep the
468.Vt ifnet
469structure stable.
470.Pp
471There are in addition a number of function pointers which the driver
472must initialize to complete its interface with the generic interface
473layer:
474.Bl -ohang -offset indent
475.It Fn if_input
476Pass a packet to an appropriate upper layer as determined
477from the link-layer header of the packet.
478This routine is to be called from an interrupt handler or
479used to emulate reception of a packet on this interface.
480A single function implementing
481.Fn if_input
482can be shared among multiple drivers utilizing the same link-layer
483framing, e.g., Ethernet.
484.It Fn if_output
485Output a packet on interface
486.Fa ifp ,
487or queue it on the output queue if the interface is already active.
488.It Fn if_transmit
489Transmit a packet on an interface or queue it if the interface is
490in use.
491This function will return
492.Dv ENOBUFS
493if the devices software and hardware queues are both full.
494This function must be installed after
495.Fn if_attach
496to override the default implementation.
497This function is exposed in order to allow drivers to manage their own queues
498and to reduce the latency caused by a frequently gratuitous enqueue / dequeue
499pair to ifq.
500The suggested internal software queuing mechanism is buf_ring.
501.It Fn if_qflush
502Free mbufs in internally managed queues when the interface is marked down.
503This function must be installed after
504.Fn if_attach
505to override the default implementation.
506This function is exposed in order to allow drivers to manage their own queues
507and to reduce the latency caused by a frequently gratuitous enqueue / dequeue
508pair to ifq.
509The suggested internal software queuing mechanism is buf_ring.
510.It Fn if_start
511Start queued output on an interface.
512This function is exposed in
513order to provide for some interface classes to share a
514.Fn if_output
515among all drivers.
516.Fn if_start
517may only be called when the
518.Dv IFF_DRV_OACTIVE
519flag is not set.
520(Thus,
521.Dv IFF_DRV_OACTIVE
522does not literally mean that output is active, but rather that the
523device's internal output queue is full.) Please note that this function
524will soon be deprecated.
525.It Fn if_ioctl
526Process interface-related
527.Xr ioctl 2
528requests
529(defined in
530.In sys/sockio.h ) .
531Preliminary processing is done by the generic routine
532.Fn ifioctl
533to check for appropriate privileges, locate the interface being
534manipulated, and perform certain generic operations like twiddling
535flags and flushing queues.
536See the description of
537.Fn ifioctl
538below for more information.
539.It Fn if_init
540Initialize and bring up the hardware,
541e.g., reset the chip and enable the receiver unit.
542Should mark the interface running,
543but not active
544.Dv ( IFF_DRV_RUNNING , ~IIF_DRV_OACTIVE ) .
545.It Fn if_resolvemulti
546Check the requested multicast group membership,
547.Fa addr ,
548for validity, and if necessary compute a link-layer group which
549corresponds to that address which is returned in
550.Fa *retsa .
551Returns zero on success, or an error code on failure.
552.El
553.Ss "Interface Flags"
554Interface flags are used for a number of different purposes.
555Some
556flags simply indicate information about the type of interface and its
557capabilities; others are dynamically manipulated to reflect the
558current state of the interface.
559Flags of the former kind are marked
560.Aq S
561in this table; the latter are marked
562.Aq D .
563Flags which begin with
564.Dq IFF_DRV_
565are stored in
566.Va if_drv_flags ;
567all other flags are stored in
568.Va if_flags .
569.Pp
570The macro
571.Dv IFF_CANTCHANGE
572defines the bits which cannot be set by a user program using the
573.Dv SIOCSIFFLAGS
574command to
575.Xr ioctl 2 ;
576these are indicated by an asterisk
577.Pq Ql *
578in the following listing.
579.Pp
580.Bl -tag -width ".Dv IFF_POINTOPOINT" -offset indent -compact
581.It Dv IFF_UP
582.Aq D
583The interface has been configured up by the user-level code.
584.It Dv IFF_BROADCAST
585.Aq S*
586The interface supports broadcast.
587.It Dv IFF_DEBUG
588.Aq D
589Used to enable/disable driver debugging code.
590.It Dv IFF_LOOPBACK
591.Aq S
592The interface is a loopback device.
593.It Dv IFF_POINTOPOINT
594.Aq S*
595The interface is point-to-point;
596.Dq broadcast
597address is actually the address of the other end.
598.It Dv IFF_DRV_RUNNING
599.Aq D*
600The interface has been configured and dynamic resources were
601successfully allocated.
602Probably only useful internal to the
603interface.
604.It Dv IFF_NOARP
605.Aq D
606Disable network address resolution on this interface.
607.It Dv IFF_PROMISC
608.Aq D*
609This interface is in promiscuous mode.
610.It Dv IFF_PPROMISC
611.Aq D
612This interface is in the permanently promiscuous mode (implies
613.Dv IFF_PROMISC ) .
614.It Dv IFF_ALLMULTI
615.Aq D*
616This interface is in all-multicasts mode (used by multicast routers).
617.It Dv IFF_DRV_OACTIVE
618.Aq D*
619The interface's hardware output queue (if any) is full; output packets
620are to be queued.
621.It Dv IFF_SIMPLEX
622.Aq S*
623The interface cannot hear its own transmissions.
624.It Dv IFF_LINK0
625.It Dv IFF_LINK1
626.It Dv IFF_LINK2
627.Aq D
628Control flags for the link layer.
629(Currently abused to select among
630multiple physical layers on some devices.)
631.It Dv IFF_MULTICAST
632.Aq S*
633This interface supports multicast.
634.It Dv IFF_CANTCONFIG
635.Aq S*
636The interface is not configurable in a meaningful way.
637Primarily useful for
638.Dv IFT_USB
639interfaces registered at the interface list.
640.It Dv IFF_MONITOR
641.Aq D
642This interface blocks transmission of packets and discards incoming
643packets after BPF processing.
644Used to monitor network traffic but not interact
645with the network in question.
646.It Dv IFF_STATICARP
647.Aq D
648Used to enable/disable ARP requests on this interface.
649.It Dv IFF_DYING
650.Aq D*
651Set when the
652.Vt ifnet
653structure of this interface is being released and still has
654.Va if_refcount
655references.
656.It Dv IFF_RENAMING
657.Aq D
658Set when this interface is being renamed.
659.El
660.Ss "Interface Capabilities Flags"
661Interface capabilities are specialized features an interface may
662or may not support.
663These capabilities are very hardware-specific
664and allow, when enabled,
665to offload specific network processing to the interface
666or to offer a particular feature for use by other kernel parts.
667.Pp
668It should be stressed that a capability can be completely
669uncontrolled (i.e., stay always enabled with no way to disable it)
670or allow limited control over itself (e.g., depend on another
671capability's state.)
672Such peculiarities are determined solely by the hardware and driver
673of a particular interface.
674Only the driver possesses
675the knowledge on whether and how the interface capabilities
676can be controlled.
677Consequently, capabilities flags in
678.Va if_capenable
679should never be modified directly by kernel code other than
680the interface driver.
681The command
682.Dv SIOCSIFCAP
683to
684.Fn ifioctl
685is the dedicated means to attempt altering
686.Va if_capenable
687on an interface.
688Userland code shall use
689.Xr ioctl 2 .
690.Pp
691The following capabilities are currently supported by the system:
692.Bl -tag -width ".Dv IFCAP_VLAN_HWTAGGING" -offset indent
693.It Dv IFCAP_RXCSUM
694This interface can do checksum validation on receiving data.
695Some interfaces do not have sufficient buffer storage to store frames
696above a certain MTU-size completely.
697The driver for the interface might disable hardware checksum validation
698if the MTU is set above the hardcoded limit.
699.It Dv IFCAP_TXCSUM
700This interface can do checksum calculation on transmitting data.
701.It Dv IFCAP_HWCSUM
702A shorthand for
703.Pq Dv IFCAP_RXCSUM | IFCAP_TXCSUM .
704.It Dv IFCAP_NETCONS
705This interface can be a network console.
706.It Dv IFCAP_VLAN_MTU
707The
708.Xr vlan 4
709driver can operate over this interface in software tagging mode
710without having to decrease MTU on
711.Xr vlan 4
712interfaces below 1500 bytes.
713This implies the ability of this interface to cope with frames somewhat
714longer than permitted by the Ethernet specification.
715.It Dv IFCAP_VLAN_HWTAGGING
716This interface can do VLAN tagging on output and
717demultiplex frames by their VLAN tag on input.
718.It Dv IFCAP_JUMBO_MTU
719This Ethernet interface can transmit and receive frames up to
7209000 bytes long.
721.It Dv IFCAP_POLLING
722This interface supports
723.Xr polling 4 .
724See below for details.
725.It Dv IFCAP_VLAN_HWCSUM
726This interface can do checksum calculation on both transmitting
727and receiving data on
728.Xr vlan 4
729interfaces (implies
730.Dv IFCAP_HWCSUM ) .
731.It Dv IFCAP_TSO4
732This Ethernet interface supports TCP4 Segmentation offloading.
733.It Dv IFCAP_TSO6
734This Ethernet interface supports TCP6 Segmentation offloading.
735.It Dv IFCAP_TSO
736A shorthand for
737.Pq Dv IFCAP_TSO4 | IFCAP_TSO6 .
738.It Dv IFCAP_TOE4
739This Ethernet interface supports TCP offloading.
740.It Dv IFCAP_TOE6
741This Ethernet interface supports TCP6 offloading.
742.It Dv IFCAP_TOE
743A shorthand for
744.Pq Dv IFCAP_TOE4 | IFCAP_TOE6 .
745.It Dv IFCAP_WOL_UCAST
746This Ethernet interface supports waking up on any Unicast packet.
747.It Dv IFCAP_WOL_MCAST
748This Ethernet interface supports waking up on any Multicast packet.
749.It Dv IFCAP_WOL_MAGIC
750This Ethernet interface supports waking up on any Magic packet such
751as those sent by
752.Xr wake 8 .
753.It Dv IFCAP_WOL
754A shorthand for
755.Pq Dv IFCAP_WOL_UCAST | IFCAP_WOL_MCAST | IFCAP_WOL_MAGIC .
756.It Dv IFCAP_TOE4
757This Ethernet interface supports TCP4 Offload Engine.
758.It Dv IFCAP_TOE6
759This Ethernet interface supports TCP6 Offload Engine.
760.It Dv IFCAP_TOE
761A shorthand for
762.Pq Dv IFCAP_TOE4 | IFCAP_TOE6 .
763.It Dv IFCAP_VLAN_HWFILTER
764This interface supports frame filtering in hardware on
765.Xr vlan 4
766interfaces.
767.It Dv IFCAP_VLAN_HWTSO
768This interface supports TCP Segmentation offloading on
769.Xr vlan 4
770interfaces (implies
771.Dv IFCAP_TSO ) .
772.It Dv IFCAP_LINKSTATE
773This Ethernet interface supports dynamic link state changes.
774.It Dv IFCAP_NETMAP
775This Ethernet interface supports
776.Xr netmap  4 .
777.El
778.Pp
779The ability of advanced network interfaces to offload certain
780computational tasks from the host CPU to the board is limited
781mostly to TCP/IP.
782Therefore a separate field associated with an interface
783(see
784.Va ifnet.if_data.ifi_hwassist
785below)
786keeps a detailed description of its enabled capabilities
787specific to TCP/IP processing.
788The TCP/IP module consults the field to see which tasks
789can be done on an
790.Em outgoing
791packet by the interface.
792The flags defined for that field are a superset of those for
793.Va mbuf.m_pkthdr.csum_flags ,
794namely:
795.Bl -tag -width ".Dv CSUM_FRAGMENT" -offset indent
796.It Dv CSUM_IP
797The interface will compute IP checksums.
798.It Dv CSUM_TCP
799The interface will compute TCP checksums.
800.It Dv CSUM_UDP
801The interface will compute UDP checksums.
802.El
803.Pp
804An interface notifies the TCP/IP module about the tasks
805the former has performed on an
806.Em incoming
807packet by setting the corresponding flags in the field
808.Va mbuf.m_pkthdr.csum_flags
809of the
810.Vt mbuf chain
811containing the packet.
812See
813.Xr mbuf 9
814for details.
815.Pp
816The capability of a network interface to operate in
817.Xr polling 4
818mode involves several flags in different
819global variables and per-interface fields.
820The capability flag
821.Dv IFCAP_POLLING
822set in interface's
823.Va if_capabilities
824indicates support for
825.Xr polling 4
826on the particular interface.
827If set in
828.Va if_capabilities ,
829the same flag can be marked or cleared in the interface's
830.Va if_capenable
831within
832.Fn ifioctl ,
833thus initiating switch of the interface to
834.Xr polling 4
835mode or interrupt
836mode, respectively.
837The actual mode change is managed by the driver-specific
838.Fn if_ioctl
839routine.
840The
841.Xr polling 4
842handler returns the number of packets processed.
843.Ss The if_data Structure
844The
845.Vt if_data
846structure contains statistics and identifying information used
847by management programs, and which is exported to user programs by way
848of the
849.Xr ifmib 4
850branch of the
851.Xr sysctl 3
852MIB.
853The following elements of the
854.Vt if_data
855structure are initialized by the interface and are not expected to change
856significantly over the course of normal operation:
857.Bl -tag -width ".Va ifi_lastchange" -offset indent
858.It Va ifi_type
859.Pq Vt u_char
860The type of the interface, as defined in
861.In net/if_types.h
862and described below in the
863.Sx "Interface Types"
864section.
865.It Va ifi_physical
866.Pq Vt u_char
867Intended to represent a selection of physical layers on devices which
868support more than one; never implemented.
869.It Va ifi_addrlen
870.Pq Vt u_char
871Length of a link-layer address on this device, or zero if there are
872none.
873Used to initialized the address length field in
874.Vt sockaddr_dl
875structures referring to this interface.
876.It Va ifi_hdrlen
877.Pq Vt u_char
878Maximum length of any link-layer header which might be prepended by
879the driver to a packet before transmission.
880The generic code computes
881the maximum over all interfaces and uses that value to influence the
882placement of data in
883.Vt mbuf Ns s
884to attempt to ensure that there is always
885sufficient space to prepend a link-layer header without allocating an
886additional
887.Vt mbuf .
888.It Va ifi_datalen
889.Pq Vt u_char
890Length of the
891.Vt if_data
892structure.
893Allows some stabilization of the routing socket ABI in the face of
894increases in the length of
895.Vt struct ifdata .
896.It Va ifi_mtu
897.Pq Vt u_long
898The maximum transmission unit of the medium, exclusive of any
899link-layer overhead.
900.It Va ifi_metric
901.Pq Vt u_long
902A dimensionless metric interpreted by a user-mode routing process.
903.It Va ifi_baudrate
904.Pq Vt u_long
905The line rate of the interface, in bits per second.
906.It Va ifi_hwassist
907.Pq Vt u_long
908A detailed interpretation of the capabilities
909to offload computational tasks for
910.Em outgoing
911packets.
912The interface driver must keep this field in accord with
913the current value of
914.Va if_capenable .
915.It Va ifi_epoch
916.Pq Vt time_t
917The system uptime when interface was attached or the statistics
918below were reset.
919This is intended to be used to set the SNMP variable
920.Va ifCounterDiscontinuityTime .
921It may also be used to determine if two successive queries for an
922interface of the same index have returned results for the same
923interface.
924.El
925.Pp
926The structure additionally contains generic statistics applicable to a
927variety of different interface types (except as noted, all members are
928of type
929.Vt u_long ) :
930.Bl -tag -width ".Va ifi_lastchange" -offset indent
931.It Va ifi_link_state
932.Pq Vt u_char
933The current link state of Ethernet interfaces.
934See the
935.Sx Interface Link States
936section for possible values.
937.It Va ifi_ipackets
938Number of packets received.
939.It Va ifi_ierrors
940Number of receive errors detected (e.g., FCS errors, DMA overruns,
941etc.).
942More detailed breakdowns can often be had by way of a
943link-specific MIB.
944.It Va ifi_opackets
945Number of packets transmitted.
946.It Va ifi_oerrors
947Number of output errors detected (e.g., late collisions, DMA overruns,
948etc.).
949More detailed breakdowns can often be had by way of a
950link-specific MIB.
951.It Va ifi_collisions
952Total number of collisions detected on output for CSMA interfaces.
953(This member is sometimes [ab]used by other types of interfaces for
954other output error counts.)
955.It Va ifi_ibytes
956Total traffic received, in bytes.
957.It Va ifi_obytes
958Total traffic transmitted, in bytes.
959.It Va ifi_imcasts
960Number of packets received which were sent by link-layer multicast.
961.It Va ifi_omcasts
962Number of packets sent by link-layer multicast.
963.It Va ifi_iqdrops
964Number of packets dropped on input.
965Rarely implemented.
966.It Va ifi_oqdrops
967Number of packets dropped on output.
968.It Va ifi_noproto
969Number of packets received for unknown network-layer protocol.
970.It Va ifi_lastchange
971.Pq Vt "struct timeval"
972The time of the last administrative change to the interface (as required
973for
974.Tn SNMP ) .
975.El
976.Ss Interface Types
977The header file
978.In net/if_types.h
979defines symbolic constants for a number of different types of
980interfaces.
981The most common are:
982.Pp
983.Bl -tag -offset indent -width ".Dv IFT_PROPVIRTUAL" -compact
984.It Dv IFT_OTHER
985none of the following
986.It Dv IFT_ETHER
987Ethernet
988.It Dv IFT_ISO88023
989ISO 8802-3 CSMA/CD
990.It Dv IFT_ISO88024
991ISO 8802-4 Token Bus
992.It Dv IFT_ISO88025
993ISO 8802-5 Token Ring
994.It Dv IFT_ISO88026
995ISO 8802-6 DQDB MAN
996.It Dv IFT_FDDI
997FDDI
998.It Dv IFT_PPP
999Internet Point-to-Point Protocol
1000.Pq Xr ppp 8
1001.It Dv IFT_LOOP
1002The loopback
1003.Pq Xr lo 4
1004interface
1005.It Dv IFT_SLIP
1006Serial Line IP
1007.It Dv IFT_PARA
1008Parallel-port IP
1009.Pq Dq Tn PLIP
1010.It Dv IFT_ATM
1011Asynchronous Transfer Mode
1012.It Dv IFT_USB
1013USB Interface
1014.El
1015.Ss Interface Link States
1016The following link states are currently defined:
1017.Pp
1018.Bl -tag -offset indent -width ".Dv LINK_STATE_UNKNOWN" -compact
1019.It Dv LINK_STATE_UNKNOWN
1020The link is in an invalid or unknown state.
1021.It Dv LINK_STATE_DOWN
1022The link is down.
1023.It Dv LINK_STATE_UP
1024The link is up.
1025.El
1026.Ss The ifaddr Structure
1027Every interface is associated with a list
1028(or, rather, a
1029.Li TAILQ )
1030of addresses, rooted at the interface structure's
1031.Va if_addrhead
1032member.
1033The first element in this list is always an
1034.Dv AF_LINK
1035address representing the interface itself; multi-access network
1036drivers should complete this structure by filling in their link-layer
1037addresses after calling
1038.Fn if_attach .
1039Other members of the structure represent network-layer addresses which
1040have been configured by means of the
1041.Dv SIOCAIFADDR
1042command to
1043.Xr ioctl 2 ,
1044called on a socket of the appropriate protocol family.
1045The elements of this list consist of
1046.Vt ifaddr
1047structures.
1048Most protocols will declare their own protocol-specific
1049interface address structures, but all begin with a
1050.Vt "struct ifaddr"
1051which provides the most-commonly-needed functionality across all
1052protocols.
1053Interface addresses are reference-counted.
1054.Pp
1055The members of
1056.Vt "struct ifaddr"
1057are as follows:
1058.Bl -tag -width ".Va ifa_rtrequest" -offset indent
1059.It Va ifa_addr
1060.Pq Vt "struct sockaddr *"
1061The local address of the interface.
1062.It Va ifa_dstaddr
1063.Pq Vt "struct sockaddr *"
1064The remote address of point-to-point interfaces, and the broadcast
1065address of broadcast interfaces.
1066.Va ( ifa_broadaddr
1067is a macro for
1068.Va ifa_dstaddr . )
1069.It Va ifa_netmask
1070.Pq Vt "struct sockaddr *"
1071The network mask for multi-access interfaces, and the confusion
1072generator for point-to-point interfaces.
1073.It Va ifa_ifp
1074.Pq Vt "struct ifnet *"
1075A link back to the interface structure.
1076.It Va ifa_link
1077.Pq Fn TAILQ_ENTRY ifaddr
1078.Xr queue 3
1079glue for list of addresses on each interface.
1080.It Va ifa_rtrequest
1081See below.
1082.It Va ifa_flags
1083.Pq Vt u_short
1084Some of the flags which would be used for a route representing this
1085address in the route table.
1086.It Va ifa_refcnt
1087.Pq Vt short
1088The reference count.
1089.El
1090.Pp
1091References to
1092.Vt ifaddr
1093structures are gained by calling the
1094.Fn ifa_ref
1095function and released by calling the
1096.Fn ifa_free
1097function.
1098.Pp
1099.Fn ifa_rtrequest
1100is a pointer to a function which receives callouts from the routing
1101code
1102.Pq Fn rtrequest
1103to perform link-layer-specific actions upon requests to add,
1104or delete routes.
1105The
1106.Fa cmd
1107argument indicates the request in question:
1108.Dv RTM_ADD ,
1109or
1110.Dv RTM_DELETE .
1111The
1112.Fa rt
1113argument is the route in question; the
1114.Fa info
1115argument contains the specific destination being manipulated.
1116.Sh FUNCTIONS
1117The functions provided by the generic interface code can be divided
1118into two groups: those which manipulate interfaces, and those which
1119manipulate interface addresses.
1120In addition to these functions, there
1121may also be link-layer support routines which are used by a number of
1122drivers implementing a specific link layer over different hardware;
1123see the documentation for that link layer for more details.
1124.Ss The ifmultiaddr Structure
1125Every multicast-capable interface is associated with a list of
1126multicast group memberships, which indicate at a low level which
1127link-layer multicast addresses (if any) should be accepted, and at a
1128high level, in which network-layer multicast groups a user process has
1129expressed interest.
1130.Pp
1131The elements of the structure are as follows:
1132.Bl -tag -width ".Va ifma_refcount" -offset indent
1133.It Va ifma_link
1134.Pq Fn LIST_ENTRY ifmultiaddr
1135.Xr queue 3
1136macro glue.
1137.It Va ifma_addr
1138.Pq Vt "struct sockaddr *"
1139A pointer to the address which this record represents.
1140The
1141memberships for various address families are stored in arbitrary
1142order.
1143.It Va ifma_lladdr
1144.Pq Vt "struct sockaddr *"
1145A pointer to the link-layer multicast address, if any, to which the
1146network-layer multicast address in
1147.Va ifma_addr
1148is mapped, else a null pointer.
1149If this element is non-nil, this
1150membership also holds an invisible reference to another membership for
1151that link-layer address.
1152.It Va ifma_refcount
1153.Pq Vt u_int
1154A reference count of requests for this particular membership.
1155.El
1156.Ss Interface Manipulation Functions
1157.Bl -ohang -offset indent
1158.It Fn if_alloc
1159Allocate and initialize
1160.Vt "struct ifnet" .
1161Initialization includes the allocation of an interface index and may
1162include the allocation of a
1163.Fa type
1164specific structure in
1165.Va if_l2com .
1166.It Fn if_alloc_dev
1167Allocate and initialize
1168.Vt "struct ifnet"
1169as
1170.Fn if_alloc
1171does, with the addition that the ifnet can be tagged with the
1172appropriate NUMA domain derived from the
1173.Fa dev
1174argument passed by the caller.
1175.It Fn if_alloc_domain
1176Allocate and initialize
1177.Vt "struct ifnet"
1178as
1179.Fn if_alloc
1180does, with the addition that the ifnet will be tagged with the NUMA
1181domain via the
1182.Fa numa_domain
1183argument passed by the caller.
1184.It Fn if_attach
1185Link the specified interface
1186.Fa ifp
1187into the list of network interfaces.
1188Also initialize the list of
1189addresses on that interface, and create a link-layer
1190.Vt ifaddr
1191structure to be the first element in that list.
1192(A pointer to
1193this address structure is saved in the
1194.Vt ifnet
1195structure and is accessed by the
1196.Fn ifaddr_byindex
1197function.)
1198The
1199.Fa ifp
1200must have been allocated by
1201.Fn if_alloc ,
1202.Fn if_alloc_dev
1203or
1204.Fn if_alloc_domain .
1205.It Fn if_detach
1206Shut down and unlink the specified
1207.Fa ifp
1208from the interface list.
1209.It Fn if_free
1210Free the given
1211.Fa ifp
1212back to the system.
1213The interface must have been previously detached if it was ever attached.
1214.It Fn if_free_type
1215Identical to
1216.Fn if_free
1217except that the given
1218.Fa type
1219is used to free
1220.Va if_l2com
1221instead of the type in
1222.Va if_type .
1223This is intended for use with drivers that change their interface type.
1224.It Fn if_down
1225Mark the interface
1226.Fa ifp
1227as down (i.e.,
1228.Dv IFF_UP
1229is not set),
1230flush its output queue, notify protocols of the transition,
1231and generate a message from the
1232.Xr route 4
1233routing socket.
1234.It Fn if_up
1235Mark the interface
1236.Fa ifp
1237as up, notify protocols of the transition,
1238and generate a message from the
1239.Xr route 4
1240routing socket.
1241.It Fn ifpromisc
1242Add or remove a promiscuous reference to
1243.Fa ifp .
1244If
1245.Fa pswitch
1246is true, add a reference;
1247if it is false, remove a reference.
1248On reference count transitions
1249from zero to one and one to zero, set the
1250.Dv IFF_PROMISC
1251flag appropriately and call
1252.Fn if_ioctl
1253to set up the interface in the desired mode.
1254.It Fn if_allmulti
1255As
1256.Fn ifpromisc ,
1257but for the all-multicasts
1258.Pq Dv IFF_ALLMULTI
1259flag instead of the promiscuous flag.
1260.It Fn ifunit
1261Return an
1262.Vt ifnet
1263pointer for the interface named
1264.Fa name .
1265.It Fn ifunit_ref
1266Return a reference-counted (via
1267.Fn ifa_ref )
1268.Vt ifnet
1269pointer for the interface named
1270.Fa name .
1271This is the preferred function over
1272.Fn ifunit .
1273The caller is responsible for releasing the reference with
1274.Fn if_rele
1275when it is finished with the ifnet.
1276.It Fn ifioctl
1277Process the ioctl request
1278.Fa cmd ,
1279issued on socket
1280.Fa so
1281by thread
1282.Fa td ,
1283with data parameter
1284.Fa data .
1285This is the main routine for handling all interface configuration
1286requests from user mode.
1287It is ordinarily only called from the socket-layer
1288.Xr ioctl 2
1289handler, and only for commands with class
1290.Sq Li i .
1291Any unrecognized commands will be passed down to socket
1292.Fa so Ns 's
1293protocol for
1294further interpretation.
1295The following commands are handled by
1296.Fn ifioctl :
1297.Pp
1298.Bl -tag -width ".Dv SIOCGIFNETMASK" -offset indent -compact
1299.It Dv SIOCGIFCONF
1300Get interface configuration.
1301(No call-down to driver.)
1302.Pp
1303.It Dv SIOCSIFNAME
1304Set the interface name.
1305.Dv RTM_IFANNOUNCE
1306departure and arrival messages are sent so that
1307routing code that relies on the interface name will update its interface
1308list.
1309Caller must have appropriate privilege.
1310(No call-down to driver.)
1311.It Dv SIOCGIFCAP
1312.It Dv SIOCGIFDATA
1313.It Dv SIOCGIFFIB
1314.It Dv SIOCGIFFLAGS
1315.It Dv SIOCGIFMETRIC
1316.It Dv SIOCGIFMTU
1317.It Dv SIOCGIFPHYS
1318Get interface capabilities, data, FIB, flags, metric, MTU, medium selection.
1319(No call-down to driver.)
1320.Pp
1321.It Dv SIOCSIFCAP
1322Enable or disable interface capabilities.
1323Caller must have appropriate privilege.
1324Before a call to the driver-specific
1325.Fn if_ioctl
1326routine, the requested mask for enabled capabilities is checked
1327against the mask of capabilities supported by the interface,
1328.Va if_capabilities .
1329Requesting to enable an unsupported capability is invalid.
1330The rest is supposed to be done by the driver,
1331which includes updating
1332.Va if_capenable
1333and
1334.Va if_data.ifi_hwassist
1335appropriately.
1336.Pp
1337.It Dv SIOCSIFFIB
1338Sets interface FIB.
1339Caller must have appropriate privilege.
1340FIB values start at 0 and values greater or equals than
1341.Va net.fibs
1342are considered invalid.
1343.It Dv SIOCSIFFLAGS
1344Change interface flags.
1345Caller must have appropriate privilege.
1346If a change to the
1347.Dv IFF_UP
1348flag is requested,
1349.Fn if_up
1350or
1351.Fn if_down
1352is called as appropriate.
1353Flags listed in
1354.Dv IFF_CANTCHANGE
1355are masked off, and the field
1356.Va if_flags
1357in the interface structure is updated.
1358Finally, the driver
1359.Fn if_ioctl
1360routine is called to perform any setup
1361requested.
1362.Pp
1363.It Dv SIOCSIFMETRIC
1364.It Dv SIOCSIFPHYS
1365Change interface metric or medium.
1366Caller must have appropriate privilege.
1367.Pp
1368.It Dv SIOCSIFMTU
1369Change interface MTU.
1370Caller must have appropriate privilege.
1371MTU
1372values less than 72 or greater than 65535 are considered invalid.
1373The driver
1374.Fn if_ioctl
1375routine is called to implement the change; it is responsible for any
1376additional sanity checking and for actually modifying the MTU in the
1377interface structure.
1378.Pp
1379.It Dv SIOCADDMULTI
1380.It Dv SIOCDELMULTI
1381Add or delete permanent multicast group memberships on the interface.
1382Caller must have appropriate privilege.
1383The
1384.Fn if_addmulti
1385or
1386.Fn if_delmulti
1387function is called to perform the operation; qq.v.
1388.Pp
1389.It Dv SIOCAIFADDR
1390.It Dv SIOCDIFADDR
1391The socket's protocol control routine is called to implement the
1392requested action.
1393.El
1394.El
1395.Ss "Interface Address Functions"
1396Several functions exist to look up an interface address structure
1397given an address.
1398.Fn ifa_ifwithaddr
1399returns an interface address with either a local address or a
1400broadcast address precisely matching the parameter
1401.Fa addr .
1402.Fn ifa_ifwithdstaddr
1403returns an interface address for a point-to-point interface whose
1404remote
1405.Pq Dq destination
1406address is
1407.Fa addr
1408and a fib is
1409.Fa fib .
1410If
1411.Fa fib
1412is
1413.Dv RT_ALL_FIBS ,
1414then the first interface address matching
1415.Fa addr
1416will be returned.
1417.Pp
1418.Fn ifa_ifwithnet
1419returns the most specific interface address which matches the
1420specified address,
1421.Fa addr ,
1422subject to its configured netmask, or a point-to-point interface
1423address whose remote address is
1424.Fa addr
1425if one is found.
1426If
1427.Fa ignore_ptp
1428is true, skip point-to-point interface addresses.
1429The
1430.Fa fib
1431parameter is handled the same way as by
1432.Fn ifa_ifwithdstaddr .
1433.Pp
1434.Fn ifaof_ifpforaddr
1435returns the most specific address configured on interface
1436.Fa ifp
1437which matches address
1438.Fa addr ,
1439subject to its configured netmask.
1440If the interface is
1441point-to-point, only an interface address whose remote address is
1442precisely
1443.Fa addr
1444will be returned.
1445.Pp
1446.Fn ifaddr_byindex
1447returns the link-level address of the interface with the given index
1448.Fa idx .
1449.Pp
1450All of these functions return a null pointer if no such address can be
1451found.
1452.Ss "Interface Multicast Address Functions"
1453The
1454.Fn if_addmulti ,
1455.Fn if_delmulti ,
1456and
1457.Fn if_findmulti
1458functions provide support for requesting and relinquishing multicast
1459group memberships, and for querying an interface's membership list,
1460respectively.
1461The
1462.Fn if_addmulti
1463function takes a pointer to an interface,
1464.Fa ifp ,
1465and a generic address,
1466.Fa sa .
1467It also takes a pointer to a
1468.Vt "struct ifmultiaddr *"
1469which is filled in on successful return with the address of the
1470group membership control block.
1471The
1472.Fn if_addmulti
1473function performs the following four-step process:
1474.Bl -enum -offset indent
1475.It
1476Call the interface's
1477.Fn if_resolvemulti
1478entry point to determine the link-layer address, if any, corresponding
1479to this membership request, and also to give the link layer an
1480opportunity to veto this membership request should it so desire.
1481.It
1482Check the interface's group membership list for a pre-existing
1483membership for this group.
1484If one is not found, allocate a new one;
1485if one is, increment its reference count.
1486.It
1487If the
1488.Fn if_resolvemulti
1489routine returned a link-layer address corresponding to the group,
1490repeat the previous step for that address as well.
1491.It
1492If the interface's multicast address filter needs to be changed
1493because a new membership was added, call the interface's
1494.Fn if_ioctl
1495routine
1496(with a
1497.Fa cmd
1498argument of
1499.Dv SIOCADDMULTI )
1500to request that it do so.
1501.El
1502.Pp
1503The
1504.Fn if_delmulti
1505function, given an interface
1506.Fa ifp
1507and an address,
1508.Fa sa ,
1509reverses this process.
1510Both functions return zero on success, or a
1511standard error number on failure.
1512.Pp
1513The
1514.Fn if_findmulti
1515function examines the membership list of interface
1516.Fa ifp
1517for an address matching
1518.Fa sa ,
1519and returns a pointer to that
1520.Vt "struct ifmultiaddr"
1521if one is found, else it returns a null pointer.
1522.Sh SEE ALSO
1523.Xr ioctl 2 ,
1524.Xr link_addr 3 ,
1525.Xr queue 3 ,
1526.Xr sysctl 3 ,
1527.Xr bpf 4 ,
1528.Xr ifmib 4 ,
1529.Xr lo 4 ,
1530.Xr netintro 4 ,
1531.Xr polling 4 ,
1532.Xr config 8 ,
1533.Xr ppp 8 ,
1534.Xr mbuf 9 ,
1535.Xr rtentry 9
1536.Rs
1537.%A Gary R. Wright
1538.%A W. Richard Stevens
1539.%B TCP/IP Illustrated
1540.%V Vol. 2
1541.%O Addison-Wesley, ISBN 0-201-63354-X
1542.Re
1543.Sh AUTHORS
1544This manual page was written by
1545.An Garrett A. Wollman .
1546