Deleted Added
full compact
in_pcb.c (194760) in_pcb.c (194951)
1/*-
2 * Copyright (c) 1982, 1986, 1991, 1993, 1995
3 * The Regents of the University of California.
4 * Copyright (c) 2007-2009 Robert N. M. Watson
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

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

27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * @(#)in_pcb.c 8.4 (Berkeley) 5/24/95
32 */
33
34#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1982, 1986, 1991, 1993, 1995
3 * The Regents of the University of California.
4 * Copyright (c) 2007-2009 Robert N. M. Watson
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

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

27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * @(#)in_pcb.c 8.4 (Berkeley) 5/24/95
32 */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: head/sys/netinet/in_pcb.c 194760 2009-06-23 20:19:09Z rwatson $");
35__FBSDID("$FreeBSD: head/sys/netinet/in_pcb.c 194951 2009-06-25 11:52:33Z rwatson $");
36
37#include "opt_ddb.h"
38#include "opt_ipsec.h"
39#include "opt_inet6.h"
40
41#include <sys/param.h>
42#include <sys/systm.h>
43#include <sys/malloc.h>

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

808 /*
809 * If the destination address is INADDR_ANY,
810 * use the primary local address.
811 * If the supplied address is INADDR_BROADCAST,
812 * and the primary interface supports broadcast,
813 * choose the broadcast address for that interface.
814 */
815 if (faddr.s_addr == INADDR_ANY) {
36
37#include "opt_ddb.h"
38#include "opt_ipsec.h"
39#include "opt_inet6.h"
40
41#include <sys/param.h>
42#include <sys/systm.h>
43#include <sys/malloc.h>

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

808 /*
809 * If the destination address is INADDR_ANY,
810 * use the primary local address.
811 * If the supplied address is INADDR_BROADCAST,
812 * and the primary interface supports broadcast,
813 * choose the broadcast address for that interface.
814 */
815 if (faddr.s_addr == INADDR_ANY) {
816 IN_IFADDR_RLOCK();
816 faddr =
817 IA_SIN(TAILQ_FIRST(&V_in_ifaddrhead))->sin_addr;
817 faddr =
818 IA_SIN(TAILQ_FIRST(&V_in_ifaddrhead))->sin_addr;
819 IN_IFADDR_RUNLOCK();
818 if (cred != NULL &&
819 (error = prison_get_ip4(cred, &faddr)) != 0)
820 return (error);
820 if (cred != NULL &&
821 (error = prison_get_ip4(cred, &faddr)) != 0)
822 return (error);
821 } else if (faddr.s_addr == (u_long)INADDR_BROADCAST &&
822 (TAILQ_FIRST(&V_in_ifaddrhead)->ia_ifp->if_flags &
823 IFF_BROADCAST))
824 faddr = satosin(&TAILQ_FIRST(
825 &V_in_ifaddrhead)->ia_broadaddr)->sin_addr;
823 } else if (faddr.s_addr == (u_long)INADDR_BROADCAST) {
824 IN_IFADDR_RLOCK();
825 if (TAILQ_FIRST(&V_in_ifaddrhead)->ia_ifp->if_flags &
826 IFF_BROADCAST)
827 faddr = satosin(&TAILQ_FIRST(
828 &V_in_ifaddrhead)->ia_broadaddr)->sin_addr;
829 IN_IFADDR_RUNLOCK();
830 }
826 }
827 if (laddr.s_addr == INADDR_ANY) {
828 error = in_pcbladdr(inp, &faddr, &laddr, cred);
829 if (error)
830 return (error);
831
832 /*
833 * If the destination address is multicast and an outgoing
834 * interface has been set as a multicast option, use the
835 * address of that interface as our source address.
836 */
837 if (IN_MULTICAST(ntohl(faddr.s_addr)) &&
838 inp->inp_moptions != NULL) {
839 struct ip_moptions *imo;
840 struct ifnet *ifp;
841
842 imo = inp->inp_moptions;
843 if (imo->imo_multicast_ifp != NULL) {
844 ifp = imo->imo_multicast_ifp;
831 }
832 if (laddr.s_addr == INADDR_ANY) {
833 error = in_pcbladdr(inp, &faddr, &laddr, cred);
834 if (error)
835 return (error);
836
837 /*
838 * If the destination address is multicast and an outgoing
839 * interface has been set as a multicast option, use the
840 * address of that interface as our source address.
841 */
842 if (IN_MULTICAST(ntohl(faddr.s_addr)) &&
843 inp->inp_moptions != NULL) {
844 struct ip_moptions *imo;
845 struct ifnet *ifp;
846
847 imo = inp->inp_moptions;
848 if (imo->imo_multicast_ifp != NULL) {
849 ifp = imo->imo_multicast_ifp;
850 IN_IFADDR_RLOCK();
845 TAILQ_FOREACH(ia, &V_in_ifaddrhead, ia_link)
846 if (ia->ia_ifp == ifp)
847 break;
851 TAILQ_FOREACH(ia, &V_in_ifaddrhead, ia_link)
852 if (ia->ia_ifp == ifp)
853 break;
848 if (ia == NULL)
854 if (ia == NULL) {
855 IN_IFADDR_RUNLOCK();
849 return (EADDRNOTAVAIL);
856 return (EADDRNOTAVAIL);
857 }
850 laddr = ia->ia_addr.sin_addr;
858 laddr = ia->ia_addr.sin_addr;
859 IN_IFADDR_RUNLOCK();
851 }
852 }
853 }
854
855 oinp = in_pcblookup_hash(inp->inp_pcbinfo, faddr, fport, laddr, lport,
856 0, NULL);
857 if (oinp != NULL) {
858 if (oinpp != NULL)

--- 1089 unchanged lines hidden ---
860 }
861 }
862 }
863
864 oinp = in_pcblookup_hash(inp->inp_pcbinfo, faddr, fport, laddr, lport,
865 0, NULL);
866 if (oinp != NULL) {
867 if (oinpp != NULL)

--- 1089 unchanged lines hidden ---