Stack Sharing

Onload User Guide (UG1586)

Document ID
Release Date
1.2 English

By default each process using Onload has its own 'stack'. Refer to Onload Stacks for definition. Several processes can be made to share a single stack, using the EF_NAME environment variable. Processes with the same value for EF_NAME in their environment will share a stack.

Stack sharing is one supported method to enable multiple processes using Onload to be accelerated when receiving the same multicast stream or to allow one application to receive a multicast stream generated locally by a second application. Other methods to achieve this are Multicast Replication and Hardware Multicast Loopback.

Stacks can also be shared by multiple processes to preserve and control resources within the system. Stack sharing can be employed by processes handling TCP as well as UDP sockets.

Note: Onload stacks cannot be shared by different network namespaces.

Stack sharing should only be requested if there is a trust relationship between the processes. If two processes share a stack then they are not completely isolated: a bug in one process can impact the other, or one process can gain access to the privileged information of the other and so breach security. Once the EF_NAME variable is set, any process on the local host can set the same value and gain access to the stack.

By default Onload stacks can only be shared with processes having the same UID. The EF_SHARE_WITH environment variable provides additional security while allowing a different UID to share a stack. Refer to Parameter Reference for a description of the EF_NAME and EF_SHARE_WITH variables.

Processes with different UIDs, sharing an Onload stack cannot use huge pages. Onload will issue a warning at startup and prevent the allocation of huge pages if EF_SHARE_WITH identifies a UID of another process or is set to -1. If a process P1 creates an Onload stack, but is not using huge pages and another process P2 attempts to share the Onload stack by setting EF_NAME, the stack options set by P1 will apply, allocation of huge pages in P2 will be prevented.

To suppress these startup warnings about turning huge pages off, set EF_USE_HUGE_PAGES to 0 if EF_SHARE_WITH is non-zero.

An alternative method of implementing stack sharing is to use the Onload Extensions API and the onload_set_stackname() function which, through its scope parameter, can limit stack access to the processes created by a particular user. Refer to Onload Extensions API for details.