Included changes:

- increase internal module version
 - increase BLA wait periods to 6
 - purge BLA backbone table when it is disabled
 - make sure post function is invoked only if sysfs value is changed
 - simplify code by removing useless NULL checks
 - various corrections to existing kerneldoc
 - minor cleanups
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABCAAGBQJWkQVBAAoJENpFlCjNi1MRpPwP/2VrRpogpVsqTqLmidvmMqOQ
 r7MOy3/W5hqXF6Iq9omVZ0jagdDzta35/QZCab8tE1YFQhW+4jIIMUNApXSJZ+Yc
 dopXpLQNN/QSGFrQJFN897aYnXz+ABt834VyOhtLzktxYRBEdI4yKBoj3l39vXjL
 d+O9MGfJkxos1cHr+ueGohr36Fk3+dnAQFVEYf5dq/G3HwRqVRdzR8ITiMPy8zCX
 gRVFbzpg37r6nvYY93jW5VLGGFkmzuUG4SMzkQqQEp7eaUrIgrcukKF4oQahSfC9
 C0wwg8SqwX56lh9fdo1n3MkuiwYDaW7wt4QRIgpiolWhebNJqBa8ExPZgfxl9QwF
 WjkRUnGV65qY6M4AGENzIJ7JGESx66k95OnUGDpF9ZmBRWi2t/4gcwpwCjemka0A
 MZ+lDgB060ksIVcsbXnGY2TOpiMRjo1nMinixFb3HueUA9mpr5edDwJpnFy5FvhN
 lv2csEazQacmUj8KzM/5GXAvS0a8iABPSknwKOaTWX3SglGBc/H4mKYcggeD8XPG
 9zfFgOyi2dW6S5d5qxHLNwVyw6O0rkfOj2BxE3Ew/FHGb5/00hVJVeqhXVxFBb6s
 EOlZz8LrxA4DIxItFDHhiUzddqqsiTqbp7Q9JmtpEn11YZ/tQ3kTK5ilWdgkM8Vj
 4z9wQN55BTrhYcTgsCp7
 =eJvF
 -----END PGP SIGNATURE-----

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

Antonio Quartulli says:

====================
Included changes:
- increase internal module version
- increase BLA wait periods to 6
- purge BLA backbone table when it is disabled
- make sure post function is invoked only if sysfs value is changed
- simplify code by removing useless NULL checks
- various corrections to existing kerneldoc
- minor cleanups
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
David S. Miller 2016-01-09 21:48:36 -05:00
commit c9c99311b5
13 changed files with 124 additions and 118 deletions

View File

@ -115,14 +115,17 @@ The "bat0" interface can be used like any other regular inter-
face. It needs an IP address which can be either statically con-
figured or dynamically (by using DHCP or similar services):
# NodeA: ifconfig bat0 192.168.0.1
# NodeB: ifconfig bat0 192.168.0.2
# NodeA: ip link set up dev bat0
# NodeA: ip addr add 192.168.0.1/24 dev bat0
# NodeB: ip link set up dev bat0
# NodeB: ip addr add 192.168.0.2/24 dev bat0
# NodeB: ping 192.168.0.1
Note: In order to avoid problems remove all IP addresses previ-
ously assigned to interfaces now used by batman advanced, e.g.
# ifconfig eth0 0.0.0.0
# ip addr flush dev eth0
LOGGING/DEBUGGING

View File

@ -361,7 +361,6 @@ batadv_iv_ogm_primary_iface_set(struct batadv_hard_iface *hard_iface)
unsigned char *ogm_buff = hard_iface->bat_iv.ogm_buff;
batadv_ogm_packet = (struct batadv_ogm_packet *)ogm_buff;
batadv_ogm_packet->flags = BATADV_PRIMARIES_FIRST_HOP;
batadv_ogm_packet->ttl = BATADV_TTL;
}
@ -842,8 +841,6 @@ static void batadv_iv_ogm_forward(struct batadv_orig_node *orig_node,
"Forwarding packet: tq: %i, ttl: %i\n",
batadv_ogm_packet->tq, batadv_ogm_packet->ttl);
/* switch of primaries first hop flag when forwarding */
batadv_ogm_packet->flags &= ~BATADV_PRIMARIES_FIRST_HOP;
if (is_single_hop_neigh)
batadv_ogm_packet->flags |= BATADV_DIRECTLINK;
else

