mirror of
https://github.com/FRRouting/frr.git
synced 2025-04-30 13:37:17 +02:00
lib: introduce global -w option for VRF netns backend
Current -n option is only for zebra and mgmtd. All other daemons receive the VRF backend configuration from zebra upon connection to it. This leads to a potential race condition - daemons need to know the backend before they start reading their config, but they can be not connected to zebra yet at this point. As the VRF backend cannot change during runtime, let's introduce a new global -w option for setting netns backend, to make sure that all daemons know their VRF backend immediately after start. The reason for introducing a new option instead of making -n global is that ospfd already uses -n for another purposes. Signed-off-by: Igor Ryzhov <idryzhov@gmail.com>
This commit is contained in:
parent
6f214d97d1
commit
300f8dbda4
|
@ -38,6 +38,8 @@ OPTIONS available for the |DAEMON| command:
|
|||
|
||||
Enable namespace VRF backend. By default, the VRF backend relies on VRF-lite support from the Linux kernel. This option permits discovering Linux named network namespaces and mapping it to FRR VRF contexts.
|
||||
|
||||
This option is deprecated. Please use the global -w option instead.
|
||||
|
||||
ROUTES
|
||||
------
|
||||
|
||||
|
|
|
@ -754,6 +754,17 @@ These options apply to all |PACKAGE_NAME| daemons.
|
|||
be added to all files that use the statedir. If you have "/var/run/frr"
|
||||
as the default statedir then it will become "/var/run/frr/<namespace>".
|
||||
|
||||
.. option:: -w, --vrfwnetns
|
||||
|
||||
Enable namespace VRF backend. By default, the VRF backend relies on VRF-lite
|
||||
support from the Linux kernel. This option permits discovering Linux named
|
||||
network namespaces and mapping them to FRR VRF contexts. This option must be
|
||||
the same for all running daemons. The easiest way to pass the same option to
|
||||
all daemons is to use the ``frr_global_options`` variable in the
|
||||
:ref:`Daemons Configuration File <daemons-configuration-file>`.
|
||||
|
||||
.. seealso:: :ref:`zebra-vrf`
|
||||
|
||||
.. option:: -o, --vrfdefaultname <name>
|
||||
|
||||
Set the name used for the *Default VRF* in CLI commands and YANG models.
|
||||
|
|
|
@ -53,6 +53,8 @@ Besides the common invocation options (:ref:`common-invocation-options`), the
|
|||
VRF defined by *Zebra*, as usual. If this option is specified when running
|
||||
*Zebra*, one must also specify the same option for *mgmtd*.
|
||||
|
||||
This options is deprecated. Please use the global -w option instead.
|
||||
|
||||
.. seealso:: :ref:`zebra-vrf`
|
||||
|
||||
.. option:: -z <path_to_socket>, --socket <path_to_socket>
|
||||
|
|
14
lib/libfrr.c
14
lib/libfrr.c
|
@ -108,6 +108,9 @@ static const struct option lo_always[] = {
|
|||
{ "module", no_argument, NULL, 'M' },
|
||||
{ "profile", required_argument, NULL, 'F' },
|
||||
{ "pathspace", required_argument, NULL, 'N' },
|
||||
#ifdef HAVE_NETLINK
|
||||
{ "vrfwnetns", no_argument, NULL, 'w' },
|
||||
#endif
|
||||
{ "vrfdefaultname", required_argument, NULL, 'o' },
|
||||
{ "graceful_restart", optional_argument, NULL, 'K' },
|
||||
{ "vty_socket", required_argument, NULL, OPTION_VTYSOCK },
|
||||
|
@ -120,6 +123,9 @@ static const struct option lo_always[] = {
|
|||
{ NULL }
|
||||
};
|
||||
static const struct optspec os_always = {
|
||||
#ifdef HAVE_NETLINK
|
||||
"w"
|
||||
#endif
|
||||
"hvdM:F:N:o:K::",
|
||||
" -h, --help Display this help and exit\n"
|
||||
" -v, --version Print program version\n"
|
||||
|
@ -127,6 +133,9 @@ static const struct optspec os_always = {
|
|||
" -M, --module Load specified module\n"
|
||||
" -F, --profile Use specified configuration profile\n"
|
||||
" -N, --pathspace Insert prefix into config & socket paths\n"
|
||||
#ifdef HAVE_NETLINK
|
||||
" -w, --vrfwnetns Use network namespaces for VRFs\n"
|
||||
#endif
|
||||
" -o, --vrfdefaultname Set default VRF name.\n"
|
||||
" -K, --graceful_restart FRR starting in Graceful Restart mode, with optional route-cleanup timer\n"
|
||||
" --vty_socket Override vty socket path\n"
|
||||
|
@ -516,6 +525,11 @@ static int frr_opt(int opt)
|
|||
snprintf(frr_zclientpath, sizeof(frr_zclientpath),
|
||||
ZAPI_SOCK_NAME);
|
||||
break;
|
||||
#ifdef HAVE_NETLINK
|
||||
case 'w':
|
||||
vrf_configure_backend(VRF_BACKEND_NETNS);
|
||||
break;
|
||||
#endif
|
||||
case 'o':
|
||||
vrf_set_default_name(optarg);
|
||||
break;
|
||||
|
|
|
@ -238,10 +238,9 @@ int main(int argc, char **argv)
|
|||
int buffer_size = MGMTD_SOCKET_BUF_SIZE;
|
||||
|
||||
frr_preinit(&mgmtd_di, argc, argv);
|
||||
frr_opt_add(
|
||||
"s:n" DEPRECATED_OPTIONS, longopts,
|
||||
frr_opt_add("s:n" DEPRECATED_OPTIONS, longopts,
|
||||
" -s, --socket_size Set MGMTD peer socket send buffer size\n"
|
||||
" -n, --vrfwnetns Use NetNS as VRF backend\n");
|
||||
" -n, --vrfwnetns Use NetNS as VRF backend (deprecated, use -w)\n");
|
||||
|
||||
/* Command line argument treatment. */
|
||||
while (1) {
|
||||
|
@ -264,6 +263,8 @@ int main(int argc, char **argv)
|
|||
buffer_size = atoi(optarg);
|
||||
break;
|
||||
case 'n':
|
||||
fprintf(stderr,
|
||||
"The -n option is deprecated, please use global -w option instead.\n");
|
||||
vrf_configure_backend(VRF_BACKEND_NETNS);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -377,7 +377,7 @@ int main(int argc, char **argv)
|
|||
" --v6-with-v4-nexthops Underlying dataplane supports v6 routes with v4 nexthops\n"
|
||||
#ifdef HAVE_NETLINK
|
||||
" -s, --nl-bufsize Set netlink receive buffer size\n"
|
||||
" -n, --vrfwnetns Use NetNS as VRF backend\n"
|
||||
" -n, --vrfwnetns Use NetNS as VRF backend (deprecated, use -w)\n"
|
||||
" --v6-rr-semantics Use v6 RR semantics\n"
|
||||
#else
|
||||
" -s, Set kernel socket receive buffer size\n"
|
||||
|
@ -438,6 +438,8 @@ int main(int argc, char **argv)
|
|||
break;
|
||||
#ifdef HAVE_NETLINK
|
||||
case 'n':
|
||||
fprintf(stderr,
|
||||
"The -n option is deprecated, please use global -w option instead.\n");
|
||||
vrf_configure_backend(VRF_BACKEND_NETNS);
|
||||
break;
|
||||
case OPTION_V6_RR_SEMANTICS:
|
||||
|
|
Loading…
Reference in a new issue