From e672f7597fd88d86acdaf504baedd19e68e6de65 Mon Sep 17 00:00:00 2001 From: Frank Cusack Date: Tue, 4 May 2004 12:30:18 +0000 Subject: [PATCH] Handle PFC on rx side, efficiently, thanks to Jan Dubiec. --- linux/mppe/ppp_mppe_compress.c | 35 ++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/linux/mppe/ppp_mppe_compress.c b/linux/mppe/ppp_mppe_compress.c index 6024edb..0512132 100644 --- a/linux/mppe/ppp_mppe_compress.c +++ b/linux/mppe/ppp_mppe_compress.c @@ -428,14 +428,19 @@ mppe_decompress(void *arg, unsigned char *ibuf, int isize, unsigned char *obuf, return DECOMP_ERROR; } - /* Make sure we have enough room to decrypt the packet. */ - if (osize < isize - MPPE_OVHD - 2) { + /* + * Make sure we have enough room to decrypt the packet. + * Note that for our test we only subtract 1 byte whereas in + * mppe_compress() we added 2 bytes (+MPPE_OVHD); + * this is to account for possible PFC. + */ + if (osize < isize - MPPE_OVHD - 1) { printk(KERN_DEBUG "mppe_decompress[%d]: osize too small! " "(have: %d need: %d)\n", state->unit, - osize, isize - MPPE_OVHD - 2); + osize, isize - MPPE_OVHD - 1); return DECOMP_ERROR; } - osize = isize - MPPE_OVHD - 2; + osize = isize - MPPE_OVHD - 2; /* assume no PFC */ ccount = MPPE_CCOUNT(ibuf); if (state->debug >= 7) @@ -537,8 +542,26 @@ mppe_decompress(void *arg, unsigned char *ibuf, int isize, unsigned char *obuf, isize -= PPP_HDRLEN + MPPE_OVHD; /* -6 */ /* net osize: isize-4 */ - /* And finally, decrypt the packet. */ - arcfour_decrypt(&state->arcfour_context, ibuf, isize, obuf); + /* + * Decrypt the first byte in order to check if it is + * a compressed or uncompressed protocol field. + */ + arcfour_decrypt(&state->arcfour_context, ibuf, 1, obuf); + + /* + * Do PFC decompression. + * This would be nicer if we were given the actual sk_buff + * instead of a char *. + */ + if ((obuf[0] & 0x01) != 0) { + obuf[1] = obuf[0]; + obuf[0] = 0; + obuf++; + osize++; + } + + /* And finally, decrypt the rest of the packet. */ + arcfour_decrypt(&state->arcfour_context, ibuf + 1, isize - 1, obuf + 1); state->stats.unc_bytes += osize; state->stats.unc_packets++; -- 2.39.2