Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Sample # of TX packets as entropy source.



details:   https://anonhg.NetBSD.org/src/rev/303538af9899
branches:  trunk
changeset: 1020757:303538af9899
user:      rin <rin%NetBSD.org@localhost>
date:      Sun Apr 25 05:15:20 2021 +0000

description:
Sample # of TX packets as entropy source.

For RX packets, individual drivers need to be modified.

diffstat:

 sys/dev/usb/usbnet.c |  11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diffs (53 lines):

diff -r 03e4a7d2e12b -r 303538af9899 sys/dev/usb/usbnet.c
--- a/sys/dev/usb/usbnet.c      Sun Apr 25 01:44:55 2021 +0000
+++ b/sys/dev/usb/usbnet.c      Sun Apr 25 05:15:20 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbnet.c,v 1.40 2021/03/01 17:41:44 jakllsch Exp $     */
+/*     $NetBSD: usbnet.c,v 1.41 2021/04/25 05:15:20 rin Exp $  */
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.40 2021/03/01 17:41:44 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.41 2021/04/25 05:15:20 rin Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -478,7 +478,7 @@
        struct mbuf *m;
        unsigned length;
        bool done_transmit = false;
-       int idx;
+       int idx, count;
 
        USBNETHIST_CALLARGS("%jd: tx_cnt %jd list_cnt %jd link %jd",
            unp->unp_number, cd->uncd_tx_cnt, un->un_tx_list_cnt,
@@ -500,6 +500,7 @@
        }
 
        idx = cd->uncd_tx_prod;
+       count = 0;
        while (cd->uncd_tx_cnt < un->un_tx_list_cnt) {
                IFQ_POLL(&ifp->if_snd, m);
                if (m == NULL) {
@@ -547,6 +548,7 @@
 
                idx = (idx + 1) % un->un_tx_list_cnt;
                cd->uncd_tx_cnt++;
+               count++;
        }
        cd->uncd_tx_prod = idx;
 
@@ -558,6 +560,9 @@
         */
        if (done_transmit)
                unp->unp_timer = 5;
+
+       if (count != 0)
+               rnd_add_uint32(&unp->unp_rndsrc, count);
 }
 
 static void



Home | Main Index | Thread Index | Old Index