Open Ethernet Networking (OpEN) API Guide and Reference Manual
3.6.0.3
|
The routing policy service is the third RPPI service. Routing policy enables routing protocols to control the routes they accept from neighbors or from other protocols through redistribution and control routes they advertise to others. Policy constructs can match on destination IP address and other route attributes, such BGP path attributes. Policy can alter the attributes of routes received or advertised. ICOS has a growing library of routing policy constructs using route maps, prefix lists, AS path access lists, and BGP community lists.
To extend the routing policy service to applications, RPPI offers RPC APIs that allow access to the policy library. These APIs allow applications to apply policies, but not to configure them. The policies must be configured within ICOS. Applications identify policies they want to apply by name or by number.
Initially, the only types of policies an application can apply directly are route maps and prefix lists. A prefix list can also be applied indirectly through a route map. The API is designed to allow it to support AS path access lists and BGP community lists in the future.
The RPC API to apply a route map is as follows:
int openapiRouteMapApply(uchar8_t *routeMapName, openRmMatchParams_t *matchParams, openRmSetParams_t *setParams);
The API returns 0 if the route map denies the route, 1 if the route map permits the route, and a negative value if an error occurs. The only match parameter that an application may set is the destination prefix. The only set parameter returned is the route metric (if the route map is configured to set a metric).
The API to apply a prefix list is similar.
An application may optionally register to be notified when the configuration of a route map changes. The RPC API to register is as follows:
open_error_t openapiRoutingPolicyRegister(open_buffdesc *clientName, uint32_t pid, uint32_t policyTypeMask, uint32_t *clientId);
The policy type mask indicates which types of policy changes the application is interested in. The mask is indexed by an enumeration, as follows:
typedef enum { OPEN_POLICY_ROUTE_MAP = 1, OPEN_POLICY_PREFIX_LIST = 2, OPEN_POLICY_AS_PATH_LIST = 4 } OPEN_ROUTING_POLICY_TYPE_t;
To register for route map and prefix list changes, an application sets policyTypeMask to 3 ( = OPEN_POLICY_ROUTE_MAP | OPEN_POLICY_PREFIX_LIST). An application may call this register API more than once. RPPI uses the value of policyTypeMask in the last call. To deregister for policy changes, an application calls the register function with policyTypeMask set to 0.
An application that registers for routing policy changes opens a UNIX socket with its client ID embedded in the local "address." When policy configuration changes, ICOS sends a message on this socket. The message format is as follows:
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Message Type | Message Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Sequence Number | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Policy Type | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Policy Change | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Policy Name | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ..... |
1 - Policy created or changed 2 - Policy deleted
When an application receives a policy change event, it checks whether it is using the policy that changed. If so, it may reapply the policy to put the change into effect.
While the UNIX datagram socket is fairly reliable, RPPI requires an explicit acknowledgment from an application for each change. If RPPI does not receive an acknowledgment within 10 seconds, RPPI deregisters the client. The application acknowledges a policy change by calling the following RPC API:
open_error_t openapiPolicyChangeAck(uint32_t clientId, uint32_t seqNo)
seqNo is the sequence number from the policy change message. The call acknowledges the change with sequence number seqNo and all changes with lower sequence numbers. The sequence number space is not expected to wrap.
Like other RPPI services, the policy service sends regular KEEPALIVE messages. If an application stops receiving KEEPALIVE messages for this service, the application assumes an error has occurred. The application should reregister and reapply all policies it is using.
Note that an application can use the policy apply RPC call even if it does not register to receive policy change notifications.