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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/udp/udp_socket_posix.h" 5 #include "net/udp/udp_socket_posix.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <net/if.h> 9 #include <net/if.h>
10 #include <netdb.h> 10 #include <netdb.h>
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 } 418 }
419 419
420 int UDPSocketPosix::SetSendBufferSize(int32_t size) { 420 int UDPSocketPosix::SetSendBufferSize(int32_t size) {
421 DCHECK_NE(socket_, kInvalidSocket); 421 DCHECK_NE(socket_, kInvalidSocket);
422 DCHECK(CalledOnValidThread()); 422 DCHECK(CalledOnValidThread());
423 int rv = setsockopt(socket_, SOL_SOCKET, SO_SNDBUF, 423 int rv = setsockopt(socket_, SOL_SOCKET, SO_SNDBUF,
424 reinterpret_cast<const char*>(&size), sizeof(size)); 424 reinterpret_cast<const char*>(&size), sizeof(size));
425 return rv == 0 ? OK : MapSystemError(errno); 425 return rv == 0 ? OK : MapSystemError(errno);
426 } 426 }
427 427
428 int UDPSocketPosix::SetDoNotFragment(bool do_not_fragment) {
429 DCHECK_NE(socket_, kInvalidSocket);
430 DCHECK(CalledOnValidThread());
431
432 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
433 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
434 if (rv != OK)
435 return MapSystemError(errno);
436
437 if (addr_family_ == AF_INET6) {
438 val = do_not_fragment ? IPV6_PMTUDISC_DO : IPV6_PMTUDISC_DONT;
439 rv =
440 setsockopt(socket_, IPPROTO_IPV6, IPV6_MTU_DISCOVER, &val, sizeof(val));
441 }
442
443 return rv == 0 ? OK : MapSystemError(errno);
444 }
445
428 int UDPSocketPosix::AllowAddressReuse() { 446 int UDPSocketPosix::AllowAddressReuse() {
429 DCHECK_NE(socket_, kInvalidSocket); 447 DCHECK_NE(socket_, kInvalidSocket);
430 DCHECK(CalledOnValidThread()); 448 DCHECK(CalledOnValidThread());
431 DCHECK(!is_connected()); 449 DCHECK(!is_connected());
432 int true_value = 1; 450 int true_value = 1;
433 int rv = setsockopt( 451 int rv = setsockopt(
434 socket_, SOL_SOCKET, SO_REUSEADDR, &true_value, sizeof(true_value)); 452 socket_, SOL_SOCKET, SO_REUSEADDR, &true_value, sizeof(true_value));
435 return rv == 0 ? OK : MapSystemError(errno); 453 return rv == 0 ? OK : MapSystemError(errno);
436 } 454 }
437 455
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 return MapSystemError(errno); 859 return MapSystemError(errno);
842 860
843 return OK; 861 return OK;
844 } 862 }
845 863
846 void UDPSocketPosix::DetachFromThread() { 864 void UDPSocketPosix::DetachFromThread() {
847 base::NonThreadSafe::DetachFromThread(); 865 base::NonThreadSafe::DetachFromThread();
848 } 866 }
849 867
850 } // namespace net 868 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698