Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/raw_ip.c
| Show All 32 Lines | |||||
| */ | */ | ||||
| #include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
| __FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
| #include "opt_inet.h" | #include "opt_inet.h" | ||||
| #include "opt_inet6.h" | #include "opt_inet6.h" | ||||
| #include "opt_ipsec.h" | #include "opt_ipsec.h" | ||||
| #include "opt_route.h" | |||||
| #include <sys/param.h> | #include <sys/param.h> | ||||
| #include <sys/jail.h> | #include <sys/jail.h> | ||||
| #include <sys/kernel.h> | #include <sys/kernel.h> | ||||
| #include <sys/eventhandler.h> | #include <sys/eventhandler.h> | ||||
| #include <sys/lock.h> | #include <sys/lock.h> | ||||
| #include <sys/malloc.h> | #include <sys/malloc.h> | ||||
| #include <sys/mbuf.h> | #include <sys/mbuf.h> | ||||
| Show All 13 Lines | |||||
| #include <net/if.h> | #include <net/if.h> | ||||
| #include <net/if_var.h> | #include <net/if_var.h> | ||||
| #include <net/route.h> | #include <net/route.h> | ||||
| #include <net/vnet.h> | #include <net/vnet.h> | ||||
| #include <netinet/in.h> | #include <netinet/in.h> | ||||
| #include <netinet/in_systm.h> | #include <netinet/in_systm.h> | ||||
| #include <netinet/in_fib.h> | |||||
| #include <netinet/in_pcb.h> | #include <netinet/in_pcb.h> | ||||
| #include <netinet/in_var.h> | #include <netinet/in_var.h> | ||||
| #include <netinet/if_ether.h> | #include <netinet/if_ether.h> | ||||
| #include <netinet/ip.h> | #include <netinet/ip.h> | ||||
| #include <netinet/ip_var.h> | #include <netinet/ip_var.h> | ||||
| #include <netinet/ip_mroute.h> | #include <netinet/ip_mroute.h> | ||||
| #include <netinet/ip_icmp.h> | #include <netinet/ip_icmp.h> | ||||
| ▲ Show 20 Lines • Show All 401 Lines • ▼ Show 20 Lines | if ((inp->inp_flags & INP_HDRINCL) == 0) { | ||||
| if (inp->inp_flags & INP_DONTFRAG) | if (inp->inp_flags & INP_DONTFRAG) | ||||
| ip->ip_off = htons(IP_DF); | ip->ip_off = htons(IP_DF); | ||||
| else | else | ||||
| ip->ip_off = htons(0); | ip->ip_off = htons(0); | ||||
| ip->ip_p = inp->inp_ip_p; | ip->ip_p = inp->inp_ip_p; | ||||
| ip->ip_len = htons(m->m_pkthdr.len); | ip->ip_len = htons(m->m_pkthdr.len); | ||||
| ip->ip_src = inp->inp_laddr; | ip->ip_src = inp->inp_laddr; | ||||
| ip->ip_dst.s_addr = dst; | ip->ip_dst.s_addr = dst; | ||||
| #ifdef ROUTE_MPATH | |||||
| if (V_fib_hash_outbound) { | |||||
| uint32_t hash_type, hash_val; | |||||
| hash_val = fib4_calc_software_hash(ip->ip_src, | |||||
| ip->ip_dst, 0, 0, ip->ip_p, &hash_type); | |||||
| m->m_pkthdr.flowid = hash_val; | |||||
| M_HASHTYPE_SET(m, hash_type); | |||||
| flags |= IP_NODEFAULTFLOWID; | |||||
| } | |||||
| #endif | |||||
| if (jailed(inp->inp_cred)) { | if (jailed(inp->inp_cred)) { | ||||
| /* | /* | ||||
| * prison_local_ip4() would be good enough but would | * prison_local_ip4() would be good enough but would | ||||
| * let a source of INADDR_ANY pass, which we do not | * let a source of INADDR_ANY pass, which we do not | ||||
| * want to see from jails. | * want to see from jails. | ||||
| */ | */ | ||||
| if (ip->ip_src.s_addr == INADDR_ANY) { | if (ip->ip_src.s_addr == INADDR_ANY) { | ||||
| NET_EPOCH_ENTER(et); | NET_EPOCH_ENTER(et); | ||||
| Show All 19 Lines | #endif | ||||
| ip = mtod(m, struct ip *); | ip = mtod(m, struct ip *); | ||||
| hlen = ip->ip_hl << 2; | hlen = ip->ip_hl << 2; | ||||
| if (m->m_len < hlen) { | if (m->m_len < hlen) { | ||||
| m = m_pullup(m, hlen); | m = m_pullup(m, hlen); | ||||
| if (m == NULL) | if (m == NULL) | ||||
| return (EINVAL); | return (EINVAL); | ||||
| ip = mtod(m, struct ip *); | ip = mtod(m, struct ip *); | ||||
| } | } | ||||
| #ifdef ROUTE_MPATH | |||||
| if (V_fib_hash_outbound) { | |||||
| uint32_t hash_type, hash_val; | |||||
| hash_val = fib4_calc_software_hash(ip->ip_dst, | |||||
| ip->ip_src, 0, 0, ip->ip_p, &hash_type); | |||||
| m->m_pkthdr.flowid = hash_val; | |||||
| M_HASHTYPE_SET(m, hash_type); | |||||
| flags |= IP_NODEFAULTFLOWID; | |||||
| } | |||||
| #endif | |||||
| INP_RLOCK(inp); | INP_RLOCK(inp); | ||||
| /* | /* | ||||
| * Don't allow both user specified and setsockopt options, | * Don't allow both user specified and setsockopt options, | ||||
| * and don't allow packet length sizes that will crash. | * and don't allow packet length sizes that will crash. | ||||
| */ | */ | ||||
| if ((hlen < sizeof (*ip)) | if ((hlen < sizeof (*ip)) | ||||
| || ((hlen > sizeof (*ip)) && inp->inp_options) | || ((hlen > sizeof (*ip)) && inp->inp_options) | ||||
| || (ntohs(ip->ip_len) != m->m_pkthdr.len)) { | || (ntohs(ip->ip_len) != m->m_pkthdr.len)) { | ||||
| ▲ Show 20 Lines • Show All 630 Lines • Show Last 20 Lines | |||||