Commit graph

119 commits

Author SHA1 Message Date
cinap_lenrek 197ff3ac2f devip: if the server does not support TCP ws option, disable window scaling (thanks joe9)
if the server responds without a window scale option in
its syn-ack, disable window scaling alltogether as both
sides need to understand the option.
2019-05-22 22:20:31 +02:00
cinap_lenrek 157d7ebdbd devip: do not lock selftab in ipselftabread(), remove unused fields from Ipself
the Ipselftab is designed to not require locking on read
operation. locking the selftab in ipselftabread() risks
deadlock when accessing the user buffer creates a fault.

remove unused fields from the Ipself struct.
2019-05-12 01:20:21 +02:00
cinap_lenrek 333c320204 devip: reset speed and delay on bind, adjust burst on mtu change, ifc->m nil check, consistent error strings
initialize the rate limits when the device gets
bound, not when it is created. so that the
rate limtis get reset to default when the ifc
is reused.

adjust the burst delay when the mtu is changed.
this is to make sure that we allow at least one
full sized packet burst.

make a local copy of ifc->m before doing nil
check as it can change under us when we do
not have the ifc locked.

specify Ebound[] and Eunbound[] error strings
and use them consistently.
2019-05-11 17:22:33 +02:00
cinap_lenrek 7186be0424 devip: make sure ifc is bound in add6 ctl command 2019-05-11 14:54:10 +02:00
cinap_lenrek 3a0d5f41a8 devip: remove unused c->car qlock, avoid potential deadlock in ipifcregisterproxy()
remove references to the unused Conv.car qlock.

ipifcregisterproxy() is called with the proxy
ifc wlock'd, which means we cannot acquire the
rwlock of the interfaces that will proxy for us
because it is allowed to rlock() multiple ifc's
in any order. to get arround this, we use canrlock()
and skip the interface when we cannot acquire the
lock.

the ifc should get wlock'd only when we are about
to modify the ifc or its lifc chain. that is when
adding or removing addresses. wlock is not required
when we addresses to the selfcache, which has its
own qlock.
2019-05-11 14:01:26 +02:00
cinap_lenrek a25819c43a devip: avoid media bind/unbind kproc reader startup race, simplify etherbind
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.
2019-05-11 07:22:34 +02:00
cinap_lenrek 83c7a727e0 devip: reject bad numeric ports (such as 9fs -> 9) 2019-04-14 03:22:05 +02:00
cinap_lenrek 4b8f7a2110 devip: ignore the evil bit in fragment info field
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-07 22:39:50 +01:00
cinap_lenrek 4885c75526 devip: ignore icmp advise about laggard fragments
icmp has to advise protocols about the first
fragment only. all other fragments should be
ignored.
2019-03-07 01:25:11 +01:00
cinap_lenrek 57284d07ca devip: ignore reserved fragment offset bits 2019-03-04 12:07:40 +01:00
cinap_lenrek e2d310e623 devip: handle packet too big advise for icmp6, remove fragment header 2019-03-04 03:13:29 +01:00
cinap_lenrek 2af6b08960 devip: use common code in icmp for handling advise 2019-03-04 03:09:39 +01:00
cinap_lenrek 827020f686 devip: zero fragment offset after reassembly, remove tos magic, cleanup 2019-03-04 03:08:27 +01:00
cinap_lenrek a1fceabd5b devip: fix fragment forwarding
unfraglen() had the side effect that it would always copy the
nexthdr field from the fragment header to the previous nexthdr
field. this is fine when we reassemble packets but breaks
fragments that we want to just forward unchanged.
2019-03-04 03:05:30 +01:00
cinap_lenrek fa97c3dd10 devip: simplify ip reassembly functions, getting rid of Ipfrag.hlen
given that we now keep the block size consistent with the
ip packet size, the variable header part of the ip packet
is just: BLEN(bp) - fp->flen == fp->hlen.

fix bug in ip6reassemble() in the non-fragmented case:
reload ih after ip header was moved before writing ih->ploadlen.

