summaryrefslogtreecommitdiff
path: root/sys/src/9/ip/arp.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-09-28arp: move arp expire logic into own functioncinap_lenrek
Add arphit() function, handling validation and checking for maximum life-time of the enty as well as copying out the mac address.
2022-09-27arp: make sure arpresolve() only returns single packetcinap_lenrek
Due to locking changes, it is possible for arpresolve() to return multiple packets in the multicast case, resulting in etherbwrite() to fail assert(bp->list == nil). Ensure that arpresolve() always returns the first packet from the hold chain and frees the rest if any. For arpenter(), we want to transmit the whole chain of packets, so we detach them from the arp entry before calling arpresolve() and ignoring its result.
2021-10-09devip: cache arp entry in Routehintcinap_lenrek
Instead of having to do an arp hash table lookup for each outgoing ip packet, forward the Routehint pointer to the medium's bwrite() function and let it cache the arp entry pointer. This avoids route and arp hash table lookups for tcp, il and connection oriented udp. It also allows us to avoid multiple route and arp table lookups for the retransmits once an arp/neighbour solicitation response arrives.
2021-10-03devip: use better hashipa() macro, use RWlock for arp cachecinap_lenrek
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.
2018-11-28devip: fix arpread, dont return partial entriescinap_lenrek
2018-08-30arp: interface address only specifies the interface, not the source address ↵cinap_lenrek
for route lookup
2018-05-10ip: add some primitive rate limiting knobs to counteract bufferbloatcinap_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: fix ipv6 icmp unreachable handling, fix retransmit, fix ifc locking, ↵cinap_lenrek
remove tentative check
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.
2016-11-07ip: always pass a single block to Medium.bwrite(), avoid concatblock() calls ↵cinap_lenrek
in Dev.bwrite() the convention for Dev.bwrite() is that it accepts a *single* block, and not a block chain. so we never have concatblock here. to keep stuff consistent, we also guarantee thet Medium.bwrite() will get a *single* block passed as well, as the callers are few in number.
2015-09-27devip: declare cleanarpent() staticcinap_lenrek
2015-09-27devip: various bugfixes and cleanups for arp codecinap_lenrek
- fix missing runlock(ifc) when ifcid != a->ifcid in rxmitsols() (thanks erik quanstro) - don't leak packets when transfering blocks from arp entry hold list to droplist - free rest of droplist when bwrite() errors in arpenter(), remove useless checks (ifc != nil) - free arp entry hold list from cleanarpent() - consistent use of nil for pointers
2013-01-22arp: fix memory leaks for "flush" and "del" arp ctl messagescinap_lenrek
2011-03-30Import sources from 2011-03-30 iso image - libTaru Karttunen
2011-03-30Import sources from 2011-03-30 iso imageTaru Karttunen