Make sctp buffers big enough for images
We had multiple problems.
1) kernel buffers were too small so the kernel was delivering partial
packets. Fix was to update the rootfs to increase the buffer size
and check the parameter. Secondary fix was to CHECK that received
packets were the size advertized.
2) Client wasn't configuring it's buffers to be the right size.
Configured the socket to make it big enough.
Change-Id: I276e698943aa5714ff2ca8e1ac73d6975d219eb9
diff --git a/aos/network/sctp_lib.cc b/aos/network/sctp_lib.cc
index 7e32bb4..1e985f3 100644
--- a/aos/network/sctp_lib.cc
+++ b/aos/network/sctp_lib.cc
@@ -4,9 +4,14 @@
#include <net/if.h>
#include <netdb.h>
#include <netinet/sctp.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
#include <string_view>
+#include "aos/util/file.h"
+
DEFINE_string(interface, "", "ipv6 interface");
namespace aos {
@@ -193,8 +198,6 @@
PCHECK((size = recvmsg(fd, &inmessage, 0)) > 0);
result->size = size;
- CHECK_LE(size, max_size) << ": Message overflowed buffer.";
-
if ((MSG_NOTIFICATION & inmessage.msg_flags)) {
result->message_type = Message::kNotification;
} else {
@@ -214,6 +217,9 @@
}
}
+ CHECK_LE(size, max_size) << ": Message overflowed buffer on stream "
+ << result->header.rcvinfo.rcv_sid << ".";
+
return result;
}
@@ -226,5 +232,29 @@
<< " cumtsn=" << header.rcvinfo.rcv_cumtsn << ")";
}
+size_t ReadRMemMax() {
+ struct stat current_stat;
+ if (stat("/proc/sys/net/core/rmem_max", ¤t_stat) != -1) {
+ return static_cast<size_t>(
+ std::stoi(util::ReadFileToStringOrDie("/proc/sys/net/core/rmem_max")));
+ } else {
+ LOG(WARNING) << "/proc/sys/net/core/rmem_max doesn't exist. Are you in a "
+ "container?";
+ return 212992;
+ }
+}
+
+size_t ReadWMemMax() {
+ struct stat current_stat;
+ if (stat("/proc/sys/net/core/wmem_max", ¤t_stat) != -1) {
+ return static_cast<size_t>(
+ std::stoi(util::ReadFileToStringOrDie("/proc/sys/net/core/wmem_max")));
+ } else {
+ LOG(WARNING) << "/proc/sys/net/core/wmem_max doesn't exist. Are you in a "
+ "container?";
+ return 212992;
+ }
+}
+
} // namespace message_bridge
} // namespace aos