Skip to content

Commit

Permalink
datapath: Drop user features if old user space attempted to create da…
Browse files Browse the repository at this point in the history
…tapath

Drop user features if an outdated user space instance that does not
understand the concept of user_features attempted to create a new
datapath.

Signed-off-by: Thomas Graf <[email protected]>
Reviewed-by: Daniel Borkmann <[email protected]>
Signed-off-by: Jesse Gross <[email protected]>
  • Loading branch information
tgraf authored and jessegross committed Dec 17, 2013
1 parent c58cc9a commit 94358dc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
21 changes: 21 additions & 0 deletions datapath/datapath.c
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,18 @@ static struct datapath *lookup_datapath(struct net *net,
return dp ? dp : ERR_PTR(-ENODEV);
}

static void ovs_dp_reset_user_features(struct sk_buff *skb, struct genl_info *info)
{
struct datapath *dp;

dp = lookup_datapath(sock_net(skb->sk), info->userhdr, info->attrs);
if (!dp)
return;

WARN(dp->user_features, "Dropping previously announced user features\n");
dp->user_features = 0;
}

static void ovs_dp_change(struct datapath *dp, struct nlattr **a)
{
if (a[OVS_DP_ATTR_USER_FEATURES])
Expand Down Expand Up @@ -1219,6 +1231,15 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
if (err == -EBUSY)
err = -EEXIST;

if (err == -EEXIST) {
/* An outdated user space instance that does not understand
* the concept of user_features has attempted to create a new
* datapath and is likely to reuse it. Drop all user features.
*/
if (info->genlhdr->version < OVS_DP_VER_FEATURES)
ovs_dp_reset_user_features(skb, info);
}

goto err_destroy_ports_array;
}

Expand Down
10 changes: 9 additions & 1 deletion include/linux/openvswitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,15 @@ struct ovs_header {

#define OVS_DATAPATH_FAMILY "ovs_datapath"
#define OVS_DATAPATH_MCGROUP "ovs_datapath"
#define OVS_DATAPATH_VERSION 0x1

/* V2:
* - API users are expected to provide OVS_DP_ATTR_USER_FEATURES
* when creating the datapath.
*/
#define OVS_DATAPATH_VERSION 2

/* First OVS datapath version to support features */
#define OVS_DP_VER_FEATURES 2

enum ovs_datapath_cmd {
OVS_DP_CMD_UNSPEC,
Expand Down

0 comments on commit 94358dc

Please sign in to comment.