Deleted Added
full compact
rtsock.c (186119) rtsock.c (186500)
1/*-
2 * Copyright (c) 1988, 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 * @(#)rtsock.c 8.7 (Berkeley) 10/12/95
1/*-
2 * Copyright (c) 1988, 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 * @(#)rtsock.c 8.7 (Berkeley) 10/12/95
30 * $FreeBSD: head/sys/net/rtsock.c 186119 2008-12-15 06:10:57Z qingli $
30 * $FreeBSD: head/sys/net/rtsock.c 186500 2008-12-26 19:45:24Z qingli $
31 */
32#include "opt_sctp.h"
33#include "opt_mpath.h"
34#include "opt_inet.h"
35#include "opt_inet6.h"
36
37#include <sys/param.h>
38#include <sys/domain.h>

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

48#include <sys/signalvar.h>
49#include <sys/socket.h>
50#include <sys/socketvar.h>
51#include <sys/sysctl.h>
52#include <sys/systm.h>
53#include <sys/vimage.h>
54
55#include <net/if.h>
31 */
32#include "opt_sctp.h"
33#include "opt_mpath.h"
34#include "opt_inet.h"
35#include "opt_inet6.h"
36
37#include <sys/param.h>
38#include <sys/domain.h>

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

48#include <sys/signalvar.h>
49#include <sys/socket.h>
50#include <sys/socketvar.h>
51#include <sys/sysctl.h>
52#include <sys/systm.h>
53#include <sys/vimage.h>
54
55#include <net/if.h>
56#include <net/if_dl.h>
56#include <net/if_llatbl.h>
57#include <net/netisr.h>
58#include <net/raw_cb.h>
59#include <net/route.h>
60#include <net/vnet.h>
61
62#include <netinet/in.h>
63#ifdef INET6

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

