static int
bind_unix_socket(int fd, struct sockaddr *sun, socklen_t sun_len)
{
-#ifdef __linux__
- /* On Linux, calling fchmod() *before* bind() sets permissions for the file
- * about to be created. Calling fchmod() *after* bind has no effect on the
- * file that was created.) */
- return fchmod(fd, 0700) || bind(fd, sun, sun_len) ? errno : 0;
-#else
/* According to _Unix Network Programming_, umask should affect bind(). */
mode_t old_umask = umask(0077);
int error = bind(fd, sun, sun_len) ? errno : 0;
umask(old_umask);
return error;
-#endif
}
/* Creates a Unix domain socket in the given 'style' (either SOCK_DGRAM or
: 0);
}
-uint32_t
-guess_netmask(uint32_t ip)
+ovs_be32
+guess_netmask(ovs_be32 ip_)
{
- ip = ntohl(ip);
+ uint32_t ip = ntohl(ip_);
return ((ip >> 31) == 0 ? htonl(0xff000000) /* Class A */
: (ip >> 30) == 2 ? htonl(0xffff0000) /* Class B */
: (ip >> 29) == 6 ? htonl(0xffffff00) /* Class C */