summaryrefslogtreecommitdiffstats
path: root/lib/sockopt.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2019-10-07 17:31:33 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2019-10-16 13:42:05 +0200
commit772aae8b1dca9b14117aa3716286d763b6f3da88 (patch)
tree93e66126f26bd599201e856ce054835b1739a2a2 /lib/sockopt.c
parentMerge pull request #5139 from donaldsharp/zebra_write_cmd_missing (diff)
downloadfrr-772aae8b1dca9b14117aa3716286d763b6f3da88.tar.xz
frr-772aae8b1dca9b14117aa3716286d763b6f3da88.zip
lib: Add getsockopt_so_recvbuf
Add a new function getsockopt_so_recvbuf which tells you the operating systems receive buffer size. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'lib/sockopt.c')
-rw-r--r--lib/sockopt.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/sockopt.c b/lib/sockopt.c
index 8e38a2927..7726d74ff 100644
--- a/lib/sockopt.c
+++ b/lib/sockopt.c
@@ -72,6 +72,21 @@ int getsockopt_so_sendbuf(const int sock)
return optval;
}
+int getsockopt_so_recvbuf(const int sock)
+{
+ uint32_t optval;
+ socklen_t optlen = sizeof(optval);
+ int ret = getsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char *)&optval,
+ &optlen);
+ if (ret < 0) {
+ flog_err_sys(EC_LIB_SYSTEM_CALL,
+ "fd %d: can't getsockopt SO_RCVBUF: %d (%s)", sock,
+ errno, safe_strerror(errno));
+ return ret;
+ }
+ return optval;
+}
+
static void *getsockopt_cmsg_data(struct msghdr *msgh, int level, int type)
{
struct cmsghdr *cmsg;