The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/netinet6/in6_rmx.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * SPDX-License-Identifier: BSD-3-Clause
    3  *
    4  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
    5  * All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  * 3. Neither the name of the project nor the names of its contributors
   16  *    may be used to endorse or promote products derived from this software
   17  *    without specific prior written permission.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
   20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
   23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   29  * SUCH DAMAGE.
   30  *
   31  *      $KAME: in6_rmx.c,v 1.11 2001/07/26 06:53:16 jinmei Exp $
   32  */
   33 
   34 /*-
   35  * Copyright 1994, 1995 Massachusetts Institute of Technology
   36  *
   37  * Permission to use, copy, modify, and distribute this software and
   38  * its documentation for any purpose and without fee is hereby
   39  * granted, provided that both the above copyright notice and this
   40  * permission notice appear in all copies, that both the above
   41  * copyright notice and this permission notice appear in all
   42  * supporting documentation, and that the name of M.I.T. not be used
   43  * in advertising or publicity pertaining to distribution of the
   44  * software without specific, written prior permission.  M.I.T. makes
   45  * no representations about the suitability of this software for any
   46  * purpose.  It is provided "as is" without express or implied
   47  * warranty.
   48  *
   49  * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''.  M.I.T. DISCLAIMS
   50  * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
   51  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
   52  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
   53  * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   54  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   55  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   56  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   57  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   58  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   59  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   60  * SUCH DAMAGE.
   61  *
   62  */
   63 
   64 #include <sys/cdefs.h>
   65 __FBSDID("$FreeBSD$");
   66 
   67 #include <sys/param.h>
   68 #include <sys/systm.h>
   69 #include <sys/kernel.h>
   70 #include <sys/lock.h>
   71 #include <sys/queue.h>
   72 #include <sys/socket.h>
   73 #include <sys/socketvar.h>
   74 #include <sys/mbuf.h>
   75 #include <sys/rwlock.h>
   76 #include <sys/syslog.h>
   77 #include <sys/callout.h>
   78 
   79 #include <net/if.h>
   80 #include <net/if_var.h>
   81 #include <net/route.h>
   82 #include <net/route/route_ctl.h>
   83 #include <net/route/route_var.h>
   84 #include <net/route/nhop.h>
   85 
   86 #include <netinet/in.h>
   87 #include <netinet/ip_var.h>
   88 #include <netinet/in_var.h>
   89 
   90 #include <netinet/ip6.h>
   91 #include <netinet6/ip6_var.h>
   92 
   93 #include <netinet/icmp6.h>
   94 #include <netinet6/nd6.h>
   95 
   96 #include <netinet/tcp.h>
   97 #include <netinet/tcp_seq.h>
   98 #include <netinet/tcp_timer.h>
   99 #include <netinet/tcp_var.h>
  100 
  101 static int
  102 rib6_set_nh_pfxflags(u_int fibnum, const struct sockaddr *addr, const struct sockaddr *mask,
  103     struct nhop_object *nh)
  104 {
  105         const struct sockaddr_in6 *mask6 = (const struct sockaddr_in6 *)mask;
  106 
  107         if (mask6 == NULL)
  108                 nhop_set_pxtype_flag(nh, NHF_HOST);
  109         else if (IN6_IS_ADDR_UNSPECIFIED(&mask6->sin6_addr))
  110                 nhop_set_pxtype_flag(nh, NHF_DEFAULT);
  111         else
  112                 nhop_set_pxtype_flag(nh, 0);
  113 
  114         return (0);
  115 }
  116 
  117 static int
  118 rib6_augment_nh(u_int fibnum, struct nhop_object *nh)
  119 {
  120         /*
  121          * Check route MTU:
  122          * inherit interface MTU if not set or
  123          * check if MTU is too large.
  124          */
  125         if (nh->nh_mtu == 0) {
  126                 nh->nh_mtu = IN6_LINKMTU(nh->nh_ifp);
  127         } else if (nh->nh_mtu > IN6_LINKMTU(nh->nh_ifp))
  128                 nh->nh_mtu = IN6_LINKMTU(nh->nh_ifp);
  129 
  130         /* Set nexthop type */
  131         if (nhop_get_type(nh) == 0) {
  132                 uint16_t nh_type;
  133                 if (nh->nh_flags & NHF_GATEWAY)
  134                         nh_type = NH_TYPE_IPV6_ETHER_NHOP;
  135                 else
  136                         nh_type = NH_TYPE_IPV6_ETHER_RSLV;
  137 
  138                 nhop_set_type(nh, nh_type);
  139         }
  140 
  141         return (0);
  142 }
  143 
  144 /*
  145  * Initialize our routing tree.
  146  */
  147 
  148 struct rib_head *
  149 in6_inithead(uint32_t fibnum)
  150 {
  151         struct rib_head *rh;
  152         struct rib_subscription *rs;
  153 
  154         rh = rt_table_init(offsetof(struct sockaddr_in6, sin6_addr) << 3,
  155             AF_INET6, fibnum);
  156         if (rh == NULL)
  157                 return (NULL);
  158 
  159         rh->rnh_set_nh_pfxflags = rib6_set_nh_pfxflags;
  160         rh->rnh_augment_nh = rib6_augment_nh;
  161 
  162         rs = rib_subscribe_internal(rh, nd6_subscription_cb, NULL,
  163             RIB_NOTIFY_IMMEDIATE, true);
  164         KASSERT(rs != NULL, ("Unable to subscribe to fib %u\n", fibnum));
  165 
  166         return (rh);
  167 }
  168 
  169 #ifdef VIMAGE
  170 void
  171 in6_detachhead(struct rib_head *rh)
  172 {
  173 
  174         rt_table_destroy(rh);
  175 }
  176 #endif

Cache object: cd3446d42439415172ac2a942c23960c


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.