summaryrefslogtreecommitdiff
path: root/sys/src/9/ip/icmp.c
AgeCommit message (Collapse)Author
2022-12-30icmp: only forward EchoRequest, Timestamp(request), InfoRequest and ↵cinap_lenrek
AddrMaskRequest
2022-12-18devip: fix icmp bugscinap_lenrek
icmpdontfrag() was not working properly, need to pass the gating source interface. in fact, we now always pass the source interface to all icmp*() functions, which is used to determine source ip address of the icmp reply. also dont generate a icmp response for packets going to non-unicast addresses (such as broadcast). increase the amount of icmp response payload, but keep icmp responses below the minimum ipv4 mtu (68 bytes). regularize icmpv6 function names. move icmp unreachable codes to icmpv6.c. provide the mtu value for icmppkttoobig6(). dont advise announced udp connections. avoid code duplication in icmp.c and icmpv6.c, by having single send function with type, code and arg parameters. maintain statistics for sent ipv4 icmp types. avoid route lookup in ipout*() by passing Routehint* to icmpnohost*(). iladvise()... more like ill advice.
2022-12-13devip: tcpmssclamp() to minimum of source and destination interface MTUcinap_lenrek
We used to only clamp to the MTU of the destination interface, but this is wrong. We have to clamp to the minimum of both source and destination. For this, we change the gating argument type of ipoput4() and ipoput6() from int to Ipifc* to pass the source interface.
2022-03-12devip: implement network address translation routescinap_lenrek
This adds a new route "t"-flag that enables network address translation, replacing the source address (and local port) of a forwarded packet to one of the outgoing interface. The state for a translation is kept in a new Translation structure, which contains two Iphash entries, so it can be inserted into the per protocol 4-tuple hash table, requiering no extra lookups. Translations have a low overhead (~200 bytes on amd64), so we can have many of them. They get reused after 5 minutes of inactivity or when the per protocol limit of 1000 entries is reached (then the one with longest inactivity is reused). The protocol needs to export a "forward" function that is responsible for modifying the forwarded packet, and then handle translations in its input function for iphash hits with Iphash.trans != 0. This patch also fixes a few minor things found during development: - Include the Iphash in the Conv structure, avoiding estra malloc - Fix ttl exceeded check (ttl < 1 -> ttl <= 1) - Router should not reply with ttl exceeded for multicast flows - Extra checks for icmp advice to avoid protocol confusions.
2021-09-26devip: implement ipv4 arp timeout with icmp host unreachable notificationcinap_lenrek
The IPv4 ARP cache used to indefinitely buffer packets in the Arpent hold list. This is bad in case of a router, because it opens a 1 second (retransmit time) window to leak all the to be forwarded packets. This change makes the ipv4 arp code path similar to the IPv6 neighbour solicitation path, using the retransmit process to time out old entries (after 3 arp retransmits => 3 seconds). A new function arpcontinue() has been added that unifies the point when we schedule the (ipv6 sol retransmit) / (ipv4 arp timeout) and reduce the hold queue to the last packet and unlock the cache. As a bonus, we also now send a icmp host unreachable notification for the dropped packets.
2019-11-10devip: use the routing table for local source ip address selectioncinap_lenrek
when making outgoing connections, the source ip was selected by just iterating from the first to the last interface and trying each local address until a route was found. the result was kind of hard to predict as it depends on the interface order. this change replaces the algorithm with the route lookup algorithm that we already have which takes more specific desination and source prefixes into account. so the order of interfaces does not matter anymore.
2019-03-07devip: ignore the evil bit in fragment info fieldcinap_lenrek
using ~IP_DF mask to select offset and "more fragments" bits includes the evil bit 15. so instead define a constant IP_FO for the fragment offset bits and use (IP_MF|IP_FO). that way the evil bit gets ignored and doesnt cause any useless calls to ipreassemble().
2019-03-07devip: ignore icmp advise about laggard fragmentscinap_lenrek
icmp has to advise protocols about the first fragment only. all other fragments should be ignored.
2019-03-04devip: use common code in icmp for handling advisecinap_lenrek
2019-03-03devip: fix block list handling for icmp/icmp6, use proper MinAdvise for icmp6cinap_lenrek
2018-04-22devip: various icmp stuffcinap_lenrek
no need to rlock ifc in targetttype() as we are called from icmpiput6(), which the ifc rlocked. for icmpadvise, the lport, destination *AND* source have to match. a connection gets a packet when the packets destination matches the source *OR* the packets source matches the destination.
2018-04-19devip: add "reflect" ctl message, fix memory leaks in icmpv6, fix source ↵cinap_lenrek
address for icmpttlexceeded, cleanup
2018-04-08devip: implement source specific routingcinap_lenrek
2018-03-19devip: pick source address for neighbor solicitations as of rfc4861 7.2.2, ↵cinap_lenrek
cleanup rfc4861 7.2.2: If the source address of the packet prompting the solicitation is the same as one of the addresses assigned to the outgoing interface, that address SHOULD be placed in the IP Source Address of the outgoing solicitation. this change adds ndbsendsol() which handles the source address selection and also handles the arp table locking; avoiding access to the arp entry after the arp table is unlocked. cleanups: - use ipmove() instead of memmove(). - useless extern qualifiers
2016-10-23ip/icmp: only reply to echo request when directed to us and source is unicastcinap_lenrek
2016-03-12devip: handle ignoreadvice flag for all protocolscinap_lenrek
2014-04-12icmp: use snprint, add more unreachable error messages (from erik quanstro)cinap_lenrek
2012-08-02ip: fix assert panic on fragmented icmp echo request (see eriks icmp-frag patch)cinap_lenrek
2011-03-30Import sources from 2011-03-30 iso image - libTaru Karttunen
2011-03-30Import sources from 2011-03-30 iso imageTaru Karttunen