📄 bgp.tex
字号:
\documentclass[11pt]{article}\usepackage{graphicx}\usepackage{times}\textwidth 6.5in\topmargin 0.0in\textheight 8.5in\headheight 0in\headsep 0in\oddsidemargin 0in\title{XORP BGP Routing Daemon \\\vspace{1ex}Version 0.5}\author{ XORP Project \\ International Computer Science Institute \\ Berkeley, CA 94704, USA \\ {\it feedback@xorp.org}}\date{November 6, 2003}%\twocolumn\begin{document}\maketitle \section{Introduction}This document provides an overview of the XORP BGP Routing Daemon. Itis intended to provide a starting point for software developerswishing to modify this software.A router running BGP takes routes from peer routers, filters them,decides which of the alternative routes is the best, and passes thewinner on to the other peers, possibly applying filters before passingthe route on.Our chosen architecture for our BGP implementation emphasizesextensibility and the separable testing of subsystems, rather thanhigh performance or minimal memory footprint. However we believe thatthe performance and memory usage will be acceptable, even for backbonerouter implementations.We implement BGP as a connected pipeline of ``routing tables'', eachperforming a specialized task. Figure \ref{overview} gives thegeneral overview of classes involved in the core of the BGP process,but excludes the classes involved in handling peerings with peers.\begin{figure}[htb]\centerline{\includegraphics[width=1.0\textwidth]{figs/overview}}\vspace{.05in}\caption{\label{overview}Overview of BGP process}\end{figure}Route information flows from left to right in this figure. Typicallyan Update or Withdraw message arrives from a BGP peer, is split upinto separate {\tt add\_route} or {\tt delete\_route} commands by the PeerHandler,and then the update flows through the tables towards theDecisionTable. If the route is better than the best alternative, thenit passes through the DecisionTable, and is then fanned out to all theoutput branches except the one it arrived un. The outgoingPeerHandler then sends the route on to the corresponding BGP peer.There is one input branch and one corresponding output branch for eachBGP peer, plus one branch that handles routes sent to BGP from theXORP RIB, and sends BGP routes to the XORP RIB and hence on to theforwarding engine. The general structure of the RIB branch isidentical to that of a peer-related branch, but a special version ofthe PeerHandler is used.\section{Major BGP Classes}In this section we discuss each of the classes from Figure \ref{overview} inturn, before discussing how each BGP peer is handled. Most of theseclasses are implemented using C++ templates for the address family, sothey are capable of handling IPv4 and IPv6 in an identical manner.\subsection{PeerHandler Class}The PeerHandler acts as the interface between the BGP Peer class(which handles BGP peering connections) and all the RouteTables thatcomprise the BGP plumbing. A single PeerHandler instance receives BGP Update messages coming from the BGP peer and constructs new BGPUpdate messages to send to that peer.A BGP Update Message consists of three parts:\begin{itemize}\item A list of withdrawn route subnets (route prefixes).\item Path Attribute information for announced routes.\item A list of subnets (route prefixes) that are being announced.The Path Attribute information applies to all these subnets.\end{itemize}The PeerHandler splits an incoming update message up, and constructs aseries of messages (InternalMessage class) to send to the plumbing.Each of the withdrawn route subnets is passed to the plumbing using aseparate {\tt delete\_route} call.Each of the announced route subnets is passed to the plumbing using aseparate {\tt add\_route} call, which includes all the Path Attributeinformation.On the output side, the PeerHandler receives a series of {\tt add\_route},{\tt delete\_route}, or \\{\tt replace\_route} calls. Each batch of calls is forroutes that share the same path attribute list. The PeerHandler thenconstructs an Update Message from each batch, and passes it on to theclasses that handle the peering for transmission to the relevant BGPpeer router. In some cases the PeerHandler can receive routes from BGP faster thanthe connection to the relevant peer can handle them. The PeerHandlercan communicate this information back upstream to regulate the flow ofchanges to a rate that can be accommodated. The actual queuing thenhappens upstream in the FanoutTable.Because of the way BGP encodes IPv6 routes, the PeerHandler classhandles IPv4 and IPv6 routing information differently.\subsection{RibInTable Class}The RibInTable class is responsible for receiving routes from thePeerHandler and storing them. These are the raw routes, unfilteredand unmodified except for syntactic correctness, as received anddecoded from the BGP Peering session.Because BGP does not indicate in an Update message whether a route isnew or merely replaces an existing route, all routes are checked tosee if they are already stored in the RibIn. If so, the {\tt add\_route} ispropagated downstream as a {\tt replace\_route}, otherwise it is propagatedas an {\tt add\_route}.The RibIn serves several additional purposes:\begin{itemize}\item It can answer {\tt lookup\_route} requests from downstream.\item When a new peer comes up, a route dump is initiated so that thenew peer learns all the feasible routes that we know. The RibIn canperform this dump as part of a background task, so as to allow furtherupdates while the dump is taking place.\item When the peer associated with the RibIn goes down, a process todelete all the routes learned from this peer is started. This is doneby transferring the RibIn's entire routing table to a new RouteTablecalled a DeletionTable that is plumbed in directly after the RibIn.The DeletionTable handles the deletion of the routes as a backgroundtask, leaving the RibIn ready to cope immediately if the peer comesback up again.\item When the routing information in the XORP RIB changes, the changeof IGP metric can change which routes should win the decision process.The RibIn can be told that the routing information associated with theindirect nexthop in a BGP route has changed, and it can initiate abackground task that re-sends all the relevant routes downstream as{\tt replace\_route} messages, so that the DecisionTable can make its choiceagain.\end{itemize}The RibIn does not do significant sanity checking on its inputs - itis the responsibility of the receive code in the Peer classes to checkthat received update messages are syntactically and semanticallyvalid.The current (Mar 2003) version of XORP stores all routes in the RibIn,irrespective of whether or not they will fail to pass a downstreamfilter. However, the RibIn has enough information (from the valuesreturned by the {\tt add\_route}, {\tt delete\_route} and {\ttreplace\_route} calls it makes downstream) to be able to store onlythose routes that will not be filtered.\subsection{FilterTable Class}The FilterTable class has one parent (upstream) RouteTable and onechild (downstream) RouteTable. It acts as a general purposefilter-bank, passing, modifying, or dropping routing information thattravels from parent to child.A FilterTable can hold many filters. Current filters include:\begin{itemize}\item {\bf SimpleASFilter:} Drops routes that contain the configuredAS in their AS Path.\item {\bf ASPrependFilter:} Prepends the configured AS number to theAS Path of allroutes that pass through the filter.\item {\bf NexthopRewriteFilter:} Changes the NextHop attribute of allroutes that pass through the filter to the specified value.\item {\bf IBGPLoopFilter:} Drops all routes that we heard throughIBGP. This is primarily useful as an outbound filter to an IBGP peer.\item {\bf LocalPrefInsertionFilter:} Inserts the configured value asthe BGP Local Preference attribute in all routes that pass through thefilter. Typically used on input from an EBGP peer, beforeroute-specific filters.\item {\bf LocalPrefRemovalFilter:} Removes the BGP Local Preferenceattribute from all routes that pass through the filter. Typicallyused on output to an EBGP peer.\item {\bf MEDInsertionFilter:} Adds a Multi-exit Descriminatorattribute based on the routes IGP metric to each route that passesthrough the filter. Typically used on output to an EBGP peer. Notethat the MED to be inserted will have been added to the route by theDecisionTable, so MEDInsertionFilter cannot be used as an input-branchfilter.\item {\bf MEDRemovalFilter:} Removes the Multi-exit Descriminatorattribute from all routes that pass through the filter. Typicallyused just before a MEDInsertionFilter to remove the MED received fromthe previous AS.\end{itemize}Note that filters are not just for operator configured filtering -they comprise part of the basic BGP processing mechanism.Typically a FilterTable will receive an InternalMessage from itsparent containing a subnet route. All the configured filters will beapplied in order to the route. One of three things may happen:\begin{itemize}\item The route may be dropped by a filter.\item The route may pass through all filters unchanged.\item One or more filters may modify the route. This is done bycreating a new copy of the route.\end{itemize}In the last case, the modified route will have the Changed flag setbefore it is propagated downstream. This flag indicates that no-oneupstream is storing a persistent copy of this route, so the downstreamtables are responsible for either storing the route or freeing thememory it uses.Filter implementors should be careful to note that if the routereceived as input to a filter is already modified, and their filterthen drops the route or creates a modified copy of the route, then the
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -