netdev
[Top] [All Lists]

Re: patch - SNMP Kernel Counters

To: Andi Kleen <ak@xxxxxx>
Subject: Re: patch - SNMP Kernel Counters
From: Mark Price <mkprice@xxxxxxxxxx>
Date: Thu, 4 Oct 2001 15:40:24 -0700 (PDT)
Cc: <mkprice@xxxxxxxxxx>, <netdev@xxxxxxxxxxx>, <davem@xxxxxxxxxx>, <kuznet@xxxxxxxxxxxxx>
In-reply-to: <20011004114917.57615@xxxxxxxxxxxx>
Sender: owner-netdev@xxxxxxxxxxx
On Thu, 4 Oct 2001, Andi Kleen wrote:

> That's not quite correct. 2.4 doesn't use the Van Jacobson algorithm anymore
> (see ftp.inr.ac.ru:/ip-routing/README.rto). I don't know what the right
> value should be however.
>
> -Andi

Modified my patch to use other(1) as the Algorithm. Full patch included
again below.

Cheers, Mark.

diff -urN linux-2.4.10/include/net/tcp.h linux/include/net/tcp.h
--- linux-2.4.10/include/net/tcp.h      Sun Sep 23 10:31:58 2001
+++ linux/include/net/tcp.h     Thu Oct  4 10:22:33 2001
@@ -331,6 +331,7 @@
 #define TCP_DELACK_MIN 4
 #define TCP_ATO_MIN    4
 #endif
+#define TCP_RTO_OTHER  1       /* RTO Algorithm used by linux */
 #define TCP_RTO_MAX    (120*HZ)
 #define TCP_RTO_MIN    (HZ/5)
 #define TCP_TIMEOUT_INIT (3*HZ)        /* RFC 1122 initial RTO value   */
diff -urN linux-2.4.10/net/ipv4/icmp.c linux/net/ipv4/icmp.c
--- linux-2.4.10/net/ipv4/icmp.c        Fri Sep  7 11:01:21 2001
+++ linux/net/ipv4/icmp.c       Tue Oct  2 11:24:44 2001
@@ -826,6 +826,10 @@
        if (net_ratelimit())
                printk(KERN_DEBUG "a guy asks for address mask. Who is it?\n");
 #endif
+        /*
+         *  Just say that there is an out-error in SNMP for now.
+         */
+        ICMP_INC_STATS(IcmpOutErrors);
 }

 /*
diff -urN linux-2.4.10/net/ipv4/ip_input.c linux/net/ipv4/ip_input.c
--- linux-2.4.10/net/ipv4/ip_input.c    Thu Apr 12 12:11:39 2001
+++ linux/net/ipv4/ip_input.c   Wed Oct  3 09:35:26 2001
@@ -219,6 +219,7 @@
 static inline int ip_local_deliver_finish(struct sk_buff *skb)
 {
        int ihl = skb->nh.iph->ihl*4;
+       int raw_flg = 0;

 #ifdef CONFIG_NETFILTER_DEBUG
        nf_debug_ip_local_deliver(skb);
@@ -245,13 +246,15 @@
                int hash = protocol & (MAX_INET_PROTOS - 1);
                struct sock *raw_sk = raw_v4_htable[hash];
                struct inet_protocol *ipprot;
-               int flag;
+               int aflg,flag;

                /* If there maybe a raw socket we must check - if not we
                 * don't care less
                 */
-               if(raw_sk != NULL)
+               if(raw_sk != NULL) {
+                       raw_flg = 1;
                        raw_sk = raw_v4_input(skb, skb->nh.iph, hash);
+               }

                ipprot = (struct inet_protocol *) inet_protos[hash];
                flag = 0;
