• Jakub Kicinski's avatar
    net/tls: add kernel-driven TLS RX resync · f953d33b
    Jakub Kicinski authored
    TLS offload device may lose sync with the TCP stream if packets
    arrive out of order.  Drivers can currently request a resync at
    a specific TCP sequence number.  When a record is found starting
    at that sequence number kernel will inform the device of the
    corresponding record number.
    
    This requires the device to constantly scan the stream for a
    known pattern (constant bytes of the header) after sync is lost.
    
    This patch adds an alternative approach which is entirely under
    the control of the kernel.  Kernel tracks records it had to fully
    decrypt, even though TLS socket is in TLS_HW mode.  If multiple
    records did not have any decrypted parts - it's a pretty strong
    indication that the device is out of sync.
    
    We choose the min number of fully encrypted records to be 2,
    which should hopefully be more than will get retransmitted at
    a time.
    
    After kernel decides the device is out of sync it schedules a
    resync request.  If the TCP socket is empty the resync gets
    performed immediately.  If socket is not empty we leave the
    record parser to resync when next record comes.
    
    Before resync in message parser we peek at the TCP socket and
    don't attempt the sync if the socket already has some of the
    next record queued.
    
    On resync failure (encrypted data continues to flow in) we
    retry with exponential backoff, up to once every 128 records
    (with a 16k record thats at most once every 2M of data).
    Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
    Reviewed-by: default avatarDirk van der Merwe <dirk.vandermerwe@netronome.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    f953d33b
tls_sw.c 59.4 KB