diff --git proto/bgp/bgp.c proto/bgp/bgp.c index b623997..37e8e0a 100644 --- proto/bgp/bgp.c +++ proto/bgp/bgp.c @@ -681,7 +681,7 @@ bgp_connect(struct bgp_proto *p) /* Enter Connect state and start establishing c s->saddr = p->source_addr; s->daddr = p->cf->remote_ip; s->iface = p->neigh ? p->neigh->iface : NULL; - s->dport = BGP_PORT; + s->dport = p->cf->dport ? p->cf->dport : BGP_PORT; s->ttl = p->cf->ttl_security ? 255 : hops; s->rbsize = BGP_RX_BUFFER_SIZE; s->tbsize = BGP_TX_BUFFER_SIZE; @@ -1018,7 +1018,7 @@ bgp_start(struct proto *P) lock->addr = p->cf->remote_ip; lock->iface = p->cf->iface; lock->type = OBJLOCK_TCP; - lock->port = BGP_PORT; + lock->port = p->cf->dport ? p->cf->dport : BGP_PORT; lock->hook = bgp_start_locked; lock->data = p; olock_acquire(lock); @@ -1349,6 +1349,9 @@ bgp_show_proto_info(struct proto *P) cli_msg(-1006, " Neighbor address: %I%J", p->cf->remote_ip, p->cf->iface); cli_msg(-1006, " Neighbor AS: %u", p->remote_as); + if (p->cf->dport) + cli_msg(-1006, " Neighbor Port: %u", p->cf->dport); + if (p->gr_active) cli_msg(-1006, " Neighbor graceful restart active"); diff --git proto/bgp/bgp.h proto/bgp/bgp.h index da0114c..cf01fc9 100644 --- proto/bgp/bgp.h +++ proto/bgp/bgp.h @@ -62,6 +62,7 @@ struct bgp_config { char *password; /* Password used for MD5 authentication */ struct rtable_config *igp_table; /* Table used for recursive next hop lookups */ int bfd; /* Use BFD for liveness detection */ + u16 dport; /* Destination port to be used. */ }; #define MLL_SELF 1 diff --git proto/bgp/config.Y proto/bgp/config.Y index 4d085d4..ad8a2b1 100644 --- proto/bgp/config.Y +++ proto/bgp/config.Y @@ -26,7 +26,7 @@ CF_KEYWORDS(BGP, LOCAL, NEIGHBOR, AS, HOLD, TIME, CONNECT, RETRY, PREFER, OLDER, MISSING, LLADDR, DROP, IGNORE, ROUTE, REFRESH, INTERPRET, COMMUNITIES, BGP_ORIGINATOR_ID, BGP_CLUSTER_LIST, IGP, TABLE, GATEWAY, DIRECT, RECURSIVE, MED, TTL, SECURITY, DETERMINISTIC, - SECONDARY, ALLOW, BFD, ADD, PATHS, RX, TX, GRACEFUL, RESTART, AWARE) + SECONDARY, ALLOW, BFD, ADD, PATHS, RX, TX, GRACEFUL, RESTART, AWARE, PORT) CF_GRAMMAR @@ -70,6 +70,7 @@ bgp_proto: BGP_CFG->iface = $4; BGP_CFG->remote_as = $6; } + | bgp_proto NEIGHBOR PORT expr ';' { BGP_CFG->dport = $4; if (($4<1) || ($4>65535)) cf_error("Invalid port number."); } | bgp_proto RR CLUSTER ID idval ';' { BGP_CFG->rr_cluster_id = $5; } | bgp_proto RR CLIENT ';' { BGP_CFG->rr_client = 1; } | bgp_proto RS CLIENT ';' { BGP_CFG->rs_client = 1; }