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 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 |
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; |
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); |
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 */ |
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 |
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 --- |