summaryrefslogtreecommitdiff
path: root/sys/src/9/ip/devip.c
AgeCommit message (Collapse)Author
2023-05-20devip: provide large buffer for ipifc->local() generatorcinap_lenrek
The ipifc->local generator is the big exception, dumping the whole link structure of the interface.
2023-05-19devip: don't leak temporary buffers on errorcinap_lenrek
when reading the status files from a conversation, ipread() allocates a temporary buffer and calls the protocols generator to fill the buffer and the calls readstr() to handle the read request. if the generator or readstr() erors, we must free the temporary buffer. also, allocate a more reasonable size for the "local" and "remote" strings. allocating and zeroing 32K big buffers for them is excessive.
2022-11-20devip: lilu dallas multicast.cinap_lenrek
Allow accepting udp "connections" using a multicast local address. Before, it was only possible to receive multicast using the headers option. Having a connection orirented stream can be very usefull when receiving multicast audio data. One gets a "connection" for every source. Implement (optional) support for IGMPv2 and MLDv1. This can be usefull if bridges on the network have IGMP/MLD snooping enabled, and wont forward multicast traffic unless we report what we excpect. This is experimental for now, so the igmp protocol must be manually added to the kernel configuration.
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.
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.
2019-09-21devip: fix permission checkingcinap_lenrek
permission checking had the "other" and "owner" bits swapped plus incoming connections where always owned by "network" instead of the owner of the listening connection. also, ipwstat() was not effective as the uid strings where not parsed. this fixes the permission checks for data/ctl/err file and makes incoming connections inherit the owner from the listening connection. we also allow ipwstat() to change ownership to the commonuser() or anyone if we are eve. we might have to add additional restrictions for none at a later point...
2019-05-11devip: remove unused c->car qlock, avoid potential deadlock in ↵cinap_lenrek
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-04-14devip: reject bad numeric ports (such as 9fs -> 9)cinap_lenrek
2018-07-09devip: don't pad the tag for routing commands (fixes removing routes with < ↵cinap_lenrek
4 character tags)
2018-04-10devip: properly initialize the connection ignoreadvice and tos flagscinap_lenrek
2018-04-08devip: implement source specific routingcinap_lenrek
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-02-25kernel: properly handle bad attach specifierscinap_lenrek
- only accept decimal for numeric device id's - exclude negative device id's - device id's out of range yield Enodev
2018-02-25devip: fix crash on negative dev id on attachcinap_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.
2016-10-23devip: simplify ipbwrite() by using retun value of qbwrite()cinap_lenrek
2016-03-28devip: applying changes for bug: multicasts_and_udp_bufferscinap_lenrek
/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
2014-09-21devip: sanity check Nchan in Fsproto()cinap_lenrek
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-21devip: print protocol name in garbage collection notificationcinap_lenrek
2013-05-05devip: dont raise error() out of Fsprotocone()cinap_lenrek
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-05devip: handle malloc errors, fix queue leakscinap_lenrek
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.
2011-08-17change definition of Chan.create to return a chan like opencinap_lenrek
2011-07-08devip: dont panic when ports get exhaustedcinap_lenrek
2011-03-30Import sources from 2011-03-30 iso image - libTaru Karttunen
2011-03-30Import sources from 2011-03-30 iso imageTaru Karttunen