[ovs-dev] [PATCH] stream-unix: only use path-based socket names
Ben Pfaff
blp at ovn.org
Mon Jul 18 18:13:50 UTC 2016
On Fri, Jul 08, 2016 at 10:01:53AM -0300, Thadeu Lima de Souza Cascardo wrote:
> FreeBSD returns a socklen of sockaddr_storage when doing an accept on an unix
> STREAM socket. The current code will assume it means a sun_path larger than 0.
>
> That breaks some tests like the one below which don't expect to find "unix::" on
> the logs.
>
> As a Linux abstract address would not have a more useful name either, it's
> better to check that sun_path starts with a non-zero byte as well as checking
> the length.
>
> 402: ovs-ofctl replace-flows with --bundle FAILED (ovs-ofctl.at:2928)
> 2016-07-08T12:44:30.068Z|00020|vconn|DBG|unix:: sent (Success): OFPT_HELLO (OF1.6) (xid=0x1):
>
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo at redhat.com>
> ---
> lib/stream-unix.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/stream-unix.c b/lib/stream-unix.c
> index cadd180..76206f8 100644
> --- a/lib/stream-unix.c
> +++ b/lib/stream-unix.c
> @@ -113,7 +113,7 @@ punix_accept(int fd, const struct sockaddr_storage *ss, size_t ss_len,
> int name_len = get_unix_name_len(ss_len);
> char name[128];
>
> - if (name_len > 0) {
> + if (name_len > 0 && sun->sun_path[0] != 0) {
> snprintf(name, sizeof name, "unix:%.*s", name_len, sun->sun_path);
> } else {
> strcpy(name, "unix");
It seems like it's probably better to fix this in get_unix_name_len(),
probably by passing in both sun and ss_len. I realize that
get_unix_name_len() only has a single caller right now but it still
seems better to get it right there.
More information about the dev
mailing list