summaryrefslogtreecommitdiff
path: root/sys/netinet/raw_ip.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).
2022-06-13Refactor like in_pcb.c:r1.187 and in6_pcb.c:r1.168.knakahara
Use TAILQ_FOREACH instead of TAILQ_FOREACH_SAFE about inpt_queue. rip_pcbnotify() doesn't use "ninph" pointer and doesn't remove elements.
2020-09-08Add IP_BINDANY, IPV6_BINDANY which can be used to bind to any address inchristos
order to implement transparent proxies.
2019-02-24RIP, RIP6, DDP, SCTP and SCTP6 lack a length check in their _connect()maxv
functions. Fix the first three, and add a big XXX in the SCTP ones. Found by KASAN, triggered by SyzKaller. Reported-by: syzbot+9eaf98dad6ca738c250d@syzkaller.appspotmail.com
2018-09-14Use non-variadic function pointer in protosw::pr_input.maxv
2018-05-11Make sure we have at least an IP header, and remove pointless XXXs (theremaxv
is no issue).
2018-04-28Remove unused ipsec_var.h includes.maxv
2018-04-12Make 'opts' local to rip_sbappendaddr().maxv
2018-04-12Synchronize the code between raw_ip6.c<->icmp6.c<->raw_ip.c, so that it ismaxv
the same everywhere.
2018-04-12Remove misleading comment; we're just checking the SP, not verifying themaxv
AH/ESP payload. While here style a bit.
2018-03-21Sprinkle more soroverflow().roy
2018-02-28Remove unused ipsec_private.h includes.maxv
2018-02-28(just forgot to commit this file, the message was)maxv
Remove duplicate IPSEC_STATINC(IPSEC_STAT_IN_POLVIO), ipsec_in_reject 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-14join lines where they fit.christos
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-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-09-29Now that we disallow sending or receiving from invalid addresses,roy
allow binding to tentative addresses.
2016-08-26Allow bind to detached INET addresses.roy
2016-08-01Apply pserialize and psref to struct ifaddr and its variantsozaki-r
This change makes struct ifaddr and its variants (in_ifaddr and in6_ifaddr) MP-safe by using pserialize and psref. At this moment, pserialize_perform and psref_target_destroy are disabled because (1) we don't need them because of softnet_lock (2) they cause a deadlock because of softnet_lock. So we'll enable them when we remove softnet_lock in the future.
2016-05-12Protect ifnet list with psz and psrefozaki-r
The change ensures that ifnet objects in the ifnet list aren't freed during list iterations by using pserialize(9) and psref(9). Note that the change adds a pslist(9) for ifnet but doesn't remove the original ifnet list (ifnet_list) to avoid breaking kvm(3) users. We shouldn't use the original list in the kernel anymore.
2016-04-26Sweep unnecessary route.h inclusionsozaki-r
2016-01-21Revert previous: ran cvs commit when I meant cvs diff. Sorry!riastradh
Hit up-arrow one too few times.
2016-01-21Give proper prototype to ip_output.riastradh
2016-01-20Give proper prototype to rip_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-05-02Add IPv4 address flags IN_IFF_TENTATIVE, IN_IFF_DUPLICATED androy
IN_IFF_DETATCHED to mimic the IPv6 address behaviour. Add SIOCGIFAFLAG_IN ioctl to retrieve the address flag via the ifreq structure. Add IPv4 DAD detection via the ARP methods described in RFC 5227. Add sysctls net.inet.ip.dad_count and net.inet.arp.debug. Discussed on tech-net@
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-25make rip_connect_pcb take sockaddr_in * instead of mbuf *rtr
make rip_connect_pcb static since it appears to be used only in raw_ip.c moves m_len check to callers which is a small duplication of code that will go away when the callers are converted to receive sockaddr *.
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-11-10Do not uselessly include <sys/malloc.h>.maxv
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
2014-08-05revert the removal of struct lwp * parameter from bind, listen and connectrtr
user requests. this should resolve the issue relating to nfs client hangs presented recently by wiz on current-users@
2014-08-03req cannot be PRU_SENDOOB here as per KASSERT() earlier in thertr
rip_usrreq() function. - KASSERT(!control || (req == PRU_SEND || req == PRU_SENDOOB)); + KASSERT(!control || (req == PRU_SEND));
2014-08-02restore splsoftnet() in various usrreqs that were removed during the PRUrtr
splits. we will properly review removal after the PRU split work is complete.
2014-07-31split PRU_DISCONNECT, PRU_SHUTDOWN and PRU_ABORT function out ofrtr
pr_generic() usrreq switches and put into separate functions xxx_disconnect(struct socket *) xxx_shutdown(struct socket *) xxx_abort(struct socket *) - always KASSERT(solocked(so)) even if not implemented - replace calls to pr_generic() with req = PRU_{DISCONNECT,SHUTDOWN,ABORT} with calls to pr_{disconnect,shutdown,abort}() respectively rename existing internal functions used to implement above functionality to permit use of the names for xxx_{disconnect,shutdown,abort}(). - {l2cap,sco,rfcomm}_disconnect() -> {l2cap,sco,rfcomm}_disconnect_pcb() - {unp,rip,tcp}_disconnect() -> {unp,rip,tcp}_disconnect1() - unp_shutdown() -> unp_shutdown1() patch reviewed by rmind
2014-07-31Define IFNET_EMPTY() and replace !IFNET_FIRST() with itozaki-r
No functional change.
2014-07-30split PRU_CONNECT function out of pr_generic() usrreq switches and putrtr
into seaparate functions xxx_listen(struct socket *, struct mbuf *) - always KASSERT(solocked(so)) and KASSERT(nam != NULL) - replace calls to pr_generic() with req = PRU_CONNECT with pr_connect() - rename existin {l2cap,sco,rfcomm}_connect() to {l2cap,sco,rfcomm}_connect_pcb() respectively to permit naming consistency with other protocols functions. - drop struct lwp * parameter from unp_connect() and at_pcbconnect() and use curlwp instead where appropriate. patch reviewed by rmind
2014-07-24split PRU_BIND and PRU_LISTEN function out of pr_generic() usrreqrtr
switches and put into separate functions xxx_bind(struct socket *, struct mbuf *) xxx_listen(struct socket *) - always KASSERT(solocked(so)) even if not implemented - replace calls to pr_generic() with req = PRU_BIND with call to pr_bind() - replace calls to pr_generic() with req = PRU_LISTEN with call to pr_listen() - drop struct lwp * parameter from at_pcbsetaddr(), in_pcbbind() and unp_bind() and always use curlwp. rename existing functions that operate on PCB for consistency (and to free up their names for xxx_{bind,listen}() PRUs - l2cap_{bind,listen}() -> l2cap_{bind,listen}_pcb() - sco_{bind,listen}() -> sco_{bind,listen}_pcb() - rfcomm_{bind,listen}() -> rfcomm_{bind,listen}_pcb() patch reviewed by rmind welcome to netbsd 6.99.48
2014-07-23split PRU_SENDOOB and PRU_RCVOOB function out of pr_generic() usrreqrtr
switches and put into separate functions xxx_sendoob(struct socket *, struct mbuf *, struct mbuf *) xxx_recvoob(struct socket *, struct mbuf *, int) - always KASSERT(solocked(so)) even if request is not implemented - replace calls to pr_generic() with req = PRU_{SEND,RCV}OOB with calls to pr_{send,recv}oob() respectively. there is still some tweaking of m_freem(m) and m_freem(control) to come for consistency. not performed with this commit for clarity. reviewed by rmind