1/*-
2 * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
3 * The Regents of the University of California.
4 * Copyright (c) 2008 Robert N. M. Watson
5 * Copyright (c) 2010-2011 Juniper Networks, Inc.
6 * All rights reserved.
7 *
8 * Portions of this software were developed by Robert N. M. Watson under
--- 22 unchanged lines hidden (view full) ---
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * @(#)udp_usrreq.c 8.6 (Berkeley) 5/23/95
36 */
37
38#include <sys/cdefs.h>
39__FBSDID("$FreeBSD: head/sys/netinet/udp_usrreq.c 253571 2013-07-23 14:14:24Z ae $");
40
41#include "opt_ipfw.h"
42#include "opt_inet.h"
43#include "opt_inet6.h"
44#include "opt_ipsec.h"
45
46#include <sys/param.h>
47#include <sys/domain.h>
48#include <sys/eventhandler.h>
49#include <sys/jail.h>
50#include <sys/kernel.h>
51#include <sys/lock.h>
52#include <sys/malloc.h>
53#include <sys/mbuf.h>
54#include <sys/priv.h>
55#include <sys/proc.h>
56#include <sys/protosw.h>
57#include <sys/signalvar.h>
58#include <sys/socket.h>
59#include <sys/socketvar.h>
60#include <sys/sx.h>
61#include <sys/sysctl.h>
62#include <sys/syslog.h>
63#include <sys/systm.h>
64
65#include <vm/uma.h>
66
67#include <net/if.h>
68#include <net/route.h>
69
70#include <netinet/in.h>
71#include <netinet/in_pcb.h>
72#include <netinet/in_systm.h>
73#include <netinet/in_var.h>
74#include <netinet/ip.h>
75#ifdef INET6
76#include <netinet/ip6.h>
77#endif
78#include <netinet/ip_icmp.h>
--- 532 unchanged lines hidden (view full) ---
611 * Check the minimum TTL for socket.
612 */
613 INP_RLOCK_ASSERT(inp);
614 if (inp->inp_ip_minttl && inp->inp_ip_minttl > ip->ip_ttl) {
615 INP_RUNLOCK(inp);
616 m_freem(m);
617 return;
618 }
619 udp_append(inp, ip, m, iphlen, &udp_in);
620 INP_RUNLOCK(inp);
621 return;
622
623badunlocked:
624 m_freem(m);
625}
626#endif /* INET */
--- 561 unchanged lines hidden (view full) ---
1188 m->m_pkthdr.len -= max_linkhdr;
1189
1190 /*
1191 * Fill in mbuf with extended UDP header and addresses and length put
1192 * into network format.
1193 */
1194 ui = mtod(m, struct udpiphdr *);
1195 bzero(ui->ui_x1, sizeof(ui->ui_x1)); /* XXX still needed? */
1196 ui->ui_pr = IPPROTO_UDP;
1197 ui->ui_src = laddr;
1198 ui->ui_dst = faddr;
1199 ui->ui_sport = lport;
1200 ui->ui_dport = fport;
1201 ui->ui_ulen = htons((u_short)len + sizeof(struct udphdr));
1202
1203 /*
--- 34 unchanged lines hidden (view full) ---
1238 ((struct ip *)ui)->ip_ttl = inp->inp_ip_ttl; /* XXX */
1239 ((struct ip *)ui)->ip_tos = tos; /* XXX */
1240 UDPSTAT_INC(udps_opackets);
1241
1242 if (unlock_udbinfo == UH_WLOCKED)
1243 INP_HASH_WUNLOCK(&V_udbinfo);
1244 else if (unlock_udbinfo == UH_RLOCKED)
1245 INP_HASH_RUNLOCK(&V_udbinfo);
1246 error = ip_output(m, inp->inp_options, NULL, ipflags,
1247 inp->inp_moptions, inp);
1248 if (unlock_udbinfo == UH_WLOCKED)
1249 INP_WUNLOCK(inp);
1250 else
1251 INP_RUNLOCK(inp);
1252 return (error);
1253
--- 375 unchanged lines hidden ---
2 * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
3 * The Regents of the University of California.
4 * Copyright (c) 2008 Robert N. M. Watson
5 * Copyright (c) 2010-2011 Juniper Networks, Inc.
6 * All rights reserved.
7 *
8 * Portions of this software were developed by Robert N. M. Watson under
--- 22 unchanged lines hidden (view full) ---
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * @(#)udp_usrreq.c 8.6 (Berkeley) 5/23/95
36 */
37
38#include <sys/cdefs.h>
39__FBSDID("$FreeBSD: head/sys/netinet/udp_usrreq.c 253571 2013-07-23 14:14:24Z ae $");
40
41#include "opt_ipfw.h"
42#include "opt_inet.h"
43#include "opt_inet6.h"
44#include "opt_ipsec.h"
45
46#include <sys/param.h>
47#include <sys/domain.h>
48#include <sys/eventhandler.h>
49#include <sys/jail.h>
50#include <sys/kernel.h>
51#include <sys/lock.h>
52#include <sys/malloc.h>
53#include <sys/mbuf.h>
54#include <sys/priv.h>
55#include <sys/proc.h>
56#include <sys/protosw.h>
57#include <sys/signalvar.h>
58#include <sys/socket.h>
59#include <sys/socketvar.h>
60#include <sys/sx.h>
61#include <sys/sysctl.h>
62#include <sys/syslog.h>
63#include <sys/systm.h>
64
65#include <vm/uma.h>
66
67#include <net/if.h>
68#include <net/route.h>
69
70#include <netinet/in.h>
71#include <netinet/in_pcb.h>
72#include <netinet/in_systm.h>
73#include <netinet/in_var.h>
74#include <netinet/ip.h>
75#ifdef INET6
76#include <netinet/ip6.h>
77#endif
78#include <netinet/ip_icmp.h>
--- 532 unchanged lines hidden (view full) ---
611 * Check the minimum TTL for socket.
612 */
613 INP_RLOCK_ASSERT(inp);
614 if (inp->inp_ip_minttl && inp->inp_ip_minttl > ip->ip_ttl) {
615 INP_RUNLOCK(inp);
616 m_freem(m);
617 return;
618 }
619 udp_append(inp, ip, m, iphlen, &udp_in);
620 INP_RUNLOCK(inp);
621 return;
622
623badunlocked:
624 m_freem(m);
625}
626#endif /* INET */
--- 561 unchanged lines hidden (view full) ---
1188 m->m_pkthdr.len -= max_linkhdr;
1189
1190 /*
1191 * Fill in mbuf with extended UDP header and addresses and length put
1192 * into network format.
1193 */
1194 ui = mtod(m, struct udpiphdr *);
1195 bzero(ui->ui_x1, sizeof(ui->ui_x1)); /* XXX still needed? */
1196 ui->ui_pr = IPPROTO_UDP;
1197 ui->ui_src = laddr;
1198 ui->ui_dst = faddr;
1199 ui->ui_sport = lport;
1200 ui->ui_dport = fport;
1201 ui->ui_ulen = htons((u_short)len + sizeof(struct udphdr));
1202
1203 /*
--- 34 unchanged lines hidden (view full) ---
1238 ((struct ip *)ui)->ip_ttl = inp->inp_ip_ttl; /* XXX */
1239 ((struct ip *)ui)->ip_tos = tos; /* XXX */
1240 UDPSTAT_INC(udps_opackets);
1241
1242 if (unlock_udbinfo == UH_WLOCKED)
1243 INP_HASH_WUNLOCK(&V_udbinfo);
1244 else if (unlock_udbinfo == UH_RLOCKED)
1245 INP_HASH_RUNLOCK(&V_udbinfo);
1246 error = ip_output(m, inp->inp_options, NULL, ipflags,
1247 inp->inp_moptions, inp);
1248 if (unlock_udbinfo == UH_WLOCKED)
1249 INP_WUNLOCK(inp);
1250 else
1251 INP_RUNLOCK(inp);
1252 return (error);
1253
--- 375 unchanged lines hidden ---