ip_icmp.c (275985) | ip_icmp.c (286001) |
---|---|
1/*- 2 * Copyright (c) 1982, 1986, 1988, 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 --- 16 unchanged lines hidden (view full) --- 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 * @(#)ip_icmp.c 8.2 (Berkeley) 1/4/94 30 */ 31 32#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1982, 1986, 1988, 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 --- 16 unchanged lines hidden (view full) --- 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 * @(#)ip_icmp.c 8.2 (Berkeley) 1/4/94 30 */ 31 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: head/sys/netinet/ip_icmp.c 275985 2014-12-21 05:07:11Z imp $"); | 33__FBSDID("$FreeBSD: head/sys/netinet/ip_icmp.c 286001 2015-07-29 08:12:05Z ae $"); |
34 35#include "opt_inet.h" 36 37#include <sys/param.h> 38#include <sys/systm.h> 39#include <sys/mbuf.h> 40#include <sys/protosw.h> 41#include <sys/socket.h> 42#include <sys/time.h> 43#include <sys/kernel.h> | 34 35#include "opt_inet.h" 36 37#include <sys/param.h> 38#include <sys/systm.h> 39#include <sys/mbuf.h> 40#include <sys/protosw.h> 41#include <sys/socket.h> 42#include <sys/time.h> 43#include <sys/kernel.h> |
44#include <sys/lock.h> 45#include <sys/rmlock.h> |
|
44#include <sys/sysctl.h> 45#include <sys/syslog.h> 46 47#include <net/if.h> 48#include <net/if_var.h> 49#include <net/if_types.h> 50#include <net/route.h> 51#include <net/vnet.h> --- 590 unchanged lines hidden (view full) --- 642} 643 644/* 645 * Reflect the ip packet back to the source 646 */ 647static void 648icmp_reflect(struct mbuf *m) 649{ | 46#include <sys/sysctl.h> 47#include <sys/syslog.h> 48 49#include <net/if.h> 50#include <net/if_var.h> 51#include <net/if_types.h> 52#include <net/route.h> 53#include <net/vnet.h> --- 590 unchanged lines hidden (view full) --- 644} 645 646/* 647 * Reflect the ip packet back to the source 648 */ 649static void 650icmp_reflect(struct mbuf *m) 651{ |
652 struct rm_priotracker in_ifa_tracker; |
|
650 struct ip *ip = mtod(m, struct ip *); 651 struct ifaddr *ifa; 652 struct ifnet *ifp; 653 struct in_ifaddr *ia; 654 struct in_addr t; 655 struct mbuf *opts = 0; 656 int optlen = (ip->ip_hl << 2) - sizeof(struct ip); 657 --- 9 unchanged lines hidden (view full) --- 667 ip->ip_dst = ip->ip_src; 668 669 /* 670 * Source selection for ICMP replies: 671 * 672 * If the incoming packet was addressed directly to one of our 673 * own addresses, use dst as the src for the reply. 674 */ | 653 struct ip *ip = mtod(m, struct ip *); 654 struct ifaddr *ifa; 655 struct ifnet *ifp; 656 struct in_ifaddr *ia; 657 struct in_addr t; 658 struct mbuf *opts = 0; 659 int optlen = (ip->ip_hl << 2) - sizeof(struct ip); 660 --- 9 unchanged lines hidden (view full) --- 670 ip->ip_dst = ip->ip_src; 671 672 /* 673 * Source selection for ICMP replies: 674 * 675 * If the incoming packet was addressed directly to one of our 676 * own addresses, use dst as the src for the reply. 677 */ |
675 IN_IFADDR_RLOCK(); | 678 IN_IFADDR_RLOCK(&in_ifa_tracker); |
676 LIST_FOREACH(ia, INADDR_HASH(t.s_addr), ia_hash) { 677 if (t.s_addr == IA_SIN(ia)->sin_addr.s_addr) { 678 t = IA_SIN(ia)->sin_addr; | 679 LIST_FOREACH(ia, INADDR_HASH(t.s_addr), ia_hash) { 680 if (t.s_addr == IA_SIN(ia)->sin_addr.s_addr) { 681 t = IA_SIN(ia)->sin_addr; |
679 IN_IFADDR_RUNLOCK(); | 682 IN_IFADDR_RUNLOCK(&in_ifa_tracker); |
680 goto match; 681 } 682 } | 683 goto match; 684 } 685 } |
683 IN_IFADDR_RUNLOCK(); | 686 IN_IFADDR_RUNLOCK(&in_ifa_tracker); |
684 685 /* 686 * If the incoming packet was addressed to one of our broadcast 687 * addresses, use the first non-broadcast address which corresponds 688 * to the incoming interface. 689 */ 690 ifp = m->m_pkthdr.rcvif; 691 if (ifp != NULL && ifp->if_flags & IFF_BROADCAST) { --- 275 unchanged lines hidden --- | 687 688 /* 689 * If the incoming packet was addressed to one of our broadcast 690 * addresses, use the first non-broadcast address which corresponds 691 * to the incoming interface. 692 */ 693 ifp = m->m_pkthdr.rcvif; 694 if (ifp != NULL && ifp->if_flags & IFF_BROADCAST) { --- 275 unchanged lines hidden --- |