📄 implementation.tex
字号:
is instantiated. If the policy is an import, then the Import code generator isused.For export policies two passes need to be done. The source match codegeneration and the export part. The export part acts much like import policycode generation but the source block matches policy tags.The source match code generation will match the source block, ignore the destblock and set policy tags as actions. However, the code generated may be formultiple {\em targets} where a target is a protocol and filter pair. Considerthe following policy fragment:\begin{verbatim}term a { source { protocol static_routes; metric == 4; }}term b { source { protocol rip; metric == 3; }} \end{verbatim}The source match will generate two code fragments of which one will need to besent to static\_routes and one to RIP.\subsection{Tracking configuration changes}Source match may generate code fragments for different targets. Suppose policyA generates a source match for RIP and static routes. Suppose a policy B is nowadded which also generates a source match for RIP. No problem, just append thecode. If policy B is deleted, the source match dependency for RIP has to be trackeddown. Then, somehow, the code relevant to B has to be deleted. If the code waskept as ``a whole'' it would not be possible, so policy A would have to bere-compiled, and possibly any other policies which generate source match forRIP.For this reason, generated code is always kept fragmented. There is a closeresemblance to what a compiler does by keeping separated object files andlinking them when needed. The same occurs with the policy manager.In the previous example, the code fragment of policy A would be deleted, and thesource match filter for RIP would be re-linked and the configuration would besent off.Policies are instantiated via the export / import list of a protocol. This listis managed via the PolicyList which will also contain all the code fragmentsgenerated by the instantiation.\subsubsection{Policy lists}A policy list is what instantiates policies. Each policy list will have itsindependent generated code for the policies which it refers to. A policy list iseither an export or import list, depending on user configuration.Internally a list of the policy names will be stored and for each policy therewill be a code list associated with it. A code list is simply a collection ofcode fragments. The code list will be all code generated for the instantiationof that policy. If it were an export policy list, the code list will contain allthe source match code, even if it was destined to a different protocol.Thus, the code fragments in a policy list may be for many different targets.Keeping code fragments this way allows tracking affected targets on policychanges easier. For example if policy A changes, each Policy list whichcontains policy A is tracked. The policy lists found will then extract all thetargets in the code list for policy A. These are the affected targets.When a target changes, the code fragments are re-linked and sent to the filtermanager. The filter manager is responsible with keeping backend filters synchronizedwith the latest configuration.\subsection{Filter manager}The Configuration class always contains the most up to date configuration forall targets. It is the responsibility of the filter manager to ensure thatbackend filters are synchronized with the configuration.Normally the filter manager will receive update requests from the configurationclass. The filter manager will then queue a configuration request for thetarget. These requests are queued in order to try and aggregate configurationchanges and especially route pushing. Particularly, on boot-up of the XORP router,many small configuration changes will occur in a short period of time.Currently, updates are flushed 2 seconds after the last update.The filter manager closely works with the process watcher. If a protocol dies,then no updates are longer sent to that protocol. Conversely, if a protocol isborn, any configuration present must be sent to it.Upon configuration changes, the filter manager tracks down which protocols needto have their routes pushed. These are also queued and flushed with a delay toattempt aggregation.There currently is a problem with the whole implementation structure. Ifredistribution from protocol A to B is requested and only A is alive, theroutes will reach the RIB. When B come to life, it will never receive theroutes. As a hack, the filter manager will cause routes of A will to pushed whenB comes to life.\subsection{RIB redistribution map}The RIB redistribution map is trivially implemented. A route table is presentbefore the register table in the RIB. As a route flows through, the table checks thepolicy tags and determines where route should be redistributed.It is configured via the filter manager which tracks down which tags areassociated to which protocol.\section{Current XORP integration}Currently, some degree of policy support is implemented in:\begin{description}\item[BGP] Import, source match, export, IPv4/6 redistribution.\item[RIP] Import, source match, export, IPv4/6 redistribution.\item[static routes] Import, source match.\item[connected] source match.\end{description}If source match filtering is supported, then the protocol may be used as thesource for a route redistribution.Following is an outline of the current implementation in the various routing protocols.\subsection{BGP}A generic route policy table is implemented. It suffices for export filtering.The import and source match filters are specialized because they contain otherfunctionality needed to allow route pushing.The import policy filter table is placed in each branch for every peering justafter the standard filter in table. The source match filter is placed rightbefore the fan out table. Finally, the export filter table is placed in eachbranch for ever peering just after the filter out table.The BGPVarRW implementation supports a subset of the most important attributeswhich need to be examined. For example, variables that indicate which peeringthe route came from still need to be added.The route pushing interface of BGP has to be redesigned.\subsubsection{BGP route push}Route pushing in BGP is a proof of concept and should not be used. It uses dumpiterators but is not a background task. The dump to peer is set to NULL todifferentiate it from normal route dumps. The source match filter initiates the route dump for its strategical position--- it has access to peerinfo from the fanout table, and may use the decisiontable to spread the route dump request to all branches. It will try to dump allroutes in one go, and will not check if routes are flowing in the pipeline asthe dump is initiated. The RibIn table will dump all routes if the dump to peeris set to NULL (even routes which are not winners).The policy import filter will intercept route dumps with the dump peer set to NULL. Itwill recognize them as policy route dumps. It will then transform the request toeither an add, replace or delete according to the matrix in table~\ref{pushmatrix}.For this reason, import filters need to be present in each branch, even thoughfiltering may not desired such as the RIB peer branch.The routes will then flow through the pipeline most likely causing unnecessaryupdates. It is important to have the routes flow all the way down, even ifnothing changed, as maybe the export filter lower in the pipeline will change them.\subsection{RIP}RIP has the worse policy implementation. For import filtering, All the RIP ``magic'' occurs in the update\_route routineof the RouteDB. An attempt is made to try to filter routes and modify them.Output filtering is slightly better and occurs both for the route table outputsand the updates output.Because of reference counting, I was not able to find a clean way to copy a RIProute without having to create a new structure containing the same data. As aresult, I ended up copying routes by setting a NULL origin to force referencecounting not to occur. For this reason, the current RIPVarRW has no informationabout origin, so matching may only be done on a subset of what is possible.Route pushing in RIP does not exist. The route database will be flushed, ascopies of original routes are not stored. For the filters to take effect,new advertisements have to come in. An attempt is made to re-filter routeslearned from the RIB.\subsection{Static routes}Static routes probably has the most correct and safe policy implementation dueto its simplicity. Filtering may occur only on the import branch. The routedatabase will always contain original routes, and routes are possibly modifiedby filters as they are sent to the RIB.Route pushing should be safe and should work correctly.\subsection{Connected routes}Connected routes may only be used as a source for route redistribution. They maynot be modified nor filtered. Notice that modifying policy tags on a route, doesnot modify the route itself. It is pure meta-data used exclusively by the policyframework.Route pushing is implemented by having the connected route filter table in theRIB store all the routes itself. This is a waste of space, as the Origin tablewill have the same exact information. On a push request, the filter table willinitiate a replace\_policytags call which should only be used by the policyredist table. The policy redist table will then decide which protocols shouldstop advertising the route and which should start.Changes only to the policy tags should be propagated in a similar way in allrouting protocols, as it will not cause route adds / deletes inside the process(in this case the RIB), which is desirable. Currently, the user has to specify rib as the protocol instead of connected dueto a lack of protocol to process mapping in the VarMap (which may be used by thefilter manager).\section{General problems}The XORP integration should be fixed as stated in the above sections. Thebiggest problem is route pushing. Other problems may arise due to raceconditions. The following list are issues which should be considered:\begin{itemize}\item What happens if the source protocol is alive, but the export is dead.\item How to configure VarMap ?\item Configuration integration with rtrmgr for source / action / dest block.\item ElemSet --- do not treat everything as a string!\item Route pushing propagate only real route changes, and propagate policy tagschanges with another mechanism.\item Counters in filters indicating how many times a term was matched.\end{itemize}\section{Conclusion}I believe that the overall idea of having generic filters was good. If it works,and works well, it will make life easy for protocol developers which wouldlike to support policy in their implementations. There are considerations tomake about how fast these filters run as flexibility does come with acost. The work is still under development and un-stable. The ``real-life''testing was basically null, possibly due to bad time management on my part.Hopefully this work will give an idea to what are the problems and possiblesolutions in implementing a policy framework for XORP. I belive however thecurrent implementation reached a good starting point for it to be extended. Ifthis design is accepted and kept, the major components and ideas are deployed.It is now a question of correcting, extending and optimizing them.\end{document}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -