summaryrefslogtreecommitdiff
path: root/sys/src/9/ip/ethermedium.c
AgeCommit message (Collapse)Author
2022-10-08devip: use port/netif.h constants for ethermediumcinap_lenrek
2022-09-28devip: get rid of Ipifc.mintucinap_lenrek
All the mediums we have implemented know their minimum transmit unit. The minimum transfer unit is not adjustable so there is no point in caching it in the ip interface.
2022-09-27arp: don't leak data in the padding of arp repliescinap_lenrek
2022-02-16devip: dont hold ifc wlock during medium bind/unbindcinap_lenrek
Wlock()'ing the ifc causes a deadlock with Medium bind/unbind as the routine can walk /net, while ndb/dns or ndb/cs are currently blocked enumerating /net/ipifc/*. The fix is to have a fake medium, called "unbound", that is set temporarily during the call of Medium bind and unbind. That way, the interface rwlock can be released while bind/unbind is in progress. The ipifcunbind() routine will refuse to unbind a ifc that is currently assigned to the "unbound" medium, preventing any accidents.
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.
2020-01-05devip: fix packet loss when interface is wlockedcinap_lenrek
to prevent deadlock on media unbind (which is called with the interface wlock()'ed), the medias reader processes that unbind was waiting for used to discard packets when the interface could not be rlocked. this has the unfortunate side effect that when we change addresses on a interface that packets are getting lost. this is problematic for the processing of ipv6 router advertisements when multiple RA's are getting received in quick succession. this change removes that packet dropping behaviour and instead changes the unbind process to avoid the deadlock by wunlock()ing the interface temporarily while waiting for the reader processes to finish. the interface media is also changed to the mullmedium before unlocking (see the comment).
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-05-11devip: avoid media bind/unbind kproc reader startup race, simplify etherbindcinap_lenrek
mark reader process pointers with (void*)-1 to mean not started yet. this avoids the race condition when media unbind happens before the kproc has set its Proc* pointer. then we would not post the note and the reader would continue running after unbind. etherbind can be simplified by reading the #lX/addr file to get the mac address, avoiding the temporary buffer.
2018-08-11devip: fix multicastarp() when ipconfig assigned the 0 addresscinap_lenrek
sending multicast was broken when ipconfig assigned the 0 address for dhcp as they would wrongly classified as Runi. this could happen when we do slaac and dhcp in parallel, breaking the sending of router solicitations.
2018-06-14devip: don't send arp requests from null addresscinap_lenrek
during dhcp, ipconfig assigns the null address :: which makes ipforme() return Runi for any destination, which can trigger arp resolution when we attempt to reply. so have v4local() skip the null address and have sendarp() check the return status of v4local(), avoing the spurious arp requests.
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-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.
2017-12-23kernel: remove Ipifc.mbps, unused.cinap_lenrek
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.
2013-06-17ip/ethermedium: drop short packets instead of producing negative size blockscinap_lenrek
on usb ethernet, it can happen that we read truncated packets smaller than the ethernet header size. this produces a warning in pullupblock() later like: "pullup negative length packet, called from 0xf0199e46"
2011-03-30Import sources from 2011-03-30 iso image - libTaru Karttunen
2011-03-30Import sources from 2011-03-30 iso imageTaru Karttunen