| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: if_bridge.c,v 1.163 2018/12/15 07:38:58 rin Exp $ */ | | 1 | /* $NetBSD: if_bridge.c,v 1.164 2018/12/22 04:28:30 rin Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright 2001 Wasabi Systems, Inc. | | 4 | * Copyright 2001 Wasabi Systems, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | | 7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -70,27 +70,27 @@ | | | @@ -70,27 +70,27 @@ |
70 | | | 70 | |
71 | /* | | 71 | /* |
72 | * Network interface bridge support. | | 72 | * Network interface bridge support. |
73 | * | | 73 | * |
74 | * TODO: | | 74 | * TODO: |
75 | * | | 75 | * |
76 | * - Currently only supports Ethernet-like interfaces (Ethernet, | | 76 | * - Currently only supports Ethernet-like interfaces (Ethernet, |
77 | * 802.11, VLANs on Ethernet, etc.) Figure out a nice way | | 77 | * 802.11, VLANs on Ethernet, etc.) Figure out a nice way |
78 | * to bridge other types of interfaces (FDDI-FDDI, and maybe | | 78 | * to bridge other types of interfaces (FDDI-FDDI, and maybe |
79 | * consider heterogenous bridges). | | 79 | * consider heterogenous bridges). |
80 | */ | | 80 | */ |
81 | | | 81 | |
82 | #include <sys/cdefs.h> | | 82 | #include <sys/cdefs.h> |
83 | __KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.163 2018/12/15 07:38:58 rin Exp $"); | | 83 | __KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.164 2018/12/22 04:28:30 rin Exp $"); |
84 | | | 84 | |
85 | #ifdef _KERNEL_OPT | | 85 | #ifdef _KERNEL_OPT |
86 | #include "opt_bridge_ipf.h" | | 86 | #include "opt_bridge_ipf.h" |
87 | #include "opt_inet.h" | | 87 | #include "opt_inet.h" |
88 | #include "opt_net_mpsafe.h" | | 88 | #include "opt_net_mpsafe.h" |
89 | #endif /* _KERNEL_OPT */ | | 89 | #endif /* _KERNEL_OPT */ |
90 | | | 90 | |
91 | #include <sys/param.h> | | 91 | #include <sys/param.h> |
92 | #include <sys/kernel.h> | | 92 | #include <sys/kernel.h> |
93 | #include <sys/mbuf.h> | | 93 | #include <sys/mbuf.h> |
94 | #include <sys/queue.h> | | 94 | #include <sys/queue.h> |
95 | #include <sys/socket.h> | | 95 | #include <sys/socket.h> |
96 | #include <sys/socketvar.h> /* for softnet_lock */ | | 96 | #include <sys/socketvar.h> /* for softnet_lock */ |
| @@ -733,26 +733,45 @@ bridge_delete_member(struct bridge_softc | | | @@ -733,26 +733,45 @@ bridge_delete_member(struct bridge_softc |
733 | { | | 733 | { |
734 | struct ifnet *ifs = bif->bif_ifp; | | 734 | struct ifnet *ifs = bif->bif_ifp; |
735 | | | 735 | |
736 | KASSERT(BRIDGE_LOCKED(sc)); | | 736 | KASSERT(BRIDGE_LOCKED(sc)); |
737 | | | 737 | |
738 | ifs->_if_input = ether_input; | | 738 | ifs->_if_input = ether_input; |
739 | ifs->if_bridge = NULL; | | 739 | ifs->if_bridge = NULL; |
740 | ifs->if_bridgeif = NULL; | | 740 | ifs->if_bridgeif = NULL; |
741 | | | 741 | |
742 | PSLIST_WRITER_REMOVE(bif, bif_next); | | 742 | PSLIST_WRITER_REMOVE(bif, bif_next); |
743 | BRIDGE_PSZ_PERFORM(sc); | | 743 | BRIDGE_PSZ_PERFORM(sc); |
744 | BRIDGE_UNLOCK(sc); | | 744 | BRIDGE_UNLOCK(sc); |
745 | | | 745 | |
| | | 746 | switch (ifs->if_type) { |
| | | 747 | case IFT_ETHER: |
| | | 748 | case IFT_L2TP: |
| | | 749 | /* |
| | | 750 | * Take the interface out of promiscuous mode. |
| | | 751 | * Don't call it with holding a spin lock. |
| | | 752 | */ |
| | | 753 | (void) ifpromisc(ifs, 0); |
| | | 754 | IFNET_LOCK(ifs); |
| | | 755 | (void) ether_disable_vlan_mtu(ifs); |
| | | 756 | IFNET_UNLOCK(ifs); |
| | | 757 | break; |
| | | 758 | default: |
| | | 759 | #ifdef DIAGNOSTIC |
| | | 760 | panic("%s: impossible", __func__); |
| | | 761 | #endif |
| | | 762 | break; |
| | | 763 | } |
| | | 764 | |
746 | psref_target_destroy(&bif->bif_psref, bridge_psref_class); | | 765 | psref_target_destroy(&bif->bif_psref, bridge_psref_class); |
747 | | | 766 | |
748 | PSLIST_ENTRY_DESTROY(bif, bif_next); | | 767 | PSLIST_ENTRY_DESTROY(bif, bif_next); |
749 | kmem_free(bif, sizeof(*bif)); | | 768 | kmem_free(bif, sizeof(*bif)); |
750 | | | 769 | |
751 | BRIDGE_LOCK(sc); | | 770 | BRIDGE_LOCK(sc); |
752 | } | | 771 | } |
753 | | | 772 | |
754 | /* | | 773 | /* |
755 | * bridge_calc_csum_flags: | | 774 | * bridge_calc_csum_flags: |
756 | * | | 775 | * |
757 | * Calculate logical and b/w csum flags each member interface supports. | | 776 | * Calculate logical and b/w csum flags each member interface supports. |
758 | */ | | 777 | */ |
| @@ -887,45 +906,26 @@ bridge_ioctl_del(struct bridge_softc *sc | | | @@ -887,45 +906,26 @@ bridge_ioctl_del(struct bridge_softc *sc |
887 | if (strcmp(ifs->if_xname, name) == 0) | | 906 | if (strcmp(ifs->if_xname, name) == 0) |
888 | break; | | 907 | break; |
889 | } | | 908 | } |
890 | | | 909 | |
891 | if (bif == NULL) { | | 910 | if (bif == NULL) { |
892 | BRIDGE_UNLOCK(sc); | | 911 | BRIDGE_UNLOCK(sc); |
893 | return ENOENT; | | 912 | return ENOENT; |
894 | } | | 913 | } |
895 | | | 914 | |
896 | bridge_delete_member(sc, bif); | | 915 | bridge_delete_member(sc, bif); |
897 | | | 916 | |
898 | BRIDGE_UNLOCK(sc); | | 917 | BRIDGE_UNLOCK(sc); |
899 | | | 918 | |
900 | switch (ifs->if_type) { | | | |
901 | case IFT_ETHER: | | | |
902 | case IFT_L2TP: | | | |
903 | /* | | | |
904 | * Take the interface out of promiscuous mode. | | | |
905 | * Don't call it with holding a spin lock. | | | |
906 | */ | | | |
907 | (void) ifpromisc(ifs, 0); | | | |
908 | IFNET_LOCK(ifs); | | | |
909 | (void) ether_disable_vlan_mtu(ifs); | | | |
910 | IFNET_UNLOCK(ifs); | | | |
911 | break; | | | |
912 | default: | | | |
913 | #ifdef DIAGNOSTIC | | | |
914 | panic("bridge_delete_member: impossible"); | | | |
915 | #endif | | | |
916 | break; | | | |
917 | } | | | |
918 | | | | |
919 | bridge_rtdelete(sc, ifs); | | 919 | bridge_rtdelete(sc, ifs); |
920 | bridge_calc_csum_flags(sc); | | 920 | bridge_calc_csum_flags(sc); |
921 | | | 921 | |
922 | if (sc->sc_if.if_flags & IFF_RUNNING) | | 922 | if (sc->sc_if.if_flags & IFF_RUNNING) |
923 | bstp_initialization(sc); | | 923 | bstp_initialization(sc); |
924 | | | 924 | |
925 | return 0; | | 925 | return 0; |
926 | } | | 926 | } |
927 | | | 927 | |
928 | static int | | 928 | static int |
929 | bridge_ioctl_gifflags(struct bridge_softc *sc, void *arg) | | 929 | bridge_ioctl_gifflags(struct bridge_softc *sc, void *arg) |
930 | { | | 930 | { |
931 | struct ifbreq *req = arg; | | 931 | struct ifbreq *req = arg; |