Re: [patch] Verify that ifaddr_byindex(foo) != NULL

From: Luigi Rizzo (rizzo_at_icir.org)
Date: 05/04/04

  • Next message: Wes Peters: "Re: [4.9-R]Can I Make My DSL Connect Go Faster ?"
    Date: Tue, 4 May 2004 06:35:00 -0700
    To: Colin Percival <colin.percival@wadham.ox.ac.uk>
    
    

    On Tue, May 04, 2004 at 01:42:20PM +0100, Colin Percival wrote:
    > Could someone confirm for me that this looks sensible? I don't
    > know anything about this code, but if we're going to check that
    > 0 < ifp->if_index <= if_index, it seems that we should also be
    > checking that ifp->if_index corresponds to an interface which
    > still exists (rather than a gap left behind when an interface was
    > removed).

    well, the problem here and elsewhere is whether we trust the rcvif
    field or not -- if we do, we must assume that if_index and ifadd_byindex()
    are all valid, because they are all set consistently in if_attach().

    If the interface is gone, ifp is already bogus thus there is no
    point to check.

    So i'd vote to remove all the bogus checks here and elsewhere, rather
    than add newer ones.

            cheers
            luigi

    > Colin Percival
    >
    > Index: src/sys/netinet/ip_input.c
    > ===================================================================
    > RCS file: /home/ncvs/src/sys/netinet/ip_input.c,v
    > retrieving revision 1.270
    > diff -u -p -r1.270 ip_input.c
    > --- src/sys/netinet/ip_input.c 2 May 2004 15:10:16 -0000 1.270
    > +++ src/sys/netinet/ip_input.c 4 May 2004 12:37:02 -0000
    > @@ -2053,7 +2053,8 @@ ip_savecontrol(inp, mp, ip, m)
    > struct sockaddr_dl *sdl2 = &sdlbuf.sdl;
    >
    > if (((ifp = m->m_pkthdr.rcvif))
    > - && ( ifp->if_index && (ifp->if_index <= if_index))) {
    > + && ( ifp->if_index && (ifp->if_index <= if_index)) &&
    > + (ifaddr_byindex(ifp->if_index) != NULL)) {
    > sdp = (struct sockaddr_dl *)
    > (ifaddr_byindex(ifp->if_index)->ifa_addr);
    > /*
    >
    > _______________________________________________
    > freebsd-net@freebsd.org mailing list
    > http://lists.freebsd.org/mailman/listinfo/freebsd-net
    > To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org"
    _______________________________________________
    freebsd-net@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-net
    To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org"


  • Next message: Wes Peters: "Re: [4.9-R]Can I Make My DSL Connect Go Faster ?"

    Relevant Pages

    • Re: enc0 patch for ipsec
      ... +.Nd Encapsulating Interface ... +or incoming packets after they have been similarly processed, ... retrieving revision 1.3 ...
      (freebsd-arch)
    • Re: enc0 patch for ipsec
      ... +.Nd Encapsulating Interface ... +or incoming packets after they have been similarly processed, ... retrieving revision 1.3 ...
      (freebsd-net)
    • Re: How do you read mail with gnus?
      ... it for reading maildir folders, ... powerful to use the same interface for both. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
      (Debian-User)
    • Re: ethernet configuration
      ... interface calls it something like "rich format") and please stop ... allow-hotplug eth0 ... But specifying the MAC address didn't worked (he configured the ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
      (Debian-User)
    • Re: new problem - networking is strange
      ... Miles Fidelman wrote: ... problem in the past a few times, usually following a kernel upgrade or ... You may need to remove some lines from there or change the interface ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
      (Debian-User)