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

Side by Side Diff: net/base/address_tracker_linux.cc

Issue 11428141: Fix Netlink message length. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/base/address_tracker_linux.h" 5 #include "net/base/address_tracker_linux.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <linux/if.h> 8 #include <linux/if.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 109
110 // Request dump of addresses. 110 // Request dump of addresses.
111 struct sockaddr_nl peer = {}; 111 struct sockaddr_nl peer = {};
112 peer.nl_family = AF_NETLINK; 112 peer.nl_family = AF_NETLINK;
113 113
114 struct { 114 struct {
115 struct nlmsghdr header; 115 struct nlmsghdr header;
116 struct rtgenmsg msg; 116 struct rtgenmsg msg;
117 } request = {}; 117 } request = {};
118 118
119 request.header.nlmsg_len = NLMSG_LENGTH(sizeof(request)); 119 request.header.nlmsg_len = NLMSG_LENGTH(sizeof(request.msg));
120 request.header.nlmsg_type = RTM_GETADDR; 120 request.header.nlmsg_type = RTM_GETADDR;
121 request.header.nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP; 121 request.header.nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP;
122 request.header.nlmsg_pid = getpid(); 122 request.header.nlmsg_pid = getpid();
123 request.msg.rtgen_family = AF_UNSPEC; 123 request.msg.rtgen_family = AF_UNSPEC;
124 124
125 rv = HANDLE_EINTR(sendto(netlink_fd_, &request, request.header.nlmsg_len, 125 rv = HANDLE_EINTR(sendto(netlink_fd_, &request, request.header.nlmsg_len,
126 0, reinterpret_cast<struct sockaddr*>(&peer), 126 0, reinterpret_cast<struct sockaddr*>(&peer),
127 sizeof(peer))); 127 sizeof(peer)));
128 if (rv < 0) { 128 if (rv < 0) {
129 PLOG(ERROR) << "Could not send NETLINK request"; 129 PLOG(ERROR) << "Could not send NETLINK request";
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 void AddressTrackerLinux::OnFileCanWriteWithoutBlocking(int /* fd */) {} 306 void AddressTrackerLinux::OnFileCanWriteWithoutBlocking(int /* fd */) {}
307 307
308 void AddressTrackerLinux::CloseSocket() { 308 void AddressTrackerLinux::CloseSocket() {
309 if (netlink_fd_ >= 0 && HANDLE_EINTR(close(netlink_fd_)) < 0) 309 if (netlink_fd_ >= 0 && HANDLE_EINTR(close(netlink_fd_)) < 0)
310 PLOG(ERROR) << "Could not close NETLINK socket."; 310 PLOG(ERROR) << "Could not close NETLINK socket.";
311 netlink_fd_ = -1; 311 netlink_fd_ = -1;
312 } 312 }
313 313
314 } // namespace internal 314 } // namespace internal
315 } // namespace net 315 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698