Merge "ANativeWindow: add setters for dimensions and fmt"
diff --git a/include/netutils/ifc.h b/include/netutils/ifc.h
index 36827ee..575e72e 100644
--- a/include/netutils/ifc.h
+++ b/include/netutils/ifc.h
@@ -34,7 +34,7 @@
extern int ifc_enable(const char *ifname);
extern int ifc_disable(const char *ifname);
-extern int ifc_reset_connections(const char *ifname);
+extern int ifc_reset_connections(const char *ifname, const int reset_mask);
extern int ifc_get_addr(const char *name, in_addr_t *addr);
extern int ifc_set_addr(const char *name, in_addr_t addr);
diff --git a/libnetutils/ifc_utils.c b/libnetutils/ifc_utils.c
index 208402c..04b0dfa 100644
--- a/libnetutils/ifc_utils.c
+++ b/libnetutils/ifc_utils.c
@@ -394,7 +394,11 @@
return result;
}
-int ifc_reset_connections(const char *ifname)
+#define RESET_IPV4_ADDRESSES 0x01
+#define RESET_IPV6_ADDRESSES 0x02
+#define RESET_ALL_ADDRESSES (RESET_IPV4_ADDRESSES | RESET_IPV6_ADDRESSES)
+
+int ifc_reset_connections(const char *ifname, const int reset_mask)
{
#ifdef HAVE_ANDROID_OS
int result, success;
@@ -402,28 +406,34 @@
struct ifreq ifr;
struct in6_ifreq ifr6;
- /* IPv4. Clear connections on the IP address. */
- ifc_init();
- ifc_get_info(ifname, &myaddr, NULL, NULL);
- ifc_init_ifr(ifname, &ifr);
- init_sockaddr_in(&ifr.ifr_addr, myaddr);
- result = ioctl(ifc_ctl_sock, SIOCKILLADDR, &ifr);
- ifc_close();
-
- /*
- * IPv6. On Linux, when an interface goes down it loses all its IPv6
- * addresses, so we don't know which connections belonged to that interface
- * So we clear all unused IPv6 connections on the device by specifying an
- * empty IPv6 address.
- */
- ifc_init6();
- // This implicitly specifies an address of ::, i.e., kill all IPv6 sockets.
- memset(&ifr6, 0, sizeof(ifr6));
- success = ioctl(ifc_ctl_sock6, SIOCKILLADDR, &ifr6);
- if (result == 0) {
- result = success;
+ if (reset_mask & RESET_IPV4_ADDRESSES) {
+ /* IPv4. Clear connections on the IP address. */
+ ifc_init();
+ ifc_get_info(ifname, &myaddr, NULL, NULL);
+ ifc_init_ifr(ifname, &ifr);
+ init_sockaddr_in(&ifr.ifr_addr, myaddr);
+ result = ioctl(ifc_ctl_sock, SIOCKILLADDR, &ifr);
+ ifc_close();
+ } else {
+ result = 0;
}
- ifc_close6();
+
+ if (reset_mask & RESET_IPV6_ADDRESSES) {
+ /*
+ * IPv6. On Linux, when an interface goes down it loses all its IPv6
+ * addresses, so we don't know which connections belonged to that interface
+ * So we clear all unused IPv6 connections on the device by specifying an
+ * empty IPv6 address.
+ */
+ ifc_init6();
+ // This implicitly specifies an address of ::, i.e., kill all IPv6 sockets.
+ memset(&ifr6, 0, sizeof(ifr6));
+ success = ioctl(ifc_ctl_sock6, SIOCKILLADDR, &ifr6);
+ if (result == 0) {
+ result = success;
+ }
+ ifc_close6();
+ }
return result;
#else
diff --git a/libnl_2/socket.c b/libnl_2/socket.c
index 1a2255e..3bcf210 100644
--- a/libnl_2/socket.c
+++ b/libnl_2/socket.c
@@ -33,12 +33,14 @@
/* Allocate new netlink socket. */
struct nl_sock *nl_socket_alloc(void)
{
- struct nl_sock *sk = (struct nl_sock *) malloc(sizeof(struct nl_sock));
+ struct nl_sock *sk;
struct timeval tv;
struct nl_cb *cb;
+ sk = (struct nl_sock *) malloc(sizeof(struct nl_sock));
if (!sk)
goto fail;
+ memset(sk, 0, sizeof(*sk));
/* Get current time */
@@ -49,7 +51,7 @@
/* Create local socket */
sk->s_local.nl_family = AF_NETLINK;
- sk->s_local.nl_pid = getpid();
+ sk->s_local.nl_pid = 0; /* Kernel fills in pid */
sk->s_local.nl_groups = 0; /* No groups */
/* Create peer socket */
@@ -76,14 +78,13 @@
{
struct nl_sock *sk = nl_socket_alloc();
if (!sk)
- goto fail;
+ return NULL;
sk->s_cb = cb;
nl_cb_get(cb);
return sk;
-fail:
- return NULL;
+
}
/* Free a netlink socket. */
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 247529f..a2d9f18 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -188,6 +188,8 @@
chown system system /sys/class/android_usb/android0/f_mass_storage/lun/file
chmod 0660 /sys/class/android_usb/android0/f_mass_storage/lun/file
+ chown system system /sys/class/android_usb/android0/f_rndis/ethaddr
+ chmod 0660 /sys/class/android_usb/android0/f_rndis/ethaddr
on boot
# basic network init
@@ -426,7 +428,6 @@
socket zygote stream 666
onrestart write /sys/android_power/request_state wake
onrestart write /sys/power/state on
- onrestart restart surfaceflinger
onrestart restart media
onrestart restart netd
@@ -438,7 +439,8 @@
service media /system/bin/mediaserver
class main
user media
- group audio camera inet net_bt net_bt_admin
+ # STOPSHIP: remove system from mediaserver groups
+ group audio camera inet net_bt net_bt_admin system
ioprio rt 4
service bootanim /system/bin/bootanimation