chiark / gitweb /
sd-network: drop get_ifindices
authorTom Gundersen <teg@jklm.no>
Fri, 18 Jul 2014 23:37:22 +0000 (01:37 +0200)
committerTom Gundersen <teg@jklm.no>
Mon, 21 Jul 2014 11:32:27 +0000 (13:32 +0200)
People should use rtnl for this, and then only query sd-network by the ifindices it finds.

TODO
src/network/sd-network.c
src/systemd/sd-network.h

diff --git a/TODO b/TODO
index bfa06def490192c88286cc2fc6e16b8ff024b75d..4a1313d419dd63451e377d1494d66f57519a105f 100644 (file)
--- a/TODO
+++ b/TODO
@@ -29,7 +29,6 @@ Features:
     releases (probably not even a directory in /run for it)
   - the order between ipv6 and ipv4 dns servers probably matters,
     hence the current DNS apis won't suffice
-  - sd_network_get_ifindices() sounds redundant, rtnetlink can do that too
 
 * resolved:
   - IDN (?)
index 0844e58686191dc74e2014335f138ca2720e03f8..91d6275056bf3eff87c8abd0124ccb4fac0f0cae 100644 (file)
@@ -206,64 +206,6 @@ _public_ int sd_network_dhcp_use_ntp(int ifindex) {
         return network_get_boolean("DHCP_USE_NTP", ifindex);
 }
 
-_public_ int sd_network_get_ifindices(int **ifindices) {
-        _cleanup_closedir_ DIR *d;
-        int r = 0;
-        unsigned n = 0;
-        _cleanup_free_ int *l = NULL;
-
-        d = opendir("/run/systemd/netif/links/");
-        if (!d)
-                return -errno;
-
-        for (;;) {
-                struct dirent *de;
-                int k;
-                int ifindex;
-
-                errno = 0;
-                de = readdir(d);
-                if (!de && errno != 0)
-                        return -errno;
-
-                if (!de)
-                        break;
-
-                dirent_ensure_type(d, de);
-
-                if (!dirent_is_file(de))
-                        continue;
-
-                k = safe_atoi(de->d_name, &ifindex);
-                if (k < 0)
-                        continue;
-
-                if (ifindices) {
-                        if ((unsigned) r >= n) {
-                                int *t;
-
-                                n = MAX(16, 2*r);
-                                t = realloc(l, sizeof(int) * n);
-                                if (!t)
-                                        return -ENOMEM;
-
-                                l = t;
-                        }
-
-                        assert((unsigned) r < n);
-                        l[r++] = ifindex;
-                } else
-                        r++;
-        }
-
-        if (ifindices) {
-                *ifindices = l;
-                l = NULL;
-        }
-
-        return r;
-}
-
 static inline int MONITOR_TO_FD(sd_network_monitor *m) {
         return (int) (unsigned long) m - 1;
 }
index 0f32c448f846c292bb2d50f6f35966ba11975b75..e4547057f130db11c4d5d4910d9d8ae5c6727223 100644 (file)
@@ -88,10 +88,6 @@ int sd_network_get_dns(int ifindex, struct in_addr **addr);
 /* Get IPv6 DNS entries statically configured for the link */
 int sd_network_get_dns6(int ifindex, struct in6_addr **addr);
 
-/* Get all network interfaces' indices, and store them in *indices. Returns
- * the number of indices. If indices is NULL, only returns the number of indices. */
-int sd_network_get_ifindices(int **ifindices);
-
 /* Monitor object */
 typedef struct sd_network_monitor sd_network_monitor;