From: "Serge Vakulenko" <vak@cronyx.ru>
To: <alan@cymru.net>
Cc: <linux-kernel@vger.kernel.org>
Subject: [patch] added SIGIO support for /dev/tap0 and other netlink-based drivers
Date: Fri, 1 Mar 2002 22:10:22 +0300 [thread overview]
Message-ID: <007501c1c154$bca973c0$48b5ce90@crox> (raw)
[-- Attachment #1: Type: text/plain, Size: 208 bytes --]
Dear Alan,
I added fasync support to netlink_dev.c.
It permits signal-based i/o on /dev/tap0 and other
netlink-based devices.
The sources of small testing program included.
___
Best wishes,
Serge Vakulenko
[-- Attachment #2: netlnk_dev.pch --]
[-- Type: application/octet-stream, Size: 2111 bytes --]
Adding SIGIO support for /dev/tapX and other netlink-based drivers.
Use the following program to test it:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#define __USE_GNU
#include <fcntl.h>
#define DEVNAME "/dev/tap0"
#define SIGNUM SIGIO
void sigio (int signum)
{
printf ("Got signal %d\n", signum);
fflush (stdout);
}
int main (int argc, char **argv)
{
int fd, flags;
fd = open (DEVNAME, O_RDWR);
if (fd < 0) {
perror (DEVNAME);
exit (1);
}
signal (SIGNUM, sigio);
fcntl (fd, F_SETOWN, getpid());
fcntl (fd, F_SETSIG, SIGNUM);
flags = fcntl (fd, F_GETFL, 0);
fcntl (fd, F_SETFL, flags | O_ASYNC);
printf ("Waiting for i/o signal.\n");
printf ("Ping /dev/tap0 interface.\n");
for (;;)
pause ();
}
___
Best wishes,
Serge Vakulenko <vak@cronyx.ru>
--- /usr/src/linux-2.2.5/net/netlink/netlink_dev.c Fri Aug 28 06:33:09 1998
+++ netlink_dev.c Fri Mar 1 21:20:17 2002
@@ -25,6 +25,7 @@
#include <linux/netlink.h>
#include <linux/poll.h>
#include <linux/init.h>
+#include <net/sock.h>
#include <asm/system.h>
#include <asm/uaccess.h>
@@ -148,11 +149,27 @@
return err;
}
+static int netlink_fasync(int fd, struct file *filp, int on)
+{
+ struct inode *inode = filp->f_dentry->d_inode;
+ struct socket *sock = netlink_user[MINOR(inode->i_rdev)];
+ int retval;
+
+ lock_sock(sock->sk);
+ retval = fasync_helper(fd, filp, on, &sock->fasync_list);
+ release_sock(sock->sk);
+
+ if (retval <= 0)
+ return retval;
+ return 0;
+}
+
static int netlink_release(struct inode * inode, struct file * file)
{
unsigned int minor = MINOR(inode->i_rdev);
struct socket *sock = netlink_user[minor];
+ netlink_fasync(-1, file, 0);
netlink_user[minor] = NULL;
open_map &= ~(1<<minor);
sock_release(sock);
@@ -187,7 +204,9 @@
NULL, /* netlink_mmap */
netlink_open,
NULL, /* flush */
- netlink_release
+ netlink_release,
+ NULL, /* no fsync */
+ netlink_fasync
};
__initfunc(int init_netlink(void))
next reply other threads:[~2002-03-01 19:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-03-01 19:10 Serge Vakulenko [this message]
2002-03-05 12:53 ` [patch] added SIGIO support for /dev/tap0 and other netlink-based drivers David S. Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='007501c1c154$bca973c0$48b5ce90@crox' \
--to=vak@cronyx.ru \
--cc=alan@cymru.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox