diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2010-06-22 16:58:41 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-06-26 00:33:17 -0400 |
commit | 1823e4c80eeae2a774c75569ce3035070e5ee009 (patch) | |
tree | bdc1bdf4a67027193312ad584924ca8a986a064c /net/ipv4/af_inet.c | |
parent | 5eaa0bd81f93225b6d1972b373ed00ca763052b2 (diff) |
snmp: add align parameter to snmp_mib_init()
In preparation for 64bit snmp counters for some mibs,
add an 'align' parameter to snmp_mib_init(), instead
of assuming mibs only contain 'unsigned long' fields.
Callers can use __alignof__(type) to provide correct
alignment.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Herbert Xu <herbert@gondor.apana.org.au>
CC: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
CC: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
CC: Vlad Yasevich <vladislav.yasevich@hp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/af_inet.c')
-rw-r--r-- | net/ipv4/af_inet.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index b4c0969137cb..640db9b90330 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
@@ -1427,13 +1427,13 @@ unsigned long snmp_fold_field(void __percpu *mib[], int offt) | |||
1427 | } | 1427 | } |
1428 | EXPORT_SYMBOL_GPL(snmp_fold_field); | 1428 | EXPORT_SYMBOL_GPL(snmp_fold_field); |
1429 | 1429 | ||
1430 | int snmp_mib_init(void __percpu *ptr[2], size_t mibsize) | 1430 | int snmp_mib_init(void __percpu *ptr[2], size_t mibsize, size_t align) |
1431 | { | 1431 | { |
1432 | BUG_ON(ptr == NULL); | 1432 | BUG_ON(ptr == NULL); |
1433 | ptr[0] = __alloc_percpu(mibsize, __alignof__(unsigned long)); | 1433 | ptr[0] = __alloc_percpu(mibsize, align); |
1434 | if (!ptr[0]) | 1434 | if (!ptr[0]) |
1435 | goto err0; | 1435 | goto err0; |
1436 | ptr[1] = __alloc_percpu(mibsize, __alignof__(unsigned long)); | 1436 | ptr[1] = __alloc_percpu(mibsize, align); |
1437 | if (!ptr[1]) | 1437 | if (!ptr[1]) |
1438 | goto err1; | 1438 | goto err1; |
1439 | return 0; | 1439 | return 0; |
@@ -1490,25 +1490,32 @@ static const struct net_protocol icmp_protocol = { | |||
1490 | static __net_init int ipv4_mib_init_net(struct net *net) | 1490 | static __net_init int ipv4_mib_init_net(struct net *net) |
1491 | { | 1491 | { |
1492 | if (snmp_mib_init((void __percpu **)net->mib.tcp_statistics, | 1492 | if (snmp_mib_init((void __percpu **)net->mib.tcp_statistics, |
1493 | sizeof(struct tcp_mib)) < 0) | 1493 | sizeof(struct tcp_mib), |
1494 | __alignof__(struct tcp_mib)) < 0) | ||
1494 | goto err_tcp_mib; | 1495 | goto err_tcp_mib; |
1495 | if (snmp_mib_init((void __percpu **)net->mib.ip_statistics, | 1496 | if (snmp_mib_init((void __percpu **)net->mib.ip_statistics, |
1496 | sizeof(struct ipstats_mib)) < 0) | 1497 | sizeof(struct ipstats_mib), |
1498 | __alignof__(struct ipstats_mib)) < 0) | ||
1497 | goto err_ip_mib; | 1499 | goto err_ip_mib; |
1498 | if (snmp_mib_init((void __percpu **)net->mib.net_statistics, | 1500 | if (snmp_mib_init((void __percpu **)net->mib.net_statistics, |
1499 | sizeof(struct linux_mib)) < 0) | 1501 | sizeof(struct linux_mib), |
1502 | __alignof__(struct linux_mib)) < 0) | ||
1500 | goto err_net_mib; | 1503 | goto err_net_mib; |
1501 | if (snmp_mib_init((void __percpu **)net->mib.udp_statistics, | 1504 | if (snmp_mib_init((void __percpu **)net->mib.udp_statistics, |
1502 | sizeof(struct udp_mib)) < 0) | 1505 | sizeof(struct udp_mib), |
1506 | __alignof__(struct udp_mib)) < 0) | ||
1503 | goto err_udp_mib; | 1507 | goto err_udp_mib; |
1504 | if (snmp_mib_init((void __percpu **)net->mib.udplite_statistics, | 1508 | if (snmp_mib_init((void __percpu **)net->mib.udplite_statistics, |
1505 | sizeof(struct udp_mib)) < 0) | 1509 | sizeof(struct udp_mib), |
1510 | __alignof__(struct udp_mib)) < 0) | ||
1506 | goto err_udplite_mib; | 1511 | goto err_udplite_mib; |
1507 | if (snmp_mib_init((void __percpu **)net->mib.icmp_statistics, | 1512 | if (snmp_mib_init((void __percpu **)net->mib.icmp_statistics, |
1508 | sizeof(struct icmp_mib)) < 0) | 1513 | sizeof(struct icmp_mib), |
1514 | __alignof__(struct icmp_mib)) < 0) | ||
1509 | goto err_icmp_mib; | 1515 | goto err_icmp_mib; |
1510 | if (snmp_mib_init((void __percpu **)net->mib.icmpmsg_statistics, | 1516 | if (snmp_mib_init((void __percpu **)net->mib.icmpmsg_statistics, |
1511 | sizeof(struct icmpmsg_mib)) < 0) | 1517 | sizeof(struct icmpmsg_mib), |
1518 | __alignof__(struct icmpmsg_mib)) < 0) | ||
1512 | goto err_icmpmsg_mib; | 1519 | goto err_icmpmsg_mib; |
1513 | 1520 | ||
1514 | tcp_mib_init(net); | 1521 | tcp_mib_init(net); |