mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-27 11:44:16 +00:00
Merge pull request #388 from opensourcerouting/snap-fixes-3.0
Snap fixes 3.0
This commit is contained in:
commit
e9e27161c3
21
lib/libfrr.c
21
lib/libfrr.c
@ -34,6 +34,7 @@ DEFINE_HOOK(frr_late_init, (struct thread_master *tm), (tm))
|
|||||||
|
|
||||||
const char frr_sysconfdir[] = SYSCONFDIR;
|
const char frr_sysconfdir[] = SYSCONFDIR;
|
||||||
const char frr_vtydir[] = DAEMON_VTY_DIR;
|
const char frr_vtydir[] = DAEMON_VTY_DIR;
|
||||||
|
const char frr_moduledir[] = MODULE_PATH;
|
||||||
|
|
||||||
char config_default[256];
|
char config_default[256];
|
||||||
static char pidfile_default[256];
|
static char pidfile_default[256];
|
||||||
@ -61,7 +62,8 @@ static void opt_extend(const struct optspec *os)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define OPTION_VTYSOCK 1000
|
#define OPTION_VTYSOCK 1000
|
||||||
|
#define OPTION_MODULEDIR 1002
|
||||||
|
|
||||||
static const struct option lo_always[] = {
|
static const struct option lo_always[] = {
|
||||||
{ "help", no_argument, NULL, 'h' },
|
{ "help", no_argument, NULL, 'h' },
|
||||||
@ -69,6 +71,7 @@ static const struct option lo_always[] = {
|
|||||||
{ "daemon", no_argument, NULL, 'd' },
|
{ "daemon", no_argument, NULL, 'd' },
|
||||||
{ "module", no_argument, NULL, 'M' },
|
{ "module", no_argument, NULL, 'M' },
|
||||||
{ "vty_socket", required_argument, NULL, OPTION_VTYSOCK },
|
{ "vty_socket", required_argument, NULL, OPTION_VTYSOCK },
|
||||||
|
{ "moduledir", required_argument, NULL, OPTION_MODULEDIR },
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
static const struct optspec os_always = {
|
static const struct optspec os_always = {
|
||||||
@ -77,7 +80,8 @@ static const struct optspec os_always = {
|
|||||||
" -v, --version Print program version\n"
|
" -v, --version Print program version\n"
|
||||||
" -d, --daemon Runs in daemon mode\n"
|
" -d, --daemon Runs in daemon mode\n"
|
||||||
" -M, --module Load specified module\n"
|
" -M, --module Load specified module\n"
|
||||||
" --vty_socket Override vty socket path\n",
|
" --vty_socket Override vty socket path\n"
|
||||||
|
" --moduledir Override modules directory\n",
|
||||||
lo_always
|
lo_always
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -193,6 +197,7 @@ struct option_chain {
|
|||||||
struct option_chain *next;
|
struct option_chain *next;
|
||||||
const char *arg;
|
const char *arg;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct option_chain *modules = NULL, **modnext = &modules;
|
static struct option_chain *modules = NULL, **modnext = &modules;
|
||||||
static int errors = 0;
|
static int errors = 0;
|
||||||
|
|
||||||
@ -277,6 +282,14 @@ static int frr_opt(int opt)
|
|||||||
}
|
}
|
||||||
di->vty_sock_path = optarg;
|
di->vty_sock_path = optarg;
|
||||||
break;
|
break;
|
||||||
|
case OPTION_MODULEDIR:
|
||||||
|
if (di->module_path) {
|
||||||
|
fprintf(stderr, "----moduledir option specified more than once!\n");
|
||||||
|
errors++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
di->module_path = optarg;
|
||||||
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
if (di->flags & FRR_NO_PRIVSEP)
|
if (di->flags & FRR_NO_PRIVSEP)
|
||||||
return 1;
|
return 1;
|
||||||
@ -319,6 +332,8 @@ struct thread_master *frr_init(void)
|
|||||||
struct option_chain *oc;
|
struct option_chain *oc;
|
||||||
struct frrmod_runtime *module;
|
struct frrmod_runtime *module;
|
||||||
char moderr[256];
|
char moderr[256];
|
||||||
|
const char *dir;
|
||||||
|
dir = di->module_path ? di->module_path : frr_moduledir;
|
||||||
|
|
||||||
srandom(time(NULL));
|
srandom(time(NULL));
|
||||||
|
|
||||||
@ -331,7 +346,7 @@ struct thread_master *frr_init(void)
|
|||||||
frrmod_init(di->module);
|
frrmod_init(di->module);
|
||||||
while (modules) {
|
while (modules) {
|
||||||
modules = (oc = modules)->next;
|
modules = (oc = modules)->next;
|
||||||
module = frrmod_load(oc->arg, moderr, sizeof(moderr));
|
module = frrmod_load(oc->arg, dir, moderr, sizeof(moderr));
|
||||||
if (!module) {
|
if (!module) {
|
||||||
fprintf(stderr, "%s\n", moderr);
|
fprintf(stderr, "%s\n", moderr);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -52,6 +52,7 @@ struct frr_daemon_info {
|
|||||||
const char *config_file;
|
const char *config_file;
|
||||||
const char *pid_file;
|
const char *pid_file;
|
||||||
const char *vty_path;
|
const char *vty_path;
|
||||||
|
const char *module_path;
|
||||||
|
|
||||||
const char *proghelp;
|
const char *proghelp;
|
||||||
void (*printhelp)(FILE *target);
|
void (*printhelp)(FILE *target);
|
||||||
@ -107,5 +108,6 @@ extern void frr_run(struct thread_master *master);
|
|||||||
extern char config_default[256];
|
extern char config_default[256];
|
||||||
extern const char frr_sysconfdir[];
|
extern const char frr_sysconfdir[];
|
||||||
extern const char frr_vtydir[];
|
extern const char frr_vtydir[];
|
||||||
|
extern const char frr_moduledir[];
|
||||||
|
|
||||||
#endif /* _ZEBRA_FRR_H */
|
#endif /* _ZEBRA_FRR_H */
|
||||||
|
@ -69,7 +69,7 @@ void frrmod_init(struct frrmod_runtime *modinfo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct frrmod_runtime *frrmod_load(const char *spec,
|
struct frrmod_runtime *frrmod_load(const char *spec,
|
||||||
char *err, size_t err_len)
|
const char *dir, char *err, size_t err_len)
|
||||||
{
|
{
|
||||||
void *handle = NULL;
|
void *handle = NULL;
|
||||||
char name[PATH_MAX], fullpath[PATH_MAX], *args;
|
char name[PATH_MAX], fullpath[PATH_MAX], *args;
|
||||||
@ -84,12 +84,12 @@ struct frrmod_runtime *frrmod_load(const char *spec,
|
|||||||
if (!strchr(name, '/')) {
|
if (!strchr(name, '/')) {
|
||||||
if (!handle && execname) {
|
if (!handle && execname) {
|
||||||
snprintf(fullpath, sizeof(fullpath), "%s/%s_%s.so",
|
snprintf(fullpath, sizeof(fullpath), "%s/%s_%s.so",
|
||||||
MODULE_PATH, execname, name);
|
dir, execname, name);
|
||||||
handle = dlopen(fullpath, RTLD_NOW | RTLD_GLOBAL);
|
handle = dlopen(fullpath, RTLD_NOW | RTLD_GLOBAL);
|
||||||
}
|
}
|
||||||
if (!handle) {
|
if (!handle) {
|
||||||
snprintf(fullpath, sizeof(fullpath), "%s/%s.so",
|
snprintf(fullpath, sizeof(fullpath), "%s/%s.so",
|
||||||
MODULE_PATH, name);
|
dir, name);
|
||||||
handle = dlopen(fullpath, RTLD_NOW | RTLD_GLOBAL);
|
handle = dlopen(fullpath, RTLD_NOW | RTLD_GLOBAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ extern struct frrmod_runtime *frrmod_list;
|
|||||||
|
|
||||||
extern void frrmod_init(struct frrmod_runtime *modinfo);
|
extern void frrmod_init(struct frrmod_runtime *modinfo);
|
||||||
extern struct frrmod_runtime *frrmod_load(const char *spec,
|
extern struct frrmod_runtime *frrmod_load(const char *spec,
|
||||||
char *err, size_t err_len);
|
const char *dir, char *err, size_t err_len);
|
||||||
#if 0
|
#if 0
|
||||||
/* not implemented yet */
|
/* not implemented yet */
|
||||||
extern void frrmod_unload(struct frrmod_runtime *module);
|
extern void frrmod_unload(struct frrmod_runtime *module);
|
||||||
|
@ -47,8 +47,10 @@ Installing the snap
|
|||||||
|
|
||||||
Connect the priviledged `network-control` plug to the snap:
|
Connect the priviledged `network-control` plug to the snap:
|
||||||
|
|
||||||
snap connect frr:network-control ubuntu-core:network-control
|
snap connect frr:network-control core:network-control
|
||||||
|
|
||||||
|
See README.usage.md for more details on setting up and using the snap
|
||||||
|
|
||||||
DONE.
|
DONE.
|
||||||
|
|
||||||
The Snap will be auto-started and running.
|
The Snap will be auto-started and running.
|
||||||
|
@ -30,6 +30,8 @@ Commands defined by this snap
|
|||||||
options
|
options
|
||||||
- `frr.readme`:
|
- `frr.readme`:
|
||||||
Returns this document `cat README_usage.md`
|
Returns this document `cat README_usage.md`
|
||||||
|
- `frr.set`:
|
||||||
|
Allows to enable `FPM` module. See FPM section below
|
||||||
|
|
||||||
and for debugging defined at this time (May get removed later - do not
|
and for debugging defined at this time (May get removed later - do not
|
||||||
depend on them). These are mainly intended to debug the Snap
|
depend on them). These are mainly intended to debug the Snap
|
||||||
@ -86,6 +88,20 @@ are named `eth0`, `eth1` and `eth2`, then the additional lines in
|
|||||||
These settings require either a reboot or a manual configuration with
|
These settings require either a reboot or a manual configuration with
|
||||||
`sysctl` as well.
|
`sysctl` as well.
|
||||||
|
|
||||||
|
FPM Module
|
||||||
|
----------
|
||||||
|
The `frr.set` allows to turn FPM module on or off.
|
||||||
|
|
||||||
|
frr.set fpm {disable|protobuf|netlink}
|
||||||
|
|
||||||
|
Disables FPM or enables FPM with selected mode
|
||||||
|
|
||||||
|
By default, the FPM module is disabled, but installed with netlink and
|
||||||
|
protobuf support. To enable the FPM module, use the `frr.set fpm protobuf`
|
||||||
|
or `frr.set fpm netlink` command. The command will only enable the mode
|
||||||
|
for the next restart of zebra. Please reboot or restart zebra after
|
||||||
|
changing the mode to become effective.
|
||||||
|
|
||||||
FAQ
|
FAQ
|
||||||
---
|
---
|
||||||
- frr.vtysh displays `--MORE--` on long output. How to suppress this?
|
- frr.vtysh displays `--MORE--` on long output. How to suppress this?
|
||||||
|
0
snapcraft/defaults/nhrpd.conf.default
Normal file
0
snapcraft/defaults/nhrpd.conf.default
Normal file
@ -11,4 +11,5 @@ install:
|
|||||||
install -D -m 0755 isisd-service $(DESTDIR)/bin/
|
install -D -m 0755 isisd-service $(DESTDIR)/bin/
|
||||||
install -D -m 0755 pimd-service $(DESTDIR)/bin/
|
install -D -m 0755 pimd-service $(DESTDIR)/bin/
|
||||||
install -D -m 0755 ldpd-service $(DESTDIR)/bin/
|
install -D -m 0755 ldpd-service $(DESTDIR)/bin/
|
||||||
|
install -D -m 0755 nhrpd-service $(DESTDIR)/bin/
|
||||||
|
install -D -m 0755 set-options $(DESTDIR)/bin/
|
||||||
|
12
snapcraft/scripts/nhrpd-service
Normal file
12
snapcraft/scripts/nhrpd-service
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e -x
|
||||||
|
|
||||||
|
if ! [ -e $SNAP_DATA/nhrpd.conf ]; then
|
||||||
|
cp $SNAP/etc/frr/nhrpd.conf.default $SNAP_DATA/nhrpd.conf
|
||||||
|
fi
|
||||||
|
exec $SNAP/sbin/nhrpd \
|
||||||
|
-f $SNAP_DATA/nhrpd.conf \
|
||||||
|
--pid_file $SNAP_DATA/nhrpd.pid \
|
||||||
|
--socket $SNAP_DATA/zsock \
|
||||||
|
--vty_socket $SNAP_DATA
|
40
snapcraft/scripts/set-options
Executable file
40
snapcraft/scripts/set-options
Executable file
@ -0,0 +1,40 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
fpm)
|
||||||
|
case $2 in
|
||||||
|
disable)
|
||||||
|
rm -f $SNAP_DATA/fpm.conf
|
||||||
|
echo "FPM module disabled. Please restart FRR"
|
||||||
|
;;
|
||||||
|
protobuf)
|
||||||
|
echo "-M fpm:protobuf" > $SNAP_DATA/fpm.conf
|
||||||
|
echo "FPM enabled and set to protobuf mode. Please restart FRR"
|
||||||
|
;;
|
||||||
|
netlink)
|
||||||
|
echo "-M fpm:netlink" > $SNAP_DATA/fpm.conf
|
||||||
|
echo "FPM enabled and set to netlink mode. Please restart FRR"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage:"
|
||||||
|
echo " ${SNAP_NAME}.set fpm {disable|protobuf|netlink}"
|
||||||
|
echo ""
|
||||||
|
echo " Disables FPM module or enables it with specified mode"
|
||||||
|
echo " Mode will be saved for next restart of zebra, but zebra"
|
||||||
|
echo " is not automatically restarted"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage:"
|
||||||
|
echo " ${SNAP_NAME}.set fpm {disable|protobuf|netlink}"
|
||||||
|
echo ""
|
||||||
|
echo " Disables FPM or enables FPM with selected mode"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit 0
|
@ -8,9 +8,13 @@ fi
|
|||||||
if ! [ -e $SNAP_DATA/vtysh.conf ]; then
|
if ! [ -e $SNAP_DATA/vtysh.conf ]; then
|
||||||
cp $SNAP/etc/frr/vtysh.conf.default $SNAP_DATA/vtysh.conf
|
cp $SNAP/etc/frr/vtysh.conf.default $SNAP_DATA/vtysh.conf
|
||||||
fi
|
fi
|
||||||
|
EXTRA_OPTIONS=""
|
||||||
|
if [ -e $SNAP_DATA/fpm.conf ]; then
|
||||||
|
EXTRA_OPTIONS="`cat $SNAP_DATA/fpm.conf`"
|
||||||
|
fi
|
||||||
exec $SNAP/sbin/zebra \
|
exec $SNAP/sbin/zebra \
|
||||||
-f $SNAP_DATA/zebra.conf \
|
-f $SNAP_DATA/zebra.conf \
|
||||||
--pid_file $SNAP_DATA/zebra.pid \
|
--pid_file $SNAP_DATA/zebra.pid \
|
||||||
--socket $SNAP_DATA/zsock \
|
--socket $SNAP_DATA/zsock \
|
||||||
--vty_socket $SNAP_DATA
|
--vty_socket $SNAP_DATA \
|
||||||
|
--moduledir $SNAP/lib/frr/modules $EXTRA_OPTIONS
|
||||||
|
@ -83,6 +83,15 @@ apps:
|
|||||||
- network
|
- network
|
||||||
- network-bind
|
- network-bind
|
||||||
- network-control
|
- network-control
|
||||||
|
nhrpd:
|
||||||
|
command: bin/nhrpd-service
|
||||||
|
daemon: simple
|
||||||
|
plugs:
|
||||||
|
- network
|
||||||
|
- network-bind
|
||||||
|
- network-control
|
||||||
|
set:
|
||||||
|
command: bin/set-options
|
||||||
zebra-debug:
|
zebra-debug:
|
||||||
command: sbin/zebra -f $SNAP_DATA/zebra.conf --pid_file $SNAP_DATA/zebra.pid --socket $SNAP_DATA/zsock --vty_socket $SNAP_DATA
|
command: sbin/zebra -f $SNAP_DATA/zebra.conf --pid_file $SNAP_DATA/zebra.pid --socket $SNAP_DATA/zsock --vty_socket $SNAP_DATA
|
||||||
plugs:
|
plugs:
|
||||||
@ -132,12 +141,18 @@ apps:
|
|||||||
- network-bind
|
- network-bind
|
||||||
- network-control
|
- network-control
|
||||||
ldpd-debug:
|
ldpd-debug:
|
||||||
command: sbin/ldpd -f $SNAP_DATA/pimd.conf --pid_file $SNAP_DATA/pimd.pid --socket $SNAP_DATA/zsock --ctl_socket $SNAP_DATA --vty_socket $SNAP_DATA
|
command: sbin/ldpd -f $SNAP_DATA/ldpd.conf --pid_file $SNAP_DATA/ldpd.pid --socket $SNAP_DATA/zsock --ctl_socket $SNAP_DATA --vty_socket $SNAP_DATA
|
||||||
plugs:
|
plugs:
|
||||||
- network
|
- network
|
||||||
- network-bind
|
- network-bind
|
||||||
- network-control
|
- network-control
|
||||||
|
nhrpd-debug:
|
||||||
|
command: sbin/nhrpd -f $SNAP_DATA/nhrpd.conf --pid_file $SNAP_DATA/nhrpd.pid --socket $SNAP_DATA/zsock --vty_socket $SNAP_DATA
|
||||||
|
plugs:
|
||||||
|
- network
|
||||||
|
- network-bind
|
||||||
|
- network-control
|
||||||
|
|
||||||
parts:
|
parts:
|
||||||
frr:
|
frr:
|
||||||
build-packages:
|
build-packages:
|
||||||
@ -148,7 +163,6 @@ parts:
|
|||||||
- gawk
|
- gawk
|
||||||
- libreadline-dev
|
- libreadline-dev
|
||||||
- texinfo
|
- texinfo
|
||||||
- dejagnu
|
|
||||||
- libncurses5-dev
|
- libncurses5-dev
|
||||||
- texlive-latex-base
|
- texlive-latex-base
|
||||||
- texlive-generic-recommended
|
- texlive-generic-recommended
|
||||||
@ -161,6 +175,11 @@ parts:
|
|||||||
- chrpath
|
- chrpath
|
||||||
- pkg-config
|
- pkg-config
|
||||||
- libjson-c-dev
|
- libjson-c-dev
|
||||||
|
- libc-ares-dev
|
||||||
|
- bison
|
||||||
|
- flex
|
||||||
|
- python3-dev
|
||||||
|
- protobuf-c-compiler
|
||||||
stage-packages:
|
stage-packages:
|
||||||
- coreutils
|
- coreutils
|
||||||
- iproute2
|
- iproute2
|
||||||
@ -192,6 +211,8 @@ parts:
|
|||||||
- --enable-group=root
|
- --enable-group=root
|
||||||
- --enable-pimd
|
- --enable-pimd
|
||||||
- --enable-ldpd
|
- --enable-ldpd
|
||||||
|
- --enable-fpm
|
||||||
|
- --enable-protobuf
|
||||||
- --enable-configfile-mask=0640
|
- --enable-configfile-mask=0640
|
||||||
- --enable-logfile-mask=0640
|
- --enable-logfile-mask=0640
|
||||||
- --localstatedir=/var/run
|
- --localstatedir=/var/run
|
||||||
@ -212,6 +233,7 @@ parts:
|
|||||||
ripd.conf.default: etc/frr/ripd.conf.default
|
ripd.conf.default: etc/frr/ripd.conf.default
|
||||||
ripngd.conf.default: etc/frr/ripngd.conf.default
|
ripngd.conf.default: etc/frr/ripngd.conf.default
|
||||||
ldpd.conf.default: etc/frr/ldpd.conf.default
|
ldpd.conf.default: etc/frr/ldpd.conf.default
|
||||||
|
nhrpd.conf.default: etc/frr/nhrpd.conf.default
|
||||||
vtysh.conf.default: etc/frr/vtysh.conf.default
|
vtysh.conf.default: etc/frr/vtysh.conf.default
|
||||||
frr-scripts:
|
frr-scripts:
|
||||||
plugin: make
|
plugin: make
|
||||||
|
Loading…
Reference in New Issue
Block a user