let bpf_mtap_hdr take a void * instead of caddr_t for the header

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

let bpf_mtap_hdr take a void * instead of caddr_t for the header

David Gwynne-5
this makes it easier to call at least.

it also brings it in line with bpf_tap_hdr. otherwise there's no
functional change.

ok?

Index: sys/net/bpf.c
===================================================================
RCS file: /cvs/src/sys/net/bpf.c,v
retrieving revision 1.177
diff -u -p -r1.177 bpf.c
--- sys/net/bpf.c 13 Jun 2019 21:14:53 -0000 1.177
+++ sys/net/bpf.c 10 Sep 2019 23:59:14 -0000
@@ -1367,7 +1367,7 @@ bpf_mtap(caddr_t arg, const struct mbuf
  * it or keep a pointer to it.
  */
 int
-bpf_mtap_hdr(caddr_t arg, caddr_t data, u_int dlen, const struct mbuf *m,
+bpf_mtap_hdr(caddr_t arg, const void *data, u_int dlen, const struct mbuf *m,
     u_int direction, void (*cpfn)(const void *, void *, size_t))
 {
  struct m_hdr mh;
@@ -1377,7 +1377,7 @@ bpf_mtap_hdr(caddr_t arg, caddr_t data,
  mh.mh_flags = 0;
  mh.mh_next = (struct mbuf *)m;
  mh.mh_len = dlen;
- mh.mh_data = data;
+ mh.mh_data = (void *)data;
  m0 = (struct mbuf *)&mh;
  } else
  m0 = m;
Index: sys/net/bpf.h
===================================================================
RCS file: /cvs/src/sys/net/bpf.h,v
retrieving revision 1.66
diff -u -p -r1.66 bpf.h
--- sys/net/bpf.h 17 Mar 2019 23:57:12 -0000 1.66
+++ sys/net/bpf.h 10 Sep 2019 23:59:14 -0000
@@ -315,7 +315,7 @@ struct mbuf;
 
 int bpf_validate(struct bpf_insn *, int);
 int bpf_mtap(caddr_t, const struct mbuf *, u_int);
-int bpf_mtap_hdr(caddr_t, caddr_t, u_int, const struct mbuf *, u_int,
+int bpf_mtap_hdr(caddr_t, const void *, u_int, const struct mbuf *, u_int,
     void (*)(const void *, void *, size_t));
 int bpf_mtap_af(caddr_t, u_int32_t, const struct mbuf *, u_int);
 int bpf_mtap_ether(caddr_t, const struct mbuf *, u_int);
Index: share/man/man9/bpf_mtap.9
===================================================================
RCS file: /cvs/src/share/man/man9/bpf_mtap.9,v
retrieving revision 1.14
diff -u -p -r1.14 bpf_mtap.9
--- share/man/man9/bpf_mtap.9 2 Feb 2018 10:52:44 -0000 1.14
+++ share/man/man9/bpf_mtap.9 10 Sep 2019 23:59:14 -0000
@@ -66,7 +66,7 @@
 .Ft int
 .Fo bpf_mtap_hdr
 .Fa "caddr_t bpf"
-.Fa "caddr_t hdr"
+.Fa "const void *hdr"
 .Fa "u_int hdrlen"
 .Fa "const struct mbuf *m"
 .Fa "u_int direction"

Reply | Threaded
Open this post in threaded view
|

Re: let bpf_mtap_hdr take a void * instead of caddr_t for the header

Stefan Sperling-5
On Wed, Sep 11, 2019 at 10:02:24AM +1000, David Gwynne wrote:
> this makes it easier to call at least.
>
> it also brings it in line with bpf_tap_hdr. otherwise there's no
> functional change.
>
> ok?

I don't see why not if this change helps you. I suppose you're going
to be passing in a pointer to a struct of some kind?

OK.

>
> Index: sys/net/bpf.c
> ===================================================================
> RCS file: /cvs/src/sys/net/bpf.c,v
> retrieving revision 1.177
> diff -u -p -r1.177 bpf.c
> --- sys/net/bpf.c 13 Jun 2019 21:14:53 -0000 1.177
> +++ sys/net/bpf.c 10 Sep 2019 23:59:14 -0000
> @@ -1367,7 +1367,7 @@ bpf_mtap(caddr_t arg, const struct mbuf
>   * it or keep a pointer to it.
>   */
>  int
> -bpf_mtap_hdr(caddr_t arg, caddr_t data, u_int dlen, const struct mbuf *m,
> +bpf_mtap_hdr(caddr_t arg, const void *data, u_int dlen, const struct mbuf *m,
>      u_int direction, void (*cpfn)(const void *, void *, size_t))
>  {
>   struct m_hdr mh;
> @@ -1377,7 +1377,7 @@ bpf_mtap_hdr(caddr_t arg, caddr_t data,
>   mh.mh_flags = 0;
>   mh.mh_next = (struct mbuf *)m;
>   mh.mh_len = dlen;
> - mh.mh_data = data;
> + mh.mh_data = (void *)data;
>   m0 = (struct mbuf *)&mh;
>   } else
>   m0 = m;
> Index: sys/net/bpf.h
> ===================================================================
> RCS file: /cvs/src/sys/net/bpf.h,v
> retrieving revision 1.66
> diff -u -p -r1.66 bpf.h
> --- sys/net/bpf.h 17 Mar 2019 23:57:12 -0000 1.66
> +++ sys/net/bpf.h 10 Sep 2019 23:59:14 -0000
> @@ -315,7 +315,7 @@ struct mbuf;
>  
>  int bpf_validate(struct bpf_insn *, int);
>  int bpf_mtap(caddr_t, const struct mbuf *, u_int);
> -int bpf_mtap_hdr(caddr_t, caddr_t, u_int, const struct mbuf *, u_int,
> +int bpf_mtap_hdr(caddr_t, const void *, u_int, const struct mbuf *, u_int,
>      void (*)(const void *, void *, size_t));
>  int bpf_mtap_af(caddr_t, u_int32_t, const struct mbuf *, u_int);
>  int bpf_mtap_ether(caddr_t, const struct mbuf *, u_int);
> Index: share/man/man9/bpf_mtap.9
> ===================================================================
> RCS file: /cvs/src/share/man/man9/bpf_mtap.9,v
> retrieving revision 1.14
> diff -u -p -r1.14 bpf_mtap.9
> --- share/man/man9/bpf_mtap.9 2 Feb 2018 10:52:44 -0000 1.14
> +++ share/man/man9/bpf_mtap.9 10 Sep 2019 23:59:14 -0000
> @@ -66,7 +66,7 @@
>  .Ft int
>  .Fo bpf_mtap_hdr
>  .Fa "caddr_t bpf"
> -.Fa "caddr_t hdr"
> +.Fa "const void *hdr"
>  .Fa "u_int hdrlen"
>  .Fa "const struct mbuf *m"
>  .Fa "u_int direction"
>

Reply | Threaded
Open this post in threaded view
|

Re: let bpf_mtap_hdr take a void * instead of caddr_t for the header

Alexandr Nedvedicky
In reply to this post by David Gwynne-5
On Wed, Sep 11, 2019 at 10:02:24AM +1000, David Gwynne wrote:
> this makes it easier to call at least.
>
> it also brings it in line with bpf_tap_hdr. otherwise there's no
> functional change.
>
> ok?

    OK sashan@, consistency never hurts.

sashan

Reply | Threaded
Open this post in threaded view
|

Re: let bpf_mtap_hdr take a void * instead of caddr_t for the header

Christian Weisgerber
In reply to this post by David Gwynne-5
David Gwynne:

> this makes it easier to call at least.
>
> it also brings it in line with bpf_tap_hdr. otherwise there's no
> functional change.

And remove the casts in the two calls to bpf_mtap_hdr() a few lines
further down?

--
Christian "naddy" Weisgerber                          [hidden email]