mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ivan Safonov <insafonov@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Aishwarya Pant <aishpant@gmail.com>,
	Yamanappagouda Patil <goudapatilk@gmail.com>,
	Luca Ceresoli <luca@lucaceresoli.net>,
	Jarod Wilson <jarod@redhat.com>,
	"David S . Miller" <davem@davemloft.net>,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	Ivan Safonov <insafonov@gmail.com>
Subject: [PATCH 3/7] staging:r8188eu: inline unprotect_frame() in mon_recv_decrypted_recv()
Date: Tue,  2 May 2017 09:01:41 +0300	[thread overview]
Message-ID: <20170502060145.26766-3-insafonov@gmail.com> (raw)
In-Reply-To: <20170502060145.26766-1-insafonov@gmail.com>

It is useful to remove IV/ICV from rtl88eu_mon_recv_hook().
Also unprotect_frame() will be very short without skb_(pull|trim).

Signed-off-by: Ivan Safonov <insafonov@gmail.com>
---
 drivers/staging/rtl8188eu/os_dep/mon.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/mon.c b/drivers/staging/rtl8188eu/os_dep/mon.c
index 7eac87d..53f853f 100644
--- a/drivers/staging/rtl8188eu/os_dep/mon.c
+++ b/drivers/staging/rtl8188eu/os_dep/mon.c
@@ -70,6 +70,8 @@ static void mon_recv_decrypted_recv(struct net_device *dev, const u8 *data,
 			       int data_len, int iv_len, int icv_len)
 {
 	struct sk_buff *skb;
+	struct ieee80211_hdr *hdr;
+	int hdr_len;
 
 	skb = netdev_alloc_skb(dev, data_len);
 	if (!skb)
@@ -80,7 +82,19 @@ static void mon_recv_decrypted_recv(struct net_device *dev, const u8 *data,
 	 * Frame data is not encrypted. Strip off protection so
 	 * userspace doesn't think that it is.
 	 */
-	unprotect_frame(skb, iv_len, icv_len);
+
+	hdr = (struct ieee80211_hdr *)skb->data;
+	hdr_len = ieee80211_hdrlen(hdr->frame_control);
+
+	if (skb->len < hdr_len + iv_len + icv_len) {
+		if (ieee80211_has_protected(hdr->frame_control)) {
+			hdr->frame_control &= ~cpu_to_le16(IEEE80211_FCTL_PROTECTED);
+
+			memmove(skb->data + iv_len, skb->data, hdr_len);
+			skb_pull(skb, iv_len);
+			skb_trim(skb, skb->len - icv_len);
+		}
+	}
 
 	skb->ip_summed = CHECKSUM_UNNECESSARY;
 	skb->protocol = eth_type_trans(skb, dev);
-- 
2.10.2

  parent reply	other threads:[~2017-05-02  6:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-02  6:01 [PATCH 1/7] staging:r8188eu: move IV/ICV trimming into decrypt() and also place it after rtl88eu_mon_recv_hook() Ivan Safonov
2017-05-02  6:01 ` [PATCH 2/7] staging:r8188eu: use different mon_recv_decrypted() inside rtl88eu_mon_recv_hook() and rtl88eu_mon_xmit_hook() Ivan Safonov
2017-05-02  6:01 ` Ivan Safonov [this message]
2017-05-02  6:01 ` [PATCH 4/7] staging:r8188eu: trim IV/ICV fields in validate_recv_data_frame() Ivan Safonov
2017-05-02  6:01 ` [PATCH 5/7] staging:r8188eu: remove ieee80211_get_hdrlen() Ivan Safonov
2017-05-02  6:01 ` [PATCH 6/7] staging:r8188eu: remove ieee80211_is_empty_essid() Ivan Safonov
2017-05-02  6:01 ` [PATCH 7/7] staging:r8188eu: remove unused definitions from include/ieee80211.h Ivan Safonov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170502060145.26766-3-insafonov@gmail.com \
    --to=insafonov@gmail.com \
    --cc=aishpant@gmail.com \
    --cc=davem@davemloft.net \
    --cc=devel@driverdev.osuosl.org \
    --cc=goudapatilk@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jarod@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luca@lucaceresoli.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®