X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fsocket-util.c;h=f8b44cc18741945cdd5ab7505e7dfbe4fe43389b;hb=8c8c0f3a9662f612752beaf67c68a25722f496a9;hp=5fe9f98ba2fd9bc2c71793891f9a2fa876fbc503;hpb=fd94a42c43ff4a0e57a44bdc9ded1b7e1e63faaa;p=sliver-openvswitch.git diff --git a/lib/socket-util.c b/lib/socket-util.c index 5fe9f98ba..f8b44cc18 100644 --- a/lib/socket-util.c +++ b/lib/socket-util.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include "dynamic-string.h" @@ -91,15 +92,17 @@ xset_nonblocking(int fd) } } -static int +int set_dscp(int fd, uint8_t dscp) { + int val; + 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; } @@ -180,7 +183,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. - * The synchronous lookup also delays other activty. (Of course we can solve + * The synchronous lookup also delays other activity. (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) @@ -890,6 +893,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]) {