Deleted Added
full compact
route.c (260488) route.c (260508)
1/*-
2 * Copyright (c) 1980, 1986, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)route.c 8.3.1.1 (Berkeley) 2/23/95
1/*-
2 * Copyright (c) 1980, 1986, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)route.c 8.3.1.1 (Berkeley) 2/23/95
30 * $FreeBSD: head/sys/net/route.c 260488 2014-01-09 18:13:25Z melifaro $
30 * $FreeBSD: head/sys/net/route.c 260508 2014-01-10 12:13:55Z melifaro $
31 */
32/************************************************************************
33 * Note: In this file a 'fib' is a "forwarding information base" *
34 * Which is the new name for an in kernel routing (next hop) table. *
35 ***********************************************************************/
36
37#include "opt_inet.h"
38#include "opt_inet6.h"

--- 9 unchanged lines hidden (view full) ---

48#include <sys/mbuf.h>
49#include <sys/socket.h>
50#include <sys/sysctl.h>
51#include <sys/syslog.h>
52#include <sys/sysproto.h>
53#include <sys/proc.h>
54#include <sys/domain.h>
55#include <sys/kernel.h>
31 */
32/************************************************************************
33 * Note: In this file a 'fib' is a "forwarding information base" *
34 * Which is the new name for an in kernel routing (next hop) table. *
35 ***********************************************************************/
36
37#include "opt_inet.h"
38#include "opt_inet6.h"

--- 9 unchanged lines hidden (view full) ---

48#include <sys/mbuf.h>
49#include <sys/socket.h>
50#include <sys/sysctl.h>
51#include <sys/syslog.h>
52#include <sys/sysproto.h>
53#include <sys/proc.h>
54#include <sys/domain.h>
55#include <sys/kernel.h>
56#include <sys/kdb.h>
57
58#include <net/if.h>
59#include <net/if_var.h>
60#include <net/if_dl.h>
61#include <net/route.h>
62#include <net/vnet.h>
63#include <net/flowtable.h>
64

--- 1681 unchanged lines hidden (view full) ---

