Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/rump/net/rumptest In case opening /dev/bpf fails, try to...
details: https://anonhg.NetBSD.org/src/rev/3b8113bf8553
branches: trunk
changeset: 751140:3b8113bf8553
user: pooka <pooka%NetBSD.org@localhost>
date: Mon Jan 25 22:25:38 2010 +0000
description:
In case opening /dev/bpf fails, try to load bpf kmod and try again.
diffstat:
sys/rump/net/rumptest/rumptest_net.c | 34 ++++++++++++++++++++++++++++++----
1 files changed, 30 insertions(+), 4 deletions(-)
diffs (58 lines):
diff -r 8913958312d3 -r 3b8113bf8553 sys/rump/net/rumptest/rumptest_net.c
--- a/sys/rump/net/rumptest/rumptest_net.c Mon Jan 25 22:21:28 2010 +0000
+++ b/sys/rump/net/rumptest/rumptest_net.c Mon Jan 25 22:25:38 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumptest_net.c,v 1.15 2010/01/19 17:51:03 pooka Exp $ */
+/* $NetBSD: rumptest_net.c,v 1.16 2010/01/25 22:25:38 pooka Exp $ */
/*
* Copyright (c) 2008 Antti Kantee. All Rights Reserved.
@@ -29,6 +29,7 @@
*/
#include <sys/param.h>
+#include <sys/module.h>
#include <sys/mbuf.h>
#include <sys/time.h>
#include <sys/sockio.h>
@@ -189,12 +190,37 @@
struct bpf_hdr *bhdr;
void *buf;
struct ifreq ifr;
- int bpfd;
+ int bpfd, modfd;
u_int bpflen, x;
bpfd = rump_sys_open("/dev/bpf", O_RDWR);
- if (bpfd == -1)
- err(1, "bpf open");
+
+ /* fail? try to load kernel module */
+ if (bpfd == -1) {
+ modctl_load_t ml;
+
+ /* XXX: struct stat size */
+ modfd = open("./bpf.kmod", O_RDONLY);
+ if (modfd == -1)
+ err(1, "no bpf, no bpf kmod");
+ close(modfd);
+
+ rump_pub_etfs_register("/bpf.kmod",
+ "./bpf.kmod", RUMP_ETFS_REG);
+ ml.ml_filename = "/bpf.kmod";
+ ml.ml_flags = 0;
+ ml.ml_props = NULL;
+ ml.ml_propslen = 0;
+
+ if (rump_sys_modctl(MODCTL_LOAD, &ml) == -1)
+ err(1, "load bpf module");
+ /* XXX: I "know" it's 256 XXX */
+ rump_sys_mknod("/dev/bpf", 0777 | S_IFCHR, makedev(256,0));
+
+ bpfd = rump_sys_open("/dev/bpf", O_RDWR);
+ if (bpfd == -1)
+ err(1, "open bpf");
+ }
if (rump_sys_ioctl(bpfd, BIOCGBLEN, &bpflen) == -1)
err(1, "BIOCGBLEN");
Home |
Main Index |
Thread Index |
Old Index