From 714238716ef36f1dfc5721055e2ec4affd42ebfa Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Wed, 10 Feb 2021 16:53:57 +0100 Subject: 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. --- sysdep/unix/main.c | 16 ++++++++++++++++ sysdep/unix/unix.h | 1 + 2 files changed, 17 insertions(+) (limited to 'sysdep/unix') diff --git a/sysdep/unix/main.c b/sysdep/unix/main.c index 2c7e3cef..67e76655 100644 --- a/sysdep/unix/main.c +++ b/sysdep/unix/main.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "nest/bird.h" @@ -88,6 +89,21 @@ drop_gid(gid_t gid) die("setgroups: %m"); } +/* + * Hostname + */ + +char * +get_hostname(linpool *lp) +{ + struct utsname uts = {}; + + if (uname(&uts) < 0) + return NULL; + + return lp_strdup(lp, uts.nodename); +} + /* * Reading the Configuration */ diff --git a/sysdep/unix/unix.h b/sysdep/unix/unix.h index 0f2973f0..ad85d1ea 100644 --- a/sysdep/unix/unix.h +++ b/sysdep/unix/unix.h @@ -24,6 +24,7 @@ extern int parse_and_exit; void async_config(void); void async_dump(void); void async_shutdown(void); +char *get_hostname(linpool *lp); void cmd_check_config(const char *name); void cmd_reconfig(const char *name, int type, uint timeout); void cmd_reconfig_confirm(void); -- cgit v1.2.3