summaryrefslogtreecommitdiff
path: root/sys/src/9/ip/icmp6.c
AgeCommit message (Collapse)Author
2023-05-16devip: address some ipv6 issues on pkt interfacecinap_lenrek
relax the maclen check as v6 neighbour disicovery might give bigger buffers as the medium uses for the mac address size, as the packet does not contain exact byte count but rounds all the options to multiples of 8. drop neighbour discovery packets coming from interfaces with zero-length maclen. when dialing icmpv6 protocol with link-local address for the local ip address, filter any packets to it that come from a different interface. otherwise ipconfig would see router advertisements from other interfaces. fix the locking for ipifc ctl messages: properly acquire the wlock and check that the interface is still bound for every ctl messages touching the interface. make add6 ipifc ctl message work for media with zero-length maclen by using the interface identier from pre-existing link-local address when available.
2023-04-15ip: generalize Rproxy route handling, allowing non point-to-point arp proxycinap_lenrek
Generalize the arp proxy code, so one can create specific routes for ip ranges that we want to arp proxy for, not just for point-to-point interface routes. as we have source specific routes, this also gives some control over which requester we will reply to. one example for this is a vps where we booked another ip address on the ethernet, that we want to route into a vpn tunnel. the new ip is in subnet of the public ethernet interface, so all we now need todo is add a route for that ip into the vpn tunnel and set the proxy flag "y", and we will respond to arp for that ip on the public ethernet interface.
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-11-20icmp6: no need set vcf and ttl before ipoput6(), use MAXTTL instead of HOP_LIMITcinap_lenrek
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.
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 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: handle packet too big advise for icmp6, remove fragment headercinap_lenrek
2019-03-03devip: fix block list handling for icmp/icmp6, use proper MinAdvise for icmp6cinap_lenrek
2018-10-03devip: remove unused QLock from udp and icmpv6 control blocks (thanks brho)cinap_lenrek
2018-08-27devip: fix router adv/sol options validation (options padded to 8 bytes)cinap_lenrek
2018-06-11devip: do not icmp reply on multicast destinationcinap_lenrek
2018-04-24devip: improve arp and ndp codecinap_lenrek
there appears to be confusion about the refresh flag of arpenter(). when we get an arp reply, it makes more sense to just refresh waiting/existing entries instead creating a new one as we do not know if we are going to communicate with the remote host in the future. when we see an arp request for ourselfs however, we want to always enter the senders address into the arp cache as it is likely the sender attempts to communicate with us and with the arp entry, we can reply immidiately. reject senders from multicast/broadcast mac addresses. thats just silly. we can get rid of the multicast/broadcast ip checks in ethermedium and do it in arpenter() instead, checking the route type for the target to see if its a non unicast target. enforce strict separation of interface's arp entries by passing a rlock'd ifc explicitely to arpenter, which we compare against the route target interface. this makes sure arp/ndp replies only affect entries for the receiving interface. handle neighbor solicitation retransmission in nbsendsol() only. that is, both ethermedium and the rxmitproc just call nbsendsol() which maintains the timers and counters and handles the rotation on the re-transmission chain.
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
2018-03-18devip: more v6 improvementscinap_lenrek
ipv4local() and ipv6local() now take remote address argument, returning the closest local address to the source. this implements the standartized source address selection rules instead of just returning the first local v4 or v6 address. the source address selection was broken for esp, rudp an udp, blindly assuming ifc->lifc->local being a valid v4 address. use ipv6local() instead. the v6 routing code used to lookup source address route to decide to drop the packet instead of checking the interface on the destination route. factor out the route hint from Conv and put it in Routehint structure. avoiding stack bloat in v4 routing. implement the same trick for v6 avoiding second route lookup in ipoput6. fix memory leak in icmpv6 router solicitation handling. remove old unfinished handling of multiple v6 routers. should implement source specific routes instead. avoid duplication, use common convipvers() function. use isv4() instead of memcmp v4prefix.
2018-01-16set router R-flag when sendra is active for neighbor advertisementcinap_lenrek
windows 7 just drops the default router when it tries to probe for router reachability but gets a neighbor avertisement from the router with the router bit clear. so set the R-flag when sendra is active, which implies that we are a router.
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
2016-02-21fix ipv6 icmphostunr() locking and memory free bugs (from sources)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