[lldp-devel] [V2 1/4] vdp change vdp_add_profile function prototype

Thomas Richter tmricht at linux.vnet.ibm.com
Wed Mar 6 14:09:18 UTC 2013


Add the pointer to the vdp data structure to the
function call vdp_add_profile.

Signed-off-by: Thomas Richter <tmricht at linux.vnet.ibm.com>
---
 event_iface.c      |    2 +-
 include/lldp_vdp.h |    2 +-
 lldp_vdp.c         |   11 +----------
 lldp_vdp_cmds.c    |    9 ++++++++-
 4 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/event_iface.c b/event_iface.c
index 46d01b0..24ff486 100644
--- a/event_iface.c
+++ b/event_iface.c
@@ -575,7 +575,7 @@ static int event_if_parse_setmsg(struct nlmsghdr *nlh)
 		goto out_err;
 	}
 
-	p = vdp_add_profile(profile);
+	p = vdp_add_profile(NULL, profile);
 
 	if (!p)
 		goto out_err;
diff --git a/include/lldp_vdp.h b/include/lldp_vdp.h
index c69f381..bbcde02 100644
--- a/include/lldp_vdp.h
+++ b/include/lldp_vdp.h
@@ -147,7 +147,7 @@ void vdp_unregister(struct lldp_module *);
 struct vdp_data *vdp_data(char *);
 struct packed_tlv *vdp_gettlv(struct vdp_data *, struct vsi_profile *);
 void vdp_vsi_sm_station(struct vsi_profile *);
-struct vsi_profile *vdp_add_profile(struct vsi_profile *);
+struct vsi_profile *vdp_add_profile(struct vdp_data *, struct vsi_profile *);
 int vdp_remove_profile(struct vsi_profile *);
 void vdp_somethingChangedLocal(struct vsi_profile *, bool);
 void vdp_update(char *, u8);
diff --git a/lldp_vdp.c b/lldp_vdp.c
index ca41d33..92fd5bc 100644
--- a/lldp_vdp.c
+++ b/lldp_vdp.c
@@ -1370,21 +1370,12 @@ void vdp_takeover_macvlans(struct vsi_profile *p1, struct vsi_profile *p2)
  * main interface function which adds a profile to a list kept on a per-port
  * basis. Checks if the profile is already in the list, adds it if necessary.
  */
-struct vsi_profile *vdp_add_profile(struct vsi_profile *profile)
+struct vsi_profile *vdp_add_profile(struct vdp_data *vd, struct vsi_profile *profile)
 {
 	struct vsi_profile *p;
-	struct vdp_data *vd;
 
 	LLDPAD_DBG("%s: adding vdp profile for %s\n", __func__,
 		   profile->port->ifname);
-
-	vd = vdp_data(profile->port->ifname);
-	if (!vd) {
-		LLDPAD_ERR("%s: could not find vdp_data for %s\n", __func__,
-			   profile->port->ifname);
-		return NULL;
-	}
-
 	vdp_trace_profile(profile);
 
 	/*
diff --git a/lldp_vdp_cmds.c b/lldp_vdp_cmds.c
index 3d9f867..14bf627 100644
--- a/lldp_vdp_cmds.c
+++ b/lldp_vdp_cmds.c
@@ -413,6 +413,7 @@ out_free:
 static int _set_arg_mode(struct cmd *cmd, char *argvalue, bool test)
 {
 	struct vsi_profile *profile, *p;
+	struct vdp_data *vd;
 
 	if (cmd->cmd != cmd_settlv)
 		return cmd_invalid;
@@ -437,12 +438,18 @@ static int _set_arg_mode(struct cmd *cmd, char *argvalue, bool test)
 		return cmd_invalid;
 	}
 
+	vd = vdp_data(cmd->ifname);
+	if (!vd) {
+		vdp_delete_profile(profile);
+		return cmd_invalid;
+	}
+
 	if (test) {
 		vdp_delete_profile(profile);
 		return cmd_success;
 	}
 
-	p = vdp_add_profile(profile);
+	p = vdp_add_profile(vd, profile);
 
 	if (!p) {
 		vdp_delete_profile(profile);
-- 
1.7.1



More information about the lldp-devel mailing list