Back out rev 1.163 which broke the logic for SIOCSIFFLAGS. PR#38976.
This commit is contained in:
parent
d4ef85aece
commit
1d92605168
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: if_ethersubr.c,v 1.167 2008/05/13 17:58:52 dyoung Exp $ */
|
||||
/* $NetBSD: if_ethersubr.c,v 1.168 2008/07/23 05:41:47 gmcgarry Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
@ -61,7 +61,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.167 2008/05/13 17:58:52 dyoung Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.168 2008/07/23 05:41:47 gmcgarry Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_atalk.h"
|
||||
@ -1443,7 +1443,7 @@ ether_ioctl(struct ifnet *ifp, u_long cmd, void *data)
|
||||
struct ethercom *ec = (void *) ifp;
|
||||
struct ifreq *ifr = (struct ifreq *)data;
|
||||
struct ifaddr *ifa = (struct ifaddr *)data;
|
||||
int error;
|
||||
int error = 0;
|
||||
|
||||
switch (cmd) {
|
||||
case SIOCSIFADDR:
|
||||
@ -1453,21 +1453,21 @@ ether_ioctl(struct ifnet *ifp, u_long cmd, void *data)
|
||||
case AF_INET:
|
||||
if ((ifp->if_flags & IFF_RUNNING) == 0 &&
|
||||
(error = (*ifp->if_init)(ifp)) != 0)
|
||||
return error;
|
||||
break;
|
||||
arp_ifinit(ifp, ifa);
|
||||
break;
|
||||
#endif /* INET */
|
||||
default:
|
||||
if ((ifp->if_flags & IFF_RUNNING) == 0)
|
||||
return (*ifp->if_init)(ifp);
|
||||
error = (*ifp->if_init)(ifp);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case SIOCGIFADDR:
|
||||
memcpy(((struct sockaddr *)&ifr->ifr_data)->sa_data,
|
||||
CLLADDR(ifp->if_sadl), ETHER_ADDR_LEN);
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case SIOCSIFMTU:
|
||||
{
|
||||
@ -1479,53 +1479,60 @@ ether_ioctl(struct ifnet *ifp, u_long cmd, void *data)
|
||||
maxmtu = ETHERMTU;
|
||||
|
||||
if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > maxmtu)
|
||||
return EINVAL;
|
||||
else if ((error = ifioctl_common(ifp, cmd, data)) != ENETRESET)
|
||||
return error;
|
||||
else if (ifp->if_flags & IFF_UP) {
|
||||
error = EINVAL;
|
||||
else if ((error = ifioctl_common(ifp, cmd, data)) == ENETRESET){
|
||||
/* Make sure the device notices the MTU change. */
|
||||
return (*ifp->if_init)(ifp);
|
||||
} else
|
||||
return 0;
|
||||
if (ifp->if_flags & IFF_UP)
|
||||
error = (*ifp->if_init)(ifp);
|
||||
else
|
||||
error = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SIOCSIFFLAGS:
|
||||
switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) {
|
||||
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) == IFF_RUNNING) {
|
||||
/*
|
||||
* If interface is marked down and it is running,
|
||||
* then stop and disable it.
|
||||
*/
|
||||
(*ifp->if_stop)(ifp, 1);
|
||||
break;
|
||||
case IFF_UP:
|
||||
} else if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) == IFF_UP) {
|
||||
/*
|
||||
* If interface is marked up and it is stopped, then
|
||||
* start it.
|
||||
*/
|
||||
return (*ifp->if_init)(ifp);
|
||||
case IFF_UP|IFF_RUNNING:
|
||||
error = (*ifp->if_init)(ifp);
|
||||
} else if ((ifp->if_flags & IFF_UP) != 0) {
|
||||
/*
|
||||
* Reset the interface to pick up changes in any other
|
||||
* flags that affect the hardware state.
|
||||
*/
|
||||
return (*ifp->if_init)(ifp);
|
||||
case 0:
|
||||
break;
|
||||
error = (*ifp->if_init)(ifp);
|
||||
}
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case SIOCADDMULTI:
|
||||
return ether_addmulti(ifreq_getaddr(cmd, ifr), ec);
|
||||
error = ether_addmulti(ifreq_getaddr(cmd, ifr), ec);
|
||||
break;
|
||||
|
||||
case SIOCDELMULTI:
|
||||
return ether_delmulti(ifreq_getaddr(cmd, ifr), ec);
|
||||
error = ether_delmulti(ifreq_getaddr(cmd, ifr), ec);
|
||||
break;
|
||||
case SIOCSIFMEDIA:
|
||||
case SIOCGIFMEDIA:
|
||||
if (ec->ec_mii == NULL)
|
||||
return ENOTTY;
|
||||
return ifmedia_ioctl(ifp, ifr, &ec->ec_mii->mii_media, cmd);
|
||||
error = ENOTTY;
|
||||
else
|
||||
error = ifmedia_ioctl(ifp, ifr, &ec->ec_mii->mii_media,
|
||||
cmd);
|
||||
break;
|
||||
case SIOCSIFCAP:
|
||||
return ifioctl_common(ifp, cmd, data);
|
||||
default:
|
||||
return ENOTTY;
|
||||
error = ENOTTY;
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user