RNS Logo

rns.recipes

◈ 9ce92808be498e9e05590ff27cbfdfe4

Bug in I2P or is it me? (Prolly me)

Started by Anonymous ·

Anonymous
#1

So I had an issue with I2P after the 1.5.0 upgrade. It wasn't working properly and I could not figure out why. I've gotten it to work but I made assumptions because this is all new to me.

This bug seems to be in the 1.5.0 master but again I could be wrong.

The components involved:

I2pd service
|

  • i2plib using the SAM protocol
    |
    RNSD

So it appears that this is just a drift in a "vendored" lib (though it's not traditionally packaged here). A sort of race condition with an exception handling logic that amplifies the impact.

dest, data = incoming.split(b"\n", 1) on this line I get "not enough values to unpack (expected 2, got 1)"

this was causing me to get a setup_failed state and then does a rebuild which then becomes a loop.

So, I changed two things I placed the read in a wrapped async await and while loop with a timeout with a timeout instead of a single read.

while b"\n" not in incoming:             
    more = await asyncio.wait_for(client_reader.read(BUFFER_SIZE), timeout=10)
    if not more: break
    incoming += more
    dest, data = incoming.split(b"\n", 1)

this seems to fix the issue now the full tcp buffer gets read and parsing succeeds. Second I altered the exception handling so it doesn't bomb the whole interface when this happens

  except Exception as e:
      logger.debug("... dropping client with unreadable destination ...")
      try: client_writer.close()                     
      return                                         

This caused my backbone to flap for days after the upgrade. Don't know if this is the best fix at all or if this is an appropriate timeout OR if this should be handled elsewhere. I know there are ways to configure TCP behavior regarding this increase the chunk size etc... for now this seems to be working for me the issue has gone away.

Anonymous
#2

A race condition actually isn't a good way of putting it. A better way would be that there are 2 "messages" on 2 different layers the message its self and the TCP payload the payload is chunked independently and there is no guarantee the message itself is delivered in one of those chunks.

Post a Reply

Supports Markdown: **bold**, *italic*, `code`, ```code blocks```, [links](url)

Log in to upload images

Quote
Copied to clipboard