On 31 December 2012 19:38, Laurent Vivier <laur...@vivier.eu> wrote: > @@ -1900,6 +1900,12 @@ static abi_long do_socket(int domain, int type, int > protocol) > #endif > if (domain == PF_NETLINK) > return -EAFNOSUPPORT; /* do not NETLINK socket connections possible > */ > + if (type == SOCK_PACKET) { > + /* in this case, socket() needs a network endian short */ > + protocol = tswapal(protocol); /* restore network endian long */ > + protocol = abi_ntohl(protocol); /* a host endian long */ > + protocol = htons(protocol); /* network endian short */ > + }
Are you sure this is correct for little endian guests? I've only desk-checked it rather than running a test program, but it looks to me like you end up passing the wrong value to socket(). Also it seems rather involved since we swap things three times and have an entirely new abi_* function. Either I'm completely confused or it should be enough to just have if (type == SOCK_PACKET) { protocol = tswap16(protocol); } -- PMM