diff options
Diffstat (limited to 'net/ipv4/af_inet.c')
-rw-r--r-- | net/ipv4/af_inet.c | 87 |
1 files changed, 52 insertions, 35 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 24eca23c2db3..dd919d84285f 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
@@ -5,8 +5,6 @@ | |||
5 | * | 5 | * |
6 | * PF_INET protocol family socket handler. | 6 | * PF_INET protocol family socket handler. |
7 | * | 7 | * |
8 | * Version: $Id: af_inet.c,v 1.137 2002/02/01 22:01:03 davem Exp $ | ||
9 | * | ||
10 | * Authors: Ross Biro | 8 | * Authors: Ross Biro |
11 | * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> | 9 | * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> |
12 | * Florian La Roche, <flla@stud.uni-sb.de> | 10 | * Florian La Roche, <flla@stud.uni-sb.de> |
@@ -112,12 +110,11 @@ | |||
112 | #include <net/ipip.h> | 110 | #include <net/ipip.h> |
113 | #include <net/inet_common.h> | 111 | #include <net/inet_common.h> |
114 | #include <net/xfrm.h> | 112 | #include <net/xfrm.h> |
113 | #include <net/net_namespace.h> | ||
115 | #ifdef CONFIG_IP_MROUTE | 114 | #ifdef CONFIG_IP_MROUTE |
116 | #include <linux/mroute.h> | 115 | #include <linux/mroute.h> |
117 | #endif | 116 | #endif |
118 | 117 | ||
119 | DEFINE_SNMP_STAT(struct linux_mib, net_statistics) __read_mostly; | ||
120 | |||
121 | extern void ip_mc_drop_socket(struct sock *sk); | 118 | extern void ip_mc_drop_socket(struct sock *sk); |
122 | 119 | ||
123 | /* The inetsw table contains everything that inet_create needs to | 120 | /* The inetsw table contains everything that inet_create needs to |
@@ -1341,50 +1338,70 @@ static struct net_protocol icmp_protocol = { | |||
1341 | .netns_ok = 1, | 1338 | .netns_ok = 1, |
1342 | }; | 1339 | }; |
1343 | 1340 | ||
1344 | static int __init init_ipv4_mibs(void) | 1341 | static __net_init int ipv4_mib_init_net(struct net *net) |
1345 | { | 1342 | { |
1346 | if (snmp_mib_init((void **)net_statistics, | 1343 | if (snmp_mib_init((void **)net->mib.tcp_statistics, |
1347 | sizeof(struct linux_mib)) < 0) | ||
1348 | goto err_net_mib; | ||
1349 | if (snmp_mib_init((void **)ip_statistics, | ||
1350 | sizeof(struct ipstats_mib)) < 0) | ||
1351 | goto err_ip_mib; | ||
1352 | if (snmp_mib_init((void **)icmp_statistics, | ||
1353 | sizeof(struct icmp_mib)) < 0) | ||
1354 | goto err_icmp_mib; | ||
1355 | if (snmp_mib_init((void **)icmpmsg_statistics, | ||
1356 | sizeof(struct icmpmsg_mib)) < 0) | ||
1357 | goto err_icmpmsg_mib; | ||
1358 | if (snmp_mib_init((void **)tcp_statistics, | ||
1359 | sizeof(struct tcp_mib)) < 0) | 1344 | sizeof(struct tcp_mib)) < 0) |
1360 | goto err_tcp_mib; | 1345 | goto err_tcp_mib; |
1361 | if (snmp_mib_init((void **)udp_statistics, | 1346 | if (snmp_mib_init((void **)net->mib.ip_statistics, |
1347 | sizeof(struct ipstats_mib)) < 0) | ||
1348 | goto err_ip_mib; | ||
1349 | if (snmp_mib_init((void **)net->mib.net_statistics, | ||
1350 | sizeof(struct linux_mib)) < 0) | ||
1351 | goto err_net_mib; | ||
1352 | if (snmp_mib_init((void **)net->mib.udp_statistics, | ||
1362 | sizeof(struct udp_mib)) < 0) | 1353 | sizeof(struct udp_mib)) < 0) |
1363 | goto err_udp_mib; | 1354 | goto err_udp_mib; |
1364 | if (snmp_mib_init((void **)udplite_statistics, | 1355 | if (snmp_mib_init((void **)net->mib.udplite_statistics, |
1365 | sizeof(struct udp_mib)) < 0) | 1356 | sizeof(struct udp_mib)) < 0) |
1366 | goto err_udplite_mib; | 1357 | goto err_udplite_mib; |
1358 | if (snmp_mib_init((void **)net->mib.icmp_statistics, | ||
1359 | sizeof(struct icmp_mib)) < 0) | ||
1360 | goto err_icmp_mib; | ||
1361 | if (snmp_mib_init((void **)net->mib.icmpmsg_statistics, | ||
1362 | sizeof(struct icmpmsg_mib)) < 0) | ||
1363 | goto err_icmpmsg_mib; | ||
1367 | 1364 | ||
1368 | tcp_mib_init(); | 1365 | tcp_mib_init(net); |
1369 | |||
1370 | return 0; | 1366 | return 0; |
1371 | 1367 | ||
1372 | err_udplite_mib: | ||
1373 | snmp_mib_free((void **)udp_statistics); | ||
1374 | err_udp_mib: | ||
1375 | snmp_mib_free((void **)tcp_statistics); | ||
1376 | err_tcp_mib: | ||
1377 | snmp_mib_free((void **)icmpmsg_statistics); | ||
1378 | err_icmpmsg_mib: | 1368 | err_icmpmsg_mib: |
1379 | snmp_mib_free((void **)icmp_statistics); | 1369 | snmp_mib_free((void **)net->mib.icmp_statistics); |
1380 | err_icmp_mib: | 1370 | err_icmp_mib: |
1381 | snmp_mib_free((void **)ip_statistics); | 1371 | snmp_mib_free((void **)net->mib.udplite_statistics); |
1382 | err_ip_mib: | 1372 | err_udplite_mib: |
1383 | snmp_mib_free((void **)net_statistics); | 1373 | snmp_mib_free((void **)net->mib.udp_statistics); |
1374 | err_udp_mib: | ||
1375 | snmp_mib_free((void **)net->mib.net_statistics); | ||
1384 | err_net_mib: | 1376 | err_net_mib: |
1377 | snmp_mib_free((void **)net->mib.ip_statistics); | ||
1378 | err_ip_mib: | ||
1379 | snmp_mib_free((void **)net->mib.tcp_statistics); | ||
1380 | err_tcp_mib: | ||
1385 | return -ENOMEM; | 1381 | return -ENOMEM; |
1386 | } | 1382 | } |
1387 | 1383 | ||
1384 | static __net_exit void ipv4_mib_exit_net(struct net *net) | ||
1385 | { | ||
1386 | snmp_mib_free((void **)net->mib.icmpmsg_statistics); | ||
1387 | snmp_mib_free((void **)net->mib.icmp_statistics); | ||
1388 | snmp_mib_free((void **)net->mib.udplite_statistics); | ||
1389 | snmp_mib_free((void **)net->mib.udp_statistics); | ||
1390 | snmp_mib_free((void **)net->mib.net_statistics); | ||
1391 | snmp_mib_free((void **)net->mib.ip_statistics); | ||
1392 | snmp_mib_free((void **)net->mib.tcp_statistics); | ||
1393 | } | ||
1394 | |||
1395 | static __net_initdata struct pernet_operations ipv4_mib_ops = { | ||
1396 | .init = ipv4_mib_init_net, | ||
1397 | .exit = ipv4_mib_exit_net, | ||
1398 | }; | ||
1399 | |||
1400 | static int __init init_ipv4_mibs(void) | ||
1401 | { | ||
1402 | return register_pernet_subsys(&ipv4_mib_ops); | ||
1403 | } | ||
1404 | |||
1388 | static int ipv4_proc_init(void); | 1405 | static int ipv4_proc_init(void); |
1389 | 1406 | ||
1390 | /* | 1407 | /* |
@@ -1481,14 +1498,15 @@ static int __init inet_init(void) | |||
1481 | * Initialise the multicast router | 1498 | * Initialise the multicast router |
1482 | */ | 1499 | */ |
1483 | #if defined(CONFIG_IP_MROUTE) | 1500 | #if defined(CONFIG_IP_MROUTE) |
1484 | ip_mr_init(); | 1501 | if (ip_mr_init()) |
1502 | printk(KERN_CRIT "inet_init: Cannot init ipv4 mroute\n"); | ||
1485 | #endif | 1503 | #endif |
1486 | /* | 1504 | /* |
1487 | * Initialise per-cpu ipv4 mibs | 1505 | * Initialise per-cpu ipv4 mibs |
1488 | */ | 1506 | */ |
1489 | 1507 | ||
1490 | if (init_ipv4_mibs()) | 1508 | if (init_ipv4_mibs()) |
1491 | printk(KERN_CRIT "inet_init: Cannot init ipv4 mibs\n"); ; | 1509 | printk(KERN_CRIT "inet_init: Cannot init ipv4 mibs\n"); |
1492 | 1510 | ||
1493 | ipv4_proc_init(); | 1511 | ipv4_proc_init(); |
1494 | 1512 | ||
@@ -1560,5 +1578,4 @@ EXPORT_SYMBOL(inet_sock_destruct); | |||
1560 | EXPORT_SYMBOL(inet_stream_connect); | 1578 | EXPORT_SYMBOL(inet_stream_connect); |
1561 | EXPORT_SYMBOL(inet_stream_ops); | 1579 | EXPORT_SYMBOL(inet_stream_ops); |
1562 | EXPORT_SYMBOL(inet_unregister_protosw); | 1580 | EXPORT_SYMBOL(inet_unregister_protosw); |
1563 | EXPORT_SYMBOL(net_statistics); | ||
1564 | EXPORT_SYMBOL(sysctl_ip_nonlocal_bind); | 1581 | EXPORT_SYMBOL(sysctl_ip_nonlocal_bind); |