use concatbloc() instead of pullupblock().
2019-03-03 18:56:18 +01:00
cinap_lenrek a859f05837 devip: fix block list handling for icmp/icmp6, use proper MinAdvise for icmp6 2019-03-03 09:01:23 +01:00
cinap_lenrek 5b972a9aea devip: fix ip fragmentation handling issues with header options
some protocols assume that Ip4hdr.length[] and Ip6hdr.ploadlen[]
are valid and not out of range within the block but this has
not been verified. also, the ipv4 and ipv6 headers can have variable
length options, which was not considered in the fragmentation and
reassembly code.

to make this sane, ipiput4() and ipiput6() now verify that everything
is in range and trims to block to the expected size before it does
any further processing. now blocklen() and Ip4hdr.length[] are conistent.

ipoput4() and ipoput6() are simpler now, as they can rely on
blocklen() only, not having a special routing case.

ip fragmentation reassembly has to consider that fragments could
arrive with different ip header options, so we store the header+option
size in new Ipfrag.hlen field.

unfraglen() has to make sure not to run past the buffer, and hadle
the case when it encounters multiple fragment headers.
2019-03-03 05:25:00 +01:00
cinap_lenrek 06912e53e4 devip: remove unused eipconvtet.c and ptclbsum.c files 2019-02-13 17:42:20 +01:00
cinap_lenrek 57ed5cc3f0 devip: ipv6 loopback ::1 has link-local scope 2019-02-13 08:46:49 +01:00
cinap_lenrek 7102a23245 devip: use parseipandmask() for ipifc and route control message parsing 2019-02-11 23:43:14 +01:00
cinap_lenrek 8152e9d075 devip: tcp: Don't respond to FIN-less ACKs during TIME-WAIT (thanks Barret Rhoden)
Under the normal close sequence, when we receive a FIN|ACK, we enter
TIME-WAIT and respond to that LAST-ACK with an ACK.  Our TCP stack would
send an ACK in response to *any* ACK, which included FIN|ACK but also
included regular ACKs.  (Or PSH|ACKs, which is what we were actually
getting/sending).

That was more ACKs than is necessary and results in an endless ACK storm
if we were under the simultaneous close sequence.  In that scenario,
both sides of a connection are in TIME-WAIT.  Both sides receive
FIN|ACK, and both respond with an ACK.  Then both sides receive *those*
ACKs, and respond again.  This continues until the TIME-WAIT wait period
elapses and each side's TCP timers (in the Plan 9 / Akaros case) shut
down.

The fix for this is to only respond to a FIN|ACK when we are in TIME-WAIT.
2019-01-27 22:12:50 +01:00
cinap_lenrek 099da8cb82 devip: fix arpread, dont return partial entries 2018-11-28 12:41:18 +01:00
cinap_lenrek 196da4ec6f devip: fix swapped tcp snd.scale and recv.scale in tcpstate() format (thanks joe9) 2018-11-18 04:14:41 +01:00
cinap_lenrek b56450471f devip: remove unused QLock from udp and icmpv6 control blocks (thanks brho) 2018-10-03 00:47:34 +02:00
cinap_lenrek 02b867f01e devip: only add interface route for "on-link" prefixes
when a prefix is added with the onlink flag clear, packets
towards that prefix needs to be send to the default gateway
so we omit adding the interface route.

when the on-link flag gets changed to 1 later, we add the
interface route.

the on-link flag is sticky, so theres no way to clear it back
to zero except removing and re-adding the prefix.
2018-09-28 18:13:01 +02:00
cinap_lenrek 94333ce6a6 devip, ipconfig: avoid overflow on lifetime checks 2018-09-23 22:07:56 +02:00
cinap_lenrek 70c6bd0397 devip: valid and prefered life-time should be unsigned, add remove6 ctl command 2018-09-23 19:09:48 +02:00
cinap_lenrek 4a92a8f6b2 devip: fix default parameter calculation for router life-time
router life time is in seconds, while max ra interval is
in milliseconds!
2018-09-23 19:08:16 +02:00
cinap_lenrek 259ce5e3de devip: make updating ra6 router parameters atomic
when we fail to parse and validate the command, no update
should take place.
2018-09-23 17:24:59 +02:00
cinap_lenrek 11d1947814 arp: interface address only specifies the interface, not the source address for route lookup 2018-08-30 21:17:54 +02:00
cinap_lenrek 5c945a0b48 devip: fix router adv/sol options validation (options padded to 8 bytes) 2018-08-27 20:58:48 +02:00
cinap_lenrek e49f7fc1f7 devip: fix multicastarp() when ipconfig assigned the 0 address
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-08-11 16:18:12 +02:00
cinap_lenrek a8a6429204 devip: make il connect fail quickly when theres no route 2018-07-10 09:11:19 +02:00
cinap_lenrek 9898aafa0c devip: don't pad the tag for routing commands (fixes removing routes with < 4 character tags) 2018-07-09 01:32:21 +02:00
cinap_lenrek 8dd003eb04 devip: fix flush, copy tag when replacing route entry 2018-06-19 21:17:15 +02:00
cinap_lenrek 4971db9e32 udp: fix udp checksum
we did not apply the special case to store 0xFFFF (-0)
in the checksum field when the checksum calculation
returned zero. we survived this for v4 as RFC768 states:

> If the computed checksum is zero, it is transmitted as
> all ones (the equivalent in one's complement arithmetic).
>
> An all zero transmitted checksum value means that the
> transmitter generated no checksum (for debuging or for
> higher level protocols that don't care).

for ipv6 however, the checksum is not optional and receivers
would drop packets with a zero checksum.
2018-06-14 20:48:21 +02:00
cinap_lenrek de9141bc6d devip: don't send arp requests from null address
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-06-14 00:07:45 +02:00
cinap_lenrek 71ce6f53a4 devip: reject incompatible multicast/interface ip address pairs for ipifcaddmulti() 2018-06-13 18:58:17 +02:00
cinap_lenrek 8fdd633d57 devip: fix missing wunlock() for "ipifc not yet bound to device" case, don't create multicast entry on error 2018-06-12 20:31:39 +02:00
cinap_lenrek 71402b2ea1 devip: fix use after free in ipifcremmulti()
closeconv() calls ipifcremmulti() like:

	while((mp = cv->multi) != nil)
		ipifcremmulti(cv, mp->ma, mp->ia);

so we have to defer freeing the entry after doing:

		if((lifc = iplocalonifc(ifc, ia)) != nil)
			remselfcache(f, ifc, lifc, ma);

which accesses the otherwise free'd ia and ma arguments.
2018-06-11 03:19:42 +02:00
cinap_lenrek 94f6f89ac1 devip: do not icmp reply on multicast destination 2018-06-11 03:14:28 +02:00
cinap_lenrek c9bb6f68eb devip: don't set mtu of interface to zero when not specified (thanks joe9)
change 9f74a951ae6a introduced a bug that set the mtu of a new
interface to 0 when not specified in the add ctl.
2018-05-14 19:18:13 +02:00
cinap_lenrek 298f239695 ip: add some primitive rate limiting knobs to counteract bufferbloat 2018-05-10 19:31:58 +02:00
cinap_lenrek 5aae3d344b devip: improve arp and ndp code
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-24 20:21:09 +02:00
cinap_lenrek 20b9326dad devip: fix ipv6 icmp unreachable handling, fix retransmit, fix ifc locking, remove tentative check 2018-04-22 18:54:13 +02:00
cinap_lenrek c80d94304d devip: cleanup ipmux.c 2018-04-22 18:50:45 +02:00
cinap_lenrek 8962551055 devip: increment in counter *AFTER* acquiering the ifc lock or loopbackmedium 2018-04-22 18:50:11 +02:00
cinap_lenrek dbf13129a7 devip: cleanup rudp.c 2018-04-22 18:49:01 +02:00
cinap_lenrek 9860172fce devip: cleanup tcp.c 2018-04-22 18:48:32 +02:00
cinap_lenrek c5c613357e devip: cleanup udp.c 2018-04-22 18:48:08 +02:00