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 254889 2013-08-25 21:54:41Z markj $");
40
41#include "opt_ipfw.h"
42#include "opt_inet.h"
43#include "opt_inet6.h"
44#include "opt_ipsec.h"
45#include "opt_kdtrace.h"
46
47#include <sys/param.h>
48#include <sys/domain.h>
49#include <sys/eventhandler.h>
50#include <sys/jail.h>
51#include <sys/kernel.h>
52#include <sys/lock.h>
53#include <sys/malloc.h>
54#include <sys/mbuf.h>
55#include <sys/priv.h>
56#include <sys/proc.h>
57#include <sys/protosw.h>
58#include <sys/sdt.h>
59#include <sys/signalvar.h>
60#include <sys/socket.h>
61#include <sys/socketvar.h>
62#include <sys/sx.h>
63#include <sys/sysctl.h>
64#include <sys/syslog.h>
65#include <sys/systm.h>
66
67#include <vm/uma.h>
68
69#include <net/if.h>
70#include <net/route.h>
71
72#include <netinet/in.h>
73#include <netinet/in_kdtrace.h>
74#include <netinet/in_pcb.h>
75#include <netinet/in_systm.h>
76#include <netinet/in_var.h>
77#include <netinet/ip.h>
78#ifdef INET6
79#include <netinet/ip6.h>
80#endif
81#include <netinet/ip_icmp.h>
--- 532 unchanged lines hidden (view full) ---
614 * Check the minimum TTL for socket.
615 */
616 INP_RLOCK_ASSERT(inp);
617 if (inp->inp_ip_minttl && inp->inp_ip_minttl > ip->ip_ttl) {
618 INP_RUNLOCK(inp);
619 m_freem(m);
620 return;
621 }
622
623 UDP_PROBE(receive, NULL, inp, ip, ip, uh);
624 udp_append(inp, ip, m, iphlen, &udp_in);
625 INP_RUNLOCK(inp);
626 return;
627
628badunlocked:
629 m_freem(m);
630}
631#endif /* INET */
--- 561 unchanged lines hidden (view full) ---
1193 m->m_pkthdr.len -= max_linkhdr;
1194
1195 /*
1196 * Fill in mbuf with extended UDP header and addresses and length put
1197 * into network format.
1198 */
1199 ui = mtod(m, struct udpiphdr *);
1200 bzero(ui->ui_x1, sizeof(ui->ui_x1)); /* XXX still needed? */
1201 ui->ui_v = IPVERSION << 4;
1202 ui->ui_pr = IPPROTO_UDP;
1203 ui->ui_src = laddr;
1204 ui->ui_dst = faddr;
1205 ui->ui_sport = lport;
1206 ui->ui_dport = fport;
1207 ui->ui_ulen = htons((u_short)len + sizeof(struct udphdr));
1208
1209 /*
--- 34 unchanged lines hidden (view full) ---
1244 ((struct ip *)ui)->ip_ttl = inp->inp_ip_ttl; /* XXX */
1245 ((struct ip *)ui)->ip_tos = tos; /* XXX */
1246 UDPSTAT_INC(udps_opackets);
1247
1248 if (unlock_udbinfo == UH_WLOCKED)
1249 INP_HASH_WUNLOCK(&V_udbinfo);
1250 else if (unlock_udbinfo == UH_RLOCKED)
1251 INP_HASH_RUNLOCK(&V_udbinfo);
1252 UDP_PROBE(send, NULL, inp, &ui->ui_i, inp, &ui->ui_u);
1253 error = ip_output(m, inp->inp_options, NULL, ipflags,
1254 inp->inp_moptions, inp);
1255 if (unlock_udbinfo == UH_WLOCKED)
1256 INP_WUNLOCK(inp);
1257 else
1258 INP_RUNLOCK(inp);
1259 return (error);
1260
--- 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 254889 2013-08-25 21:54:41Z markj $");
40
41#include "opt_ipfw.h"
42#include "opt_inet.h"
43#include "opt_inet6.h"
44#include "opt_ipsec.h"
45#include "opt_kdtrace.h"
46
47#include <sys/param.h>
48#include <sys/domain.h>
49#include <sys/eventhandler.h>
50#include <sys/jail.h>
51#include <sys/kernel.h>
52#include <sys/lock.h>
53#include <sys/malloc.h>
54#include <sys/mbuf.h>
55#include <sys/priv.h>
56#include <sys/proc.h>
57#include <sys/protosw.h>
58#include <sys/sdt.h>
59#include <sys/signalvar.h>
60#include <sys/socket.h>
61#include <sys/socketvar.h>
62#include <sys/sx.h>
63#include <sys/sysctl.h>
64#include <sys/syslog.h>
65#include <sys/systm.h>
66
67#include <vm/uma.h>
68
69#include <net/if.h>
70#include <net/route.h>
71
72#include <netinet/in.h>
73#include <netinet/in_kdtrace.h>
74#include <netinet/in_pcb.h>
75#include <netinet/in_systm.h>
76#include <netinet/in_var.h>
77#include <netinet/ip.h>
78#ifdef INET6
79#include <netinet/ip6.h>
80#endif
81#include <netinet/ip_icmp.h>
--- 532 unchanged lines hidden (view full) ---
614 * Check the minimum TTL for socket.
615 */
616 INP_RLOCK_ASSERT(inp);
617 if (inp->inp_ip_minttl && inp->inp_ip_minttl > ip->ip_ttl) {
618 INP_RUNLOCK(inp);
619 m_freem(m);
620 return;
621 }
622
623 UDP_PROBE(receive, NULL, inp, ip, ip, uh);
624 udp_append(inp, ip, m, iphlen, &udp_in);
625 INP_RUNLOCK(inp);
626 return;
627
628badunlocked:
629 m_freem(m);
630}
631#endif /* INET */
--- 561 unchanged lines hidden (view full) ---
1193 m->m_pkthdr.len -= max_linkhdr;
1194
1195 /*
1196 * Fill in mbuf with extended UDP header and addresses and length put
1197 * into network format.
1198 */
1199 ui = mtod(m, struct udpiphdr *);
1200 bzero(ui->ui_x1, sizeof(ui->ui_x1)); /* XXX still needed? */
1201 ui->ui_v = IPVERSION << 4;
1202 ui->ui_pr = IPPROTO_UDP;
1203 ui->ui_src = laddr;
1204 ui->ui_dst = faddr;
1205 ui->ui_sport = lport;
1206 ui->ui_dport = fport;
1207 ui->ui_ulen = htons((u_short)len + sizeof(struct udphdr));
1208
1209 /*
--- 34 unchanged lines hidden (view full) ---
1244 ((struct ip *)ui)->ip_ttl = inp->inp_ip_ttl; /* XXX */
1245 ((struct ip *)ui)->ip_tos = tos; /* XXX */
1246 UDPSTAT_INC(udps_opackets);
1247
1248 if (unlock_udbinfo == UH_WLOCKED)
1249 INP_HASH_WUNLOCK(&V_udbinfo);
1250 else if (unlock_udbinfo == UH_RLOCKED)
1251 INP_HASH_RUNLOCK(&V_udbinfo);
1252 UDP_PROBE(send, NULL, inp, &ui->ui_i, inp, &ui->ui_u);
1253 error = ip_output(m, inp->inp_options, NULL, ipflags,
1254 inp->inp_moptions, inp);
1255 if (unlock_udbinfo == UH_WLOCKED)
1256 INP_WUNLOCK(inp);
1257 else
1258 INP_RUNLOCK(inp);
1259 return (error);
1260
--- 375 unchanged lines hidden ---