- int ret;
-
- ret = new_foreach_bridge(iterator, arg);
- if (ret <= 0)
- ret = old_foreach_bridge(iterator, arg);
-
- return ret;
-}
-
-/*
- * Only used if sysfs is not available.
- */
-static int old_foreach_port(const char *brname,
- int (*iterator)(const char *br, const char *port,
- void *arg),
- void *arg)
-{
- int i, err, count;
- struct ifreq ifr;
- char ifname[IFNAMSIZ];
- int ifindices[MAX_PORTS];
- unsigned long args[4] = { BRCTL_GET_PORT_LIST,
- (unsigned long)ifindices, MAX_PORTS, 0 };
-
- memset(ifindices, 0, sizeof(ifindices));
- strncpy(ifr.ifr_name, brname, IFNAMSIZ);
- ifr.ifr_data = (char *) &args;
-
- err = ioctl(br_socket_fd, SIOCDEVPRIVATE, &ifr);
- if (err < 0) {
- dprintf("list ports for bridge:'%s' failed: %s\n",
- brname, strerror(errno));
- return -errno;
- }
-
- count = 0;
- for (i = 0; i < MAX_PORTS; i++) {
- if (!ifindices[i])
- continue;
-
- if (!if_indextoname(ifindices[i], ifname)) {
- dprintf("can't find name for ifindex:%d\n",
- ifindices[i]);
- continue;
- }
-
- ++count;
- if (iterator(brname, ifname, arg))
- break;
- }
-
- return count;