Commit graph

14 commits

Author SHA1 Message Date
cinap_lenrek 71f807873b devip: more v6 improvements
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-03-18 07:50:48 +01:00
cinap_lenrek b2d7992025 kernel: properly handle bad attach specifiers
- only accept decimal for numeric device id's
- exclude negative device id's
- device id's out of range yield Enodev
2018-02-25 17:11:18 +01:00
cinap_lenrek 5560efb3db devip: fix crash on negative dev id on attach 2018-02-25 03:32:29 +01:00
cinap_lenrek 857f2528e0 ip: always pass a single block to Medium.bwrite(), avoid concatblock() calls 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.
2016-11-07 22:05:29 +01:00
cinap_lenrek 75c6ab45e0 devip: simplify ipbwrite() by using retun value of qbwrite() 2016-10-23 00:29:41 +02:00
cinap_lenrek 38a8af2d72 devip: applying changes for bug: multicasts_and_udp_buffers
/n/bugs/open/multicasts_and_udp_buffers
http://bugs.9front.org/open/multicasts_and_udp_buffers/readme

michal@Lnet.pl

I have ported my small MPEG-TS analisis tool to Plan9.

To allow this application working I had to fix a bug in the kernel IPv4 code and increase UDP input buffer.

Bug is related to listening for IPv4 multicast traffic. There is no problem if you listen for only one group or multiple groups with different UDP ports. This works:

Write to UDP ctl:

anounce PORT
addmulti INTERFACE_ADDR MULTICAST_ADDR
headers

and you can read packets from data file.

You need to set headers option because otherwise every UDP packet for MULTICAST_ADDR!PORT is treat as separate connection. This is a bug and should be fixed too, but I didn't tried it.

There is a problem when you need to receive packets for multiple multicast groups. Usually the same destination port is used by multiple streams and above sequence of commands fails for second group because the port is the same.

Simple and probably non-intrusive fix is adding "|| ipismulticast(addr)" to if statement at /sys/src/9/ip/devip.c:861 line:

if(ipforme(c->p->f, addr) || ipismulticast(addr))

This fixes the problem and now you can use the following sequence to listen for multiple multicast groups even if they all have the same destination port:

announce MULTICAST_ADDR!PORT
addmulti INTERFACE_ADDR MULTICAST_ADDR
headers

After that my application started working but signals packet drops at >2 Mb/s input rate. The same is reported by kernel netlog. Increase capacity of UDP connection input queue fixes this problem /sys/src/9/ip/udp.c:153

c->rq = qopen(512*1024, Qmsg, 0, 0);

--
Michał Derkacz
2016-03-28 16:58:09 +02:00
cinap_lenrek 84c40fb226 devip: sanity check Nchan in Fsproto()
devip can only handle Maskconv+1 conversations per
protocol depending on how many bits it uses in the
qid to encode the conversation number.

we check this when the protocol gets registered.

if we do not do this, the kernel will mysteriously
panic when the conversaion numbers collide which
took some time to debug.
2014-09-21 19:24:38 +02:00
cinap_lenrek c145a2c0aa devip: print protocol name in garbage collection notification 2014-09-21 18:02:53 +02:00
cinap_lenrek d3b727db18 devip: dont raise error() out of Fsprotocone()
Fsprotoclone() is not supposed to raise error, but return nil.
ipopen() seemed to assume otherwise as it setup error label
before calling Fsprotoclone(). fix ipopen(), make Fsprotoclone()
return nil instead of raising error.
2013-05-05 04:28:50 +02:00
cinap_lenrek 9500191af6 devip: handle malloc errors, fix queue leaks
Fsprotocone():

qopen() and qbypass() can fail and return nil, so make sure
the connection was not partially created by checking if read
and write queues have been setup by the protocol create hanler.
on error, free any resources of the partial connection and
error out.

netlogopen(): check malloc() error.
2013-05-05 03:56:11 +02:00
cinap_lenrek c44b78f739 change definition of Chan.create to return a chan like open 2011-08-17 23:27:31 +02:00
cinap_lenrek bf8fcab00d devip: dont panic when ports get exhausted 2011-07-08 14:39:13 +00:00
Taru Karttunen a9060cc06b Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
Taru Karttunen e5888a1ffd Import sources from 2011-03-30 iso image 2011-03-30 15:46:40 +03:00