Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(823)

Unified Diff: net/udp/udp_socket_posix.cc

Issue 2235973002: Add a SetDoNotFragment() method to DatagramSocket, and call this for (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/udp/udp_socket_posix.h ('k') | net/udp/udp_socket_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/udp/udp_socket_posix.cc
diff --git a/net/udp/udp_socket_posix.cc b/net/udp/udp_socket_posix.cc
index 797e1a0bc1352b5a4a9a43c8c663c7acb05ab374..d76de3252c5e8cafe75f99c0578389035caf939d 100644
--- a/net/udp/udp_socket_posix.cc
+++ b/net/udp/udp_socket_posix.cc
@@ -425,6 +425,37 @@ int UDPSocketPosix::SetSendBufferSize(int32_t size) {
return rv == 0 ? OK : MapSystemError(errno);
}
+int UDPSocketPosix::SetDoNotFragment() {
+ DCHECK_NE(socket_, kInvalidSocket);
+ DCHECK(CalledOnValidThread());
+
+#if !defined(IP_PMTUDISC_DO)
+ return ERR_NOT_IMPLEMENTED;
+#else
+ if (addr_family_ == AF_INET6) {
+ int val = IPV6_PMTUDISC_DO;
+ if (setsockopt(socket_, IPPROTO_IPV6, IPV6_MTU_DISCOVER, &val,
+ sizeof(val)) != 0) {
+ return MapSystemError(errno);
+ }
+
+ int v6_only = false;
+ socklen_t v6_only_len = sizeof(v6_only);
+ if (getsockopt(socket_, IPPROTO_IPV6, IPV6_V6ONLY, &v6_only,
+ &v6_only_len) != 0) {
+ return MapSystemError(errno);
+ }
+
+ if (v6_only)
+ return OK;
+ }
+
+ int val = IP_PMTUDISC_DO;
+ int rv = setsockopt(socket_, IPPROTO_IP, IP_MTU_DISCOVER, &val, sizeof(val));
+ return rv == 0 ? OK : MapSystemError(errno);
+#endif
+}
+
int UDPSocketPosix::AllowAddressReuse() {
DCHECK_NE(socket_, kInvalidSocket);
DCHECK(CalledOnValidThread());
« no previous file with comments | « net/udp/udp_socket_posix.h ('k') | net/udp/udp_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698