struct datapath *dp_get_by_name(const char *dp_name)
{
int i;
-
- if (!dp_name || (strlen(dp_name) >= sizeof(dps[0]->netdev->name)))
- return NULL;
-
for (i=0; i<DP_MAX; i++) {
struct datapath *dp = rcu_dereference(dps[i]);
- if (dp && !strncmp(dp->netdev->name, dp_name, IFNAMSIZ))
+ if (dp && !strcmp(dp->netdev->name, dp_name))
return dp;
}
return NULL;
nla_get_u32(info->attrs[DP_GENL_A_DP_IDX]) : -1;
const char *dp_name = info->attrs[DP_GENL_A_DP_NAME] ?
nla_data(info->attrs[DP_GENL_A_DP_NAME]) : NULL;
- struct datapath *dp = NULL;
-
- if ((dp_idx == -1) && (!dp_name))
- return ERR_PTR(-EINVAL);
if (dp_idx != -1) {
- dp = dp_get_by_idx(dp_idx);
+ struct datapath *dp = dp_get_by_idx(dp_idx);
if (!dp)
return ERR_PTR(-ENOENT);
- }
-
- if (dp_name) {
- struct datapath *dp_n = dp_get_by_name(dp_name);
- if (dp && dp != dp_n)
+ else if (dp_name && strcmp(dp->netdev->name, dp_name))
return ERR_PTR(-EINVAL);
- dp = dp_n;
+ else
+ return dp;
+ } else if (dp_name) {
+ struct datapath *dp = dp_get_by_name(dp_name);
+ return dp ? dp : ERR_PTR(-ENOENT);
+ } else {
+ return ERR_PTR(-EINVAL);
}
-
- return dp ? dp : ERR_PTR(-ENOENT);
}
static int dp_genl_del(struct sk_buff *skb, struct genl_info *info)