1746 * Announce interface address arrival/withdraw
1747 * Returns 0 on success.
1748 */
1749int
1750rt_addrmsg(int cmd, struct ifaddr *ifa, int fibnum)
1751{
1752
1753 KASSERT(cmd == RTM_ADD || cmd == RTM_DELETE,
56
57#include <net/if.h>
58#include <net/if_var.h>
59#include <net/if_dl.h>
60#include <net/route.h>
61#include <net/vnet.h>
62#include <net/flowtable.h>
63

--- 1681 unchanged lines hidden (view full) ---

1745 * Announce interface address arrival/withdraw
1746 * Returns 0 on success.
1747 */
1748int
1749rt_addrmsg(int cmd, struct ifaddr *ifa, int fibnum)
1750{
1751
1752 KASSERT(cmd == RTM_ADD || cmd == RTM_DELETE,
1754 ("unexpected cmd %u", cmd));
1753 ("unexpected cmd %d", cmd));
1755
1754
1756 if (fibnum != RT_ALL_FIBS) {
1757 KASSERT(fibnum >= 0 && fibnum < rt_numfibs, ("%s: "
1758 "fibnum out of range 0 <= %d < %d", __func__,
1759 fibnum, rt_numfibs));
1760 }
1755 KASSERT(fibnum == RT_ALL_FIBS || (fibnum >= 0 && fibnum < rt_numfibs),
1756 ("%s: fib out of range 0 <=%d<%d", __func__, fibnum, rt_numfibs));
1761
1762 return (rtsock_addrmsg(cmd, ifa, fibnum));
1763}
1764
1757
1758 return (rtsock_addrmsg(cmd, ifa, fibnum));
1759}
1760
1765
1766/*
1761/*
1767 * Announce route addition/removal
1762 * Announce route addition/removal.
1768 * Users of this function MUST validate input data BEFORE calling.
1769 * However we have to be able to handle invalid data:
1770 * if some userland app sends us "invalid" route message (invalid mask,
1763 * Users of this function MUST validate input data BEFORE calling.
1764 * However we have to be able to handle invalid data:
1765 * if some userland app sends us "invalid" route message (invalid mask,
1771 * no dst, wrokg address families, etc...) we need to pass it back
1766 * no dst, wrong address families, etc...) we need to pass it back
1772 * to app (and any other rtsock consumers) with rtm_errno field set to
1773 * non-zero value.
1774 * Returns 0 on success.
1775 */
1776int
1777rt_routemsg(int cmd, struct ifnet *ifp, int error, struct rtentry *rt,
1778 int fibnum)
1779{
1780
1781 KASSERT(cmd == RTM_ADD || cmd == RTM_DELETE,
1767 * to app (and any other rtsock consumers) with rtm_errno field set to
1768 * non-zero value.
1769 * Returns 0 on success.
1770 */
1771int
1772rt_routemsg(int cmd, struct ifnet *ifp, int error, struct rtentry *rt,
1773 int fibnum)
1774{
1775
1776 KASSERT(cmd == RTM_ADD || cmd == RTM_DELETE,
1782 ("unexpected cmd %u", cmd));
1777 ("unexpected cmd %d", cmd));
1783
1778
1784 if (fibnum != RT_ALL_FIBS) {
1785 KASSERT(fibnum >= 0 && fibnum < rt_numfibs, ("%s: "
1786 "fibnum out of range 0 <= %d < %d", __func__,
1787 fibnum, rt_numfibs));
1788 }
1779 KASSERT(fibnum == RT_ALL_FIBS || (fibnum >= 0 && fibnum < rt_numfibs),
1780 ("%s: fib out of range 0 <=%d<%d", __func__, fibnum, rt_numfibs));
1789
1790 KASSERT(rt_key(rt) != NULL, (":%s: rt_key must be supplied", __func__));
1791
1792 return (rtsock_routemsg(cmd, ifp, error, rt, fibnum));
1793}
1794
1795void
1796rt_newaddrmsg(int cmd, struct ifaddr *ifa, int error, struct rtentry *rt)

--- 8 unchanged lines hidden (view full) ---

1805 */
1806void
1807rt_newaddrmsg_fib(int cmd, struct ifaddr *ifa, int error, struct rtentry *rt,
1808 int fibnum)
1809{
1810
1811 KASSERT(cmd == RTM_ADD || cmd == RTM_DELETE,
1812 ("unexpected cmd %u", cmd));
1781
1782 KASSERT(rt_key(rt) != NULL, (":%s: rt_key must be supplied", __func__));
1783
1784 return (rtsock_routemsg(cmd, ifp, error, rt, fibnum));
1785}
1786
1787void
1788rt_newaddrmsg(int cmd, struct ifaddr *ifa, int error, struct rtentry *rt)

--- 8 unchanged lines hidden (view full) ---

1797 */
1798void
1799rt_newaddrmsg_fib(int cmd, struct ifaddr *ifa, int error, struct rtentry *rt,
1800 int fibnum)
1801{
1802
1803 KASSERT(cmd == RTM_ADD || cmd == RTM_DELETE,
1804 ("unexpected cmd %u", cmd));
1813 if (fibnum != RT_ALL_FIBS) {
1814 KASSERT(fibnum >= 0 && fibnum < rt_numfibs, ("%s: "
1815 "fibnum out of range 0 <= %d < %d", __func__,
1816 fibnum, rt_numfibs));
1817 }
1805 KASSERT(fibnum == RT_ALL_FIBS || (fibnum >= 0 && fibnum < rt_numfibs),
1806 ("%s: fib out of range 0 <=%d<%d", __func__, fibnum, rt_numfibs));
1818
1819#if defined(INET) || defined(INET6)
1820#ifdef SCTP
1821 /*
1822 * notify the SCTP stack
1823 * this will only get called when an address is added/deleted
1824 * XXX pass the ifaddr struct instead if ifa->ifa_addr...
1825 */

--- 14 unchanged lines hidden ---
1807
1808#if defined(INET) || defined(INET6)
1809#ifdef SCTP
1810 /*
1811 * notify the SCTP stack
1812 * this will only get called when an address is added/deleted
1813 * XXX pass the ifaddr struct instead if ifa->ifa_addr...
1814 */

--- 14 unchanged lines hidden ---