Increase size of ifnet.if_flags from 16 bits (short) to 32 bits (int). To avoid

breaking application ABI use unused ifreq.ifru_flags[1] for upper 16 bits in
SIOCSIFFLAGS and SIOCGIFFLAGS ioctl's.

Reviewed by:	-hackers, -net
This commit is contained in:
Maxim Sobolev 2002-08-18 07:05:00 +00:00
parent 4f8fa749f0
commit 62f7648682
20 changed files with 64 additions and 62 deletions

View File

@ -999,14 +999,15 @@ setifflags(const char *vname, int value, int s, const struct afswtch *afp)
exit(1);
}
strncpy(my_ifr.ifr_name, name, sizeof (my_ifr.ifr_name));
flags = my_ifr.ifr_flags;
flags = (ifr->ifr_flags & 0xffff) | (my_ifr.ifr_flagshigh << 16);
if (value < 0) {
value = -value;
flags &= ~value;
} else
flags |= value;
my_ifr.ifr_flags = flags;
my_ifr.ifr_flags = flags & 0xffff;
my_ifr.ifr_flagshigh = flags >> 16;
if (ioctl(s, SIOCSIFFLAGS, (caddr_t)&my_ifr) < 0)
Perror(vname);
}

View File

@ -197,20 +197,21 @@ struct ifreq {
struct sockaddr ifru_addr;
struct sockaddr ifru_dstaddr;
struct sockaddr ifru_broadaddr;
short ifru_flags;
short ifru_flags[2];
int ifru_metric;
int ifru_mtu;
int ifru_phys;
caddr_t ifru_data;
} ifr_ifru;
#define ifr_addr ifr_ifru.ifru_addr /* address */
#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
#define ifr_addr ifr_ifru.ifru_addr /* address */
#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
#define ifr_flags ifr_ifru.ifru_flags /* flags */
#define ifr_metric ifr_ifru.ifru_metric /* metric */
#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
#define ifr_phys ifr_ifru.ifru_phys /* physical wire */
#define ifr_data ifr_ifru.ifru_data /* for use by interface */
#define ifr_flags ifr_ifru.ifru_flags[0] /* flags (low 16 bits) */
#define ifr_flagshigh ifr_ifru.ifru_flags[1] /* flags (high 16 bits) */
#define ifr_metric ifr_ifru.ifru_metric /* metric */
#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
#define ifr_phys ifr_ifru.ifru_phys /* physical wire */
#define ifr_data ifr_ifru.ifru_data /* for use by interface */
};
.Ed
.Pp

View File

@ -284,7 +284,7 @@ is called, or zero if the timer is disabled.
(Set by driver,
decremented by generic watchdog code.)
.It Va if_flags
.Pq Vt short
.Pq Vt int
Flags describing operational parameters of this interface (see below).
(Manipulated by both driver and generic code.)
.It Va if_capabilities

View File

