summaryrefslogtreecommitdiffstats
path: root/libsysutils
diff options
context:
space:
mode:
authorChenbo Feng <fengc@google.com>2018-03-02 01:32:53 -0800
committerChenbo Feng <fengc@google.com>2018-03-07 11:39:52 +0900
commit5e5e5e9a733d9427064f6fb0a72df9769f634d92 (patch)
tree53b7e9ae4dd887dc0622dce70e41e030c349ec43 /libsysutils
parentd555e08224d2a08f4f12c16ae4109b63b9f7def9 (diff)
downloadsystem_core-5e5e5e9a733d9427064f6fb0a72df9769f634d92.tar.gz
system_core-5e5e5e9a733d9427064f6fb0a72df9769f634d92.tar.bz2
system_core-5e5e5e9a733d9427064f6fb0a72df9769f634d92.zip
Include iface index in the netlink event
The TrafficController inside netd also get notified when the interface on device added or removed, and it need both ifaceName and ifaceIndex information from Netlink event. Add the ifaceIndex in the event can avoid the TrafficController to run if_nametoindex again when receive the event. Bug: 30950746 Bug: 73137611 Test: new interface show up in bpf interface map. Change-Id: Ia3b4aeb8eff345ce7cf03ccec88f0893cfe125c0
Diffstat (limited to 'libsysutils')
-rw-r--r--libsysutils/src/NetlinkEvent.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/libsysutils/src/NetlinkEvent.cpp b/libsysutils/src/NetlinkEvent.cpp
index 7f92904f2..35a30639b 100644
--- a/libsysutils/src/NetlinkEvent.cpp
+++ b/libsysutils/src/NetlinkEvent.cpp
@@ -137,6 +137,12 @@ bool NetlinkEvent::parseIfInfoMessage(const struct nlmsghdr *nh) {
switch(rta->rta_type) {
case IFLA_IFNAME:
asprintf(&mParams[0], "INTERFACE=%s", (char *) RTA_DATA(rta));
+ // We can get the interface change information from sysfs update
+ // already. But in case we missed those message when devices start.
+ // We do a update again when received a kLinkUp event. To make
+ // the message consistent, use IFINDEX here as well since sysfs
+ // uses IFINDEX.
+ asprintf(&mParams[1], "IFINDEX=%d", ifi->ifi_index);
mAction = (ifi->ifi_flags & IFF_LOWER_UP) ? Action::kLinkUp :
Action::kLinkDown;
mSubsystem = strdup("net");