diff options
Diffstat (limited to 'meta-networking/recipes-daemons/autofs/autofs-5.0.7/autofs-5.0.7-fix-ipv6-proximity-calculation.patch')
| -rw-r--r-- | meta-networking/recipes-daemons/autofs/autofs-5.0.7/autofs-5.0.7-fix-ipv6-proximity-calculation.patch | 297 |
1 files changed, 0 insertions, 297 deletions
diff --git a/meta-networking/recipes-daemons/autofs/autofs-5.0.7/autofs-5.0.7-fix-ipv6-proximity-calculation.patch b/meta-networking/recipes-daemons/autofs/autofs-5.0.7/autofs-5.0.7-fix-ipv6-proximity-calculation.patch deleted file mode 100644 index b341ecdd50..0000000000 --- a/meta-networking/recipes-daemons/autofs/autofs-5.0.7/autofs-5.0.7-fix-ipv6-proximity-calculation.patch +++ /dev/null | |||
| @@ -1,297 +0,0 @@ | |||
| 1 | autofs-5.0.7 - fix ipv6 proximity calculation | ||
| 2 | |||
| 3 | From: Ian Kent <ikent@redhat.com> | ||
| 4 | |||
| 5 | The socket based ioctl used to get interface information only | ||
| 6 | return IPv4 information. Change get_proximity() function to use | ||
| 7 | getifaddrs(3) instead. | ||
| 8 | --- | ||
| 9 | |||
| 10 | CHANGELOG | 1 | ||
| 11 | modules/replicated.c | 149 ++++++++++++++------------------------------------ | ||
| 12 | 2 files changed, 42 insertions(+), 108 deletions(-) | ||
| 13 | |||
| 14 | |||
| 15 | diff --git a/CHANGELOG b/CHANGELOG | ||
| 16 | index dc38580..34c70fa 100644 | ||
| 17 | --- a/CHANGELOG | ||
| 18 | +++ b/CHANGELOG | ||
| 19 | @@ -2,6 +2,7 @@ | ||
| 20 | ======================= | ||
| 21 | - fix nobind sun escaped map entries. | ||
| 22 | - fix use cache entry after free in lookup_prune_one_cache(). | ||
| 23 | +- fix ipv6 proximity calculation. | ||
| 24 | |||
| 25 | 25/07/2012 autofs-5.0.7 | ||
| 26 | ======================= | ||
| 27 | diff --git a/modules/replicated.c b/modules/replicated.c | ||
| 28 | index 78046c6..bd6003b 100644 | ||
| 29 | --- a/modules/replicated.c | ||
| 30 | +++ b/modules/replicated.c | ||
| 31 | @@ -52,6 +52,7 @@ | ||
| 32 | #include <net/if.h> | ||
| 33 | #include <netinet/in.h> | ||
| 34 | #include <netdb.h> | ||
| 35 | +#include <ifaddrs.h> | ||
| 36 | |||
| 37 | #include "rpc_subs.h" | ||
| 38 | #include "replicated.h" | ||
| 39 | @@ -110,58 +111,18 @@ void seed_random(void) | ||
| 40 | return; | ||
| 41 | } | ||
| 42 | |||
| 43 | -static int alloc_ifreq(struct ifconf *ifc, int sock) | ||
| 44 | -{ | ||
| 45 | - int ret, lastlen = ifc_last_len, len = ifc_buf_len; | ||
| 46 | - char err_buf[MAX_ERR_BUF], *buf; | ||
| 47 | - | ||
| 48 | - while (1) { | ||
| 49 | - buf = malloc(len); | ||
| 50 | - if (!buf) { | ||
| 51 | - char *estr = strerror_r(errno, err_buf, MAX_ERR_BUF); | ||
| 52 | - logerr("malloc: %s", estr); | ||
| 53 | - return 0; | ||
| 54 | - } | ||
| 55 | - | ||
| 56 | - ifc->ifc_len = len; | ||
| 57 | - ifc->ifc_req = (struct ifreq *) buf; | ||
| 58 | - | ||
| 59 | - ret = ioctl(sock, SIOCGIFCONF, ifc); | ||
| 60 | - if (ret == -1) { | ||
| 61 | - char *estr = strerror_r(errno, err_buf, MAX_ERR_BUF); | ||
| 62 | - logerr("ioctl: %s", estr); | ||
| 63 | - free(buf); | ||
| 64 | - return 0; | ||
| 65 | - } | ||
| 66 | - | ||
| 67 | - if (ifc->ifc_len <= lastlen) | ||
| 68 | - break; | ||
| 69 | - | ||
| 70 | - lastlen = ifc->ifc_len; | ||
| 71 | - len += MAX_IFC_BUF; | ||
| 72 | - free(buf); | ||
| 73 | - } | ||
| 74 | - | ||
| 75 | - if (lastlen != ifc_last_len) { | ||
| 76 | - ifc_last_len = lastlen; | ||
| 77 | - ifc_buf_len = len; | ||
| 78 | - } | ||
| 79 | - | ||
| 80 | - return 1; | ||
| 81 | -} | ||
| 82 | - | ||
| 83 | static unsigned int get_proximity(struct sockaddr *host_addr) | ||
| 84 | { | ||
| 85 | + struct ifaddrs *ifa = NULL; | ||
| 86 | + struct ifaddrs *this; | ||
| 87 | struct sockaddr_in *addr, *msk_addr, *if_addr; | ||
| 88 | struct sockaddr_in6 *addr6, *msk6_addr, *if6_addr; | ||
| 89 | struct in_addr *hst_addr; | ||
| 90 | struct in6_addr *hst6_addr; | ||
| 91 | int addr_len; | ||
| 92 | - char buf[MAX_ERR_BUF], *ptr; | ||
| 93 | - struct ifconf ifc; | ||
| 94 | - struct ifreq *ifr, nmptr; | ||
| 95 | - int sock, ret, i; | ||
| 96 | + char buf[MAX_ERR_BUF]; | ||
| 97 | uint32_t mask, ha, ia, *mask6, *ha6, *ia6; | ||
| 98 | + int ret; | ||
| 99 | |||
| 100 | addr = NULL; | ||
| 101 | addr6 = NULL; | ||
| 102 | @@ -170,13 +131,14 @@ static unsigned int get_proximity(struct sockaddr *host_addr) | ||
| 103 | mask6 = NULL; | ||
| 104 | ha6 = NULL; | ||
| 105 | ia6 = NULL; | ||
| 106 | + ha = 0; | ||
| 107 | |||
| 108 | switch (host_addr->sa_family) { | ||
| 109 | case AF_INET: | ||
| 110 | addr = (struct sockaddr_in *) host_addr; | ||
| 111 | hst_addr = (struct in_addr *) &addr->sin_addr; | ||
| 112 | ha = ntohl((uint32_t) hst_addr->s_addr); | ||
| 113 | - addr_len = sizeof(hst_addr); | ||
| 114 | + addr_len = sizeof(*hst_addr); | ||
| 115 | break; | ||
| 116 | |||
| 117 | case AF_INET6: | ||
| 118 | @@ -186,7 +148,7 @@ static unsigned int get_proximity(struct sockaddr *host_addr) | ||
| 119 | addr6 = (struct sockaddr_in6 *) host_addr; | ||
| 120 | hst6_addr = (struct in6_addr *) &addr6->sin6_addr; | ||
| 121 | ha6 = &hst6_addr->s6_addr32[0]; | ||
| 122 | - addr_len = sizeof(hst6_addr); | ||
| 123 | + addr_len = sizeof(*hst6_addr); | ||
| 124 | break; | ||
| 125 | #endif | ||
| 126 | |||
| 127 | @@ -194,36 +156,29 @@ static unsigned int get_proximity(struct sockaddr *host_addr) | ||
| 128 | return PROXIMITY_ERROR; | ||
| 129 | } | ||
| 130 | |||
| 131 | - sock = open_sock(AF_INET, SOCK_DGRAM, 0); | ||
| 132 | - if (sock < 0) { | ||
| 133 | + ret = getifaddrs(&ifa); | ||
| 134 | + if (ret) { | ||
| 135 | char *estr = strerror_r(errno, buf, MAX_ERR_BUF); | ||
| 136 | - logerr("socket creation failed: %s", estr); | ||
| 137 | + logerr("getifaddrs: %s", estr); | ||
| 138 | return PROXIMITY_ERROR; | ||
| 139 | } | ||
| 140 | |||
| 141 | - if (!alloc_ifreq(&ifc, sock)) { | ||
| 142 | - close(sock); | ||
| 143 | - return PROXIMITY_ERROR; | ||
| 144 | - } | ||
| 145 | - | ||
| 146 | - /* For each interface */ | ||
| 147 | - | ||
| 148 | - /* Is the address a local interface */ | ||
| 149 | - i = 0; | ||
| 150 | - ptr = (char *) &ifc.ifc_buf[0]; | ||
| 151 | - | ||
| 152 | - while (ptr < (char *) ifc.ifc_req + ifc.ifc_len) { | ||
| 153 | - ifr = (struct ifreq *) ptr; | ||
| 154 | + this = ifa; | ||
| 155 | + while (this) { | ||
| 156 | + if (this->ifa_flags & IFF_POINTOPOINT || | ||
| 157 | + this->ifa_addr->sa_data == NULL) { | ||
| 158 | + this = this->ifa_next; | ||
| 159 | + continue; | ||
| 160 | + } | ||
| 161 | |||
| 162 | - switch (ifr->ifr_addr.sa_family) { | ||
| 163 | + switch (this->ifa_addr->sa_family) { | ||
| 164 | case AF_INET: | ||
| 165 | if (host_addr->sa_family == AF_INET6) | ||
| 166 | break; | ||
| 167 | - if_addr = (struct sockaddr_in *) &ifr->ifr_addr; | ||
| 168 | + if_addr = (struct sockaddr_in *) this->ifa_addr; | ||
| 169 | ret = memcmp(&if_addr->sin_addr, hst_addr, addr_len); | ||
| 170 | if (!ret) { | ||
| 171 | - close(sock); | ||
| 172 | - free(ifc.ifc_req); | ||
| 173 | + freeifaddrs(ifa); | ||
| 174 | return PROXIMITY_LOCAL; | ||
| 175 | } | ||
| 176 | break; | ||
| 177 | @@ -234,55 +189,41 @@ static unsigned int get_proximity(struct sockaddr *host_addr) | ||
| 178 | #else | ||
| 179 | if (host_addr->sa_family == AF_INET) | ||
| 180 | break; | ||
| 181 | - | ||
| 182 | - if6_addr = (struct sockaddr_in6 *) &ifr->ifr_addr; | ||
| 183 | + if6_addr = (struct sockaddr_in6 *) this->ifa_addr; | ||
| 184 | ret = memcmp(&if6_addr->sin6_addr, hst6_addr, addr_len); | ||
| 185 | if (!ret) { | ||
| 186 | - close(sock); | ||
| 187 | - free(ifc.ifc_req); | ||
| 188 | + freeifaddrs(ifa); | ||
| 189 | return PROXIMITY_LOCAL; | ||
| 190 | } | ||
| 191 | #endif | ||
| 192 | - | ||
| 193 | default: | ||
| 194 | break; | ||
| 195 | } | ||
| 196 | - | ||
| 197 | - i++; | ||
| 198 | - ptr = (char *) &ifc.ifc_req[i]; | ||
| 199 | + this = this->ifa_next; | ||
| 200 | } | ||
| 201 | |||
| 202 | - i = 0; | ||
| 203 | - ptr = (char *) &ifc.ifc_buf[0]; | ||
| 204 | - | ||
| 205 | - while (ptr < (char *) ifc.ifc_req + ifc.ifc_len) { | ||
| 206 | - ifr = (struct ifreq *) ptr; | ||
| 207 | - | ||
| 208 | - nmptr = *ifr; | ||
| 209 | - ret = ioctl(sock, SIOCGIFNETMASK, &nmptr); | ||
| 210 | - if (ret == -1) { | ||
| 211 | - char *estr = strerror_r(errno, buf, MAX_ERR_BUF); | ||
| 212 | - logerr("ioctl: %s", estr); | ||
| 213 | - close(sock); | ||
| 214 | - free(ifc.ifc_req); | ||
| 215 | - return PROXIMITY_ERROR; | ||
| 216 | + this = ifa; | ||
| 217 | + while (this) { | ||
| 218 | + if (this->ifa_flags & IFF_POINTOPOINT || | ||
| 219 | + this->ifa_addr->sa_data == NULL) { | ||
| 220 | + this = this->ifa_next; | ||
| 221 | + continue; | ||
| 222 | } | ||
| 223 | |||
| 224 | - switch (ifr->ifr_addr.sa_family) { | ||
| 225 | + switch (this->ifa_addr->sa_family) { | ||
| 226 | case AF_INET: | ||
| 227 | if (host_addr->sa_family == AF_INET6) | ||
| 228 | break; | ||
| 229 | - if_addr = (struct sockaddr_in *) &ifr->ifr_addr; | ||
| 230 | + if_addr = (struct sockaddr_in *) this->ifa_addr; | ||
| 231 | ia = ntohl((uint32_t) if_addr->sin_addr.s_addr); | ||
| 232 | |||
| 233 | - /* Is the address within a localiy attached subnet */ | ||
| 234 | + /* Is the address within a localy attached subnet */ | ||
| 235 | |||
| 236 | - msk_addr = (struct sockaddr_in *) &nmptr.ifr_netmask; | ||
| 237 | + msk_addr = (struct sockaddr_in *) this->ifa_netmask; | ||
| 238 | mask = ntohl((uint32_t) msk_addr->sin_addr.s_addr); | ||
| 239 | |||
| 240 | if ((ia & mask) == (ha & mask)) { | ||
| 241 | - close(sock); | ||
| 242 | - free(ifc.ifc_req); | ||
| 243 | + freeifaddrs(ifa); | ||
| 244 | return PROXIMITY_SUBNET; | ||
| 245 | } | ||
| 246 | |||
| 247 | @@ -304,8 +245,7 @@ static unsigned int get_proximity(struct sockaddr *host_addr) | ||
| 248 | break; | ||
| 249 | |||
| 250 | if ((ia & mask) == (ha & mask)) { | ||
| 251 | - close(sock); | ||
| 252 | - free(ifc.ifc_req); | ||
| 253 | + freeifaddrs(ifa); | ||
| 254 | return PROXIMITY_NET; | ||
| 255 | } | ||
| 256 | break; | ||
| 257 | @@ -316,35 +256,28 @@ static unsigned int get_proximity(struct sockaddr *host_addr) | ||
| 258 | #else | ||
| 259 | if (host_addr->sa_family == AF_INET) | ||
| 260 | break; | ||
| 261 | - | ||
| 262 | - if6_addr = (struct sockaddr_in6 *) &ifr->ifr_addr; | ||
| 263 | + if6_addr = (struct sockaddr_in6 *) this->ifa_addr; | ||
| 264 | ia6 = &if6_addr->sin6_addr.s6_addr32[0]; | ||
| 265 | |||
| 266 | /* Is the address within the network of the interface */ | ||
| 267 | |||
| 268 | - msk6_addr = (struct sockaddr_in6 *) &nmptr.ifr_netmask; | ||
| 269 | + msk6_addr = (struct sockaddr_in6 *) this->ifa_netmask; | ||
| 270 | mask6 = &msk6_addr->sin6_addr.s6_addr32[0]; | ||
| 271 | |||
| 272 | if (ipv6_mask_cmp(ha6, ia6, mask6)) { | ||
| 273 | - close(sock); | ||
| 274 | - free(ifc.ifc_req); | ||
| 275 | + freeifaddrs(ifa); | ||
| 276 | return PROXIMITY_SUBNET; | ||
| 277 | } | ||
| 278 | |||
| 279 | /* How do we define "local network" in ipv6? */ | ||
| 280 | #endif | ||
| 281 | - break; | ||
| 282 | - | ||
| 283 | default: | ||
| 284 | break; | ||
| 285 | } | ||
| 286 | - | ||
| 287 | - i++; | ||
| 288 | - ptr = (char *) &ifc.ifc_req[i]; | ||
| 289 | + this = this->ifa_next; | ||
| 290 | } | ||
| 291 | |||
| 292 | - close(sock); | ||
| 293 | - free(ifc.ifc_req); | ||
| 294 | + freeifaddrs(ifa); | ||
| 295 | |||
| 296 | return PROXIMITY_OTHER; | ||
| 297 | } | ||
