summaryrefslogtreecommitdiff
path: root/lib/socket-util.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Convert remaining network-byte-order "uint<N>_t"s into "ovs_be<N>"s.Ben Pfaff2011-05-161-3/+3
| | | | | | | | | I looked at almost every uint<N>_t in the tree to determine whether it was really in network byte order, and converted the ones that were. The only remaining ones, modulo my mistakes, are in openflow.h. I'm not sure whether we should convert those, because there might be some value in remaining close to upstream for this header.
* poll-loop: Make wakeup logging more portable and easier to understand.Ben Pfaff2011-05-131-0/+155
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Until now, when the poll_loop module's log level was turned up to "debug", it would log a backtrace of the call stack for the event that caused poll() to wake up in poll_block(). This was pretty useful from time to time to find out why ovs-vswitchd was using more CPU than expected, because we could find out what was causing it to wake up. But there were some issues. One is simply that the backtrace was printed as a series of hexadecimal numbers, so GDB or another debugger was needed to translate it into human-readable format. Compiler optimizations meant that even the human-readable backtrace wasn't, in my experience, as helpful as it could have been. And, of course, one needed to have the binary to interpret the backtrace. When the backtrace couldn't be interpreted or wasn't meaningful, there was essentially nothing to fall back on. This commit changes the way that "debug" logging for poll_block() wakeups works. Instead of logging a backtrace, it logs the source code file name and line number of the call to a poll_loop function, using __FILE__ and __LINE__. This is by itself much more meaningful than a sequence of hexadecimal numbers, since no additional interpretation is necessary. It can be useful even if the Open vSwitch version is only approximately known. In addition to the file and line, this commit adds, for wakeups caused by file descriptors, information about the file descriptor itself: what kind of file it is (regular file, directory, socket, etc.), the name of the file (on Linux only), and the local and remote endpoints for socket file descriptors. Here are a few examples of the new output format: 932-ms timeout at ../ofproto/in-band.c:507 [POLLIN] on fd 20 (192.168.0.20:35388<->192.168.0.3:6633) at ../lib/stream-fd.c:149 [POLLIN] on fd 7 (FIFO pipe:[48049]) at ../lib/fatal-signal.c:168
* socket-util: Use portable solution for setting Unix socket permissions.Ben Pfaff2011-04-211-7/+0
| | | | Requested-by: Jesse Gross <jesse@nicira.com>
* socket-util: Properly set socket permissions in make_unix_socket().Ben Pfaff2011-04-191-3/+20
| | | | | | | | | | | | | | | | Under Linux, at least, bind and fchmod interact for Unix sockets in a way that surprised me. Calling fchmod() on a Unix socket successfully sets the permissions for the socket's own inode. But that has no effect on any inode that has already been created in the file system by bind(), because that inode is not the same as the one for the Unix socket itself. However, if you bind() *after* calling fchmod(), then the bind() takes the permissions for the new inode from the Unix socket inode, which has the desired effect. This also adds a more portable fallback for non-Linux systems. Reported-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
* Log anything that could prevent a daemon from starting.Ben Pfaff2011-04-041-0/+7
| | | | | If a daemon doesn't start, we need to know why. Being able to consistently consult the log to find out is helpful.
* util: New function ovs_strzcpy().Ben Pfaff2011-02-221-2/+1
| | | | | | | | Static analyzers hate strncpy(). This new function shares its property of initializing an entire buffer, without its nasty habit of failing to null-terminate long strings. Coverity #10697,10696,10695,10694,10693,10692,10691,10690.
* socket-util: Free strings in make_sockaddr_un() error handling.Justin Pettit2011-02-221-0/+2
| | | | Coverity #10721,10720
* nicira-ext: Support matching IPv6 traffic.Justin Pettit2011-02-021-0/+14
| | | | | | | | | | | | | | | | | Provides ability to match over IPv6 traffic in the same manner as IPv4. Currently, the matching fields include: - IPv6 source and destination addresses (ipv6_src and ipv6_dst) - Traffic Class (nw_tos) - Next Header (nw_proto) - ICMPv6 Type and Code (icmp_type and icmp_code) - TCP and UDP Ports over IPv6 (tp_src and tp_dst) When defining IPv6 rules, the Nicira Extensible Match (NXM) extension to OVS must be used. Signed-off-by: Justin Pettit <jpettit@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* Fix non-static instances of "struct vlog_rate_limit" and add check.Ben Pfaff2011-01-121-3/+3
| | | | A non-static vlog_rate_limit is not actually going to rate-limit anything.
* socket-util: Work around Unix domain socket path name limits on Linux.Ben Pfaff2010-11-101-9/+98
| | | | | | | | | | | | | | | | | | Many Open vSwitch tests fail on Debian's automatic build machines because the builds occur in deeply nested directories with long names. OVS tries to bind and connect to Unix domain sockets using absolute path names, which in combination with long directory names means that the socket's name exceeds the limit for Unix domain socket names (108 bytes on Linux). This commit works around the problem on Linux by indirecting through /proc/self/fd/<dirfd>/<basename> when names exceed the maximum that can be used directly. Reported-by: Hector Oron <hector.oron@gmail.com> Reported-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc> Reported-by: Roger Leigh <rleigh@codelibre.net> Debian bug #602891. Debian bug #602911.
* socket-util: Define LINUX macro at top of file.Ben Pfaff2010-11-101-6/+10
| | | | This will be used further in the following commit.
* vlog: Make client supply semicolon for VLOG_DEFINE_THIS_MODULE.Ben Pfaff2010-10-291-1/+1
| | | | | It's kind of odd for VLOG_DEFINE_THIS_MODULE to supply its own semicolon, so this commit switches to the more common form.
* treewide: Remove trailing whitespaceJoe Perches2010-08-301-3/+3
| | | | | | Signed-off-by: Joe Perches <joe@perches.com> Acked-by: Simon Horman <horms@verge.net.au> Signed-off-by: Jesse Gross <jesse@nicira.com>
* socket-util: Suppress uninitialized variable warning with old GCC.Bryan Phillippe2010-08-201-1/+1
|
* socket-util: Remove stray printf() from make_unix_socket().Bryan Phillippe2010-08-201-1/+0
|
* vlog: Introduce VLOG_DEFINE_THIS_MODULE for declaring vlog module in use.Ben Pfaff2010-07-211-2/+2
| | | | | | | Adding a macro to define the vlog module in use adds a level of indirection, which makes it easier to change how the vlog module must be defined. A followup commit needs to do that, so getting these widespread changes out of the way first should make that commit easier to review.
* socket-util: Tolerate missing RLIM_SAVED_CUR and RLIM_SAVED_MAX.Ben Pfaff2010-05-261-4/+23
| | | | POSIX requires these macros, but FreeBSD 8.0 doesn't have them.
* Add some missing "#include"s.Ben Pfaff2010-05-261-0/+2
| | | | These are required to build on FreeBSD 8.0.
* socket-util: Move get_mtime() here from stream-ssl.Ben Pfaff2010-04-261-0/+28
| | | | | An upcoming commit will add a new user for this function in another file, so export it and move it to a common library file.
* socket-util: Factor out new function inet_parse_active().Ben Pfaff2010-04-261-29/+52
| | | | | An upcoming commit needs to parse connection strings without connecting to them, so this change enables that.
* ovsdb: Factor out code to fsync a file's containing directory.Ben Pfaff2010-02-151-0/+31
| | | | | In an upcoming commit, another function wants to do the same thing, so break it out into a helper function.
* Merge "master" into "next".Ben Pfaff2010-02-111-1/+1
|\ | | | | | | | | The main change here is the need to update all of the uses of UNUSED in the next branch to OVS_UNUSED as it is now spelled on "master".
| * Rename UNUSED macro to OVS_UNUSED to avoid naming conflict.Ben Pfaff2010-02-111-2/+2
| | | | | | | | Requested by Jean Tourrilhes <jt@hpl.hp.com>.
* | socket-util: Make inet_open_passive() pass back the bound address.Ben Pfaff2010-01-071-2/+21
| | | | | | | | This feature is useful in an upcoming commit.
* | socket-util: Allow binding without a port number in inet_open_passive().Ben Pfaff2010-01-071-9/+15
| | | | | | | | | | | | | | | | The test-vconn program binds a socket to a nonspecific port number. To add SSL support to this program, it needs to be able to use SSL, and the stream library is the easiest way to do that. But the stream library can't bind to a nonspecific port. This commit adds that feature, by adding it to the function that the stream SSL library uses as a building block.
* | socket-util: Clarify EAGAIN error code for make_unix_socket().Ben Pfaff2009-12-111-1/+2
|/ | | | | | | | make_unix_socket() can return EAGAIN in rare circumstances, e.g. when the server's socket listen queue is full. A lot of OVS callers interpret EAGAIN as a "try again" error code, but in this case it means that the attempt to create the socket failed. So munge EAGAIN into another error code to prevent that misinterpretation.
* socket-util: Generalize tcp_open_*() to UDP, as inet_open_*().Ben Pfaff2009-11-231-16/+21
| | | | | | | The tcp_open_active() and tcp_open_passive() functions don't really have any strong dependencies on TCP. With a couple of simple changes they can be used for UDP also. Since this is useful for Netflow, this commit does so.
* socket-util: Make TCP open function support no default port.Ben Pfaff2009-11-231-6/+15
| | | | | | | | | | Until now, tcp_open_active() and tcp_open_passive() have only been used in situations where there is a reasonable default port, e.g. OFP_TCP_PORT. But for NetFlow there is no universal default, so enhance these functions so that they can require the user to specify a port explicitly. Crossported from the 'db' branch, where this is useful for JSON-RPC, which also has no widely known port.
* Merge commit 'origin/citrix'Justin Pettit2009-07-281-15/+6
|\ | | | | | | | | | | Conflicts: configure.ac
| * Do not try to resolve DNS for OpenFlow controllers or netflow collectors.Ben Pfaff2009-07-211-15/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Until now, setting a netflow collector to a DNS name would cause secchan to attempt to resolve that DNS name each time that the set of netflow collectors is re-set. For the vswitch, this is every time that the vswitch reconfigures itself. Unfortunately, DNS lookup within secchan cannot work as currently implemented, because it needs both an asynchronous DNS resolver library and in-band control updates. Currently we have neither. Attempting to look up DNS anyway just hangs. This commit disables DNS lookup entirely, and updates the documentation to change user expectations. DNS still won't work, but at least it won't hang. Bug #1609.
* | Merge citrix branch into master.Ben Pfaff2009-07-161-0/+18
|\ \ | |/
| * Add function get_null_fd(), to reduce code redundancy.Ben Pfaff2009-07-161-0/+18
| |
* | Merge changes from citrix branch into master.Ben Pfaff2009-06-151-10/+10
|\ \ | |/
| * Update primary code license to Apache 2.0.Ben Pfaff2009-06-151-10/+10
| |
* | vconn: Factor out common code from TCP and SSL vconns.Ben Pfaff2009-06-121-0/+167
|/ | | | | | | | | The TCP and SSL vconn implementations had a lot of common code to make and accept TCP connections, which this commit factors out into common functions in socket-util.c. Also adds the ability to bind ptcp and pssl vconns to a particular IP address instead of the wildcard address.
* Import from old repository commit 61ef2b42a9c4ba8e1600f15bb0236765edc2ad45.v0.90.0Ben Pfaff2009-07-081-0/+343