@ -1981,7 +1981,7 @@ linux_gifflags(struct thread *td, struct ifnet *ifp, struct l_ifreq *ifr)
{
l_short flags;
flags = ifp->if_flags;
flags = ifp->if_flags & 0xffff;
/* these flags have no Linux equivalent */
flags &= ~(IFF_SMART|IFF_OACTIVE|IFF_SIMPLEX|
IFF_LINK0|IFF_LINK1|IFF_LINK2);

View File

@ -2483,7 +2483,7 @@ static void dc_rxeof(sc)
while(!(sc->dc_ldata->dc_rx_list[i].dc_status & DC_RXSTAT_OWN)) {
#ifdef DEVICE_POLLING
if (ifp->if_ipending & IFF_POLLING) {
if (ifp->if_flags & IFF_POLLING) {
if (sc->rxcycles <= 0)
break;
sc->rxcycles--;
@ -2885,7 +2885,7 @@ static void dc_intr(arg)
DC_LOCK(sc);
ifp = &sc->arpcom.ac_if;
#ifdef DEVICE_POLLING
if (ifp->if_ipending & IFF_POLLING)
if (ifp->if_flags & IFF_POLLING)
goto done;
if (ether_poll_register(dc_poll, ifp)) { /* ok, disable interrupts */
CSR_WRITE_4(sc, DC_IMR, 0x00000000);
@ -3265,7 +3265,7 @@ static void dc_init(xsc)
* the case of polling. Some cards (e.g. fxp) turn interrupts on
* after a reset.
*/
if (ifp->if_ipending & IFF_POLLING)
if (ifp->if_flags & IFF_POLLING)
CSR_WRITE_4(sc, DC_IMR, 0x00000000);
else
#endif

View File

@ -1193,7 +1193,7 @@ fxp_intr(void *xsc)
#ifdef DEVICE_POLLING
struct ifnet *ifp = &sc->sc_if;
if (ifp->if_ipending & IFF_POLLING)
if (ifp->if_flags & IFF_POLLING)
return;
if (ether_poll_register(fxp_poll, ifp)) {
/* disable interrupts */
@ -1785,7 +1785,7 @@ fxp_init(void *xsc)
* ... but only do that if we are not polling. And because (presumably)
* the default is interrupts on, we need to disable them explicitly!
*/
if ( ifp->if_ipending & IFF_POLLING )
if ( ifp->if_flags & IFF_POLLING )
CSR_WRITE_1(sc, FXP_CSR_SCB_INTRCNTL, FXP_SCB_INTR_DISABLE);
else
#endif /* DEVICE_POLLING */

View File

@ -285,7 +285,7 @@ vxsetlink(sc)
register struct ifnet *ifp = &sc->arpcom.ac_if;
int i, j, k;
char *reason, *warning;
static short prev_flags;
static int prev_flags;
static char prev_conn = -1;
if (prev_conn == -1) {

View File

@ -383,7 +383,7 @@ netisr_poll(void)
for (i = 0 ; i < poll_handlers ; i++) {
if (pr[i].handler &&
pr[i].ifp->if_flags & IFF_RUNNING) {
pr[i].ifp->if_ipending &= ~IFF_POLLING;
pr[i].ifp->if_flags &= ~IFF_POLLING;
pr[i].handler(pr[i].ifp, POLL_DEREGISTER, 1);
}
pr[i].handler=NULL;
@ -415,7 +415,7 @@ ether_poll_register(poll_handler_t *h, struct ifnet *ifp)
return 0;
if ( !(ifp->if_flags & IFF_UP) ) /* must be up */
return 0;
if (ifp->if_ipending & IFF_POLLING) /* already polling */
if (ifp->if_flags & IFF_POLLING) /* already polling */
return 0;
s = splhigh();
@ -440,7 +440,7 @@ ether_poll_register(poll_handler_t *h, struct ifnet *ifp)
pr[poll_handlers].handler = h;
pr[poll_handlers].ifp = ifp;
poll_handlers++;
ifp->if_ipending |= IFF_POLLING;
ifp->if_flags |= IFF_POLLING;
splx(s);
if (idlepoll_sleeping)
wakeup(&idlepoll_sleeping);
@ -459,14 +459,14 @@ ether_poll_deregister(struct ifnet *ifp)
int i;
mtx_lock(&Giant);
if ( !ifp || !(ifp->if_ipending & IFF_POLLING) ) {
if ( !ifp || !(ifp->if_flags & IFF_POLLING) ) {
mtx_unlock(&Giant);
return 0;
}
for (i = 0 ; i < poll_handlers ; i++)
if (pr[i].ifp == ifp) /* found it */
break;
ifp->if_ipending &= ~IFF_POLLING; /* found or not... */
ifp->if_flags &= ~IFF_POLLING; /* found or not... */
if (i == poll_handlers) {
mtx_unlock(&Giant);
printf("ether_poll_deregister: ifp not found!!!\n");

View File

@ -1234,6 +1234,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
struct ifreq *ifr;
struct ifstat *ifs;
int error = 0;
int new_flags;
ifr = (struct ifreq *)data;
switch (cmd) {
@ -1242,7 +1243,8 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
break;
case SIOCGIFFLAGS:
ifr->ifr_flags = ifp->if_flags;
ifr->ifr_flags = ifp->if_flags & 0xffff;
ifr->ifr_flagshigh = ifp->if_flags >> 16;
break;
case SIOCGIFCAP:
@ -1272,22 +1274,23 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
error = suser(td);
if (error)
return (error);
ifr->ifr_prevflags = ifp->if_flags;
new_flags = (ifr->ifr_flags & 0xffff) |
(ifr->ifr_flagshigh << 16);
if (ifp->if_flags & IFF_SMART) {
/* Smart drivers twiddle their own routes */
} else if (ifp->if_flags & IFF_UP &&
(ifr->ifr_flags & IFF_UP) == 0) {
(new_flags & IFF_UP) == 0) {
int s = splimp();
if_down(ifp);
splx(s);
} else if (ifr->ifr_flags & IFF_UP &&
} else if (new_flags & IFF_UP &&
(ifp->if_flags & IFF_UP) == 0) {
int s = splimp();
if_up(ifp);
splx(s);
}
ifp->if_flags = (ifp->if_flags & IFF_CANTCHANGE) |
(ifr->ifr_flags &~ IFF_CANTCHANGE);
(new_flags &~ IFF_CANTCHANGE);
if (ifp->if_ioctl)
(void) (*ifp->if_ioctl)(ifp, cmd, data);
getmicrotime(&ifp->if_lastchange);
@ -1438,7 +1441,7 @@ ifioctl(so, cmd, data, td)
struct ifnet *ifp;
struct ifreq *ifr;
int error;
short oif_flags;
int oif_flags;
switch (cmd) {
case SIOCGIFCONF:
@ -1573,7 +1576,8 @@ ifpromisc(ifp, pswitch)
return (0);
ifp->if_flags &= ~IFF_PROMISC;
}
ifr.ifr_flags = ifp->if_flags;
ifr.ifr_flags = ifp->if_flags & 0xffff;
ifr.ifr_flagshigh = ifp->if_flags >> 16;
error = (*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, (caddr_t)&ifr);
if (error == 0) {
log(LOG_INFO, "%s%d: promiscuous mode %s\n",
@ -1695,7 +1699,8 @@ if_allmulti(ifp, onswitch)
if (onswitch) {
if (ifp->if_amcount++ == 0) {
ifp->if_flags |= IFF_ALLMULTI;
ifr.ifr_flags = ifp->if_flags;
ifr.ifr_flags = ifp->if_flags & 0xffff;
ifr.ifr_flagshigh = ifp->if_flags >> 16;
error = ifp->if_ioctl(ifp, SIOCSIFFLAGS, (caddr_t)&ifr);
}
} else {
@ -1704,7 +1709,8 @@ if_allmulti(ifp, onswitch)
} else {
ifp->if_amcount = 0;
ifp->if_flags &= ~IFF_ALLMULTI;
ifr.ifr_flags = ifp->if_flags;
ifr.ifr_flags = ifp->if_flags & 0xffff;;
ifr.ifr_flagshigh = ifp->if_flags >> 16;
error = ifp->if_ioctl(ifp, SIOCSIFFLAGS, (caddr_t)&ifr);
}
}
@ -1919,10 +1925,12 @@ if_setlladdr(struct ifnet *ifp, const u_char *lladdr, int len)
*/
if ((ifp->if_flags & IFF_UP) != 0) {
ifp->if_flags &= ~IFF_UP;
ifr.ifr_flags = ifp->if_flags;
ifr.ifr_flags = ifp->if_flags & 0xffff;
ifr.ifr_flagshigh = ifp->if_flags >> 16;
(*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, (caddr_t)&ifr);
ifp->if_flags |= IFF_UP;
ifr.ifr_flags = ifp->if_flags;
ifr.ifr_flags = ifp->if_flags & 0xffff;
ifr.ifr_flagshigh = ifp->if_flags >> 16;
(*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, (caddr_t)&ifr);
#ifdef INET
/*

View File

@ -139,14 +139,6 @@ struct if_data {
#define IFF_LINK2 0x4000 /* per link layer defined bit */
#define IFF_ALTPHYS IFF_LINK2 /* use alternate physical connection */
#define IFF_MULTICAST 0x8000 /* supports multicast */
/*
* The following flag(s) ought to go in if_flags, but we cannot change
* struct ifnet because of binary compatibility, so we store them in
* if_ipending, which is not used so far.
* If possible, make sure the value is not conflicting with other
* IFF flags, so we have an easier time when we want to merge them.
*/
#define IFF_POLLING 0x10000 /* Interface is in polling mode. */
/* flags set internally only: */
@ -244,8 +236,8 @@ struct ifreq {
#define ifr_addr ifr_ifru.ifru_addr /* address */
#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
#define ifr_flags ifr_ifru.ifru_flags[0] /* flags */
#define ifr_prevflags ifr_ifru.ifru_flags[1] /* flags */
#define ifr_flags ifr_ifru.ifru_flags[0] /* flags (low 16 bits) */
#define ifr_flagshigh ifr_ifru.ifru_flags[1] /* flags (high 16 bits) */
#define ifr_metric ifr_ifru.ifru_metric /* metric */
#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
#define ifr_phys ifr_ifru.ifru_phys /* physical wire */

View File

@ -654,7 +654,7 @@ tapioctl(dev, cmd, data, flag, td)
struct ifnet *ifp = &tp->tap_if;
struct tapinfo *tapp = NULL;
int s;
short f;
int f;
switch (cmd) {
case TAPSIFINFO:
@ -728,7 +728,7 @@ tapioctl(dev, cmd, data, flag, td)
break;
case VMIO_SIOCSIFFLAGS: /* VMware/VMnet SIOCSIFFLAGS */
f = *(short *)data;
f = *(int *)data;
f &= 0x0fff;
f &= ~IFF_CANTCHANGE;
f |= IFF_UP;

View File

@ -138,7 +138,7 @@ struct ifnet {
u_short if_index; /* numeric abbreviation for this if */
short if_unit; /* sub-unit for lower level driver */
short if_timer; /* time 'til if_watchdog called */
short if_flags; /* up/down, broadcast, etc. */
int if_flags; /* up/down, broadcast, etc. */
int if_capabilities; /* interface capabilities */
int if_capenable; /* enabled features */
int if_ipending; /* interrupts pending */

View File

@ -757,7 +757,7 @@ rt_ifmsg(ifp)
return;
ifm = mtod(m, struct if_msghdr *);
ifm->ifm_index = ifp->if_index;
ifm->ifm_flags = (u_short)ifp->if_flags;
ifm->ifm_flags = ifp->if_flags;
ifm->ifm_data = ifp->if_data;
ifm->ifm_addrs = 0;
route_proto.sp_protocol = 0;
@ -958,7 +958,7 @@ sysctl_iflist(af, w)
ifm = (struct if_msghdr *)w->w_tmem;
ifm->ifm_index = ifp->if_index;
ifm->ifm_flags = (u_short)ifp->if_flags;
ifm->ifm_flags = ifp->if_flags;
ifm->ifm_data = ifp->if_data;
ifm->ifm_addrs = info.rti_addrs;
error = SYSCTL_OUT(w->w_req,(caddr_t)ifm, len);

View File

@ -1057,7 +1057,7 @@ atm_if_ioctl(ifp, cmd, data)
break;
case SIOCGIFFLAGS:
*(short *)data = ifp->if_flags;
*(int *)data = ifp->if_flags;
break;
case SIOCSIFFLAGS:

View File

@ -234,7 +234,7 @@ struct in6_ifreq {
union {
struct sockaddr_in6 ifru_addr;
struct sockaddr_in6 ifru_dstaddr;
short ifru_flags;
int ifru_flags;
int ifru_flags6;
int ifru_metric;
caddr_t ifru_data;

View File

@ -385,7 +385,7 @@ bootpboot_p_if(struct ifnet *ifp, struct ifaddr *ifa)
printf("%s%d flags %x, addr ",
ifp->if_name,
ifp->if_unit,
(unsigned short) ifp->if_flags);
ifp->if_flags);
print_sin_addr((struct sockaddr_in *) ifa->ifa_addr);
printf(", broadcast ");
print_sin_addr((struct sockaddr_in *) ifa->ifa_dstaddr);

View File

@ -2483,7 +2483,7 @@ static void dc_rxeof(sc)
while(!(sc->dc_ldata->dc_rx_list[i].dc_status & DC_RXSTAT_OWN)) {
#ifdef DEVICE_POLLING
if (ifp->if_ipending & IFF_POLLING) {
if (ifp->if_flags & IFF_POLLING) {
if (sc->rxcycles <= 0)
break;
sc->rxcycles--;
@ -2885,7 +2885,7 @@ static void dc_intr(arg)
DC_LOCK(sc);
ifp = &sc->arpcom.ac_if;
#ifdef DEVICE_POLLING
if (ifp->if_ipending & IFF_POLLING)
if (ifp->if_flags & IFF_POLLING)
goto done;
if (ether_poll_register(dc_poll, ifp)) { /* ok, disable interrupts */
CSR_WRITE_4(sc, DC_IMR, 0x00000000);
@ -3265,7 +3265,7 @@ static void dc_init(xsc)
* the case of polling. Some cards (e.g. fxp) turn interrupts on
* after a reset.
*/
if (ifp->if_ipending & IFF_POLLING)
if (ifp->if_flags & IFF_POLLING)
CSR_WRITE_4(sc, DC_IMR, 0x00000000);
else
#endif

View File

@ -1187,7 +1187,7 @@ static void rl_rxeof(sc)
while((CSR_READ_1(sc, RL_COMMAND) & RL_CMD_EMPTY_RXBUF) == 0) {
#ifdef DEVICE_POLLING
if (ifp->if_ipending & IFF_POLLING) {
if (ifp->if_flags & IFF_POLLING) {
if (sc->rxcycles <= 0)
break;
sc->rxcycles--;
@ -1416,7 +1416,7 @@ static void rl_intr(arg)
ifp = &sc->arpcom.ac_if;
#ifdef DEVICE_POLLING
if (ifp->if_ipending & IFF_POLLING)
if (ifp->if_flags & IFF_POLLING)
goto done;
if (ether_poll_register(rl_poll, ifp)) { /* ok, disable interrupts */
CSR_WRITE_2(sc, RL_IMR, 0x0000);
@ -1654,7 +1654,7 @@ static void rl_init(xsc)
/*
* Disable interrupts if we are polling.
*/
if (ifp->if_ipending & IFF_POLLING)
if (ifp->if_flags & IFF_POLLING)
CSR_WRITE_2(sc, RL_IMR, 0);
else /* otherwise ... */
#endif /* DEVICE_POLLING */

View File

@ -1285,7 +1285,7 @@ static void sis_rxeof(sc)
while(SIS_OWNDESC(&sc->sis_ldata.sis_rx_list[i])) {
#ifdef DEVICE_POLLING
if (ifp->if_ipending & IFF_POLLING) {
if (ifp->if_flags & IFF_POLLING) {
if (sc->rxcycles <= 0)
break;
sc->rxcycles--;
@ -1508,7 +1508,7 @@ static void sis_intr(arg)
SIS_LOCK(sc);
#ifdef DEVICE_POLLING
if (ifp->if_ipending & IFF_POLLING)
if (ifp->if_flags & IFF_POLLING)
goto done;
if (ether_poll_register(sis_poll, ifp)) { /* ok, disable interrupts */
CSR_WRITE_4(sc, SIS_IER, 0);
@ -1810,7 +1810,7 @@ static void sis_init(xsc)
* ... only enable interrupts if we are not polling, make sure
* they are off otherwise.
*/
if (ifp->if_ipending & IFF_POLLING)
if (ifp->if_flags & IFF_POLLING)
CSR_WRITE_4(sc, SIS_IER, 0);
else
#endif /* DEVICE_POLLING */

View File

@ -32,7 +32,7 @@ config_vifs_from_kernel()
register vifi_t vifi;
int n;
u_int32 addr, mask, subnet;
short flags;
int flags;
int num_ifreq = 32;
ifc.ifc_len = num_ifreq * sizeof(struct ifreq);