diff options
Diffstat (limited to 'vtysh')
| -rw-r--r-- | vtysh/Makefile.am | 4 | ||||
| -rw-r--r-- | vtysh/vtysh.c | 70 | ||||
| -rw-r--r-- | vtysh/vtysh.h | 7 | ||||
| -rw-r--r-- | vtysh/vtysh_main.c | 6 |
4 files changed, 36 insertions, 51 deletions
diff --git a/vtysh/Makefile.am b/vtysh/Makefile.am index 376f380a32..d02ec9661f 100644 --- a/vtysh/Makefile.am +++ b/vtysh/Makefile.am @@ -67,6 +67,10 @@ if RIPNGD vtysh_scan += $(top_srcdir)/ripngd/*.c endif +if NHRPD +vtysh_scan += $(top_srcdir)/nhrpd/nhrp_vty.c +endif + vtysh_cmd_FILES = $(vtysh_scan) \ $(top_srcdir)/lib/keychain.c $(top_srcdir)/lib/routemap.c \ $(top_srcdir)/lib/filter.c $(top_srcdir)/lib/plist.c \ diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 38f28e4530..114022d199 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -43,6 +43,7 @@ #include "bgpd/bgp_vty.h" #include "ns.h" #include "vrf.h" +#include "libfrr.h" DEFINE_MTYPE_STATIC(MVTYSH, VTYSH_CMD, "Vtysh cmd copy") @@ -58,22 +59,23 @@ struct vtysh_client int fd; const char *name; int flag; - const char *path; + char path[MAXPATHLEN]; struct vtysh_client *next; }; struct vtysh_client vtysh_client[] = { - { .fd = -1, .name = "zebra", .flag = VTYSH_ZEBRA, .path = ZEBRA_VTYSH_PATH, .next = NULL}, - { .fd = -1, .name = "ripd", .flag = VTYSH_RIPD, .path = RIP_VTYSH_PATH, .next = NULL}, - { .fd = -1, .name = "ripngd", .flag = VTYSH_RIPNGD, .path = RIPNG_VTYSH_PATH, .next = NULL}, - { .fd = -1, .name = "ospfd", .flag = VTYSH_OSPFD, .path = OSPF_VTYSH_PATH, .next = NULL}, - { .fd = -1, .name = "ospf6d", .flag = VTYSH_OSPF6D, .path = OSPF6_VTYSH_PATH, .next = NULL}, - { .fd = -1, .name = "ldpd", .flag = VTYSH_LDPD, .path = LDP_VTYSH_PATH, .next = NULL}, - { .fd = -1, .name = "bgpd", .flag = VTYSH_BGPD, .path = BGP_VTYSH_PATH, .next = NULL}, - { .fd = -1, .name = "isisd", .flag = VTYSH_ISISD, .path = ISIS_VTYSH_PATH, .next = NULL}, - { .fd = -1, .name = "pimd", .flag = VTYSH_PIMD, .path = PIM_VTYSH_PATH, .next = NULL}, - { .fd = -1, .name = "watchfrr", .flag = VTYSH_WATCHFRR, .path = WATCHFRR_VTYSH_PATH, .next = NULL}, + { .fd = -1, .name = "zebra", .flag = VTYSH_ZEBRA, .next = NULL}, + { .fd = -1, .name = "ripd", .flag = VTYSH_RIPD, .next = NULL}, + { .fd = -1, .name = "ripngd", .flag = VTYSH_RIPNGD, .next = NULL}, + { .fd = -1, .name = "ospfd", .flag = VTYSH_OSPFD, .next = NULL}, + { .fd = -1, .name = "ospf6d", .flag = VTYSH_OSPF6D, .next = NULL}, + { .fd = -1, .name = "ldpd", .flag = VTYSH_LDPD, .next = NULL}, + { .fd = -1, .name = "bgpd", .flag = VTYSH_BGPD, .next = NULL}, + { .fd = -1, .name = "isisd", .flag = VTYSH_ISISD, .next = NULL}, + { .fd = -1, .name = "pimd", .flag = VTYSH_PIMD, .next = NULL}, + { .fd = -1, .name = "nhrpd", .flag = VTYSH_NHRPD, .next = NULL}, + { .fd = -1, .name = "watchfrr", .flag = VTYSH_WATCHFRR, .next = NULL}, }; enum vtysh_write_integrated vtysh_write_integrated = WRITE_INTEGRATED_UNSPECIFIED; @@ -2865,27 +2867,12 @@ vtysh_connect (struct vtysh_client *vclient) int sock, len; struct sockaddr_un addr; struct stat s_stat; - char path[MAXPATHLEN]; + const char *path; - if (vty_sock_path == NULL) - strlcpy (path, vclient->path, sizeof (path)); - else { - /* Different path for VTY Socket specified - overriding the default path, but keep the filename */ - strlcpy (path, vty_sock_path, sizeof (path)); - - if (strrchr (vclient->path, '/') != NULL) - strlcat (path, strrchr (vclient->path, '/'), sizeof (path)); - else { - /* - * vclient->path configured as relative path during config? Should - * really never happen for sensible config - */ - strlcat (path, "/", sizeof (path)); - strlcat (path, vclient->path, sizeof (path)); - } - } - path[sizeof(path)-1] = '\0'; + if (!vclient->path[0]) + snprintf(vclient->path, sizeof(vclient->path), "%s/%s.vty", + vty_sock_path, vclient->name); + path = vclient->path; /* Stat socket to see if we have permission to access it. */ ret = stat (path, &s_stat); @@ -2980,24 +2967,14 @@ static void vtysh_update_all_insances(struct vtysh_client * head_client) { struct vtysh_client *client; - char *ptr; - char vty_dir[MAXPATHLEN]; DIR *dir; struct dirent *file; int n = 0; if (head_client->flag != VTYSH_OSPFD) return; - if (vty_sock_path == NULL) - /* ls DAEMON_VTY_DIR and look for all files ending in .vty */ - strlcpy(vty_dir, DAEMON_VTY_DIR "/", MAXPATHLEN); - else - { - /* ls vty_sock_dir and look for all files ending in .vty */ - strlcpy(vty_dir, vty_sock_path, MAXPATHLEN); - strlcat(vty_dir, "/", MAXPATHLEN); - } - dir = opendir(vty_dir); + /* ls vty_sock_dir and look for all files ending in .vty */ + dir = opendir(vty_sock_path); if (dir) { while ((file = readdir(dir)) != NULL) @@ -3008,16 +2985,15 @@ vtysh_update_all_insances(struct vtysh_client * head_client) { fprintf(stderr, "Parsing %s, client limit(%d) reached!\n", - vty_dir, n); + vty_sock_path, n); break; } client = (struct vtysh_client *) malloc(sizeof(struct vtysh_client)); client->fd = -1; client->name = "ospfd"; client->flag = VTYSH_OSPFD; - ptr = (char *) malloc(100); - sprintf(ptr, "%s%s", vty_dir, file->d_name); - client->path = (const char *)ptr; + snprintf(client->path, sizeof(client->path), "%s/%s", + vty_sock_path, file->d_name); client->next = NULL; vtysh_client_sorted_insert(head_client, client); n++; diff --git a/vtysh/vtysh.h b/vtysh/vtysh.h index ad31195ac4..07ba8367de 100644 --- a/vtysh/vtysh.h +++ b/vtysh/vtysh.h @@ -35,15 +35,16 @@ DECLARE_MGROUP(MVTYSH) #define VTYSH_PIMD 0x100 #define VTYSH_LDPD 0x200 #define VTYSH_WATCHFRR 0x400 +#define VTYSH_NHRPD 0x800 /* commands in REALLYALL are crucial to correct vtysh operation */ #define VTYSH_REALLYALL ~0U /* watchfrr is not in ALL since library CLI functions should not be * run on it (logging & co. should stay in a fixed/frozen config, and * things like prefix lists are not even initialised) */ -#define VTYSH_ALL VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_LDPD|VTYSH_BGPD|VTYSH_ISISD|VTYSH_PIMD +#define VTYSH_ALL VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_LDPD|VTYSH_BGPD|VTYSH_ISISD|VTYSH_PIMD|VTYSH_NHRPD #define VTYSH_RMAP VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_PIMD -#define VTYSH_INTERFACE VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_LDPD|VTYSH_ISISD|VTYSH_PIMD +#define VTYSH_INTERFACE VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_LDPD|VTYSH_ISISD|VTYSH_PIMD|VTYSH_NHRPD #define VTYSH_NS VTYSH_ZEBRA #define VTYSH_VRF VTYSH_ZEBRA @@ -96,6 +97,6 @@ extern int execute_flag; extern struct vty *vty; -extern char * vty_sock_path; +extern const char * vty_sock_path; #endif /* VTYSH_H */ diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c index 3dffa05ace..bf62850e22 100644 --- a/vtysh/vtysh_main.c +++ b/vtysh/vtysh_main.c @@ -37,6 +37,7 @@ #include "memory.h" #include "linklist.h" #include "memory_vty.h" +#include "libfrr.h" #include "vtysh/vtysh.h" #include "vtysh/vtysh_user.h" @@ -54,7 +55,7 @@ char history_file[MAXPATHLEN]; int execute_flag = 0; /* VTY Socket prefix */ -char * vty_sock_path = NULL; +const char * vty_sock_path = NULL; /* For sigsetjmp() & siglongjmp(). */ static sigjmp_buf jmpbuf; @@ -402,6 +403,9 @@ main (int argc, char **argv, char **env) } } + if (!vty_sock_path) + vty_sock_path = frr_vtydir; + if (markfile + writeconfig + dryrun + boot_flag > 1) { fprintf (stderr, "Invalid combination of arguments. Please specify at " |
