Thanks to João Taveira Araújo for the original patch.
%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
%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
| '%' 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");
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
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
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.
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;
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);
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 */
| 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)
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; }