Commit graph

142 commits

Author SHA1 Message Date
Lorenzo Colitti
3b56a0226b Add a libipchecksum that contains the C IP checksum code.
This is useful for test code that wants to statically link the IP
checksum code. This is not currently possible because libnetutils
is vendor_available and making it available for static linking is
discouraged.

Test: m libnetutils libipchecksum
Change-Id: Ic7f1864902581b8a5e3626860565b78c168bdb7f
2020-07-09 16:35:47 +09:00
Maciej Żenczykowski
39c26d63cd libnetutils/packet.c - create socket with close-on-exec
This prevents fork/exec leaking sockets to child processes.

Test: builds, atest
Bug: 155297277
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I57cb2003dd75b0bc5528978fd131730273e37a43
2020-05-08 22:34:37 -07:00
Maciej Żenczykowski
0129aaae86 libnetutils/packet.c - fix a raw socket reception race
A socket created bound to a specific protocol can receive packets before
it's bound to a specific interface/mac.

It's best to rely on the bind().

This replicates the way packet sockets are created in external/android-clat.
See: ring.c ring_create() and clatd.c configure_packet_socket()

Test: builds, atest
Bug: 155297277
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I569d2b81a396f352ab5d1b71bd5ad0d96217aab1
2020-05-08 22:34:37 -07:00
Maciej Żenczykowski
b7f370c014 libnetutils/packet.c - fix a socket leak on bind error
and clean up the code a little bit while at it.

Test: builds, atest
Bug: 155297277
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I01a10e36f852cde1b93a91f95b51294a434885ab
2020-05-08 22:34:37 -07:00
Maciej Żenczykowski
9943ed2597 add nodad argument to ifc_act_on_address() and add it to header file
Test: atest
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ia45f00ecc5eae035ed2e25d5b73008acb77fa6c2
2020-01-26 06:35:30 -08:00
Lorenzo Colitti
a9027581bd Properly size response buffer in ifc_act_on_address
Currently, any netlink error reported in ifc_act_on_address is
reported as EINVAL, because the receive buffer is too short and
the NLMSG_OK check fails on it.

Make the buffer long enough so the function can return the
correct netlink error to the caller.

Test: new test coverage in other CL in this topic
Change-Id: Ica752db834a0fd614312b800d88721826be08d56
2019-12-02 17:37:39 +09:00
Lorenzo Colitti
c3d38969ca Return a valid error code when adding an invalid IP address.
Currently, passing an invalid IP address to interfaceAddAddress
and friends results in an invalid error message:

    12-02 13:00:42.675 interfaceAddAddress("testtap2355", "2001:db8::1/64", 64) -> ServiceSpecificException(-8, "InterfaceController error: Unknown error -8") <1.63ms>

This is due to confusion between getaddrinfo error codes and
errno values.

Test: new unit test added to IpClientIntegrationTest
Change-Id: Ifdaa4281a9bcf3998e3216472c5c1df0f5285214
2019-12-02 13:42:20 +09:00
Maciej Żenczykowski
f0d101266f better document ifc_{add,del}_address return code
Test: N/A
Bug: 142764715
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I8ffa7985aa2ec81959d57188755e453f0551b872
2019-10-17 17:20:25 -07:00
junyulai
1e9c3a50fb Refactor OWNERS files for Android Core Networking
Bug: 120829091
Test: build/make/tools/checkowners.py -c -v path/OWNERS
Change-Id: Ia172b5e907a28441d288b84cd74ceea24c58cbcf
2019-02-12 13:25:13 +08:00
Lorenzo Colitti
2e4280dfe1 Move checksum code from clatd to libnetutils.
This allows us to use it elsewhere, for example, in netd.

Bug: 65674744
Test: builds, boots
Test: atest clatd_test clatd_microbenchmark
Change-Id: I262ddd4176dabc3b10758fb0b4eb09643aa4911c
2019-01-30 12:33:29 +09:00
Elliott Hughes
aede8375fe Merge "Add OWNERS." am: 3289b9c928
am: 515c8fe572

Change-Id: I378e0205c21a4df5baacde3432b618443f7ef567
2017-12-07 23:51:13 +00:00
Elliott Hughes
693d63f9cf Add OWNERS.
Bug: N/A
Test: N/A
Change-Id: Ie785058c0f5eb9b4086c98ccba6e63e3ed411b65
2017-12-07 13:30:03 -08:00
tintin
d60dc7ef5c libnetutil: Check dhcp respose packet length am: 61f25d4a36 am: cee6d38c55 am: 29d054046f am: c29049f4f8 am: 3de04e9840 am: 19702dc499 am: 8191e9ba87 am: 804323c195 am: 4f5f00d879 am: 3a1ff1ad71 am: bab7b1ecd9 am: cdf0fc6018
am: 9f1398c6e3

