Resolved: if_index in struct ifnet broken in recent CURRENT

From: Gleb Smirnoff <glebius_at_freebsd.org>
Date: Thu, 12 Aug 2004 17:03:21 +0400
  The problem was that kernel source tree from which I was building
module was newer than running kernel, and struct ifnet size has
changed recently...

On Thu, Aug 12, 2004 at 11:59:28AM +0400, Gleb Smirnoff wrote:
T>   Hmm, some more information: actually if_index is broken
T> not only in in mbuf packet headers.
T> 
T> This code with different addresses:
T> 
T>         bzero((caddr_t)&ro, sizeof(ro));
T>         sin = (struct sockaddr_in *)&ro.ro_dst;
T>         sin->sin_len = sizeof(*sin);
T>         sin->sin_family = AF_INET;
T>         sin->sin_addr = \\some address\\;
T>         rtalloc_ign(&ro, RTF_CLONING);
T>         if (ro.ro_rt != NULL) {
T>                 struct rtentry *rt = ro.ro_rt;
T> 
T>                 printf("rt idx %d, name %s\n",
T>                         rt->rt_ifp->if_index,
T>                         rt->rt_ifp->if_xname);
T> 
T> produces 
T> 
T> rt idx 0, name fxp0
T> rt idx 0, name lo0
T> 
T> On Thu, Aug 12, 2004 at 11:50:53AM +0400, Gleb Smirnoff wrote:
T> T>   I can see this at least in fxp driver: if I capture packets using
T> T> ng_ether(4), and check interface name like this
T> T> 
T> T>                 printf("idx %d, name %s\n",
T> T>                         (*m)->m_pkthdr.rcvif->if_index,
T> T>                         (*m)->m_pkthdr.rcvif->if_xname);
T> T> I get on console:
T> T> 
T> T> idx 0, name fxp0
T> T> 
T> T> Really fxp's index is 1 (AFAIK if_index must be > 0), I have checked this
T> T> using if_nametoindex() from userland.
T> 
T> -- 
T> Totus tuus, Glebius.
T> GLEBIUS-RIPN GLEB-RIPE
T> _______________________________________________
T> freebsd-current_at_freebsd.org mailing list
T> http://lists.freebsd.org/mailman/listinfo/freebsd-current
T> To unsubscribe, send any mail to "freebsd-current-unsubscribe_at_freebsd.org"

-- 
Totus tuus, Glebius.
GLEBIUS-RIPN GLEB-RIPE
Received on Thu Aug 12 2004 - 11:03:25 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:05 UTC