Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet do not consult routing table under the following...



details:   https://anonhg.NetBSD.org/src/rev/6ffc069ff59a
branches:  trunk
changeset: 533199:6ffc069ff59a
user:      itojun <itojun%NetBSD.org@localhost>
date:      Mon Jun 24 08:01:35 2002 +0000

description:
do not consult routing table under the following condition:
- the destination is IPv4 multicast or 255.255.255.255, and
- outgoing interface is specified via socket option

this simplifies operation of routed
(no longer reqiure 224.0.0.0/4 to be set up)

diffstat:

 sys/netinet/ip_output.c |  28 ++++++++++++++++++++--------
 1 files changed, 20 insertions(+), 8 deletions(-)

diffs (58 lines):

diff -r fed944c0738a -r 6ffc069ff59a sys/netinet/ip_output.c
--- a/sys/netinet/ip_output.c   Mon Jun 24 07:15:24 2002 +0000
+++ b/sys/netinet/ip_output.c   Mon Jun 24 08:01:35 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_output.c,v 1.97 2002/06/09 16:33:42 itojun Exp $    */
+/*     $NetBSD: ip_output.c,v 1.98 2002/06/24 08:01:35 itojun Exp $    */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -102,7 +102,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.97 2002/06/09 16:33:42 itojun Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.98 2002/06/24 08:01:35 itojun Exp $");
 
 #include "opt_pfil_hooks.h"
 #include "opt_ipsec.h"
@@ -263,6 +263,11 @@
                ifp = ia->ia_ifp;
                mtu = ifp->if_mtu;
                ip->ip_ttl = 1;
+       } else if ((IN_MULTICAST(ip->ip_dst.s_addr) ||
+           ip->ip_dst.s_addr == INADDR_BROADCAST) &&
+           imo != NULL && imo->imo_multicast_ifp != NULL) {
+               ifp = imo->imo_multicast_ifp;
+               mtu = ifp->if_mtu;
        } else {
                if (ro->ro_rt == 0)
                        rtalloc(ro);
@@ -294,14 +299,21 @@
                /*
                 * See if the caller provided any multicast options
                 */
-               if (imo != NULL) {
+               if (imo != NULL)
                        ip->ip_ttl = imo->imo_multicast_ttl;
-                       if (imo->imo_multicast_ifp != NULL) {
-                               ifp = imo->imo_multicast_ifp;
-                               mtu = ifp->if_mtu;
-                       }
-               } else
+               else
                        ip->ip_ttl = IP_DEFAULT_MULTICAST_TTL;
+
+               /*
+                * if we don't know the outgoing ifp yet, we can't generate
+                * output
+                */
+               if (!ifp) {
+                       ipstat.ips_noroute++;
+                       error = ENETUNREACH;
+                       goto bad;
+               }
+
                /*
                 * If the packet is multicast or broadcast, confirm that
                 * the outgoing interface can transmit it.



Home | Main Index | Thread Index | Old Index