Change-Id: I4c46a36846dd8f6588f29bc84de9bc3f1d7c088a
2017-11-02 03:28:42 +00:00
tintin
9f1398c6e3 libnetutil: Check dhcp respose packet length am: 61f25d4a36 am: cee6d38c55 am: 29d054046f am: c29049f4f8 am: 3de04e9840 am: 19702dc499 am: 8191e9ba87 am: 804323c195 am: 4f5f00d879 am: 3a1ff1ad71 am: bab7b1ecd9
am: cdf0fc6018

Change-Id: If9bc99849e62fe38cdf52180ff76390c452e0784
2017-11-02 03:25:33 +00:00
tintin
cdf0fc6018 libnetutil: Check dhcp respose packet length am: 61f25d4a36 am: cee6d38c55 am: 29d054046f am: c29049f4f8 am: 3de04e9840 am: 19702dc499 am: 8191e9ba87 am: 804323c195 am: 4f5f00d879 am: 3a1ff1ad71
am: bab7b1ecd9

Change-Id: Id56f81b841d83b4b6fc75517fa165c0000dac663
2017-11-02 03:23:59 +00:00
tintin
8191e9ba87 libnetutil: Check dhcp respose packet length am: 61f25d4a36 am: cee6d38c55 am: 29d054046f am: c29049f4f8 am: 3de04e9840
am: 19702dc499

Change-Id: I5056e93b303683a70c38251f282c80e810fb317b
2017-11-02 03:11:49 +00:00
tintin
29d054046f libnetutil: Check dhcp respose packet length am: 61f25d4a36
am: cee6d38c55

Change-Id: Ieac19dd67cee1f22e019ac87b33b8afcd1200dcb
2017-11-02 03:03:42 +00:00
tintin
cee6d38c55 libnetutil: Check dhcp respose packet length
am: 61f25d4a36

Change-Id: Id5158c66d2ade871c90a2337fe867f977cefdca3
2017-11-02 03:01:40 +00:00
tintin
61f25d4a36 libnetutil: Check dhcp respose packet length
Bug: 67474440
Test: Manual

Change-Id: I84b533f0101a56ec01e64c7591f3c7e82f513b2e
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
2017-10-17 17:48:48 +00:00
Justin Yun
6a7e882316 Mark the modules as VNDK in Android.bp
As a VNDK module, Android.bp must have 'vndk' tag as well as
'vendor_available: true'.

The 'vndk' tag for VNDK module is formated as below:
vndk: {
        enabled: true,
},

VNDK modules will be installed both in system/lib(64) as normal and
in system/lib(64)/vndk as a vendor variant.

Bug: 63866913
Test: build and boot with BOARD_VNDK_VERSION=current
Merged-In: Icecb22ed2ed0f58c3168605d4cf64815e2dda750
Change-Id: Icecb22ed2ed0f58c3168605d4cf64815e2dda750
(cherry picked from commit 9b0ed72942)
2017-09-14 08:35:16 +00:00
Justin Yun
9b0ed72942 Mark the modules as VNDK in Android.bp
As a VNDK module, Android.bp must have 'vndk' tag as well as
'vendor_available: true'.

The 'vndk' tag for VNDK module is formated as below:
vndk: {
        enabled: true,
},
    
VNDK modules will be installed both in system/lib(64) as normal and
in system/lib(64)/vndk as a vendor variant.

Bug: 63866913
Test: build and boot with BOARD_VNDK_VERSION=current
Change-Id: Icecb22ed2ed0f58c3168605d4cf64815e2dda750
2017-08-03 06:43:23 +00:00
Jayant Chowdhary
9feff960e3 Mark libnetutils vendor_available.
libneutils is a library which belongs to vndk-cap. Mark it
vendor_available to enable vndk abi stability checks on it.

Details: https://android-review.googlesource.com/368372

Test: mm -j64

Bug: 38244611

Merged-In: Ief58111dea549224b3bce5cb52fd691d4381fb88
Change-Id: I32938e3e0bcc1e771290d87f561cc06b9b019046
(cherry picked from commit 409731efc1)
2017-05-31 02:02:17 +00:00
Jayant Chowdhary
409731efc1 Mark libnetutils vendor_available.
libneutils is a library which belongs to vndk-cap. Mark it
vendor_available to enable vndk abi stability checks on it.

