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

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: 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 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() {
429 DCHECK_NE(socket_, kInvalidSocket);
430 DCHECK(CalledOnValidThread());
431
432 #if !defined(IP_PMTUDISC_DO)
433 return ERR_NOT_IMPLEMENTED;
434 #else
435 int v6_only = false;
436 if (addr_family_ == AF_INET6) {
437 socklen_t v6_only_len = sizeof(v6_only);
438 int rv =
439 getsockopt(socket_, IPPROTO_IPV6, IPV6_V6ONLY, &v6_only, &v6_only_len);
440 if (rv != 0)
441 return MapSystemError(errno);
442
443 int val = IPV6_PMTUDISC_DO;
444 rv =
445 setsockopt(socket_, IPPROTO_IPV6, IPV6_MTU_DISCOVER, &val, sizeof(val));
446 if (rv != 0)
447 return MapSystemError(errno);
448 if (v6_only)
449 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
450 }
451
452 int val = IP_PMTUDISC_DO;
453 int rv = setsockopt(socket_, IPPROTO_IP, IP_MTU_DISCOVER, &val, sizeof(val));
454 return rv == 0 ? OK : MapSystemError(errno);
455 #endif
456 }
457
428 int UDPSocketPosix::AllowAddressReuse() { 458 int UDPSocketPosix::AllowAddressReuse() {
429 DCHECK_NE(socket_, kInvalidSocket); 459 DCHECK_NE(socket_, kInvalidSocket);
430 DCHECK(CalledOnValidThread()); 460 DCHECK(CalledOnValidThread());
431 DCHECK(!is_connected()); 461 DCHECK(!is_connected());
432 int true_value = 1; 462 int true_value = 1;
433 int rv = setsockopt( 463 int rv = setsockopt(
434 socket_, SOL_SOCKET, SO_REUSEADDR, &true_value, sizeof(true_value)); 464 socket_, SOL_SOCKET, SO_REUSEADDR, &true_value, sizeof(true_value));
435 return rv == 0 ? OK : MapSystemError(errno); 465 return rv == 0 ? OK : MapSystemError(errno);
436 } 466 }
437 467
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 return MapSystemError(errno); 871 return MapSystemError(errno);
842 872
843 return OK; 873 return OK;
844 } 874 }
845 875
846 void UDPSocketPosix::DetachFromThread() { 876 void UDPSocketPosix::DetachFromThread() {
847 base::NonThreadSafe::DetachFromThread(); 877 base::NonThreadSafe::DetachFromThread();
848 } 878 }
849 879
850 } // namespace net 880 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698