netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC][PATCH 0/3] net: per skb control messages
@ 2008-07-23 22:01 Octavian Purdila
  2008-07-23 22:01 ` [RFC][PATCH 1/3] " Octavian Purdila
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Octavian Purdila @ 2008-07-23 22:01 UTC (permalink / raw)
  To: netdev; +Cc: Octavian Purdila

Hi everybody,

These patches are a follow up on two previous [rfc] threads: 
- new sk_buff member: hwstamp [1]
- support for IEEE 1588 [2]

[1] http://www.spinics.net/lists/netdev/msg68804.html
[2] http://www.spinics.net/lists/netdev/msg67799.html

The idea is to associate control messages with skbs - for both 
out-going and in-going traffic. 

The RX case seems pretty straight forward.  

For the TX case, I am queueing an empty (or a clone of the original)
skb (with control messages attached) to the error queue of the socket
the TX skb belongs to.

To make an idea about how would this be used from userspace, I've
added a simple userspace demo for getting TX hardware timestamps.

I still ended up adding a new skb member but since this is a bit more
generic maybe it can offset the cost?

Thanks,
tavi
---
#include <stdlib.h>
#include <string.h>
#include <error.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/poll.h>
#include <sys/uio.h>
#include <netinet/in.h>

typedef unsigned long long __u64;
typedef unsigned long long __u32;

#define SOL_SKB 275

#include "include/linux/skb_cmsg.h"

struct cmsg_tx_tstamp  {
	struct cmsghdr hdr;
	struct skb_tx_tstamp stt __attribute__ ((packed));
};


int main()
{
	char buffer[100];
	struct iovec iovec = {
		.iov_base = buffer,
		.iov_len = sizeof(buffer)
	};
	struct cmsg_tx_tstamp ctt = {
		.hdr = {
			.cmsg_len = sizeof(ctt),
			.cmsg_level = SOL_SKB,
			.cmsg_type = SKB_TX_GET_TSTAMP
		},
		.stt = {
			.cookie = 0x0bad0badbeefbeefULL,
		}
	};
	struct sockaddr_in daddr = {
		.sin_family = AF_INET,
		.sin_port = 8888,
		.sin_addr = { htonl(0x01010101) }
	};
	struct msghdr msg = {
		.msg_iov = &iovec,
		.msg_iovlen = 1,
		.msg_control = &ctt,
		.msg_controllen = sizeof(ctt),
		.msg_name = &daddr,
		.msg_namelen = sizeof(daddr)
	};
	int s=socket(PF_INET, SOCK_DGRAM, 0);
	struct pollfd pollfd = {
		.fd = s,
		.events = POLLERR,
	};

	printf("%d %d %d %llx %llx\n", ctt.hdr.cmsg_len, ctt.hdr.cmsg_level,
	       ctt.hdr.cmsg_type, ctt.stt.cookie, ctt.stt.tstamp);

	if (sendmsg(s, &msg, 0) < 0)
		perror("sendmsg");

	poll(&pollfd, 1, -1);

	if (recvmsg(s, &msg, MSG_ERRQUEUE) < 0)
		perror("recvmsg");

	return printf("%d %d %d %llx %llx\n", ctt.hdr.cmsg_len,
		      ctt.hdr.cmsg_level, ctt.hdr.cmsg_type, ctt.stt.tstamp,
		      ctt.stt.cookie);
}
---

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2008-07-24 23:29 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-23 22:01 [RFC][PATCH 0/3] net: per skb control messages Octavian Purdila
2008-07-23 22:01 ` [RFC][PATCH 1/3] " Octavian Purdila
2008-07-24 12:46   ` Herbert Xu
2008-07-24 13:34     ` Octavian Purdila
2008-07-24 15:01       ` Herbert Xu
2008-07-24 16:22         ` Octavian Purdila
2008-07-24 20:28           ` David Miller
2008-07-24 21:49             ` Octavian Purdila
2008-07-24 21:56               ` David Miller
2008-07-24 21:58                 ` Stephen Hemminger
2008-07-24 22:35                   ` Octavian Purdila
2008-07-24 23:05                     ` Stephen Hemminger
2008-07-24 22:12                 ` Octavian Purdila
2008-07-24 22:17                   ` David Miller
2008-07-24 23:14                     ` Octavian Purdila
2008-07-24 23:18                       ` David Miller
2008-07-24 23:26                         ` Octavian Purdila
2008-07-23 22:01 ` [RFC][PATCH 2/3] ip: support for SOL_SKB control messages for UDP/RAW sockets Octavian Purdila
2008-07-23 22:01 ` [RFC][PATCH 3/3] net: add SKB_SOL control messages Octavian Purdila

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).