diff options
| author | Lorenzo Colitti <lorenzo@google.com> | 2011-03-30 17:26:15 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-03-30 17:26:15 -0700 |
| commit | 0dd572a5196f7887de56912b6f2a22f053f1ca34 (patch) | |
| tree | 43f22e7a7fd63bb42dac1ca6b867b2b4a51c0655 | |
| parent | 9cbac1fc0bb5e521e3e017542ca8b6477504fce7 (diff) | |
| parent | 6cf73eadc752b619bc7c38d0d1277891eccbf81d (diff) | |
| download | system_core-0dd572a5196f7887de56912b6f2a22f053f1ca34.tar.gz system_core-0dd572a5196f7887de56912b6f2a22f053f1ca34.tar.bz2 system_core-0dd572a5196f7887de56912b6f2a22f053f1ca34.zip | |
Merge "Kill IPv6 sockets as well as IPv4 sockets." into honeycomb-LTE
| -rw-r--r-- | libnetutils/ifc_utils.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/libnetutils/ifc_utils.c b/libnetutils/ifc_utils.c index e5c58b9b..946c39de 100644 --- a/libnetutils/ifc_utils.c +++ b/libnetutils/ifc_utils.c @@ -366,10 +366,12 @@ int ifc_disable(const char *ifname) int ifc_reset_connections(const char *ifname) { #ifdef HAVE_ANDROID_OS - int result; + int result, success; in_addr_t myaddr; 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); @@ -377,6 +379,21 @@ int ifc_reset_connections(const char *ifname) 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; + } + ifc_close6(); + return result; #else return 0; |
