Module Name:    src
Committed By:   matt
Date:           Fri Sep  5 09:22:22 UTC 2014

Modified Files:
        src/sys/net: bpf.c if_gre.c if_tap.c

Log Message:
Try not to use f_data, use f_{vnode,socket,pipe,mqueue,kqueue,ksem} to get
a correctly typed pointer.


To generate a diff of this commit:
cvs rdiff -u -r1.187 -r1.188 src/sys/net/bpf.c
cvs rdiff -u -r1.160 -r1.161 src/sys/net/if_gre.c
cvs rdiff -u -r1.77 -r1.78 src/sys/net/if_tap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/bpf.c
diff -u src/sys/net/bpf.c:1.187 src/sys/net/bpf.c:1.188
--- src/sys/net/bpf.c:1.187	Thu Aug  7 03:40:21 2014
+++ src/sys/net/bpf.c	Fri Sep  5 09:22:22 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpf.c,v 1.187 2014/08/07 03:40:21 ozaki-r Exp $	*/
+/*	$NetBSD: bpf.c,v 1.188 2014/09/05 09:22:22 matt Exp $	*/
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.187 2014/08/07 03:40:21 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.188 2014/09/05 09:22:22 matt Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_bpf.h"
@@ -472,7 +472,7 @@ bpfopen(dev_t dev, int flag, int mode, s
 static int
 bpf_close(struct file *fp)
 {
-	struct bpf_d *d = fp->f_data;
+	struct bpf_d *d = fp->f_bpf;
 	int s;
 
 	KERNEL_LOCK(1, NULL);
@@ -497,7 +497,7 @@ bpf_close(struct file *fp)
 	seldestroy(&d->bd_sel);
 	softint_disestablish(d->bd_sih);
 	free(d, M_DEVBUF);
-	fp->f_data = NULL;
+	fp->f_bpf = NULL;
 
 	KERNEL_UNLOCK_ONE(NULL);
 
@@ -522,7 +522,7 @@ static int
 bpf_read(struct file *fp, off_t *offp, struct uio *uio,
     kauth_cred_t cred, int flags)
 {
-	struct bpf_d *d = fp->f_data;
+	struct bpf_d *d = fp->f_bpf;
 	int timed_out;
 	int error;
 	int s;
@@ -663,7 +663,7 @@ static int
 bpf_write(struct file *fp, off_t *offp, struct uio *uio,
     kauth_cred_t cred, int flags)
 {
-	struct bpf_d *d = fp->f_data;
+	struct bpf_d *d = fp->f_bpf;
 	struct ifnet *ifp;
 	struct mbuf *m, *mc;
 	int error, s;
@@ -772,7 +772,7 @@ reset_d(struct bpf_d *d)
 static int
 bpf_ioctl(struct file *fp, u_long cmd, void *addr)
 {
-	struct bpf_d *d = fp->f_data;
+	struct bpf_d *d = fp->f_bpf;
 	int s, error = 0;
 
 	/*
@@ -1228,7 +1228,7 @@ bpf_ifname(struct ifnet *ifp, struct ifr
 static int
 bpf_stat(struct file *fp, struct stat *st)
 {
-	struct bpf_d *d = fp->f_data;
+	struct bpf_d *d = fp->f_bpf;
 
 	(void)memset(st, 0, sizeof(*st));
 	KERNEL_LOCK(1, NULL);
@@ -1254,7 +1254,7 @@ bpf_stat(struct file *fp, struct stat *s
 static int
 bpf_poll(struct file *fp, int events)
 {
-	struct bpf_d *d = fp->f_data;
+	struct bpf_d *d = fp->f_bpf;
 	int s = splnet();
 	int revents;
 
@@ -1323,7 +1323,7 @@ static const struct filterops bpfread_fi
 static int
 bpf_kqfilter(struct file *fp, struct knote *kn)
 {
-	struct bpf_d *d = fp->f_data;
+	struct bpf_d *d = fp->f_bpf;
 	struct klist *klist;
 	int s;
 

Index: src/sys/net/if_gre.c
diff -u src/sys/net/if_gre.c:1.160 src/sys/net/if_gre.c:1.161
--- src/sys/net/if_gre.c:1.160	Mon Aug 18 04:28:55 2014
+++ src/sys/net/if_gre.c	Fri Sep  5 09:22:22 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_gre.c,v 1.160 2014/08/18 04:28:55 riastradh Exp $ */
+/*	$NetBSD: if_gre.c,v 1.161 2014/09/05 09:22:22 matt Exp $ */
 
 /*
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -45,7 +45,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.160 2014/08/18 04:28:55 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.161 2014/09/05 09:22:22 matt Exp $");
 
 #include "opt_atalk.h"
 #include "opt_gre.h"
@@ -1102,7 +1102,7 @@ gre_ssock(struct ifnet *ifp, struct gre_
 
 	GRE_DPRINTF(sc, "\n");
 
-	so = (struct socket *)fp->f_data;
+	so = fp->f_socket;
 	pr = so->so_proto;
 
 	GRE_DPRINTF(sc, "type %d, proto %d\n", pr->pr_type, pr->pr_protocol);

Index: src/sys/net/if_tap.c
diff -u src/sys/net/if_tap.c:1.77 src/sys/net/if_tap.c:1.78
--- src/sys/net/if_tap.c:1.77	Fri Jul 25 08:10:40 2014
+++ src/sys/net/if_tap.c	Fri Sep  5 09:22:22 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_tap.c,v 1.77 2014/07/25 08:10:40 dholland Exp $	*/
+/*	$NetBSD: if_tap.c,v 1.78 2014/09/05 09:22:22 matt Exp $	*/
 
 /*
  *  Copyright (c) 2003, 2004, 2008, 2009 The NetBSD Foundation.
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.77 2014/07/25 08:10:40 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.78 2014/09/05 09:22:22 matt Exp $");
 
 #if defined(_KERNEL_OPT)
 
@@ -739,7 +739,7 @@ tap_cdev_open(dev_t dev, int flags, int 
  *
  * Once those two steps are successful, we can re-wire the existing file
  * descriptor to its new self.  This is done with fdclone():  it fills the fp
- * structure as needed (notably f_data gets filled with the fifth parameter
+ * structure as needed (notably f_devunit gets filled with the fifth parameter
  * passed, the unit of the tap device which will allows us identifying the
  * device later), and returns EMOVEFD.
  *
@@ -805,7 +805,7 @@ tap_cdev_close(dev_t dev, int flags, int
 static int
 tap_fops_close(file_t *fp)
 {
-	int unit = (intptr_t)fp->f_data;
+	int unit = fp->f_devunit;
 	struct tap_softc *sc;
 	int error;
 
@@ -882,7 +882,7 @@ tap_fops_read(file_t *fp, off_t *offp, s
 	int error;
 
 	KERNEL_LOCK(1, NULL);
-	error = tap_dev_read((intptr_t)fp->f_data, uio, flags);
+	error = tap_dev_read(fp->f_devunit, uio, flags);
 	KERNEL_UNLOCK_ONE(NULL);
 	return error;
 }
@@ -890,8 +890,7 @@ tap_fops_read(file_t *fp, off_t *offp, s
 static int
 tap_dev_read(int unit, struct uio *uio, int flags)
 {
-	struct tap_softc *sc =
-	    device_lookup_private(&tap_cd, unit);
+	struct tap_softc *sc = device_lookup_private(&tap_cd, unit);
 	struct ifnet *ifp;
 	struct mbuf *m, *n;
 	int error = 0, s;
@@ -977,7 +976,7 @@ tap_fops_stat(file_t *fp, struct stat *s
 {
 	int error = 0;
 	struct tap_softc *sc;
-	int unit = (uintptr_t)fp->f_data;
+	int unit = fp->f_devunit;
 
 	(void)memset(st, 0, sizeof(*st));
 
@@ -1012,7 +1011,7 @@ tap_fops_write(file_t *fp, off_t *offp, 
 	int error;
 
 	KERNEL_LOCK(1, NULL);
-	error = tap_dev_write((intptr_t)fp->f_data, uio, flags);
+	error = tap_dev_write(fp->f_devunit, uio, flags);
 	KERNEL_UNLOCK_ONE(NULL);
 	return error;
 }
@@ -1081,7 +1080,7 @@ tap_cdev_ioctl(dev_t dev, u_long cmd, vo
 static int
 tap_fops_ioctl(file_t *fp, u_long cmd, void *data)
 {
-	return tap_dev_ioctl((intptr_t)fp->f_data, cmd, data, curlwp);
+	return tap_dev_ioctl(fp->f_devunit, cmd, data, curlwp);
 }
 
 static int
@@ -1163,7 +1162,7 @@ tap_cdev_poll(dev_t dev, int events, str
 static int
 tap_fops_poll(file_t *fp, int events)
 {
-	return tap_dev_poll((intptr_t)fp->f_data, events, curlwp);
+	return tap_dev_poll(fp->f_devunit, events, curlwp);
 }
 
 static int
@@ -1212,7 +1211,7 @@ tap_cdev_kqfilter(dev_t dev, struct knot
 static int
 tap_fops_kqfilter(file_t *fp, struct knote *kn)
 {
-	return tap_dev_kqfilter((intptr_t)fp->f_data, kn);
+	return tap_dev_kqfilter(fp->f_devunit, kn);
 }
 
 static int

Reply via email to