License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 15:07:57 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2018-08-03 16:26:13 +05:30
|
|
|
/*
|
|
|
|
* Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2019-11-05 09:51:25 +00:00
|
|
|
#include "cfg80211.h"
|
2015-07-28 17:47:22 +09:00
|
|
|
|
2015-05-11 14:30:56 +09:00
|
|
|
struct wilc_wfi_radiotap_hdr {
|
|
|
|
struct ieee80211_radiotap_header hdr;
|
|
|
|
u8 rate;
|
2016-02-01 21:26:37 +09:00
|
|
|
} __packed;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
|
|
|
struct wilc_wfi_radiotap_cb_hdr {
|
|
|
|
struct ieee80211_radiotap_header hdr;
|
|
|
|
u8 rate;
|
|
|
|
u8 dump;
|
|
|
|
u16 tx_flags;
|
2016-02-01 21:26:37 +09:00
|
|
|
} __packed;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-05-11 13:43:26 +05:30
|
|
|
#define TX_RADIOTAP_PRESENT ((1 << IEEE80211_RADIOTAP_RATE) | \
|
|
|
|
(1 << IEEE80211_RADIOTAP_TX_FLAGS))
|
|
|
|
|
2019-02-02 19:16:53 +00:00
|
|
|
void wilc_wfi_monitor_rx(struct net_device *mon_dev, u8 *buff, u32 size)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2015-09-15 14:06:16 +09:00
|
|
|
u32 header, pkt_offset;
|
2015-05-11 14:30:56 +09:00
|
|
|
struct sk_buff *skb = NULL;
|
|
|
|
struct wilc_wfi_radiotap_hdr *hdr;
|
|
|
|
struct wilc_wfi_radiotap_cb_hdr *cb_hdr;
|
|
|
|
|
2019-02-02 19:16:53 +00:00
|
|
|
if (!mon_dev)
|
2015-05-11 14:30:56 +09:00
|
|
|
return;
|
|
|
|
|
2019-02-02 19:16:53 +00:00
|
|
|
if (!netif_running(mon_dev))
|
2015-05-11 14:30:56 +09:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* Get WILC header */
|
2019-07-25 10:52:03 +08:00
|
|
|
header = get_unaligned_le32(buff - HOST_HDR_OFFSET);
|
2016-03-14 18:06:54 +05:30
|
|
|
/*
|
|
|
|
* The packet offset field contain info about what type of management
|
|
|
|
* the frame we are dealing with and ack status
|
|
|
|
*/
|
2020-02-14 11:52:15 +00:00
|
|
|
pkt_offset = FIELD_GET(WILC_PKT_HDR_OFFSET_FIELD, header);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
|
|
|
if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
|
|
|
|
/* hostapd callback mgmt frame */
|
|
|
|
|
2018-05-11 13:43:10 +05:30
|
|
|
skb = dev_alloc_skb(size + sizeof(*cb_hdr));
|
2016-02-22 13:11:52 +09:00
|
|
|
if (!skb)
|
2015-05-11 14:30:56 +09:00
|
|
|
return;
|
|
|
|
|
networking: introduce and use skb_put_data()
A common pattern with skb_put() is to just want to memcpy()
some data into the new space, introduce skb_put_data() for
this.
An spatch similar to the one for skb_put_zero() converts many
of the places using it:
@@
identifier p, p2;
expression len, skb, data;
type t, t2;
@@
(
-p = skb_put(skb, len);
+p = skb_put_data(skb, data, len);
|
-p = (t)skb_put(skb, len);
+p = skb_put_data(skb, data, len);
)
(
p2 = (t2)p;
-memcpy(p2, data, len);
|
-memcpy(p, data, len);
)
@@
type t, t2;
identifier p, p2;
expression skb, data;
@@
t *p;
...
(
-p = skb_put(skb, sizeof(t));
+p = skb_put_data(skb, data, sizeof(t));
|
-p = (t *)skb_put(skb, sizeof(t));
+p = skb_put_data(skb, data, sizeof(t));
)
(
p2 = (t2)p;
-memcpy(p2, data, sizeof(*p));
|
-memcpy(p, data, sizeof(*p));
)
@@
expression skb, len, data;
@@
-memcpy(skb_put(skb, len), data, len);
+skb_put_data(skb, data, len);
(again, manually post-processed to retain some comments)
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16 14:29:20 +02:00
|
|
|
skb_put_data(skb, buff, size);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
networking: make skb_push & __skb_push return void pointers
It seems like a historic accident that these return unsigned char *,
and in many places that means casts are required, more often than not.
Make these functions return void * and remove all the casts across
the tree, adding a (u8 *) cast only where the unsigned char pointer
was used directly, all done with the following spatch:
@@
expression SKB, LEN;
typedef u8;
identifier fn = { skb_push, __skb_push, skb_push_rcsum };
@@
- *(fn(SKB, LEN))
+ *(u8 *)fn(SKB, LEN)
@@
expression E, SKB, LEN;
identifier fn = { skb_push, __skb_push, skb_push_rcsum };
type T;
@@
- E = ((T *)(fn(SKB, LEN)))
+ E = fn(SKB, LEN)
@@
expression SKB, LEN;
identifier fn = { skb_push, __skb_push, skb_push_rcsum };
@@
- fn(SKB, LEN)[0]
+ *(u8 *)fn(SKB, LEN)
Note that the last part there converts from push(...)[0] to the
more idiomatic *(u8 *)push(...).
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16 14:29:23 +02:00
|
|
|
cb_hdr = skb_push(skb, sizeof(*cb_hdr));
|
2018-05-11 13:43:10 +05:30
|
|
|
memset(cb_hdr, 0, sizeof(*cb_hdr));
|
2015-05-11 14:30:56 +09:00
|
|
|
|
|
|
|
cb_hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */
|
|
|
|
|
2018-05-11 13:43:10 +05:30
|
|
|
cb_hdr->hdr.it_len = cpu_to_le16(sizeof(*cb_hdr));
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-05-11 13:43:26 +05:30
|
|
|
cb_hdr->hdr.it_present = cpu_to_le32(TX_RADIOTAP_PRESENT);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-07-29 11:36:51 +05:30
|
|
|
cb_hdr->rate = 5;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
|
|
|
if (pkt_offset & IS_MGMT_STATUS_SUCCES) {
|
|
|
|
/* success */
|
|
|
|
cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_RTS;
|
|
|
|
} else {
|
|
|
|
cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2018-05-11 13:43:10 +05:30
|
|
|
skb = dev_alloc_skb(size + sizeof(*hdr));
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2016-02-22 13:11:52 +09:00
|
|
|
if (!skb)
|
2015-05-11 14:30:56 +09:00
|
|
|
return;
|
|
|
|
|
networking: introduce and use skb_put_data()
A common pattern with skb_put() is to just want to memcpy()
some data into the new space, introduce skb_put_data() for
this.
An spatch similar to the one for skb_put_zero() converts many
of the places using it:
@@
identifier p, p2;
expression len, skb, data;
type t, t2;
@@
(
-p = skb_put(skb, len);
+p = skb_put_data(skb, data, len);
|
-p = (t)skb_put(skb, len);
+p = skb_put_data(skb, data, len);
)
(
p2 = (t2)p;
-memcpy(p2, data, len);
|
-memcpy(p, data, len);
)
@@
type t, t2;
identifier p, p2;
expression skb, data;
@@
t *p;
...
(
-p = skb_put(skb, sizeof(t));
+p = skb_put_data(skb, data, sizeof(t));
|
-p = (t *)skb_put(skb, sizeof(t));
+p = skb_put_data(skb, data, sizeof(t));
)
(
p2 = (t2)p;
-memcpy(p2, data, sizeof(*p));
|
-memcpy(p, data, sizeof(*p));
)
@@
expression skb, len, data;
@@
-memcpy(skb_put(skb, len), data, len);
+skb_put_data(skb, data, len);
(again, manually post-processed to retain some comments)
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16 14:29:20 +02:00
|
|
|
skb_put_data(skb, buff, size);
|
networking: make skb_push & __skb_push return void pointers
It seems like a historic accident that these return unsigned char *,
and in many places that means casts are required, more often than not.
Make these functions return void * and remove all the casts across
the tree, adding a (u8 *) cast only where the unsigned char pointer
was used directly, all done with the following spatch:
@@
expression SKB, LEN;
typedef u8;
identifier fn = { skb_push, __skb_push, skb_push_rcsum };
@@
- *(fn(SKB, LEN))
+ *(u8 *)fn(SKB, LEN)
@@
expression E, SKB, LEN;
identifier fn = { skb_push, __skb_push, skb_push_rcsum };
type T;
@@
- E = ((T *)(fn(SKB, LEN)))
+ E = fn(SKB, LEN)
@@
expression SKB, LEN;
identifier fn = { skb_push, __skb_push, skb_push_rcsum };
@@
- fn(SKB, LEN)[0]
+ *(u8 *)fn(SKB, LEN)
Note that the last part there converts from push(...)[0] to the
more idiomatic *(u8 *)push(...).
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16 14:29:23 +02:00
|
|
|
hdr = skb_push(skb, sizeof(*hdr));
|
2015-05-11 14:30:56 +09:00
|
|
|
memset(hdr, 0, sizeof(struct wilc_wfi_radiotap_hdr));
|
|
|
|
hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */
|
2018-05-11 13:43:10 +05:30
|
|
|
hdr->hdr.it_len = cpu_to_le16(sizeof(*hdr));
|
2015-05-11 14:30:56 +09:00
|
|
|
hdr->hdr.it_present = cpu_to_le32
|
2018-07-29 11:36:51 +05:30
|
|
|
(1 << IEEE80211_RADIOTAP_RATE);
|
|
|
|
hdr->rate = 5;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2019-02-02 19:16:53 +00:00
|
|
|
skb->dev = mon_dev;
|
2016-12-02 09:51:07 +08:00
|
|
|
skb_reset_mac_header(skb);
|
2015-05-11 14:30:56 +09:00
|
|
|
skb->ip_summed = CHECKSUM_UNNECESSARY;
|
|
|
|
skb->pkt_type = PACKET_OTHERHOST;
|
|
|
|
skb->protocol = htons(ETH_P_802_2);
|
|
|
|
memset(skb->cb, 0, sizeof(skb->cb));
|
|
|
|
|
|
|
|
netif_rx(skb);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct tx_complete_mon_data {
|
|
|
|
int size;
|
|
|
|
void *buff;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void mgmt_tx_complete(void *priv, int status)
|
|
|
|
{
|
2016-02-12 22:52:11 -08:00
|
|
|
struct tx_complete_mon_data *pv_data = priv;
|
2016-03-14 18:06:54 +05:30
|
|
|
/*
|
|
|
|
* in case of fully hosting mode, the freeing will be done
|
|
|
|
* in response to the cfg packet
|
|
|
|
*/
|
2015-05-11 14:30:56 +09:00
|
|
|
kfree(pv_data->buff);
|
|
|
|
|
|
|
|
kfree(pv_data);
|
|
|
|
}
|
2016-02-01 21:26:43 +09:00
|
|
|
|
2015-05-11 14:30:56 +09:00
|
|
|
static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len)
|
|
|
|
{
|
|
|
|
struct tx_complete_mon_data *mgmt_tx = NULL;
|
|
|
|
|
2016-02-22 13:11:47 +09:00
|
|
|
if (!dev)
|
2015-09-16 18:36:03 +09:00
|
|
|
return -EFAULT;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
|
|
|
netif_stop_queue(dev);
|
2016-02-01 21:26:45 +09:00
|
|
|
mgmt_tx = kmalloc(sizeof(*mgmt_tx), GFP_ATOMIC);
|
2016-02-01 21:26:47 +09:00
|
|
|
if (!mgmt_tx)
|
2016-02-01 21:26:46 +09:00
|
|
|
return -ENOMEM;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-03-14 18:15:01 +05:30
|
|
|
mgmt_tx->buff = kmemdup(buf, len, GFP_ATOMIC);
|
2016-02-01 21:26:41 +09:00
|
|
|
if (!mgmt_tx->buff) {
|
2015-09-07 19:09:31 +09:00
|
|
|
kfree(mgmt_tx);
|
2016-02-01 21:26:46 +09:00
|
|
|
return -ENOMEM;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
mgmt_tx->size = len;
|
|
|
|
|
2015-10-29 12:18:44 +09:00
|
|
|
wilc_wlan_txq_add_mgmt_pkt(dev, mgmt_tx, mgmt_tx->buff, mgmt_tx->size,
|
2015-10-01 16:03:43 +09:00
|
|
|
mgmt_tx_complete);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
|
|
|
netif_wake_queue(dev);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-05-02 12:43:36 +05:30
|
|
|
static netdev_tx_t wilc_wfi_mon_xmit(struct sk_buff *skb,
|
2015-05-11 14:30:56 +09:00
|
|
|
struct net_device *dev)
|
|
|
|
{
|
2016-02-22 13:11:52 +09:00
|
|
|
u32 rtap_len, ret = 0;
|
2018-05-02 12:43:35 +05:30
|
|
|
struct wilc_wfi_mon_priv *mon_priv;
|
2015-05-11 14:30:56 +09:00
|
|
|
struct sk_buff *skb2;
|
|
|
|
struct wilc_wfi_radiotap_cb_hdr *cb_hdr;
|
2019-02-05 07:15:56 +00:00
|
|
|
u8 srcadd[ETH_ALEN];
|
|
|
|
u8 bssid[ETH_ALEN];
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-02-02 19:16:53 +00:00
|
|
|
mon_priv = netdev_priv(dev);
|
2016-02-22 13:11:47 +09:00
|
|
|
if (!mon_priv)
|
2015-09-16 18:36:03 +09:00
|
|
|
return -EFAULT;
|
2019-02-02 19:16:53 +00:00
|
|
|
|
2015-05-11 14:30:56 +09:00
|
|
|
rtap_len = ieee80211_get_radiotap_len(skb->data);
|
2016-02-22 13:11:47 +09:00
|
|
|
if (skb->len < rtap_len)
|
2015-05-11 14:30:56 +09:00
|
|
|
return -1;
|
2016-02-22 13:11:47 +09:00
|
|
|
|
2015-05-11 14:30:56 +09:00
|
|
|
skb_pull(skb, rtap_len);
|
|
|
|
|
2018-05-02 12:43:45 +05:30
|
|
|
if (skb->data[0] == 0xc0 && is_broadcast_ether_addr(&skb->data[4])) {
|
2018-05-11 13:43:10 +05:30
|
|
|
skb2 = dev_alloc_skb(skb->len + sizeof(*cb_hdr));
|
2017-04-23 19:53:58 +08:00
|
|
|
if (!skb2)
|
|
|
|
return -ENOMEM;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
networking: introduce and use skb_put_data()
A common pattern with skb_put() is to just want to memcpy()
some data into the new space, introduce skb_put_data() for
this.
An spatch similar to the one for skb_put_zero() converts many
of the places using it:
@@
identifier p, p2;
expression len, skb, data;
type t, t2;
@@
(
-p = skb_put(skb, len);
+p = skb_put_data(skb, data, len);
|
-p = (t)skb_put(skb, len);
+p = skb_put_data(skb, data, len);
)
(
p2 = (t2)p;
-memcpy(p2, data, len);
|
-memcpy(p, data, len);
)
@@
type t, t2;
identifier p, p2;
expression skb, data;
@@
t *p;
...
(
-p = skb_put(skb, sizeof(t));
+p = skb_put_data(skb, data, sizeof(t));
|
-p = (t *)skb_put(skb, sizeof(t));
+p = skb_put_data(skb, data, sizeof(t));
)
(
p2 = (t2)p;
-memcpy(p2, data, sizeof(*p));
|
-memcpy(p, data, sizeof(*p));
)
@@
expression skb, len, data;
@@
-memcpy(skb_put(skb, len), data, len);
+skb_put_data(skb, data, len);
(again, manually post-processed to retain some comments)
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16 14:29:20 +02:00
|
|
|
skb_put_data(skb2, skb->data, skb->len);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
networking: make skb_push & __skb_push return void pointers
It seems like a historic accident that these return unsigned char *,
and in many places that means casts are required, more often than not.
Make these functions return void * and remove all the casts across
the tree, adding a (u8 *) cast only where the unsigned char pointer
was used directly, all done with the following spatch:
@@
expression SKB, LEN;
typedef u8;
identifier fn = { skb_push, __skb_push, skb_push_rcsum };
@@
- *(fn(SKB, LEN))
+ *(u8 *)fn(SKB, LEN)
@@
expression E, SKB, LEN;
identifier fn = { skb_push, __skb_push, skb_push_rcsum };
type T;
@@
- E = ((T *)(fn(SKB, LEN)))
+ E = fn(SKB, LEN)
@@
expression SKB, LEN;
identifier fn = { skb_push, __skb_push, skb_push_rcsum };
@@
- fn(SKB, LEN)[0]
+ *(u8 *)fn(SKB, LEN)
Note that the last part there converts from push(...)[0] to the
more idiomatic *(u8 *)push(...).
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16 14:29:23 +02:00
|
|
|
cb_hdr = skb_push(skb2, sizeof(*cb_hdr));
|
2015-05-11 14:30:56 +09:00
|
|
|
memset(cb_hdr, 0, sizeof(struct wilc_wfi_radiotap_cb_hdr));
|
|
|
|
|
|
|
|
cb_hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */
|
|
|
|
|
2018-05-11 13:43:10 +05:30
|
|
|
cb_hdr->hdr.it_len = cpu_to_le16(sizeof(*cb_hdr));
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-05-11 13:43:26 +05:30
|
|
|
cb_hdr->hdr.it_present = cpu_to_le32(TX_RADIOTAP_PRESENT);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2018-07-29 11:36:51 +05:30
|
|
|
cb_hdr->rate = 5;
|
2015-05-11 14:30:56 +09:00
|
|
|
cb_hdr->tx_flags = 0x0004;
|
|
|
|
|
2019-02-02 19:16:53 +00:00
|
|
|
skb2->dev = dev;
|
2016-12-02 09:51:07 +08:00
|
|
|
skb_reset_mac_header(skb2);
|
2015-05-11 14:30:56 +09:00
|
|
|
skb2->ip_summed = CHECKSUM_UNNECESSARY;
|
|
|
|
skb2->pkt_type = PACKET_OTHERHOST;
|
|
|
|
skb2->protocol = htons(ETH_P_802_2);
|
|
|
|
memset(skb2->cb, 0, sizeof(skb2->cb));
|
|
|
|
|
|
|
|
netif_rx(skb2);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
skb->dev = mon_priv->real_ndev;
|
|
|
|
|
2019-02-05 07:15:56 +00:00
|
|
|
ether_addr_copy(srcadd, &skb->data[10]);
|
|
|
|
ether_addr_copy(bssid, &skb->data[16]);
|
2018-07-29 11:36:51 +05:30
|
|
|
/*
|
|
|
|
* Identify if data or mgmt packet, if source address and bssid
|
|
|
|
* fields are equal send it to mgmt frames handler
|
|
|
|
*/
|
2016-03-22 18:01:42 +05:30
|
|
|
if (!(memcmp(srcadd, bssid, 6))) {
|
2016-02-22 13:11:49 +09:00
|
|
|
ret = mon_mgmt_tx(mon_priv->real_ndev, skb->data, skb->len);
|
|
|
|
if (ret)
|
|
|
|
netdev_err(dev, "fail to mgmt tx\n");
|
2015-05-11 14:30:56 +09:00
|
|
|
dev_kfree_skb(skb);
|
2016-02-01 21:26:44 +09:00
|
|
|
} else {
|
2015-11-16 15:04:54 +01:00
|
|
|
ret = wilc_mac_xmit(skb, mon_priv->real_ndev);
|
2016-02-01 21:26:44 +09:00
|
|
|
}
|
2015-05-11 14:30:56 +09:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct net_device_ops wilc_wfi_netdev_ops = {
|
2018-05-02 12:43:36 +05:30
|
|
|
.ndo_start_xmit = wilc_wfi_mon_xmit,
|
2015-05-11 14:30:56 +09:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2019-02-02 19:16:53 +00:00
|
|
|
struct net_device *wilc_wfi_init_mon_interface(struct wilc *wl,
|
|
|
|
const char *name,
|
2016-03-14 18:06:54 +05:30
|
|
|
struct net_device *real_dev)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2018-05-02 12:43:35 +05:30
|
|
|
struct wilc_wfi_mon_priv *priv;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-11-05 09:51:33 +00:00
|
|
|
/* If monitor interface is already initialized, return it */
|
2019-02-02 19:16:53 +00:00
|
|
|
if (wl->monitor_dev)
|
|
|
|
return wl->monitor_dev;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-02-02 19:16:53 +00:00
|
|
|
wl->monitor_dev = alloc_etherdev(sizeof(struct wilc_wfi_mon_priv));
|
|
|
|
if (!wl->monitor_dev)
|
2015-05-11 14:30:56 +09:00
|
|
|
return NULL;
|
|
|
|
|
2019-02-02 19:16:53 +00:00
|
|
|
wl->monitor_dev->type = ARPHRD_IEEE80211_RADIOTAP;
|
2020-07-10 05:18:30 +00:00
|
|
|
strlcpy(wl->monitor_dev->name, name, IFNAMSIZ);
|
2019-02-02 19:16:53 +00:00
|
|
|
wl->monitor_dev->netdev_ops = &wilc_wfi_netdev_ops;
|
2019-06-26 12:40:52 +00:00
|
|
|
wl->monitor_dev->needs_free_netdev = true;
|
2019-02-02 19:16:53 +00:00
|
|
|
|
2022-05-04 16:19:26 +00:00
|
|
|
if (register_netdevice(wl->monitor_dev)) {
|
2016-02-22 13:11:48 +09:00
|
|
|
netdev_err(real_dev, "register_netdevice failed\n");
|
2020-09-17 08:30:19 -04:00
|
|
|
free_netdev(wl->monitor_dev);
|
2015-05-11 14:30:56 +09:00
|
|
|
return NULL;
|
|
|
|
}
|
2019-02-02 19:16:53 +00:00
|
|
|
priv = netdev_priv(wl->monitor_dev);
|
2015-05-11 14:30:56 +09:00
|
|
|
|
|
|
|
priv->real_ndev = real_dev;
|
|
|
|
|
2019-02-02 19:16:53 +00:00
|
|
|
return wl->monitor_dev;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|
|
|
|
|
2019-06-26 12:40:52 +00:00
|
|
|
void wilc_wfi_deinit_mon_interface(struct wilc *wl, bool rtnl_locked)
|
2015-05-11 14:30:56 +09:00
|
|
|
{
|
2019-02-02 19:16:56 +00:00
|
|
|
if (!wl->monitor_dev)
|
|
|
|
return;
|
2015-05-11 14:30:56 +09:00
|
|
|
|
2019-06-26 12:40:52 +00:00
|
|
|
if (rtnl_locked)
|
2022-05-04 16:19:26 +00:00
|
|
|
unregister_netdevice(wl->monitor_dev);
|
2019-06-26 12:40:52 +00:00
|
|
|
else
|
|
|
|
unregister_netdev(wl->monitor_dev);
|
2019-02-02 19:16:56 +00:00
|
|
|
wl->monitor_dev = NULL;
|
2015-05-11 14:30:56 +09:00
|
|
|
}
|