| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* SCTP kernel implementation |
|---|
| 2 | 3 | * (C) Copyright IBM Corp. 2001, 2004 |
|---|
| 3 | 4 | * Copyright (c) 1999-2000 Cisco, Inc. |
|---|
| .. | .. |
|---|
| 9 | 10 | * This file is part of the SCTP kernel implementation |
|---|
| 10 | 11 | * |
|---|
| 11 | 12 | * Initialization/cleanup for SCTP protocol support. |
|---|
| 12 | | - * |
|---|
| 13 | | - * This SCTP implementation is free software; |
|---|
| 14 | | - * you can redistribute it and/or modify it under the terms of |
|---|
| 15 | | - * the GNU General Public License as published by |
|---|
| 16 | | - * the Free Software Foundation; either version 2, or (at your option) |
|---|
| 17 | | - * any later version. |
|---|
| 18 | | - * |
|---|
| 19 | | - * This SCTP implementation is distributed in the hope that it |
|---|
| 20 | | - * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
|---|
| 21 | | - * ************************ |
|---|
| 22 | | - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|---|
| 23 | | - * See the GNU General Public License for more details. |
|---|
| 24 | | - * |
|---|
| 25 | | - * You should have received a copy of the GNU General Public License |
|---|
| 26 | | - * along with GNU CC; see the file COPYING. If not, see |
|---|
| 27 | | - * <http://www.gnu.org/licenses/>. |
|---|
| 28 | 13 | * |
|---|
| 29 | 14 | * Please send any bug reports or fixes you make to the |
|---|
| 30 | 15 | * email address(es): |
|---|
| .. | .. |
|---|
| 46 | 31 | #include <linux/netdevice.h> |
|---|
| 47 | 32 | #include <linux/inetdevice.h> |
|---|
| 48 | 33 | #include <linux/seq_file.h> |
|---|
| 49 | | -#include <linux/bootmem.h> |
|---|
| 34 | +#include <linux/memblock.h> |
|---|
| 50 | 35 | #include <linux/highmem.h> |
|---|
| 51 | 36 | #include <linux/swap.h> |
|---|
| 52 | 37 | #include <linux/slab.h> |
|---|
| .. | .. |
|---|
| 96 | 81 | return; |
|---|
| 97 | 82 | } |
|---|
| 98 | 83 | |
|---|
| 99 | | - for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) { |
|---|
| 84 | + in_dev_for_each_ifa_rcu(ifa, in_dev) { |
|---|
| 100 | 85 | /* Add the address to the local list. */ |
|---|
| 101 | 86 | addr = kzalloc(sizeof(*addr), GFP_ATOMIC); |
|---|
| 102 | 87 | if (addr) { |
|---|
| .. | .. |
|---|
| 373 | 358 | if (addr->v4.sin_addr.s_addr != htonl(INADDR_ANY) && |
|---|
| 374 | 359 | ret != RTN_LOCAL && |
|---|
| 375 | 360 | !sp->inet.freebind && |
|---|
| 376 | | - !net->ipv4.sysctl_ip_nonlocal_bind) |
|---|
| 361 | + !READ_ONCE(net->ipv4.sysctl_ip_nonlocal_bind)) |
|---|
| 377 | 362 | return 0; |
|---|
| 378 | 363 | |
|---|
| 379 | 364 | if (ipv6_only_sock(sctp_opt2sk(sp))) |
|---|
| .. | .. |
|---|
| 392 | 377 | * Level 3 - private addresses. |
|---|
| 393 | 378 | * Level 4 - global addresses |
|---|
| 394 | 379 | * For INIT and INIT-ACK address list, let L be the level of |
|---|
| 395 | | - * of requested destination address, sender and receiver |
|---|
| 380 | + * requested destination address, sender and receiver |
|---|
| 396 | 381 | * SHOULD include all of its addresses with level greater |
|---|
| 397 | 382 | * than or equal to L. |
|---|
| 398 | 383 | * |
|---|
| .. | .. |
|---|
| 1048 | 1033 | .getname = inet_getname, /* Semantics are different. */ |
|---|
| 1049 | 1034 | .poll = sctp_poll, |
|---|
| 1050 | 1035 | .ioctl = inet_ioctl, |
|---|
| 1036 | + .gettstamp = sock_gettstamp, |
|---|
| 1051 | 1037 | .listen = sctp_inet_listen, |
|---|
| 1052 | 1038 | .shutdown = inet_shutdown, /* Looks harmless. */ |
|---|
| 1053 | 1039 | .setsockopt = sock_common_setsockopt, /* IP_SOL IP_OPTION is a problem */ |
|---|
| .. | .. |
|---|
| 1056 | 1042 | .recvmsg = inet_recvmsg, |
|---|
| 1057 | 1043 | .mmap = sock_no_mmap, |
|---|
| 1058 | 1044 | .sendpage = sock_no_sendpage, |
|---|
| 1059 | | -#ifdef CONFIG_COMPAT |
|---|
| 1060 | | - .compat_setsockopt = compat_sock_common_setsockopt, |
|---|
| 1061 | | - .compat_getsockopt = compat_sock_common_getsockopt, |
|---|
| 1062 | | -#endif |
|---|
| 1063 | 1045 | }; |
|---|
| 1064 | 1046 | |
|---|
| 1065 | 1047 | /* Registration with AF_INET family. */ |
|---|
| .. | .. |
|---|
| 1113 | 1095 | .net_header_len = sizeof(struct iphdr), |
|---|
| 1114 | 1096 | .sockaddr_len = sizeof(struct sockaddr_in), |
|---|
| 1115 | 1097 | .ip_options_len = sctp_v4_ip_options_len, |
|---|
| 1116 | | -#ifdef CONFIG_COMPAT |
|---|
| 1117 | | - .compat_setsockopt = compat_ip_setsockopt, |
|---|
| 1118 | | - .compat_getsockopt = compat_ip_getsockopt, |
|---|
| 1119 | | -#endif |
|---|
| 1120 | 1098 | }; |
|---|
| 1121 | 1099 | |
|---|
| 1122 | 1100 | struct sctp_pf *sctp_get_pf_specific(sa_family_t family) |
|---|
| .. | .. |
|---|
| 1253 | 1231 | /* Max.Burst - 4 */ |
|---|
| 1254 | 1232 | net->sctp.max_burst = SCTP_DEFAULT_MAX_BURST; |
|---|
| 1255 | 1233 | |
|---|
| 1234 | + /* Disable of Primary Path Switchover by default */ |
|---|
| 1235 | + net->sctp.ps_retrans = SCTP_PS_RETRANS_MAX; |
|---|
| 1236 | + |
|---|
| 1256 | 1237 | /* Enable pf state by default */ |
|---|
| 1257 | 1238 | net->sctp.pf_enable = 1; |
|---|
| 1239 | + |
|---|
| 1240 | + /* Ignore pf exposure feature by default */ |
|---|
| 1241 | + net->sctp.pf_expose = SCTP_PF_EXPOSE_UNSET; |
|---|
| 1258 | 1242 | |
|---|
| 1259 | 1243 | /* Association.Max.Retrans - 10 attempts |
|---|
| 1260 | 1244 | * Path.Max.Retrans - 5 attempts (per destination address) |
|---|
| .. | .. |
|---|
| 1289 | 1273 | |
|---|
| 1290 | 1274 | /* Disable AUTH by default. */ |
|---|
| 1291 | 1275 | net->sctp.auth_enable = 0; |
|---|
| 1276 | + |
|---|
| 1277 | + /* Enable ECN by default. */ |
|---|
| 1278 | + net->sctp.ecn_enable = 1; |
|---|
| 1292 | 1279 | |
|---|
| 1293 | 1280 | /* Set SCOPE policy to enabled */ |
|---|
| 1294 | 1281 | net->sctp.scope_policy = SCTP_SCOPE_POLICY_ENABLE; |
|---|
| .. | .. |
|---|
| 1386 | 1373 | /* Initialize the universe into something sensible. */ |
|---|
| 1387 | 1374 | static __init int sctp_init(void) |
|---|
| 1388 | 1375 | { |
|---|
| 1389 | | - int i; |
|---|
| 1390 | | - int status = -EINVAL; |
|---|
| 1391 | | - unsigned long goal; |
|---|
| 1376 | + unsigned long nr_pages = totalram_pages(); |
|---|
| 1392 | 1377 | unsigned long limit; |
|---|
| 1393 | | - int max_share; |
|---|
| 1394 | | - int order; |
|---|
| 1395 | | - int num_entries; |
|---|
| 1378 | + unsigned long goal; |
|---|
| 1396 | 1379 | int max_entry_order; |
|---|
| 1380 | + int num_entries; |
|---|
| 1381 | + int max_share; |
|---|
| 1382 | + int status; |
|---|
| 1383 | + int order; |
|---|
| 1384 | + int i; |
|---|
| 1397 | 1385 | |
|---|
| 1398 | 1386 | sock_skb_cb_check_size(sizeof(struct sctp_ulpevent)); |
|---|
| 1399 | 1387 | |
|---|
| .. | .. |
|---|
| 1448 | 1436 | * The methodology is similar to that of the tcp hash tables. |
|---|
| 1449 | 1437 | * Though not identical. Start by getting a goal size |
|---|
| 1450 | 1438 | */ |
|---|
| 1451 | | - if (totalram_pages >= (128 * 1024)) |
|---|
| 1452 | | - goal = totalram_pages >> (22 - PAGE_SHIFT); |
|---|
| 1439 | + if (nr_pages >= (128 * 1024)) |
|---|
| 1440 | + goal = nr_pages >> (22 - PAGE_SHIFT); |
|---|
| 1453 | 1441 | else |
|---|
| 1454 | | - goal = totalram_pages >> (24 - PAGE_SHIFT); |
|---|
| 1442 | + goal = nr_pages >> (24 - PAGE_SHIFT); |
|---|
| 1455 | 1443 | |
|---|
| 1456 | 1444 | /* Then compute the page order for said goal */ |
|---|
| 1457 | 1445 | order = get_order(goal); |
|---|
| .. | .. |
|---|
| 1501 | 1489 | num_entries = (1UL << order) * PAGE_SIZE / |
|---|
| 1502 | 1490 | sizeof(struct sctp_bind_hashbucket); |
|---|
| 1503 | 1491 | |
|---|
| 1504 | | - /* And finish by rounding it down to the nearest power of two |
|---|
| 1505 | | - * this wastes some memory of course, but its needed because |
|---|
| 1492 | + /* And finish by rounding it down to the nearest power of two. |
|---|
| 1493 | + * This wastes some memory of course, but it's needed because |
|---|
| 1506 | 1494 | * the hash function operates based on the assumption that |
|---|
| 1507 | | - * that the number of entries is a power of two |
|---|
| 1495 | + * the number of entries is a power of two. |
|---|
| 1508 | 1496 | */ |
|---|
| 1509 | 1497 | sctp_port_hashsize = rounddown_pow_of_two(num_entries); |
|---|
| 1510 | 1498 | |
|---|