The system compiles the plugin code into a shared library instead of a program. The JUNOS daemon dynamically (at runtime) loads the shared library, allowing the SDK application to plug into it to extend the system's functionality. (It is possible for a plugin on the control plane to register its own events to drive itself.)
The following figure shows plugins in the context of the Services SDK services architecture.
Plugins and the Services Plane
Each service a plugin implements is modular and independent and is defined by a registration entry in the policy database. The registration entry for each service contains the plugin name, the names of its associated control and data event handlers, and an application ID you assign.
The system maintains a table of plugins and assigns a unique plugin ID to each one. A context structure is used to deliver the necessary data required by the plugin handler with each event.
The control portion of the plugin is still optionally part of the shared library; however, the control portion does not plug in in the same sense, because mspmand spawns a new thread to run this component independently. You can also write the control component to run separately, in another daemon, and hence not be compiled into the shared library.
Layers in the SDK Stack
The flow layer contains a control part and a data part. The data part is responsible for classifying packets into flows. The control part is responsible for flow management: aging, timing, counting, and enforcing flows.
When you open a session, you specify a flow type.
A service can choose to maintain its own sessions - that is, it can choose to use packet-based sessions instead of the default flow-based sessions. To do this, your code sets the
MSP_POLICY_FLAGS_SSET_PACKET flag before defining the policy add parameters. (For sample code that updates the policy database, see Attaching to the Policy Database).
The system assigns a new flow type to differentiate sessions that use new flow types from sessions the system creates. All plugins that will share these sessions must know the new type.
INIT_PENDING:A plugin is attempting to add a policy before the service set has been created (the service set is not yet initialized with complete information). The system holds the policy added by the plugin.
POLICY_ADD_PENDING:The service set has been initialized and is waiting for all the services to load their policies.
ACTIVE:The service set has been initialized and all the services have loaded thier policies in the service set.
DEL_PENDING:The service set has received the
SSRB_DELevent, but policies are still attached to the service set. The system starts a timer to ensure that the service set gets deleted in the stipulated time. If the time expires, the service set is deleted.
SSRB_ADD:Occurs when the new service set has been created, or there was a significant change in the configuration of the service set. A configuration change causes the system to delete and add the service set. Plugins and applications are expected to generate a
POLICY_ADDevent whenever they receive an
POLICY_ADD:Occurs when a policy is added by a plugin. This can be before or after the
SSRB_ADDevent is received. It can occur when the new service set is created, or when a new policy has been added to an existing service set.
POLICY_DELETE:Occurs when a policy is deleted by a plugin. This can be before or after the
SSRB_DELETEevent is received. It can occur when the service set is deleted, or when a policy has been deleted from an existing service set.
SSRB_DEL:Occurs when a service set is deleted. Plugins and applications are expected to delete their policies from the service set in the stipulated time whenever they receive an
Initial State External Event New State ================================================================== - SSRB_ ADD POLICY_ADD_PENDING - POLICY_ADD INIT_PENDING INIT_PENDING SSRB_ADD POLICY_ADD_PENDING/ACTIVE POLICY_ADD_PENDING POLICY_ADD ACTIVE ACTIVE POLICY_DELETE POLICY_ADD_PENDING ACTIVE SSRB_DEL DEL_PENDING POLICY_ADD_PENDING SSRB_DEL DEL_PENDING DEL_PENDING POLICY_DELETE -
For more details about plugin functionality and writing plugins, see Plugin Functionality and Service Chaining.