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

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 !$ 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..112f119d51888cafc8977ceff05faf834227bd9f 100644
--- a/net/udp/udp_socket_posix.cc
+++ b/net/udp/udp_socket_posix.cc
@@ -425,6 +425,35 @@ 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 OK;
mmenke 2016/08/12 19:46:05 It's considered a success if we can't set this? I
Ryan Hamilton 2016/08/12 21:46:02 Good point. Changed it to return NOT_IMPLEMENTED.
+#else
+ int v6_only = false;
+ if (addr_family_ == AF_INET6) {
+ socklen_t v6_only_len = sizeof(v6_only);
+ getsockopt(socket_, IPPROTO_IPV6, IPV6_V6ONLY, &v6_only, &v6_only_len);
mmenke 2016/08/12 19:46:05 What if getsockopt fails? Do we care?
Ryan Hamilton 2016/08/12 21:46:02 Good point. I don't think we *really* care, but mi
+ }
+
+ int rv;
+ if (addr_family_ == AF_INET6) {
mmenke 2016/08/12 19:46:05 Should this be merged with the above if block? Co
Ryan Hamilton 2016/08/12 21:46:02 Ah, yes. This code moved around so I missed that.
+ int val = IPV6_PMTUDISC_DO;
mmenke 2016/08/12 19:46:05 IP_PMTUDISC_DO being defined guarantees IPV6_PMTUD
Ryan Hamilton 2016/08/12 21:46:02 As far as I can tell. It's true for all our trybot
+ rv =
+ setsockopt(socket_, IPPROTO_IPV6, IPV6_MTU_DISCOVER, &val, sizeof(val));
+ if (rv != 0)
+ return MapSystemError(errno);
+ }
+ if (!v6_only) {
+ int val = IP_PMTUDISC_DO;
+ 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