struct interfaces_device_list *interfaces,
struct interfaces_device *master)
{
- struct ifbreq req[64];
- struct ifbifconf bifc = {
- .ifbic_len = sizeof(req),
- .ifbic_req = req
- };
+ static size_t ifbic_len = 64;
+ struct ifbreq *req = NULL;
+ struct ifbifconf bifc = {};
+
+ retry_alloc:
+ if ((req = realloc(req, ifbic_len)) == NULL) {
+ log_warn("interfaces", "unable to allocate memory to query bridge %s",
+ master->name);
+ free(bifc.ifbic_req);
+ return;
+ }
+ bifc.ifbic_len = ifbic_len;
+ bifc.ifbic_req = req;
#if defined HOST_OS_FREEBSD || defined HOST_OS_NETBSD || defined HOST_OS_OSX || defined HOST_OS_DRAGONFLY
struct ifdrv ifd = {
#else
# error Unsupported OS
#endif
- if (bifc.ifbic_len >= sizeof(req)) {
- log_warnx("interfaces",
- "%s is a bridge too big. Please, report the problem",
- master->name);
- return;
+ if (bifc.ifbic_len >= ifbic_len) {
+ ifbic_len = bifc.ifbic_len + 1;
+ goto retry_alloc;
}
for (int i = 0; i < bifc.ifbic_len / sizeof(*req); i++) {
struct interfaces_device *slave =