Commit 45593c2b authored by David S. Miller's avatar David S. Miller

Merge tag 'batman-adv-for-davem' of git://git.open-mesh.org/linux-merge

Included changes:
- substitute FSF address with URL
- deselect current bat-GW when GW-client mode gets deactivated
- send every DHCP packet using bat-unicast messages when GW-client mode is
  enabled
- implement the Extended Isolation mechanism (it is an enhancement of the
  already existing batman-AP-isolation). This mechanism allows the user to drop
  packets exchanged by selected clients by using netfilter marks.
- fix typ0 in header guard
- minor code cleanups
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 795709af 42cb0bef
...@@ -68,6 +68,14 @@ Description: ...@@ -68,6 +68,14 @@ Description:
Defines the penalty which will be applied to an Defines the penalty which will be applied to an
originator message's tq-field on every hop. originator message's tq-field on every hop.
What: /sys/class/net/<mesh_iface>/mesh/isolation_mark
Date: Nov 2013
Contact: Antonio Quartulli <antonio@meshcoding.com>
Description:
Defines the isolation mark (and its bitmask) which
is used to classify clients as "isolated" by the
Extended Isolation feature.
What: /sys/class/net/<mesh_iface>/mesh/network_coding What: /sys/class/net/<mesh_iface>/mesh/network_coding
Date: Nov 2012 Date: Nov 2012
Contact: Martin Hundeboll <martin@hundeboll.net> Contact: Martin Hundeboll <martin@hundeboll.net>
......
...@@ -13,9 +13,7 @@ ...@@ -13,9 +13,7 @@
# General Public License for more details. # General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, see <http://www.gnu.org/licenses/>.
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA
# #
obj-$(CONFIG_BATMAN_ADV) += batman-adv.o obj-$(CONFIG_BATMAN_ADV) += batman-adv.o
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#ifndef _NET_BATMAN_ADV_BAT_ALGO_H_ #ifndef _NET_BATMAN_ADV_BAT_ALGO_H_
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#include "main.h" #include "main.h"
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#include "main.h" #include "main.h"
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#ifndef _NET_BATMAN_ADV_BITARRAY_H_ #ifndef _NET_BATMAN_ADV_BITARRAY_H_
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#include "main.h" #include "main.h"
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#ifndef _NET_BATMAN_ADV_BLA_H_ #ifndef _NET_BATMAN_ADV_BLA_H_
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#include "main.h" #include "main.h"
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#ifndef _NET_BATMAN_ADV_DEBUGFS_H_ #ifndef _NET_BATMAN_ADV_DEBUGFS_H_
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#include <linux/if_ether.h> #include <linux/if_ether.h>
...@@ -141,7 +139,7 @@ static int batadv_compare_dat(const struct hlist_node *node, const void *data2) ...@@ -141,7 +139,7 @@ static int batadv_compare_dat(const struct hlist_node *node, const void *data2)
const void *data1 = container_of(node, struct batadv_dat_entry, const void *data1 = container_of(node, struct batadv_dat_entry,
hash_entry); hash_entry);
return (memcmp(data1, data2, sizeof(__be32)) == 0 ? 1 : 0); return memcmp(data1, data2, sizeof(__be32)) == 0 ? 1 : 0;
} }
/** /**
...@@ -1039,9 +1037,9 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv, ...@@ -1039,9 +1037,9 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
if (hdr_size == sizeof(struct batadv_unicast_4addr_packet)) if (hdr_size == sizeof(struct batadv_unicast_4addr_packet))
err = batadv_send_skb_via_tt_4addr(bat_priv, skb_new, err = batadv_send_skb_via_tt_4addr(bat_priv, skb_new,
BATADV_P_DAT_CACHE_REPLY, BATADV_P_DAT_CACHE_REPLY,
vid); NULL, vid);
else else
err = batadv_send_skb_via_tt(bat_priv, skb_new, vid); err = batadv_send_skb_via_tt(bat_priv, skb_new, NULL, vid);
if (err != NET_XMIT_DROP) { if (err != NET_XMIT_DROP) {
batadv_inc_counter(bat_priv, BATADV_CNT_DAT_CACHED_REPLY_TX); batadv_inc_counter(bat_priv, BATADV_CNT_DAT_CACHED_REPLY_TX);
......
...@@ -12,13 +12,11 @@ ...@@ -12,13 +12,11 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#ifndef _NET_BATMAN_ADV_ARP_H_ #ifndef _NET_BATMAN_ADV_DISTRIBUTED_ARP_TABLE_H_
#define _NET_BATMAN_ADV_ARP_H_ #define _NET_BATMAN_ADV_DISTRIBUTED_ARP_TABLE_H_
#ifdef CONFIG_BATMAN_ADV_DAT #ifdef CONFIG_BATMAN_ADV_DAT
...@@ -169,4 +167,4 @@ static inline void batadv_dat_inc_counter(struct batadv_priv *bat_priv, ...@@ -169,4 +167,4 @@ static inline void batadv_dat_inc_counter(struct batadv_priv *bat_priv,
#endif /* CONFIG_BATMAN_ADV_DAT */ #endif /* CONFIG_BATMAN_ADV_DAT */
#endif /* _NET_BATMAN_ADV_ARP_H_ */ #endif /* _NET_BATMAN_ADV_DISTRIBUTED_ARP_TABLE_H_ */
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#include "main.h" #include "main.h"
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#ifndef _NET_BATMAN_ADV_FRAGMENTATION_H_ #ifndef _NET_BATMAN_ADV_FRAGMENTATION_H_
......
This diff is collapsed.
...@@ -12,16 +12,14 @@ ...@@ -12,16 +12,14 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#ifndef _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ #ifndef _NET_BATMAN_ADV_GATEWAY_CLIENT_H_
#define _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ #define _NET_BATMAN_ADV_GATEWAY_CLIENT_H_
void batadv_gw_check_client_stop(struct batadv_priv *bat_priv); void batadv_gw_check_client_stop(struct batadv_priv *bat_priv);
void batadv_gw_deselect(struct batadv_priv *bat_priv); void batadv_gw_reselect(struct batadv_priv *bat_priv);
void batadv_gw_election(struct batadv_priv *bat_priv); void batadv_gw_election(struct batadv_priv *bat_priv);
struct batadv_orig_node * struct batadv_orig_node *
batadv_gw_get_selected_orig(struct batadv_priv *bat_priv); batadv_gw_get_selected_orig(struct batadv_priv *bat_priv);
...@@ -34,7 +32,9 @@ void batadv_gw_node_delete(struct batadv_priv *bat_priv, ...@@ -34,7 +32,9 @@ void batadv_gw_node_delete(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node); struct batadv_orig_node *orig_node);
void batadv_gw_node_purge(struct batadv_priv *bat_priv); void batadv_gw_node_purge(struct batadv_priv *bat_priv);
int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset); int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset);
bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len);
bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, struct sk_buff *skb); bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, struct sk_buff *skb);
enum batadv_dhcp_recipient
batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len,
uint8_t *chaddr);
#endif /* _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ */ #endif /* _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ */
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#include "main.h" #include "main.h"
...@@ -164,7 +162,7 @@ ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff, ...@@ -164,7 +162,7 @@ ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff,
if ((down_curr == down_new) && (up_curr == up_new)) if ((down_curr == down_new) && (up_curr == up_new))
return count; return count;
batadv_gw_deselect(bat_priv); batadv_gw_reselect(bat_priv);
batadv_info(net_dev, batadv_info(net_dev,
"Changing gateway bandwidth from: '%u.%u/%u.%u MBit' to: '%u.%u/%u.%u MBit'\n", "Changing gateway bandwidth from: '%u.%u/%u.%u MBit' to: '%u.%u/%u.%u MBit'\n",
down_curr / 10, down_curr % 10, up_curr / 10, up_curr % 10, down_curr / 10, down_curr % 10, up_curr / 10, up_curr % 10,
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#ifndef _NET_BATMAN_ADV_GATEWAY_COMMON_H_ #ifndef _NET_BATMAN_ADV_GATEWAY_COMMON_H_
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#include "main.h" #include "main.h"
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#ifndef _NET_BATMAN_ADV_HARD_INTERFACE_H_ #ifndef _NET_BATMAN_ADV_HARD_INTERFACE_H_
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#include "main.h" #include "main.h"
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#ifndef _NET_BATMAN_ADV_HASH_H_ #ifndef _NET_BATMAN_ADV_HASH_H_
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#include "main.h" #include "main.h"
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#ifndef _NET_BATMAN_ADV_ICMP_SOCKET_H_ #ifndef _NET_BATMAN_ADV_ICMP_SOCKET_H_
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#include <linux/crc32c.h> #include <linux/crc32c.h>
...@@ -1173,6 +1171,32 @@ unsigned short batadv_get_vid(struct sk_buff *skb, size_t header_len) ...@@ -1173,6 +1171,32 @@ unsigned short batadv_get_vid(struct sk_buff *skb, size_t header_len)
return vid; return vid;
} }
/**
* batadv_vlan_ap_isola_get - return the AP isolation status for the given vlan
* @bat_priv: the bat priv with all the soft interface information
* @vid: the VLAN identifier for which the AP isolation attributed as to be
* looked up
*
* Returns true if AP isolation is on for the VLAN idenfied by vid, false
* otherwise
*/
bool batadv_vlan_ap_isola_get(struct batadv_priv *bat_priv, unsigned short vid)
{
bool ap_isolation_enabled = false;
struct batadv_softif_vlan *vlan;
/* if the AP isolation is requested on a VLAN, then check for its
* setting in the proper VLAN private data structure
*/
vlan = batadv_softif_vlan_get(bat_priv, vid);
if (vlan) {
ap_isolation_enabled = atomic_read(&vlan->ap_isolation);
batadv_softif_vlan_free_ref(vlan);
}
return ap_isolation_enabled;
}
static int batadv_param_set_ra(const char *val, const struct kernel_param *kp) static int batadv_param_set_ra(const char *val, const struct kernel_param *kp)
{ {
struct batadv_algo_ops *bat_algo_ops; struct batadv_algo_ops *bat_algo_ops;
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#ifndef _NET_BATMAN_ADV_MAIN_H_ #ifndef _NET_BATMAN_ADV_MAIN_H_
...@@ -72,6 +70,8 @@ ...@@ -72,6 +70,8 @@
#define BATADV_NULL_IFINDEX 0 /* dummy ifindex used to avoid iface checks */ #define BATADV_NULL_IFINDEX 0 /* dummy ifindex used to avoid iface checks */
#define BATADV_NO_MARK 0
#define BATADV_NUM_WORDS BITS_TO_LONGS(BATADV_TQ_LOCAL_WINDOW_SIZE) #define BATADV_NUM_WORDS BITS_TO_LONGS(BATADV_TQ_LOCAL_WINDOW_SIZE)
#define BATADV_LOG_BUF_LEN 8192 /* has to be a power of 2 */ #define BATADV_LOG_BUF_LEN 8192 /* has to be a power of 2 */
...@@ -369,5 +369,6 @@ void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, uint8_t *src, ...@@ -369,5 +369,6 @@ void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, uint8_t *src,
uint8_t *dst, uint8_t type, uint8_t version, uint8_t *dst, uint8_t type, uint8_t version,
void *tvlv_value, uint16_t tvlv_value_len); void *tvlv_value, uint16_t tvlv_value_len);
unsigned short batadv_get_vid(struct sk_buff *skb, size_t header_len); unsigned short batadv_get_vid(struct sk_buff *skb, size_t header_len);
bool batadv_vlan_ap_isola_get(struct batadv_priv *bat_priv, unsigned short vid);
#endif /* _NET_BATMAN_ADV_MAIN_H_ */ #endif /* _NET_BATMAN_ADV_MAIN_H_ */
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#include <linux/debugfs.h> #include <linux/debugfs.h>
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#ifndef _NET_BATMAN_ADV_NETWORK_CODING_H_ #ifndef _NET_BATMAN_ADV_NETWORK_CODING_H_
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#include "main.h" #include "main.h"
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#ifndef _NET_BATMAN_ADV_ORIGINATOR_H_ #ifndef _NET_BATMAN_ADV_ORIGINATOR_H_
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#ifndef _NET_BATMAN_ADV_PACKET_H_ #ifndef _NET_BATMAN_ADV_PACKET_H_
...@@ -117,6 +115,7 @@ enum batadv_tt_client_flags { ...@@ -117,6 +115,7 @@ enum batadv_tt_client_flags {
BATADV_TT_CLIENT_DEL = BIT(0), BATADV_TT_CLIENT_DEL = BIT(0),
BATADV_TT_CLIENT_ROAM = BIT(1), BATADV_TT_CLIENT_ROAM = BIT(1),
BATADV_TT_CLIENT_WIFI = BIT(4), BATADV_TT_CLIENT_WIFI = BIT(4),
BATADV_TT_CLIENT_ISOLA = BIT(5),
BATADV_TT_CLIENT_NOPURGE = BIT(8), BATADV_TT_CLIENT_NOPURGE = BIT(8),
BATADV_TT_CLIENT_NEW = BIT(9), BATADV_TT_CLIENT_NEW = BIT(9),
BATADV_TT_CLIENT_PENDING = BIT(10), BATADV_TT_CLIENT_PENDING = BIT(10),
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#include "main.h" #include "main.h"
...@@ -1135,6 +1133,7 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, ...@@ -1135,6 +1133,7 @@ int batadv_recv_bcast_packet(struct sk_buff *skb,
int hdr_size = sizeof(*bcast_packet); int hdr_size = sizeof(*bcast_packet);
int ret = NET_RX_DROP; int ret = NET_RX_DROP;
int32_t seq_diff; int32_t seq_diff;
uint32_t seqno;
/* drop packet if it has not necessary minimum size */ /* drop packet if it has not necessary minimum size */
if (unlikely(!pskb_may_pull(skb, hdr_size))) if (unlikely(!pskb_may_pull(skb, hdr_size)))
...@@ -1170,12 +1169,13 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, ...@@ -1170,12 +1169,13 @@ int batadv_recv_bcast_packet(struct sk_buff *skb,
spin_lock_bh(&orig_node->bcast_seqno_lock); spin_lock_bh(&orig_node->bcast_seqno_lock);
seqno = ntohl(bcast_packet->seqno);
/* check whether the packet is a duplicate */ /* check whether the packet is a duplicate */
if (batadv_test_bit(orig_node->bcast_bits, orig_node->last_bcast_seqno, if (batadv_test_bit(orig_node->bcast_bits, orig_node->last_bcast_seqno,
ntohl(bcast_packet->seqno))) seqno))
goto spin_unlock; goto spin_unlock;
seq_diff = ntohl(bcast_packet->seqno) - orig_node->last_bcast_seqno; seq_diff = seqno - orig_node->last_bcast_seqno;
/* check whether the packet is old and the host just restarted. */ /* check whether the packet is old and the host just restarted. */
if (batadv_window_protected(bat_priv, seq_diff, if (batadv_window_protected(bat_priv, seq_diff,
...@@ -1186,7 +1186,7 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, ...@@ -1186,7 +1186,7 @@ int batadv_recv_bcast_packet(struct sk_buff *skb,
* if required. * if required.
*/ */
if (batadv_bit_get_packet(bat_priv, orig_node->bcast_bits, seq_diff, 1)) if (batadv_bit_get_packet(bat_priv, orig_node->bcast_bits, seq_diff, 1))
orig_node->last_bcast_seqno = ntohl(bcast_packet->seqno); orig_node->last_bcast_seqno = seqno;
spin_unlock_bh(&orig_node->bcast_seqno_lock); spin_unlock_bh(&orig_node->bcast_seqno_lock);
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#ifndef _NET_BATMAN_ADV_ROUTING_H_ #ifndef _NET_BATMAN_ADV_ROUTING_H_
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#include "main.h" #include "main.h"
...@@ -321,13 +319,23 @@ static int batadv_send_skb_unicast(struct batadv_priv *bat_priv, ...@@ -321,13 +319,23 @@ static int batadv_send_skb_unicast(struct batadv_priv *bat_priv,
*/ */
int batadv_send_skb_via_tt_generic(struct batadv_priv *bat_priv, int batadv_send_skb_via_tt_generic(struct batadv_priv *bat_priv,
struct sk_buff *skb, int packet_type, struct sk_buff *skb, int packet_type,
int packet_subtype, unsigned short vid) int packet_subtype, uint8_t *dst_hint,
unsigned short vid)
{ {
struct ethhdr *ethhdr = (struct ethhdr *)skb->data; struct ethhdr *ethhdr = (struct ethhdr *)skb->data;
struct batadv_orig_node *orig_node; struct batadv_orig_node *orig_node;
uint8_t *src, *dst;
src = ethhdr->h_source;
dst = ethhdr->h_dest;
/* if we got an hint! let's send the packet to this client (if any) */
if (dst_hint) {
src = NULL;
dst = dst_hint;
}
orig_node = batadv_transtable_search(bat_priv, src, dst, vid);
orig_node = batadv_transtable_search(bat_priv, ethhdr->h_source,
ethhdr->h_dest, vid);
return batadv_send_skb_unicast(bat_priv, skb, packet_type, return batadv_send_skb_unicast(bat_priv, skb, packet_type,
packet_subtype, orig_node, vid); packet_subtype, orig_node, vid);
} }
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#ifndef _NET_BATMAN_ADV_SEND_H_ #ifndef _NET_BATMAN_ADV_SEND_H_
...@@ -40,7 +38,8 @@ bool batadv_send_skb_prepare_unicast_4addr(struct batadv_priv *bat_priv, ...@@ -40,7 +38,8 @@ bool batadv_send_skb_prepare_unicast_4addr(struct batadv_priv *bat_priv,
int packet_subtype); int packet_subtype);
int batadv_send_skb_via_tt_generic(struct batadv_priv *bat_priv, int batadv_send_skb_via_tt_generic(struct batadv_priv *bat_priv,
struct sk_buff *skb, int packet_type, struct sk_buff *skb, int packet_type,
int packet_subtype, unsigned short vid); int packet_subtype, uint8_t *dst_hint,
unsigned short vid);
int batadv_send_skb_via_gw(struct batadv_priv *bat_priv, struct sk_buff *skb, int batadv_send_skb_via_gw(struct batadv_priv *bat_priv, struct sk_buff *skb,
unsigned short vid); unsigned short vid);
...@@ -57,11 +56,11 @@ int batadv_send_skb_via_gw(struct batadv_priv *bat_priv, struct sk_buff *skb, ...@@ -57,11 +56,11 @@ int batadv_send_skb_via_gw(struct batadv_priv *bat_priv, struct sk_buff *skb,
* Returns NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise. * Returns NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
*/ */
static inline int batadv_send_skb_via_tt(struct batadv_priv *bat_priv, static inline int batadv_send_skb_via_tt(struct batadv_priv *bat_priv,
struct sk_buff *skb, struct sk_buff *skb, uint8_t *dst_hint,
unsigned short vid) unsigned short vid)
{ {
return batadv_send_skb_via_tt_generic(bat_priv, skb, BATADV_UNICAST, 0, return batadv_send_skb_via_tt_generic(bat_priv, skb, BATADV_UNICAST, 0,
vid); dst_hint, vid);
} }
/** /**
...@@ -81,11 +80,12 @@ static inline int batadv_send_skb_via_tt(struct batadv_priv *bat_priv, ...@@ -81,11 +80,12 @@ static inline int batadv_send_skb_via_tt(struct batadv_priv *bat_priv,
static inline int batadv_send_skb_via_tt_4addr(struct batadv_priv *bat_priv, static inline int batadv_send_skb_via_tt_4addr(struct batadv_priv *bat_priv,
struct sk_buff *skb, struct sk_buff *skb,
int packet_subtype, int packet_subtype,
uint8_t *dst_hint,
unsigned short vid) unsigned short vid)
{ {
return batadv_send_skb_via_tt_generic(bat_priv, skb, return batadv_send_skb_via_tt_generic(bat_priv, skb,
BATADV_UNICAST_4ADDR, BATADV_UNICAST_4ADDR,
packet_subtype, vid); packet_subtype, dst_hint, vid);
} }
#endif /* _NET_BATMAN_ADV_SEND_H_ */ #endif /* _NET_BATMAN_ADV_SEND_H_ */
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#include "main.h" #include "main.h"
...@@ -121,7 +119,7 @@ static int batadv_interface_set_mac_addr(struct net_device *dev, void *p) ...@@ -121,7 +119,7 @@ static int batadv_interface_set_mac_addr(struct net_device *dev, void *p)
batadv_tt_local_remove(bat_priv, old_addr, BATADV_NO_FLAGS, batadv_tt_local_remove(bat_priv, old_addr, BATADV_NO_FLAGS,
"mac address changed", false); "mac address changed", false);
batadv_tt_local_add(dev, addr->sa_data, BATADV_NO_FLAGS, batadv_tt_local_add(dev, addr->sa_data, BATADV_NO_FLAGS,
BATADV_NULL_IFINDEX); BATADV_NULL_IFINDEX, BATADV_NO_MARK);
} }
return 0; return 0;
...@@ -162,6 +160,8 @@ static int batadv_interface_tx(struct sk_buff *skb, ...@@ -162,6 +160,8 @@ static int batadv_interface_tx(struct sk_buff *skb,
0x00, 0x00}; 0x00, 0x00};
static const uint8_t ectp_addr[ETH_ALEN] = {0xCF, 0x00, 0x00, 0x00, static const uint8_t ectp_addr[ETH_ALEN] = {0xCF, 0x00, 0x00, 0x00,
0x00, 0x00}; 0x00, 0x00};
enum batadv_dhcp_recipient dhcp_rcp = BATADV_DHCP_NO;
uint8_t *dst_hint = NULL, chaddr[ETH_ALEN];
struct vlan_ethhdr *vhdr; struct vlan_ethhdr *vhdr;
unsigned int header_len = 0; unsigned int header_len = 0;
int data_len = skb->len, ret; int data_len = skb->len, ret;
...@@ -169,6 +169,7 @@ static int batadv_interface_tx(struct sk_buff *skb, ...@@ -169,6 +169,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
bool do_bcast = false, client_added; bool do_bcast = false, client_added;
unsigned short vid; unsigned short vid;
uint32_t seqno; uint32_t seqno;
int gw_mode;
if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE) if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE)
goto dropped; goto dropped;
...@@ -198,7 +199,8 @@ static int batadv_interface_tx(struct sk_buff *skb, ...@@ -198,7 +199,8 @@ static int batadv_interface_tx(struct sk_buff *skb,
/* Register the client MAC in the transtable */ /* Register the client MAC in the transtable */
if (!is_multicast_ether_addr(ethhdr->h_source)) { if (!is_multicast_ether_addr(ethhdr->h_source)) {
client_added = batadv_tt_local_add(soft_iface, ethhdr->h_source, client_added = batadv_tt_local_add(soft_iface, ethhdr->h_source,
vid, skb->skb_iif); vid, skb->skb_iif,
skb->mark);
if (!client_added) if (!client_added)
goto dropped; goto dropped;
} }
...@@ -215,36 +217,39 @@ static int batadv_interface_tx(struct sk_buff *skb, ...@@ -215,36 +217,39 @@ static int batadv_interface_tx(struct sk_buff *skb,
if (batadv_compare_eth(ethhdr->h_dest, ectp_addr)) if (batadv_compare_eth(ethhdr->h_dest, ectp_addr))
goto dropped; goto dropped;
gw_mode = atomic_read(&bat_priv->gw_mode);
if (is_multicast_ether_addr(ethhdr->h_dest)) { if (is_multicast_ether_addr(ethhdr->h_dest)) {
do_bcast = true; /* if gw mode is off, broadcast every packet */
if (gw_mode == BATADV_GW_MODE_OFF) {
switch (atomic_read(&bat_priv->gw_mode)) { do_bcast = true;
case BATADV_GW_MODE_SERVER: goto send;
/* gateway servers should not send dhcp
* requests into the mesh
*/
ret = batadv_gw_is_dhcp_target(skb, &header_len);
if (ret)
goto dropped;
break;
case BATADV_GW_MODE_CLIENT:
/* gateway clients should send dhcp requests
* via unicast to their gateway
*/
ret = batadv_gw_is_dhcp_target(skb, &header_len);
if (ret)
do_bcast = false;
break;
case BATADV_GW_MODE_OFF:
default:
break;
} }
/* reminder: ethhdr might have become unusable from here on dhcp_rcp = batadv_gw_dhcp_recipient_get(skb, &header_len,
* (batadv_gw_is_dhcp_target() might have reallocated skb data) chaddr);
/* skb->data may have been modified by
* batadv_gw_dhcp_recipient_get()
*/ */
ethhdr = (struct ethhdr *)skb->data;
/* if gw_mode is on, broadcast any non-DHCP message.
* All the DHCP packets are going to be sent as unicast
*/
if (dhcp_rcp == BATADV_DHCP_NO) {
do_bcast = true;
goto send;
}
if (dhcp_rcp == BATADV_DHCP_TO_CLIENT)
dst_hint = chaddr;
else if ((gw_mode == BATADV_GW_MODE_SERVER) &&
(dhcp_rcp == BATADV_DHCP_TO_SERVER))
/* gateways should not forward any DHCP message if
* directed to a DHCP server
*/
goto dropped;
} }
send:
batadv_skb_set_priority(skb, 0); batadv_skb_set_priority(skb, 0);
/* ethernet packet should be broadcasted */ /* ethernet packet should be broadcasted */
...@@ -290,22 +295,22 @@ static int batadv_interface_tx(struct sk_buff *skb, ...@@ -290,22 +295,22 @@ static int batadv_interface_tx(struct sk_buff *skb,
/* unicast packet */ /* unicast packet */
} else { } else {
if (atomic_read(&bat_priv->gw_mode) != BATADV_GW_MODE_OFF) { /* DHCP packets going to a server will use the GW feature */
if (dhcp_rcp == BATADV_DHCP_TO_SERVER) {
ret = batadv_gw_out_of_range(bat_priv, skb); ret = batadv_gw_out_of_range(bat_priv, skb);
if (ret) if (ret)
goto dropped; goto dropped;
}
if (batadv_dat_snoop_outgoing_arp_request(bat_priv, skb))
goto dropped;
batadv_dat_snoop_outgoing_arp_reply(bat_priv, skb);
if (is_multicast_ether_addr(ethhdr->h_dest))
ret = batadv_send_skb_via_gw(bat_priv, skb, vid); ret = batadv_send_skb_via_gw(bat_priv, skb, vid);
else } else {
ret = batadv_send_skb_via_tt(bat_priv, skb, vid); if (batadv_dat_snoop_outgoing_arp_request(bat_priv,
skb))
goto dropped;
batadv_dat_snoop_outgoing_arp_reply(bat_priv, skb);
ret = batadv_send_skb_via_tt(bat_priv, skb, dst_hint,
vid);
}
if (ret == NET_XMIT_DROP) if (ret == NET_XMIT_DROP)
goto dropped_freed; goto dropped_freed;
} }
...@@ -394,9 +399,23 @@ void batadv_interface_rx(struct net_device *soft_iface, ...@@ -394,9 +399,23 @@ void batadv_interface_rx(struct net_device *soft_iface,
batadv_tt_add_temporary_global_entry(bat_priv, orig_node, batadv_tt_add_temporary_global_entry(bat_priv, orig_node,
ethhdr->h_source, vid); ethhdr->h_source, vid);
if (batadv_is_ap_isolated(bat_priv, ethhdr->h_source, ethhdr->h_dest, if (is_multicast_ether_addr(ethhdr->h_dest)) {
vid)) /* set the mark on broadcast packets if AP isolation is ON and
* the packet is coming from an "isolated" client
*/
if (batadv_vlan_ap_isola_get(bat_priv, vid) &&
batadv_tt_global_is_isolated(bat_priv, ethhdr->h_source,
vid)) {
/* save bits in skb->mark not covered by the mask and
* apply the mark on the rest
*/
skb->mark &= ~bat_priv->isolation_mark_mask;
skb->mark |= bat_priv->isolation_mark;
}
} else if (batadv_is_ap_isolated(bat_priv, ethhdr->h_source,
ethhdr->h_dest, vid)) {
goto dropped; goto dropped;
}
netif_rx(skb); netif_rx(skb);
goto out; goto out;
...@@ -485,7 +504,7 @@ int batadv_softif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid) ...@@ -485,7 +504,7 @@ int batadv_softif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid)
*/ */
batadv_tt_local_add(bat_priv->soft_iface, batadv_tt_local_add(bat_priv->soft_iface,
bat_priv->soft_iface->dev_addr, vid, bat_priv->soft_iface->dev_addr, vid,
BATADV_NULL_IFINDEX); BATADV_NULL_IFINDEX, BATADV_NO_MARK);
spin_lock_bh(&bat_priv->softif_vlan_list_lock); spin_lock_bh(&bat_priv->softif_vlan_list_lock);
hlist_add_head_rcu(&vlan->list, &bat_priv->softif_vlan_list); hlist_add_head_rcu(&vlan->list, &bat_priv->softif_vlan_list);
...@@ -697,6 +716,8 @@ static int batadv_softif_init_late(struct net_device *dev) ...@@ -697,6 +716,8 @@ static int batadv_softif_init_late(struct net_device *dev)
#endif #endif
bat_priv->tt.last_changeset = NULL; bat_priv->tt.last_changeset = NULL;
bat_priv->tt.last_changeset_len = 0; bat_priv->tt.last_changeset_len = 0;
bat_priv->isolation_mark = 0;
bat_priv->isolation_mark_mask = 0;
/* randomize initial seqno to avoid collision */ /* randomize initial seqno to avoid collision */
get_random_bytes(&random_seqno, sizeof(random_seqno)); get_random_bytes(&random_seqno, sizeof(random_seqno));
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#ifndef _NET_BATMAN_ADV_SOFT_INTERFACE_H_ #ifndef _NET_BATMAN_ADV_SOFT_INTERFACE_H_
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#include "main.h" #include "main.h"
...@@ -329,10 +327,10 @@ static ssize_t batadv_show_bat_algo(struct kobject *kobj, ...@@ -329,10 +327,10 @@ static ssize_t batadv_show_bat_algo(struct kobject *kobj,
return sprintf(buff, "%s\n", bat_priv->bat_algo_ops->name); return sprintf(buff, "%s\n", bat_priv->bat_algo_ops->name);
} }
static void batadv_post_gw_deselect(struct net_device *net_dev) static void batadv_post_gw_reselect(struct net_device *net_dev)
{ {
struct batadv_priv *bat_priv = netdev_priv(net_dev); struct batadv_priv *bat_priv = netdev_priv(net_dev);
batadv_gw_deselect(bat_priv); batadv_gw_reselect(bat_priv);
} }
static ssize_t batadv_show_gw_mode(struct kobject *kobj, struct attribute *attr, static ssize_t batadv_show_gw_mode(struct kobject *kobj, struct attribute *attr,
...@@ -408,7 +406,16 @@ static ssize_t batadv_store_gw_mode(struct kobject *kobj, ...@@ -408,7 +406,16 @@ static ssize_t batadv_store_gw_mode(struct kobject *kobj,
batadv_info(net_dev, "Changing gw mode from: %s to: %s\n", batadv_info(net_dev, "Changing gw mode from: %s to: %s\n",
curr_gw_mode_str, buff); curr_gw_mode_str, buff);
batadv_gw_deselect(bat_priv); /* Invoking batadv_gw_reselect() is not enough to really de-select the
* current GW. It will only instruct the gateway client code to perform
* a re-election the next time that this is needed.
*
* When gw client mode is being switched off the current GW must be
* de-selected explicitly otherwise no GW_ADD uevent is thrown on
* client mode re-activation. This is operation is performed in
* batadv_gw_check_client_stop().
*/
batadv_gw_reselect(bat_priv);
/* always call batadv_gw_check_client_stop() before changing the gateway /* always call batadv_gw_check_client_stop() before changing the gateway
* state * state
*/ */
...@@ -443,6 +450,74 @@ static ssize_t batadv_store_gw_bwidth(struct kobject *kobj, ...@@ -443,6 +450,74 @@ static ssize_t batadv_store_gw_bwidth(struct kobject *kobj,
return batadv_gw_bandwidth_set(net_dev, buff, count); return batadv_gw_bandwidth_set(net_dev, buff, count);
} }
/**
* batadv_show_isolation_mark - print the current isolation mark/mask
* @kobj: kobject representing the private mesh sysfs directory
* @attr: the batman-adv attribute the user is interacting with
* @buff: the buffer that will contain the data to send back to the user
*
* Returns the number of bytes written into 'buff' on success or a negative
* error code in case of failure
*/
static ssize_t batadv_show_isolation_mark(struct kobject *kobj,
struct attribute *attr, char *buff)
{
struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj);
return sprintf(buff, "%#.8x/%#.8x\n", bat_priv->isolation_mark,
bat_priv->isolation_mark_mask);
}
/**
* batadv_store_isolation_mark - parse and store the isolation mark/mask entered
* by the user
* @kobj: kobject representing the private mesh sysfs directory
* @attr: the batman-adv attribute the user is interacting with
* @buff: the buffer containing the user data
* @count: number of bytes in the buffer
*
* Returns 'count' on success or a negative error code in case of failure
*/
static ssize_t batadv_store_isolation_mark(struct kobject *kobj,
struct attribute *attr, char *buff,
size_t count)
{
struct net_device *net_dev = batadv_kobj_to_netdev(kobj);
struct batadv_priv *bat_priv = netdev_priv(net_dev);
uint32_t mark, mask;
char *mask_ptr;
/* parse the mask if it has been specified, otherwise assume the mask is
* the biggest possible
*/
mask = 0xFFFFFFFF;
mask_ptr = strchr(buff, '/');
if (mask_ptr) {
*mask_ptr = '\0';
mask_ptr++;
/* the mask must be entered in hex base as it is going to be a
* bitmask and not a prefix length
*/
if (kstrtou32(mask_ptr, 16, &mask) < 0)
return -EINVAL;
}
/* the mark can be entered in any base */
if (kstrtou32(buff, 0, &mark) < 0)
return -EINVAL;
bat_priv->isolation_mark_mask = mask;
/* erase bits not covered by the mask */
bat_priv->isolation_mark = mark & bat_priv->isolation_mark_mask;
batadv_info(net_dev,
"New skb mark for extended isolation: %#.8x/%#.8x\n",
bat_priv->isolation_mark, bat_priv->isolation_mark_mask);
return count;
}
BATADV_ATTR_SIF_BOOL(aggregated_ogms, S_IRUGO | S_IWUSR, NULL); BATADV_ATTR_SIF_BOOL(aggregated_ogms, S_IRUGO | S_IWUSR, NULL);
BATADV_ATTR_SIF_BOOL(bonding, S_IRUGO | S_IWUSR, NULL); BATADV_ATTR_SIF_BOOL(bonding, S_IRUGO | S_IWUSR, NULL);
#ifdef CONFIG_BATMAN_ADV_BLA #ifdef CONFIG_BATMAN_ADV_BLA
...@@ -461,7 +536,7 @@ BATADV_ATTR_SIF_UINT(orig_interval, S_IRUGO | S_IWUSR, 2 * BATADV_JITTER, ...@@ -461,7 +536,7 @@ BATADV_ATTR_SIF_UINT(orig_interval, S_IRUGO | S_IWUSR, 2 * BATADV_JITTER,
BATADV_ATTR_SIF_UINT(hop_penalty, S_IRUGO | S_IWUSR, 0, BATADV_TQ_MAX_VALUE, BATADV_ATTR_SIF_UINT(hop_penalty, S_IRUGO | S_IWUSR, 0, BATADV_TQ_MAX_VALUE,
NULL); NULL);
BATADV_ATTR_SIF_UINT(gw_sel_class, S_IRUGO | S_IWUSR, 1, BATADV_TQ_MAX_VALUE, BATADV_ATTR_SIF_UINT(gw_sel_class, S_IRUGO | S_IWUSR, 1, BATADV_TQ_MAX_VALUE,
batadv_post_gw_deselect); batadv_post_gw_reselect);
static BATADV_ATTR(gw_bandwidth, S_IRUGO | S_IWUSR, batadv_show_gw_bwidth, static BATADV_ATTR(gw_bandwidth, S_IRUGO | S_IWUSR, batadv_show_gw_bwidth,
batadv_store_gw_bwidth); batadv_store_gw_bwidth);
#ifdef CONFIG_BATMAN_ADV_DEBUG #ifdef CONFIG_BATMAN_ADV_DEBUG
...@@ -471,6 +546,8 @@ BATADV_ATTR_SIF_UINT(log_level, S_IRUGO | S_IWUSR, 0, BATADV_DBG_ALL, NULL); ...@@ -471,6 +546,8 @@ BATADV_ATTR_SIF_UINT(log_level, S_IRUGO | S_IWUSR, 0, BATADV_DBG_ALL, NULL);
BATADV_ATTR_SIF_BOOL(network_coding, S_IRUGO | S_IWUSR, BATADV_ATTR_SIF_BOOL(network_coding, S_IRUGO | S_IWUSR,
batadv_nc_status_update); batadv_nc_status_update);
#endif #endif
static BATADV_ATTR(isolation_mark, S_IRUGO | S_IWUSR,
batadv_show_isolation_mark, batadv_store_isolation_mark);
static struct batadv_attribute *batadv_mesh_attrs[] = { static struct batadv_attribute *batadv_mesh_attrs[] = {
&batadv_attr_aggregated_ogms, &batadv_attr_aggregated_ogms,
...@@ -494,6 +571,7 @@ static struct batadv_attribute *batadv_mesh_attrs[] = { ...@@ -494,6 +571,7 @@ static struct batadv_attribute *batadv_mesh_attrs[] = {
#ifdef CONFIG_BATMAN_ADV_NC #ifdef CONFIG_BATMAN_ADV_NC
&batadv_attr_network_coding, &batadv_attr_network_coding,
#endif #endif
&batadv_attr_isolation_mark,
NULL, NULL,
}; };
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#ifndef _NET_BATMAN_ADV_SYSFS_H_ #ifndef _NET_BATMAN_ADV_SYSFS_H_
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#include "main.h" #include "main.h"
...@@ -476,11 +474,13 @@ static void batadv_tt_global_free(struct batadv_priv *bat_priv, ...@@ -476,11 +474,13 @@ static void batadv_tt_global_free(struct batadv_priv *bat_priv,
* @vid: VLAN identifier * @vid: VLAN identifier
* @ifindex: index of the interface where the client is connected to (useful to * @ifindex: index of the interface where the client is connected to (useful to
* identify wireless clients) * identify wireless clients)
* @mark: the value contained in the skb->mark field of the received packet (if
* any)
* *
* Returns true if the client was successfully added, false otherwise. * Returns true if the client was successfully added, false otherwise.
*/ */
bool batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, bool batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
unsigned short vid, int ifindex) unsigned short vid, int ifindex, uint32_t mark)
{ {
struct batadv_priv *bat_priv = netdev_priv(soft_iface); struct batadv_priv *bat_priv = netdev_priv(soft_iface);
struct batadv_tt_local_entry *tt_local; struct batadv_tt_local_entry *tt_local;
...@@ -491,6 +491,7 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, ...@@ -491,6 +491,7 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
int hash_added, table_size, packet_size_max; int hash_added, table_size, packet_size_max;
bool ret = false, roamed_back = false; bool ret = false, roamed_back = false;
uint8_t remote_flags; uint8_t remote_flags;
uint32_t match_mark;
if (ifindex != BATADV_NULL_IFINDEX) if (ifindex != BATADV_NULL_IFINDEX)
in_dev = dev_get_by_index(&init_net, ifindex); in_dev = dev_get_by_index(&init_net, ifindex);
...@@ -615,6 +616,17 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, ...@@ -615,6 +616,17 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
else else
tt_local->common.flags &= ~BATADV_TT_CLIENT_WIFI; tt_local->common.flags &= ~BATADV_TT_CLIENT_WIFI;
/* check the mark in the skb: if it's equal to the configured
* isolation_mark, it means the packet is coming from an isolated
* non-mesh client
*/
match_mark = (mark & bat_priv->isolation_mark_mask);
if (bat_priv->isolation_mark_mask &&
match_mark == bat_priv->isolation_mark)
tt_local->common.flags |= BATADV_TT_CLIENT_ISOLA;
else
tt_local->common.flags &= ~BATADV_TT_CLIENT_ISOLA;
/* if any "dynamic" flag has been modified, resend an ADD event for this /* if any "dynamic" flag has been modified, resend an ADD event for this
* entry so that all the nodes can get the new flags * entry so that all the nodes can get the new flags
*/ */
...@@ -875,7 +887,7 @@ int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset) ...@@ -875,7 +887,7 @@ int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset)
seq_printf(seq, seq_printf(seq,
"Locally retrieved addresses (from %s) announced via TT (TTVN: %u):\n", "Locally retrieved addresses (from %s) announced via TT (TTVN: %u):\n",
net_dev->name, (uint8_t)atomic_read(&bat_priv->tt.vn)); net_dev->name, (uint8_t)atomic_read(&bat_priv->tt.vn));
seq_printf(seq, " %-13s %s %-7s %-9s (%-10s)\n", "Client", "VID", seq_printf(seq, " %-13s %s %-8s %-9s (%-10s)\n", "Client", "VID",
"Flags", "Last seen", "CRC"); "Flags", "Last seen", "CRC");
for (i = 0; i < hash->size; i++) { for (i = 0; i < hash->size; i++) {
...@@ -903,7 +915,7 @@ int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset) ...@@ -903,7 +915,7 @@ int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset)
} }
seq_printf(seq, seq_printf(seq,
" * %pM %4i [%c%c%c%c%c] %3u.%03u (%#.8x)\n", " * %pM %4i [%c%c%c%c%c%c] %3u.%03u (%#.8x)\n",
tt_common_entry->addr, tt_common_entry->addr,
BATADV_PRINT_VID(tt_common_entry->vid), BATADV_PRINT_VID(tt_common_entry->vid),
(tt_common_entry->flags & (tt_common_entry->flags &
...@@ -915,6 +927,8 @@ int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset) ...@@ -915,6 +927,8 @@ int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset)
BATADV_TT_CLIENT_PENDING ? 'X' : '.'), BATADV_TT_CLIENT_PENDING ? 'X' : '.'),
(tt_common_entry->flags & (tt_common_entry->flags &
BATADV_TT_CLIENT_WIFI ? 'W' : '.'), BATADV_TT_CLIENT_WIFI ? 'W' : '.'),
(tt_common_entry->flags &
BATADV_TT_CLIENT_ISOLA ? 'I' : '.'),
no_purge ? 0 : last_seen_secs, no_purge ? 0 : last_seen_secs,
no_purge ? 0 : last_seen_msecs, no_purge ? 0 : last_seen_msecs,
vlan->tt.crc); vlan->tt.crc);
...@@ -1447,13 +1461,14 @@ batadv_tt_global_print_entry(struct batadv_priv *bat_priv, ...@@ -1447,13 +1461,14 @@ batadv_tt_global_print_entry(struct batadv_priv *bat_priv,
last_ttvn = atomic_read(&best_entry->orig_node->last_ttvn); last_ttvn = atomic_read(&best_entry->orig_node->last_ttvn);
seq_printf(seq, seq_printf(seq,
" %c %pM %4i (%3u) via %pM (%3u) (%#.8x) [%c%c%c]\n", " %c %pM %4i (%3u) via %pM (%3u) (%#.8x) [%c%c%c%c]\n",
'*', tt_global_entry->common.addr, '*', tt_global_entry->common.addr,
BATADV_PRINT_VID(tt_global_entry->common.vid), BATADV_PRINT_VID(tt_global_entry->common.vid),
best_entry->ttvn, best_entry->orig_node->orig, best_entry->ttvn, best_entry->orig_node->orig,
last_ttvn, vlan->tt.crc, last_ttvn, vlan->tt.crc,
(flags & BATADV_TT_CLIENT_ROAM ? 'R' : '.'), (flags & BATADV_TT_CLIENT_ROAM ? 'R' : '.'),
(flags & BATADV_TT_CLIENT_WIFI ? 'W' : '.'), (flags & BATADV_TT_CLIENT_WIFI ? 'W' : '.'),
(flags & BATADV_TT_CLIENT_ISOLA ? 'I' : '.'),
(flags & BATADV_TT_CLIENT_TEMP ? 'T' : '.')); (flags & BATADV_TT_CLIENT_TEMP ? 'T' : '.'));
batadv_orig_node_vlan_free_ref(vlan); batadv_orig_node_vlan_free_ref(vlan);
...@@ -1478,13 +1493,14 @@ batadv_tt_global_print_entry(struct batadv_priv *bat_priv, ...@@ -1478,13 +1493,14 @@ batadv_tt_global_print_entry(struct batadv_priv *bat_priv,
last_ttvn = atomic_read(&orig_entry->orig_node->last_ttvn); last_ttvn = atomic_read(&orig_entry->orig_node->last_ttvn);
seq_printf(seq, seq_printf(seq,
" %c %pM %4d (%3u) via %pM (%3u) (%#.8x) [%c%c%c]\n", " %c %pM %4d (%3u) via %pM (%3u) (%#.8x) [%c%c%c%c]\n",
'+', tt_global_entry->common.addr, '+', tt_global_entry->common.addr,
BATADV_PRINT_VID(tt_global_entry->common.vid), BATADV_PRINT_VID(tt_global_entry->common.vid),
orig_entry->ttvn, orig_entry->orig_node->orig, orig_entry->ttvn, orig_entry->orig_node->orig,
last_ttvn, vlan->tt.crc, last_ttvn, vlan->tt.crc,
(flags & BATADV_TT_CLIENT_ROAM ? 'R' : '.'), (flags & BATADV_TT_CLIENT_ROAM ? 'R' : '.'),
(flags & BATADV_TT_CLIENT_WIFI ? 'W' : '.'), (flags & BATADV_TT_CLIENT_WIFI ? 'W' : '.'),
(flags & BATADV_TT_CLIENT_ISOLA ? 'I' : '.'),
(flags & BATADV_TT_CLIENT_TEMP ? 'T' : '.')); (flags & BATADV_TT_CLIENT_TEMP ? 'T' : '.'));
batadv_orig_node_vlan_free_ref(vlan); batadv_orig_node_vlan_free_ref(vlan);
...@@ -1853,6 +1869,11 @@ _batadv_is_ap_isolated(struct batadv_tt_local_entry *tt_local_entry, ...@@ -1853,6 +1869,11 @@ _batadv_is_ap_isolated(struct batadv_tt_local_entry *tt_local_entry,
tt_global_entry->common.flags & BATADV_TT_CLIENT_WIFI) tt_global_entry->common.flags & BATADV_TT_CLIENT_WIFI)
ret = true; ret = true;
/* check if the two clients are marked as isolated */
if (tt_local_entry->common.flags & BATADV_TT_CLIENT_ISOLA &&
tt_global_entry->common.flags & BATADV_TT_CLIENT_ISOLA)
ret = true;
return ret; return ret;
} }
...@@ -1879,19 +1900,8 @@ struct batadv_orig_node *batadv_transtable_search(struct batadv_priv *bat_priv, ...@@ -1879,19 +1900,8 @@ struct batadv_orig_node *batadv_transtable_search(struct batadv_priv *bat_priv,
struct batadv_tt_global_entry *tt_global_entry = NULL; struct batadv_tt_global_entry *tt_global_entry = NULL;
struct batadv_orig_node *orig_node = NULL; struct batadv_orig_node *orig_node = NULL;
struct batadv_tt_orig_list_entry *best_entry; struct batadv_tt_orig_list_entry *best_entry;
bool ap_isolation_enabled = false;
struct batadv_softif_vlan *vlan;
/* if the AP isolation is requested on a VLAN, then check for its if (src && batadv_vlan_ap_isola_get(bat_priv, vid)) {
* setting in the proper VLAN private data structure
*/
vlan = batadv_softif_vlan_get(bat_priv, vid);
if (vlan) {
ap_isolation_enabled = atomic_read(&vlan->ap_isolation);
batadv_softif_vlan_free_ref(vlan);
}
if (src && ap_isolation_enabled) {
tt_local_entry = batadv_tt_local_hash_find(bat_priv, src, vid); tt_local_entry = batadv_tt_local_hash_find(bat_priv, src, vid);
if (!tt_local_entry || if (!tt_local_entry ||
(tt_local_entry->common.flags & BATADV_TT_CLIENT_PENDING)) (tt_local_entry->common.flags & BATADV_TT_CLIENT_PENDING))
...@@ -3567,3 +3577,29 @@ int batadv_tt_init(struct batadv_priv *bat_priv) ...@@ -3567,3 +3577,29 @@ int batadv_tt_init(struct batadv_priv *bat_priv)
return 1; return 1;
} }
/**
* batadv_tt_global_is_isolated - check if a client is marked as isolated
* @bat_priv: the bat priv with all the soft interface information
* @addr: the mac address of the client
* @vid: the identifier of the VLAN where this client is connected
*
* Returns true if the client is marked with the TT_CLIENT_ISOLA flag, false
* otherwise
*/
bool batadv_tt_global_is_isolated(struct batadv_priv *bat_priv,
const uint8_t *addr, unsigned short vid)
{
struct batadv_tt_global_entry *tt;
bool ret;
tt = batadv_tt_global_hash_find(bat_priv, addr, vid);
if (!tt)
return false;
ret = tt->common.flags & BATADV_TT_CLIENT_ISOLA;
batadv_tt_global_entry_free_ref(tt);
return ret;
}
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#ifndef _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ #ifndef _NET_BATMAN_ADV_TRANSLATION_TABLE_H_
...@@ -22,7 +20,7 @@ ...@@ -22,7 +20,7 @@
int batadv_tt_init(struct batadv_priv *bat_priv); int batadv_tt_init(struct batadv_priv *bat_priv);
bool batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, bool batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
unsigned short vid, int ifindex); unsigned short vid, int ifindex, uint32_t mark);
uint16_t batadv_tt_local_remove(struct batadv_priv *bat_priv, uint16_t batadv_tt_local_remove(struct batadv_priv *bat_priv,
const uint8_t *addr, unsigned short vid, const uint8_t *addr, unsigned short vid,
const char *message, bool roaming); const char *message, bool roaming);
...@@ -50,5 +48,7 @@ bool batadv_tt_add_temporary_global_entry(struct batadv_priv *bat_priv, ...@@ -50,5 +48,7 @@ bool batadv_tt_add_temporary_global_entry(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node, struct batadv_orig_node *orig_node,
const unsigned char *addr, const unsigned char *addr,
unsigned short vid); unsigned short vid);
bool batadv_tt_global_is_isolated(struct batadv_priv *bat_priv,
const uint8_t *addr, unsigned short vid);
#endif /* _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ */ #endif /* _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ */
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/ */
#ifndef _NET_BATMAN_ADV_TYPES_H_ #ifndef _NET_BATMAN_ADV_TYPES_H_
...@@ -35,6 +33,18 @@ ...@@ -35,6 +33,18 @@
#endif /* CONFIG_BATMAN_ADV_DAT */ #endif /* CONFIG_BATMAN_ADV_DAT */
/**
* enum batadv_dhcp_recipient - dhcp destination
* @BATADV_DHCP_NO: packet is not a dhcp message
* @BATADV_DHCP_TO_SERVER: dhcp message is directed to a server
* @BATADV_DHCP_TO_CLIENT: dhcp message is directed to a client
*/
enum batadv_dhcp_recipient {
BATADV_DHCP_NO = 0,
BATADV_DHCP_TO_SERVER,
BATADV_DHCP_TO_CLIENT,
};
/** /**
* BATADV_TT_REMOTE_MASK - bitmask selecting the flags that are sent over the * BATADV_TT_REMOTE_MASK - bitmask selecting the flags that are sent over the
* wire only * wire only
...@@ -687,6 +697,8 @@ struct batadv_priv { ...@@ -687,6 +697,8 @@ struct batadv_priv {
#ifdef CONFIG_BATMAN_ADV_DEBUG #ifdef CONFIG_BATMAN_ADV_DEBUG
atomic_t log_level; atomic_t log_level;
#endif #endif
uint32_t isolation_mark;
uint32_t isolation_mark_mask;
atomic_t bcast_seqno; atomic_t bcast_seqno;
atomic_t bcast_queue_left; atomic_t bcast_queue_left;
atomic_t batman_queue_left; atomic_t batman_queue_left;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment