Deleted Added
full compact
udp_usrreq.c (205251) udp_usrreq.c (207369)
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 * 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 * @(#)udp_usrreq.c 8.6 (Berkeley) 5/23/95
32 */
33
34#include <sys/cdefs.h>
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 * 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 * @(#)udp_usrreq.c 8.6 (Berkeley) 5/23/95
32 */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: head/sys/netinet/udp_usrreq.c 205251 2010-03-17 18:28:27Z bz $");
35__FBSDID("$FreeBSD: head/sys/netinet/udp_usrreq.c 207369 2010-04-29 11:52:42Z bz $");
36
37#include "opt_ipfw.h"
38#include "opt_inet6.h"
39#include "opt_ipsec.h"
40
41#include <sys/param.h>
42#include <sys/domain.h>
43#include <sys/eventhandler.h>

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

89
90#include <security/mac/mac_framework.h>
91
92/*
93 * UDP protocol implementation.
94 * Per RFC 768, August, 1980.
95 */
96
36
37#include "opt_ipfw.h"
38#include "opt_inet6.h"
39#include "opt_ipsec.h"
40
41#include <sys/param.h>
42#include <sys/domain.h>
43#include <sys/eventhandler.h>

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

89
90#include <security/mac/mac_framework.h>
91
92/*
93 * UDP protocol implementation.
94 * Per RFC 768, August, 1980.
95 */
96
97VNET_DEFINE(int, udp_blackhole);
98
99/*
100 * BSD 4.2 defaulted the udp checksum to be off. Turning off udp checksums
101 * removes the only data integrity mechanism for packets and malformed
102 * packets that would otherwise be discarded due to bad checksums, and may
103 * cause problems (especially for NFS data blocks).
104 */
105static int udp_cksum = 1;
106SYSCTL_INT(_net_inet_udp, UDPCTL_CHECKSUM, checksum, CTLFLAG_RW, &udp_cksum,
107 0, "compute udp checksum");
108
109int udp_log_in_vain = 0;
110SYSCTL_INT(_net_inet_udp, OID_AUTO, log_in_vain, CTLFLAG_RW,
111 &udp_log_in_vain, 0, "Log all incoming UDP packets");
112
97/*
98 * BSD 4.2 defaulted the udp checksum to be off. Turning off udp checksums
99 * removes the only data integrity mechanism for packets and malformed
100 * packets that would otherwise be discarded due to bad checksums, and may
101 * cause problems (especially for NFS data blocks).
102 */
103static int udp_cksum = 1;
104SYSCTL_INT(_net_inet_udp, UDPCTL_CHECKSUM, checksum, CTLFLAG_RW, &udp_cksum,
105 0, "compute udp checksum");
106
107int udp_log_in_vain = 0;
108SYSCTL_INT(_net_inet_udp, OID_AUTO, log_in_vain, CTLFLAG_RW,
109 &udp_log_in_vain, 0, "Log all incoming UDP packets");
110
111VNET_DEFINE(int, udp_blackhole) = 0;
113SYSCTL_VNET_INT(_net_inet_udp, OID_AUTO, blackhole, CTLFLAG_RW,
114 &VNET_NAME(udp_blackhole), 0,
115 "Do not send port unreachables for refused connects");
116
117u_long udp_sendspace = 9216; /* really max datagram size */
118 /* 40 1K datagrams */
119SYSCTL_ULONG(_net_inet_udp, UDPCTL_MAXDGRAM, maxdgram, CTLFLAG_RW,
120 &udp_sendspace, 0, "Maximum outgoing UDP datagram size");

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

128 );
129
130SYSCTL_ULONG(_net_inet_udp, UDPCTL_RECVSPACE, recvspace, CTLFLAG_RW,
131 &udp_recvspace, 0, "Maximum space for incoming UDP datagrams");
132
133VNET_DEFINE(struct inpcbhead, udb); /* from udp_var.h */
134VNET_DEFINE(struct inpcbinfo, udbinfo);
135static VNET_DEFINE(uma_zone_t, udpcb_zone);
112SYSCTL_VNET_INT(_net_inet_udp, OID_AUTO, blackhole, CTLFLAG_RW,
113 &VNET_NAME(udp_blackhole), 0,
114 "Do not send port unreachables for refused connects");
115
116u_long udp_sendspace = 9216; /* really max datagram size */
117 /* 40 1K datagrams */
118SYSCTL_ULONG(_net_inet_udp, UDPCTL_MAXDGRAM, maxdgram, CTLFLAG_RW,
119 &udp_sendspace, 0, "Maximum outgoing UDP datagram size");

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

127 );
128
129SYSCTL_ULONG(_net_inet_udp, UDPCTL_RECVSPACE, recvspace, CTLFLAG_RW,
130 &udp_recvspace, 0, "Maximum space for incoming UDP datagrams");
131
132VNET_DEFINE(struct inpcbhead, udb); /* from udp_var.h */
133VNET_DEFINE(struct inpcbinfo, udbinfo);
134static VNET_DEFINE(uma_zone_t, udpcb_zone);
136VNET_DEFINE(struct udpstat, udpstat); /* from udp_var.h */
137
138#define V_udpcb_zone VNET(udpcb_zone)
139
140#ifndef UDBHASHSIZE
141#define UDBHASHSIZE 128
142#endif
143
135#define V_udpcb_zone VNET(udpcb_zone)
136
137#ifndef UDBHASHSIZE
138#define UDBHASHSIZE 128
139#endif
140
141VNET_DEFINE(struct udpstat, udpstat); /* from udp_var.h */
144SYSCTL_VNET_STRUCT(_net_inet_udp, UDPCTL_STATS, stats, CTLFLAG_RW,
145 &VNET_NAME(udpstat), udpstat,
146 "UDP statistics (struct udpstat, netinet/udp_var.h)");
147
148static void udp_detach(struct socket *so);
149static int udp_output(struct inpcb *, struct mbuf *, struct sockaddr *,
150 struct mbuf *, struct thread *);
151#ifdef IPSEC

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

