Deleted Added
full compact
route.c (271916) route.c (274175)
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 271916 2014-09-21 03:48:20Z hrs $
30 * $FreeBSD: head/sys/net/route.c 274175 2014-11-06 13:13:09Z 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"

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

1274 * We use the ifa reference returned by rt_getifa_fib().
1275 * This moved from below so that rnh->rnh_addaddr() can
1276 * examine the ifa and ifa->ifa_ifp if it so desires.
1277 */
1278 rt->rt_ifa = ifa;
1279 rt->rt_ifp = ifa->ifa_ifp;
1280 rt->rt_weight = 1;
1281
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"

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

1274 * We use the ifa reference returned by rt_getifa_fib().
1275 * This moved from below so that rnh->rnh_addaddr() can
1276 * examine the ifa and ifa->ifa_ifp if it so desires.
1277 */
1278 rt->rt_ifa = ifa;
1279 rt->rt_ifp = ifa->ifa_ifp;
1280 rt->rt_weight = 1;
1281
1282 rt_setmetrics(info, rt);
1283
1282#ifdef RADIX_MPATH
1283 /* do not permit exactly the same dst/mask/gw pair */
1284 if (rn_mpath_capable(rnh) &&
1285 rt_mpath_conflict(rnh, rt, netmask)) {
1286 ifa_free(rt->rt_ifa);
1287 Free(rt_key(rt));
1288 uma_zfree(V_rtzone, rt);
1289 senderr(EEXIST);

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

1368
1369 /*
1370 * If this protocol has something to add to this then
1371 * allow it to do that as well.
1372 */
1373 if (ifa->ifa_rtrequest)
1374 ifa->ifa_rtrequest(req, rt, info);
1375
1284#ifdef RADIX_MPATH
1285 /* do not permit exactly the same dst/mask/gw pair */
1286 if (rn_mpath_capable(rnh) &&
1287 rt_mpath_conflict(rnh, rt, netmask)) {
1288 ifa_free(rt->rt_ifa);
1289 Free(rt_key(rt));
1290 uma_zfree(V_rtzone, rt);
1291 senderr(EEXIST);

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

1370
1371 /*
1372 * If this protocol has something to add to this then
1373 * allow it to do that as well.
1374 */
1375 if (ifa->ifa_rtrequest)
1376 ifa->ifa_rtrequest(req, rt, info);
1377
1376 rt_setmetrics(info, rt);
1377
1378 /*
1379 * actually return a resultant rtentry and
1380 * give the caller a single reference.
1381 */
1382 if (ret_nrt) {
1383 *ret_nrt = rt;
1384 RT_ADDREF(rt);
1385 }

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

1407
1408static int
1409rtrequest1_fib_change(struct radix_node_head *rnh, struct rt_addrinfo *info,
1410 struct rtentry **ret_nrt, u_int fibnum)
1411{
1412 struct rtentry *rt = NULL;
1413 int error = 0;
1414 int free_ifa = 0;
1378 /*
1379 * actually return a resultant rtentry and
1380 * give the caller a single reference.
1381 */
1382 if (ret_nrt) {
1383 *ret_nrt = rt;
1384 RT_ADDREF(rt);
1385 }

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

1407
1408static int
1409rtrequest1_fib_change(struct radix_node_head *rnh, struct rt_addrinfo *info,
1410 struct rtentry **ret_nrt, u_int fibnum)
1411{
1412 struct rtentry *rt = NULL;
1413 int error = 0;
1414 int free_ifa = 0;
1415 int family, mtu;
1415
1416 rt = (struct rtentry *)rnh->rnh_lookup(info->rti_info[RTAX_DST],
1417 info->rti_info[RTAX_NETMASK], rnh);
1418
1419 if (rt == NULL)
1420 return (ESRCH);
1421
1422#ifdef RADIX_MPATH

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

1428 rt = rt_mpath_matchgate(rt, info->rti_info[RTAX_GATEWAY]);
1429 if (rt == NULL)
1430 return (ESRCH);
1431 }
1432#endif
1433
1434 RT_LOCK(rt);
1435
1416
1417 rt = (struct rtentry *)rnh->rnh_lookup(info->rti_info[RTAX_DST],
1418 info->rti_info[RTAX_NETMASK], rnh);
1419
1420 if (rt == NULL)
1421 return (ESRCH);
1422
1423#ifdef RADIX_MPATH

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

1429 rt = rt_mpath_matchgate(rt, info->rti_info[RTAX_GATEWAY]);
1430 if (rt == NULL)
1431 return (ESRCH);
1432 }
1433#endif
1434
1435 RT_LOCK(rt);
1436
1437 rt_setmetrics(info, rt);
1438
1436 /*
1437 * New gateway could require new ifaddr, ifp;
1438 * flags may also be different; ifp may be specified
1439 * by ll sockaddr when protocol address is ambiguous
1440 */
1441 if (((rt->rt_flags & RTF_GATEWAY) &&
1442 info->rti_info[RTAX_GATEWAY] != NULL) ||
1443 info->rti_info[RTAX_IFP] != NULL ||

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

1475 }
1476 /* Allow some flags to be toggled on change. */
1477 rt->rt_flags &= ~RTF_FMASK;
1478 rt->rt_flags |= info->rti_flags & RTF_FMASK;
1479
1480 if (rt->rt_ifa && rt->rt_ifa->ifa_rtrequest != NULL)
1481 rt->rt_ifa->ifa_rtrequest(RTM_ADD, rt, info);
1482
1439 /*
1440 * New gateway could require new ifaddr, ifp;
1441 * flags may also be different; ifp may be specified
1442 * by ll sockaddr when protocol address is ambiguous
1443 */
1444 if (((rt->rt_flags & RTF_GATEWAY) &&
1445 info->rti_info[RTAX_GATEWAY] != NULL) ||
1446 info->rti_info[RTAX_IFP] != NULL ||

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

1478 }
1479 /* Allow some flags to be toggled on change. */
1480 rt->rt_flags &= ~RTF_FMASK;
1481 rt->rt_flags |= info->rti_flags & RTF_FMASK;
1482
1483 if (rt->rt_ifa && rt->rt_ifa->ifa_rtrequest != NULL)
1484 rt->rt_ifa->ifa_rtrequest(RTM_ADD, rt, info);
1485
1483 rt_setmetrics(info, rt);
1486 /* Ensure route MTU is not bigger than interface MTU */
1487 if (rt->rt_ifp != NULL) {
1488 family = info->rti_info[RTAX_DST]->sa_family;
1489 mtu = if_getmtu_family(rt->rt_ifp, family);
1490 if (rt->rt_mtu > mtu)
1491 rt->rt_mtu = mtu;
1492 }
1484
1485 if (ret_nrt) {
1486 *ret_nrt = rt;
1487 RT_ADDREF(rt);
1488 }
1489bad:
1490 RT_UNLOCK(rt);
1491 if (free_ifa != 0)

--- 433 unchanged lines hidden ---
1493
1494 if (ret_nrt) {
1495 *ret_nrt = rt;
1496 RT_ADDREF(rt);
1497 }
1498bad:
1499 RT_UNLOCK(rt);
1500 if (free_ifa != 0)

--- 433 unchanged lines hidden ---