View File

@ -1168,6 +1168,26 @@ void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
}
}
/**
* batadv_bla_status_update - purge bla interfaces if necessary
* @net_dev: the soft interface net device
*/
void batadv_bla_status_update(struct net_device *net_dev)
{
struct batadv_priv *bat_priv = netdev_priv(net_dev);
struct batadv_hard_iface *primary_if;
primary_if = batadv_primary_if_get_selected(bat_priv);
if (!primary_if)
return;
/* this function already purges everything when bla is disabled,
* so just call that one.
*/
batadv_bla_update_orig_address(bat_priv, primary_if, primary_if);
batadv_hardif_free_ref(primary_if);
}
/* periodic work to do:
* * purge structures when they are too old
* * send announcements

View File

@ -22,6 +22,7 @@
#include <linux/types.h>
struct net_device;
struct seq_file;
struct sk_buff;
@ -42,6 +43,7 @@ int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
struct batadv_hard_iface *primary_if,
struct batadv_hard_iface *oldif);
void batadv_bla_status_update(struct net_device *net_dev);
int batadv_bla_init(struct batadv_priv *bat_priv);
void batadv_bla_free(struct batadv_priv *bat_priv);

View File

@ -31,27 +31,23 @@
#include "packet.h"
/**
* batadv_parse_gw_bandwidth - parse supplied string buffer to extract download
* and upload bandwidth information
* batadv_parse_throughput - parse supplied string buffer to extract throughput
* information
* @net_dev: the soft interface net device
* @buff: string buffer to parse
* @down: pointer holding the returned download bandwidth information
* @up: pointer holding the returned upload bandwidth information
* @description: text shown when throughput string cannot be parsed
* @throughput: pointer holding the returned throughput information
*
* Returns false on parse error and true otherwise.
*/
static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff,
u32 *down, u32 *up)
static bool batadv_parse_throughput(struct net_device *net_dev, char *buff,
const char *description, u32 *throughput)
{
enum batadv_bandwidth_units bw_unit_type = BATADV_BW_UNIT_KBIT;
char *slash_ptr, *tmp_ptr;
u64 ldown, lup;
u64 lthroughput;
char *tmp_ptr;
int ret;
slash_ptr = strchr(buff, '/');
if (slash_ptr)
*slash_ptr = 0;
if (strlen(buff) > 4) {
tmp_ptr = buff + strlen(buff) - 4;
@ -63,90 +59,75 @@ static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff,
*tmp_ptr = '\0';
}
ret = kstrtou64(buff, 10, &ldown);
ret = kstrtou64(buff, 10, &lthroughput);
if (ret) {
batadv_err(net_dev,
"Download speed of gateway mode invalid: %s\n",
buff);
"Invalid throughput speed for %s: %s\n",
description, buff);
return false;
}
switch (bw_unit_type) {
case BATADV_BW_UNIT_MBIT:
/* prevent overflow */
if (U64_MAX / 10 < ldown) {
if (U64_MAX / 10 < lthroughput) {
batadv_err(net_dev,
"Download speed of gateway mode too large: %s\n",
buff);
"Throughput speed for %s too large: %s\n",
description, buff);
return false;
}
ldown *= 10;
lthroughput *= 10;
break;
case BATADV_BW_UNIT_KBIT:
default:
ldown = div_u64(ldown, 100);
lthroughput = div_u64(lthroughput, 100);
break;
}
if (U32_MAX < ldown) {
if (lthroughput > U32_MAX) {
batadv_err(net_dev,
"Download speed of gateway mode too large: %s\n",
buff);
"Throughput speed for %s too large: %s\n",
description, buff);
return false;
}
*down = ldown;
*throughput = lthroughput;
return true;
}
/**
* batadv_parse_gw_bandwidth - parse supplied string buffer to extract download
* and upload bandwidth information
* @net_dev: the soft interface net device
* @buff: string buffer to parse
* @down: pointer holding the returned download bandwidth information
* @up: pointer holding the returned upload bandwidth information
*
* Return: false on parse error and true otherwise.
*/
static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff,
u32 *down, u32 *up)
{
char *slash_ptr;
bool ret;
slash_ptr = strchr(buff, '/');
if (slash_ptr)
*slash_ptr = 0;
ret = batadv_parse_throughput(net_dev, buff, "download gateway speed",
down);
if (!ret)
return false;
/* we also got some upload info */
if (slash_ptr) {
bw_unit_type = BATADV_BW_UNIT_KBIT;
if (strlen(slash_ptr + 1) > 4) {
tmp_ptr = slash_ptr + 1 - 4 + strlen(slash_ptr + 1);
if (strncasecmp(tmp_ptr, "mbit", 4) == 0)
bw_unit_type = BATADV_BW_UNIT_MBIT;
if ((strncasecmp(tmp_ptr, "kbit", 4) == 0) ||
(bw_unit_type == BATADV_BW_UNIT_MBIT))
*tmp_ptr = '\0';
}
ret = kstrtou64(slash_ptr + 1, 10, &lup);
if (ret) {
batadv_err(net_dev,
"Upload speed of gateway mode invalid: %s\n",
slash_ptr + 1);
ret = batadv_parse_throughput(net_dev, slash_ptr + 1,
"upload gateway speed", up);
if (!ret)
return false;
}
switch (bw_unit_type) {
case BATADV_BW_UNIT_MBIT:
/* prevent overflow */
if (U64_MAX / 10 < lup) {
batadv_err(net_dev,
"Upload speed of gateway mode too large: %s\n",
slash_ptr + 1);
return false;
}
lup *= 10;
break;
case BATADV_BW_UNIT_KBIT:
default:
lup = div_u64(lup, 100);
break;
}
if (U32_MAX < lup) {
batadv_err(net_dev,
"Upload speed of gateway mode too large: %s\n",
slash_ptr + 1);
return false;
}
*up = lup;
}
return true;

View File

@ -747,7 +747,7 @@ static u16 batadv_tvlv_container_list_size(struct batadv_priv *bat_priv)
static void batadv_tvlv_container_remove(struct batadv_priv *bat_priv,
struct batadv_tvlv_container *tvlv)
{
lockdep_assert_held(&bat_priv->tvlv.handler_list_lock);
lockdep_assert_held(&bat_priv->tvlv.container_list_lock);
if (!tvlv)
return;
@ -1143,15 +1143,14 @@ void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, u8 *src,
struct batadv_unicast_tvlv_packet *unicast_tvlv_packet;
struct batadv_tvlv_hdr *tvlv_hdr;
struct batadv_orig_node *orig_node;
struct sk_buff *skb = NULL;
struct sk_buff *skb;
unsigned char *tvlv_buff;
unsigned int tvlv_len;
ssize_t hdr_len = sizeof(*unicast_tvlv_packet);
bool ret = false;
orig_node = batadv_orig_hash_find(bat_priv, dst);
if (!orig_node)
goto out;
return;
tvlv_len = sizeof(*tvlv_hdr) + tvlv_value_len;
@ -1180,14 +1179,10 @@ void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, u8 *src,
tvlv_buff += sizeof(*tvlv_hdr);
memcpy(tvlv_buff, tvlv_value, tvlv_value_len);
if (batadv_send_skb_to_orig(skb, orig_node, NULL) != NET_XMIT_DROP)
ret = true;
out:
if (skb && !ret)
if (batadv_send_skb_to_orig(skb, orig_node, NULL) == NET_XMIT_DROP)
kfree_skb(skb);
if (orig_node)
batadv_orig_node_free_ref(orig_node);
out:
batadv_orig_node_free_ref(orig_node);
}
/**

View File

@ -24,7 +24,7 @@
#define BATADV_DRIVER_DEVICE "batman-adv"
#ifndef BATADV_SOURCE_VERSION
#define BATADV_SOURCE_VERSION "2015.2"
#define BATADV_SOURCE_VERSION "2016.0"
#endif
/* B.A.T.M.A.N. parameters */
@ -109,7 +109,7 @@
#define BATADV_MAX_AGGREGATION_MS 100
#define BATADV_BLA_PERIOD_LENGTH 10000 /* 10 seconds */
#define BATADV_BLA_BACKBONE_TIMEOUT (BATADV_BLA_PERIOD_LENGTH * 3)
#define BATADV_BLA_BACKBONE_TIMEOUT (BATADV_BLA_PERIOD_LENGTH * 6)
#define BATADV_BLA_CLAIM_TIMEOUT (BATADV_BLA_PERIOD_LENGTH * 10)
#define BATADV_BLA_WAIT_PERIODS 3

View File

@ -244,9 +244,7 @@ static void batadv_nc_path_free_ref(struct batadv_nc_path *nc_path)
*/
static void batadv_nc_packet_free(struct batadv_nc_packet *nc_packet)
{
if (nc_packet->skb)
kfree_skb(nc_packet->skb);
kfree_skb(nc_packet->skb);
batadv_nc_path_free_ref(nc_packet->nc_path);
kfree(nc_packet);
}

View File

@ -72,8 +72,7 @@ enum batadv_subtype {
* enum batadv_iv_flags - flags used in B.A.T.M.A.N. IV OGM packets
* @BATADV_NOT_BEST_NEXT_HOP: flag is set when ogm packet is forwarded and was
* previously received from someone else than the best neighbor.
* @BATADV_PRIMARIES_FIRST_HOP: flag is set when the primary interface address
* is used, and the packet travels its first hop.
* @BATADV_PRIMARIES_FIRST_HOP: flag unused.
* @BATADV_DIRECTLINK: flag is for the first hop or if rebroadcasted from a
* one hop neighbor on the interface where it was originally received.
*/

View File

@ -407,8 +407,7 @@ void batadv_schedule_bat_ogm(struct batadv_hard_iface *hard_iface)
static void batadv_forw_packet_free(struct batadv_forw_packet *forw_packet)
{
if (forw_packet->skb)
kfree_skb(forw_packet->skb);
kfree_skb(forw_packet->skb);
if (forw_packet->if_incoming)
batadv_hardif_free_ref(forw_packet->if_incoming);
if (forw_packet->if_outgoing)

View File

@ -40,6 +40,7 @@
#include "distributed-arp-table.h"
#include "gateway_client.h"
#include "gateway_common.h"
#include "bridge_loop_avoidance.h"
#include "hard-interface.h"
#include "network-coding.h"
#include "packet.h"
@ -241,10 +242,13 @@ ssize_t batadv_show_vlan_##_name(struct kobject *kobj, \
static int batadv_store_bool_attr(char *buff, size_t count,
struct net_device *net_dev,
const char *attr_name, atomic_t *attr)
const char *attr_name, atomic_t *attr,
bool *changed)
{
int enabled = -1;
*changed = false;
if (buff[count - 1] == '\n')
buff[count - 1] = '\0';
@ -271,6 +275,8 @@ static int batadv_store_bool_attr(char *buff, size_t count,
atomic_read(attr) == 1 ? "enabled" : "disabled",
enabled == 1 ? "enabled" : "disabled");
*changed = true;
atomic_set(attr, (unsigned int)enabled);
return count;
}
@ -281,11 +287,12 @@ __batadv_store_bool_attr(char *buff, size_t count,
struct attribute *attr,
atomic_t *attr_store, struct net_device *net_dev)
{
bool changed;
int ret;
ret = batadv_store_bool_attr(buff, count, net_dev, attr->name,
attr_store);
if (post_func && ret)
attr_store, &changed);
if (post_func && changed)
post_func(net_dev);
return ret;
@ -549,7 +556,8 @@ static ssize_t batadv_store_isolation_mark(struct kobject *kobj,
BATADV_ATTR_SIF_BOOL(aggregated_ogms, S_IRUGO | S_IWUSR, NULL);
BATADV_ATTR_SIF_BOOL(bonding, S_IRUGO | S_IWUSR, NULL);
#ifdef CONFIG_BATMAN_ADV_BLA
BATADV_ATTR_SIF_BOOL(bridge_loop_avoidance, S_IRUGO | S_IWUSR, NULL);
BATADV_ATTR_SIF_BOOL(bridge_loop_avoidance, S_IRUGO | S_IWUSR,
batadv_bla_status_update);
#endif
#ifdef CONFIG_BATMAN_ADV_DAT
BATADV_ATTR_SIF_BOOL(distributed_arp_table, S_IRUGO | S_IWUSR,

View File

@ -3339,7 +3339,10 @@ bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst,
bool ret = false;
vlan = batadv_softif_vlan_get(bat_priv, vid);
if (!vlan || !atomic_read(&vlan->ap_isolation))
if (!vlan)
return false;
if (!atomic_read(&vlan->ap_isolation))
goto out;
tt_local_entry = batadv_tt_local_hash_find(bat_priv, dst, vid);
@ -3356,8 +3359,7 @@ bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst,
ret = true;
out:
if (vlan)
batadv_softif_vlan_free_ref(vlan);
batadv_softif_vlan_free_ref(vlan);
if (tt_global_entry)
batadv_tt_global_entry_free_ref(tt_global_entry);
if (tt_local_entry)

View File

@ -223,12 +223,12 @@ struct batadv_orig_bat_iv {
* @orig: originator ethernet address
* @ifinfo_list: list for routers per outgoing interface
* @last_bonding_candidate: pointer to last ifinfo of last used router
* @batadv_dat_addr_t: address of the orig node in the distributed hash
* @dat_addr: address of the orig node in the distributed hash
* @last_seen: time when last packet from this node was received
* @bcast_seqno_reset: time when the broadcast seqno window was reset
* @mcast_handler_lock: synchronizes mcast-capability and -flag changes
* @mcast_flags: multicast flags announced by the orig node
* @mcast_want_all_unsnoop_node: a list node for the
* @mcast_want_all_unsnoopables_node: a list node for the
* mcast.want_all_unsnoopables list
* @mcast_want_all_ipv4_node: a list node for the mcast.want_all_ipv4 list
* @mcast_want_all_ipv6_node: a list node for the mcast.want_all_ipv6 list
@ -371,9 +371,8 @@ struct batadv_hardif_neigh_node {
* @ifinfo_lock: lock protecting private ifinfo members and list
* @if_incoming: pointer to incoming hard interface
* @last_seen: when last packet via this neighbor was received
* @last_ttl: last received ttl from this neigh node
* @refcount: number of contexts the object is used
* @rcu: struct used for freeing in an RCU-safe manner
* @bat_iv: B.A.T.M.A.N. IV private structure
*/
struct batadv_neigh_node {
struct hlist_node list;
@ -423,13 +422,14 @@ struct batadv_neigh_ifinfo {
struct rcu_head rcu;
};
#ifdef CONFIG_BATMAN_ADV_BLA
/**
* struct batadv_bcast_duplist_entry - structure for LAN broadcast suppression
* @orig[ETH_ALEN]: mac address of orig node orginating the broadcast
* @orig: mac address of orig node orginating the broadcast
* @crc: crc32 checksum of broadcast payload
* @entrytime: time when the broadcast packet was received
*/
#ifdef CONFIG_BATMAN_ADV_BLA
struct batadv_bcast_duplist_entry {
u8 orig[ETH_ALEN];
__be32 crc;
@ -571,9 +571,11 @@ struct batadv_priv_tt {
struct delayed_work work;
};
#ifdef CONFIG_BATMAN_ADV_BLA
/**
* struct batadv_priv_bla - per mesh interface bridge loope avoidance data
* @num_requests; number of bla requests in flight
* @num_requests: number of bla requests in flight
* @claim_hash: hash table containing mesh nodes this host has claimed
* @backbone_hash: hash table containing all detected backbone gateways
* @bcast_duplist: recently received broadcast packets array (for broadcast
@ -583,7 +585,6 @@ struct batadv_priv_tt {
* @claim_dest: local claim data (e.g. claim group)
* @work: work queue callback item for cleanups & bla announcements
*/
#ifdef CONFIG_BATMAN_ADV_BLA
struct batadv_priv_bla {
atomic_t num_requests;
struct batadv_hashtable *claim_hash;
@ -597,6 +598,8 @@ struct batadv_priv_bla {
};
#endif
#ifdef CONFIG_BATMAN_ADV_DEBUG
/**
* struct batadv_priv_debug_log - debug logging data
* @log_buff: buffer holding the logs (ring bufer)
@ -605,7 +608,6 @@ struct batadv_priv_bla {
* @lock: lock protecting log_buff, log_start & log_end
* @queue_wait: log reader's wait queue
*/
#ifdef CONFIG_BATMAN_ADV_DEBUG
struct batadv_priv_debug_log {
char log_buff[BATADV_LOG_BUF_LEN];
unsigned long log_start;
@ -647,13 +649,14 @@ struct batadv_priv_tvlv {
spinlock_t handler_list_lock; /* protects handler_list */
};
#ifdef CONFIG_BATMAN_ADV_DAT
/**
* struct batadv_priv_dat - per mesh interface DAT private data
* @addr: node DAT address
* @hash: hashtable representing the local ARP cache
* @work: work queue callback item for cache purging
*/
#ifdef CONFIG_BATMAN_ADV_DAT
struct batadv_priv_dat {
batadv_dat_addr_t addr;
struct batadv_hashtable *hash;
@ -795,7 +798,7 @@ struct batadv_softif_vlan {
* @dat: distributed arp table data
* @mcast: multicast data
* @network_coding: bool indicating whether network coding is enabled
* @batadv_priv_nc: network coding data
* @nc: network coding data
*/
struct batadv_priv {
atomic_t mesh_state;
@ -893,6 +896,8 @@ struct batadv_socket_packet {
u8 icmp_packet[BATADV_ICMP_MAX_PACKET_SIZE];
};
#ifdef CONFIG_BATMAN_ADV_BLA
/**
* struct batadv_bla_backbone_gw - batman-adv gateway bridged into the LAN
* @orig: originator address of backbone node (mac address of primary iface)
@ -910,7 +915,6 @@ struct batadv_socket_packet {
* @refcount: number of contexts the object is used
* @rcu: struct used for freeing in an RCU-safe manner
*/
#ifdef CONFIG_BATMAN_ADV_BLA
struct batadv_bla_backbone_gw {
u8 orig[ETH_ALEN];
unsigned short vid;
@ -929,7 +933,7 @@ struct batadv_bla_backbone_gw {
* struct batadv_bla_claim - claimed non-mesh client structure
* @addr: mac address of claimed non-mesh client
* @vid: vlan id this client was detected on
* @batadv_bla_backbone_gw: pointer to backbone gw claiming this client
* @backbone_gw: pointer to backbone gw claiming this client
* @lasttime: last time we heard of claim (locals only)
* @hash_entry: hlist node for batadv_priv_bla::claim_hash
* @refcount: number of contexts the object is used
@ -1252,8 +1256,6 @@ struct batadv_dat_candidate {
* struct batadv_tvlv_container - container for tvlv appended to OGMs
* @list: hlist node for batadv_priv_tvlv::container_list
* @tvlv_hdr: tvlv header information needed to construct the tvlv
* @value_len: length of the buffer following this struct which contains
* the actual tvlv payload
* @refcount: number of contexts the object is used
*/
struct batadv_tvlv_container {