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

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: Blimp 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..09774ee0033144077ac9a1646e30a637851fcadd 100644
--- a/net/udp/udp_socket_posix.cc
+++ b/net/udp/udp_socket_posix.cc
@@ -425,6 +425,24 @@ int UDPSocketPosix::SetSendBufferSize(int32_t size) {
return rv == 0 ? OK : MapSystemError(errno);
}
+int UDPSocketPosix::SetDoNotFragment(bool do_not_fragment) {
+ DCHECK_NE(socket_, kInvalidSocket);
+ DCHECK(CalledOnValidThread());
+
+ int val = do_not_fragment ? IP_PMTUDISC_DO : IP_PMTUDISC_DONT;
Jeremy Dorfman 2016/08/10 23:56:57 Strictly speaking, the system default is configura
Ryan Hamilton 2016/08/11 19:47:31 Good point. I removed the argument so that this me
+ int rv = setsockopt(socket_, IPPROTO_IP, IP_MTU_DISCOVER, &val, sizeof(val));
Jeremy Dorfman 2016/08/10 23:56:57 I'm not sure what will happen if the socket is v6-
Ryan Hamilton 2016/08/11 19:47:31 How 'bout we only do one of these codepaths depend
Ryan Hamilton 2016/08/12 16:53:29 As discussed offline, doing only one codepath is p
+ if (rv != OK)
+ return MapSystemError(errno);
+
+ if (addr_family_ == AF_INET6) {
+ val = do_not_fragment ? IPV6_PMTUDISC_DO : IPV6_PMTUDISC_DONT;
+ rv =
+ setsockopt(socket_, IPPROTO_IPV6, IPV6_MTU_DISCOVER, &val, sizeof(val));
+ }
+
+ return rv == 0 ? OK : MapSystemError(errno);
+}
+
int UDPSocketPosix::AllowAddressReuse() {
DCHECK_NE(socket_, kInvalidSocket);
DCHECK(CalledOnValidThread());

Powered by Google App Engine
This is Rietveld 408576698