From 714238716ef36f1dfc5721055e2ec4affd42ebfa Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Wed, 10 Feb 2021 16:53:57 +0100 Subject: [PATCH] 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. --- conf/conf.c | 9 +++++++++ conf/conf.h | 1 + doc/bird.sgml | 6 ++++++ nest/cmds.c | 1 + nest/config.Y | 6 +++++- proto/bgp/bgp.c | 4 ++++ proto/bgp/bgp.h | 3 +++ proto/bgp/config.Y | 2 ++ proto/bgp/packets.c | 41 +++++++++++++++++++++++++++++++++++++++++ sysdep/unix/main.c | 16 ++++++++++++++++ sysdep/unix/unix.h | 1 + 11 files changed, 89 insertions(+), 1 deletion(-) diff --git a/conf/conf.c b/conf/conf.c index 6f64b541..58abcde1 100644 --- a/conf/conf.c +++ b/conf/conf.c @@ -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; diff --git a/conf/conf.h b/conf/conf.h index 3e47c918..860d267a 100644 --- a/conf/conf.h +++ b/conf/conf.h @@ -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 */ diff --git a/doc/bird.sgml b/doc/bird.sgml index 28b0e400..5d1df5bc 100644 --- a/doc/bird.sgml +++ b/doc/bird.sgml @@ -585,6 +585,9 @@ include "tablename.conf";; See section for detailed description of interface patterns with extended clauses. +