diff --git a/src/sonic-sswsyncd/Makefile b/src/sonic-sswsyncd/Makefile new file mode 100644 index 000000000000..e2db3161f9f1 --- /dev/null +++ b/src/sonic-sswsyncd/Makefile @@ -0,0 +1,92 @@ +CFLAGS_COMMON = +CFLAGS_COMMON += -ansi +CFLAGS_COMMON += -fPIC +CFLAGS_COMMON += -std=c++11 +CFLAGS_COMMON += -Wall +CFLAGS_COMMON += -Wcast-align +CFLAGS_COMMON += -Wcast-qual +CFLAGS_COMMON += -Wconversion +CFLAGS_COMMON += -Wdisabled-optimization +CFLAGS_COMMON += -Werror +CFLAGS_COMMON += -Wextra +CFLAGS_COMMON += -Wfloat-equal +CFLAGS_COMMON += -Wformat=2 +CFLAGS_COMMON += -Wformat-nonliteral +CFLAGS_COMMON += -Wformat-security +CFLAGS_COMMON += -Wformat-y2k +CFLAGS_COMMON += -Wimport +CFLAGS_COMMON += -Winit-self +CFLAGS_COMMON += -Winline +CFLAGS_COMMON += -Winvalid-pch +CFLAGS_COMMON += -Wlong-long +CFLAGS_COMMON += -Wmissing-field-initializers +CFLAGS_COMMON += -Wmissing-format-attribute +CFLAGS_COMMON += -Wmissing-include-dirs +CFLAGS_COMMON += -Wmissing-noreturn +CFLAGS_COMMON += -Wno-aggregate-return +CFLAGS_COMMON += -Wno-padded +CFLAGS_COMMON += -Wno-switch-enum +CFLAGS_COMMON += -Wno-unused-parameter +CFLAGS_COMMON += -Wpacked +CFLAGS_COMMON += -Wpointer-arith +CFLAGS_COMMON += -Wredundant-decls +CFLAGS_COMMON += -Wshadow +CFLAGS_COMMON += -Wstack-protector +CFLAGS_COMMON += -Wstrict-aliasing=3 +CFLAGS_COMMON += -Wswitch +CFLAGS_COMMON += -Wswitch-default +CFLAGS_COMMON += -Wunreachable-code +CFLAGS_COMMON += -Wunused +CFLAGS_COMMON += -Wvariadic-macros +CFLAGS_COMMON += -Wwrite-strings +CFLAGS_COMMON += -Wno-switch-default +CFLAGS_COMMON += -Wconversion +CFLAGS_COMMON += -Wlong-long + +CC = g++ +SAI_INCLUDE_DIR = /usr/include/sai +CFLAGS = -g -I$(SAI_INCLUDE_DIR) -I/usr/include/libnl3 -std=c++11 +ifdef SAITHRIFT +SAI_RPC_INCLUDE_DIR = libsaiserver/include +SAI_RPC_LIB_DIR = libsaiserver/lib +CFLAGS += -I$(SAI_RPC_INCLUDE_DIR) -L$(SAI_RPC_LIB_DIR) -DSAITHRIFT=yes +endif +ifeq ($(platform),MLNX) +CDEFS = -DMLNXSAI +else +ifeq ($(platform),BFT) +CDEFS = -DBFTSAI +else +ifeq ($(platform),) +CDEFS = -DBRCMSAI +endif +endif +endif +INSTALL := /usr/bin/install +DSSERVE := dsserve +BCMCMD := bcmcmd + +SDIR = src +ODIR = obj +BIN_DIR = build + +LIBS = -lpthread -lutil + +$(shell mkdir -p $(ODIR) && mkdir -p $(BIN_DIR)) + +.phony : install clean + +all : $(DSSERVE) $(BCMCMD) + +$(DSSERVE) : $(SDIR)/$(DSSERVE).cpp + $(CC) -o $(BIN_DIR)/$(DSSERVE) $^ $(CFLAGS) $(LIBS) + +$(BCMCMD) : $(SDIR)/$(BCMCMD).cpp + $(CC) -o $(BIN_DIR)/$(BCMCMD) $^ $(CFLAGS) $(CFLAGS_COMMON) $(LIBS) + +install : + $(INSTALL) -D $(BIN_DIR)/$(DSSERVE) $(DESTDIR)/usr/sbin/$(DSSERVE) + $(INSTALL) -D $(BIN_DIR)/$(BCMCMD) $(DESTDIR)/usr/sbin/$(BCMCMD) + +clean: + rm -rf $(ODIR) $(BIN_DIR) diff --git a/src/sonic-sswsyncd/debian/changelog b/src/sonic-sswsyncd/debian/changelog new file mode 100644 index 000000000000..ef03a9655806 --- /dev/null +++ b/src/sonic-sswsyncd/debian/changelog @@ -0,0 +1,33 @@ +sswsyncd (0.2-8) UNRELEASED; urgency=medium + + * Add support for Mellanox switches + + -- Pavel Shirshov Wed, 13 Apr 2016 14:07:03 -0700 + +sswsyncd (0.2-7) UNRELEASED; urgency=medium + + * build two packages: one for production, one for development with saithrift server included + + -- Pavel Shirshov Wed, 06 Apr 2016 01:39:03 -0700 + +sswsyncd (0.2-6) UNRELEASED; urgency=medium + + * add init script + * consume libsai virtual package + * add interface syncer + * add dependency for socat in the init.d + * add sswsyncd.service for systemd + + -- Guohan Lu Fri, 17 Jul 2015 01:39:03 -0700 + +sswsyncd (0.2-2) unstable; urgency=low + + * Initial version based on SAI + + -- Guohan Lu Thu, 19 Feb 2015 06:37:50 -0800 + +sswsyncd (0.2-1) unstable; urgency=low + + * Initial release (Closes: #nnnn) + + -- Guohan Lu Thu, 13 Nov 2014 01:08:15 -0800 diff --git a/src/sonic-sswsyncd/debian/compat b/src/sonic-sswsyncd/debian/compat new file mode 100644 index 000000000000..ec635144f600 --- /dev/null +++ b/src/sonic-sswsyncd/debian/compat @@ -0,0 +1 @@ +9 diff --git a/src/sonic-sswsyncd/debian/control b/src/sonic-sswsyncd/debian/control new file mode 100644 index 000000000000..340c81e58ef8 --- /dev/null +++ b/src/sonic-sswsyncd/debian/control @@ -0,0 +1,20 @@ +Source: sswsyncd +Section: main +Priority: extra +Maintainer: Guohan Lu +Build-Depends: debhelper (>= 8.0.0) +Standards-Version: 3.9.3 +#Vcs-Git: git://git.debian.org/collab-maint/ssw.git +#Vcs-Browser: http://git.debian.org/?p=collab-maint/ssw.git;a=summary + +Package: sswsyncd +Architecture: amd64 +Depends: libsai, python-tabulate, ifupdown, ${shlibs:Depends}, ${misc:Depends} +Conflicts: sswsyncd-saithrift +Description: AzureCloudSwitch route sync daemon + +Package: sswsyncd-saithrift +Architecture: amd64 +Depends: libsai, python-tabulate, ifupdown, ${shlibs:Depends}, ${misc:Depends} +Conflicts: sswsyncd +Description: AzureCloudSwitch route sync daemon diff --git a/src/sonic-sswsyncd/debian/rules b/src/sonic-sswsyncd/debian/rules new file mode 100755 index 000000000000..5c8768476cd9 --- /dev/null +++ b/src/sonic-sswsyncd/debian/rules @@ -0,0 +1,62 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +PACKAGES += sswsyncd + +BUILDFLAGS_sswsyncd = + +.PHONY: clean + +binary: binary-arch + +binary-arch: binary-arch-sswsyncd + +binary-arch-sswsyncd: install-stamp-sswsyncd + dh_testdir + dh_testroot + dh_systemd_enable -p $* + dh_installinit -p $* --name=sswsyncd + dh_installdocs -p $* + dh_installchangelogs -p $* + dh_perl -p $* + dh_link -p $* + dh_compress -p $* + dh_fixperms -p $* + dh_strip -p $* + dh_makeshlibs -p $* + dh_shlibdeps -p $* -- -xlibsaibcm + dh_installdeb -p $* + dh_gencontrol -p $* + dh_md5sums -p $* + dh_builddeb -p $* + +install-stamp-sswsyncd: DESTDIR=$(CURDIR)/debian/sswsyncd +install-stamp-sswsyncd: build-stamp-sswsyncd + dh_testdir + dh_testroot + @echo "!!! INSTALLING PACKAGE $*" + cp $(CURDIR)/debian/dirs.tmpl $(CURDIR)/debian/$*.dirs + dh_installdirs -p $* + $(MAKE) install DESTDIR=$(DESTDIR) + touch $@ + +build-stamp-sswsyncd: BUILDFLAGS=$(BUILDFLAGS_sswsyncd) +build-stamp-sswsyncd: + dh_testdir + dh_prep -p $* + @echo "!!! BUILDING PACKAGE $*" + $(MAKE) clean + $(MAKE) $(BUILDFLAGS) + touch $@ + +clean: + rm -f *-stamp* + dh_clean diff --git a/src/sonic-sswsyncd/src/bcmcmd.cpp b/src/sonic-sswsyncd/src/bcmcmd.cpp new file mode 100644 index 000000000000..301d8c4557d4 --- /dev/null +++ b/src/sonic-sswsyncd/src/bcmcmd.cpp @@ -0,0 +1,275 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "dsserve.h" +using namespace std; + +class timeout_error : public std::runtime_error +{ +public: + explicit timeout_error(const string& what_arg) : std::runtime_error(what_arg) { } + explicit timeout_error(const char* what_arg) : std::runtime_error(what_arg) { } +}; + +class socketio_error : public std::runtime_error +{ +public: + explicit socketio_error(const string& what_arg) : std::runtime_error(what_arg) { } + explicit socketio_error(const char* what_arg) : std::runtime_error(what_arg) { } +}; + +// Default timeout for connecting to brcm sdk unix domain socket +// User may change it by command line argument +const int DEFAULT_TIMEOUT_SEC = 30; + +const int MILLISECONDS_IN_SEC = 1000; + +typedef vector::iterator vsi; + +ssize_t write(int fd, const string& s) { + return write(fd, s.c_str(), s.size()); +} + +/* returns true iff str ends with suffix */ +bool str_ends_with(const char * str, const char * suffix) { + if( str == NULL || suffix == NULL ) return 0; + + size_t str_len = strlen(str); + size_t suffix_len = strlen(suffix); + if(suffix_len > str_len) return 0; + + return 0 == strncmp(str + str_len - suffix_len, suffix, suffix_len); +} + +/* return the index of matched prompt, otherwise -1 */ +/* output parameter: bytes_read - the total bytes read till the prompt (inclusive) */ +int read_to_prompts(int sock, vsi prompt_begin, vsi prompt_end, bool enable_out, int ms_timeout, size_t& bytes_read) { + const size_t BUF_SIZE = 1024; + static char buf[BUF_SIZE]; + static size_t leftover = 0; + bytes_read = 0; + + struct pollfd fd; + fd.fd = sock; + fd.events = POLLIN; + + for (;;) { + // Discard complete lines left in the buffer, and keep the last partial line + // The line delimiters could be \n, or \r\n + // Note: if buffer ends with \r, it may follow by \n later + char *p; + for (p = buf + leftover - 1; p >= buf; p--) + { + if (*p == '\n') break; + } + if (p < buf) + { + if (leftover >= BUF_SIZE - 1) + { + // There is large amount of char in the buffer without line separators, + // which is unexpected. Just flush the left over chars. + leftover = 0; + } + } + else + { + char *partial = p + 1; + leftover = buf + leftover - partial; + memmove(buf, partial, leftover); + } + + // Poll the sock to detect timeout or other errors + int res = poll(&fd, 1, ms_timeout); + switch (res) { + case -1: + throw socketio_error("polling socket error"); + case 0: + throw timeout_error("polling socket timeout"); + default: + // will get your data later + break; + } + + // Read a batch from the socket + ssize_t rval = read(sock, buf + leftover, (BUF_SIZE - 1 - leftover)); + + if (rval < 0) throw socketio_error("reading stream message"); + if (rval == 0) throw socketio_error("ending connection"); + bytes_read += (size_t)rval; + buf[leftover + rval] = '\0'; // Terminate read string with NUL char + if (enable_out) { + printf("%s", buf + leftover); + fflush(stdout); + } + leftover += rval; + + int index = 0; + for (auto i = prompt_begin; i != prompt_end; i++, index++) { + if (str_ends_with(buf, i->c_str())) + return index; + } + } +} + +int main(int argc, char *argv[]) { + int sock; + struct sockaddr_un server; + + auto usage = [=]() { + printf("USAGE: %s [-f ] -v \n", argv[0]); + printf(" -v verbose mode\n"); + printf(" -f domain socket filename, default %s\n", DEFAULT_SUN_PATH); + printf(" -t timeout in seconds, default %d\n", DEFAULT_TIMEOUT_SEC); + printf("RETURN VALUE:\n" + " 0 success\n"); + printf(" %3d socket io error\n", EIO); + printf(" %3d invalid argument\n", EINVAL); + printf(" %3d timeout\n", ETIME); + printf("\n"); + return EINVAL; + }; + + // Parse command line + const char *sun_path = DEFAULT_SUN_PATH; + const char *cmd = NULL; + bool verbose = false; + int timeout_sec = DEFAULT_TIMEOUT_SEC; + if (argc < 2) { + return usage(); + } + for (argc--, argv++; argc > 0 && *argv; argc--, argv++) { + if (!strcmp(*argv, "--help") || !strcmp(*argv, "-h")) { + return usage(); + } + else if (!strcmp(*argv, "-v")) { + verbose = true; + } + else if (!strcmp(*argv, "-t")) { + argc--, argv++; + if (argc > 1 && *argv && isdigit(argv[0][0])) { + timeout_sec = atoi(*argv); + } + else { + fprintf(stderr, "[ERROR] bad timeout\n"); + return usage(); + } + } + else if (!strcmp(*argv, "-f")) { + argc--, argv++; + if (argc > 1 && *argv) { + sun_path = *argv; + } + else { + fprintf(stderr, "[ERROR] bad domain socket filename\n"); + return usage(); + } + if (verbose) printf("[INFO] domain socket filename: %s\n", sun_path); + } + else { + cmd = *argv; + if (verbose) printf("[INFO] cmd: %s\n", cmd); + } + } + if (cmd == NULL || *cmd == '\0' || *sun_path == '\0' || timeout_sec < 0) { + return usage(); + } + int timeout_ms; + if (timeout_sec >= INT_MAX / MILLISECONDS_IN_SEC) { + timeout_ms = INT_MAX; + } + else { + timeout_ms = timeout_sec * MILLISECONDS_IN_SEC; + } + + sock = socket(AF_UNIX, SOCK_STREAM, 0); + if (sock < 0) { + perror("opening stream socket"); + exit(1); + } + server.sun_family = AF_UNIX; + strcpy(server.sun_path, sun_path); + + if (connect(sock, (struct sockaddr *) &server, sizeof(struct sockaddr_un)) < 0) { + close(sock); + perror("connecting stream socket"); + exit(1); + } + + ssize_t written; + written = write(sock, "\n"); + if (written <= 0) { + perror("writing on stream socket"); + exit(1); + } + + // Interactive with shell + // Wait for the first shell prompt + vector prompt = { "Hit enter to get drivshell prompt..\r\n", "drivshell>" }; + + try + { + int index; + size_t bytesread; + index = read_to_prompts(sock, prompt.begin(), prompt.end(), false, timeout_ms, bytesread); + if (index < 0) { + perror("failed to wait the prompt"); + exit(index); + } + + if (index == 0) { + // Write enter char to socket + written = write(sock, "\n"); + if (written <= 0) { + perror("failed to write enter"); + exit(1); + } + + // Wait next prompt + index = read_to_prompts(sock, prompt.begin() + 1, prompt.begin() + 2, true, timeout_ms, bytesread); + if (index < 0) { + perror("failed to wait the prompt"); + exit(index); + } + } + + // Write the command to the socket + written = write(sock, cmd + string("\n")); + if (written <= 0) { + perror("failed to write command"); + exit(1); + } + + // Wait for the prompt after the command output, may ignore empty prompt lines + do { + index = read_to_prompts(sock, prompt.begin() + 1, prompt.begin() + 2, true, timeout_ms, bytesread); + } while (bytesread == prompt[1].size() && index >= 0); + + if (index < 0) { + perror("failed to wait the prompt"); + exit(index); + } + + printf("\n"); // Print enter after the final prompt + close(sock); + return 0; + } + catch(timeout_error& ex) + { + perror(ex.what()); + exit(ETIME); + } + catch(socketio_error& ex) + { + perror(ex.what()); + exit(EIO); + } +} diff --git a/src/sonic-sswsyncd/src/dsserve.cpp b/src/sonic-sswsyncd/src/dsserve.cpp new file mode 100644 index 000000000000..9c05bd9ec941 --- /dev/null +++ b/src/sonic-sswsyncd/src/dsserve.cpp @@ -0,0 +1,300 @@ +/* + * + * dsserve: domain socket server for stdio. + * + * This daemon connects a network socket to stdio of a local + * application through a pseudo TTY, thus enabling access to + * the application from a telnet client. Terminating the + * telnet session does not terminate the application, i.e. + * it is possible to connect several times to the same + * instance of the application. + * + * Example launching bcm.user on the domain socket filename: + * + * dsserve -d bcm.user + * + * Now connect to bcm.user, e.g. like this: + * + * dsclient + * + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include "dsserve.h" + +static inline void syslog_printf(int priority, const char *format, ...) +{ + va_list args1, args2; + va_start(args1, format); + va_copy(args2, args1); // va_list cannot be used twice, copy it + vsyslog(priority, format, args1); + + auto f = (priority & LOG_PRIMASK) <= LOG_WARNING ? stderr : stdout; + fprintf(f, "[%d] ", priority); + vfprintf(f, format, args2); + va_end(args2); + va_end(args1); +} +// Quickly replace all syslog() with syslog_printf() +#define syslog syslog_printf + +/* Network server */ +static volatile int _dsfd = -1; +static int _server_socket; + +static int +_setup_domain_socket(const char *sun_path) +{ + struct sockaddr_un addr; + int sockfd; + + if ((sockfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { + syslog(LOG_ERR, "server: can't open stream socket: %s", strerror(errno)); + exit(EXIT_FAILURE); + } + + /* Set up server address */ + memset((void *) &addr, 0x0, sizeof(addr)); + addr.sun_family = AF_UNIX; + // Copy 1 char less to make sure the destination is ended with \0 + strncpy(addr.sun_path, sun_path, sizeof(addr.sun_path) - 1); + + /* Remove the domain socket file first */ + unlink(sun_path); + /* Bind our domain socket */ + if (bind(sockfd, (struct sockaddr *) &addr, sizeof(addr)) < 0) { + syslog(LOG_ERR, "server: can't bind domain socket: %s", strerror(errno)); + exit(EXIT_FAILURE); + } + + /* Only process one connection at a time */ + listen(sockfd, 1); + + return sockfd; +} + +static void * +_ds2tty(void *arg) +{ + int fd = *((int *)arg); + const size_t DATA_SIZE = 1024; + unsigned char data[DATA_SIZE]; + ssize_t rc; + struct sockaddr_in addr; + socklen_t len; + + while (1) { + if (_dsfd < 0) + { + len = sizeof(addr); + if ((_dsfd = accept(_server_socket, (struct sockaddr *) &addr, &len)) < 0) { + syslog(LOG_ERR, "server: can't accept socket: %s", strerror(errno)); + exit(EXIT_FAILURE); + } + } + + rc = read(_dsfd, data, DATA_SIZE); + if (rc <= 0) { + if (rc < 0) { + /* Broken pipe -- client quit */ + syslog(LOG_ERR, "_ds2tty broken pipe"); + } + else { + /* Ending connection */ + } + close(_dsfd); + _dsfd = -1; + } else { + write(fd, data, rc); + fsync(fd); + } + } + + return NULL; +} + +static void * +_tty2ds(void *arg) +{ + int fd = *((int *)arg); + const size_t DATA_SIZE = 1024; + unsigned char data[DATA_SIZE]; + ssize_t rc; + + while (1) { + rc = read(fd, data, DATA_SIZE); + if (rc <= 0) { + /* Broken pipe -- app quit */ + syslog(LOG_ERR, "_tty2ds broken pipe"); + close(fd); + exit(0); + } + if (_dsfd >= 0) { + ssize_t written = write(_dsfd, data, rc); + // Handle the client exit problem + if (written < 0) { + close(_dsfd); + _dsfd = -1; + } + fsync(_dsfd); + } + else + { + /* print orphaned message to the stdout */ + printf("%.*s", rc, data); + fflush(stdout); + } + } + return NULL; +} + +static int +_start_app(char **args, int s) +{ + pid_t pid; + + if ((pid = fork()) < 0) { + syslog(LOG_ERR, "fork %s", strerror(errno)); + return -1; + } + if (pid > 0) { + return pid; + } + dup2(s, 0); + dup2(s, 1); + dup2(s, 2); + int rc = execv(*args, args); + + syslog(LOG_ERR, "execv program exit, rc=%d, errno=%d: %s\n", rc, errno, strerror(errno)); + exit(0); +} + +int +main(int argc, char *argv[]) +{ + int pid; + int do_fork = 0; + int rc; + int ttyfd, appfd; + pthread_t id; + + auto usage = [=]() { + const char* prog = argv[0]; + printf("Usage: %s [-d] [-f ] [args]\n", prog); + printf(" -d Daemon mode\n"); + printf(" -f Specify the path of unix socket\n"); + printf("Default sun_path: %s\n", DEFAULT_SUN_PATH); + printf("\n"); + printf("Exit status:\n"); + printf(" 0 Both %s and program exit normally in non daemon mode, or %s exits normally in daemon mode\n", prog, prog); + printf(" 1 %s exits with error\n", prog); + printf(" 2 Program exits with non-zero exit status\n"); + printf(" 3 Program terminates without an exit status, eg. receiving a signal\n"); + printf(" 255 Usage error\n"); + return 255; + }; + + const char *sun_path = DEFAULT_SUN_PATH; + for (argc--, argv++; argc > 0 && *argv; argc--, argv++) { + if (!strcmp(*argv, "--help") || !strcmp(*argv, "-h")) { + usage(); + return 0; + } + else if (!strcmp(*argv, "-d")) { + syslog(LOG_INFO, "daemon mode\n"); + do_fork = 1; + } + else if (!strcmp(*argv, "-f")) { + argc--, argv++; + if (argc > 1 && *argv) { + sun_path = *argv; + } + else { + fprintf(stderr, "[ERROR] bad domain socket filename\n"); + return usage(); + } + syslog(LOG_INFO, "domain socket filename: %s\n", sun_path); + } + else break; + } + + if (do_fork) { + /* Daemonize */ + if (daemon(1, 1) < 0) { + syslog(LOG_ERR, "daemon(): %s", strerror(errno)); + exit(EXIT_FAILURE); + } + } + + /* Broken pipes are not a problem */ + signal(SIGPIPE, SIG_IGN); + + /* Get a pseudo tty */ + if (openpty(&ttyfd, &appfd, NULL, NULL, NULL) < 0) { + syslog(LOG_ERR, "open pty: %s", strerror(errno)); + exit(EXIT_FAILURE); + } + + /* Start the application up with sv[1] as its stdio */ + const char *process_name = argv[0]; + if (process_name == NULL) + { + fprintf(stderr, "[ERROR] no program name\n"); + return usage(); + } + pid = _start_app(argv, appfd); + + /* Setup server */ + _server_socket = _setup_domain_socket(sun_path); + + /* Start proxy for input */ + if ((rc = pthread_create(&id, NULL, _ds2tty, (void *)&ttyfd)) < 0) { + syslog(LOG_ERR, "pthread_create: %s", strerror(rc)); + exit(EXIT_FAILURE); + } + + /* Start proxy for output */ + if ((rc = pthread_create(&id, NULL, _tty2ds, (void *)&ttyfd)) < 0) { + syslog(LOG_ERR, "pthread_create: %s", strerror(rc)); + exit(EXIT_FAILURE); + } + + /* Wait for our child to exit */ + int status; + waitpid(pid, &status, 0); + syslog(LOG_NOTICE, "child %s exited status: %d", process_name, status); + + if (WIFEXITED(status)) + { + if (WEXITSTATUS(status)) + { + return 2; + } + else + { + return 0; + } + } + else + { + return 3; + } +} diff --git a/src/sonic-sswsyncd/src/dsserve.h b/src/sonic-sswsyncd/src/dsserve.h new file mode 100644 index 000000000000..13eaa0af4b5d --- /dev/null +++ b/src/sonic-sswsyncd/src/dsserve.h @@ -0,0 +1 @@ +static const char *const DEFAULT_SUN_PATH = "/var/run/sswsyncd/sswsyncd.socket";