diff options
-rw-r--r-- | conf/confbase.Y | 12 | ||||
-rw-r--r-- | doc/bird.sgml | 5 | ||||
-rw-r--r-- | proto/bgp/bgp.c | 4 | ||||
-rw-r--r-- | proto/bgp/bgp.h | 1 | ||||
-rw-r--r-- | proto/bgp/config.Y | 5 |
5 files changed, 18 insertions, 9 deletions
diff --git a/conf/confbase.Y b/conf/confbase.Y index cba6fc56..49831b1a 100644 --- a/conf/confbase.Y +++ b/conf/confbase.Y @@ -72,7 +72,7 @@ CF_DECLS %token <t> TEXT %type <iface> ipa_scope -%type <i> expr bool pxlen +%type <i> expr bool pxlen ipa_port %type <i32> expr_us %type <time> datetime %type <a> ipa @@ -88,7 +88,7 @@ CF_DECLS %left '!' %nonassoc '.' -CF_KEYWORDS(DEFINE, ON, OFF, YES, NO, S, MS, US) +CF_KEYWORDS(DEFINE, ON, OFF, YES, NO, S, MS, US, PORT) CF_GRAMMAR @@ -161,6 +161,14 @@ ipa_scope: | '%' SYM { $$ = if_get_by_name($2->name); } ; +ipa_port: + /* empty */ { $$ = 0; } + | PORT expr { + if (($2 < 1) || ($2 > 65535)) cf_error("Invalid port number"); + $$ = $2; + } + ; + prefix: ipa pxlen { if (!ip_is_prefix($1, $2)) cf_error("Invalid prefix"); diff --git a/doc/bird.sgml b/doc/bird.sgml index 1a8e233d..8f2e6935 100644 --- a/doc/bird.sgml +++ b/doc/bird.sgml @@ -1004,7 +1004,6 @@ foot). So <cf>1.2.0.0/16.pxlen = 16</cf> is true. <tag/ec/ - This is a specialized type used to represent BGP extended community values. It is essentially a 64bit value, literals of this type are usually written as <cf>(<m/kind/, <m/key/, <m/value/)</cf>, where @@ -1014,7 +1013,7 @@ foot). used kind. Similarly to pairs, ECs can be constructed using expressions for <cf/key/ and <cf/value/ parts, (e.g. <cf/(ro, myas, 3*10)/, where <cf/myas/ is an integer variable). - + <tag/int|pair|quad|ip|prefix|ec|enum set/ Filters recognize four types of sets. Sets are similar to strings: you can pass them around but you can't modify them. Literals of type <cf>int @@ -1616,7 +1615,7 @@ using the following configuration parameters: address, equivalent to the <cf/source address/ option (see below). This parameter is mandatory. - <tag>neighbor <m/ip/ as <m/number/</tag> + <tag>neighbor <m/ip/ [port <m/number/] 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. diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c index b6239971..e2339112 100644 --- a/proto/bgp/bgp.c +++ b/proto/bgp/bgp.c @@ -680,8 +680,8 @@ bgp_connect(struct bgp_proto *p) /* Enter Connect state and start establishing c s->type = SK_TCP_ACTIVE; s->saddr = p->source_addr; s->daddr = p->cf->remote_ip; + s->dport = p->cf->remote_port; s->iface = p->neigh ? p->neigh->iface : NULL; - s->dport = BGP_PORT; s->ttl = p->cf->ttl_security ? 255 : hops; s->rbsize = BGP_RX_BUFFER_SIZE; s->tbsize = BGP_TX_BUFFER_SIZE; @@ -1016,9 +1016,9 @@ bgp_start(struct proto *P) lock = p->lock = olock_new(P->pool); lock->addr = p->cf->remote_ip; + lock->port = p->cf->remote_port; lock->iface = p->cf->iface; lock->type = OBJLOCK_TCP; - lock->port = BGP_PORT; lock->hook = bgp_start_locked; lock->data = p; olock_acquire(lock); diff --git a/proto/bgp/bgp.h b/proto/bgp/bgp.h index da0114c2..0fd3a73c 100644 --- a/proto/bgp/bgp.h +++ b/proto/bgp/bgp.h @@ -23,6 +23,7 @@ struct bgp_config { ip_addr remote_ip; ip_addr source_addr; /* Source address to use */ struct iface *iface; /* Interface for link-local addresses */ + u16 remote_port; /* Neighbor destination port */ int multihop; /* Number of hops if multihop */ int ttl_security; /* Enable TTL security [RFC5082] */ int next_hop_self; /* Always set next hop to local IP address */ diff --git a/proto/bgp/config.Y b/proto/bgp/config.Y index 4d085d42..8e0b2412 100644 --- a/proto/bgp/config.Y +++ b/proto/bgp/config.Y @@ -60,7 +60,7 @@ bgp_proto: | bgp_proto proto_item ';' | bgp_proto LOCAL AS expr ';' { BGP_CFG->local_as = $4; } | bgp_proto LOCAL ipa AS expr ';' { BGP_CFG->source_addr = $3; BGP_CFG->local_as = $5; } - | bgp_proto NEIGHBOR ipa ipa_scope AS expr ';' { + | bgp_proto NEIGHBOR ipa ipa_scope ipa_port AS expr ';' { if (ipa_nonzero(BGP_CFG->remote_ip)) cf_error("Only one neighbor per BGP instance is allowed"); if (!ipa_has_link_scope($3) != !$4) @@ -68,7 +68,8 @@ bgp_proto: BGP_CFG->remote_ip = $3; BGP_CFG->iface = $4; - BGP_CFG->remote_as = $6; + BGP_CFG->remote_port = ($5 > 0) ? $5 : BGP_PORT; + BGP_CFG->remote_as = $7; } | bgp_proto RR CLUSTER ID idval ';' { BGP_CFG->rr_cluster_id = $5; } | bgp_proto RR CLIENT ';' { BGP_CFG->rr_client = 1; } |