diff options
author | dwmalone <dwmalone@FreeBSD.org> | 2004-08-14 15:32:40 +0000 |
---|---|---|
committer | dwmalone <dwmalone@FreeBSD.org> | 2004-08-14 15:32:40 +0000 |
commit | 5df13d37b27b8510415fb500f01a289443950ebb (patch) | |
tree | 56a806b0847f95ede378bb97ce9bfcb595420ea2 /sys/netinet/ip_var.h | |
parent | 271672aa9c335d2a4944e53a99960718533d3f22 (diff) | |
download | FreeBSD-src-5df13d37b27b8510415fb500f01a289443950ebb.zip FreeBSD-src-5df13d37b27b8510415fb500f01a289443950ebb.tar.gz |
Get rid of the RANDOM_IP_ID option and make it a sysctl. NetBSD
have already done this, so I have styled the patch on their work:
1) introduce a ip_newid() static inline function that checks
the sysctl and then decides if it should return a sequential
or random IP ID.
2) named the sysctl net.inet.ip.random_id
3) IPv6 flow IDs and fragment IDs are now always random.
Flow IDs and frag IDs are significantly less common in the
IPv6 world (ie. rarely generated per-packet), so there should
be smaller performance concerns.
The sysctl defaults to 0 (sequential IP IDs).
Reviewed by: andre, silby, mlaier, ume
Based on: NetBSD
MFC after: 2 months
Diffstat (limited to 'sys/netinet/ip_var.h')
-rw-r--r-- | sys/netinet/ip_var.h | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h index ff616fb..66da695b 100644 --- a/sys/netinet/ip_var.h +++ b/sys/netinet/ip_var.h @@ -142,9 +142,7 @@ struct route; struct sockopt; extern struct ipstat ipstat; -#ifndef RANDOM_IP_ID extern u_short ip_id; /* ip packet ctr, for ids */ -#endif extern int ip_defttl; /* default IP ttl */ extern int ipforwarding; /* ip forwarding */ extern int ip_doopts; /* process or ignore IP options */ @@ -178,10 +176,7 @@ void ip_slowtimo(void); struct mbuf * ip_srcroute(void); void ip_stripoptions(struct mbuf *, struct mbuf *); -#ifdef RANDOM_IP_ID -u_int16_t - ip_randomid(void); -#endif +u_int16_t ip_randomid(void); int rip_ctloutput(struct socket *, struct sockopt *); void rip_ctlinput(int, struct sockaddr *, void *); void rip_init(void); @@ -201,6 +196,18 @@ extern struct pfil_head inet_pfil_hook; void in_delayed_cksum(struct mbuf *m); +static __inline uint16_t ip_newid(void); +extern int ip_do_randomid; + +static __inline uint16_t +ip_newid(void) +{ + if (ip_do_randomid) + return ip_randomid(); + + return htons(ip_id++); +} + #endif /* _KERNEL */ #endif /* !_NETINET_IP_VAR_H_ */ |