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

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: Fix mmenke's comments 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
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..342c94cd6612a31d762829d6f52d679be70182e0 100644
--- a/net/udp/udp_socket_posix.cc
+++ b/net/udp/udp_socket_posix.cc
@@ -425,6 +425,36 @@ 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
+ int v6_only = false;
+ if (addr_family_ == AF_INET6) {
+ socklen_t v6_only_len = sizeof(v6_only);
+ int rv =
+ getsockopt(socket_, IPPROTO_IPV6, IPV6_V6ONLY, &v6_only, &v6_only_len);
+ if (rv != 0)
+ return MapSystemError(errno);
+
+ int val = IPV6_PMTUDISC_DO;
+ rv =
+ setsockopt(socket_, IPPROTO_IPV6, IPV6_MTU_DISCOVER, &val, sizeof(val));
+ if (rv != 0)
+ return MapSystemError(errno);
+ if (v6_only)
+ return rv == 0 ? OK : MapSystemError(errno);
mmenke 2016/08/12 21:55:49 rv is always 0 here (See if statement on above lin
Ryan Hamilton 2016/08/12 22:15:26 Done. I realize that we don't actually need rv h
+ }
+
+ 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());

Powered by Google App Engine
This is Rietveld 408576698