LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File 0009-libteam-introduce-ream_refresh.patch of Package libteam (Project home:ods:ppc64)

From efcbc1732ab7631cbc3035f1426d6a5d6dbdda4e Mon Sep 17 00:00:00 2001
From: Jiri Pirko <jiri@resnulli.us>
Date: Wed, 26 Feb 2014 11:33:39 +0100
Subject: [patch libteam 1/3] libteam: introduce ream_refresh

New function used to refresh internal lists and to call connected
handlers.

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
 include/team.h    |  1 +
 libteam/ifinfo.c  | 10 +++++-----
 libteam/libteam.c | 33 +++++++++++++++++++++++++++++++++
 3 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/include/team.h b/include/team.h
index ec90ad9..d87975c 100644
--- a/include/team.h
+++ b/include/team.h
@@ -42,6 +42,7 @@ int team_recreate(struct team_handle *th, const char *team_name);
 int team_destroy(struct team_handle *th);
 int team_init(struct team_handle *th, uint32_t ifindex);
 void team_free(struct team_handle *th);
+int team_refresh(struct team_handle *th);
 void team_set_log_fn(struct team_handle *th,
 		     void (*log_fn)(struct team_handle *th, int priority,
 				    const char *file, int line, const char *fn,
diff --git a/libteam/ifinfo.c b/libteam/ifinfo.c
index 07627fc..f950873 100644
--- a/libteam/ifinfo.c
+++ b/libteam/ifinfo.c
@@ -190,7 +190,7 @@ static struct team_ifinfo *ifinfo_find_create(struct team_handle *th,
 	return ifinfo;
 }
 
-static void obj_input(struct nl_object *obj, void *arg, bool getlink)
+static void obj_input(struct nl_object *obj, void *arg, bool event)
 {
 	struct team_handle *th = arg;
 	struct rtnl_link *link;
@@ -205,7 +205,7 @@ static void obj_input(struct nl_object *obj, void *arg, bool getlink)
 	if (!ifinfo)
 		return;
 
-	if (getlink) {
+	if (event) {
 		err = rtnl_link_get_kernel(th->nl_cli.sock, ifindex, NULL, &link);
 		if (err)
 			return;
@@ -214,10 +214,10 @@ static void obj_input(struct nl_object *obj, void *arg, bool getlink)
 	clear_last_changed(th);
 	ifinfo_update(ifinfo, link);
 
-	if (getlink)
+	if (event)
 		rtnl_link_put(link);
 
-	if (ifinfo->changed)
+	if (ifinfo->changed || !event)
 		set_call_change_handlers(th, TEAM_IFINFO_CHANGE);
 }
 
@@ -286,7 +286,7 @@ int get_ifinfo_list(struct team_handle *th)
 	nl_cb_put(cb);
 	if (ret < 0)
 		return -nl2syserr(ret);
-	return 0;
+	return check_call_change_handlers(th, TEAM_IFINFO_CHANGE);
 }
 
 int ifinfo_list_init(struct team_handle *th)
diff --git a/libteam/libteam.c b/libteam/libteam.c
index 64b8a4d..2aee123 100644
--- a/libteam/libteam.c
+++ b/libteam/libteam.c
@@ -643,6 +643,39 @@ void team_free(struct team_handle *th)
 }
 
 /**
+ * team_refresh:
+ * @th: libteam library context
+ *
+ * This is used for user to refresh internal lists and call event handlers.
+ *
+ * Returns: zero on success or negative number in case of an error.
+ **/
+TEAM_EXPORT
+int team_refresh(struct team_handle *th)
+{
+	int err;
+
+	err = ifinfo_list_init(th);
+	if (err) {
+		err(th, "Failed to refresh interface information list.");
+		return err;
+	}
+
+	err = port_list_init(th);
+	if (err) {
+		err(th, "Failed to refresh port list.");
+		return err;
+	}
+
+	err = option_list_init(th);
+	if (err) {
+		err(th, "Failed to refresh option list.");
+		return err;
+	}
+	return 0;
+}
+
+/**
  * team_set_log_fn:
  * @th: libteam library context
  * @log_fn: function to be called for logging messages
-- 
1.8.5.3