Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netinet reinstate a simple version of ip_randomid()
details: https://anonhg.NetBSD.org/src/rev/d1ff69703c39
branches: trunk
changeset: 960125:d1ff69703c39
user: christos <christos%NetBSD.org@localhost>
date: Mon Mar 08 20:01:54 2021 +0000
description:
reinstate a simple version of ip_randomid()
diffstat:
sys/net/npf/npf_ext_normalize.c | 4 ++--
sys/netinet/in_var.h | 13 ++++++++++---
2 files changed, 12 insertions(+), 5 deletions(-)
diffs (55 lines):
diff -r 3edf6341df93 -r d1ff69703c39 sys/net/npf/npf_ext_normalize.c
--- a/sys/net/npf/npf_ext_normalize.c Mon Mar 08 20:01:16 2021 +0000
+++ b/sys/net/npf/npf_ext_normalize.c Mon Mar 08 20:01:54 2021 +0000
@@ -26,7 +26,7 @@
#ifdef _KERNEL
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npf_ext_normalize.c,v 1.10 2020/05/30 14:16:56 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_ext_normalize.c,v 1.11 2021/03/08 20:01:54 christos Exp $");
#include <sys/types.h>
#include <sys/module.h>
@@ -114,7 +114,7 @@
if (np->n_random_id) {
uint16_t oid = ip->ip_id, nid;
- nid = htons(ip_randomid(ip_ids, 0));
+ nid = ip_randomid();
cksum = npf_fixup16_cksum(cksum, oid, nid);
ip->ip_id = nid;
}
diff -r 3edf6341df93 -r d1ff69703c39 sys/netinet/in_var.h
--- a/sys/netinet/in_var.h Mon Mar 08 20:01:16 2021 +0000
+++ b/sys/netinet/in_var.h Mon Mar 08 20:01:54 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: in_var.h,v 1.100 2021/03/08 18:03:25 christos Exp $ */
+/* $NetBSD: in_var.h,v 1.101 2021/03/08 20:01:54 christos Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -450,6 +450,14 @@
extern uint16_t ip_id;
extern int ip_do_randomid;
+static __inline uint16_t
+ip_randomid(void)
+{
+
+ uint16_t id = (uint16_t)cprng_fast32();
+ return id ? id : 1;
+}
+
/*
* ip_newid_range: "allocate" num contiguous IP IDs.
*
@@ -462,8 +470,7 @@
if (ip_do_randomid) {
/* XXX ignore num */
- id = (uint16_t)cprng_fast32();
- return id ? id : 1;
+ return ip_randomid();
}
/* Never allow an IP ID of 0 (detect wrap). */
Home |
Main Index |
Thread Index |
Old Index