Use bpf_ops for bpf_mtap_softint By doing so we don't need to care whether a kernel enables bpfilter or not.diff -r1.205 -r1.206 src/sys/net/bpf.c
(ozaki-r)
--- src/sys/net/bpf.c 2017/01/24 09:05:28 1.205
+++ src/sys/net/bpf.c 2017/01/25 01:04:23 1.206
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: bpf.c,v 1.205 2017/01/24 09:05:28 ozaki-r Exp $ */ | 1 | /* $NetBSD: bpf.c,v 1.206 2017/01/25 01:04:23 ozaki-r Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1990, 1991, 1993 | 4 | * Copyright (c) 1990, 1991, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from the Stanford/CMU enet packet filter, | 7 | * This code is derived from the Stanford/CMU enet packet filter, | |
8 | * (net/enet.c) distributed as part of 4.3BSD, and code contributed | 8 | * (net/enet.c) distributed as part of 4.3BSD, and code contributed | |
9 | * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence | 9 | * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence | |
10 | * Berkeley Laboratory. | 10 | * Berkeley Laboratory. | |
11 | * | 11 | * | |
12 | * Redistribution and use in source and binary forms, with or without | 12 | * Redistribution and use in source and binary forms, with or without | |
13 | * modification, are permitted provided that the following conditions | 13 | * modification, are permitted provided that the following conditions | |
14 | * are met: | 14 | * are met: | |
@@ -29,27 +29,27 @@ | @@ -29,27 +29,27 @@ | |||
29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
34 | * SUCH DAMAGE. | 34 | * SUCH DAMAGE. | |
35 | * | 35 | * | |
36 | * @(#)bpf.c 8.4 (Berkeley) 1/9/95 | 36 | * @(#)bpf.c 8.4 (Berkeley) 1/9/95 | |
37 | * static char rcsid[] = | 37 | * static char rcsid[] = | |
38 | * "Header: bpf.c,v 1.67 96/09/26 22:00:52 leres Exp "; | 38 | * "Header: bpf.c,v 1.67 96/09/26 22:00:52 leres Exp "; | |
39 | */ | 39 | */ | |
40 | 40 | |||
41 | #include <sys/cdefs.h> | 41 | #include <sys/cdefs.h> | |
42 | __KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.205 2017/01/24 09:05:28 ozaki-r Exp $"); | 42 | __KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.206 2017/01/25 01:04:23 ozaki-r Exp $"); | |
43 | 43 | |||
44 | #if defined(_KERNEL_OPT) | 44 | #if defined(_KERNEL_OPT) | |
45 | #include "opt_bpf.h" | 45 | #include "opt_bpf.h" | |
46 | #include "sl.h" | 46 | #include "sl.h" | |
47 | #include "strip.h" | 47 | #include "strip.h" | |
48 | #include "opt_net_mpsafe.h" | 48 | #include "opt_net_mpsafe.h" | |
49 | #endif | 49 | #endif | |
50 | 50 | |||
51 | #include <sys/param.h> | 51 | #include <sys/param.h> | |
52 | #include <sys/systm.h> | 52 | #include <sys/systm.h> | |
53 | #include <sys/mbuf.h> | 53 | #include <sys/mbuf.h> | |
54 | #include <sys/buf.h> | 54 | #include <sys/buf.h> | |
55 | #include <sys/time.h> | 55 | #include <sys/time.h> | |
@@ -1656,35 +1656,36 @@ bpf_mtap_si(void *arg) | @@ -1656,35 +1656,36 @@ bpf_mtap_si(void *arg) | |||
1656 | __func__, m, bp->bif_ifp->if_xname); | 1656 | __func__, m, bp->bif_ifp->if_xname); | |
1657 | #endif | 1657 | #endif | |
1658 | #ifndef NET_MPSAFE | 1658 | #ifndef NET_MPSAFE | |
1659 | KERNEL_LOCK(1, NULL); | 1659 | KERNEL_LOCK(1, NULL); | |
1660 | #endif | 1660 | #endif | |
1661 | bpf_ops->bpf_mtap(bp, m); | 1661 | bpf_ops->bpf_mtap(bp, m); | |
1662 | #ifndef NET_MPSAFE | 1662 | #ifndef NET_MPSAFE | |
1663 | KERNEL_UNLOCK_ONE(NULL); | 1663 | KERNEL_UNLOCK_ONE(NULL); | |
1664 | #endif | 1664 | #endif | |
1665 | m_freem(m); | 1665 | m_freem(m); | |
1666 | } | 1666 | } | |
1667 | } | 1667 | } | |
1668 | 1668 | |||
1669 | void | 1669 | static void | |
1670 | bpf_mtap_softint(struct ifnet *ifp, struct mbuf *m) | 1670 | _bpf_mtap_softint(struct ifnet *ifp, struct mbuf *m) | |
1671 | { | 1671 | { | |
1672 | struct bpf_if *bp = ifp->if_bpf; | 1672 | struct bpf_if *bp = ifp->if_bpf; | |
1673 | struct mbuf *dup; | 1673 | struct mbuf *dup; | |
1674 | 1674 | |||
1675 | KASSERT(cpu_intr_p()); | 1675 | KASSERT(cpu_intr_p()); | |
1676 | 1676 | |||
1677 | if (bp == NULL || bp->bif_dlist == NULL) | 1677 | /* To avoid extra invocations of the softint */ | |
1678 | if (bp->bif_dlist == NULL) | |||
1678 | return; | 1679 | return; | |
1679 | KASSERT(bp->bif_si != NULL); | 1680 | KASSERT(bp->bif_si != NULL); | |
1680 | 1681 | |||
1681 | dup = bpf_mbuf_enqueue(bp, m); | 1682 | dup = bpf_mbuf_enqueue(bp, m); | |
1682 | if (dup != NULL) | 1683 | if (dup != NULL) | |
1683 | softint_schedule(bp->bif_si); | 1684 | softint_schedule(bp->bif_si); | |
1684 | } | 1685 | } | |
1685 | 1686 | |||
1686 | static int | 1687 | static int | |
1687 | bpf_hdrlen(struct bpf_d *d) | 1688 | bpf_hdrlen(struct bpf_d *d) | |
1688 | { | 1689 | { | |
1689 | int hdrlen = d->bd_bif->bif_hdrlen; | 1690 | int hdrlen = d->bd_bif->bif_hdrlen; | |
1690 | /* | 1691 | /* | |
@@ -1883,28 +1884,28 @@ _bpfattach(struct ifnet *ifp, u_int dlt, | @@ -1883,28 +1884,28 @@ _bpfattach(struct ifnet *ifp, u_int dlt, | |||
1883 | 1884 | |||
1884 | bp->bif_next = bpf_iflist; | 1885 | bp->bif_next = bpf_iflist; | |
1885 | bpf_iflist = bp; | 1886 | bpf_iflist = bp; | |
1886 | 1887 | |||
1887 | *bp->bif_driverp = NULL; | 1888 | *bp->bif_driverp = NULL; | |
1888 | 1889 | |||
1889 | bp->bif_hdrlen = hdrlen; | 1890 | bp->bif_hdrlen = hdrlen; | |
1890 | mutex_exit(&bpf_mtx); | 1891 | mutex_exit(&bpf_mtx); | |
1891 | #if 0 | 1892 | #if 0 | |
1892 | printf("bpf: %s attached\n", ifp->if_xname); | 1893 | printf("bpf: %s attached\n", ifp->if_xname); | |
1893 | #endif | 1894 | #endif | |
1894 | } | 1895 | } | |
1895 | 1896 | |||
1896 | void | 1897 | static void | |
1897 | bpf_mtap_softint_init(struct ifnet *ifp) | 1898 | _bpf_mtap_softint_init(struct ifnet *ifp) | |
1898 | { | 1899 | { | |
1899 | struct bpf_if *bp; | 1900 | struct bpf_if *bp; | |
1900 | 1901 | |||
1901 | mutex_enter(&bpf_mtx); | 1902 | mutex_enter(&bpf_mtx); | |
1902 | for (bp = bpf_iflist; bp != NULL; bp = bp->bif_next) { | 1903 | for (bp = bpf_iflist; bp != NULL; bp = bp->bif_next) { | |
1903 | if (bp->bif_ifp != ifp) | 1904 | if (bp->bif_ifp != ifp) | |
1904 | continue; | 1905 | continue; | |
1905 | 1906 | |||
1906 | bp->bif_mbuf_head = NULL; | 1907 | bp->bif_mbuf_head = NULL; | |
1907 | bp->bif_mbuf_tail = NULL; | 1908 | bp->bif_mbuf_tail = NULL; | |
1908 | bp->bif_si = softint_establish(SOFTINT_NET, bpf_mtap_si, bp); | 1909 | bp->bif_si = softint_establish(SOFTINT_NET, bpf_mtap_si, bp); | |
1909 | if (bp->bif_si == NULL) | 1910 | if (bp->bif_si == NULL) | |
1910 | panic("%s: softint_establish() failed", __func__); | 1911 | panic("%s: softint_establish() failed", __func__); | |
@@ -2217,26 +2218,29 @@ sysctl_net_bpf_setup(void) | @@ -2217,26 +2218,29 @@ sysctl_net_bpf_setup(void) | |||
2217 | } | 2218 | } | |
2218 | 2219 | |||
2219 | struct bpf_ops bpf_ops_kernel = { | 2220 | struct bpf_ops bpf_ops_kernel = { | |
2220 | .bpf_attach = _bpfattach, | 2221 | .bpf_attach = _bpfattach, | |
2221 | .bpf_detach = _bpfdetach, | 2222 | .bpf_detach = _bpfdetach, | |
2222 | .bpf_change_type = _bpf_change_type, | 2223 | .bpf_change_type = _bpf_change_type, | |
2223 | 2224 | |||
2224 | .bpf_tap = _bpf_tap, | 2225 | .bpf_tap = _bpf_tap, | |
2225 | .bpf_mtap = _bpf_mtap, | 2226 | .bpf_mtap = _bpf_mtap, | |
2226 | .bpf_mtap2 = _bpf_mtap2, | 2227 | .bpf_mtap2 = _bpf_mtap2, | |
2227 | .bpf_mtap_af = _bpf_mtap_af, | 2228 | .bpf_mtap_af = _bpf_mtap_af, | |
2228 | .bpf_mtap_sl_in = _bpf_mtap_sl_in, | 2229 | .bpf_mtap_sl_in = _bpf_mtap_sl_in, | |
2229 | .bpf_mtap_sl_out = _bpf_mtap_sl_out, | 2230 | .bpf_mtap_sl_out = _bpf_mtap_sl_out, | |
2231 | ||||
2232 | .bpf_mtap_softint = _bpf_mtap_softint, | |||
2233 | .bpf_mtap_softint_init = _bpf_mtap_softint_init, | |||
2230 | }; | 2234 | }; | |
2231 | 2235 | |||
2232 | MODULE(MODULE_CLASS_DRIVER, bpf, "bpf_filter"); | 2236 | MODULE(MODULE_CLASS_DRIVER, bpf, "bpf_filter"); | |
2233 | 2237 | |||
2234 | static int | 2238 | static int | |
2235 | bpf_modcmd(modcmd_t cmd, void *arg) | 2239 | bpf_modcmd(modcmd_t cmd, void *arg) | |
2236 | { | 2240 | { | |
2237 | #ifdef _MODULE | 2241 | #ifdef _MODULE | |
2238 | devmajor_t bmajor, cmajor; | 2242 | devmajor_t bmajor, cmajor; | |
2239 | #endif | 2243 | #endif | |
2240 | int error = 0; | 2244 | int error = 0; | |
2241 | 2245 | |||
2242 | switch (cmd) { | 2246 | switch (cmd) { |
--- src/sys/net/bpf.h 2017/01/24 09:05:28 1.68
+++ src/sys/net/bpf.h 2017/01/25 01:04:23 1.69
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: bpf.h,v 1.68 2017/01/24 09:05:28 ozaki-r Exp $ */ | 1 | /* $NetBSD: bpf.h,v 1.69 2017/01/25 01:04:23 ozaki-r Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1990, 1991, 1993 | 4 | * Copyright (c) 1990, 1991, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from the Stanford/CMU enet packet filter, | 7 | * This code is derived from the Stanford/CMU enet packet filter, | |
8 | * (net/enet.c) distributed as part of 4.3BSD, and code contributed | 8 | * (net/enet.c) distributed as part of 4.3BSD, and code contributed | |
9 | * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence | 9 | * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence | |
10 | * Berkeley Laboratory. | 10 | * Berkeley Laboratory. | |
11 | * | 11 | * | |
12 | * Redistribution and use in source and binary forms, with or without | 12 | * Redistribution and use in source and binary forms, with or without | |
13 | * modification, are permitted provided that the following conditions | 13 | * modification, are permitted provided that the following conditions | |
14 | * are met: | 14 | * are met: | |
@@ -413,26 +413,29 @@ struct bpf_ctx { | @@ -413,26 +413,29 @@ struct bpf_ctx { | |||
413 | struct bpf_if; | 413 | struct bpf_if; | |
414 | 414 | |||
415 | struct bpf_ops { | 415 | struct bpf_ops { | |
416 | void (*bpf_attach)(struct ifnet *, u_int, u_int, struct bpf_if **); | 416 | void (*bpf_attach)(struct ifnet *, u_int, u_int, struct bpf_if **); | |
417 | void (*bpf_detach)(struct ifnet *); | 417 | void (*bpf_detach)(struct ifnet *); | |
418 | void (*bpf_change_type)(struct ifnet *, u_int, u_int); | 418 | void (*bpf_change_type)(struct ifnet *, u_int, u_int); | |
419 | 419 | |||
420 | void (*bpf_tap)(struct bpf_if *, u_char *, u_int); | 420 | void (*bpf_tap)(struct bpf_if *, u_char *, u_int); | |
421 | void (*bpf_mtap)(struct bpf_if *, struct mbuf *); | 421 | void (*bpf_mtap)(struct bpf_if *, struct mbuf *); | |
422 | void (*bpf_mtap2)(struct bpf_if *, void *, u_int, struct mbuf *); | 422 | void (*bpf_mtap2)(struct bpf_if *, void *, u_int, struct mbuf *); | |
423 | void (*bpf_mtap_af)(struct bpf_if *, uint32_t, struct mbuf *); | 423 | void (*bpf_mtap_af)(struct bpf_if *, uint32_t, struct mbuf *); | |
424 | void (*bpf_mtap_sl_in)(struct bpf_if *, u_char *, struct mbuf **); | 424 | void (*bpf_mtap_sl_in)(struct bpf_if *, u_char *, struct mbuf **); | |
425 | void (*bpf_mtap_sl_out)(struct bpf_if *, u_char *, struct mbuf *); | 425 | void (*bpf_mtap_sl_out)(struct bpf_if *, u_char *, struct mbuf *); | |
426 | ||||
427 | void (*bpf_mtap_softint_init)(struct ifnet *); | |||
428 | void (*bpf_mtap_softint)(struct ifnet *, struct mbuf *); | |||
426 | }; | 429 | }; | |
427 | 430 | |||
428 | extern struct bpf_ops *bpf_ops; | 431 | extern struct bpf_ops *bpf_ops; | |
429 | 432 | |||
430 | static inline void | 433 | static inline void | |
431 | bpf_attach(struct ifnet *_ifp, u_int _dlt, u_int _hdrlen) | 434 | bpf_attach(struct ifnet *_ifp, u_int _dlt, u_int _hdrlen) | |
432 | { | 435 | { | |
433 | bpf_ops->bpf_attach(_ifp, _dlt, _hdrlen, &_ifp->if_bpf); | 436 | bpf_ops->bpf_attach(_ifp, _dlt, _hdrlen, &_ifp->if_bpf); | |
434 | } | 437 | } | |
435 | 438 | |||
436 | static inline void | 439 | static inline void | |
437 | bpf_attach2(struct ifnet *_ifp, u_int _dlt, u_int _hdrlen, struct bpf_if **_dp) | 440 | bpf_attach2(struct ifnet *_ifp, u_int _dlt, u_int _hdrlen, struct bpf_if **_dp) | |
438 | { | 441 | { | |
@@ -488,43 +491,54 @@ bpf_detach(struct ifnet *_ifp) | @@ -488,43 +491,54 @@ bpf_detach(struct ifnet *_ifp) | |||
488 | static inline void | 491 | static inline void | |
489 | bpf_mtap_sl_in(struct ifnet *_ifp, u_char *_hdr, struct mbuf **_m) | 492 | bpf_mtap_sl_in(struct ifnet *_ifp, u_char *_hdr, struct mbuf **_m) | |
490 | { | 493 | { | |
491 | bpf_ops->bpf_mtap_sl_in(_ifp->if_bpf, _hdr, _m); | 494 | bpf_ops->bpf_mtap_sl_in(_ifp->if_bpf, _hdr, _m); | |
492 | } | 495 | } | |
493 | 496 | |||
494 | static inline void | 497 | static inline void | |
495 | bpf_mtap_sl_out(struct ifnet *_ifp, u_char *_hdr, struct mbuf *_m) | 498 | bpf_mtap_sl_out(struct ifnet *_ifp, u_char *_hdr, struct mbuf *_m) | |
496 | { | 499 | { | |
497 | if (_ifp->if_bpf) | 500 | if (_ifp->if_bpf) | |
498 | bpf_ops->bpf_mtap_sl_out(_ifp->if_bpf, _hdr, _m); | 501 | bpf_ops->bpf_mtap_sl_out(_ifp->if_bpf, _hdr, _m); | |
499 | } | 502 | } | |
500 | 503 | |||
504 | static inline void | |||
505 | bpf_mtap_softint_init(struct ifnet *_ifp) | |||
506 | { | |||
507 | ||||
508 | bpf_ops->bpf_mtap_softint_init(_ifp); | |||
509 | } | |||
510 | ||||
511 | static inline void | |||
512 | bpf_mtap_softint(struct ifnet *_ifp, struct mbuf *_m) | |||
513 | { | |||
514 | ||||
515 | if (_ifp->if_bpf) | |||
516 | bpf_ops->bpf_mtap_softint(_ifp, _m); | |||
517 | } | |||
501 | 518 | |||
502 | void bpf_setops(void); | 519 | void bpf_setops(void); | |
503 | 520 | |||
504 | void bpf_ops_handover_enter(struct bpf_ops *); | 521 | void bpf_ops_handover_enter(struct bpf_ops *); | |
505 | void bpf_ops_handover_exit(void); | 522 | void bpf_ops_handover_exit(void); | |
506 | 523 | |||
507 | void bpfilterattach(int); | 524 | void bpfilterattach(int); | |
508 | 525 | |||
509 | bpf_ctx_t *bpf_create(void); | 526 | bpf_ctx_t *bpf_create(void); | |
510 | void bpf_destroy(bpf_ctx_t *); | 527 | void bpf_destroy(bpf_ctx_t *); | |
511 | 528 | |||
512 | int bpf_set_cop(bpf_ctx_t *, const bpf_copfunc_t *, size_t); | 529 | int bpf_set_cop(bpf_ctx_t *, const bpf_copfunc_t *, size_t); | |
513 | int bpf_set_extmem(bpf_ctx_t *, size_t, bpf_memword_init_t); | 530 | int bpf_set_extmem(bpf_ctx_t *, size_t, bpf_memword_init_t); | |
514 | u_int bpf_filter_ext(const bpf_ctx_t *, const struct bpf_insn *, bpf_args_t *); | 531 | u_int bpf_filter_ext(const bpf_ctx_t *, const struct bpf_insn *, bpf_args_t *); | |
515 | int bpf_validate_ext(const bpf_ctx_t *, const struct bpf_insn *, int); | 532 | int bpf_validate_ext(const bpf_ctx_t *, const struct bpf_insn *, int); | |
516 | 533 | |||
517 | bpfjit_func_t bpf_jit_generate(bpf_ctx_t *, void *, size_t); | 534 | bpfjit_func_t bpf_jit_generate(bpf_ctx_t *, void *, size_t); | |
518 | void bpf_jit_freecode(bpfjit_func_t); | 535 | void bpf_jit_freecode(bpfjit_func_t); | |
519 | 536 | |||
520 | void bpf_mtap_softint_init(struct ifnet *); | |||
521 | void bpf_mtap_softint(struct ifnet *, struct mbuf *); | |||
522 | ||||
523 | #endif | 537 | #endif | |
524 | 538 | |||
525 | int bpf_validate(const struct bpf_insn *, int); | 539 | int bpf_validate(const struct bpf_insn *, int); | |
526 | u_int bpf_filter(const struct bpf_insn *, const u_char *, u_int, u_int); | 540 | u_int bpf_filter(const struct bpf_insn *, const u_char *, u_int, u_int); | |
527 | 541 | |||
528 | __END_DECLS | 542 | __END_DECLS | |
529 | 543 | |||
530 | #endif /* !_NET_BPF_H_ */ | 544 | #endif /* !_NET_BPF_H_ */ |
--- src/sys/net/bpf_stub.c 2012/01/30 23:31:27 1.6
+++ src/sys/net/bpf_stub.c 2017/01/25 01:04:23 1.7
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: bpf_stub.c,v 1.6 2012/01/30 23:31:27 matt Exp $ */ | 1 | /* $NetBSD: bpf_stub.c,v 1.7 2017/01/25 01:04:23 ozaki-r Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2010 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2010 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -17,27 +17,27 @@ | @@ -17,27 +17,27 @@ | |||
17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | 26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | __KERNEL_RCSID(0, "$NetBSD: bpf_stub.c,v 1.6 2012/01/30 23:31:27 matt Exp $"); | 30 | __KERNEL_RCSID(0, "$NetBSD: bpf_stub.c,v 1.7 2017/01/25 01:04:23 ozaki-r Exp $"); | |
31 | 31 | |||
32 | #include <sys/param.h> | 32 | #include <sys/param.h> | |
33 | #include <sys/kmem.h> | 33 | #include <sys/kmem.h> | |
34 | #include <sys/mbuf.h> | 34 | #include <sys/mbuf.h> | |
35 | 35 | |||
36 | #include <net/bpf.h> | 36 | #include <net/bpf.h> | |
37 | 37 | |||
38 | struct laglist { | 38 | struct laglist { | |
39 | struct ifnet *lag_ifp; | 39 | struct ifnet *lag_ifp; | |
40 | u_int lag_dlt; | 40 | u_int lag_dlt; | |
41 | u_int lag_hlen; | 41 | u_int lag_hlen; | |
42 | struct bpf_if **lag_drvp; | 42 | struct bpf_if **lag_drvp; | |
43 | 43 | |||
@@ -57,26 +57,29 @@ static kcondvar_t handovercv; | @@ -57,26 +57,29 @@ static kcondvar_t handovercv; | |||
57 | static bool handover; | 57 | static bool handover; | |
58 | 58 | |||
59 | struct bpf_ops bpf_ops_stub = { | 59 | struct bpf_ops bpf_ops_stub = { | |
60 | .bpf_attach = bpf_stub_attach, | 60 | .bpf_attach = bpf_stub_attach, | |
61 | .bpf_detach = bpf_stub_detach, | 61 | .bpf_detach = bpf_stub_detach, | |
62 | .bpf_change_type = (void *)bpf_stub_null, | 62 | .bpf_change_type = (void *)bpf_stub_null, | |
63 | 63 | |||
64 | .bpf_tap = (void *)bpf_stub_warn, | 64 | .bpf_tap = (void *)bpf_stub_warn, | |
65 | .bpf_mtap = (void *)bpf_stub_warn, | 65 | .bpf_mtap = (void *)bpf_stub_warn, | |
66 | .bpf_mtap2 = (void *)bpf_stub_warn, | 66 | .bpf_mtap2 = (void *)bpf_stub_warn, | |
67 | .bpf_mtap_af = (void *)bpf_stub_warn, | 67 | .bpf_mtap_af = (void *)bpf_stub_warn, | |
68 | .bpf_mtap_sl_in = (void *)bpf_stub_warn, | 68 | .bpf_mtap_sl_in = (void *)bpf_stub_warn, | |
69 | .bpf_mtap_sl_out = (void *)bpf_stub_warn, | 69 | .bpf_mtap_sl_out = (void *)bpf_stub_warn, | |
70 | ||||
71 | .bpf_mtap_softint_init = (void *)bpf_stub_null, | |||
72 | .bpf_mtap_softint = (void *)bpf_stub_warn, | |||
70 | }; | 73 | }; | |
71 | struct bpf_ops *bpf_ops; | 74 | struct bpf_ops *bpf_ops; | |
72 | 75 | |||
73 | static void | 76 | static void | |
74 | bpf_stub_attach(struct ifnet *ifp, u_int dlt, u_int hlen, struct bpf_if **drvp) | 77 | bpf_stub_attach(struct ifnet *ifp, u_int dlt, u_int hlen, struct bpf_if **drvp) | |
75 | { | 78 | { | |
76 | struct laglist *lag; | 79 | struct laglist *lag; | |
77 | bool storeattach = true; | 80 | bool storeattach = true; | |
78 | 81 | |||
79 | lag = kmem_alloc(sizeof(*lag), KM_SLEEP); | 82 | lag = kmem_alloc(sizeof(*lag), KM_SLEEP); | |
80 | lag->lag_ifp = ifp; | 83 | lag->lag_ifp = ifp; | |
81 | lag->lag_dlt = dlt; | 84 | lag->lag_dlt = dlt; | |
82 | lag->lag_hlen = hlen; | 85 | lag->lag_hlen = hlen; |