Subject: Re: ifnet.ifLastChange
To: None <tech-net@netbsd.org, core@kame.net>
From: None <itojun@iijlab.net>
List: tech-net
Date: 06/14/2001 13:49:31
does it looks okay? note that sys/net/if_{sl,strip}.c used
if_lastchange as watchdog timer, so i've added a variable to
softc (sc->sc_lastpacket).
itojun
Index: net/if.c
===================================================================
RCS file: /cvsroot/syssrc/sys/net/if.c,v
retrieving revision 1.90
diff -u -r1.90 if.c
--- net/if.c 2001/06/07 13:26:48 1.90
+++ net/if.c 2001/06/14 04:44:24
@@ -992,6 +992,7 @@
struct ifaddr *ifa;
ifp->if_flags &= ~IFF_UP;
+ microtime(&ifp->if_lastchange);
for (ifa = TAILQ_FIRST(&ifp->if_addrlist); ifa != NULL;
ifa = TAILQ_NEXT(ifa, ifa_list))
pfctlinput(PRC_IFDOWN, ifa->ifa_addr);
@@ -1013,6 +1014,7 @@
#endif
ifp->if_flags |= IFF_UP;
+ microtime(&ifp->if_lastchange);
#ifdef notyet
/* this has no effect on IP, and will kill all ISO connections XXX */
for (ifa = TAILQ_FIRST(&ifp->if_addrlist); ifa != NULL;
Index: net/if_arcsubr.c
===================================================================
RCS file: /cvsroot/syssrc/sys/net/if_arcsubr.c,v
retrieving revision 1.35
diff -u -r1.35 if_arcsubr.c
--- net/if_arcsubr.c 2001/04/13 23:30:12 1.35
+++ net/if_arcsubr.c 2001/06/14 04:44:24
@@ -139,7 +139,6 @@
myself = *LLADDR(ifp->if_sadl);
- ifp->if_lastchange = time;
if ((rt = rt0)) {
if ((rt->rt_flags & RTF_UP) == 0) {
if ((rt0 = rt = rtalloc1(dst, 1)))
@@ -576,7 +575,6 @@
ah = mtod(m, struct arc_header *);
- ifp->if_lastchange = time;
ifp->if_ibytes += m->m_pkthdr.len;
if (arcbroadcastaddr == ah->arc_dhost) {
Index: net/if_atmsubr.c
===================================================================
RCS file: /cvsroot/syssrc/sys/net/if_atmsubr.c,v
retrieving revision 1.28
diff -u -r1.28 if_atmsubr.c
--- net/if_atmsubr.c 2001/04/13 23:30:12 1.28
+++ net/if_atmsubr.c 2001/06/14 04:44:25
@@ -113,7 +113,6 @@
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
senderr(ENETDOWN);
- ifp->if_lastchange = time;
/*
* If the queueing discipline needs packet classification,
@@ -266,7 +265,6 @@
m_freem(m);
return;
}
- ifp->if_lastchange = time;
ifp->if_ibytes += m->m_pkthdr.len;
if (rxhand) {
Index: net/if_ethersubr.c
===================================================================
RCS file: /cvsroot/syssrc/sys/net/if_ethersubr.c,v
retrieving revision 1.84
diff -u -r1.84 if_ethersubr.c
--- net/if_ethersubr.c 2001/06/12 15:03:26 1.84
+++ net/if_ethersubr.c 2001/06/14 04:44:25
@@ -203,7 +203,6 @@
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
senderr(ENETDOWN);
- ifp->if_lastchange = time;
if ((rt = rt0) != NULL) {
if ((rt->rt_flags & RTF_UP) == 0) {
if ((rt0 = rt = rtalloc1(dst, 1)) != NULL) {
@@ -687,7 +686,6 @@
m->m_flags &= ~M_HASFCS;
}
- ifp->if_lastchange = time;
ifp->if_ibytes += m->m_pkthdr.len;
#if NBRIDGE > 0
Index: net/if_fddisubr.c
===================================================================
RCS file: /cvsroot/syssrc/sys/net/if_fddisubr.c,v
retrieving revision 1.39
diff -u -r1.39 if_fddisubr.c
--- net/if_fddisubr.c 2001/04/13 23:30:13 1.39
+++ net/if_fddisubr.c 2001/06/14 04:44:26
@@ -222,7 +222,6 @@
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
senderr(ENETDOWN);
- ifp->if_lastchange = time;
#if !defined(__bsdi__) || _BSDI_VERSION >= 199401
if ((rt = rt0) != NULL) {
if ((rt->rt_flags & RTF_UP) == 0) {
@@ -633,7 +632,6 @@
fh = mtod(m, struct fddi_header *);
- ifp->if_lastchange = time;
ifp->if_ibytes += m->m_pkthdr.len;
if (fh->fddi_dhost[0] & 1) {
if (bcmp((caddr_t)fddibroadcastaddr, (caddr_t)fh->fddi_dhost,
Index: net/if_gif.c
===================================================================
RCS file: /cvsroot/syssrc/sys/net/if_gif.c,v
retrieving revision 1.28
diff -u -r1.28 if_gif.c
--- net/if_gif.c 2001/06/04 23:53:13 1.28
+++ net/if_gif.c 2001/06/14 04:44:26
@@ -298,7 +298,6 @@
goto end;
}
- ifp->if_lastchange = time;
m->m_flags &= ~(M_BCAST|M_MCAST);
if (!(ifp->if_flags & IFF_UP) ||
sc->gif_psrc == NULL || sc->gif_pdst == NULL) {
Index: net/if_hippisubr.c
===================================================================
RCS file: /cvsroot/syssrc/sys/net/if_hippisubr.c,v
retrieving revision 1.11
diff -u -r1.11 if_hippisubr.c
--- net/if_hippisubr.c 2001/04/13 23:30:14 1.11
+++ net/if_hippisubr.c 2001/06/14 04:44:26
@@ -107,7 +107,6 @@
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
senderr(ENETDOWN);
- ifp->if_lastchange = time;
/* HIPPI doesn't really do broadcast or multicast right now */
if (m->m_flags & (M_BCAST | M_MCAST))
@@ -268,7 +267,6 @@
hh = mtod(m, struct hippi_header *);
- ifp->if_lastchange = time;
ifp->if_ibytes += m->m_pkthdr.len;
if (hh->hi_le.le_dest_addr[0] & 1) {
if (bcmp((caddr_t)etherbroadcastaddr,
Index: net/if_ieee1394subr.c
===================================================================
RCS file: /cvsroot/syssrc/sys/net/if_ieee1394subr.c,v
retrieving revision 1.10
diff -u -r1.10 if_ieee1394subr.c
--- net/if_ieee1394subr.c 2001/04/13 23:30:14 1.10
+++ net/if_ieee1394subr.c 2001/06/14 04:44:27
@@ -101,7 +101,6 @@
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
senderr(ENETDOWN);
- ifp->if_lastchange = time;
if ((rt = rt0) != NULL) {
if ((rt->rt_flags & RTF_UP) == 0) {
if ((rt0 = rt = rtalloc1(dst, 1)) != NULL) {
Index: net/if_loop.c
===================================================================
RCS file: /cvsroot/syssrc/sys/net/if_loop.c,v
retrieving revision 1.38
diff -u -r1.38 if_loop.c
--- net/if_loop.c 2001/04/13 23:30:14 1.38
+++ net/if_loop.c 2001/06/14 04:44:27
@@ -186,7 +186,6 @@
if ((m->m_flags & M_PKTHDR) == 0)
panic("looutput: no header mbuf");
- ifp->if_lastchange = time;
#if NBPFILTER > 0
if (ifp->if_bpf && (ifp->if_flags & IFF_LOOPBACK)) {
/*
Index: net/if_ppp.c
===================================================================
RCS file: /cvsroot/syssrc/sys/net/if_ppp.c,v
retrieving revision 1.68
diff -u -r1.68 if_ppp.c
--- net/if_ppp.c 2001/04/13 23:30:14 1.68
+++ net/if_ppp.c 2001/06/14 04:44:29
@@ -929,7 +929,6 @@
}
ppp_restart(sc);
}
- ifp->if_lastchange = time;
ifp->if_opackets++;
ifp->if_obytes += len;
@@ -1647,7 +1646,6 @@
splx(s);
ifp->if_ipackets++;
ifp->if_ibytes += ilen;
- ifp->if_lastchange = time;
if (rv)
(*sc->sc_ctlp)(sc);
Index: net/if_pppoe.c
===================================================================
RCS file: /cvsroot/syssrc/sys/net/if_pppoe.c,v
retrieving revision 1.1
diff -u -r1.1 if_pppoe.c
--- net/if_pppoe.c 2001/04/29 09:50:37 1.1
+++ net/if_pppoe.c 2001/06/14 04:44:29
@@ -943,7 +943,6 @@
}
while ((m = sppp_dequeue(ifp)) != NULL) {
- microtime(&ifp->if_lastchange);
len = m->m_pkthdr.len;
M_PREPEND(m, PPPOE_HEADERLEN, M_DONTWAIT);
if (m == NULL) {
Index: net/if_sl.c
===================================================================
RCS file: /cvsroot/syssrc/sys/net/if_sl.c,v
retrieving revision 1.75
diff -u -r1.75 if_sl.c
--- net/if_sl.c 2001/05/30 16:42:02 1.75
+++ net/if_sl.c 2001/06/14 04:44:30
@@ -444,7 +444,7 @@
struct timeval tv;
/* if output's been stalled for too long, and restart */
- timersub(&time, &sc->sc_if.if_lastchange, &tv);
+ timersub(&time, &sc->sc_lastpacket, &tv);
if (tv.tv_sec > 0) {
sc->sc_otimeout++;
slstart(sc->sc_ttyp);
@@ -473,7 +473,7 @@
ifp->if_oerrors++;
return (error);
}
- sc->sc_if.if_lastchange = time;
+ sc->sc_lastpacket = time;
splx(s);
s = spltty();
@@ -788,7 +788,7 @@
m_freem(bpf_m);
}
#endif
- sc->sc_if.if_lastchange = time;
+ sc->sc_lastpacket = time;
s = spltty();
@@ -987,7 +987,7 @@
}
sc->sc_if.if_ipackets++;
- sc->sc_if.if_lastchange = time;
+ sc->sc_lastpacket = time;
s = splnet();
if (IF_QFULL(&ipintrq)) {
Index: net/if_slvar.h
===================================================================
RCS file: /cvsroot/syssrc/sys/net/if_slvar.h,v
retrieving revision 1.23
diff -u -r1.23 if_slvar.h
--- net/if_slvar.h 2001/01/15 16:33:31 1.23
+++ net/if_slvar.h 2001/06/14 04:44:30
@@ -71,6 +71,7 @@
#ifdef INET /* XXX */
struct slcompress sc_comp; /* tcp compression data */
#endif
+ struct timeval sc_lastpacket; /* for watchdog */
};
/* internal flags */
Index: net/if_strip.c
===================================================================
RCS file: /cvsroot/syssrc/sys/net/if_strip.c,v
retrieving revision 1.38
diff -u -r1.38 if_strip.c
--- net/if_strip.c 2001/05/07 10:15:46 1.38
+++ net/if_strip.c 2001/06/14 04:44:32
@@ -834,7 +834,7 @@
struct timeval tv;
/* if output's been stalled for too long, and restart */
- timersub(&time, &sc->sc_if.if_lastchange, &tv);
+ timersub(&time, &sc->sc_lastpacket, &tv);
if (tv.tv_sec > 0) {
DPRINTF(("stripoutput: stalled, resetting\n"));
sc->sc_otimeout++;
@@ -860,7 +860,7 @@
ifp->if_oerrors++;
return (error);
}
- sc->sc_if.if_lastchange = time;
+ sc->sc_lastpacket = time;
splx(s);
s = spltty();
@@ -1182,7 +1182,7 @@
m_freem(bpf_m);
}
#endif
- sc->sc_if.if_lastchange = time;
+ sc->sc_lastpacket = time;
s = spltty();
strip_send(sc, m);
@@ -1300,7 +1300,7 @@
}
sc->sc_if.if_ipackets++;
- sc->sc_if.if_lastchange = time;
+ sc->sc_lastpacket = time;
s = splnet();
if (IF_QFULL(&ipintrq)) {
@@ -1411,7 +1411,7 @@
* is so badlyhung it needs powercycling.
*/
sc->sc_state = ST_DEAD;
- sc->sc_if.if_lastchange = time;
+ sc->sc_lastpacket = time;
sc->sc_statetimo = time.tv_sec + STRIP_RESET_INTERVAL;
/*
Index: net/if_stripvar.h
===================================================================
RCS file: /cvsroot/syssrc/sys/net/if_stripvar.h,v
retrieving revision 1.11
diff -u -r1.11 if_stripvar.h
--- net/if_stripvar.h 2001/01/15 16:33:32 1.11
+++ net/if_stripvar.h 2001/06/14 04:44:32
@@ -39,6 +39,8 @@
#define ST_DEAD 0x2 /* no answer to probe; do reset */
long sc_statetimo; /* When (secs) current state ends */
+
+ struct timeval sc_lastpacket; /* for watchdog */
};
Index: net/if_tokensubr.c
===================================================================
RCS file: /cvsroot/syssrc/sys/net/if_tokensubr.c,v
retrieving revision 1.17
diff -u -r1.17 if_tokensubr.c
--- net/if_tokensubr.c 2001/04/13 23:30:17 1.17
+++ net/if_tokensubr.c 2001/06/14 04:44:32
@@ -167,7 +167,6 @@
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
senderr(ENETDOWN);
- ifp->if_lastchange = time;
if ((rt = rt0)) {
if ((rt->rt_flags & RTF_UP) == 0) {
if ((rt0 = rt = RTALLOC1(dst, 1)))
@@ -506,7 +505,6 @@
trh = mtod(m, struct token_header *);
- ifp->if_lastchange = time;
ifp->if_ibytes += m->m_pkthdr.len;
if (bcmp((caddr_t)tokenbroadcastaddr, (caddr_t)trh->token_dhost,
sizeof(tokenbroadcastaddr)) == 0)
Index: net/ppp_tty.c
===================================================================
RCS file: /cvsroot/syssrc/sys/net/ppp_tty.c,v
retrieving revision 1.24
diff -u -r1.24 ppp_tty.c
--- net/ppp_tty.c 2001/03/31 00:35:24 1.24
+++ net/ppp_tty.c 2001/06/14 04:44:37
@@ -643,7 +643,6 @@
if (sc->sc_flags & SC_DEBUG)
pppdumpframe(sc,m,1);
}
- microtime(&sc->sc_if.if_lastchange);
for(n=m,len=0;n!=NULL;n=n->m_next)
len += n->m_len;
@@ -709,7 +708,6 @@
/* Calculate the FCS for the first mbuf's worth. */
sc->sc_outfcs = pppfcs(PPP_INITFCS, mtod(m, u_char *), m->m_len);
- sc->sc_if.if_lastchange = time;
}
for (;;) {
Index: netccitt/if_x25subr.c
===================================================================
RCS file: /cvsroot/syssrc/sys/netccitt/if_x25subr.c,v
retrieving revision 1.24
diff -u -r1.24 if_x25subr.c
--- netccitt/if_x25subr.c 2001/04/13 23:30:20 1.24
+++ netccitt/if_x25subr.c 2001/06/14 04:44:39
@@ -174,7 +174,6 @@
struct llinfo_x25 *lx = (struct llinfo_x25 *) lcp->lcd_upnext;
struct ifnet *ifp;
struct ifqueue *inq;
- extern struct timeval time;
int s, isr;
if (m == 0 || lcp->lcd_state != DATA_TRANSFER)
@@ -182,7 +181,6 @@
pk_flowcontrol(lcp, 0, 1); /* Generate RR */
ifp = m->m_pkthdr.rcvif;
- ifp->if_lastchange = time;
switch (m->m_type) {
default:
if (m)
Index: netisdn/i4b_ipr.c
===================================================================
RCS file: /cvsroot/syssrc/sys/netisdn/i4b_ipr.c,v
retrieving revision 1.5
diff -u -r1.5 i4b_ipr.c
--- netisdn/i4b_ipr.c 2001/03/24 12:40:31 1.5
+++ netisdn/i4b_ipr.c 2001/06/14 04:44:40
@@ -496,10 +496,6 @@
}
#endif
- /* update access time */
-
- microtime(&sc->sc_if.if_lastchange);
-
/*
* check, if type of service indicates interactive, i.e. telnet,
* traffic. in case it is interactive, put it into the fast queue,
@@ -581,7 +577,6 @@
error = EAFNOSUPPORT;
else
sc->sc_if.if_flags |= IFF_UP;
- microtime(&sc->sc_if.if_lastchange);
break;
case SIOCSIFFLAGS: /* set interface flags */
@@ -610,7 +605,6 @@
/* enable debug messages */
}
- microtime(&sc->sc_if.if_lastchange);
break;
#if !defined(__OpenBSD__)
@@ -620,10 +614,7 @@
else if(ifr->ifr_mtu < I4BIPRMINMTU)
error = EINVAL;
else
- {
ifp->if_mtu = ifr->ifr_mtu;
- microtime(&sc->sc_if.if_lastchange);
- }
break;
#endif /* __OPENBSD__ */
@@ -936,8 +927,6 @@
m->m_pkthdr.len = m->m_len;
- microtime(&sc->sc_if.if_lastchange);
-
#ifdef I4BIPRADJFRXP
/*
@@ -1136,8 +1125,6 @@
break;
}
- microtime(&sc->sc_if.if_lastchange);
-
#if NBPFILTER > 0 || NBPF > 0
if(sc->sc_if.if_bpf)
{
Index: netisdn/i4b_isppp.c
===================================================================
RCS file: /cvsroot/syssrc/sys/netisdn/i4b_isppp.c,v
retrieving revision 1.5
diff -u -r1.5 i4b_isppp.c
--- netisdn/i4b_isppp.c 2001/04/09 19:35:46 1.5
+++ netisdn/i4b_isppp.c 2001/06/14 04:44:41
@@ -431,8 +431,6 @@
#endif
#endif /* NBPFILTER > 0 || NBPF > 0 */
- microtime(&ifp->if_lastchange);
-
if(IF_QFULL(isdn_linktab[unit]->tx_queue))
{
NDBGL4(L4_ISPDBG, "isp%d, tx queue full!", unit);
@@ -709,8 +707,6 @@
m->m_pkthdr.rcvif = &sc->sc_if;
m->m_pkthdr.len = m->m_len;
-
- microtime(&sc->sc_if.if_lastchange);
sc->sc_if.if_ipackets++;
#if 0
Index: netiso/if_eon.c
===================================================================
RCS file: /cvsroot/syssrc/sys/netiso/if_eon.c,v
retrieving revision 1.33
diff -u -r1.33 if_eon.c
--- netiso/if_eon.c 2001/04/13 23:30:27 1.33
+++ netiso/if_eon.c 2001/06/14 04:44:43
@@ -375,7 +375,6 @@
}
#endif
- ifp->if_lastchange = time;
ifp->if_opackets++;
if (rt == 0 || (el = (struct eon_llinfo *) rt->rt_llinfo) == 0) {
if (dst->siso_family == AF_LINK) {
@@ -505,7 +504,6 @@
}
}
eonif->if_ibytes += m->m_pkthdr.len;
- eonif->if_lastchange = time;
iphdr = mtod(m, struct ip *);
/* do a few checks for debugging */
if (iphdr->ip_p != IPPROTO_EON) {
Index: dev/ic/hd64570.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/ic/hd64570.c,v
retrieving revision 1.16
diff -u -r1.16 hd64570.c
--- dev/ic/hd64570.c 2001/06/12 11:48:51 1.16
+++ dev/ic/hd64570.c 2001/06/14 04:44:45
@@ -807,7 +807,6 @@
ALTQ_DECL(struct altq_pktattr pktattr;)
error = 0;
- ifp->if_lastchange = time;
if ((ifp->if_flags & IFF_UP) != IFF_UP) {
error = ENETDOWN;
@@ -906,7 +905,6 @@
return (error);
}
ifp->if_obytes += len;
- ifp->if_lastchange = time;
if (mflags & M_MCAST)
ifp->if_omcasts++;
@@ -1610,7 +1608,6 @@
#endif
scp->sp_if.if_ipackets++;
- scp->sp_if.if_lastchange = time;
hdlc = mtod(m, struct hdlc_header *);
switch (ntohs(hdlc->h_proto)) {
Index: dev/ic/smc91cxx.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/ic/smc91cxx.c,v
retrieving revision 1.32
diff -u -r1.32 smc91cxx.c
--- dev/ic/smc91cxx.c 2000/12/14 06:27:26 1.32
+++ dev/ic/smc91cxx.c 2001/06/14 04:44:46
@@ -996,9 +996,8 @@
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == NULL)
goto out;
-
m->m_pkthdr.rcvif = ifp;
- m->m_pkthdr.len = m->m_len = packetlen;
+ m->m_pkthdr.len = packetlen;
/*
* Always put the packet in a cluster.
Index: dev/usb/if_upl.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/usb/if_upl.c,v
retrieving revision 1.14
diff -u -r1.14 if_upl.c
--- dev/usb/if_upl.c 2001/04/13 23:30:09 1.14
+++ dev/usb/if_upl.c 2001/06/14 04:44:49
@@ -1082,5 +1082,4 @@
splx(s);
ifp->if_ipackets++;
ifp->if_ibytes += m->m_len;
- ifp->if_lastchange = time;
}
Index: arch/alpha/a12/if_xb.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/alpha/a12/if_xb.c,v
retrieving revision 1.6
diff -u -r1.6 if_xb.c
--- arch/alpha/a12/if_xb.c 2001/01/17 00:30:49 1.6
+++ arch/alpha/a12/if_xb.c 2001/06/14 04:44:49
@@ -506,7 +506,6 @@
m_freem(m);
return ENETDOWN;
}
- ifp->if_lastchange = time;
/*
* We want an IP packet with a link level route, on a silver platter.
*/