@@ -261,11 +264,18 @@
                           ipprot->protocol == protocol) {
                                int ret;

+                               /* Increment IpInDelivers prior to calling the 
Fast Path
+                                * protocol handler.
+                                */
+
+                               IP_INC_STATS_BH(IpInDelivers);
+
                                /* Fast path... */
                                ret = ipprot->handler(skb);

                                return ret;
                        } else {
+                               aflg = 1;
                                flag = ip_run_ipprot(skb, skb->nh.iph, ipprot, 
(raw_sk != NULL));
                        }
                }
@@ -280,9 +290,16 @@
                        sock_put(raw_sk);
                } else if (!flag) {             /* Free and report errors */
                        icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PROT_UNREACH, 0);
+                        /*
+                         * Increment unknown-protocol counter for SNMP.
+                         */
+                        IP_INC_STATS_BH(IpInUnknownProtos);
 out:
                        kfree_skb(skb);
                }
+
+               if (flag || raw_flg || aflg)
+                       IP_INC_STATS_BH(IpInDelivers);
        }

        return 0;
@@ -343,8 +360,10 @@
                                                      --ANK (980813)
                */

-               if (skb_cow(skb, skb_headroom(skb)))
+               if (skb_cow(skb, skb_headroom(skb))) {
+                       IP_INC_STATS_BH(IpInDiscards);
                        goto drop;
+               }
                iph = skb->nh.iph;

                skb->ip_summed = 0;
@@ -393,8 +412,10 @@

        IP_INC_STATS_BH(IpInReceives);

-       if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL)
+       if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL) {
+               IP_INC_STATS_BH(IpInDiscards);
                goto out;
+       }

        if (!pskb_may_pull(skb, sizeof(struct iphdr)))
                goto inhdr_error;
diff -urN linux-2.4.10/net/ipv4/proc.c linux/net/ipv4/proc.c
--- linux-2.4.10/net/ipv4/proc.c        Wed May 16 10:21:45 2001
+++ linux/net/ipv4/proc.c       Tue Oct  2 11:23:46 2001
@@ -135,7 +135,14 @@
                "\nTcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens 
PassiveOpens AttemptFails EstabResets CurrEstab InSegs OutSegs RetransSegs 
InErrs OutRsts\n"
                  "Tcp:");
        for (i=0; i<offsetof(struct tcp_mib, __pad)/sizeof(unsigned long); i++)
-               len += sprintf(buffer+len, " %lu", fold_field((unsigned 
long*)tcp_statistics, sizeof(struct tcp_mib), i));
+
+               /* The SNMP TCP MaxxConn value is -1 for Linux - Special casing 
as fold_field was called with unsigned long. */
+
+               if(i==3) {
+               len += sprintf(buffer+len, " %ld", (long)fold_field((unsigned 
long*)tcp_statistics, sizeof(struct tcp_mib), i));
+        } else {
+               len += sprintf(buffer+len, " %lu", fold_field((unsigned 
long*)tcp_statistics, sizeof(struct tcp_mib), i));
+        }

        len += sprintf (buffer + len,
                "\nUdp: InDatagrams NoPorts InErrors OutDatagrams\n"
diff -urN linux-2.4.10/net/ipv4/raw.c linux/net/ipv4/raw.c
--- linux-2.4.10/net/ipv4/raw.c Tue Jul 10 16:11:43 2001
+++ linux/net/ipv4/raw.c        Tue Oct  2 11:21:01 2001
@@ -233,12 +233,10 @@
        /* Charge it to the socket. */

        if (sock_queue_rcv_skb(sk, skb) < 0) {
-               IP_INC_STATS(IpInDiscards);
                kfree_skb(skb);
                return NET_RX_DROP;
        }

-       IP_INC_STATS(IpInDelivers);
        return NET_RX_SUCCESS;
 }

diff -urN linux-2.4.10/net/ipv4/route.c linux/net/ipv4/route.c
--- linux-2.4.10/net/ipv4/route.c       Thu Sep 20 14:12:56 2001
+++ linux/net/ipv4/route.c      Tue Oct  2 11:17:05 2001
@@ -1587,6 +1587,7 @@
                        "%u.%u.%u.%u, dev %s\n",
                        NIPQUAD(daddr), NIPQUAD(saddr), dev->name);
 #endif
