projects
/
openvswitch
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ofp-print: Do not display flow mod cookie if it is UINT64_MAX
[openvswitch]
/
lib
/
socket-util.c
diff --git
a/lib/socket-util.c
b/lib/socket-util.c
index 5fe9f98ba2fd9bc2c71793891f9a2fa876fbc503..a37dfe4aa5cbf01572d87d69b0b3e6be2d6b7771 100644
(file)
--- a/
lib/socket-util.c
+++ b/
lib/socket-util.c
@@
-30,6
+30,7
@@
#include <sys/resource.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/resource.h>
#include <sys/socket.h>
#include <sys/stat.h>
+#include <sys/uio.h>
#include <sys/un.h>
#include <unistd.h>
#include "dynamic-string.h"
#include <sys/un.h>
#include <unistd.h>
#include "dynamic-string.h"
@@
-38,7
+39,7
@@
#include "poll-loop.h"
#include "util.h"
#include "vlog.h"
#include "poll-loop.h"
#include "util.h"
#include "vlog.h"
-#if AF_PACKET &&
__linux__
+#if AF_PACKET &&
LINUX_DATAPATH
#include <linux/if_packet.h>
#endif
#ifdef HAVE_NETLINK
#include <linux/if_packet.h>
#endif
#ifdef HAVE_NETLINK
@@
-50,11
+51,9
@@
VLOG_DEFINE_THIS_MODULE(socket_util);
/* #ifdefs make it a pain to maintain code: you have to try to build both ways.
* Thus, this file compiles all of the code regardless of the target, by
/* #ifdefs make it a pain to maintain code: you have to try to build both ways.
* Thus, this file compiles all of the code regardless of the target, by
- * writing "if (LINUX)" instead of "#ifdef __linux__". */
-#ifdef __linux__
-#define LINUX 1
-#else
-#define LINUX 0
+ * writing "if (LINUX_DATAPATH)" instead of "#ifdef __linux__". */
+#ifndef LINUX_DATAPATH
+#define LINUX_DATAPATH 0
#endif
#ifndef O_DIRECTORY
#endif
#ifndef O_DIRECTORY
@@
-91,15
+90,17
@@
xset_nonblocking(int fd)
}
}
}
}
-
static
int
+int
set_dscp(int fd, uint8_t dscp)
{
set_dscp(int fd, uint8_t dscp)
{
+ int val;
+
if (dscp > 63) {
return EINVAL;
}
if (dscp > 63) {
return EINVAL;
}
-
dscp
= dscp << 2;
- if (setsockopt(fd, IPPROTO_IP, IP_TOS, &
dscp, sizeof dscp
)) {
+
val
= dscp << 2;
+ if (setsockopt(fd, IPPROTO_IP, IP_TOS, &
val, sizeof val
)) {
return errno;
}
return errno;
}
@@
-180,7
+181,7
@@
lookup_ipv6(const char *host_name, struct in6_addr *addr)
* Most Open vSwitch code should not use this because it causes deadlocks:
* gethostbyname() sends out a DNS request but that starts a new flow for which
* OVS must set up a flow, but it can't because it's waiting for a DNS reply.
* Most Open vSwitch code should not use this because it causes deadlocks:
* gethostbyname() sends out a DNS request but that starts a new flow for which
* OVS must set up a flow, but it can't because it's waiting for a DNS reply.
- * The synchronous lookup also delays other activty. (Of course we can solve
+ * The synchronous lookup also delays other activ
i
ty. (Of course we can solve
* this but it doesn't seem worthwhile quite yet.) */
int
lookup_hostname(const char *host_name, struct in_addr *addr)
* this but it doesn't seem worthwhile quite yet.) */
int
lookup_hostname(const char *host_name, struct in_addr *addr)
@@
-263,7
+264,7
@@
drain_rcvbuf(int fd)
*
* On other Unix-like OSes, MSG_TRUNC has no effect in the flags
* argument. */
*
* On other Unix-like OSes, MSG_TRUNC has no effect in the flags
* argument. */
- char buffer[LINUX ? 1 : 2048];
+ char buffer[LINUX
_DATAPATH
? 1 : 2048];
ssize_t n_bytes = recv(fd, buffer, sizeof buffer,
MSG_TRUNC | MSG_DONTWAIT);
if (n_bytes <= 0 || n_bytes >= rcvbuf) {
ssize_t n_bytes = recv(fd, buffer, sizeof buffer,
MSG_TRUNC | MSG_DONTWAIT);
if (n_bytes <= 0 || n_bytes >= rcvbuf) {
@@
-332,7
+333,7
@@
make_sockaddr_un(const char *name, struct sockaddr_un *un, socklen_t *un_len,
if (strlen(name) > MAX_UN_LEN) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1);
if (strlen(name) > MAX_UN_LEN) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1);
- if (LINUX) {
+ if (LINUX
_DATAPATH
) {
/* 'name' is too long to fit in a sockaddr_un, but we have a
* workaround for that on Linux: shorten it by opening a file
* descriptor for the directory part of the name and indirecting
/* 'name' is too long to fit in a sockaddr_un, but we have a
* workaround for that on Linux: shorten it by opening a file
* descriptor for the directory part of the name and indirecting
@@
-890,6
+891,14
@@
xpipe(int fds[2])
}
}
}
}
+void
+xpipe_nonblocking(int fds[2])
+{
+ xpipe(fds);
+ xset_nonblocking(fds[0]);
+ xset_nonblocking(fds[1]);
+}
+
void
xsocketpair(int domain, int type, int protocol, int fds[2])
{
void
xsocketpair(int domain, int type, int protocol, int fds[2])
{
@@
-977,7
+986,7
@@
describe_sockaddr(struct ds *string, int fd,
}
}
#endif
}
}
#endif
-#if AF_PACKET &&
__linux__
+#if AF_PACKET &&
LINUX_DATAPATH
else if (ss.ss_family == AF_PACKET) {
struct sockaddr_ll sll;
else if (ss.ss_family == AF_PACKET) {
struct sockaddr_ll sll;
@@
-1007,7
+1016,7
@@
describe_sockaddr(struct ds *string, int fd,
}
}
-#ifdef
__linux__
+#ifdef
LINUX_DATAPATH
static void
put_fd_filename(struct ds *string, int fd)
{
static void
put_fd_filename(struct ds *string, int fd)
{
@@
-1051,7
+1060,7
@@
describe_fd(int fd)
: S_ISFIFO(s.st_mode) ? "FIFO"
: S_ISLNK(s.st_mode) ? "symbolic link"
: "unknown"));
: S_ISFIFO(s.st_mode) ? "FIFO"
: S_ISLNK(s.st_mode) ? "symbolic link"
: "unknown"));
-#ifdef
__linux__
+#ifdef
LINUX_DATAPATH
put_fd_filename(&string, fd);
#endif
}
put_fd_filename(&string, fd);
#endif
}