mib: put icmpmsg statistics on struct net
[safe/jmp/linux-2.6] / net / ipv4 / icmp.c
index f064031..8605586 100644 (file)
@@ -3,8 +3,6 @@
  *
  *             Alan Cox, <alan@redhat.com>
  *
- *     Version: $Id: icmp.c,v 1.85 2002/02/01 22:01:03 davem Exp $
- *
  *     This program is free software; you can redistribute it and/or
  *     modify it under the terms of the GNU General Public License
  *     as published by the Free Software Foundation; either version
@@ -113,12 +111,6 @@ struct icmp_bxm {
        unsigned char  optbuf[40];
 };
 
-/*
- *     Statistics
- */
-DEFINE_SNMP_STAT(struct icmp_mib, icmp_statistics) __read_mostly;
-DEFINE_SNMP_STAT(struct icmpmsg_mib, icmpmsg_statistics) __read_mostly;
-
 /* An array of errno for error messages from dest unreach. */
 /* RFC 1122: 3.2.2.1 States that NET_UNREACH, HOST_UNREACH and SR_FAILED MUST be considered 'transient errs'. */
 
@@ -298,10 +290,10 @@ out:
 /*
  *     Maintain the counters used in the SNMP statistics for outgoing ICMP
  */
-void icmp_out_count(unsigned char type)
+void icmp_out_count(struct net *net, unsigned char type)
 {
-       ICMPMSGOUT_INC_STATS(type);
-       ICMP_INC_STATS(ICMP_MIB_OUTMSGS);
+       ICMPMSGOUT_INC_STATS(net, type);
+       ICMP_INC_STATS(net, ICMP_MIB_OUTMSGS);
 }
 
 /*
@@ -691,7 +683,8 @@ static void icmp_unreach(struct sk_buff *skb)
                                               NIPQUAD(iph->daddr));
                        } else {
                                info = ip_rt_frag_needed(net, iph,
-                                                    ntohs(icmph->un.frag.mtu));
+                                                        ntohs(icmph->un.frag.mtu),
+                                                        skb->dev);
                                if (!info)
                                        goto out;
                        }
@@ -764,7 +757,7 @@ static void icmp_unreach(struct sk_buff *skb)
 out:
        return;
 out_err:
-       ICMP_INC_STATS_BH(ICMP_MIB_INERRORS);
+       ICMP_INC_STATS_BH(net, ICMP_MIB_INERRORS);
        goto out;
 }
 
@@ -804,7 +797,7 @@ static void icmp_redirect(struct sk_buff *skb)
 out:
        return;
 out_err:
-       ICMP_INC_STATS_BH(ICMP_MIB_INERRORS);
+       ICMP_INC_STATS_BH(dev_net(skb->dev), ICMP_MIB_INERRORS);
        goto out;
 }
 
@@ -847,7 +840,7 @@ static void icmp_echo(struct sk_buff *skb)
  */
 static void icmp_timestamp(struct sk_buff *skb)
 {
-       struct timeval tv;
+       struct timespec tv;
        struct icmp_bxm icmp_param;
        /*
         *      Too short.
@@ -858,9 +851,9 @@ static void icmp_timestamp(struct sk_buff *skb)
        /*
         *      Fill in the current time as ms since midnight UT:
         */
-       do_gettimeofday(&tv);
-       icmp_param.data.times[1] = htonl((tv.tv_sec % 86400) * 1000 +
-                                        tv.tv_usec / 1000);
+       getnstimeofday(&tv);
+       icmp_param.data.times[1] = htonl((tv.tv_sec % 86400) * MSEC_PER_SEC +
+                                        tv.tv_nsec / NSEC_PER_MSEC);
        icmp_param.data.times[2] = icmp_param.data.times[1];
        if (skb_copy_bits(skb, 0, &icmp_param.data.times[0], 4))
                BUG();
@@ -875,7 +868,7 @@ static void icmp_timestamp(struct sk_buff *skb)
 out:
        return;
 out_err:
-       ICMP_INC_STATS_BH(ICMP_MIB_INERRORS);
+       ICMP_INC_STATS_BH(dev_net(skb->dst->dev), ICMP_MIB_INERRORS);
        goto out;
 }
 
@@ -974,6 +967,7 @@ int icmp_rcv(struct sk_buff *skb)
 {
        struct icmphdr *icmph;
        struct rtable *rt = skb->rtable;
+       struct net *net = dev_net(rt->u.dst.dev);
 
        if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) {
                int nh;
@@ -994,7 +988,7 @@ int icmp_rcv(struct sk_buff *skb)
                skb_set_network_header(skb, nh);
        }
 
-       ICMP_INC_STATS_BH(ICMP_MIB_INMSGS);
+       ICMP_INC_STATS_BH(net, ICMP_MIB_INMSGS);
 
        switch (skb->ip_summed) {
        case CHECKSUM_COMPLETE:
@@ -1012,7 +1006,7 @@ int icmp_rcv(struct sk_buff *skb)
 
        icmph = icmp_hdr(skb);
 
-       ICMPMSGIN_INC_STATS_BH(icmph->type);
+       ICMPMSGIN_INC_STATS_BH(net, icmph->type);
        /*
         *      18 is the highest 'known' ICMP type. Anything else is a mystery
         *
@@ -1028,9 +1022,6 @@ int icmp_rcv(struct sk_buff *skb)
         */
 
        if (rt->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST)) {
-               struct net *net;
-
-               net = dev_net(rt->u.dst.dev);
                /*
                 *      RFC 1122: 3.2.2.6 An ICMP_ECHO to broadcast MAY be
                 *        silently ignored (we let user decide with a sysctl).
@@ -1056,7 +1047,7 @@ drop:
        kfree_skb(skb);
        return 0;
 error:
-       ICMP_INC_STATS_BH(ICMP_MIB_INERRORS);
+       ICMP_INC_STATS_BH(net, ICMP_MIB_INERRORS);
        goto drop;
 }
 
@@ -1144,7 +1135,7 @@ static void __net_exit icmp_sk_exit(struct net *net)
        net->ipv4.icmp_sk = NULL;
 }
 
-int __net_init icmp_sk_init(struct net *net)
+static int __net_init icmp_sk_init(struct net *net)
 {
        int i, err;
 
@@ -1216,5 +1207,4 @@ int __init icmp_init(void)
 
 EXPORT_SYMBOL(icmp_err_convert);
 EXPORT_SYMBOL(icmp_send);
-EXPORT_SYMBOL(icmp_statistics);
 EXPORT_SYMBOL(xrlim_allow);