aboutsummaryrefslogtreecommitdiff
path: root/lib/netlink-socket.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2012-08-17 15:40:03 -0700
committerBen Pfaff <blp@nicira.com>2013-02-01 10:33:50 -0800
commit80af5ee5a526706a80dc772d5d79b7894771b4be (patch)
tree36f43fea6302547c6a069ea582db258184377204 /lib/netlink-socket.c
parentda78d43d752dbd438236bb11ca440c9c31896393 (diff)
netlink-socket: Don't bother logging SO_RCVBUFFORCE failure as non-root.
Some Open vSwitch utilities can do useful work when they are not run as root. Without this commit, these utilities will log a warning on failure to use the SO_RCVBUFFORCE socket option if they open any Netlink sockets. This will always happen, it does not report anything unexpected or fixable as non-root, and sometimes it makes users wonder if something is wrong, so there is no benefit to logging it. This commit drops it in that case. Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'lib/netlink-socket.c')
-rw-r--r--lib/netlink-socket.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/netlink-socket.c b/lib/netlink-socket.c
index 847f11f1..e6b10a18 100644
--- a/lib/netlink-socket.c
+++ b/lib/netlink-socket.c
@@ -128,8 +128,12 @@ nl_sock_create(int protocol, struct nl_sock **sockp)
rcvbuf = 1024 * 1024;
if (setsockopt(sock->fd, SOL_SOCKET, SO_RCVBUFFORCE,
&rcvbuf, sizeof rcvbuf)) {
- VLOG_WARN_RL(&rl, "setting %d-byte socket receive buffer failed (%s)",
- rcvbuf, strerror(errno));
+ /* Only root can use SO_RCVBUFFORCE. Everyone else gets EPERM.
+ * Warn only if the failure is therefore unexpected. */
+ if (errno != EPERM || !getuid()) {
+ VLOG_WARN_RL(&rl, "setting %d-byte socket receive buffer failed "
+ "(%s)", rcvbuf, strerror(errno));
+ }
}
retval = get_socket_rcvbuf(sock->fd);