summaryrefslogtreecommitdiff
path: root/sys/netinet/udp_usrreq.c
AgeCommit message (Collapse)Author
2022-11-04inpcb: rename functions to inpcb_*ozaki-r
Inspired by rmind-smpnet patches.
2022-10-28inpcb: separate inpcb again to reduce the size of PCB for IPv4ozaki-r
The data size of PCB for IPv4 increased because of the merge of struct in6pcb. The change decreases the size to the original size by separating struct inpcb (again). struct in4pcb and in6pcb that embed struct inpcb are introduced. Even after the separation, users don't need to realize the separation and only have to use some macros to access dedicated data. For example, inp->inp_laddr is now accessed through in4p_laddr(inp).
2022-10-28inpcb: integrate data structures of PCB into oneozaki-r
Data structures of network protocol control blocks (PCBs), i.e., struct inpcb, in6pcb and inpcb_hdr, are not organized well. Users of the data structures have to handle them separately and thus the code is cluttered and duplicated. The commit integrates the data structures into one, struct inpcb. As a result, users of PCBs only have to handle just one data structure, so the code becomes simple. One drawback is that the data size of PCB for IPv4 increases by 40 bytes (from 248 bytes to 288 bytes).
2021-02-19- Make ALIGNED_POINTER use __alignof(t) instead of sizeof(t). This is morechristos
correct because it works with non-primitive types and provides the ABI alignment for the type the compiler will use. - Remove all the *_HDR_ALIGNMENT macros and asserts - Replace POINTER_ALIGNED_P with ACCESSIBLE_POINTER which is identical to ALIGNED_POINTER, but returns that the pointer is always aligned if the CPU supports unaligned accesses. [ as proposed in tech-kern ]
2021-02-14- centralize header align and pullup into a single inline functionchristos
- use a single macro to align pointers and expose the alignment, instead of hard-coding 3 in 1/2 the macros. - fix an issue in the ipv6 lt2p where it was aligning for ipv4 and pulling for ipv6.
2020-08-20[ozaki-r] Changes to the kernel core for wireguardriastradh
2018-12-27Remove unused arguments.maxv
2018-11-22Support IPv6 NAT-T. Implemented by hsuenaga@IIJ and ohishi@IIJ.knakahara
Add ATF later.
2018-09-14Use non-variadic function pointer in protosw::pr_input.maxv
2018-07-15Retire ipkdb entirely. The option was removed from the config filesmaxv
yesterday. ok kamil christos
2018-05-31Remove the non-IKE part of the computation, too.maxv
2018-05-31Remove support for non-IKE markers in the kernel. Discussed on tech-net@,maxv
and now in PR/53334. Basically non-IKE markers come from a deprecated draft, and our kernel code for them has never worked. Setsockopt will now reject UDP_ENCAP_ESPINUDP_NON_IKE. Perhaps we should also add a check in key_handle_natt_info(), to make sure we also reject UDP_ENCAP_ESPINUDP_NON_IKE in the SADB.
2018-05-18IP6_EXTHDR_GET -> M_REGION_GET, no functional change.maxv
2018-05-13Clarify ESP-in-UDP.maxv
2018-05-01Remove unused argument from udp4_espinudp, and remove unused includes.maxv
2018-04-28Remove unused ipsec_var.h includes.maxv
2018-04-13Improve the check, we want to have len >= udphdr all the time, and notmaxv
just when the packet size doesn't match the mbuf size. Normally that's not a huge problem, since IP6_EXTHDR_GET gets called earlier, so we can't have (ip_len == iphlen + len) && (len < sizeof(struct udphdr))
2018-04-12Remove misleading comment; we're just checking the SP, not verifying themaxv
AH/ESP payload. While here style a bit.
2018-03-19socket: report receive buffer overflowsroy
Add soroverflow() which increments the overflow counter, sets so_error to ENOBUFS and wakes the receive socket up. Replace all code that manually increments this counter with soroverflow(). Add soroverflow() to raw_input(). This allows userland to detect route(4) overflows so it can re-sync with the current state.
2018-02-28Remove unused ipsec_private.h includes.maxv
2018-02-28Remove duplicate IPSEC_STATINC(IPSEC_STAT_IN_POLVIO), ipsec_in_rejectmaxv
already increases it. IPSEC6_STATINC is now unused, so remove it too.
2018-02-26Dedup: merge ipsec4_in_reject and ipsec6_in_reject into ipsec_in_reject.maxv
While here fix misleading comment. ok ozaki-r@
2018-02-14Revert my two last changes in this file. They are apparently causingmaxv
problems with racoon, I'll investigate this later.
2018-02-12Don't rebase the pointers. 'm' is only allowed to become NULL (whichmaxv
means 'processed').
2018-02-10If the socket wants a ESP-over-UDP packet, and the packet is incorrect,maxv
stop processing it instead of giving it to udp4_sendup. It just doesn't make any sense not to drop it. I was already telling myself this the other day when I visited this place, but I just saw PR/36782 (11 years old) that suggests the exact same thing, so fix it. Now, udp4_espinudp always frees the mbuf, and is made void. The packet is not processed any further afterwards.
2018-02-08More style, no functional change.maxv
2018-02-08Style, and remove printfs.maxv
2018-02-08Fix three pretty bad mistakes in NAT-T:maxv
* If we got a keepalive packet, we need to call m_freem, not m_free. Here the next mbufs in the chain are not freed. Seems easy to remotely DoS the system by sending fragmented keepalives in a loop. * If !ipsec_used, free the mbuf. * In udp_input, we need to update 'uh', because udp4_realinput may have modified the chain. Perhaps we also need to re-enforce alignment, so add an XXX.
2017-12-11As is the case with IPV6_PKTINFO, IP_PKTINFO can be sent without EADDRINUSEryo
even if the UDP address:port in use is specified.
2017-08-10Add support IP_PKTINFO for sendmsg(2).ryo
The source address or output interface can be specified by adding IP_PKTINFO to the control part of the message on a SOCK_DGRAM or SOCK_RAW socket. Reviewed by ozaki-r@ and christos@. thanks.
2017-07-06Merge the two copies SO_TIMESTAMP/SO_OTIMESTAMP processing to a singlechristos
function, and add a SOOPT_TIMESTAMP define reducing compat pollution from 5 places to 1.
2017-04-20Remove unnecessary NULL checks for inp_socket and in6p_socketozaki-r
They cannot be NULL except for programming errors.
2017-04-20Simplify logic of udp4_sendup and udp6_sendupozaki-r
They are always passed a socket with the same protocol faimiliy as its own: AF_INET for udp4_sendup and AF_INET6 for udp6_sendup.
2017-03-03Pass inpcb/in6pcb instead of socket to ip_output/ip6_outputozaki-r
- Passing a socket to Layer 3 is layer violation and even unnecessary - The change makes codes of callers and IPsec a bit simple
2017-01-24Tweak softnet_lock and NET_MPSAFEozaki-r
- Don't hold softnet_lock in some functions if NET_MPSAFE - Add softnet_lock to sysctl_net_inet_icmp_redirtimeout - Add softnet_lock to expire_upcalls of ip_mroute.c - Restore softnet_lock for in{,6}_pcbpurgeif{,0} if NET_MPSAFE - Mark some softnet_lock for future work
2016-11-18fix: "ifconfig destory" can stalls when "ifconfig" is done parallel.knakahara
This problem occurs only if NET_MPSAFE on. ifconfig destroy side: kernel entry point is ifioctl => if_clone_destroy. pr_purgeif() acquires softnet_lock, and then ifa_remove() calls pserialize_perform() holding softnet_lock. ifconfig side: kernel entry point is socreate. pr_attach()(udp_attach_wrapper()) calls sosetlock(). In this call path, sosetlock() try to acquire softnet_lock. These can cause dead lock.
2016-11-15Enforce alignment requirements that are violated in some cases.mlelstv
For machines that don't need strict alignment (i386,amd64,vax,m68k) this is a no-op. Fixes PR kern/50766 but should be improved.
2016-10-19Remove unnecessary #ifdef IPSECozaki-r
The entire function is already in #ifdef IPSEC. No functional change.
2016-06-10Avoid storing a pointer of an interface in a mbufozaki-r
Having a pointer of an interface in a mbuf isn't safe if we remove big kernel locks; an interface object (ifnet) can be destroyed anytime in any packet processing and accessing such object via a pointer is racy. Instead we have to get an object from the interface collection (ifindex2ifnet) via an interface index (if_index) that is stored to a mbuf instead of an pointer. The change provides two APIs: m_{get,put}_rcvif_psref that use psref(9) for sleep-able critical sections and m_{get,put}_rcvif that use pserialize(9) for other critical sections. The change also adds another API called m_get_rcvif_NOMPSAFE, that is NOT MP-safe and for transition moratorium, i.e., it is intended to be used for places where are not planned to be MP-ified soon. The change adds some overhead due to psref to performance sensitive paths, however the overhead is not serious, 2% down at worst. Proposed on tech-kern and tech-net.
2016-04-26Sweep unnecessary route.h inclusionsozaki-r
2016-02-15Reduce code duplication.rtr
Split creation of IPv4-Mapped IPv6 addresses into its own function and use it. No functional change intended. As posted to tech-net@
2016-01-20Give proper prototype to udp_output.riastradh
2015-08-24sprinkle _KERNEL_OPTpooka
2015-05-02make connect syscall use sockaddr_big and modify pr_{send,connect}rtr
nam parameter type from buf * to sockaddr *. final commit for parameter type changes to protocol user requests * bump kernel version to 7.99.15 for parameter type changes to pr_{send,connect}
2015-04-26remove pr_generic from struct pr_usrreqs and all implementations ofrtr
pr_generic in protocols. bump to 7.99.13 approved by rmind@
2015-04-24make accept, getsockname and getpeername syscalls use sockaddr_big and modifyrtr
pr_{accept,sockname,peername} nam parameter type from mbuf * to sockaddr *. * retained use of mbuftypes[MT_SONAME] for now. * bump to netbsd version 7.99.12 for parameter type change. patch posted to tech-net@ 2015/04/19
2015-04-03* change pr_bind to accept struct sockaddr * instead of struct mbuf *rtr
* update protocol bind implementations to use/expect sockaddr * instead of mbuf * * introduce sockaddr_big struct for storage of addr data passed via sys_bind; sockaddr_big is of sufficient size and alignment to accommodate all addr data sizes received. * modify sys_bind to allocate sockaddr_big instead of using an mbuf. * bump kernel version to 7.99.9 for change to pr_bind() parameter type. Patch posted to tech-net@ http://mail-index.netbsd.org/tech-net/2015/03/15/msg005004.html The choice to use a new structure sockaddr_big has been retained since changing sockaddr_storage size would lead to unnecessary ABI change. The use of the new structure does not preclude future work that increases the size of sockaddr_storage and at that time sockaddr_big may be trivially replaced. Tested by mrg@ and myself, discussed with rmind@, posted to tech-net@
2014-08-09split PRU_CONNECT2 & PRU_PURGEIF function out of pr_generic() usrreqrtr
switches and put into separate functions - always KASSERT(solocked(so)) even if not implemented (for PRU_CONNECT2 only) - replace calls to pr_generic() with req = PRU_CONNECT2 with calls to pr_connect2() - replace calls to pr_generic() with req = PRU_PURGEIF with calls to pr_purgeif() put common code from unp_connect2() (used by unp_connect() into unp_connect1() and call out to it when needed patch only briefly reviewed by rmind@
2014-08-08split PRU_RCVD function out of pr_generic() usrreq switches and put intortr
separate functions - always KASSERT(solocked(so)) even if not implemented - replace calls to pr_generic() with req = PRU_RCVD with calls to pr_rcvd()
2014-08-05split PRU_SEND function out of pr_generic() usrreq switches and put intortr
separate functions xxx_send(struct socket *, struct mbuf *, struct mbuf *, struct mbuf *, struct lwp *) - always KASSERT(solocked(so)) even if not implemented - replace calls to pr_generic() with req = PRU_SEND with calls to pr_send() rename existing functions that operate on PCB for consistency (and to free up their names for xxx_send() PRUs - l2cap_send() -> l2cap_send_pcb() - sco_send() -> sco_send_pcb() - rfcomm_send() -> rfcomm_send_pcb() patch reviewed by rmind