#include "ieee80211_i.h"
 #include "ieee80211_rate.h"
+#ifdef CONFIG_MAC80211_MESH
+#include "mesh.h"
+#endif
 #include "wep.h"
 #include "wme.h"
 #include "aes_ccm.h"
 
 static int ieee80211_change_mtu(struct net_device *dev, int new_mtu)
 {
+       int meshhdrlen;
+       struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+
+       meshhdrlen = (sdata->vif.type == IEEE80211_IF_TYPE_MESH_POINT) ? 5 : 0;
+
        /* FIX: what would be proper limits for MTU?
         * This interface uses 802.3 frames. */
-       if (new_mtu < 256 || new_mtu > IEEE80211_MAX_DATA_LEN - 24 - 6) {
+       if (new_mtu < 256 ||
+               new_mtu > IEEE80211_MAX_DATA_LEN - 24 - 6 - meshhdrlen) {
                printk(KERN_WARNING "%s: invalid MTU %d\n",
                       dev->name, new_mtu);
                return -EINVAL;
                ieee80211_configure_filter(local);
                netif_tx_unlock_bh(local->mdev);
                break;
+       case IEEE80211_IF_TYPE_MESH_POINT:
+               sta_info_flush(local, dev);
+               /* fall through */
        case IEEE80211_IF_TYPE_STA:
        case IEEE80211_IF_TYPE_IBSS:
                sdata->u.sta.state = IEEE80211_DISABLED;
                conf.bssid = sdata->u.sta.bssid;
                conf.ssid = sdata->u.sta.ssid;
                conf.ssid_len = sdata->u.sta.ssid_len;
+#ifdef CONFIG_MAC80211_MESH
+       } else if (sdata->vif.type == IEEE80211_IF_TYPE_MESH_POINT) {
+               conf.beacon = beacon;
+               ieee80211_start_mesh(dev);
+#endif
        } else if (sdata->vif.type == IEEE80211_IF_TYPE_AP) {
                conf.ssid = sdata->u.ap.ssid;
                conf.ssid_len = sdata->u.ap.ssid_len;
 
 int ieee80211_if_config(struct net_device *dev)
 {
+       struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+       struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
+       if (sdata->vif.type == IEEE80211_IF_TYPE_MESH_POINT &&
+           (local->hw.flags & IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE))
+               return ieee80211_if_config_beacon(dev);
        return __ieee80211_if_config(dev, NULL, NULL);
 }
 
        rc80211_simple_exit();
        rc80211_pid_exit();
 
+#ifdef CONFIG_MAC80211_MESH
+       if (mesh_allocated)
+               ieee80211s_stop();
+#endif
        ieee80211_wme_unregister();
        ieee80211_debugfs_netdev_exit();
 }