Details: https://android-review.googlesource.com/368372

Test: mm -j64

Bug: 38244611

Change-Id: I32938e3e0bcc1e771290d87f561cc06b9b019046
2017-05-24 14:18:35 -07:00
Dmitry Shmidt
d3b2d4ff2e libnetutils: Rename dhcptool to dhcpdbg
Also print warning that IP will not allow full connectivity.

Test: Manual

Change-Id: I264c478f07236108a01e766c5264897c2000f008
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
2017-05-17 10:47:28 -07:00
Dmitry Shmidt
bc592761c9 libnetutils: Restore dhcptool
Despite it is not used for network management, it is
very convenient tool for wifi bringup and debugging.

Test: Manual

Change-Id: I045301acc2dd15d0e68d6b99c8e214865f19ebad
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
2017-05-16 14:24:18 -07:00
Colin Cross
56546c0b27 Convert libnetutils to Android.bp
See build/soong/README.md for more information.

Test: m -j checkbuild
Bug: 37567578

cherry picked from cafe889aa8

Merged-In: Ia11dffde6fc4d89be6ee651be06b48131c877dc0
Change-Id: Ia11dffde6fc4d89be6ee651be06b48131c877dc0
2017-04-28 22:22:16 +00:00
Colin Cross
cafe889aa8 Convert libnetutils to Android.bp
See build/soong/README.md for more information.

Test: m -j checkbuild
Change-Id: Ia11dffde6fc4d89be6ee651be06b48131c877dc0
2017-04-20 10:36:43 -07:00
Mark Salyzyn
30f991f251 liblog: use log/log.h when utilizing ALOG macros
Test: compile
Bug: 30465923
Change-Id: Id6d76510819ebd88c3f5003d00d73a0dbe85e943
2017-01-11 09:31:15 -08:00
Tianjie Xu
bef09aaf9e DO NOT MERGE:Add missing SOCK_CLOEXEC flag when opening socket
Go through the code that opens socket in marshmallow, and backport the
SOCK_CLOEXEC usage when opening sockets with AF_NETLINK.
Bug: 31242981
Test: mma

Change-Id: I709fc1dd43a883f95bb99021e1350c062ca35203
2016-11-03 06:08:17 +00:00
Mark Salyzyn
66ce3e08c5 system/core Replace cutils/log.h with android/log.h
Should use android/log.h instead of cutils/log.h as a good example
to all others.  Adjust header order to comply with Android Coding
standards.

Test: Compile
Bug: 26552300
Bug: 31289077
Change-Id: I2c9cbbbd64d8dccf2d44356361d9742e4a9b9031
2016-09-30 12:47:05 -07:00
Erik Kline
d72ba4489c Remove deprecated libnetutils DHCPv4 code
Change-Id: I9777730fee0f5c1877b246aa65b03e82d6f475a5
2016-09-10 09:14:51 +09:00
Elliott Hughes
9110eaab41 resolve merge conflicts of 847d963 to nyc-dev-plus-aosp
Change-Id: Ib97f56112bff71e2997116f969fd6d3e30e72f26
2016-05-18 21:26:35 -07:00
Elliott Hughes
847d963598 Remove a dead header (<netutils/dhcp.h>).
9c07eb9dd8 removed the implementation, but
missed the header file.

Bug: http://b/27192644
Change-Id: I809a3eb0081b05783b70dbca0274cdde6b1b31a6
2016-05-18 14:22:15 -07:00
Erik Kline
91bc2c9084 Merge "Set IFA_BROADCAST during IPv4 RTM_NEWADDRs" am: d709914
am: 012d35b

* commit '012d35b7f046f42d97dadd831c8201ecda2daa55':
  Set IFA_BROADCAST during IPv4 RTM_NEWADDRs

Change-Id: Ib4ac0486a06551dce8d79fb1e738e9c567328610
2016-03-31 07:10:47 +00:00
Erik Kline
e3a769529b Set IFA_BROADCAST during IPv4 RTM_NEWADDRs
Bug: 27194345
Bug: 27732412
Bug: 27786864
Change-Id: I5a5b41422bbaab4582c268c213b788f61cb0e169
(cherry picked from commit 06cb8e9203)
2016-03-31 16:00:40 +09:00
Erik Kline
06cb8e9203 Set IFA_BROADCAST during IPv4 RTM_NEWADDRs
Bug: 27194345
Bug: 27732412
Bug: 27786864
Change-Id: I5a5b41422bbaab4582c268c213b788f61cb0e169
2016-03-30 20:06:36 +09:00
Lorenzo Colitti
5e953a2909 Merge "Delete dhcpcd code in system/core, since dhcpcd is no more." into nyc-dev
am: b046e74bef

