The capwap data channel migrated from userspace to kernalspace

This commit is contained in:
vemax78
2014-09-10 21:58:23 +02:00
parent 71006a9121
commit 8d9985fdea
104 changed files with 6967 additions and 4840 deletions

View File

@ -40,7 +40,7 @@ define KernelPackage/smartcapwap
SUBMENU:=Network Support
TITLE:=SmartCAPWAP Data Channel Module
MAINTAINER:=Massimo Vellucci <vemax78@gmail.com>
DEPENDS:=+kmod-mac80211
DEPENDS:=+kmod-mac80211 +kmod-ipv6
FILES:=$(PKG_BUILD_DIR)/src/wtp/kmod/smartcapwap.ko
AUTOLOAD:=$(call AutoLoad,70,smartcapwap)
endef
@ -74,7 +74,7 @@ define Build/Compile/kmod
SUBDIRS="$(PKG_BUILD_DIR)/src/wtp/kmod" \
KLIB_BUILD="$(LINUX_DIR)" \
KLIB="$(TARGET_MODULES_DIR)" \
KBUILD_EXTRA_SYMBOLS="$(LINUX_DIR)/../compat-wireless-2014-03-31/Module.symvers" \
KBUILD_EXTRA_SYMBOLS="$(LINUX_DIR)/../compat-wireless-2014-05-22/Module.symvers" \
LINUXINCLUDE="-I$(STAGING_DIR)/usr/include/mac80211-backport/uapi \
-I$(STAGING_DIR)/usr/include/mac80211-backport \
-I$(STAGING_DIR)/usr/include/mac80211/uapi \

View File

