Enables multihop mode for IBGP by default.

This is more consistent with common usage and also with the behavior of
other implementations (Cisco, Juniper).

Also changes the default for gw mode to be based solely on
direct/multihop.
This commit is contained in:
Ondrej Zajicek 2013-11-24 12:37:24 +01:00
parent 52e030e146
commit f3e5917850
3 changed files with 50 additions and 41 deletions

View file

@ -1536,33 +1536,37 @@ This allows to set routing policy and all the other parameters differently
for each neighbor using the following configuration parameters: for each neighbor using the following configuration parameters:
<descrip> <descrip>
<tag>local [<m/ip/] as <m/number/</tag> Define which AS we <tag>local [<m/ip/] as <m/number/</tag> Define which AS we are part
are part of. (Note that contrary to other IP routers, BIRD is of. (Note that contrary to other IP routers, BIRD is able to act as a
able to act as a router located in multiple AS'es router located in multiple AS'es simultaneously, but in such cases you
simultaneously, but in such cases you need to tweak the BGP need to tweak the BGP paths manually in the filters to get consistent
paths manually in the filters to get consistent behavior.) behavior.) Optional <cf/ip/ argument specifies a source address,
Optional <cf/ip/ argument specifies a source address, equivalent to the <cf/source address/ option (see below). This
equivalent to the <cf/source address/ option (see below). parameter is mandatory.
<tag>neighbor <m/ip/ as <m/number/</tag> Define neighboring router this
instance will be talking to and what AS it's located in. In case the
neighbor is in the same AS as we are, we automatically switch to iBGP.
This parameter is mandatory. This parameter is mandatory.
<tag>neighbor <m/ip/ as <m/number/</tag> Define neighboring router <tag>direct</tag> Specify that the neighbor is directly connected. The
this instance will be talking to and what AS it's located in. Unless IP address of the neighbor must be from a directly reachable IP range
you use the <cf/multihop/ clause, it must be directly connected to one (i.e. associated with one of your router's interfaces), otherwise the
of your router's interfaces. In case the neighbor is in the same AS BGP session wouldn't start but it would wait for such interface to
as we are, we automatically switch to iBGP. This parameter is mandatory. appear. The alternative is the <cf/multihop/ option. Default: enabled
for eBGP.
<tag>multihop [<m/number/]</tag> Configure multihop BGP <tag>multihop [<m/number/]</tag> Configure multihop BGP session to a
session to a neighbor that isn't directly connected. neighbor that isn't directly connected. Accurately, this option should
Accurately, this option should be used if the configured be used if the configured neighbor IP address does not match with any
neighbor IP address does not match with any local network local network subnets. Such IP address have to be reachable through
subnets. Such IP address have to be reachable through system system routing table. The alternative is the <cf/direct/ option. For
routing table. For multihop BGP it is recommended to multihop BGP it is recommended to explicitly configure the source
explicitly configure <cf/source address/ to have it address to have it stable. Optional <cf/number/ argument can be used to
stable. Optional <cf/number/ argument can be used to specify specify the number of hops (used for TTL). Note that the number of
the number of hops (used for TTL). Note that the number of networks (edges) in a path is counted; i.e., if two BGP speakers are
networks (edges) in a path is counted, i.e. if two BGP separated by one router, the number of hops is 2. Default: enabled for
speakers are separated by one router, the number of hops is iBGP.
2. Default: switched off.
<tag>source address <m/ip/</tag> Define local address we <tag>source address <m/ip/</tag> Define local address we
should use for next hop calculation and as a source address should use for next hop calculation and as a source address
@ -1609,8 +1613,8 @@ for each neighbor using the following configuration parameters:
table, and was used in older versions of BIRD, but does not table, and was used in older versions of BIRD, but does not
handle well nontrivial iBGP setups and multihop. Recursive handle well nontrivial iBGP setups and multihop. Recursive
mode is incompatible with <ref id="dsc-sorted" name="sorted mode is incompatible with <ref id="dsc-sorted" name="sorted
tables">. Default: <cf/direct/ for singlehop eBGP, tables">. Default: <cf/direct/ for direct sessions,
<cf/recursive/ otherwise. <cf/recursive/ for multihop sessions.
<tag>igp table <m/name/</tag> Specifies a table that is used <tag>igp table <m/name/</tag> Specifies a table that is used
as an IGP routing table. Default: the same as the table BGP is as an IGP routing table. Default: the same as the table BGP is

View file

@ -1006,6 +1006,24 @@ bgp_check_config(struct bgp_config *c)
if (c->c.class == SYM_TEMPLATE) if (c->c.class == SYM_TEMPLATE)
return; return;
/* EBGP direct by default, IBGP multihop by default */
if (c->multihop < 0)
c->multihop = internal ? 64 : 0;
/* Different default for gw_mode */
if (!c->gw_mode)
c->gw_mode = c->multihop ? GW_RECURSIVE : GW_DIRECT;
/* Different default based on rs_client */
if (!c->missing_lladdr)
c->missing_lladdr = c->rs_client ? MLL_IGNORE : MLL_SELF;
/* Disable after error incompatible with restart limit action */
if (c->c.in_limit && (c->c.in_limit->action == PLA_RESTART) && c->disable_after_error)
c->c.in_limit->action = PLA_DISABLE;
if (!c->local_as) if (!c->local_as)
cf_error("Local AS number must be set"); cf_error("Local AS number must be set");
@ -1021,7 +1039,6 @@ bgp_check_config(struct bgp_config *c)
if (internal && c->rs_client) if (internal && c->rs_client)
cf_error("Only external neighbor can be RS client"); cf_error("Only external neighbor can be RS client");
if (c->multihop && (c->gw_mode == GW_DIRECT)) if (c->multihop && (c->gw_mode == GW_DIRECT))
cf_error("Multihop BGP cannot use direct gateway mode"); cf_error("Multihop BGP cannot use direct gateway mode");
@ -1032,20 +1049,6 @@ bgp_check_config(struct bgp_config *c)
if (c->multihop && c->bfd && ipa_zero(c->source_addr)) if (c->multihop && c->bfd && ipa_zero(c->source_addr))
cf_error("Multihop BGP with BFD requires specified source address"); cf_error("Multihop BGP with BFD requires specified source address");
/* Different default based on rs_client */
if (!c->missing_lladdr)
c->missing_lladdr = c->rs_client ? MLL_IGNORE : MLL_SELF;
/* Different default for gw_mode */
if (!c->gw_mode)
c->gw_mode = (c->multihop || internal) ? GW_RECURSIVE : GW_DIRECT;
/* Disable after error incompatible with restart limit action */
if (c->c.in_limit && (c->c.in_limit->action == PLA_RESTART) && c->disable_after_error)
c->c.in_limit->action = PLA_DISABLE;
if ((c->gw_mode == GW_RECURSIVE) && c->c.table->sorted) if ((c->gw_mode == GW_RECURSIVE) && c->c.table->sorted)
cf_error("BGP in recursive mode prohibits sorted table"); cf_error("BGP in recursive mode prohibits sorted table");

View file

@ -34,6 +34,7 @@ CF_ADDTO(proto, bgp_proto '}' { bgp_check_config(BGP_CFG); } )
bgp_proto_start: proto_start BGP { bgp_proto_start: proto_start BGP {
this_proto = proto_config_new(&proto_bgp, sizeof(struct bgp_config), $1); this_proto = proto_config_new(&proto_bgp, sizeof(struct bgp_config), $1);
BGP_CFG->multihop = -1; /* undefined */
BGP_CFG->hold_time = 240; BGP_CFG->hold_time = 240;
BGP_CFG->connect_retry_time = 120; BGP_CFG->connect_retry_time = 120;
BGP_CFG->initial_hold_time = 240; BGP_CFG->initial_hold_time = 240;
@ -74,6 +75,7 @@ bgp_proto:
| bgp_proto STARTUP HOLD TIME expr ';' { BGP_CFG->initial_hold_time = $5; } | bgp_proto STARTUP HOLD TIME expr ';' { BGP_CFG->initial_hold_time = $5; }
| bgp_proto CONNECT RETRY TIME expr ';' { BGP_CFG->connect_retry_time = $5; } | bgp_proto CONNECT RETRY TIME expr ';' { BGP_CFG->connect_retry_time = $5; }
| bgp_proto KEEPALIVE TIME expr ';' { BGP_CFG->keepalive_time = $4; } | bgp_proto KEEPALIVE TIME expr ';' { BGP_CFG->keepalive_time = $4; }
| bgp_proto DIRECT ';' { BGP_CFG->multihop = 0; }
| bgp_proto MULTIHOP ';' { BGP_CFG->multihop = 64; } | bgp_proto MULTIHOP ';' { BGP_CFG->multihop = 64; }
| bgp_proto MULTIHOP expr ';' { BGP_CFG->multihop = $3; if (($3<1) || ($3>255)) cf_error("Multihop must be in range 1-255"); } | bgp_proto MULTIHOP expr ';' { BGP_CFG->multihop = $3; if (($3<1) || ($3>255)) cf_error("Multihop must be in range 1-255"); }
| bgp_proto NEXT HOP SELF ';' { BGP_CFG->next_hop_self = 1; BGP_CFG->next_hop_keep = 0; } | bgp_proto NEXT HOP SELF ';' { BGP_CFG->next_hop_self = 1; BGP_CFG->next_hop_keep = 0; }