rtsock.c (188149) | rtsock.c (191080) |
---|---|
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 188149 2009-02-05 14:58:16Z jamie $ | 30 * $FreeBSD: head/sys/net/rtsock.c 191080 2009-04-14 23:05:36Z kmacy $ |
31 */ 32#include "opt_sctp.h" 33#include "opt_mpath.h" 34#include "opt_route.h" 35#include "opt_inet.h" 36#include "opt_inet6.h" 37 38#include <sys/param.h> --- 593 unchanged lines hidden (view full) --- 632 RT_UNLOCK(rt); 633 senderr(ENOBUFS); 634 } 635 bcopy(rtm, new_rtm, rtm->rtm_msglen); 636 Free(rtm); rtm = new_rtm; 637 } 638 (void)rt_msg2(rtm->rtm_type, &info, (caddr_t)rtm, NULL); 639 rtm->rtm_flags = rt->rt_flags; | 31 */ 32#include "opt_sctp.h" 33#include "opt_mpath.h" 34#include "opt_route.h" 35#include "opt_inet.h" 36#include "opt_inet6.h" 37 38#include <sys/param.h> --- 593 unchanged lines hidden (view full) --- 632 RT_UNLOCK(rt); 633 senderr(ENOBUFS); 634 } 635 bcopy(rtm, new_rtm, rtm->rtm_msglen); 636 Free(rtm); rtm = new_rtm; 637 } 638 (void)rt_msg2(rtm->rtm_type, &info, (caddr_t)rtm, NULL); 639 rtm->rtm_flags = rt->rt_flags; |
640 rtm->rtm_use = 0; | |
641 rt_getmetrics(&rt->rt_rmx, &rtm->rtm_rmx); 642 rtm->rtm_addrs = info.rti_addrs; 643 break; 644 645 case RTM_CHANGE: 646 /* 647 * New gateway could require new ifaddr, ifp; 648 * flags may also be different; ifp may be specified --- 37 unchanged lines hidden (view full) --- 686 } 687 if (info.rti_ifa != NULL && 688 info.rti_ifa != rt->rt_ifa) { 689 IFAREF(info.rti_ifa); 690 rt->rt_ifa = info.rti_ifa; 691 rt->rt_ifp = info.rti_ifp; 692 } 693 /* Allow some flags to be toggled on change. */ | 640 rt_getmetrics(&rt->rt_rmx, &rtm->rtm_rmx); 641 rtm->rtm_addrs = info.rti_addrs; 642 break; 643 644 case RTM_CHANGE: 645 /* 646 * New gateway could require new ifaddr, ifp; 647 * flags may also be different; ifp may be specified --- 37 unchanged lines hidden (view full) --- 685 } 686 if (info.rti_ifa != NULL && 687 info.rti_ifa != rt->rt_ifa) { 688 IFAREF(info.rti_ifa); 689 rt->rt_ifa = info.rti_ifa; 690 rt->rt_ifp = info.rti_ifp; 691 } 692 /* Allow some flags to be toggled on change. */ |
694 if (rtm->rtm_fmask & RTF_FMASK) 695 rt->rt_flags = (rt->rt_flags & 696 ~rtm->rtm_fmask) | 697 (rtm->rtm_flags & rtm->rtm_fmask); | 693 rt->rt_flags = (rt->rt_flags & ~RTF_FMASK) | 694 (rtm->rtm_flags & RTF_FMASK); |
698 rt_setmetrics(rtm->rtm_inits, &rtm->rtm_rmx, 699 &rt->rt_rmx); 700 rtm->rtm_index = rt->rt_ifp->if_index; 701 if (rt->rt_ifa && rt->rt_ifa->ifa_rtrequest) 702 rt->rt_ifa->ifa_rtrequest(RTM_ADD, rt, &info); 703 /* FALLTHROUGH */ 704 case RTM_LOCK: 705 /* We don't support locks anymore */ --- 62 unchanged lines hidden (view full) --- 768 struct rt_metrics_lite *out) 769{ 770#define metric(f, e) if (which & (f)) out->e = in->e; 771 /* 772 * Only these are stored in the routing entry since introduction 773 * of tcp hostcache. The rest is ignored. 774 */ 775 metric(RTV_MTU, rmx_mtu); | 695 rt_setmetrics(rtm->rtm_inits, &rtm->rtm_rmx, 696 &rt->rt_rmx); 697 rtm->rtm_index = rt->rt_ifp->if_index; 698 if (rt->rt_ifa && rt->rt_ifa->ifa_rtrequest) 699 rt->rt_ifa->ifa_rtrequest(RTM_ADD, rt, &info); 700 /* FALLTHROUGH */ 701 case RTM_LOCK: 702 /* We don't support locks anymore */ --- 62 unchanged lines hidden (view full) --- 765 struct rt_metrics_lite *out) 766{ 767#define metric(f, e) if (which & (f)) out->e = in->e; 768 /* 769 * Only these are stored in the routing entry since introduction 770 * of tcp hostcache. The rest is ignored. 771 */ 772 metric(RTV_MTU, rmx_mtu); |
773 metric(RTV_WEIGHT, rmx_weight); |
|
776 /* Userland -> kernel timebase conversion. */ 777 if (which & RTV_EXPIRE) 778 out->rmx_expire = in->rmx_expire ? 779 in->rmx_expire - time_second + time_uptime : 0; 780#undef metric 781} 782 783static void 784rt_getmetrics(const struct rt_metrics_lite *in, struct rt_metrics *out) 785{ 786#define metric(e) out->e = in->e; 787 bzero(out, sizeof(*out)); 788 metric(rmx_mtu); | 774 /* Userland -> kernel timebase conversion. */ 775 if (which & RTV_EXPIRE) 776 out->rmx_expire = in->rmx_expire ? 777 in->rmx_expire - time_second + time_uptime : 0; 778#undef metric 779} 780 781static void 782rt_getmetrics(const struct rt_metrics_lite *in, struct rt_metrics *out) 783{ 784#define metric(e) out->e = in->e; 785 bzero(out, sizeof(*out)); 786 metric(rmx_mtu); |
787 metric(rmx_weight); |
|
789 /* Kernel -> userland timebase conversion. */ 790 out->rmx_expire = in->rmx_expire ? 791 in->rmx_expire - time_uptime + time_second : 0; 792#undef metric 793} 794 795/* 796 * Extract the addresses of the passed sockaddrs. --- 455 unchanged lines hidden (view full) --- 1252 if (rt->rt_ifp->if_flags & IFF_POINTOPOINT) 1253 info.rti_info[RTAX_BRD] = rt->rt_ifa->ifa_dstaddr; 1254 } 1255 size = rt_msg2(RTM_GET, &info, NULL, w); 1256 if (w->w_req && w->w_tmem) { 1257 struct rt_msghdr *rtm = (struct rt_msghdr *)w->w_tmem; 1258 1259 rtm->rtm_flags = rt->rt_flags; | 788 /* Kernel -> userland timebase conversion. */ 789 out->rmx_expire = in->rmx_expire ? 790 in->rmx_expire - time_uptime + time_second : 0; 791#undef metric 792} 793 794/* 795 * Extract the addresses of the passed sockaddrs. --- 455 unchanged lines hidden (view full) --- 1251 if (rt->rt_ifp->if_flags & IFF_POINTOPOINT) 1252 info.rti_info[RTAX_BRD] = rt->rt_ifa->ifa_dstaddr; 1253 } 1254 size = rt_msg2(RTM_GET, &info, NULL, w); 1255 if (w->w_req && w->w_tmem) { 1256 struct rt_msghdr *rtm = (struct rt_msghdr *)w->w_tmem; 1257 1258 rtm->rtm_flags = rt->rt_flags; |
1260 rtm->rtm_use = rt->rt_rmx.rmx_pksent; | 1259 /* 1260 * let's be honest about this being a retarded hack 1261 */ 1262 rtm->rtm_fmask = rt->rt_rmx.rmx_pksent; |
1261 rt_getmetrics(&rt->rt_rmx, &rtm->rtm_rmx); 1262 rtm->rtm_index = rt->rt_ifp->if_index; 1263 rtm->rtm_errno = rtm->rtm_pid = rtm->rtm_seq = 0; 1264 rtm->rtm_addrs = info.rti_addrs; 1265 error = SYSCTL_OUT(w->w_req, (caddr_t)rtm, size); 1266 return (error); 1267 } 1268 return (error); --- 217 unchanged lines hidden --- | 1263 rt_getmetrics(&rt->rt_rmx, &rtm->rtm_rmx); 1264 rtm->rtm_index = rt->rt_ifp->if_index; 1265 rtm->rtm_errno = rtm->rtm_pid = rtm->rtm_seq = 0; 1266 rtm->rtm_addrs = info.rti_addrs; 1267 error = SYSCTL_OUT(w->w_req, (caddr_t)rtm, size); 1268 return (error); 1269 } 1270 return (error); --- 217 unchanged lines hidden --- |