@ -1,6 +1,6 @@
--- a/include/net/mac80211.h 2014-06-02 11:48:37.000000000 +0200
+++ b/include/net/mac80211.h 2014-06-07 17:23:03.000000000 +0200
@@ -4699,4 +4699,24 @@ int ieee80211_parse_p2p_noa(const struct
--- a/include/net/mac80211.h 2014-07-10 19:19:55.000000000 +0200
+++ b/include/net/mac80211.h 2014-07-10 20:52:02.000000000 +0200
@@ -4772,4 +4772,24 @@ int ieee80211_parse_p2p_noa(const struct
*/
void ieee80211_update_p2p_noa(struct ieee80211_noa_data *data, u32 tsf);
@ -17,16 +17,16 @@
+/**
+ *
+ */
+int ieee80211_pcktunnel_register(u32 ifindex, struct ieee80211_pcktunnel *handler);
+int ieee80211_pcktunnel_register(struct net_device *dev, struct ieee80211_pcktunnel *handler);
+
+/**
+ *
+ */
+int ieee80211_pcktunnel_deregister(u32 ifindex, struct ieee80211_pcktunnel *handler);
+int ieee80211_pcktunnel_deregister(struct net_device *dev, struct ieee80211_pcktunnel *handler);
+
#endif /* MAC80211_H */
--- a/net/mac80211/ieee80211_i.h 2014-06-02 11:48:37.000000000 +0200
+++ b/net/mac80211/ieee80211_i.h 2014-06-07 17:14:25.000000000 +0200
--- a/net/mac80211/ieee80211_i.h 2014-07-10 19:19:55.000000000 +0200
+++ b/net/mac80211/ieee80211_i.h 2014-07-10 20:47:56.000000000 +0200
@@ -165,6 +165,7 @@ typedef unsigned __bitwise__ ieee80211_r
#define RX_DROP_UNUSABLE ((__force ieee80211_rx_result) 1u)
#define RX_DROP_MONITOR ((__force ieee80211_rx_result) 2u)
@ -35,7 +35,7 @@
/**
* enum ieee80211_packet_rx_flags - packet RX flags
@@ -727,6 +728,9 @@ struct ieee80211_sub_if_data {
@@ -743,6 +744,9 @@ struct ieee80211_sub_if_data {
char name[IFNAMSIZ];
@ -45,34 +45,17 @@
/* Fragment table for host-based reassembly */
struct ieee80211_fragment_entry fragments[IEEE80211_FRAGMENT_MAX];
unsigned int fragment_next;
--- a/net/mac80211/iface.c 2014-06-02 11:48:37.000000000 +0200
+++ b/net/mac80211/iface.c 2014-06-04 22:52:06.000000000 +0200
@@ -1850,3 +1850,80 @@ void ieee80211_iface_exit(void)
--- a/net/mac80211/iface.c 2014-07-10 19:19:55.000000000 +0200
+++ b/net/mac80211/iface.c 2014-07-10 20:51:28.000000000 +0200
@@ -1844,3 +1844,45 @@ void ieee80211_iface_exit(void)
{
unregister_netdevice_notifier(&mac80211_netdev_notifier);
}
+
+
+int ieee80211_pcktunnel_register(u32 ifindex, struct ieee80211_pcktunnel *handler)
+int ieee80211_pcktunnel_register(struct net_device *dev, struct ieee80211_pcktunnel *handler)
+{
+ int ret = 0;
+ struct net_device *dev;
+ struct ieee80211_sub_if_data *sdata;
+
+ /* Retrieve device from ifindex */
+ dev = dev_get_by_index(&init_net, ifindex);
+ if (!dev) {
+ return -ENODEV;
+ }
+
+ /* Check if wireless device */
+ if (!dev->ieee80211_ptr || !dev->ieee80211_ptr->wiphy) {
+ dev_put(dev);
+ return -EINVAL;
+ }
+
+ /* Add handler to list */
+ sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+ struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+
+ mutex_lock(&sdata->local->iflist_mtx);
+
@ -85,33 +68,16 @@
+ mutex_unlock(&sdata->local->iflist_mtx);
+ synchronize_net();
+
+ dev_put(dev);
+ return ret;
+}
+EXPORT_SYMBOL(ieee80211_pcktunnel_register);
+
+int ieee80211_pcktunnel_deregister(u32 ifindex, struct ieee80211_pcktunnel *handler)
+int ieee80211_pcktunnel_deregister(struct net_device *dev, struct ieee80211_pcktunnel *handler)
+{
+ int ret = -ENODEV;
+ struct net_device *dev;
+ struct ieee80211_sub_if_data *sdata;
+ struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+ struct ieee80211_pcktunnel *h;
+
+ /* Retrieve device from ifindex */
+ dev = dev_get_by_index(&init_net, ifindex);
+ if (!dev) {
+ return -ENODEV;
+ }
+
+ /* Check if wireless device */
+ if (!dev->ieee80211_ptr || !dev->ieee80211_ptr->wiphy) {
+ dev_put(dev);
+ return -EINVAL;
+ }
+
+ /* Remove handler from list */
+ sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+
+ mutex_lock(&sdata->local->iflist_mtx);
+
+ h = rcu_dereference_protected(sdata->pcktunnel_handlers, lockdep_is_held(&sdata->local->iflist_mtx));
@ -123,14 +89,13 @@
+ mutex_unlock(&sdata->local->iflist_mtx);
+ synchronize_net();
+
+ dev_put(dev);
+ return ret;
+}
+EXPORT_SYMBOL(ieee80211_pcktunnel_deregister);
+
--- a/net/mac80211/rx.c 2014-06-02 11:48:37.000000000 +0200
+++ b/net/mac80211/rx.c 2014-06-07 17:22:05.000000000 +0200
@@ -2828,6 +2828,51 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
--- a/net/mac80211/rx.c 2014-07-10 19:19:55.000000000 +0200
+++ b/net/mac80211/rx.c 2014-07-10 21:01:19.000000000 +0200
@@ -2831,6 +2831,51 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
return RX_QUEUED;
}
@ -182,7 +147,7 @@
/* TODO: use IEEE80211_RX_FRAGMENTED */
static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx,
struct ieee80211_rate *rate)
@@ -2907,6 +2952,7 @@ static void ieee80211_rx_handlers_result
@@ -2910,6 +2955,7 @@ static void ieee80211_rx_handlers_result
if (rx->sta)
rx->sta->rx_dropped++;
/* fall through */
@ -190,17 +155,18 @@
case RX_CONTINUE: {
struct ieee80211_rate *rate = NULL;
struct ieee80211_supported_band *sband;
@@ -2935,7 +2981,8 @@ static void ieee80211_rx_handlers_result
@@ -2938,7 +2984,9 @@ static void ieee80211_rx_handlers_result
}
static void ieee80211_rx_handlers(struct ieee80211_rx_data *rx,
- struct sk_buff_head *frames)
+ struct sk_buff_head *frames,
+ struct ieee80211_rate *rate)
+
{
ieee80211_rx_result res = RX_DROP_MONITOR;
struct sk_buff *skb;
@@ -2968,6 +3015,11 @@ static void ieee80211_rx_handlers(struct
@@ -2971,6 +3019,11 @@ static void ieee80211_rx_handlers(struct
if (ieee80211_vif_is_mesh(&rx->sdata->vif))
CALL_RXH(ieee80211_rx_h_mesh_fwding);
#endif
@ -212,7 +178,7 @@
CALL_RXH(ieee80211_rx_h_amsdu)
CALL_RXH(ieee80211_rx_h_data)
@@ -2991,7 +3043,8 @@ static void ieee80211_rx_handlers(struct
@@ -2994,7 +3047,8 @@ static void ieee80211_rx_handlers(struct
spin_unlock_bh(&rx->local->rx_path_lock);
}
@ -222,7 +188,7 @@
{
struct sk_buff_head reorder_release;
ieee80211_rx_result res = RX_DROP_MONITOR;
@@ -3009,7 +3062,7 @@ static void ieee80211_invoke_rx_handlers
@@ -3012,7 +3066,7 @@ static void ieee80211_invoke_rx_handlers
ieee80211_rx_reorder_ampdu(rx, &reorder_release);
@ -231,7 +197,7 @@
return;
rxh_next:
@@ -3046,7 +3099,7 @@ void ieee80211_release_reorder_timeout(s
@@ -3049,7 +3103,7 @@ void ieee80211_release_reorder_timeout(s
ieee80211_sta_reorder_release(sta->sdata, tid_agg_rx, &frames);
spin_unlock(&tid_agg_rx->reorder_lock);
@ -240,7 +206,7 @@
}
/* main receive path */
@@ -3160,7 +3213,9 @@ static bool prepare_for_handlers(struct
@@ -3163,7 +3217,9 @@ static bool prepare_for_handlers(struct
* or not the skb was consumed.
*/
static bool ieee80211_prepare_and_rx_handle(struct ieee80211_rx_data *rx,
@ -251,7 +217,7 @@
{
struct ieee80211_local *local = rx->local;
struct ieee80211_sub_if_data *sdata = rx->sdata;
@@ -3186,7 +3241,7 @@ static bool ieee80211_prepare_and_rx_han
@@ -3189,7 +3245,7 @@ static bool ieee80211_prepare_and_rx_han
rx->skb = skb;
}
@ -260,7 +226,7 @@
return true;
}
@@ -3195,7 +3250,8 @@ static bool ieee80211_prepare_and_rx_han
@@ -3198,7 +3254,8 @@ static bool ieee80211_prepare_and_rx_han
* be called with rcu_read_lock protection.
*/
static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
@ -270,7 +236,7 @@
{
struct ieee80211_local *local = hw_to_local(hw);
struct ieee80211_sub_if_data *sdata;
@@ -3248,7 +3304,7 @@ static void __ieee80211_rx_handle_packet
@@ -3251,7 +3308,7 @@ static void __ieee80211_rx_handle_packet
rx.sta = prev_sta;
rx.sdata = prev_sta->sdata;
@ -279,7 +245,7 @@
prev_sta = sta;
}
@@ -3257,7 +3313,7 @@ static void __ieee80211_rx_handle_packet
@@ -3260,7 +3317,7 @@ static void __ieee80211_rx_handle_packet
rx.sta = prev_sta;
rx.sdata = prev_sta->sdata;
@ -288,7 +254,7 @@
return;
goto out;
}
@@ -3286,7 +3342,7 @@ static void __ieee80211_rx_handle_packet
@@ -3289,7 +3346,7 @@ static void __ieee80211_rx_handle_packet
rx.sta = sta_info_get_bss(prev, hdr->addr2);
rx.sdata = prev;
@ -297,7 +263,7 @@
prev = sdata;
}
@@ -3295,7 +3351,7 @@ static void __ieee80211_rx_handle_packet
@@ -3298,7 +3355,7 @@ static void __ieee80211_rx_handle_packet
rx.sta = sta_info_get_bss(prev, hdr->addr2);
rx.sdata = prev;
@ -306,7 +272,7 @@
return;
}
@@ -3406,7 +3462,7 @@ void ieee80211_rx(struct ieee80211_hw *h
@@ -3409,7 +3466,7 @@ void ieee80211_rx(struct ieee80211_hw *h
ieee80211_tpt_led_trig_rx(local,
((struct ieee80211_hdr *)skb->data)->frame_control,
skb->len);