lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <17893.46122.730254.596655@robur.slu.se>
Date:	Wed, 28 Feb 2007 17:56:10 +0100
From:	Robert Olsson <Robert.Olsson@...a.slu.se>
To:	Stephen Hemminger <shemminger@...ux-foundation.org>
Cc:	Robert Olsson <Robert.Olsson@...a.slu.se>,
	"David S. Miller" <davem@...emloft.net>, netdev@...r.kernel.org
Subject: [PATCH 2/4] pktgen: use random32


Thanks!

It seems like network code has preference for net_random() but they
are the same now.

Signed-off-by: Robert Olsson <robert.olsson@....uu.se>

Cheers.

					--ro

Stephen Hemminger writes:
 > Can use random32() now.
 > 
 > Signed-off-by: Stephen Hemminger <shemminger@...ux-foundation.org>
 > 
 > ---
 >  net/core/pktgen.c |   52 +++++++++++++++++++---------------------------------
 >  1 file changed, 19 insertions(+), 33 deletions(-)
 > 
 > --- pktgen.orig/net/core/pktgen.c	2007-02-26 14:34:36.000000000 -0800
 > +++ pktgen/net/core/pktgen.c	2007-02-26 14:39:53.000000000 -0800
 > @@ -464,17 +464,6 @@
 >  	return tmp;
 >  }
 >  
 > -static inline u32 pktgen_random(void)
 > -{
 > -#if 0
 > -	__u32 n;
 > -	get_random_bytes(&n, 4);
 > -	return n;
 > -#else
 > -	return net_random();
 > -#endif
 > -}
 > -
 >  static inline __u64 getCurMs(void)
 >  {
 >  	struct timeval tv;
 > @@ -2091,7 +2080,7 @@
 >  	int flow = 0;
 >  
 >  	if (pkt_dev->cflows) {
 > -		flow = pktgen_random() % pkt_dev->cflows;
 > +		flow = random32() % pkt_dev->cflows;
 >  
 >  		if (pkt_dev->flows[flow].count > pkt_dev->lflow)
 >  			pkt_dev->flows[flow].count = 0;
 > @@ -2103,7 +2092,7 @@
 >  		__u32 tmp;
 >  
 >  		if (pkt_dev->flags & F_MACSRC_RND)
 > -			mc = pktgen_random() % (pkt_dev->src_mac_count);
 > +			mc = random32() % pkt_dev->src_mac_count;
 >  		else {
 >  			mc = pkt_dev->cur_src_mac_offset++;
 >  			if (pkt_dev->cur_src_mac_offset >
 > @@ -2129,7 +2118,7 @@
 >  		__u32 tmp;
 >  
 >  		if (pkt_dev->flags & F_MACDST_RND)
 > -			mc = pktgen_random() % (pkt_dev->dst_mac_count);
 > +			mc = random32() % pkt_dev->dst_mac_count;
 >  
 >  		else {
 >  			mc = pkt_dev->cur_dst_mac_offset++;
 > @@ -2156,24 +2145,23 @@
 >  		for(i = 0; i < pkt_dev->nr_labels; i++)
 >  			if (pkt_dev->labels[i] & MPLS_STACK_BOTTOM)
 >  				pkt_dev->labels[i] = MPLS_STACK_BOTTOM |
 > -					     ((__force __be32)pktgen_random() &
 > +					     ((__force __be32)random32() &
 >  						      htonl(0x000fffff));
 >  	}
 >  
 >  	if ((pkt_dev->flags & F_VID_RND) && (pkt_dev->vlan_id != 0xffff)) {
 > -		pkt_dev->vlan_id = pktgen_random() % 4096;
 > +		pkt_dev->vlan_id = random32() & (4096-1);
 >  	}
 >  
 >  	if ((pkt_dev->flags & F_SVID_RND) && (pkt_dev->svlan_id != 0xffff)) {
 > -		pkt_dev->svlan_id = pktgen_random() % 4096;
 > +		pkt_dev->svlan_id = random32() & (4096 - 1);
 >  	}
 >  
 >  	if (pkt_dev->udp_src_min < pkt_dev->udp_src_max) {
 >  		if (pkt_dev->flags & F_UDPSRC_RND)
 > -			pkt_dev->cur_udp_src =
 > -			    ((pktgen_random() %
 > -			      (pkt_dev->udp_src_max - pkt_dev->udp_src_min)) +
 > -			     pkt_dev->udp_src_min);
 > +			pkt_dev->cur_udp_src = random32() %
 > +				(pkt_dev->udp_src_max - pkt_dev->udp_src_min)
 > +				+ pkt_dev->udp_src_min;
 >  
 >  		else {
 >  			pkt_dev->cur_udp_src++;
 > @@ -2184,10 +2172,9 @@
 >  
 >  	if (pkt_dev->udp_dst_min < pkt_dev->udp_dst_max) {
 >  		if (pkt_dev->flags & F_UDPDST_RND) {
 > -			pkt_dev->cur_udp_dst =
 > -			    ((pktgen_random() %
 > -			      (pkt_dev->udp_dst_max - pkt_dev->udp_dst_min)) +
 > -			     pkt_dev->udp_dst_min);
 > +			pkt_dev->cur_udp_dst = random32() %
 > +				(pkt_dev->udp_dst_max - pkt_dev->udp_dst_min)
 > +				+ pkt_dev->udp_dst_min;
 >  		} else {
 >  			pkt_dev->cur_udp_dst++;
 >  			if (pkt_dev->cur_udp_dst >= pkt_dev->udp_dst_max)
 > @@ -2202,7 +2189,7 @@
 >  							       saddr_max))) {
 >  			__u32 t;
 >  			if (pkt_dev->flags & F_IPSRC_RND)
 > -				t = ((pktgen_random() % (imx - imn)) + imn);
 > +				t = random32() % (imx - imn) + imn;
 >  			else {
 >  				t = ntohl(pkt_dev->cur_saddr);
 >  				t++;
 > @@ -2223,14 +2210,13 @@
 >  				__be32 s;
 >  				if (pkt_dev->flags & F_IPDST_RND) {
 >  
 > -					t = pktgen_random() % (imx - imn) + imn;
 > +					t = random32() % (imx - imn) + imn;
 >  					s = htonl(t);
 >  
 >  					while (LOOPBACK(s) || MULTICAST(s)
 >  					       || BADCLASS(s) || ZERONET(s)
 >  					       || LOCAL_MCAST(s)) {
 > -						t = (pktgen_random() %
 > -						      (imx - imn)) + imn;
 > +						t = random32() % (imx - imn) + imn;
 >  						s = htonl(t);
 >  					}
 >  					pkt_dev->cur_daddr = s;
 > @@ -2262,7 +2248,7 @@
 >  
 >  			for (i = 0; i < 4; i++) {
 >  				pkt_dev->cur_in6_daddr.s6_addr32[i] =
 > -				    (((__force __be32)pktgen_random() |
 > +				    (((__force __be32)random32() |
 >  				      pkt_dev->min_in6_daddr.s6_addr32[i]) &
 >  				     pkt_dev->max_in6_daddr.s6_addr32[i]);
 >  			}
 > @@ -2272,9 +2258,9 @@
 >  	if (pkt_dev->min_pkt_size < pkt_dev->max_pkt_size) {
 >  		__u32 t;
 >  		if (pkt_dev->flags & F_TXSIZE_RND) {
 > -			t = ((pktgen_random() %
 > -			      (pkt_dev->max_pkt_size - pkt_dev->min_pkt_size))
 > -			     + pkt_dev->min_pkt_size);
 > +			t = random32() %
 > +				(pkt_dev->max_pkt_size - pkt_dev->min_pkt_size)
 > +				+ pkt_dev->min_pkt_size;
 >  		} else {
 >  			t = pkt_dev->cur_pkt_size + 1;
 >  			if (t > pkt_dev->max_pkt_size)
 > -
 > To unsubscribe from this list: send the line "unsubscribe netdev" in
 > the body of a message to majordomo@...r.kernel.org
 > More majordomo info at  http://vger.kernel.org/majordomo-info.html
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