summaryrefslogtreecommitdiff
path: root/sys/netinet/ip_output.c
AgeCommit message (Collapse)Author
2023-04-19Again allow multicast packets to be sent from unnumbered interfaces.mlelstv
2023-04-19Revert "Fix panic on packet sending via a route with rt_ifa of AF_LINK."ozaki-r
The fix is mistakenly upstreamed.
2022-11-21Fix panic on packet sending via a route with rt_ifa of AF_LINK.knakahara
A route with rt_ifa of AF_LINK can be set by some routing daemons when it adds a route that has a gateway of AF_LINK. If there is no address on a target interface, the kernel sets an AF_LINK address of the interface to rt_ifa of the route. In that case, a variable of a local address in ip_output (ia) can be NULL and we need more NULL-checks of it.
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).
2020-09-08Add IP_BINDANY, IPV6_BINDANY which can be used to bind to any address inchristos
order to implement transparent proxies.
2020-08-28Don't cache the sa, because we are dealing with multiple mbufs (from ozaki-r)christos
2020-08-28inet: reduce silent packet discardsozaki-r
2020-08-28inet: reduce indents of a normal path to improve readability (NFCI)ozaki-r
2020-08-28inet, inet6: count packets dropped by IPsecozaki-r
The counters count packets dropped due to security policy checks.
2019-12-27s/referece/reference/ in comment.msaitoh
2019-06-05The packets which will be esp-fragmented should not be applied pfil. Pointed ↵knakahara
out by ohishi@IIJ, thanks.
2019-06-05Fix rtcache cannot be released once an esp-fragmented packet is sent. ↵knakahara
Pointed out by ohishi@IIJ, thanks.
2019-05-15Get rid of IFNET_LOCK for if_mcast_op to avoid a deadlockozaki-r
The IFNET_LOCK was added to avoid data races on if_flags for IFF_ALLMULTI. Unfortunatetly it caused a deadlock instead. A known scenario causing a deadlock is to occur the following two operations concurrently: (a) a removal of an IP adddres assigned to an interface and (b) a manipulation of multicast groups to the interface. The resource dependency graph is like this: softnet_lock => IFNET_LOCK => psref_target_destroy => softint => softnet_lock Thanks to the previous commit that avoids data races on if_flags for IFF_ALLMULTI by another approach, we can remove IFNET_LOCK and defuse the deadlock. PR kern/54189
2019-05-13Count packets dropped by pfilozaki-r
2019-02-04rework the #ifdef IPSEC code to not use fallthru.mrg
same number of lines with more local context.
2018-12-22Replace: M_MOVE_PKTHDR -> m_move_pkthdr. No functional change, since themaxv
former is a macro to the latter.
2018-12-12Simplify logic in ip{,6}_output().rin
Now, we have M_CSUM_TSOv[46] bit in ifp->if_csum_flags_tx when TSO[46] is enabled for the interface. So we can simply check whether TSO[46] is required in a packet but missing in the interface by (sw_csum & M_CSUM_TSOv[46]). Note that this is a very rare case where TSO[46] is suddenly turned off during a packet passing b/w TCP and IP. part of PR kern/53562 OK msaitoh
2018-07-11Renamemaxv
ip_undefer_csum -> in_undefer_cksum in_delayed_cksum -> in_undefer_cksum_tcpudp The two previous names were inconsistent and misleading. Put the two functions into in_offload.c. Add comments to explain what we're doing. The same could be done for IPv6.
2018-06-02Copy more mbuf flags.maxv
2018-05-29Fix an XXX of mine, be clearer about what we're doing. Basically we want tomaxv
preserve the fragment offset and flags. That's necessary if the packet we're fragmenting is itself a fragment.
2018-04-29Remove unused and misleading argument from ipsec_set_policy.maxv
2018-04-21Remove #ifndef __vax__.maxv
The check enforces a 4-byte-aligned size for the option mbuf. If the size is not multiple of 4, the computation of ip_hl gets truncated in the output path. There is no reason for this check not to be present on VAX. While here add a KASSERT in ip_insertoptions to enforce the assumption. Discussed briefly on tech-net@
2018-04-13Remove useless comment and style.maxv
2018-04-13Reduce the diff between similar blocks.maxv
2018-04-13Reorder a few instructions to clarify. Replace two bcopy by memcpy.maxv
2018-03-30correct typo: and and -> and (comments only)maya
heads up on this being a common typo from chris28.
2018-03-03Add KASSERTs, we don't want m_nextpkt in ipsec{4/6}_process_packet.maxv
2018-02-27Dedup: merge ipsec4_set_policy and ipsec6_set_policy. The content of themaxv
original ipsec_set_policy function is inlined into the new one.
2018-02-27Dedup: mergemaxv
ipsec4_get_policy and ipsec6_get_policy ipsec4_delete_pcbpolicy and ipsec6_delete_pcbpolicy The already-existing ipsec_get_policy() function is inlined in the new one.
2018-02-12Keep a pointer to the interface of the multicast membership, because thechristos
multicast element itself might go away in in_delmulti (but the interface can't because we hold the lock). From ozaki-r@
2018-02-07ip_add_membership() has an missing {} issue, but solve it bymrg
dropping the "goto out" that would have happened immediately next anyway, ie, should be NFC.
2018-02-06Several changes, mostly cosmetic:maxv
* Add a KASSERT in ip_output(), we expect (at least) the IP header to be here. * In ip_fragment(), declare two variables instead of recomputing the values each time. Add an XXX for ipoff, it seems to me we should also remove IP_RF. * Rename the arguments of ip_optcopy(). * Style: use NULL for pointers, remove ()s for return statements, and add whitespaces for clarity. No real functional change.
2018-01-10from ozaki-r: use the proper ifp.christos
XXX: perhaps push the lock in in_delmulti()?
2018-01-10- this is not python, we need braceschristos
- protect ifp locking against NULL
2018-01-01Remove comment now that the getsockopt code passes the size.christos
2018-01-011) "#define ipi_spec_dst ipi_addr" in <netinet/in.h>christos
2) Change the IP_RECVPKTINFO option to control the generation of IP_PKTINFO control messages, the way it's done in Solaris. 3) Remove the superfluous IP_RECVPKTINFO control message. 4) Change the IP_PKTINFO option to do different things depending on the parameter it's supplied with: - If it's sizeof(int), assume it's being used as in Linux: - If it's non-zero, turn on the IP_RECVPKTINFO option. - If it's zero, turn off the IP_RECVPKTINFO option. - If it's sizeof(struct in_pktinfo), assume it's being used as in Solaris, to set a default for the source interface and/or source address for outgoing packets on the socket. 5) Return what Linux or Solaris compatible code expects, depending on data size, and just added a fallback to a Linux (and current NetBSD) compatible value if the size is unknown (as it is now), or, in the future, if the calling application specifies a receiving buffer that doesn't match either data item. From: Tom Ivar Helbekkmo
2017-12-22Fix usage of curlwp_bind in ip_outputozaki-r
curlwp_bindx must be called in LIFO order, i.e., we can't call curlwp_bind and curlwp_bindx like this: bound1 = curlwp_bind(); bound2 = curlwp_bind(); curlwp_bindx(bound1); curlwp_bindx(bound2); ip_outout did so if NET_MPSAFE. Fix it.
2017-12-15Ensure to call if_mcast_op with holding IFNET_LOCKozaki-r
Note that CARP doesn't deal with IFNET_LOCK yet.
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-11-17Provide macros for softnet_lock and KERNEL_LOCK hiding NET_MPSAFE switchozaki-r
It reduces C&P codes such as "#ifndef NET_MPSAFE KERNEL_LOCK(1, NULL); ..." scattered all over the source code and makes it easy to identify remaining KERNEL_LOCK and/or softnet_lock that are held even if NET_MPSAFE. No functional change
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-23kmem_intr_free kmem_intr_[z]alloced memorypara
the underlying pools are the same but api-wise those should match
2017-07-04Rename u to udst, .dst to .sa and .dst4 to sin.roy
Create sockaddr for the source address in usrc so it won't stamp on udst. This fixes a regression caused in r1.280
2017-07-03Typokhorben
2017-07-03When outputting, search for the sending address on the sending interfaceroy
rather than blindly picking the first matcing address from any interface when testing source address validity. This allows another interface to have the same address, but be detached.
2017-05-12replace in_fmtaddr() by IN_PRINT(), and delete function in_fmtaddr()ryo
2017-05-10Stop ipsec4_output returning SP to the callerozaki-r
SP isn't used by the caller (ip_output) and also holding its reference looks unnecessary.
2017-05-07PR/52074: Frank Kardel: current npf map directive brokenchristos
Don't filter packets that can't be resolved to source interfaces because they could have been generated by a packet filter.