On 3/20/08, Claudio Jeker <[EMAIL PROTECTED]> wrote:
> On Wed, Mar 19, 2008 at 04:59:40PM -0700, Matthew Dempsky wrote:
>  > OpenBSD's currently limited to using interfaces with an index < 32 for
>  > multicast, and on one of my machines I created and destroyed enough
>  > virtual interfaces during experimentation that some of the interfaces
>  > currently in use and that I would like to route multicast traffic to
>  > have indexes >= 32.
>
> That's a bug in the multicast code that needs fixing.

Yeah, but in the mean-time I need a workaround. :-)

>  > Fortunately, I tested this idea first, because it actually leads to a
>  > kernel panic. :-)
>
> I somewhat expected that. Nobody ever expected the ifindex to wrap.

Looks like at least markus@ did. ;-)

> See attached diff which should help finding free slots (at least it helped
>  in my case). It will only reuse the last if_index and not previous free
>  slots. See if.c:if_attachsetup() use of the static if_index.

Cool.

>  The main issue with this diff is that ifindexes are reused and some
>  userland apps (mainly SNMP) require that the ifindex is unique and not
>  reused. I don't care about SNMP but I wanted to warn you about that.

I prefer SNMP giving bad results in extreme cases to a kernel panic. :-)

Also, I suspect this might be necessary for correctness when IPv6 is
used.  Since ifindex2ifnet is used in the IPv6 code for choosing which
interface a link-scoped address points to, and the ifnet struct is
free()'d when the interface detaches, it looks like running (e.g.)
'ping6 fe80:100::1' after interface 256 has been destroyed would lead
to undefined memory accesses.

(Though I'm still learning how the networking stack works; maybe
somewhere higher is able to identify that if_index is invalid even
when ifindex2ifnet[if_index] != NULL.)

Reply via email to