in_pcb.c (118607) | in_pcb.c (120727) |
---|---|
1/* 2 * Copyright (c) 1982, 1986, 1991, 1993, 1995 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 --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)in_pcb.c 8.4 (Berkeley) 5/24/95 | 1/* 2 * Copyright (c) 1982, 1986, 1991, 1993, 1995 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 --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)in_pcb.c 8.4 (Berkeley) 5/24/95 |
34 * $FreeBSD: head/sys/netinet/in_pcb.c 118607 2003-08-07 15:04:27Z jhb $ | 34 * $FreeBSD: head/sys/netinet/in_pcb.c 120727 2003-10-04 03:44:50Z sam $ |
35 */ 36 37#include "opt_ipsec.h" 38#include "opt_inet6.h" 39 40#include <sys/param.h> 41#include <sys/systm.h> 42#include <sys/limits.h> --- 117 unchanged lines hidden (view full) --- 160 struct socket *so; 161 struct inpcbinfo *pcbinfo; 162 struct thread *td; 163{ 164 register struct inpcb *inp; 165#ifdef IPSEC 166 int error; 167#endif | 35 */ 36 37#include "opt_ipsec.h" 38#include "opt_inet6.h" 39 40#include <sys/param.h> 41#include <sys/systm.h> 42#include <sys/limits.h> --- 117 unchanged lines hidden (view full) --- 160 struct socket *so; 161 struct inpcbinfo *pcbinfo; 162 struct thread *td; 163{ 164 register struct inpcb *inp; 165#ifdef IPSEC 166 int error; 167#endif |
168 169 inp = uma_zalloc(pcbinfo->ipi_zone, M_NOWAIT); | 168 inp = uma_zalloc(pcbinfo->ipi_zone, M_NOWAIT | M_ZERO); |
170 if (inp == NULL) 171 return (ENOBUFS); | 169 if (inp == NULL) 170 return (ENOBUFS); |
172 bzero((caddr_t)inp, sizeof(*inp)); | |
173 inp->inp_gencnt = ++pcbinfo->ipi_gencnt; 174 inp->inp_pcbinfo = pcbinfo; 175 inp->inp_socket = so; 176#ifdef IPSEC 177 error = ipsec_init_policy(so, &inp->inp_sp); 178 if (error != 0) { 179 uma_zfree(pcbinfo->ipi_zone, inp); 180 return error; --- 492 unchanged lines hidden (view full) --- 673 in_pcbremlists(inp); 674 if (so) { 675 so->so_pcb = 0; 676 sotryfree(so); 677 } 678 if (inp->inp_options) 679 (void)m_free(inp->inp_options); 680 if (inp->inp_route.ro_rt) | 171 inp->inp_gencnt = ++pcbinfo->ipi_gencnt; 172 inp->inp_pcbinfo = pcbinfo; 173 inp->inp_socket = so; 174#ifdef IPSEC 175 error = ipsec_init_policy(so, &inp->inp_sp); 176 if (error != 0) { 177 uma_zfree(pcbinfo->ipi_zone, inp); 178 return error; --- 492 unchanged lines hidden (view full) --- 671 in_pcbremlists(inp); 672 if (so) { 673 so->so_pcb = 0; 674 sotryfree(so); 675 } 676 if (inp->inp_options) 677 (void)m_free(inp->inp_options); 678 if (inp->inp_route.ro_rt) |
681 rtfree(inp->inp_route.ro_rt); | 679 RTFREE(inp->inp_route.ro_rt); |
682 ip_freemoptions(inp->inp_moptions); 683 inp->inp_vflag = 0; 684 INP_LOCK_DESTROY(inp); 685 uma_zfree(ipi->ipi_zone, inp); 686} 687 688struct sockaddr * 689in_sockaddr(port, addr_p) --- 170 unchanged lines hidden (view full) --- 860void 861in_losing(inp) 862 struct inpcb *inp; 863{ 864 register struct rtentry *rt; 865 struct rt_addrinfo info; 866 867 if ((rt = inp->inp_route.ro_rt)) { | 680 ip_freemoptions(inp->inp_moptions); 681 inp->inp_vflag = 0; 682 INP_LOCK_DESTROY(inp); 683 uma_zfree(ipi->ipi_zone, inp); 684} 685 686struct sockaddr * 687in_sockaddr(port, addr_p) --- 170 unchanged lines hidden (view full) --- 858void 859in_losing(inp) 860 struct inpcb *inp; 861{ 862 register struct rtentry *rt; 863 struct rt_addrinfo info; 864 865 if ((rt = inp->inp_route.ro_rt)) { |
866 RT_LOCK(rt); 867 inp->inp_route.ro_rt = NULL; |
|
868 bzero((caddr_t)&info, sizeof(info)); 869 info.rti_flags = rt->rt_flags; 870 info.rti_info[RTAX_DST] = rt_key(rt); 871 info.rti_info[RTAX_GATEWAY] = rt->rt_gateway; 872 info.rti_info[RTAX_NETMASK] = rt_mask(rt); 873 rt_missmsg(RTM_LOSING, &info, rt->rt_flags, 0); | 868 bzero((caddr_t)&info, sizeof(info)); 869 info.rti_flags = rt->rt_flags; 870 info.rti_info[RTAX_DST] = rt_key(rt); 871 info.rti_info[RTAX_GATEWAY] = rt->rt_gateway; 872 info.rti_info[RTAX_NETMASK] = rt_mask(rt); 873 rt_missmsg(RTM_LOSING, &info, rt->rt_flags, 0); |
874 if (rt->rt_flags & RTF_DYNAMIC) | 874 if (rt->rt_flags & RTF_DYNAMIC) { 875 RT_UNLOCK(rt); /* XXX refcnt? */ |
875 (void) rtrequest1(RTM_DELETE, &info, NULL); | 876 (void) rtrequest1(RTM_DELETE, &info, NULL); |
876 inp->inp_route.ro_rt = NULL; 877 rtfree(rt); | 877 } else 878 rtfree(rt); |
878 /* 879 * A new route can be allocated 880 * the next time output is attempted. 881 */ 882 } 883} 884 885/* 886 * After a routing change, flush old routing 887 * and allocate a (hopefully) better one. 888 */ 889struct inpcb * 890in_rtchange(inp, errno) 891 register struct inpcb *inp; 892 int errno; 893{ 894 if (inp->inp_route.ro_rt) { | 879 /* 880 * A new route can be allocated 881 * the next time output is attempted. 882 */ 883 } 884} 885 886/* 887 * After a routing change, flush old routing 888 * and allocate a (hopefully) better one. 889 */ 890struct inpcb * 891in_rtchange(inp, errno) 892 register struct inpcb *inp; 893 int errno; 894{ 895 if (inp->inp_route.ro_rt) { |
895 rtfree(inp->inp_route.ro_rt); | 896 RTFREE(inp->inp_route.ro_rt); |
896 inp->inp_route.ro_rt = 0; 897 /* 898 * A new route can be allocated the next time 899 * output is attempted. 900 */ 901 } 902 return inp; 903} --- 278 unchanged lines hidden --- | 897 inp->inp_route.ro_rt = 0; 898 /* 899 * A new route can be allocated the next time 900 * output is attempted. 901 */ 902 } 903 return inp; 904} --- 278 unchanged lines hidden --- |