+       IP_INC_STATS_BH(IpInAddrErrors);
 e_inval:
        err = -EINVAL;
        goto done;
diff -urN linux-2.4.10/net/ipv4/tcp.c linux/net/ipv4/tcp.c
--- linux-2.4.10/net/ipv4/tcp.c Thu Sep 20 14:12:56 2001
+++ linux/net/ipv4/tcp.c        Thu Oct  4 10:23:07 2001
@@ -2555,4 +2555,15 @@

        printk("TCP: Hash tables configured (established %d bind %d)\n",
               tcp_ehash_size<<1, tcp_bhash_size);
+
+       /* Setup the SNMP Stats for the TCP RTO values.
+        * TcpMaxConn = -1 as the maximum number of connections is
+        * dynamic.
+        */
+
+       tcp_statistics[0].TcpRtoAlgorithm=TCP_RTO_OTHER;
+        tcp_statistics[0].TcpRtoMin=TCP_RTO_MIN*1000/HZ;
+        tcp_statistics[0].TcpRtoMax=TCP_RTO_MAX*1000/HZ;
+        tcp_statistics[0].TcpMaxConn=-1;
+
 }
diff -urN linux-2.4.10/net/ipv4/tcp_ipv4.c linux/net/ipv4/tcp_ipv4.c
--- linux-2.4.10/net/ipv4/tcp_ipv4.c    Fri Sep  7 11:01:21 2001
+++ linux/net/ipv4/tcp_ipv4.c   Tue Oct  2 11:25:34 2001
@@ -1538,8 +1538,6 @@
                goto discard;
 #endif /* CONFIG_FILTER */

-       IP_INC_STATS_BH(IpInDelivers);
-
        if (sk->state == TCP_ESTABLISHED) { /* Fast path */
                TCP_CHECK_TIMER(sk);
                if (tcp_rcv_established(sk, skb, skb->h.th, skb->len))
diff -urN linux-2.4.10/net/ipv4/udp.c linux/net/ipv4/udp.c
--- linux-2.4.10/net/ipv4/udp.c Fri Sep  7 11:01:21 2001
+++ linux/net/ipv4/udp.c        Tue Oct  2 11:25:12 2001
@@ -785,8 +785,6 @@
        if (sk->filter && skb->ip_summed != CHECKSUM_UNNECESSARY) {
                if (__udp_checksum_complete(skb)) {
                        UDP_INC_STATS_BH(UdpInErrors);
-                       IP_INC_STATS_BH(IpInDiscards);
-                       ip_statistics[smp_processor_id()*2].IpInDelivers--;
                        kfree_skb(skb);
                        return -1;
                }
@@ -796,8 +794,6 @@

        if (sock_queue_rcv_skb(sk,skb)<0) {
                UDP_INC_STATS_BH(UdpInErrors);
-               IP_INC_STATS_BH(IpInDiscards);
-               ip_statistics[smp_processor_id()*2].IpInDelivers--;
                kfree_skb(skb);
                return -1;
        }
@@ -836,8 +832,10 @@
                                udp_queue_rcv_skb(sk, skb1);
                        sk = sknext;
                } while(sknext);
-       } else
+       } else {
+               UDP_INC_STATS_BH(UdpNoPorts);
                kfree_skb(skb);
+       }
        read_unlock(&udp_hash_lock);
        return 0;
 }
@@ -880,8 +878,6 @@
        u32 saddr = skb->nh.iph->saddr;
        u32 daddr = skb->nh.iph->daddr;
        int len = skb->len;
-
-       IP_INC_STATS_BH(IpInDelivers);

        /*
         *      Validate the packet and the UDP length.


<Prev in Thread] Current Thread [Next in Thread>