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]
Date:	Sun, 20 Apr 2008 22:36:11 -0700
From:	Jason Uhlenkott <juhlenko@...mai.com>
To:	"David S. Miller" <davem@...emloft.net>
Cc:	netdev@...r.kernel.org,
	Stephen Hemminger <shemminger@...ux-foundation.org>
Subject: [RFC 4/4] af_packet: efficient SOCK_TIMESTAMP support

Implement SOCK_TIMESTAMP support for AF_PACKET sockets by recording a
timestamp for each skb which makes it past the filter.

By implementing SOCK_TIMESTAMP at this layer, we avoid the overhead of
recording a timestamp in the net core for every packet before we
know whether the packet will be filtered.

This preserves the existing behavior of recording a timestamp in the
tpacket_hdr of every packet on an mmaped packet socket, regardless of
whether SOCK_TIMESTAMP is set (but at least now we'll always record
timestamps *after* the filter runs).

Signed-off-by: Jason Uhlenkott <juhlenko@...mai.com>


---
 net/packet/af_packet.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Index: linux/net/packet/af_packet.c
===================================================================
--- linux.orig/net/packet/af_packet.c	2008-04-20 21:03:53.000000000 -0700
+++ linux/net/packet/af_packet.c	2008-04-20 21:04:07.000000000 -0700
@@ -484,6 +484,8 @@
 	    (unsigned)sk->sk_rcvbuf)
 		goto drop_n_acct;
 
+	sock_timestamp(sk, skb);
+
 	if (skb_shared(skb)) {
 		struct sk_buff *nskb = skb_clone(skb, GFP_ATOMIC);
 		if (nskb == NULL)
@@ -638,10 +640,9 @@
 	h->tp_snaplen = snaplen;
 	h->tp_mac = macoff;
 	h->tp_net = netoff;
-	if (skb->tstamp.tv64)
-		tv = ktime_to_timeval(skb->tstamp);
-	else
-		do_gettimeofday(&tv);
+	if (!skb->tstamp.tv64)
+		__net_timestamp(skb);
+	tv = ktime_to_timeval(skb->tstamp);
 	h->tp_sec = tv.tv_sec;
 	h->tp_usec = tv.tv_usec;
 
@@ -957,6 +958,7 @@
 	.name	  = "PACKET",
 	.owner	  = THIS_MODULE,
 	.obj_size = sizeof(struct packet_sock),
+	.flags	  = (1 << PROTO_HAS_SOCK_TIMESTAMP),
 };
 
 /*
--
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