rtrmgr.tex

来自「BCAST Implementation for NS2」· TEX 代码 · 共 668 行 · 第 1/2 页

TEX
668
字号
    \>\tt\%activate: xrl {\it XRL2}\\    \>\tt netmask: ipv4 \{\\        \>\>\tt\%set: xrl {\it XRL3}\\    \>\tt\}\\\tt\}\end{tabbing}Then when an instance of address and netmask are created andconfigured, the execution order of the XRLs will be: {\it XRL1, XRL3, XRL2}.\subsubsection{The {\tt \%list} Command.}{\tt \%list} is called to obtain a list of all the configuration treeinstances of a particular template tree node.  For example, aparticular template tree node might represent the interfaces on arouter.  The configuration tree would then contain an instance of thisnode for each interface currently configured.  The {\tt \%list}command on this node would then return the list of interfaces.\begin{itemize}\item The first parameter indicates the form of action to take to performthis action - typically it is {\tt xrl} which indicates an XRL shouldbe called.\item If the action is {\tt xrl}, then the second parameter gives the XRL tocall to return the list.\end{itemize}\subsubsection{The {\tt \%delete} Command.}{\tt \%delete} is called to delete a configuration tree node and all itschildren.  A node that has a {\tt \%create} or {\tt \%activate}command should also have a {\tt \%delete} command.\begin{itemize}\item The first parameter indicates the form of action to take to performthis action - typically it is {\tt xrl} which indicates an XRL shouldbe called.\item If the action is {\tt xrl}, then the second parameter gives the XRL tocall to delete the configuration tree instance of this template treenode.\end{itemize}\subsubsection{The {\tt \%set} Command.}{\tt \%set} is called to set the value of a leaf node in theconfiguration tree.\begin{itemize}\item The first parameter indicates the form of action to take to performthis action - typically it is {\tt xrl} which indicates an XRL shouldbe called.\item If the action is {\tt xrl}, then the second parameter gives the XRL tocall to set the value of configuration tree instance of this templatetree node.\end{itemize}\subsubsection{The {\tt \%unset} Command.}{\tt \%unset} is called to unset the value of a leaf node in theconfiguration tree.  The value will return to its default value if adefault value is specified.\begin{itemize}\item The first parameter indicates the form of action to take to performthis action - typically it is {\tt xrl} which indicates an XRL shouldbe called.\item If the action is {\tt xrl}, then the second parameter gives the XRL tocall to unset the value of configuration tree instance of this templatetree node.\end{itemize}\subsubsection{The {\tt \%get} Command.}{\tt \%get} is called to get the value of a leaf node in theconfiguration tree.  Normally the rtrmgr will know the value if thereis no external means to change the value, but the {\tt \%get} commandprovides a way for the rtrmgr to re-sync if the value has changed.\begin{itemize}\item The first parameter indicates the form of action to take to performthis action - typically it is {\tt xrl} which indicates an XRL shouldbe called.\item If the action is {\tt xrl}, then the second parameter gives the XRL tocall to get the value of configuration tree instance of this templatetree node.\end{itemize}\subsubsection{The {\tt \%allow} Command.}The {\tt \%allow} command provides a way to restrict the value ofcertain nodes to specific values.\begin{itemize}\item The first parameter gives the name of the variable to be restricted.\item The remaining parameters are a list of possible allowed values forthis variable.\end{itemize}For example, a node might specify an address family, which is intendedto be one of ``inet'' or ``inet6''.  The type of the node is {\tttext}, which would allow any value, so the allow command might allowthe rtrmgr to restrict the legal values without having tocommunicate with the process providing this functionality.A more subtle use might be to allow certain nodes to exist only if aparent node was of a certain value.For example:\begin{verbatim}      family @: text {        %allow: $(@) "inet" "inet6";        address @: ipv4 {          %allow: $(family.@) "inet";          broadcast: ipv4;        }        address @: ipv6 {          %allow: $(family.@) "inet6";        }      }\end{verbatim}In this case, there are two different typed versions of the ``{\ttaddress @}'' node, once for IPv4 and one for IPv6.  Only one of them hasa leaf node called {\tt broadcast}.  The allow command permits thertrmgr to do type-checking to ensure that only the permittedcombinations are allowed.\newpage\section{The Configuration File}Whereas the template files inform the rtrmgr as the {\it possible}configuration of the router, the configuration file provides thespecific startup configuration to be used by this specific router.The syntax is similar to, but not the same as, that of template files -the differences are intentional - template files are intended to bewritten by software developers, whereas configuration files areintended to be written by network managers.  Hence the syntax ofconfiguration files is simpler and more intuitive, but less powerful.However, both specify the same sort of tree structure, and the nodesin the configuration tree must correspond to the nodes in the templatetree.An example fragment of a configuration file might be:\begin{verbatim}protocols {  ospf {    router-id: 1.2.3.4    mospf    area 1.2.3.27 {      stub      interface fxp1 {        hello-interval: 10      }      interface fxp2    }  }}\end{verbatim}Note that unlike in the template tree, semicolons are not needed in theconfiguration tree, and that line-breaks are significant.The example fragment of a configuration file above will construct thefollowing configuration tree from the template tree example givenearlier:\begin{figure}[htb]\centerline{\includegraphics[width=0.7\textwidth]{figs/config}}\vspace{.05in}%\caption{\label{overview}Overview of XORP processes}\end{figure}Note that configuration tree nodes have been created for {\ttdead-interval} and (in the case of fxp1) for {\tt hello-interval} eventhough this was not mentioned in the configuration file.  This isbecause the template tree contains a default value for this leaf node.\newpage\section{Command Line Interface: xorpsh}The rtrmgr process is the core of a XORP router - it starts and stopsprocesses and keeps track of the configuration.  To do its task, itmust run as root, whereas most other XORP processes don't needprivileged operation and so can be sandboxed.  This makes the rtrmgrprocess the single most critical point from a security point of view.Thus we would like the rtrmgr to be as simple aspossible\footnote{Unfortunately the router manager is not simple as wewould like.}, and to isolate it from possibly hostile input as far asis reasonable.For these reasons we do not build a command line interface directlyinto the rtrmgr, but instead use an external process called {\ttxorpsh} to interact with the user, while limiting the rtrmgr'sinteraction with xorpsh to simple authentication mechanisms, andexchanges of configuration tree data.  Thus the command line interfacearchitecture looks like:\begin{figure}[htb]\centerline{\includegraphics[width=0.7\textwidth]{figs/xorpsh}}\vspace{.05in}%\caption{\label{overview}Overview of XORP processes}\end{figure}The interface between the rtrmgr and a xorpsh instance consists ofXRLs that the xorpsh may call to query or configure rtrmgr, and a fewXRLs that the rtrmgr may asynchronously call to alert the xorpshprocess to certain events.  The rtrmgr exports the following XRLs that may be called by xorpsh:\begin{description}\item{\tt register\_client} \\This XRL is used by a xorpsh instance toregister with the rtrmgr.  In response, the rtrmgr provides the nameof a file containing a nonce - the xorpsh must read this file andreturn the contents to the rtrmgr to authenticate the user.\item{\tt authenticate\_client} \\Xorpsh uses this to complete theauthentication process.\item{\tt get\_running\_config} \\Xorpsh uses this to request thecurrent running configuration from the rtrmgr.  The response is textin the same syntax as the rtrmgr configuration file that provides thertrmgr's view of the configuration.\item{\tt enter\_config\_mode} \\A xorpsh process must be inconfiguration mode to submit configuration changes to the rtrmgr.This XRL requests that the rtrmgr allows the xorpsh to enterconfiguration mode.  Not all users have permission to enterconfiguration mode, and it is also possible that a request may berefused because the configuration is locked.  \item{\tt get\_config\_users} \\Xorpsh uses this to request the list ofusers who are currently in configuration mode. \item{\tt apply\_config\_change} \\Xorpsh uses this to submit a requestto change the running configuration of the router to the rtrmgr.  Thechange consists of a set of differences from the current runningconfiguration.\item{\tt lock\_config} \\Xorpsh uses this to request an exclusivelock on configuration changes.  Typically this is done just prior tosubmitting a set of changes.\item{\tt unlock\_config} \\Unlocks the rtrmgr configuration that waslocked by a previous call to {\tt lock\_config}.\item{\tt lock\_node} \\Xorpsh uses this to request a lock onconfiguration changes to a specific config tree node.  Usually thiswill be called because the user has made local changes to the configbut not yet committed them, and wishes to prevent another user makingchanges that conflict.  Locking is no substitute for human-to-humanconfiguration, but it can alert users to potential problems.{\it Note: node locking is not yet implemented.}\item{\tt unlock\_node} \\Xorpsh uses this to request a lock on aconfig tree node be removed. \item{\tt save\_config} \\Xorpsh uses this to request theconfiguration be saved to a file.  The actual save is performed by thertrmgr rather than by xorpsh, but the resulting file will be owned bythe user running this instance of xorpsh, and the file cannotoverwrite files that this user would not otherwise be able tooverwrite.\item{\tt load\_config} \\Xorpsh uses this to request the rtrmgr reloadsthe router configuration from the named file.  The file must bereadable by the user running this instance of xorpsh, and the usermust be in configuration mode when the request is made.\item{\tt leave\_config\_mode} \\Xorpsh uses this to inform rtrmgr thatit is no longer in configuration mode.\end{description}\vspace{0.2in}Each xorpsh process exports the following XRLs that the rtrmgr can useto asynchronously communicate with the xorpsh instance:\begin{description}\item{\tt new\_config\_user} \\Rtrmgr uses this XRL to inform allxorpsh instances that are in config mode than another user has enteredconfig mode.\item{\tt config\_change\_done} \\When a xorpsh instance submits arequest to the rtrmgr to change the running config or to load a configfrom a file, the rtrmgr may have to perform a large number or XRL callsto implement the config change.  Due to the single-threaded nature ofXORP processes, the rtrmgr cannot do this while remaining in the {\ttapply\_config\_change} XRL, so it only performs local checks on thesanity of the request before returning success or failure - theconfiguration will not have actually been changed at that point.  Whenthe rtrmgr finishes making the change, or when failure occurs part waythrough making the change, the rtrmgr will call {\ttconfig\_change\_done} on the xorpsh instance that requested the changeto inform it of the success or failure.\item{\tt config\_changed} \\When multiple xorpsh processes areconnected to the rtrmgr, and one of them submits a successful changeto the configuration, the differences in the configuration will thenbe communicated to the other xorpsh instances to keep their version ofthe configuration in sync with the rtrmgr's version.\end{description}\subsection{Operational Commands and xorpsh}Up to this point, we have been dealing with changes to the routerconfiguration.  Indeed this is the role of the rtrmgr process.However a router's command line interface is not only used to changeor query the router configuration, but also to learn about the dynamicstate of the router, such as link utilization or routes learned by arouting protocol.  To keep it as simple and robust as possible, thertrmgr is not involved in these \textit{operational mode} commands.Instead these commands are executed directly by a xorpsh processitself.To avoid the xorpsh implementation needing in-built knowledge ofrouter commands, the information about operational mode commands isloaded from another set of template files.  A simple example might be:\begin{verbatim}show interface $(interfaces.interface.*) {        %command: show_interface;        %module: fea;        %opt_parameter: brief;        %opt_parameter: detail;        %opt_parameter: extensive;}show vif $(interfaces.interface.*.vif.*) {        %command: show_vif;        %module: fea;        %opt_parameter: brief;        %opt_parameter: detail;        %opt_parameter: extensive;}\end{verbatim}This template file defines two operational mode commands: ``{\tt showinterface}'' and ``{\tt show vif}''.The ``show interface'' command takes one mandatory parameter, whosevalue must be the name of one of the configuration tree nodes takenfrom the variable name wildcard expansion {\tt\$(interfaces.interface.*)}.  Thus if the router had config tree nodescalled ``{\tt interfaces interface xl0}'', and ``{\tt interfaces interfacexl1}'', then the value of the mandatory parameter must be either {\ttxl0} or {\tt xl1}.  Additional optional parameters might be {\tt brief}, {\tt detail}, or{\tt extensive} - the set of allowed optional parameters is specifiedby the {\tt \%opt\_parameter} commands.  The {\tt \%command} command indicates the program or script to beexecuted to implement this command - the script should returnhuman-readable output preceded by a MIME content type indicatingwhether the text is structured or not\footnote{Only {\tt text/plain}is currently supported.}.  The entire command line typed by the useris passed into the command.  Thus the xorpsh might invoke the {\ttshow\_interface} command using the Unix command line:\begin{verbatim}    path/to/show_interface show interface xl0 brief\end{verbatim}The pathname to a command must berelative to the root of the XORP tree. The ordering in computing the root ofthe tree is: (a) the shell environment XORP\_ROOT (if exists); (b) the parentdirectory the xorpsh is run from (only if it contains theetc/templates and the xrl/targets directories); (c) the XORP\_ROOT value asdefined in config.h (currently this is the installation directory, anddefaults to ``/usr/local/xorp'').The command {\tt \%module} indicates that this command should only beavailable through the CLI when the router configuration has requiredthat the named module has been started.\textit{Note: currently there is no security mechanism restrictingaccess to operational mode commands beyond the restrictions imposed byUnix file permissions.  This is not intended to be the long-termsituation.}\end{document}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?