Commit dcde7ae5 authored by Ondrej Zajicek's avatar Ondrej Zajicek
Browse files

Allows to configure different remote port for BGP sessions.

Thanks to João Taveira Araújo for the original patch.
parent 252c7e4d
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -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");
+2 −3
Original line number Diff line number Diff line
@@ -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
@@ -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.
+2 −2
Original line number Diff line number Diff line
@@ -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);
+1 −0
Original line number Diff line number Diff line
@@ -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 */
+3 −2
Original line number Diff line number Diff line
@@ -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; }