IFF_PROMISC support
Gerald Britton
gbritton
Wed Nov 20 11:33:24 PST 2002
Here's my patch again, rediffed and updated for current CVS.
This implements IFF_PROMISC and IFF_ALLMULTI (via just setting promisc).
It appears to work as expected. It also quiets the messages generated
while in promisc mode (the wlan-ng driver does the same).
-- Gerald
-------------- next part --------------
--- hostap/driver/modules/hostap.c.promisc 2002-11-17 15:00:12.000000000 -0500
+++ hostap/driver/modules/hostap.c 2002-11-19 19:14:26.000000000 -0500
@@ -56,6 +56,7 @@
int rtnl_locked);
static int prism2_wds_del(local_info_t *local, u8 *remote_addr,
int rtnl_locked, int do_not_remove);
+static void prism2_do_set_mc_list(void *data);
/* hostap_ap.c */
#ifdef WIRELESS_EXT
@@ -684,6 +685,8 @@
netif_device_attach(dev);
netif_start_queue(dev);
+ HOSTAP_QUEUE_INIT(&local->set_mc_queue, prism2_do_set_mc_list, dev);
+
return 0;
}
@@ -718,6 +721,51 @@
#endif /* HAVE_SET_MAC_ADDR */
+/* TODO: to be further implemented as soon as Prism2 fully supports
+ * GroupAddresses and correct documentation is available */
+static void prism2_do_set_mc_list(void *data)
+{
+ struct net_device *dev = (struct net_device *)data;
+ local_info_t *local = (local_info_t *) dev->priv;
+
+ local->is_promisc = 0;
+
+ if (dev->flags & IFF_ALLMULTI) {
+ local->is_promisc = 1;
+ }
+
+ if (dev->flags & IFF_PROMISC) {
+ local->is_promisc = 1;
+ }
+
+ if (hostap_set_word(dev, HFA384X_RID_PROMISCUOUSMODE,
+ local->is_promisc)) {
+ printk("%s: %sabling promiscuous mode failed\n",
+ dev->name, local->is_promisc ? "en" : "dis");
+ }
+
+ MOD_DEC_USE_COUNT;
+}
+
+static void prism2_set_multicast_list(struct net_device *dev)
+{
+ local_info_t *local = (local_info_t *) dev->priv;
+ int promisc = 0;
+
+ if (dev->flags & IFF_ALLMULTI) {
+ promisc = 1;
+ }
+
+ if (dev->flags & IFF_PROMISC) {
+ promisc = 1;
+ }
+
+ if (promisc != local->is_promisc) {
+ PRISM2_SCHEDULE_TASK(&local->set_mc_queue);
+ }
+}
+
+
static int prism2_change_mtu(struct net_device *dev, int new_mtu)
{
if (new_mtu < PRISM2_MIN_MTU || new_mtu > PRISM2_MAX_MTU)
@@ -771,12 +819,7 @@
#ifdef HAVE_SET_MAC_ADDR
dev->set_mac_address = prism2_set_mac_address;
#endif /* HAVE_SET_MAC_ADDR */
-#ifdef HAVE_MULTICAST
- /* FIX: to be implemented as soon as Prism2 supports GroupAddresses
- * and correct documentation is available */
-
- /* dev->set_multicast_list = prism2_set_multicast_list; */
-#endif
+ dev->set_multicast_list = prism2_set_multicast_list;
#ifdef HAVE_PRIVATE_IOCTL
dev->do_ioctl = main_dev ? hostap_ioctl : NULL;
#endif
--- hostap/driver/modules/hostap_hw.c.promisc 2002-11-17 19:28:30.000000000 -0500
+++ hostap/driver/modules/hostap_hw.c 2002-11-19 19:08:43.000000000 -0500
@@ -919,6 +919,22 @@
goto fail;
}
+ local->is_promisc = 0;
+
+ if (dev->flags & IFF_ALLMULTI) {
+ local->is_promisc = 1;
+ }
+
+ if (dev->flags & IFF_PROMISC) {
+ local->is_promisc = 1;
+ }
+
+ ret = hostap_set_word(dev, HFA384X_RID_PROMISCUOUSMODE,
+ local->is_promisc);
+ if (ret)
+ printk("%s: %sabling promiscuous mode failed\n",
+ dev->name, local->is_promisc ? "en" : "dis");
+
if (!local->fw_ap) {
ret = hostap_set_string(dev, HFA384X_RID_CNFDESIREDSSID,
local->essid);
@@ -2439,7 +2455,7 @@
if (macport != 0) {
if (macport == 7) {
monitor_rx(dev, rxdesc);
- } else {
+ } else if (!local->is_promisc) {
printk(KERN_DEBUG "RX: Unknown MACPort %d\n", macport);
}
goto rx_dropped;
@@ -2448,8 +2464,9 @@
/* FCS errors should not come this far, but let's make sure that frames
* with errors will be dropped even in Host AP mode */
if (status & HFA384X_RX_STATUS_FCSERR) {
- printk(KERN_DEBUG "%s: prism2_rx: dropped FCSErr frame "
- "(status=%02X)\n", dev->name, status);
+ if (!local->is_promisc)
+ printk(KERN_DEBUG "%s: prism2_rx: dropped FCSErr frame"
+ " (status=%02X)\n", dev->name, status);
goto rx_dropped;
}
--- hostap/driver/modules/hostap_wlan.h.promisc 2002-11-17 19:28:30.000000000 -0500
+++ hostap/driver/modules/hostap_wlan.h 2002-11-19 19:15:10.000000000 -0500
@@ -1117,6 +1117,14 @@
struct work_struct bridge_queue;
#endif
+ /* For scheduling a change of the promiscuous mode RID */
+ int is_promisc;
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,44))
+ struct tq_struct set_mc_queue;
+#else
+ struct work_struct set_mc_queue
+#endif
+
/* command queue for hfa384x_cmd(); protected with cmdlock */
struct list_head cmd_queue;
/* max_len for cmd_queue; in addition, cmd_callback can use two
More information about the Hostap
mailing list