Subject: kern/32963: cannot install an unnumbered-p2p multicast interface into kernel
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Motoyuki OHMORI <ohmori@mobile-ip.org>
List: netbsd-bugs
Date: 03/01/2006 22:10:01
>Number:         32963
>Category:       kern
>Synopsis:       cannot install an unnumbered-p2p multicast interface into kernel
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 01 22:10:00 +0000 2006
>Originator:     Motoyuki OHMORI
>Release:        NetBSD 3.99.15
>Organization:
        Chikushi Jogakuen University
>Environment:
        MI
Architecture: i386
Machine: i386
>Description:
        IPv4 multicast routing code does not take account for an unnumbered
        p2p interface. If a multicast routing daemon tries install an interface
        as a vif into kernel, kernel might take different interface as a vif.
        IPv4 multicast packets could loop due to this.
>How-To-Repeat:
        Use an unumbered-p2p interface as a vif then multicast routing daemon:
# ifconfig fxp0 192.168.0.1/24
# ifconfig gif0 192.168.0.1/32 192.168.1.1
# mrouted
>Fix:
Make mrouted use an interface index when mrouted installes vifs into kernel and
make kernel can take an interface index.
Here is only a kernel patch to fix it:

diff -c sys/netinet/ip_var.h.orig sys/netinet/ip_var.h
*** sys/netinet/ip_var.h.orig   Thu Mar  2 06:10:35 2006
--- sys/netinet/ip_var.h        Thu Mar  2 06:12:32 2006
***************
*** 217,222 ****
--- 217,224 ----
  extern struct pool ipqent_pool;
  struct         inpcb;

+ struct ifnet *
+        ip_multicast_if(struct in_addr *, int *);
  int    ip_ctloutput(int, struct socket *, int, int, struct mbuf **);
  int    ip_dooptions(struct mbuf *);
  void   ip_drain(void);
*** sys/netinet/ip_output.c.orig        Thu Mar  2 06:09:55 2006
--- sys/netinet/ip_output.c     Thu Mar  2 06:12:06 2006
***************
*** 153,159 ****
  #endif
  
  static struct mbuf *ip_insertoptions(struct mbuf *, struct mbuf *, int *);
- static struct ifnet *ip_multicast_if(struct in_addr *, int *);
  static void ip_mloopback(struct ifnet *, struct mbuf *, struct sockaddr_in *);
  static int ip_getoptval(struct mbuf *, u_int8_t *, u_int);
  
--- 153,158 ----
***************
*** 1611,1617 ****
  /*
   * following RFC1724 section 3.3, 0.0.0.0/8 is interpreted as interface index.
   */
! static struct ifnet *
  ip_multicast_if(struct in_addr *a, int *ifindexp)
  {
        int ifindex;
--- 1610,1616 ----
  /*
   * following RFC1724 section 3.3, 0.0.0.0/8 is interpreted as interface index.
   */
! struct ifnet *
  ip_multicast_if(struct in_addr *a, int *ifindexp)
  {
        int ifindex;
*** sys/netinet/ip_mroute.c.orig        Thu Mar  2 06:08:38 2006
--- sys/netinet/ip_mroute.c     Thu Mar  2 06:16:04 2006
***************
*** 875,881 ****
  {
        struct vifctl *vifcp;
        struct vif *vifp;
-       struct ifaddr *ifa;
        struct ifnet *ifp;
        struct ifreq ifr;
        int error, s;
--- 875,880 ----
***************
*** 905,915 ****
        } else
  #endif
        {
!               sin.sin_addr = vifcp->vifc_lcl_addr;
!               ifa = ifa_ifwithaddr(sintosa(&sin));
!               if (ifa == NULL)
                        return (EADDRNOTAVAIL);
-               ifp = ifa->ifa_ifp;
        }
  
        if (vifcp->vifc_flags & VIFF_TUNNEL) {
--- 904,912 ----
        } else
  #endif
        {
!               ifp = ip_multicast_if(&vifcp->vifc_lcl_addr, NULL);
!               if (ifp == NULL)
                        return (EADDRNOTAVAIL);
        }
  
        if (vifcp->vifc_flags & VIFF_TUNNEL) {

>Unformatted:
 X-send-pr-version: 3.95