diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 04:24:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 04:24:31 +0000 |
commit | acb594b1d825c6e12369cebb941968ec08c840ce (patch) | |
tree | d544788908e7353a4f117e2991f15f4236a0c963 /bfdd | |
parent | Adding upstream version 9.1. (diff) | |
download | frr-acb594b1d825c6e12369cebb941968ec08c840ce.tar.xz frr-acb594b1d825c6e12369cebb941968ec08c840ce.zip |
Adding upstream version 10.0.upstream/10.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'bfdd')
-rw-r--r-- | bfdd/bfd.h | 5 | ||||
-rw-r--r-- | bfdd/bfd_packet.c | 5 | ||||
-rw-r--r-- | bfdd/bfdd.c | 28 | ||||
-rw-r--r-- | bfdd/bfdd_cli.c | 12 | ||||
-rw-r--r-- | bfdd/bfdd_nb_config.c | 22 | ||||
-rw-r--r-- | bfdd/control.c | 9 | ||||
-rw-r--r-- | bfdd/ptm_adapter.c | 8 |
7 files changed, 56 insertions, 33 deletions
@@ -32,6 +32,8 @@ DECLARE_MGROUP(BFDD); DECLARE_MTYPE(BFDD_CONTROL); DECLARE_MTYPE(BFDD_NOTIFICATION); +#define BFDD_SOCK_NAME "%s/bfdd.sock", frr_runstatedir + /* bfd Authentication Type. */ #define BFD_AUTH_NULL 0 #define BFD_AUTH_SIMPLE 1 @@ -193,7 +195,7 @@ struct bfd_key { uint16_t mhop; struct in6_addr peer; struct in6_addr local; - char ifname[INTERFACE_NAMSIZ]; + char ifname[IFNAMSIZ]; char vrfname[VRF_NAMSIZ]; } __attribute__((packed)); @@ -782,6 +784,7 @@ void bfdd_cli_init(void); */ void bfdd_zclient_init(struct zebra_privs_t *bfdd_priv); void bfdd_zclient_stop(void); +void bfdd_zclient_terminate(void); void bfdd_zclient_unregister(vrf_id_t vrf_id); void bfdd_zclient_register(vrf_id_t vrf_id); void bfdd_sessions_enable_vrf(struct vrf *vrf); diff --git a/bfdd/bfd_packet.c b/bfdd/bfd_packet.c index 5d8bf47..fec195c 100644 --- a/bfdd/bfd_packet.c +++ b/bfdd/bfd_packet.c @@ -12,6 +12,11 @@ */ #include <zebra.h> +#include <sys/ioctl.h> + +#ifdef GNU_LINUX +#include <linux/filter.h> +#endif #ifdef BFD_LINUX #include <linux/if_packet.h> diff --git a/bfdd/bfdd.c b/bfdd/bfdd.c index 95066b9..243cf5c 100644 --- a/bfdd/bfdd.c +++ b/bfdd/bfdd.c @@ -75,6 +75,8 @@ static void sigterm_handler(void) bfd_vrf_terminate(); + bfdd_zclient_terminate(); + /* Terminate and free() FRR related memory. */ frr_fini(); @@ -115,13 +117,20 @@ static const struct frr_yang_module_info *const bfdd_yang_modules[] = { &frr_vrf_info, }; -FRR_DAEMON_INFO(bfdd, BFD, .vty_port = 2617, - .proghelp = "Implementation of the BFD protocol.", - .signals = bfd_signals, .n_signals = array_size(bfd_signals), - .privs = &bglobal.bfdd_privs, - .yang_modules = bfdd_yang_modules, - .n_yang_modules = array_size(bfdd_yang_modules), +/* clang-format off */ +FRR_DAEMON_INFO(bfdd, BFD, + .vty_port = BFDD_VTY_PORT, + .proghelp = "Implementation of the BFD protocol.", + + .signals = bfd_signals, + .n_signals = array_size(bfd_signals), + + .privs = &bglobal.bfdd_privs, + + .yang_modules = bfdd_yang_modules, + .n_yang_modules = array_size(bfdd_yang_modules), ); +/* clang-format on */ #define OPTION_CTLSOCK 1001 #define OPTION_DPLANEADDR 2000 @@ -333,8 +342,6 @@ int main(int argc, char *argv[]) " --bfdctl Specify bfdd control socket\n" " --dplaneaddr Specify BFD data plane address\n"); - snprintf(ctl_path, sizeof(ctl_path), BFDD_CONTROL_SOCKET, - "", ""); while (true) { opt = frr_getopt(argc, argv, NULL); if (opt == EOF) @@ -355,9 +362,8 @@ int main(int argc, char *argv[]) } } - if (bfdd_di.pathspace && !ctlsockused) - snprintf(ctl_path, sizeof(ctl_path), BFDD_CONTROL_SOCKET, - "/", bfdd_di.pathspace); + if (!ctlsockused) + snprintf(ctl_path, sizeof(ctl_path), BFDD_SOCK_NAME); /* Initialize FRR infrastructure. */ master = frr_init(); diff --git a/bfdd/bfdd_cli.c b/bfdd/bfdd_cli.c index 44439c6..75034d2 100644 --- a/bfdd/bfdd_cli.c +++ b/bfdd/bfdd_cli.c @@ -219,24 +219,24 @@ static void _bfd_cli_show_peer(struct vty *vty, const struct lyd_node *dnode, bool show_defaults __attribute__((__unused__)), bool mhop) { - const char *vrf = yang_dnode_get_string(dnode, "./vrf"); + const char *vrf = yang_dnode_get_string(dnode, "vrf"); vty_out(vty, " peer %s", - yang_dnode_get_string(dnode, "./dest-addr")); + yang_dnode_get_string(dnode, "dest-addr")); if (mhop) vty_out(vty, " multihop"); - if (yang_dnode_exists(dnode, "./source-addr")) + if (yang_dnode_exists(dnode, "source-addr")) vty_out(vty, " local-address %s", - yang_dnode_get_string(dnode, "./source-addr")); + yang_dnode_get_string(dnode, "source-addr")); if (strcmp(vrf, VRF_DEFAULT_NAME)) vty_out(vty, " vrf %s", vrf); if (!mhop) { const char *ifname = - yang_dnode_get_string(dnode, "./interface"); + yang_dnode_get_string(dnode, "interface"); if (strcmp(ifname, "*")) vty_out(vty, " interface %s", ifname); } @@ -567,7 +567,7 @@ DEFPY_YANG(no_bfd_profile, no_bfd_profile_cmd, void bfd_cli_show_profile(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { - vty_out(vty, " profile %s\n", yang_dnode_get_string(dnode, "./name")); + vty_out(vty, " profile %s\n", yang_dnode_get_string(dnode, "name")); } ALIAS_YANG(bfd_peer_mult, bfd_profile_mult_cmd, diff --git a/bfdd/bfdd_nb_config.c b/bfdd/bfdd_nb_config.c index 8cf2f0a..48fbe71 100644 --- a/bfdd/bfdd_nb_config.c +++ b/bfdd/bfdd_nb_config.c @@ -24,17 +24,17 @@ static void bfd_session_get_key(bool mhop, const struct lyd_node *dnode, struct sockaddr_any psa, lsa; /* Required destination parameter. */ - strtosa(yang_dnode_get_string(dnode, "./dest-addr"), &psa); + strtosa(yang_dnode_get_string(dnode, "dest-addr"), &psa); /* Get optional source address. */ memset(&lsa, 0, sizeof(lsa)); - if (yang_dnode_exists(dnode, "./source-addr")) - strtosa(yang_dnode_get_string(dnode, "./source-addr"), &lsa); + if (yang_dnode_exists(dnode, "source-addr")) + strtosa(yang_dnode_get_string(dnode, "source-addr"), &lsa); - vrfname = yang_dnode_get_string(dnode, "./vrf"); + vrfname = yang_dnode_get_string(dnode, "vrf"); if (!mhop) { - ifname = yang_dnode_get_string(dnode, "./interface"); + ifname = yang_dnode_get_string(dnode, "interface"); if (strcmp(ifname, "*") == 0) ifname = NULL; } @@ -53,7 +53,7 @@ static int session_iter_cb(const struct lyd_node *dnode, void *arg) struct session_iter *iter = arg; const char *ifname; - ifname = yang_dnode_get_string(dnode, "./interface"); + ifname = yang_dnode_get_string(dnode, "interface"); if (strmatch(ifname, "*")) iter->wildcard = true; @@ -76,7 +76,7 @@ static int bfd_session_create(struct nb_cb_create_args *args, bool mhop) switch (args->event) { case NB_EV_VALIDATE: - yang_dnode_get_prefix(&p, args->dnode, "./dest-addr"); + yang_dnode_get_prefix(&p, args->dnode, "dest-addr"); if (mhop) { /* @@ -97,7 +97,7 @@ static int bfd_session_create(struct nb_cb_create_args *args, bool mhop) * require interface name, otherwise we can't figure * which interface to use to send the packets. */ - ifname = yang_dnode_get_string(args->dnode, "./interface"); + ifname = yang_dnode_get_string(args->dnode, "interface"); if (p.family == AF_INET6 && IN6_IS_ADDR_LINKLOCAL(&p.u.prefix6) && strcmp(ifname, "*") == 0) { @@ -112,8 +112,8 @@ static int bfd_session_create(struct nb_cb_create_args *args, bool mhop) sess_dnode = yang_dnode_get_parent(args->dnode, "sessions"); - dest = yang_dnode_get_string(args->dnode, "./dest-addr"); - vrfname = yang_dnode_get_string(args->dnode, "./vrf"); + dest = yang_dnode_get_string(args->dnode, "dest-addr"); + vrfname = yang_dnode_get_string(args->dnode, "vrf"); yang_dnode_iterate(session_iter_cb, &iter, sess_dnode, "./single-hop[dest-addr='%s'][vrf='%s']", @@ -275,7 +275,7 @@ int bfdd_bfd_profile_create(struct nb_cb_create_args *args) if (args->event != NB_EV_APPLY) return NB_OK; - name = yang_dnode_get_string(args->dnode, "./name"); + name = yang_dnode_get_string(args->dnode, "name"); bp = bfd_profile_new(name); nb_running_set_entry(args->dnode, bp); diff --git a/bfdd/control.c b/bfdd/control.c index f435358..98fd813 100644 --- a/bfdd/control.c +++ b/bfdd/control.c @@ -12,6 +12,9 @@ #include <zebra.h> +#include <fcntl.h> +#include <sys/stat.h> + #include <sys/un.h> #include "bfd.h" @@ -92,11 +95,11 @@ int control_init(const char *path) mode_t umval; struct sockaddr_un sun_ = { .sun_family = AF_UNIX, - .sun_path = BFDD_CONTROL_SOCKET, }; - if (path) - strlcpy(sun_.sun_path, path, sizeof(sun_.sun_path)); + assert(path); + + strlcpy(sun_.sun_path, path, sizeof(sun_.sun_path)); /* Remove previously created sockets. */ unlink(sun_.sun_path); diff --git a/bfdd/ptm_adapter.c b/bfdd/ptm_adapter.c index 9e7ed11..b5ab2ef 100644 --- a/bfdd/ptm_adapter.c +++ b/bfdd/ptm_adapter.c @@ -826,7 +826,8 @@ static zclient_handler *const bfd_handlers[] = { void bfdd_zclient_init(struct zebra_privs_t *bfdd_priv) { - if_zapi_callbacks(bfd_ifp_create, NULL, NULL, bfd_ifp_destroy); + hook_register_prio(if_real, 0, bfd_ifp_create); + hook_register_prio(if_unreal, 0, bfd_ifp_destroy); zclient = zclient_new(master, &zclient_options_default, bfd_handlers, array_size(bfd_handlers)); assert(zclient != NULL); @@ -858,6 +859,11 @@ void bfdd_zclient_stop(void) pc_free_all(); } +void bfdd_zclient_terminate(void) +{ + zclient_free(zclient); +} + /* * Client handling. |