Commit 71423871 authored by Vincent Bernat's avatar Vincent Bernat Committed by Ondrej Zajicek (work)
Browse files

BGP: Add support for BGP hostname capability

This is an implementation of draft-walton-bgp-hostname-capability-02.
It is implemented since quite some time for FRR and in datacenter, this
gives a nice output to avoid using IP addresses.

It is disabled by default. The hostname is retrieved from uname(2) and
can be overriden with "hostname" option. The domain name is never set
nor displayed.

Minor changes by committer.
parent 00b85905
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@
#include "lib/timer.h"
#include "conf/conf.h"
#include "filter/filter.h"
#include "sysdep/unix/unix.h"


static jmp_buf conf_jmpbuf;
@@ -217,6 +218,14 @@ config_del_obstacle(struct config *c)
static int
global_commit(struct config *new, struct config *old)
{
  if (!new->hostname)
    {
      new->hostname = get_hostname(new->mem);

      if (!new->hostname)
        log(L_WARN "Cannot determine hostname");
    }

  if (!old)
    return 0;

+1 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ struct config {
  struct timeformat tf_log;		/* Time format for the logfile */
  struct timeformat tf_base;		/* Time format for other purposes */
  u32 gr_wait;				/* Graceful restart wait timeout (sec) */
  const char *hostname;			/* Hostname */

  int cli_debug;			/* Tracing of CLI connections and commands */
  int latency_debug;			/* I/O loop tracks duration of each event */
+6 −0
Original line number Diff line number Diff line
@@ -585,6 +585,9 @@ include "tablename.conf";;
	See <ref id="proto-iface" name="interface"> section for detailed
	description of interface patterns with extended clauses.

	<tag><label id="opt-hostname">hostname "<m/name/"</tag>
	Set hostname. Default: node name as returned by `uname -n'.

	<tag><label id="opt-graceful-restart">graceful restart wait <m/number/</tag>
	During graceful restart recovery, BIRD waits for convergence of routing
	protocols. This option allows to specify a timeout for the recovery to
@@ -2536,6 +2539,9 @@ using the following configuration parameters:
	This option is relevant to IPv4 mode with enabled capability
	advertisement only. Default: on.

	<tag><label id="bgp-advertise-hostname">advertise hostname <m/switch/</tag>
	Advertise hostname capability along with the hostname. Default: off.

	<tag><label id="bgp-disable-after-error">disable after error <m/switch/</tag>
	When an error is encountered (either locally or by the other side),
	disable the instance automatically and wait for an administrator to fix
+1 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ cmd_show_status(void)
  cli_msg(-1000, "BIRD " BIRD_VERSION);
  tm_format_time(tim, &config->tf_base, current_time());
  cli_msg(-1011, "Router ID is %R", config->router_id);
  cli_msg(-1011, "Hostname is %s", config->hostname);
  cli_msg(-1011, "Current server time is %s", tim);
  tm_format_time(tim, &config->tf_base, boot_time);
  cli_msg(-1011, "Last reboot on %s", tim);
+5 −1
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ proto_postconfig(void)

CF_DECLS

CF_KEYWORDS(ROUTER, ID, PROTOCOL, TEMPLATE, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT)
CF_KEYWORDS(ROUTER, ID, HOSTNAME, PROTOCOL, TEMPLATE, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT)
CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, VRF, DEFAULT, TABLE, STATES, ROUTES, FILTERS)
CF_KEYWORDS(IPV4, IPV6, VPN4, VPN6, ROA4, ROA6, FLOW4, FLOW6, SADR, MPLS)
CF_KEYWORDS(RECEIVE, LIMIT, ACTION, WARN, BLOCK, RESTART, DISABLE, KEEP, FILTERED)
@@ -151,6 +151,10 @@ idval:
   }
 ;

conf: hostname_override ;

hostname_override: HOSTNAME text ';' { new_config->hostname = $2; } ;

conf: gr_opts ;

gr_opts: GRACEFUL RESTART WAIT expr ';' { new_config->gr_wait = $4; } ;
Loading