Skip to content

Commit 44da5ae

Browse files
tgrafjessegross
authored andcommitted
openvswitch: Drop user features if old user space attempted to create datapath
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 <tgraf@suug.ch> Signed-off-by: Jesse Gross <jesse@nicira.com>
1 parent 43d4be9 commit 44da5ae

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

include/uapi/linux/openvswitch.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,15 @@ struct ovs_header {
4040

4141
#define OVS_DATAPATH_FAMILY "ovs_datapath"
4242
#define OVS_DATAPATH_MCGROUP "ovs_datapath"
43-
#define OVS_DATAPATH_VERSION 0x1
43+
44+
/* V2:
45+
* - API users are expected to provide OVS_DP_ATTR_USER_FEATURES
46+
* when creating the datapath.
47+
*/
48+
#define OVS_DATAPATH_VERSION 2
49+
50+
/* First OVS datapath version to support features */
51+
#define OVS_DP_VER_FEATURES 2
4452

4553
enum ovs_datapath_cmd {
4654
OVS_DP_CMD_UNSPEC,

net/openvswitch/datapath.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,18 @@ static struct datapath *lookup_datapath(struct net *net,
11481148
return dp ? dp : ERR_PTR(-ENODEV);
11491149
}
11501150

1151+
static void ovs_dp_reset_user_features(struct sk_buff *skb, struct genl_info *info)
1152+
{
1153+
struct datapath *dp;
1154+
1155+
dp = lookup_datapath(sock_net(skb->sk), info->userhdr, info->attrs);
1156+
if (!dp)
1157+
return;
1158+
1159+
WARN(dp->user_features, "Dropping previously announced user features\n");
1160+
dp->user_features = 0;
1161+
}
1162+
11511163
static void ovs_dp_change(struct datapath *dp, struct nlattr **a)
11521164
{
11531165
if (a[OVS_DP_ATTR_USER_FEATURES])
@@ -1220,6 +1232,15 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
12201232
if (err == -EBUSY)
12211233
err = -EEXIST;
12221234

1235+
if (err == -EEXIST) {
1236+
/* An outdated user space instance that does not understand
1237+
* the concept of user_features has attempted to create a new
1238+
* datapath and is likely to reuse it. Drop all user features.
1239+
*/
1240+
if (info->genlhdr->version < OVS_DP_VER_FEATURES)
1241+
ovs_dp_reset_user_features(skb, info);
1242+
}
1243+
12231244
goto err_destroy_ports_array;
12241245
}
12251246

0 commit comments

Comments
 (0)