* commit 'b046e74beff221d96189c4142f42f18730565921':
  Delete dhcpcd code in system/core, since dhcpcd is no more.
2016-02-25 07:57:34 +00:00
Lorenzo Colitti
9c07eb9dd8 Delete dhcpcd code in system/core, since dhcpcd is no more.
Bug: 27192644
Change-Id: I44c2ded2da69395f12a8850b2677322b11c2cb91
2016-02-25 16:04:43 +09:00
Elliott Hughes
5ce57a6717 Merge "Move libnetutils headers into libnetutils."
am: d61ad3c44e

* commit 'd61ad3c44eba0d9b9248005a9068e6b477c06c32':
  Move libnetutils headers into libnetutils.
2016-02-16 22:11:31 +00:00
Elliott Hughes
8501751bdf Move libnetutils headers into libnetutils.
Change-Id: I8e51b369b7617e780db78c2f77c8e28d0fb93445
2016-02-12 18:10:06 -08:00
Elliott Hughes
34965eb118 Merge "libnetutils: Check socket() return value" am: e4b332c7e4
am: be6d330c18

* commit 'be6d330c18f861fe10c0b238f74cecb2c9783205':
  libnetutils: Check socket() return value
2016-01-12 04:53:01 +00:00
Bjorn Andersson
292997420c libnetutils: Check socket() return value
Add a check for socket() errors and make sure to preserve errno over the
subsequent close() calls.

Change-Id: If52d76cd3cb45044eaaf7fea9bfd4471dc66a078
2015-12-29 11:17:05 -08:00
Dmitry Shmidt
cebcd450c6 libnetutils: Add synchronization per socket full operation
Take and release mutex between ifc_init() and ifc_close()
calls to prevent global ifc_ctl_sock override.

Bug: 22307208

Change-Id: Iacffd329ce2a51defa550c7e33277332045a7b9b
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
2015-10-01 14:30:20 -07:00
Elliott Hughes
5ec940aed8 am fb1ecbc5: am e6e71608: Merge "Use __ANDROID__ instead of HAVE_ANDROID_OS."
* commit 'fb1ecbc55e7edeafb138eb2a60ca89ba9a7b1f0f':
  Use __ANDROID__ instead of HAVE_ANDROID_OS.
2015-07-30 16:50:27 +00:00
Elliott Hughes
145afc2cc4 am fb1ecbc5: am e6e71608: Merge "Use __ANDROID__ instead of HAVE_ANDROID_OS."
* commit 'fb1ecbc55e7edeafb138eb2a60ca89ba9a7b1f0f':
  Use __ANDROID__ instead of HAVE_ANDROID_OS.
2015-07-30 16:50:15 +00:00
Elliott Hughes
9b828adfad Use __ANDROID__ instead of HAVE_ANDROID_OS.
Change-Id: I9967f3fd758c2a5b40be5b60ae72be7e2fb75136
2015-07-30 09:33:43 -07:00
Elliott Hughes
9e2d8b47c8 am f91c0664: am 421d01c8: am d4196ef8: Merge "Add a command to call libnetutils\' do_dhcp."
* commit 'f91c06646ed836c25aeacc4332851c53cd1e0861':
  Add a command to call libnetutils' do_dhcp.
2015-04-22 03:32:13 +00:00
Elliott Hughes
9ab372eb22 Add a command to call libnetutils' do_dhcp.
Useful for wifi bringup.

Change-Id: Ib1d1b1d15cb9ce57119457a780e169b8f98987c2
2015-04-21 19:31:43 -07:00
Dmitry Shmidt
91dbb7eb6a am c92420b2: am d9a65a65: Merge "Improving the time to wait for assigning IP address"
* commit 'c92420b23b3006ed2e1ece6020dc9d6daa7bf336':
  Improving the time to wait for assigning IP address
2015-03-19 00:43:49 +00:00
Dmitry Shmidt
d9a65a6561 Merge "Improving the time to wait for assigning IP address" 2015-03-19 00:26:30 +00:00