diff options
Diffstat (limited to 'net/sctp/protocol.c')
-rw-r--r-- | net/sctp/protocol.c | 64 |
1 files changed, 41 insertions, 23 deletions
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index b7143337e4fa..3d9ea9a48289 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c | |||
@@ -1186,7 +1186,7 @@ static void sctp_v4_del_protocol(void) | |||
1186 | unregister_inetaddr_notifier(&sctp_inetaddr_notifier); | 1186 | unregister_inetaddr_notifier(&sctp_inetaddr_notifier); |
1187 | } | 1187 | } |
1188 | 1188 | ||
1189 | static int __net_init sctp_net_init(struct net *net) | 1189 | static int __net_init sctp_defaults_init(struct net *net) |
1190 | { | 1190 | { |
1191 | int status; | 1191 | int status; |
1192 | 1192 | ||
@@ -1279,12 +1279,6 @@ static int __net_init sctp_net_init(struct net *net) | |||
1279 | 1279 | ||
1280 | sctp_dbg_objcnt_init(net); | 1280 | sctp_dbg_objcnt_init(net); |
1281 | 1281 | ||
1282 | /* Initialize the control inode/socket for handling OOTB packets. */ | ||
1283 | if ((status = sctp_ctl_sock_init(net))) { | ||
1284 | pr_err("Failed to initialize the SCTP control sock\n"); | ||
1285 | goto err_ctl_sock_init; | ||
1286 | } | ||
1287 | |||
1288 | /* Initialize the local address list. */ | 1282 | /* Initialize the local address list. */ |
1289 | INIT_LIST_HEAD(&net->sctp.local_addr_list); | 1283 | INIT_LIST_HEAD(&net->sctp.local_addr_list); |
1290 | spin_lock_init(&net->sctp.local_addr_lock); | 1284 | spin_lock_init(&net->sctp.local_addr_lock); |
@@ -1300,9 +1294,6 @@ static int __net_init sctp_net_init(struct net *net) | |||
1300 | 1294 | ||
1301 | return 0; | 1295 | return 0; |
1302 | 1296 | ||
1303 | err_ctl_sock_init: | ||
1304 | sctp_dbg_objcnt_exit(net); | ||
1305 | sctp_proc_exit(net); | ||
1306 | err_init_proc: | 1297 | err_init_proc: |
1307 | cleanup_sctp_mibs(net); | 1298 | cleanup_sctp_mibs(net); |
1308 | err_init_mibs: | 1299 | err_init_mibs: |
@@ -1311,15 +1302,12 @@ err_sysctl_register: | |||
1311 | return status; | 1302 | return status; |
1312 | } | 1303 | } |
1313 | 1304 | ||
1314 | static void __net_exit sctp_net_exit(struct net *net) | 1305 | static void __net_exit sctp_defaults_exit(struct net *net) |
1315 | { | 1306 | { |
1316 | /* Free the local address list */ | 1307 | /* Free the local address list */ |
1317 | sctp_free_addr_wq(net); | 1308 | sctp_free_addr_wq(net); |
1318 | sctp_free_local_addr_list(net); | 1309 | sctp_free_local_addr_list(net); |
1319 | 1310 | ||
1320 | /* Free the control endpoint. */ | ||
1321 | inet_ctl_sock_destroy(net->sctp.ctl_sock); | ||
1322 | |||
1323 | sctp_dbg_objcnt_exit(net); | 1311 | sctp_dbg_objcnt_exit(net); |
1324 | 1312 | ||
1325 | sctp_proc_exit(net); | 1313 | sctp_proc_exit(net); |
@@ -1327,9 +1315,32 @@ static void __net_exit sctp_net_exit(struct net *net) | |||
1327 | sctp_sysctl_net_unregister(net); | 1315 | sctp_sysctl_net_unregister(net); |
1328 | } | 1316 | } |
1329 | 1317 | ||
1330 | static struct pernet_operations sctp_net_ops = { | 1318 | static struct pernet_operations sctp_defaults_ops = { |
1331 | .init = sctp_net_init, | 1319 | .init = sctp_defaults_init, |
1332 | .exit = sctp_net_exit, | 1320 | .exit = sctp_defaults_exit, |
1321 | }; | ||
1322 | |||
1323 | static int __net_init sctp_ctrlsock_init(struct net *net) | ||
1324 | { | ||
1325 | int status; | ||
1326 | |||
1327 | /* Initialize the control inode/socket for handling OOTB packets. */ | ||
1328 | status = sctp_ctl_sock_init(net); | ||
1329 | if (status) | ||
1330 | pr_err("Failed to initialize the SCTP control sock\n"); | ||
1331 | |||
1332 | return status; | ||
1333 | } | ||
1334 | |||
1335 | static void __net_init sctp_ctrlsock_exit(struct net *net) | ||
1336 | { | ||
1337 | /* Free the control endpoint. */ | ||
1338 | inet_ctl_sock_destroy(net->sctp.ctl_sock); | ||
1339 | } | ||
1340 | |||
1341 | static struct pernet_operations sctp_ctrlsock_ops = { | ||
1342 | .init = sctp_ctrlsock_init, | ||
1343 | .exit = sctp_ctrlsock_exit, | ||
1333 | }; | 1344 | }; |
1334 | 1345 | ||
1335 | /* Initialize the universe into something sensible. */ | 1346 | /* Initialize the universe into something sensible. */ |
@@ -1462,8 +1473,11 @@ static __init int sctp_init(void) | |||
1462 | sctp_v4_pf_init(); | 1473 | sctp_v4_pf_init(); |
1463 | sctp_v6_pf_init(); | 1474 | sctp_v6_pf_init(); |
1464 | 1475 | ||
1465 | status = sctp_v4_protosw_init(); | 1476 | status = register_pernet_subsys(&sctp_defaults_ops); |
1477 | if (status) | ||
1478 | goto err_register_defaults; | ||
1466 | 1479 | ||
1480 | status = sctp_v4_protosw_init(); | ||
1467 | if (status) | 1481 | if (status) |
1468 | goto err_protosw_init; | 1482 | goto err_protosw_init; |
1469 | 1483 | ||
@@ -1471,9 +1485,9 @@ static __init int sctp_init(void) | |||
1471 | if (status) | 1485 | if (status) |
1472 | goto err_v6_protosw_init; | 1486 | goto err_v6_protosw_init; |
1473 | 1487 | ||
1474 | status = register_pernet_subsys(&sctp_net_ops); | 1488 | status = register_pernet_subsys(&sctp_ctrlsock_ops); |
1475 | if (status) | 1489 | if (status) |
1476 | goto err_register_pernet_subsys; | 1490 | goto err_register_ctrlsock; |
1477 | 1491 | ||
1478 | status = sctp_v4_add_protocol(); | 1492 | status = sctp_v4_add_protocol(); |
1479 | if (status) | 1493 | if (status) |
@@ -1489,12 +1503,14 @@ out: | |||
1489 | err_v6_add_protocol: | 1503 | err_v6_add_protocol: |
1490 | sctp_v4_del_protocol(); | 1504 | sctp_v4_del_protocol(); |
1491 | err_add_protocol: | 1505 | err_add_protocol: |
1492 | unregister_pernet_subsys(&sctp_net_ops); | 1506 | unregister_pernet_subsys(&sctp_ctrlsock_ops); |
1493 | err_register_pernet_subsys: | 1507 | err_register_ctrlsock: |
1494 | sctp_v6_protosw_exit(); | 1508 | sctp_v6_protosw_exit(); |
1495 | err_v6_protosw_init: | 1509 | err_v6_protosw_init: |
1496 | sctp_v4_protosw_exit(); | 1510 | sctp_v4_protosw_exit(); |
1497 | err_protosw_init: | 1511 | err_protosw_init: |
1512 | unregister_pernet_subsys(&sctp_defaults_ops); | ||
1513 | err_register_defaults: | ||
1498 | sctp_v4_pf_exit(); | 1514 | sctp_v4_pf_exit(); |
1499 | sctp_v6_pf_exit(); | 1515 | sctp_v6_pf_exit(); |
1500 | sctp_sysctl_unregister(); | 1516 | sctp_sysctl_unregister(); |
@@ -1527,12 +1543,14 @@ static __exit void sctp_exit(void) | |||
1527 | sctp_v6_del_protocol(); | 1543 | sctp_v6_del_protocol(); |
1528 | sctp_v4_del_protocol(); | 1544 | sctp_v4_del_protocol(); |
1529 | 1545 | ||
1530 | unregister_pernet_subsys(&sctp_net_ops); | 1546 | unregister_pernet_subsys(&sctp_ctrlsock_ops); |
1531 | 1547 | ||
1532 | /* Free protosw registrations */ | 1548 | /* Free protosw registrations */ |
1533 | sctp_v6_protosw_exit(); | 1549 | sctp_v6_protosw_exit(); |
1534 | sctp_v4_protosw_exit(); | 1550 | sctp_v4_protosw_exit(); |
1535 | 1551 | ||
1552 | unregister_pernet_subsys(&sctp_defaults_ops); | ||
1553 | |||
1536 | /* Unregister with socket layer. */ | 1554 | /* Unregister with socket layer. */ |
1537 | sctp_v6_pf_exit(); | 1555 | sctp_v6_pf_exit(); |
1538 | sctp_v4_pf_exit(); | 1556 | sctp_v4_pf_exit(); |