[OpenWrt-Devel] [PATCH v2] [netifd] Changes for more readability.

Yousong Zhou yszhou4tech at gmail.com
Sun May 24 03:36:37 EDT 2015


 - "ifname" for Linux interface name.
 - "interface" for netifd defined logical interface names as in
   /etc/config/network.
 - A few comments and variable renames for better readability.

Signed-off-by: Yousong Zhou <yszhou4tech at gmail.com>
---
v2 <- v1

	- Drop the ev (type cast + pointer dereference) change in v1.
	- Reword the comment for alias interface.

 device.h      |    3 +++
 interface.c   |    4 ++--
 interface.h   |    1 +
 proto-shell.c |    8 ++++----
 ubus.c        |    2 +-
 5 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/device.h b/device.h
index 3001f10..7f0f9d1 100644
--- a/device.h
+++ b/device.h
@@ -154,8 +154,11 @@ struct device {
 	struct blob_attr *config;
 	bool config_pending;
 	bool sys_present;
+	/* DEV_EVENT_ADD */
 	bool present;
+	/* DEV_EVENT_UP */
 	int active;
+	/* DEV_EVENT_LINK_UP */
 	bool link_active;
 
 	bool external;
diff --git a/interface.c b/interface.c
index 5166c0c..baf521a 100644
--- a/interface.c
+++ b/interface.c
@@ -647,7 +647,7 @@ interface_handle_config_change(struct interface *iface)
 }
 
 static void
-interface_proto_cb(struct interface_proto_state *state, enum interface_proto_event ev)
+interface_proto_event_cb(struct interface_proto_state *state, enum interface_proto_event ev)
 {
 	struct interface *iface = state->iface;
 
@@ -706,7 +706,7 @@ void interface_set_proto_state(struct interface *iface, struct interface_proto_s
 	if (!state)
 		return;
 
-	state->proto_event = interface_proto_cb;
+	state->proto_event = interface_proto_event_cb;
 	state->iface = iface;
 }
 
diff --git a/interface.h b/interface.h
index 8eeb7db..6f9112c 100644
--- a/interface.h
+++ b/interface.h
@@ -120,6 +120,7 @@ struct interface {
 
 	struct list_head users;
 
+	/* for alias interface */
 	const char *parent_ifname;
 	struct interface_user parent_iface;
 
diff --git a/proto-shell.c b/proto-shell.c
index bac57e0..bb6edc8 100644
--- a/proto-shell.c
+++ b/proto-shell.c
@@ -52,7 +52,7 @@ struct proto_shell_handler {
 struct proto_shell_dependency {
 	struct list_head list;
 
-	char *interface;
+	char *ifname;
 	struct proto_shell_state *proto;
 	struct interface_user dep;
 
@@ -111,8 +111,8 @@ proto_shell_update_host_dep(struct proto_shell_dependency *dep)
 	if (dep->dep.iface)
 		goto out;
 
-	if (dep->interface[0])
-		iface = vlist_find(&interfaces, dep->interface, iface, node);
+	if (dep->ifname[0])
+		iface = vlist_find(&interfaces, dep->ifname, iface, node);
 
 	iface = interface_ip_add_target_route(&dep->host, dep->v6, iface);
 	if (!iface)
@@ -695,7 +695,7 @@ proto_shell_add_host_dependency(struct proto_shell_state *state, struct blob_att
 	}
 
 	dep->proto = state;
-	dep->interface = strcpy(ifname, ifname_str);
+	dep->ifname = strcpy(ifname, ifname_str);
 
 	dep->dep.cb = proto_shell_if_up_cb;
 	interface_add_user(&dep->dep, NULL);
diff --git a/ubus.c b/ubus.c
index 422b652..c7a329a 100644
--- a/ubus.c
+++ b/ubus.c
@@ -843,7 +843,7 @@ netifd_iface_handle_device(struct ubus_context *ctx, struct ubus_object *obj,
 
 	cur = tb[DEV_LINK_EXT];
 	if (cur)
-		link_ext = !!blobmsg_get_u8(cur);
+		link_ext = blobmsg_get_bool(cur);
 
 	return interface_handle_link(iface, blobmsg_data(tb[DEV_LINK_NAME]), add, link_ext);
 }
-- 
1.7.10.4
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list