summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/iftable.c12
-rw-r--r--src/rtnl.c9
-rw-r--r--src/rtnl.h1
3 files changed, 21 insertions, 1 deletions
diff --git a/src/iftable.c b/src/iftable.c
index 959249a..0325335 100644
--- a/src/iftable.c
+++ b/src/iftable.c
@@ -295,6 +295,16 @@ int nlif_catch(struct nlif_handle *h)
return -1;
}
+static int nlif_catch_multi(struct nlif_handle *h)
+{
+ assert(h != NULL);
+
+ if (h->rtnl_handle)
+ return rtnl_receive_multi(h->rtnl_handle);
+
+ return -1;
+}
+
/**
* nlif_query - request a dump of interfaces available in the system
* @h: pointer to a valid nlif_handler
@@ -306,7 +316,7 @@ int nlif_query(struct nlif_handle *h)
if (rtnl_dump_type(h->rtnl_handle, RTM_GETLINK) < 0)
return -1;
- return nlif_catch(h);
+ return nlif_catch_multi(h);
}
/** Returns socket descriptor for the netlink socket
diff --git a/src/rtnl.c b/src/rtnl.c
index 1092c81..5ccb272 100644
--- a/src/rtnl.c
+++ b/src/rtnl.c
@@ -193,6 +193,15 @@ int rtnl_receive(struct rtnl_handle *rtnl_handle)
return 1;
}
+int rtnl_receive_multi(struct rtnl_handle *rtnl_handle)
+{
+ while (1) {
+ if (rtnl_receive(rtnl_handle) <= 0)
+ break;
+ }
+ return 1;
+}
+
/* rtnl_open - constructor of rtnetlink module */
struct rtnl_handle *rtnl_open(void)
{
diff --git a/src/rtnl.h b/src/rtnl.h
index bf018d4..0c403dc 100644
--- a/src/rtnl.h
+++ b/src/rtnl.h
@@ -32,5 +32,6 @@ int rtnl_dump_type(struct rtnl_handle *rtnl_handle, unsigned int type);
struct rtnl_handle *rtnl_open(void);
void rtnl_close(struct rtnl_handle *rtnl_handle);
int rtnl_receive(struct rtnl_handle *rtnl_handle);
+int rtnl_receive_multi(struct rtnl_handle *rtnl_handle);
#endif