diff options
author | dg <dg@FreeBSD.org> | 1996-12-10 07:29:50 +0000 |
---|---|---|
committer | dg <dg@FreeBSD.org> | 1996-12-10 07:29:50 +0000 |
commit | 1665979d2e5ce0eb4858dedb47572346ff1eadef (patch) | |
tree | 6dd10ac37eb6c182f025fad192efc51d37c719ca | |
parent | 46f2dd81651991d6e396015c9ce7929a0ca242ec (diff) | |
download | FreeBSD-src-1665979d2e5ce0eb4858dedb47572346ff1eadef.zip FreeBSD-src-1665979d2e5ce0eb4858dedb47572346ff1eadef.tar.gz |
1) Implement SIOCSIFMTU in ether_ioctl(), and change ether_ioctl's return
type to be int so that errors can be returned.
2) Use the new SIOCSIFMTU ether_ioctl support in the few drivers that are
using ether_ioctl().
3) In if_fxp.c: treat if_bpf as a token, not as a pointer. Don't bother
testing for FXP_NTXSEG being reached in fxp_start()...just check for
non-NULL 'm'. Change fxp_ioctl() to use ether_ioctl().
-rw-r--r-- | sys/dev/ed/if_ed.c | 16 | ||||
-rw-r--r-- | sys/dev/fxp/if_fxp.c | 107 | ||||
-rw-r--r-- | sys/i386/isa/if_ed.c | 16 | ||||
-rw-r--r-- | sys/i386/isa/if_eg.c | 5 | ||||
-rw-r--r-- | sys/net/if.h | 4 | ||||
-rw-r--r-- | sys/net/if_ethersubr.c | 18 | ||||
-rw-r--r-- | sys/pci/if_fxp.c | 107 |
7 files changed, 56 insertions, 217 deletions
diff --git a/sys/dev/ed/if_ed.c b/sys/dev/ed/if_ed.c index 96da68c..6bed04e 100644 --- a/sys/dev/ed/if_ed.c +++ b/sys/dev/ed/if_ed.c @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: if_ed.c,v 1.108 1996/11/15 16:07:03 wollman Exp $ + * $Id: if_ed.c,v 1.109 1996/12/03 16:08:00 phk Exp $ */ /* @@ -2627,7 +2627,8 @@ ed_ioctl(ifp, command, data) case SIOCSIFADDR: case SIOCGIFADDR: - ether_ioctl(ifp, command, data); + case SIOCSIFMTU: + error = ether_ioctl(ifp, command, data); break; case SIOCSIFFLAGS: @@ -2689,17 +2690,6 @@ ed_ioctl(ifp, command, data) } break; - case SIOCSIFMTU: - /* - * Set the interface MTU. - */ - if (ifr->ifr_mtu > ETHERMTU) { - error = EINVAL; - } else { - ifp->if_mtu = ifr->ifr_mtu; - } - break; - default: error = EINVAL; } diff --git a/sys/dev/fxp/if_fxp.c b/sys/dev/fxp/if_fxp.c index 9140a06..61cb065 100644 --- a/sys/dev/fxp/if_fxp.c +++ b/sys/dev/fxp/if_fxp.c @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: if_fxp.c,v 1.21 1996/10/12 19:49:43 bde Exp $ + * $Id: if_fxp.c,v 1.22 1996/11/18 02:45:46 davidg Exp $ */ /* @@ -131,7 +131,7 @@ static void fxp_attach __P((pcici_t, int)); static void fxp_intr __P((void *)); static void fxp_start __P((struct ifnet *)); static int fxp_ioctl __P((struct ifnet *, int, caddr_t)); -static void fxp_init __P((struct ifnet *)); +static void fxp_init __P((void *)); static void fxp_stop __P((struct fxp_softc *)); static void fxp_watchdog __P((struct ifnet *)); static void fxp_get_macaddr __P((struct fxp_softc *)); @@ -285,6 +285,7 @@ fxp_attach(config_id, unit) ifp->if_start = fxp_start; ifp->if_watchdog = fxp_watchdog; ifp->if_baudrate = 100000000; + ifp->if_init = fxp_init; fxp_get_macaddr(sc); printf("fxp%d: Ethernet address %6D\n", unit, @@ -460,7 +461,7 @@ tbdinit: segment++; } } - if (m != NULL && segment == FXP_NTXSEG) { + if (m != NULL) { struct mbuf *mn; /* @@ -531,7 +532,7 @@ tbdinit: /* * Pass packet to bpf if there is a listener. */ - if (ifp->if_bpf != NULL) + if (ifp->if_bpf) bpf_mtap(ifp, mb_head); #endif /* @@ -619,7 +620,7 @@ rcvloop: sizeof(struct ether_header); eh = mtod(m, struct ether_header *); #if NBPFILTER > 0 - if (ifp->if_bpf != NULL) { + if (ifp->if_bpf) { bpf_tap(ifp, mtod(m, caddr_t), total_len); /* * Only pass this packet up if it is for us. @@ -788,14 +789,15 @@ fxp_watchdog(ifp) log(LOG_ERR, "fxp%d: device timeout\n", ifp->if_unit); ifp->if_oerrors++; - fxp_init(ifp); + fxp_init(ifp->if_softc); } static void -fxp_init(ifp) - struct ifnet *ifp; +fxp_init(xsc) + void *xsc; { - struct fxp_softc *sc = ifp->if_softc; + struct fxp_softc *sc = xsc; + struct ifnet *ifp = &sc->arpcom.ac_if; struct fxp_cb_config *cbp; struct fxp_cb_ias *cb_ias; struct fxp_cb_tx *txp; @@ -1029,77 +1031,9 @@ fxp_ioctl(ifp, command, data) switch (command) { case SIOCSIFADDR: - ifp->if_flags |= IFF_UP; - - switch (ifa->ifa_addr->sa_family) { -#ifdef INET - case AF_INET: - fxp_init(ifp); /* before arpwhohas */ - arp_ifinit((struct arpcom *)ifp, ifa); - break; -#endif -#ifdef IPX - /* - * XXX - This code is probably wrong - */ - case AF_IPX: - { - register struct ipx_addr *ina = &(IA_SIPX(ifa)->sipx_addr); - - if (ipx_nullhost(*ina)) - ina->x_host = - *(union ipx_host *) (sc->arpcom.ac_enaddr); - else { - bcopy((caddr_t) ina->x_host.c_host, - (caddr_t) sc->arpcom.ac_enaddr, - sizeof(sc->arpcom.ac_enaddr)); - } - - /* - * Set new address - */ - fxp_init(ifp); - break; - } -#endif -#ifdef NS - /* - * XXX - This code is probably wrong - */ - case AF_NS: - { - register struct ns_addr *ina = &(IA_SNS(ifa)->sns_addr); - - if (ns_nullhost(*ina)) - ina->x_host = - *(union ns_host *) (sc->arpcom.ac_enaddr); - else { - bcopy((caddr_t) ina->x_host.c_host, - (caddr_t) sc->arpcom.ac_enaddr, - sizeof(sc->arpcom.ac_enaddr)); - } - - /* - * Set new address - */ - fxp_init(ifp); - break; - } -#endif - default: - fxp_init(ifp); - break; - } - break; - case SIOCGIFADDR: - { - struct sockaddr *sa; - - sa = (struct sockaddr *) & ifr->ifr_data; - bcopy((caddr_t) sc->arpcom.ac_enaddr, - (caddr_t) sa->sa_data, sizeof(sc->arpcom.ac_enaddr)); - } + case SIOCSIFMTU: + error = ether_ioctl(ifp, command, data); break; case SIOCSIFFLAGS: @@ -1111,7 +1045,7 @@ fxp_ioctl(ifp, command, data) * such as IFF_PROMISC are handled. */ if (ifp->if_flags & IFF_UP) { - fxp_init(ifp); + fxp_init(sc); } else { if (ifp->if_flags & IFF_RUNNING) fxp_stop(sc); @@ -1132,23 +1066,12 @@ fxp_ioctl(ifp, command, data) * Multicast list has changed; set the hardware filter * accordingly. */ - fxp_init(ifp); + fxp_init(sc); error = 0; } break; - case SIOCSIFMTU: - /* - * Set the interface MTU. - */ - if (ifr->ifr_mtu > ETHERMTU) { - error = EINVAL; - } else { - ifp->if_mtu = ifr->ifr_mtu; - } - break; - default: error = EINVAL; } diff --git a/sys/i386/isa/if_ed.c b/sys/i386/isa/if_ed.c index 96da68c..6bed04e 100644 --- a/sys/i386/isa/if_ed.c +++ b/sys/i386/isa/if_ed.c @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: if_ed.c,v 1.108 1996/11/15 16:07:03 wollman Exp $ + * $Id: if_ed.c,v 1.109 1996/12/03 16:08:00 phk Exp $ */ /* @@ -2627,7 +2627,8 @@ ed_ioctl(ifp, command, data) case SIOCSIFADDR: case SIOCGIFADDR: - ether_ioctl(ifp, command, data); + case SIOCSIFMTU: + error = ether_ioctl(ifp, command, data); break; case SIOCSIFFLAGS: @@ -2689,17 +2690,6 @@ ed_ioctl(ifp, command, data) } break; - case SIOCSIFMTU: - /* - * Set the interface MTU. - */ - if (ifr->ifr_mtu > ETHERMTU) { - error = EINVAL; - } else { - ifp->if_mtu = ifr->ifr_mtu; - } - break; - default: error = EINVAL; } diff --git a/sys/i386/isa/if_eg.c b/sys/i386/isa/if_eg.c index f0475e7..fd3d52a 100644 --- a/sys/i386/isa/if_eg.c +++ b/sys/i386/isa/if_eg.c @@ -27,7 +27,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: if_eg.c,v 1.18 1996/09/06 23:07:31 phk Exp $ + * $Id: if_eg.c,v 1.19 1996/10/30 08:50:26 phk Exp $ * * Support for 3Com 3c505 Etherlink+ card. */ @@ -730,7 +730,8 @@ egioctl(ifp, command, data) case SIOCSIFADDR: case SIOCGIFADDR: - ether_ioctl(ifp, command, data); + case SIOCSIFMTU: + error = ether_ioctl(ifp, command, data); break; case SIOCSIFFLAGS: diff --git a/sys/net/if.h b/sys/net/if.h index 67a7c17..9d7985a 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)if.h 8.1 (Berkeley) 6/10/93 - * $Id: if.h,v 1.35 1996/10/12 19:49:22 bde Exp $ + * $Id: if.h,v 1.36 1996/10/21 23:05:57 fenner Exp $ */ #ifndef _NET_IF_H_ @@ -418,7 +418,7 @@ void ether_ifattach __P((struct ifnet *)); void ether_input __P((struct ifnet *, struct ether_header *, struct mbuf *)); int ether_output __P((struct ifnet *, struct mbuf *, struct sockaddr *, struct rtentry *)); -void ether_ioctl __P((struct ifnet *, int , caddr_t )); +int ether_ioctl __P((struct ifnet *, int, caddr_t)); void if_attach __P((struct ifnet *)); void if_down __P((struct ifnet *)); diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index 8ca3e60..bdcdde7 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)if_ethersubr.c 8.1 (Berkeley) 6/10/93 - * $Id: if_ethersubr.c,v 1.26 1996/10/18 15:59:25 jkh Exp $ + * $Id: if_ethersubr.c,v 1.27 1996/11/18 04:55:44 davidg Exp $ */ #include <sys/param.h> @@ -848,11 +848,12 @@ ether_delmulti(ifr, ac) SYSCTL_NODE(_net_link, IFT_ETHER, ether, CTLFLAG_RW, 0, "Ethernet"); -void +int ether_ioctl(struct ifnet *ifp, int command, caddr_t data) { struct ifaddr *ifa = (struct ifaddr *) data; struct ifreq *ifr = (struct ifreq *) data; + int error = 0; switch (command) { case SIOCSIFADDR: @@ -931,6 +932,17 @@ ether_ioctl(struct ifnet *ifp, int command, caddr_t data) (caddr_t) sa->sa_data, ETHER_ADDR_LEN); } break; + + case SIOCSIFMTU: + /* + * Set the interface MTU. + */ + if (ifr->ifr_mtu > ETHERMTU) { + error = EINVAL; + } else { + ifp->if_mtu = ifr->ifr_mtu; + } + break; } - return; + return (error); } diff --git a/sys/pci/if_fxp.c b/sys/pci/if_fxp.c index 9140a06..61cb065 100644 --- a/sys/pci/if_fxp.c +++ b/sys/pci/if_fxp.c @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: if_fxp.c,v 1.21 1996/10/12 19:49:43 bde Exp $ + * $Id: if_fxp.c,v 1.22 1996/11/18 02:45:46 davidg Exp $ */ /* @@ -131,7 +131,7 @@ static void fxp_attach __P((pcici_t, int)); static void fxp_intr __P((void *)); static void fxp_start __P((struct ifnet *)); static int fxp_ioctl __P((struct ifnet *, int, caddr_t)); -static void fxp_init __P((struct ifnet *)); +static void fxp_init __P((void *)); static void fxp_stop __P((struct fxp_softc *)); static void fxp_watchdog __P((struct ifnet *)); static void fxp_get_macaddr __P((struct fxp_softc *)); @@ -285,6 +285,7 @@ fxp_attach(config_id, unit) ifp->if_start = fxp_start; ifp->if_watchdog = fxp_watchdog; ifp->if_baudrate = 100000000; + ifp->if_init = fxp_init; fxp_get_macaddr(sc); printf("fxp%d: Ethernet address %6D\n", unit, @@ -460,7 +461,7 @@ tbdinit: segment++; } } - if (m != NULL && segment == FXP_NTXSEG) { + if (m != NULL) { struct mbuf *mn; /* @@ -531,7 +532,7 @@ tbdinit: /* * Pass packet to bpf if there is a listener. */ - if (ifp->if_bpf != NULL) + if (ifp->if_bpf) bpf_mtap(ifp, mb_head); #endif /* @@ -619,7 +620,7 @@ rcvloop: sizeof(struct ether_header); eh = mtod(m, struct ether_header *); #if NBPFILTER > 0 - if (ifp->if_bpf != NULL) { + if (ifp->if_bpf) { bpf_tap(ifp, mtod(m, caddr_t), total_len); /* * Only pass this packet up if it is for us. @@ -788,14 +789,15 @@ fxp_watchdog(ifp) log(LOG_ERR, "fxp%d: device timeout\n", ifp->if_unit); ifp->if_oerrors++; - fxp_init(ifp); + fxp_init(ifp->if_softc); } static void -fxp_init(ifp) - struct ifnet *ifp; +fxp_init(xsc) + void *xsc; { - struct fxp_softc *sc = ifp->if_softc; + struct fxp_softc *sc = xsc; + struct ifnet *ifp = &sc->arpcom.ac_if; struct fxp_cb_config *cbp; struct fxp_cb_ias *cb_ias; struct fxp_cb_tx *txp; @@ -1029,77 +1031,9 @@ fxp_ioctl(ifp, command, data) switch (command) { case SIOCSIFADDR: - ifp->if_flags |= IFF_UP; - - switch (ifa->ifa_addr->sa_family) { -#ifdef INET - case AF_INET: - fxp_init(ifp); /* before arpwhohas */ - arp_ifinit((struct arpcom *)ifp, ifa); - break; -#endif -#ifdef IPX - /* - * XXX - This code is probably wrong - */ - case AF_IPX: - { - register struct ipx_addr *ina = &(IA_SIPX(ifa)->sipx_addr); - - if (ipx_nullhost(*ina)) - ina->x_host = - *(union ipx_host *) (sc->arpcom.ac_enaddr); - else { - bcopy((caddr_t) ina->x_host.c_host, - (caddr_t) sc->arpcom.ac_enaddr, - sizeof(sc->arpcom.ac_enaddr)); - } - - /* - * Set new address - */ - fxp_init(ifp); - break; - } -#endif -#ifdef NS - /* - * XXX - This code is probably wrong - */ - case AF_NS: - { - register struct ns_addr *ina = &(IA_SNS(ifa)->sns_addr); - - if (ns_nullhost(*ina)) - ina->x_host = - *(union ns_host *) (sc->arpcom.ac_enaddr); - else { - bcopy((caddr_t) ina->x_host.c_host, - (caddr_t) sc->arpcom.ac_enaddr, - sizeof(sc->arpcom.ac_enaddr)); - } - - /* - * Set new address - */ - fxp_init(ifp); - break; - } -#endif - default: - fxp_init(ifp); - break; - } - break; - case SIOCGIFADDR: - { - struct sockaddr *sa; - - sa = (struct sockaddr *) & ifr->ifr_data; - bcopy((caddr_t) sc->arpcom.ac_enaddr, - (caddr_t) sa->sa_data, sizeof(sc->arpcom.ac_enaddr)); - } + case SIOCSIFMTU: + error = ether_ioctl(ifp, command, data); break; case SIOCSIFFLAGS: @@ -1111,7 +1045,7 @@ fxp_ioctl(ifp, command, data) * such as IFF_PROMISC are handled. */ if (ifp->if_flags & IFF_UP) { - fxp_init(ifp); + fxp_init(sc); } else { if (ifp->if_flags & IFF_RUNNING) fxp_stop(sc); @@ -1132,23 +1066,12 @@ fxp_ioctl(ifp, command, data) * Multicast list has changed; set the hardware filter * accordingly. */ - fxp_init(ifp); + fxp_init(sc); error = 0; } break; - case SIOCSIFMTU: - /* - * Set the interface MTU. - */ - if (ifr->ifr_mtu > ETHERMTU) { - error = EINVAL; - } else { - ifp->if_mtu = ifr->ifr_mtu; - } - break; - default: error = EINVAL; } |