[ovs-dev] [PATCH] stream-unix: append ovs_rundir to socket
Ethan Jackson
ethan at nicira.com
Wed Feb 6 01:08:35 UTC 2013
This isn't a full review of the patch, but have you considered using
xasprintf() instead of doing the string manipulation by hand?
Ethan
On Tue, Feb 5, 2013 at 5:07 PM, Pavithra Ramesh <paramesh at vmware.com> wrote:
> If socket path specified is relative to ovs_rundir(),
> append the directory name to in unix_open.
>
> Signed-off-by: Pavithra Ramesh <paramesh at vmware.com>
> ---
> lib/stream-unix.c | 12 +++++++++++-
> 1 files changed, 11 insertions(+), 1 deletions(-)
>
> diff --git a/lib/stream-unix.c b/lib/stream-unix.c
> index 6ed7648..8764b6c 100644
> --- a/lib/stream-unix.c
> +++ b/lib/stream-unix.c
> @@ -42,9 +42,19 @@ static int
> unix_open(const char *name, char *suffix, struct stream **streamp,
> uint8_t dscp OVS_UNUSED)
> {
> - const char *connect_path = suffix;
> + const char *ovsDir = ovs_rundir();
> + char *new_path, *connect_path = suffix;
> int fd;
>
> + if ((!strstr(suffix, ovsDir)) {
> + /* alloc one byte for '/' and one for null terminator */
> + new_path = (char *)xmalloc(strlen(ovsDir) + strlen(suffix) + 2);
> + strncpy(new_path, ovsDir, strlen(ovsDir));
> + new_path[strlen(ovsDir)] = '/';
> + new_path[strlen(ovsDir) + 1] = '\0';
> + strncat(new_path, suffix, strlen(suffix));
> + connect_path = new_path;
> + }
> fd = make_unix_socket(SOCK_STREAM, true, NULL, connect_path);
> if (fd < 0) {
> VLOG_DBG("%s: connection failed (%s)", connect_path, strerror(-fd));
> --
> 1.7.0.4
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
More information about the dev
mailing list