mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-04-29 16:17:38 +00:00
vtysh: use daemon type and handle multi-instance types
To handle multi-instance daemons (ospf, e.g.), each forked vtysh handles all of the instances of a daemon type. Signed-off-by: Mark Stapp <mstapp@nvidia.com>
This commit is contained in:
parent
916af6559c
commit
449f66552f
@ -135,8 +135,6 @@ struct vtysh_client vtysh_client[] = {
|
|||||||
{.name = "pim6d", .flag = VTYSH_PIM6D},
|
{.name = "pim6d", .flag = VTYSH_PIM6D},
|
||||||
};
|
};
|
||||||
|
|
||||||
char my_client[64];
|
|
||||||
|
|
||||||
/* Searches for client by name, returns index */
|
/* Searches for client by name, returns index */
|
||||||
static int vtysh_client_lookup(const char *name)
|
static int vtysh_client_lookup(const char *name)
|
||||||
{
|
{
|
||||||
|
@ -132,6 +132,5 @@ struct vtysh_client {
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern struct vtysh_client vtysh_client[22];
|
extern struct vtysh_client vtysh_client[22];
|
||||||
extern char my_client[64];
|
|
||||||
|
|
||||||
#endif /* VTYSH_H */
|
#endif /* VTYSH_H */
|
||||||
|
@ -345,6 +345,8 @@ int main(int argc, char **argv, char **env)
|
|||||||
char pathspace[MAXPATHLEN] = "";
|
char pathspace[MAXPATHLEN] = "";
|
||||||
const char *histfile = NULL;
|
const char *histfile = NULL;
|
||||||
const char *histfile_env = getenv("VTYSH_HISTFILE");
|
const char *histfile_env = getenv("VTYSH_HISTFILE");
|
||||||
|
char my_client[64];
|
||||||
|
int my_client_type;
|
||||||
|
|
||||||
/* SUID: drop down to calling user & go back up when needed */
|
/* SUID: drop down to calling user & go back up when needed */
|
||||||
elevuid = geteuid();
|
elevuid = geteuid();
|
||||||
@ -739,6 +741,7 @@ int main(int argc, char **argv, char **env)
|
|||||||
/* Store name of client this fork will handle */
|
/* Store name of client this fork will handle */
|
||||||
strlcpy(my_client, vtysh_client[i].name,
|
strlcpy(my_client, vtysh_client[i].name,
|
||||||
sizeof(my_client));
|
sizeof(my_client));
|
||||||
|
my_client_type = vtysh_client[i].flag;
|
||||||
fork_pid = fork();
|
fork_pid = fork();
|
||||||
|
|
||||||
/* If child, break */
|
/* If child, break */
|
||||||
@ -761,15 +764,21 @@ int main(int argc, char **argv, char **env)
|
|||||||
*/
|
*/
|
||||||
for (unsigned int i = 0; i < array_size(vtysh_client);
|
for (unsigned int i = 0; i < array_size(vtysh_client);
|
||||||
i++) {
|
i++) {
|
||||||
if (strcmp(my_client, vtysh_client[i].name)) {
|
if (my_client_type != vtysh_client[i].flag) {
|
||||||
|
struct vtysh_client *cl;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If this is a client we aren't
|
* If this is a client we aren't
|
||||||
* responsible for, disconnect
|
* responsible for, disconnect
|
||||||
*/
|
*/
|
||||||
if (vtysh_client[i].fd >= 0)
|
for (cl = &vtysh_client[i]; cl;
|
||||||
close(vtysh_client[i].fd);
|
cl = cl->next) {
|
||||||
vtysh_client[i].fd = -1;
|
if (cl->fd >= 0)
|
||||||
} else if (vtysh_client[i].fd == -1) {
|
close(cl->fd);
|
||||||
|
cl->fd = -1;
|
||||||
|
}
|
||||||
|
} else if (vtysh_client[i].fd == -1 &&
|
||||||
|
vtysh_client[i].next == NULL) {
|
||||||
/*
|
/*
|
||||||
* If this is the client we are
|
* If this is the client we are
|
||||||
* responsible for, but we aren't
|
* responsible for, but we aren't
|
||||||
|
Loading…
Reference in New Issue
Block a user