174 INP_LOCK_INIT(inp, "inp", "udpinp");
175 return (0);
176}
177
178void
179udp_init(void)
180{
181
142SYSCTL_VNET_STRUCT(_net_inet_udp, UDPCTL_STATS, stats, CTLFLAG_RW,
143 &VNET_NAME(udpstat), udpstat,
144 "UDP statistics (struct udpstat, netinet/udp_var.h)");
145
146static void udp_detach(struct socket *so);
147static int udp_output(struct inpcb *, struct mbuf *, struct sockaddr *,
148 struct mbuf *, struct thread *);
149#ifdef IPSEC

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

172 INP_LOCK_INIT(inp, "inp", "udpinp");
173 return (0);
174}
175
176void
177udp_init(void)
178{
179
182 V_udp_blackhole = 0;
183 in_pcbinfo_init(&V_udbinfo, "udp", &V_udb, UDBHASHSIZE, UDBHASHSIZE,
184 "udp_inpcb", udp_inpcb_init, NULL, UMA_ZONE_NOFREE);
185 V_udpcb_zone = uma_zcreate("udpcb", sizeof(struct udpcb),
186 NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE);
187 uma_zone_set_max(V_udpcb_zone, maxsockets);
188 EVENTHANDLER_REGISTER(maxsockets_change, udp_zone_change, NULL,
189 EVENTHANDLER_PRI_ANY);
190}

--- 1424 unchanged lines hidden ---
180 in_pcbinfo_init(&V_udbinfo, "udp", &V_udb, UDBHASHSIZE, UDBHASHSIZE,
181 "udp_inpcb", udp_inpcb_init, NULL, UMA_ZONE_NOFREE);
182 V_udpcb_zone = uma_zcreate("udpcb", sizeof(struct udpcb),
183 NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE);
184 uma_zone_set_max(V_udpcb_zone, maxsockets);
185 EVENTHANDLER_REGISTER(maxsockets_change, udp_zone_change, NULL,
186 EVENTHANDLER_PRI_ANY);
187}

--- 1424 unchanged lines hidden ---