Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet Diff to netinet/ip_input.c (restore ip_id, initi...



details:   https://anonhg.NetBSD.org/src/rev/b173994bad89
branches:  trunk
changeset: 555445:b173994bad89
user:      jonathan <jonathan%NetBSD.org@localhost>
date:      Mon Nov 17 22:34:16 2003 +0000

description:
Diff to netinet/ip_input.c (restore ip_id, initialize) for ip_id fix:

Revert the (default) ip_id algorithm to the pre-randomid algorithm,
due to demonstrated low-period repeated IDs from the randomized IP_id
code.  Consensus is that the low-period repetition (much less than
2^15) is not suitable for general-purpose use.

Allocators of new IPv4 IDs should now call the function ip_newid().
Randomized IP_ids is now a config-time option, "options RANDOM_IP_ID".
ip_newid() can use ip_random-id()_IP_ID if and only if configured
with RANDOM_IP_ID. A sysctl knob should be  provided.

This API may be reworked in the near future to support linear ip_id
counters per (src,dst) IP-address pair.

diffstat:

 sys/netinet/ip_input.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (34 lines):

diff -r 9f0765955429 -r b173994bad89 sys/netinet/ip_input.c
--- a/sys/netinet/ip_input.c    Mon Nov 17 22:20:00 2003 +0000
+++ b/sys/netinet/ip_input.c    Mon Nov 17 22:34:16 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_input.c,v 1.182 2003/11/12 15:00:05 itojun Exp $    */
+/*     $NetBSD: ip_input.c,v 1.183 2003/11/17 22:34:16 jonathan Exp $  */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -98,7 +98,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.182 2003/11/12 15:00:05 itojun Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.183 2003/11/17 22:34:16 jonathan Exp $");
 
 #include "opt_gateway.h"
 #include "opt_pfil_hooks.h"
@@ -226,6 +226,7 @@
 struct in_multihashhead *in_multihashtbl;
 struct ifqueue ipintrq;
 struct ipstat  ipstat;
+uint16_t ip_id;
 
 #ifdef PFIL_HOOKS
 struct pfil_head inet_pfil_hook;
@@ -359,6 +360,7 @@
                    pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW)
                        ip_protox[pr->pr_protocol] = pr - inetsw;
        LIST_INIT(&ipq);
+       ip_id = time.tv_sec & 0xfffff;
        ipintrq.ifq_maxlen = ipqmaxlen;
        TAILQ_INIT(&in_ifaddrhead);
        in_ifaddrhashtbl = hashinit(IN_IFADDR_HASH_SIZE, HASH_LIST, M_IFADDR,



Home | Main Index | Thread Index | Old Index