Index: net/tools/quic/quic_socket_utils.cc |
diff --git a/net/tools/quic/quic_socket_utils.cc b/net/tools/quic/quic_socket_utils.cc |
index 3202150917bbb55c9d21a5b1d0ab94e7d6bef29c..f635515a3cf651cf212308b22c052ff2c5126cb9 100644 |
--- a/net/tools/quic/quic_socket_utils.cc |
+++ b/net/tools/quic/quic_socket_utils.cc |
@@ -70,13 +70,13 @@ bool QuicSocketUtils::GetOverflowFromMsghdr(struct msghdr *hdr, |
// static |
int QuicSocketUtils::SetGetAddressInfo(int fd, int address_family) { |
int get_local_ip = 1; |
- if (address_family == AF_INET) { |
- return setsockopt(fd, IPPROTO_IP, IP_PKTINFO, |
- &get_local_ip, sizeof(get_local_ip)); |
- } else { |
- return setsockopt(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, |
+ int rc = setsockopt(fd, IPPROTO_IP, IP_PKTINFO, |
&get_local_ip, sizeof(get_local_ip)); |
+ if (rc == 0 && address_family == AF_INET6) { |
+ rc = setsockopt(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, |
+ &get_local_ip, sizeof(get_local_ip)); |
} |
+ return rc; |
} |
// static |