MAC_ALLOC(9F) Kernel Functions for Drivers MAC_ALLOC(9F)

mac_alloc, mac_freeallocate and free mac registration structures

#include <sys/mac_provider.h>

mac_register_t *
mac_alloc(uint_t mac_version);

mac_free(mac_register_t *mregp);

illumos DDI specific

An integer corresponding to the version of the MAC interface that the device driver was built against.
A pointer to an allocated mac_register_t structure that was obtained from calling the () function.

The () and mac_free() routines are used to allocate and free the structures used to register a device driver with mac(9E). The device driver should call mac_alloc() with the value of MAC_VERSION to indicate the current version of the MAC framework that it supports. The device driver will be returned an instance of a mac_register(9S) structure which it can then use to call mac_register(9F). For more information on the order of events, see the Initializing MAC Support section of mac(9E).

When the driver is done with the mac_register(9S) structure, it must call the () function to release any memory associated with the handle.

After the driver has called mac_register(9F) during its attach(9E) entry point, the mac_register(9S) structure is no longer needed and can be freed.

The mac_alloc() and mac_free() routines are generally called from the context of a device driver's attach(9E) entry point; however, they may be called from both and context.

Upon successful completion, the mac_alloc() function will return a pointer to an allocated structure that can be filled in by the driver. Otherwise, NULL is returned to indicate that the structure could not be allocated. The most common cause for this is that the value of mac_version is not supported by the kernel.

attach(9E), mac(9E), mac_register(9F), mac_register(9S)

July 22, 2019 OmniOS