Hi Folks,
This is my first patch suggestion post, so I hope I've copied the correct
people. Please let me know if I've not followed the process correctly.
Included below is patch file against the 2.4.10 tree which makes some
changes to the SNMP related kernel counters, mainly to try and make the
statistics more accurate. I've included a brief summary below.
Any thoughts, comments ?
Cheers, Mark.
o Added support for TcpRtoMin,TcpRtoMax,TcpRtoAlgorithm and TcpMaxConn
variables, including a rather ugly cludge to proc.c for TCPMaxConn.
o Modified the way IpInDelivers is incremented. Rather than incrementing
this counter in each of the other protocols recieve routines (ie.
tcp_v4_rcv() raw_rcv() etc.) the counter is incremented prior to the
protocol handler being called. Also removed code which decrements
IpInDelivers in the protocol handlers, higher level protocol handlers
shouldn't be modifying other layers protocol counters.
o Removed IpInDiscards increments in other other layers protocol receive
routines.
o Added IpInDiscards increments in IP routines where frame is discarded
due to memory allocation failures.
o Increment IcmpOutErrors on AddrMask Requests, which are not supported by
the kernel.
o Increment IpInAddrErrors during Martian handling.
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 Tue Oct 2 11:26:24 2001
@@ -331,6 +331,7 @@
#define TCP_DELACK_MIN 4
#define TCP_ATO_MIN 4
#endif
+#define TCP_RTO_JACOBSON 4 /* The Van Jacobson retransmission timeout
algorithm */
#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 Tue Oct 2 11:16:06 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_JACOBSON;
+ 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.
|