@@ -1229,23 +1229,23 @@ static ssize_t ucma_notify(struct ucma_file *file, const char __user *inbuf,
1229
1229
return ret ;
1230
1230
}
1231
1231
1232
- static ssize_t ucma_join_ip_multicast (struct ucma_file * file ,
1233
- const char __user * inbuf ,
1234
- int in_len , int out_len )
1232
+ static ssize_t ucma_process_join (struct ucma_file * file ,
1233
+ struct rdma_ucm_join_mcast * cmd , int out_len )
1235
1234
{
1236
- struct rdma_ucm_join_ip_mcast cmd ;
1237
1235
struct rdma_ucm_create_id_resp resp ;
1238
1236
struct ucma_context * ctx ;
1239
1237
struct ucma_multicast * mc ;
1238
+ struct sockaddr * addr ;
1240
1239
int ret ;
1241
1240
1242
1241
if (out_len < sizeof (resp ))
1243
1242
return - ENOSPC ;
1244
1243
1245
- if (copy_from_user (& cmd , inbuf , sizeof (cmd )))
1246
- return - EFAULT ;
1244
+ addr = (struct sockaddr * ) & cmd -> addr ;
1245
+ if (cmd -> reserved || !cmd -> addr_size || (cmd -> addr_size != rdma_addr_size (addr )))
1246
+ return - EINVAL ;
1247
1247
1248
- ctx = ucma_get_ctx (file , cmd . id );
1248
+ ctx = ucma_get_ctx (file , cmd -> id );
1249
1249
if (IS_ERR (ctx ))
1250
1250
return PTR_ERR (ctx );
1251
1251
@@ -1256,14 +1256,14 @@ static ssize_t ucma_join_ip_multicast(struct ucma_file *file,
1256
1256
goto err1 ;
1257
1257
}
1258
1258
1259
- mc -> uid = cmd . uid ;
1260
- memcpy (& mc -> addr , & cmd . addr , sizeof cmd . addr );
1259
+ mc -> uid = cmd -> uid ;
1260
+ memcpy (& mc -> addr , addr , cmd -> addr_size );
1261
1261
ret = rdma_join_multicast (ctx -> cm_id , (struct sockaddr * ) & mc -> addr , mc );
1262
1262
if (ret )
1263
1263
goto err2 ;
1264
1264
1265
1265
resp .id = mc -> id ;
1266
- if (copy_to_user ((void __user * )(unsigned long )cmd . response ,
1266
+ if (copy_to_user ((void __user * )(unsigned long ) cmd -> response ,
1267
1267
& resp , sizeof (resp ))) {
1268
1268
ret = - EFAULT ;
1269
1269
goto err3 ;
@@ -1288,6 +1288,38 @@ static ssize_t ucma_join_ip_multicast(struct ucma_file *file,
1288
1288
return ret ;
1289
1289
}
1290
1290
1291
+ static ssize_t ucma_join_ip_multicast (struct ucma_file * file ,
1292
+ const char __user * inbuf ,
1293
+ int in_len , int out_len )
1294
+ {
1295
+ struct rdma_ucm_join_ip_mcast cmd ;
1296
+ struct rdma_ucm_join_mcast join_cmd ;
1297
+
1298
+ if (copy_from_user (& cmd , inbuf , sizeof (cmd )))
1299
+ return - EFAULT ;
1300
+
1301
+ join_cmd .response = cmd .response ;
1302
+ join_cmd .uid = cmd .uid ;
1303
+ join_cmd .id = cmd .id ;
1304
+ join_cmd .addr_size = rdma_addr_size ((struct sockaddr * ) & cmd .addr );
1305
+ join_cmd .reserved = 0 ;
1306
+ memcpy (& join_cmd .addr , & cmd .addr , join_cmd .addr_size );
1307
+
1308
+ return ucma_process_join (file , & join_cmd , out_len );
1309
+ }
1310
+
1311
+ static ssize_t ucma_join_multicast (struct ucma_file * file ,
1312
+ const char __user * inbuf ,
1313
+ int in_len , int out_len )
1314
+ {
1315
+ struct rdma_ucm_join_mcast cmd ;
1316
+
1317
+ if (copy_from_user (& cmd , inbuf , sizeof (cmd )))
1318
+ return - EFAULT ;
1319
+
1320
+ return ucma_process_join (file , & cmd , out_len );
1321
+ }
1322
+
1291
1323
static ssize_t ucma_leave_multicast (struct ucma_file * file ,
1292
1324
const char __user * inbuf ,
1293
1325
int in_len , int out_len )
@@ -1451,7 +1483,8 @@ static ssize_t (*ucma_cmd_table[])(struct ucma_file *file,
1451
1483
[RDMA_USER_CM_CMD_MIGRATE_ID ] = ucma_migrate_id ,
1452
1484
[RDMA_USER_CM_CMD_QUERY ] = ucma_query ,
1453
1485
[RDMA_USER_CM_CMD_BIND ] = ucma_bind ,
1454
- [RDMA_USER_CM_CMD_RESOLVE_ADDR ] = ucma_resolve_addr
1486
+ [RDMA_USER_CM_CMD_RESOLVE_ADDR ] = ucma_resolve_addr ,
1487
+ [RDMA_USER_CM_CMD_JOIN_MCAST ] = ucma_join_multicast
1455
1488
};
1456
1489
1457
1490
static ssize_t ucma_write (struct file * filp , const char __user * buf ,
0 commit comments