rtsol: introduce an 'always' script
In addition to the 'M' and 'O' scripts (for when 'Managed' and 'Other' flags are set) also introduce an 'always' script that is called for any router advertisement (so even if M and O are not set). This is primarly useful for systems like pfSense that wish to be informed of routers for further system configuration. See also https://redmine.pfsense.org/issues/14072 Reviewed by: melifaro Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D39931
This commit is contained in:
parent
a1d71cebc0
commit
476babaea7
@ -81,6 +81,7 @@ static char *make_rsid(const char *, const char *, struct rainfo *);
|
|||||||
|
|
||||||
#define _ARGS_MANAGED managedconf_script, ifi->ifname, rasender
|
#define _ARGS_MANAGED managedconf_script, ifi->ifname, rasender
|
||||||
#define _ARGS_OTHER otherconf_script, ifi->ifname, rasender
|
#define _ARGS_OTHER otherconf_script, ifi->ifname, rasender
|
||||||
|
#define _ARGS_ALWAYS alwaysconf_script, ifi->ifname, rasender
|
||||||
#define _ARGS_RESADD resolvconf_script, "-a", rsid
|
#define _ARGS_RESADD resolvconf_script, "-a", rsid
|
||||||
#define _ARGS_RESDEL resolvconf_script, "-d", rsid
|
#define _ARGS_RESDEL resolvconf_script, "-d", rsid
|
||||||
|
|
||||||
@ -327,6 +328,17 @@ rtsol_input(int sock)
|
|||||||
if (!ifi->managedconfig)
|
if (!ifi->managedconfig)
|
||||||
CALL_SCRIPT(OTHER, NULL);
|
CALL_SCRIPT(OTHER, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* "Always" script.
|
||||||
|
*/
|
||||||
|
if (!ifi->alwaysconfig) {
|
||||||
|
const char *rasender = inet_ntop(AF_INET6, &from.sin6_addr,
|
||||||
|
ntopbuf, sizeof(ntopbuf));
|
||||||
|
ifi->alwaysconfig = 1;
|
||||||
|
CALL_SCRIPT(ALWAYS, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
clock_gettime(CLOCK_MONOTONIC_FAST, &now);
|
clock_gettime(CLOCK_MONOTONIC_FAST, &now);
|
||||||
newent_rai = 0;
|
newent_rai = 0;
|
||||||
rai = find_rainfo(ifi, &from);
|
rai = find_rainfo(ifi, &from);
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd December 15, 2021
|
.Dd May 2, 2023
|
||||||
.Dt RTSOLD 8
|
.Dt RTSOLD 8
|
||||||
.Os
|
.Os
|
||||||
.\"
|
.\"
|
||||||
@ -42,6 +42,7 @@
|
|||||||
.Op Fl dDfFimu1
|
.Op Fl dDfFimu1
|
||||||
.Op Fl M Ar script-name
|
.Op Fl M Ar script-name
|
||||||
.Op Fl O Ar script-name
|
.Op Fl O Ar script-name
|
||||||
|
.Op Fl A Ar script-name
|
||||||
.Op Fl p Ar pidfile
|
.Op Fl p Ar pidfile
|
||||||
.Op Fl R Ar script-name
|
.Op Fl R Ar script-name
|
||||||
.Ar interface ...
|
.Ar interface ...
|
||||||
@ -49,6 +50,7 @@
|
|||||||
.Op Fl dDfFimu1
|
.Op Fl dDfFimu1
|
||||||
.Op Fl M Ar script-name
|
.Op Fl M Ar script-name
|
||||||
.Op Fl O Ar script-name
|
.Op Fl O Ar script-name
|
||||||
|
.Op Fl A Ar script-name
|
||||||
.Op Fl p Ar pidfile
|
.Op Fl p Ar pidfile
|
||||||
.Op Fl R Ar script-name
|
.Op Fl R Ar script-name
|
||||||
.Fl a
|
.Fl a
|
||||||
@ -56,12 +58,14 @@
|
|||||||
.Op Fl dDiu
|
.Op Fl dDiu
|
||||||
.Op Fl M Ar script-name
|
.Op Fl M Ar script-name
|
||||||
.Op Fl O Ar script-name
|
.Op Fl O Ar script-name
|
||||||
|
.Op Fl A Ar script-name
|
||||||
.Op Fl R Ar script-name
|
.Op Fl R Ar script-name
|
||||||
.Ar interface ...
|
.Ar interface ...
|
||||||
.Nm rtsol
|
.Nm rtsol
|
||||||
.Op Fl dDiu
|
.Op Fl dDiu
|
||||||
.Op Fl M Ar script-name
|
.Op Fl M Ar script-name
|
||||||
.Op Fl O Ar script-name
|
.Op Fl O Ar script-name
|
||||||
|
.Op Fl A Ar script-name
|
||||||
.Op Fl R Ar script-name
|
.Op Fl R Ar script-name
|
||||||
.Fl a
|
.Fl a
|
||||||
.\"
|
.\"
|
||||||
@ -250,6 +254,18 @@ router advertisement is also TRUE.
|
|||||||
must be the absolute path from root to the script file, be a regular
|
must be the absolute path from root to the script file, be a regular
|
||||||
file, and be created by the same owner who runs
|
file, and be created by the same owner who runs
|
||||||
.Nm .
|
.Nm .
|
||||||
|
.It Fl A Ar script-name
|
||||||
|
Specifies a supplement script file to always be called for the router
|
||||||
|
advertisement.
|
||||||
|
.Nm
|
||||||
|
will invoke
|
||||||
|
.Ar script-name
|
||||||
|
with a first argument of the receiving interface name
|
||||||
|
and a second argument of the sending router address.
|
||||||
|
.Ar script-name
|
||||||
|
must be the absolute path from root to the script file, be a regular
|
||||||
|
file, and be created by the same owner who runs
|
||||||
|
.Nm .
|
||||||
.It Fl p Ar pidfile
|
.It Fl p Ar pidfile
|
||||||
Writes the process ID of
|
Writes the process ID of
|
||||||
.Nm
|
.Nm
|
||||||
|
@ -82,6 +82,7 @@ int uflag = 0;
|
|||||||
|
|
||||||
const char *managedconf_script;
|
const char *managedconf_script;
|
||||||
const char *otherconf_script;
|
const char *otherconf_script;
|
||||||
|
const char *alwaysconf_script;
|
||||||
const char *resolvconf_script = "/sbin/resolvconf";
|
const char *resolvconf_script = "/sbin/resolvconf";
|
||||||
|
|
||||||
cap_channel_t *capllflags, *capscript, *capsendmsg, *capsyslog;
|
cap_channel_t *capllflags, *capscript, *capsendmsg, *capsyslog;
|
||||||
@ -126,11 +127,11 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
progname = basename(argv[0]);
|
progname = basename(argv[0]);
|
||||||
if (strcmp(progname, "rtsold") == 0) {
|
if (strcmp(progname, "rtsold") == 0) {
|
||||||
opts = "adDfFim1M:O:p:R:u";
|
opts = "adDfFim1M:O:A:p:R:u";
|
||||||
once = 0;
|
once = 0;
|
||||||
pidfilepath = NULL;
|
pidfilepath = NULL;
|
||||||
} else {
|
} else {
|
||||||
opts = "adDFiM:O:R:u";
|
opts = "adDFiM:O:A:R:u";
|
||||||
fflag = 1;
|
fflag = 1;
|
||||||
once = 1;
|
once = 1;
|
||||||
}
|
}
|
||||||
@ -167,6 +168,9 @@ main(int argc, char **argv)
|
|||||||
case 'O':
|
case 'O':
|
||||||
otherconf_script = optarg;
|
otherconf_script = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'A':
|
||||||
|
alwaysconf_script = optarg;
|
||||||
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
pidfilepath = optarg;
|
pidfilepath = optarg;
|
||||||
break;
|
break;
|
||||||
@ -204,6 +208,9 @@ main(int argc, char **argv)
|
|||||||
if (otherconf_script != NULL && *otherconf_script != '/')
|
if (otherconf_script != NULL && *otherconf_script != '/')
|
||||||
errx(1, "configuration script (%s) must be an absolute path",
|
errx(1, "configuration script (%s) must be an absolute path",
|
||||||
otherconf_script);
|
otherconf_script);
|
||||||
|
if (alwaysconf_script != NULL && *alwaysconf_script != '/')
|
||||||
|
errx(1, "configuration script (%s) must be an absolute path",
|
||||||
|
alwaysconf_script);
|
||||||
if (*resolvconf_script != '/')
|
if (*resolvconf_script != '/')
|
||||||
errx(1, "configuration script (%s) must be an absolute path",
|
errx(1, "configuration script (%s) must be an absolute path",
|
||||||
resolvconf_script);
|
resolvconf_script);
|
||||||
@ -336,7 +343,8 @@ init_capabilities(void)
|
|||||||
{
|
{
|
||||||
#ifdef WITH_CASPER
|
#ifdef WITH_CASPER
|
||||||
const char *const scripts[] =
|
const char *const scripts[] =
|
||||||
{ resolvconf_script, managedconf_script, otherconf_script };
|
{ resolvconf_script, managedconf_script, otherconf_script,
|
||||||
|
alwaysconf_script };
|
||||||
cap_channel_t *capcasper;
|
cap_channel_t *capcasper;
|
||||||
nvlist_t *limits;
|
nvlist_t *limits;
|
||||||
|
|
||||||
@ -616,6 +624,7 @@ rtsol_check_timer(void)
|
|||||||
if (probe) {
|
if (probe) {
|
||||||
ifi->managedconfig = 0;
|
ifi->managedconfig = 0;
|
||||||
ifi->otherconfig = 0;
|
ifi->otherconfig = 0;
|
||||||
|
ifi->alwaysconfig = 0;
|
||||||
}
|
}
|
||||||
if (probe && mobile_node) {
|
if (probe && mobile_node) {
|
||||||
error = cap_probe_defrouters(capsendmsg,
|
error = cap_probe_defrouters(capsendmsg,
|
||||||
@ -786,13 +795,17 @@ usage(const char *progname)
|
|||||||
|
|
||||||
if (strcmp(progname, "rtsold") == 0) {
|
if (strcmp(progname, "rtsold") == 0) {
|
||||||
fprintf(stderr, "usage: rtsold [-dDfFm1] [-O script-name] "
|
fprintf(stderr, "usage: rtsold [-dDfFm1] [-O script-name] "
|
||||||
|
"[-M script-name ] [-A script-name ] "
|
||||||
"[-p pidfile] [-R script-name] interface ...\n");
|
"[-p pidfile] [-R script-name] interface ...\n");
|
||||||
fprintf(stderr, "usage: rtsold [-dDfFm1] [-O script-name] "
|
fprintf(stderr, "usage: rtsold [-dDfFm1] [-O script-name] "
|
||||||
|
"[-M script-name ] [-A script-name ] "
|
||||||
"[-p pidfile] [-R script-name] -a\n");
|
"[-p pidfile] [-R script-name] -a\n");
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "usage: rtsol [-dDF] [-O script-name] "
|
fprintf(stderr, "usage: rtsol [-dDF] [-O script-name] "
|
||||||
|
"[-M script-name ] [-A script-name ] "
|
||||||
"[-p pidfile] [-R script-name] interface ...\n");
|
"[-p pidfile] [-R script-name] interface ...\n");
|
||||||
fprintf(stderr, "usage: rtsol [-dDF] [-O script-name] "
|
fprintf(stderr, "usage: rtsol [-dDF] [-O script-name] "
|
||||||
|
"[-M script-name ] [-A script-name ] "
|
||||||
"[-p pidfile] [-R script-name] -a\n");
|
"[-p pidfile] [-R script-name] -a\n");
|
||||||
}
|
}
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -75,6 +75,7 @@ struct ifinfo {
|
|||||||
* configuration */
|
* configuration */
|
||||||
int otherconfig; /* need a separate protocol for the "other"
|
int otherconfig; /* need a separate protocol for the "other"
|
||||||
* configuration */
|
* configuration */
|
||||||
|
int alwaysconfig; /* Have we called the 'always' script? */
|
||||||
int state;
|
int state;
|
||||||
int probes;
|
int probes;
|
||||||
int dadcount;
|
int dadcount;
|
||||||
@ -160,6 +161,7 @@ extern int Fflag;
|
|||||||
extern int uflag;
|
extern int uflag;
|
||||||
extern const char *managedconf_script;
|
extern const char *managedconf_script;
|
||||||
extern const char *otherconf_script;
|
extern const char *otherconf_script;
|
||||||
|
extern const char *alwaysconf_script;
|
||||||
extern const char *resolvconf_script;
|
extern const char *resolvconf_script;
|
||||||
extern struct cap_channel *capllflags, *capscript, *capsendmsg, *capsyslog;
|
extern struct cap_channel *capllflags, *capscript, *capsendmsg, *capsyslog;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user