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.
This commit is contained in:
jonathan 2003-11-17 22:34:16 +00:00
parent 4c59345a6c
commit de80d1419e
1 changed files with 4 additions and 2 deletions

View File

@ -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 @@ int in_multientries; /* total number of addrs */
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 @@ ip_init()
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,