merge from tridge
authorRonnie Sahlberg <sahlberg@ronnie>
Thu, 13 Sep 2007 04:28:18 +0000 (14:28 +1000)
committerRonnie Sahlberg <sahlberg@ronnie>
Thu, 13 Sep 2007 04:28:18 +0000 (14:28 +1000)
(This used to be ctdb commit eda3caa77be352967a41ff9bddda5296c94797a9)

1  2 
ctdb/common/system_linux.c

index 82a6575bab333198a2fbe042cfd2bb1b73045757,6e42199e83a62d9dd60157779e6db8d7e8ec6808..bd44bd75b40ceb6b450e8d9cc8f0db1b665338d0
@@@ -266,75 -255,6 +255,7 @@@ bool ctdb_sys_have_ip(struct sockaddr_i
                return false;
        }
        ret = bind(s, (struct sockaddr *)&ip, sizeof(ip));
-       if (ret) {
-               goto finished;
-       }
-       /* find out how much space we need to store the interface details */
-       ifc.ifc_len = 0;
-       ifc.ifc_req = NULL;
-       ret = ioctl(s, SIOCGIFCONF, &ifc);
-       if (ret) {
-               DEBUG(0,(__location__ " ioctl to read interface list failed\n"));
-               goto finished;
-       }
-       ifr = talloc_size(mem_ctx, ifc.ifc_len);
-       /* get a list of all interface names and addresses */
-       ifc.ifc_req = ifr;
-       ret = ioctl(s, SIOCGIFCONF, &ifc);
-       if (ret) {
-               DEBUG(0,(__location__ " ioctl to read interface list failed\n"));
-               goto finished;
-       }
 +
-       /* loop over all interfaces and search for the one matching ip */
-       num_ifs = ifc.ifc_len/sizeof(struct ifreq);
-       for (i=0; i<num_ifs;i++) {
-               struct sockaddr_in *sa;
-               /* we only care bout ipv4 addresses */
-               sa = (struct sockaddr_in *)&ifr[i].ifr_addr;
-               if (sa->sin_family != AF_INET) {
-                       continue;
-               }
-               /* this is not the interface you are looking for */
-               if (!ctdb_same_ip(sa, &ip)) {
-                       continue;
-               }
-               /* this is the ifr entry for this interface/address 
-                  read the interface flags so we can tell if it is 
-                  loopback or not
-               */
-               ret = ioctl(s, SIOCGIFFLAGS, &ifr[i]);
-               if (ret) {
-                       DEBUG(0,(__location__ " failed to read interface flags for interface %s\n", ifr[i].ifr_name));
-                       goto finished;
-               }
-               /* was this ip tied to a loopback interface ? */
-               if (ifr[i].ifr_flags & IFF_LOOPBACK) {
-                       if (is_loopback != NULL) {
-                               *is_loopback = true;
-                       }
-               }
-               if (ifname) {
-                       *ifname = talloc_asprintf(mem_ctx, "%s", ifr[i].ifr_name);
-               }
-               /* if we got this far, we have found our interface so we can
-                  exit the loop.
-               */              
-               break;
-       }       
- finished:
-       talloc_free(ifr);
        close(s);
        return ret == 0;
  }