509
510 switch (rtm->rtm_type) {
511 struct rtentry *saved_nrt;
512
513 case RTM_ADD:
514 if (info.rti_info[RTAX_GATEWAY] == NULL)
515 senderr(EINVAL);
516 saved_nrt = NULL;
57#include <net/if_llatbl.h>
58#include <net/netisr.h>
59#include <net/raw_cb.h>
60#include <net/route.h>
61#include <net/vnet.h>
62
63#include <netinet/in.h>
64#ifdef INET6

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

510
511 switch (rtm->rtm_type) {
512 struct rtentry *saved_nrt;
513
514 case RTM_ADD:
515 if (info.rti_info[RTAX_GATEWAY] == NULL)
516 senderr(EINVAL);
517 saved_nrt = NULL;
518
517 /* support for new ARP code */
519 /* support for new ARP code */
518 if (info.rti_info[RTAX_GATEWAY]->sa_family == AF_LINK) {
520 if (info.rti_info[RTAX_GATEWAY]->sa_family == AF_LINK &&
521 (rtm->rtm_flags & RTF_LLDATA) != 0) {
519 error = lla_rt_output(rtm, &info);
520 break;
521 }
522 error = rtrequest1_fib(RTM_ADD, &info, &saved_nrt,
523 so->so_fibnum);
524 if (error == 0 && saved_nrt) {
525 RT_LOCK(saved_nrt);
526 rt_setmetrics(rtm->rtm_inits,
527 &rtm->rtm_rmx, &saved_nrt->rt_rmx);
528 rtm->rtm_index = saved_nrt->rt_ifp->if_index;
529 RT_REMREF(saved_nrt);
530 RT_UNLOCK(saved_nrt);
531 }
532 break;
533
534 case RTM_DELETE:
535 saved_nrt = NULL;
536 /* support for new ARP code */
537 if (info.rti_info[RTAX_GATEWAY] &&
522 error = lla_rt_output(rtm, &info);
523 break;
524 }
525 error = rtrequest1_fib(RTM_ADD, &info, &saved_nrt,
526 so->so_fibnum);
527 if (error == 0 && saved_nrt) {
528 RT_LOCK(saved_nrt);
529 rt_setmetrics(rtm->rtm_inits,
530 &rtm->rtm_rmx, &saved_nrt->rt_rmx);
531 rtm->rtm_index = saved_nrt->rt_ifp->if_index;
532 RT_REMREF(saved_nrt);
533 RT_UNLOCK(saved_nrt);
534 }
535 break;
536
537 case RTM_DELETE:
538 saved_nrt = NULL;
539 /* support for new ARP code */
540 if (info.rti_info[RTAX_GATEWAY] &&
538 (info.rti_info[RTAX_GATEWAY]->sa_family == AF_LINK)) {
541 (info.rti_info[RTAX_GATEWAY]->sa_family == AF_LINK) &&
542 (rtm->rtm_flags & RTF_LLDATA) != 0) {
539 error = lla_rt_output(rtm, &info);
540 break;
541 }
542 error = rtrequest1_fib(RTM_DELETE, &info, &saved_nrt,
543 so->so_fibnum);
544 if (error == 0) {
545 RT_LOCK(saved_nrt);
546 rt = saved_nrt;

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

1422
1423 case NET_RT_DUMP:
1424 case NET_RT_FLAGS:
1425 if (af == 0) { /* dump all tables */
1426 i = 1;
1427 lim = AF_MAX;
1428 } else /* dump only one table */
1429 i = lim = af;
543 error = lla_rt_output(rtm, &info);
544 break;
545 }
546 error = rtrequest1_fib(RTM_DELETE, &info, &saved_nrt,
547 so->so_fibnum);
548 if (error == 0) {
549 RT_LOCK(saved_nrt);
550 rt = saved_nrt;

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

1426
1427 case NET_RT_DUMP:
1428 case NET_RT_FLAGS:
1429 if (af == 0) { /* dump all tables */
1430 i = 1;
1431 lim = AF_MAX;
1432 } else /* dump only one table */
1433 i = lim = af;
1434
1435 /*
1436 * take care of llinfo entries, the caller must
1437 * specify an AF
1438 */
1439 if (w.w_op == NET_RT_FLAGS && w.w_arg == 0) {
1440 if (af != 0)
1441 error = lltable_sysctl_dumparp(af, w.w_req);
1442 else
1443 error = EINVAL;
1444 break;
1445 }
1446 /*
1447 * take care of routing entries
1448 */
1430 for (error = 0; error == 0 && i <= lim; i++)
1431 if ((rnh = V_rt_tables[curthread->td_proc->p_fibnum][i]) != NULL) {
1432 RADIX_NODE_HEAD_LOCK(rnh);
1433 error = rnh->rnh_walktree(rnh,
1434 sysctl_dumpentry, &w);
1435 RADIX_NODE_HEAD_UNLOCK(rnh);
1436 } else if (af != 0)
1437 error = EAFNOSUPPORT;
1449 for (error = 0; error == 0 && i <= lim; i++)
1450 if ((rnh = V_rt_tables[curthread->td_proc->p_fibnum][i]) != NULL) {
1451 RADIX_NODE_HEAD_LOCK(rnh);
1452 error = rnh->rnh_walktree(rnh,
1453 sysctl_dumpentry, &w);
1454 RADIX_NODE_HEAD_UNLOCK(rnh);
1455 } else if (af != 0)
1456 error = EAFNOSUPPORT;
1438 /*
1439 * take care of llinfo entries
1440 */
1441 if (w.w_op == NET_RT_FLAGS)
1442 error = lltable_sysctl_dumparp(af, w.w_req);
1443 break;
1444
1445 case NET_RT_IFLIST:
1446 error = sysctl_iflist(af, &w);
1447 break;
1448
1449 case NET_RT_IFMALIST:
1450 error = sysctl_ifmalist(af, &w);

--- 35 unchanged lines hidden ---
1457 break;
1458
1459 case NET_RT_IFLIST:
1460 error = sysctl_iflist(af, &w);
1461 break;
1462
1463 case NET_RT_IFMALIST:
1464 error = sysctl_ifmalist(af, &w);

--- 35 unchanged lines hidden ---