Modify FrameworkListener to ignore commands that exceed the maximum
buffer length and send an error message.
Bug: 29831647
Change-Id: I9e57d1648d55af2ca0191bb47868e375ecc26950
Signed-off-by: Connor O'Brien <connoro@google.com>
(cherry picked from commit baa126dc15)
When an interface is deleted (which can happen, for example, to
the tun interfaces used for VPN and 464xlat), the kernel sends
RTM_DELADDR messages for all its IP addresses.
Currently we ignore these because we cannot fetch the interface
name. Instead, pass them up with an empty interface name so that
NetlinkHandler can do something useful for them, such as destroy
connections on the IP addresses that are being deleted.
Bug: 26976388
Change-Id: I2ced7e389228f9d665d0a87d97bd3452c8c0c98b
Packets captured and logged by the NFLOG target are unicast, so
extend to catch and decode them. To avoid escaping issues, the raw
contents are passed around as hex strings.
Bug: 18335678
Change-Id: Ib7299500baa00080a1f000f9da843eb527363353
Otherwise, need to keep previous errno.
Reproduced steps:
pre-condition:
DUT support external SDcard or Usb mass storage;
1. Insert blank(no partition) SDcard or UMS to DUT;
Expected result:
Should prompt user with storage error.
Test result:
There is no notification for error.
Error log:
01-01 01:06:49.239 I/fsck_msdos( 200): fsck_msdos terminated by exit(8)
01-01 01:06:49.239 E/Vold ( 200): /dev/block/vold/179:16 failed FS checks (I/O error)
01-01 01:06:49.239 D/Vold ( 200): Volume sdcard1 state changing 3 (Checking) -> 1 (Idle-Unmounted)
01-01 01:06:49.239 W/Vold ( 200): Returning OperationFailed - no handler for errno 0)
Root cause analysis:
1.Volume::setState will call senBroadcase to send out state notification;
2.Finally, SocketClient::sendDataLockedv was called to sent message.
In sendDataLockedv funtion, when current == iovcnt, e is 0 by default.
So Vold get incorrect errno.
Change-Id: Icb32a4193f02f22b5e3feaba177bc278f8f1f41b
Signed-off-by: Bo Huang <bo.b.huang@intel.com>
1. Accept that parseNetlinkMessage can only parse one netlink
message, because its way of returning output is to modify its
member variables (mAction, mParams, etc.). Currently, it
loops through all the messages it finds, updating its member
variables as it goes along, and always returns true at the end
of the buffer. This has the following problems:
1. Since the function always returns true even when no
messages were parsed, the caller has no way to know if
parsing succeeded, and we get lots of "No subsystem found
in netlink event" logs if the buffer did not contain any
valid messages we were interested in.
2. If there are multiple messages in the buffer, all but the
last message will be silently ignored.
3. If there are multiple messages and previous messages have
more parameters than the last one, the resulting event will
have a mixture of parameters from multiple messages.
Instead of doing all this, change the contract to "parse the
first valid message of interest in the buffer and return true,
or return false if there were no such messages", and update
the code and the comments accordingly.
2. Modify the caller (NetlinkListener) so it doesn't log an
error when parseBinaryNetlinkMessage returns false, because
this can now simply mean that we weren't interested in that
particular message. parseBinaryNetlinkMessage already logs
more informative errors.
3. Provide utility functions to check received message lengths and
to convert message types to message names.
4. Simplify logging duplicate attributes.
5. Use the appropriate IFLA_xxx macros instead of rolling our own
code to parse link state messages.
6. Move all the parsing code out to per-message-type parsing
functions to order to simplify parseBinaryNetlinkMessage.
Bug: 9180552
Change-Id: I6bbc2f7a104f618674dde2369c1fd5e93ea49430
- init: set /proc/sys/net/unix/max_dgram_qlen to 300
- libsysutils: Add listen backlog argument to startListener
- logd: set listen backlog to 300
Change-Id: Id6d37d6c937ba2d221e76258d89c9516619caeec
regression from commit a6e965578e44f9ae5f98de822ba5decec381dffc
* wrap writev with sigaction SIG_IGN SIGPIPE to emulate the
send(,,,MSG_NOSIGNAL) call it had replaced.
(cherry pick from commit 83fc720785)
BUG: 12796279
Change-Id: I14363630ada79c0a5b85bb6b2afd0a1c4d5c3109
* Foreground thread (legacy) closes connection by
reporting false return value for onDataAvailable.
* Background thread can choose instead to close the
connection asynchronously by calling release, must
return true for the onDataAvailable method.
(cherry picked from commit d7ad4e409e)
Change-Id: I70ab37d5c22b02804aa3b4dfb26cc9b75291f8b6
SocketClient:
* Replace sendDataLocked with sendDataLockedv which takes an iovec.
* Add a version of sendData, sendDatav, which takes an iovec.
* do not preserve iovec content through sendDatav
SocketListener:
* Add runOnEachSocket, which allows to to specify a SocketClientCommand to
run individually on each socket. This allows you to do broadcast-like
actions customized for each individual socket.
* Client safe list reference counting for sendBroadcast & runOnEach Socket
(cherry picked from commit a6e965578e)
Signed-off-by: Nick Kralevich <nnk@google.com>
Signed-off-by: Mark Salyzyn <salyzyn@google.com>
Change-Id: I716f89c01b4cb7af900045c7e41fac1492defb06
The kernel headers are already in the include path, and manually
adding them again will break on a multiarch build, where the
kernel headers may be different for each arch.
Change-Id: Ib13d96543f2c97b1b487a46e1748ceb2c5724169
The RDNSS options (RFC 6106) used to configure DNS servers via
router advertisements are passed from the kernel to userspace via
RTM_NEWNDUSEROPT netlink messages. Add code to NetlinkEvent to
parse them.
Also fix a compiler warning and a couple of style issues.
[Cherry-pick of b185e90dcc]
Bug: 9180552
Change-Id: I6c532c8f0ceef3afdc977a431a036df398013e1a
The change to enable address tracking via netlink incorrectly
changed the subsystem of rtnetlink events from "net" to
"interface". This broke interface add/delete notifications,
which come from the kernel with subsystem "net".
Switch back to "net" and deal with address tracking via new
action codes instead of a new subsystem.
[Cherry-pick of f34861346d]
Bug: 10433320
Change-Id: Ibf30efb426949dfd02304cc1d9adb1c005a539a6
This adds support for parsing RTM_NEWADDR and RTM_DELADDR
netlink messages received on netd's netlink socket and
formatting them them so NetlinkHandler can process them.
Address changes are notified in subsystem "address". Interface
changes, which used to be notified in subsystem "net", are now
notified in subsystem "interface" to avoid confusion.
[Cherry-pick of a4b4e9ad8e]
Bug: 10232006
Change-Id: I93a50e8de17014e118a42f5cc0eb90a0cbfa73cc
The change to enable address tracking via netlink incorrectly
changed the subsystem of rtnetlink events from "net" to
"interface". This broke interface add/delete notifications,
which come from the kernel with subsystem "net".
Switch back to "net" and deal with address tracking via new
action codes instead of a new subsystem.
Bug: 10433320
Change-Id: Ibf30efb426949dfd02304cc1d9adb1c005a539a6
This adds support for parsing RTM_NEWADDR and RTM_DELADDR
netlink messages received on netd's netlink socket and
formatting them them so NetlinkHandler can process them.
Address changes are notified in subsystem "address". Interface
changes, which used to be notified in subsystem "net", are now
notified in subsystem "interface" to avoid confusion.
Bug: 10232006
Change-Id: I93a50e8de17014e118a42f5cc0eb90a0cbfa73cc
Needed to support tethering of multiple remote Bluetooth devices.
Change-Id: I9f736affd83226e8b2fa4f0faacd3654175dd8c9
Signed-off-by: Patrik Ryd <patrik.ryd@stericsson.com>
It's up to the protocol to know when quotes are required. In the future
the response should probably all be binary blobs with lengths.
bug:6353048
Change-Id: I3f9b48ab0f4e6746d75cdc9c0c84d33f38f63661
xt_IDLETIMER events are used to infer the interface (radio) state
based on a inactivity timeout value.
Change-Id: I755eb54a048ca1c6ce0c646564d61188d8241851
This change is to make sure the users of library does not crash
if they are not handling SIGPIPE properly.
Change-Id: I4ea80d6bfc26a4bca6b901959ae3060b059d46d3
Sending 3digit code, null, binary-length and data. Current code sends
3digit code, space, null, binary-length, binary-data.
The space should not be sent.
Change-Id: I1df00a3e70805b39b6105966c7f3c613461a6858
Add a utility function to SocketClient to send a c-string code
prepended to a binary message. This is necessary to be able to
send a binary message while keeping compatible with underlying
text-based protocol.
Change-Id: Ifc6562003a687577d7deb50260533a5147ae4f97
Allows for one socket to be multiplexed for multiple requests.
Doesn't use command sequence numbers for broadcasts - would make no sense.
Doesn't alter current default behavior so OEM's using these classes
won't notice a difference.
bug:5864209
Change-Id: Ie3b19c4f81eea868569229a365c8cb7de249c2dd
The problem was: if a socket is shared between SocketListener and another
thread, only if the last reference is removed by SocketListener can the socket
be closed, otherwise the socket will leak. This sometimes happens in netd's
dnsproxyd.
This change let the SocketClient own the socket and close the socket when
the SocketClient is destructed.
Change-Id: I2865fbfe9ee4d8b3e43d7e02919dbb2d261f70de
It passes the quota2 name and the device at the time the quota was
reached.
ALERT_NAME=...
INTERFACE=...
This needs the new kernel in which xt_quota2 can log.
Change-Id: Icf5045374e1e33bdd1da0d2a2c183e70903a1fea
To workaround a binary incompatiblity with Motorola's ril.so, I had to
temporarily provide the old constructor for NetlinkListener as well as
a new contructor that takes an additional format argument.
There's still a slight chance of a problem because the size of the
NetlinkListener has changed with the addition of the
mFormat member, but so far I've not seen any obvious problem with that
incompatiblity.
Another way we could have worked around the incompatiblity is to have
netd (the main user of the new format argument to NetlinkListener) keep
track of the format itself in it's NetlinkHandler (derived from NetlinkListener)
and supply it's own version of onDataAvailable() that's almost 100% identical
to NetlinkListener's except for the decode() call. That would allow us
not to modify NetlinkListener at all. Worth considering but I think it's
more properly divided right now and we just have to make Motorola fix their
code (and ideally not use our private APIs).
This change should be reverted when Motorola's has fixed their ril to
either not use our private APIs or to use our updated ones.
Change-Id: I255cca6908444e56cbbbed7eef1fa0cf1d8f0918
Signed-off-by: Mike J. Chen <mjchen@google.com>
To make it easier to be compatible with older existing code, use
default parameters instead of separate functions for setting.
Also, reintroduce the const usage that was not in the original
changes by Stan.
Also fix some indent spacing.
Change-Id: Ice9ec7f0d5c4a0673037e2e04a764d88a98f68eb
Signed-off-by: Mike J. Chen <mjchen@google.com>
This reverts commit 1d504eeb50.
Conflicts:
libsysutils/src/NetlinkEvent.cpp
Bring back the changes from Stan Chesnutt regarding adding NETLINK_ROUTE
processing. The original commit message description was:
Add NETLINK_ROUTE processing to the netlink client code, so that Ethernet
physical-layer up/down events can be tracked. Upper layers will use these
events to enable/disable Ethernet connectivity.
The original change was reverted due to an incompatiblity with Motorola's
ril.so binary. I'll submit a patch to workaround that incompatiblity
separately.
Change-Id: I4e97ac98833b10543e654c63ecae3b9b8c7db44f
Signed-off-by: Mike J. Chen <mjchen@google.com>
Verify that netlink messages are actually from the kernel,
and not from a userspace program.
This is a manual cherry-pick from b620a0b1c7
Change-Id: I237f0a5cb56393bb3aab64a7ae5898f2bdc95cef
Digit wrote:
"You probably don't want to close the socket here without updating
c->socket as well. Otherwise, another thread holding a handle to the
client after the c->decRef() could end up sending a message to a
different socket, if the file descriptor index is reused by another
client in the meantime."
Change-Id: Icdefb5ffc0c7607325d7db761e1f04e5d868bfb7
The recent refactoring of the select() loop in SocketListener
missed a close() of the file descriptor when the onDataAvailable()
callback returns false.
Change-Id: I767caefab4b98ab350f2db2497ee2bd630f20850
+ Handle EINTR in accept(), write() and select()
+ Fix a memory leak when deleting the mClients list
+ Fix typo in SocketListener.h
Change-Id: Ie68bb3e2dbefe0dfdaa22a5cd06a42dbc4c0f8aa
This depends on frameworks/... :-(
Technically it doesn't belong in system/core at all, but of course there are
things in system/core that depend on it, so for now we'll hack around this.
Change-Id: I6aa437f18e1c09bd10fbd3333cf6998a0b6140c6
The recent refactoring of the select() loop in SocketListener
missed a close() of the file descriptor when the onDataAvailable()
callback returns false.
Change-Id: I767caefab4b98ab350f2db2497ee2bd630f20850
+ Handle EINTR in accept(), write() and select()
+ Fix a memory leak when deleting the mClients list
+ Fix typo in SocketListener.h
Change-Id: Ie68bb3e2dbefe0dfdaa22a5cd06a42dbc4c0f8aa
The issues were the following:
- The code in decode() didn't handle the degenerate case where the input buffer is full of '@'
- The code in decode() assumed the input buffer is properly zero-terminated.
- The code in decode() would not check that it doesn't overwrite the mParams[] array.
- The code in findParam() would check mParams[i] before checking the value of 'i'
Also remove un-necessary calls to strlen() at runtime.
Change-Id: I8acead959bd10d97c5380b08958fcb796248a010
This is a dependency for the DNS proxy CLs.
This CL also adds a new socket for the netd process to inherit which
is owned by the inet group. (so only apps with the INTERNET
permission can use the DNS proxy...)
Change-Id: I8a51924e0ed56c6066f77e6f1b02d39bdadac51e
This is a dependency for the DNS proxy CLs.
This CL also adds a new socket for the netd process to inherit which
is owned by the inet group. (so only apps with the INTERNET
permission can use the DNS proxy...)
Change-Id: Ic3475c697913ba85805b4e49801b65e7a1d59289
Merge commit '6fd75635d820754295557c300ccee89c643864cc' into gingerbread-plus-aosp
* commit '6fd75635d820754295557c300ccee89c643864cc':
Fetch peer credentials for local sockets