Commit bd414860 authored by David S. Miller's avatar David S. Miller

Merge tag 'batadv-next-for-davem-20170406' of git://git.open-mesh.org/linux-merge

Simon Wunderlich says:

====================
This feature/cleanup patchset includes the following patches:

 - bump version strings, by Simon Wunderlich

 - Code and Style cleanups, by Sven Eckelmann (5 patches)

 - Remove an unneccessary memset, by Tobias Klauser

 - DAT and BLA optimizations for various corner cases, by Andreas Pape
   (5 patches)

 - forward/rebroadcast packet restructuring, by Linus Luessing
   (2 patches)

 - ethtool cleanup and remove unncessary code, by Sven Eckelmann
   (4 patches)

 - use net_device_stats from net_device instead of private copy,
   by Tobias Klauser
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 54280168 ab044f8e
...@@ -679,15 +679,11 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff, ...@@ -679,15 +679,11 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff,
{ {
struct batadv_priv *bat_priv = netdev_priv(if_incoming->soft_iface); struct batadv_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
struct batadv_forw_packet *forw_packet_aggr; struct batadv_forw_packet *forw_packet_aggr;
struct sk_buff *skb;
unsigned char *skb_buff; unsigned char *skb_buff;
unsigned int skb_size; unsigned int skb_size;
atomic_t *queue_left = own_packet ? NULL : &bat_priv->batman_queue_left; atomic_t *queue_left = own_packet ? NULL : &bat_priv->batman_queue_left;
forw_packet_aggr = batadv_forw_packet_alloc(if_incoming, if_outgoing,
queue_left, bat_priv);
if (!forw_packet_aggr)
return;
if (atomic_read(&bat_priv->aggregated_ogms) && if (atomic_read(&bat_priv->aggregated_ogms) &&
packet_len < BATADV_MAX_AGGREGATION_BYTES) packet_len < BATADV_MAX_AGGREGATION_BYTES)
skb_size = BATADV_MAX_AGGREGATION_BYTES; skb_size = BATADV_MAX_AGGREGATION_BYTES;
...@@ -696,9 +692,14 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff, ...@@ -696,9 +692,14 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff,
skb_size += ETH_HLEN; skb_size += ETH_HLEN;
forw_packet_aggr->skb = netdev_alloc_skb_ip_align(NULL, skb_size); skb = netdev_alloc_skb_ip_align(NULL, skb_size);
if (!forw_packet_aggr->skb) { if (!skb)
batadv_forw_packet_free(forw_packet_aggr, true); return;
forw_packet_aggr = batadv_forw_packet_alloc(if_incoming, if_outgoing,
queue_left, bat_priv, skb);
if (!forw_packet_aggr) {
kfree_skb(skb);
return; return;
} }
......
This diff is collapsed.
...@@ -69,6 +69,10 @@ void batadv_bla_status_update(struct net_device *net_dev); ...@@ -69,6 +69,10 @@ void batadv_bla_status_update(struct net_device *net_dev);
int batadv_bla_init(struct batadv_priv *bat_priv); int batadv_bla_init(struct batadv_priv *bat_priv);
void batadv_bla_free(struct batadv_priv *bat_priv); void batadv_bla_free(struct batadv_priv *bat_priv);
int batadv_bla_claim_dump(struct sk_buff *msg, struct netlink_callback *cb); int batadv_bla_claim_dump(struct sk_buff *msg, struct netlink_callback *cb);
#ifdef CONFIG_BATMAN_ADV_DAT
bool batadv_bla_check_claim(struct batadv_priv *bat_priv, u8 *addr,
unsigned short vid);
#endif
#define BATADV_BLA_CRC_INIT 0 #define BATADV_BLA_CRC_INIT 0
#else /* ifdef CONFIG_BATMAN_ADV_BLA */ #else /* ifdef CONFIG_BATMAN_ADV_BLA */
...@@ -145,6 +149,13 @@ static inline int batadv_bla_backbone_dump(struct sk_buff *msg, ...@@ -145,6 +149,13 @@ static inline int batadv_bla_backbone_dump(struct sk_buff *msg,
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
static inline
bool batadv_bla_check_claim(struct batadv_priv *bat_priv, u8 *addr,
unsigned short vid)
{
return true;
}
#endif /* ifdef CONFIG_BATMAN_ADV_BLA */ #endif /* ifdef CONFIG_BATMAN_ADV_BLA */
#endif /* ifndef _NET_BATMAN_ADV_BLA_H_ */ #endif /* ifndef _NET_BATMAN_ADV_BLA_H_ */
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <net/arp.h> #include <net/arp.h>
#include "bridge_loop_avoidance.h"
#include "hard-interface.h" #include "hard-interface.h"
#include "hash.h" #include "hash.h"
#include "log.h" #include "log.h"
...@@ -330,7 +331,7 @@ static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip, ...@@ -330,7 +331,7 @@ static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip,
batadv_dbg(BATADV_DBG_DAT, bat_priv, batadv_dbg(BATADV_DBG_DAT, bat_priv,
"Entry updated: %pI4 %pM (vid: %d)\n", "Entry updated: %pI4 %pM (vid: %d)\n",
&dat_entry->ip, dat_entry->mac_addr, &dat_entry->ip, dat_entry->mac_addr,
BATADV_PRINT_VID(vid)); batadv_print_vid(vid));
goto out; goto out;
} }
...@@ -356,7 +357,7 @@ static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip, ...@@ -356,7 +357,7 @@ static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip,
} }
batadv_dbg(BATADV_DBG_DAT, bat_priv, "New entry added: %pI4 %pM (vid: %d)\n", batadv_dbg(BATADV_DBG_DAT, bat_priv, "New entry added: %pI4 %pM (vid: %d)\n",
&dat_entry->ip, dat_entry->mac_addr, BATADV_PRINT_VID(vid)); &dat_entry->ip, dat_entry->mac_addr, batadv_print_vid(vid));
out: out:
if (dat_entry) if (dat_entry)
...@@ -835,7 +836,7 @@ int batadv_dat_cache_seq_print_text(struct seq_file *seq, void *offset) ...@@ -835,7 +836,7 @@ int batadv_dat_cache_seq_print_text(struct seq_file *seq, void *offset)
seq_printf(seq, " * %15pI4 %14pM %4i %6i:%02i\n", seq_printf(seq, " * %15pI4 %14pM %4i %6i:%02i\n",
&dat_entry->ip, dat_entry->mac_addr, &dat_entry->ip, dat_entry->mac_addr,
BATADV_PRINT_VID(dat_entry->vid), batadv_print_vid(dat_entry->vid),
last_seen_mins, last_seen_secs); last_seen_mins, last_seen_secs);
} }
rcu_read_unlock(); rcu_read_unlock();
...@@ -1002,6 +1003,7 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv, ...@@ -1002,6 +1003,7 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
bool ret = false; bool ret = false;
struct batadv_dat_entry *dat_entry = NULL; struct batadv_dat_entry *dat_entry = NULL;
struct sk_buff *skb_new; struct sk_buff *skb_new;
struct net_device *soft_iface = bat_priv->soft_iface;
int hdr_size = 0; int hdr_size = 0;
unsigned short vid; unsigned short vid;
...@@ -1040,16 +1042,30 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv, ...@@ -1040,16 +1042,30 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
goto out; goto out;
} }
/* If BLA is enabled, only send ARP replies if we have claimed
* the destination for the ARP request or if no one else of
* the backbone gws belonging to our backbone has claimed the
* destination.
*/
if (!batadv_bla_check_claim(bat_priv,
dat_entry->mac_addr, vid)) {
batadv_dbg(BATADV_DBG_DAT, bat_priv,
"Device %pM claimed by another backbone gw. Don't send ARP reply!",
dat_entry->mac_addr);
ret = true;
goto out;
}
skb_new = batadv_dat_arp_create_reply(bat_priv, ip_dst, ip_src, skb_new = batadv_dat_arp_create_reply(bat_priv, ip_dst, ip_src,
dat_entry->mac_addr, dat_entry->mac_addr,
hw_src, vid); hw_src, vid);
if (!skb_new) if (!skb_new)
goto out; goto out;
skb_new->protocol = eth_type_trans(skb_new, skb_new->protocol = eth_type_trans(skb_new, soft_iface);
bat_priv->soft_iface);
bat_priv->stats.rx_packets++; soft_iface->stats.rx_packets++;
bat_priv->stats.rx_bytes += skb->len + ETH_HLEN + hdr_size; soft_iface->stats.rx_bytes += skb->len + ETH_HLEN + hdr_size;
netif_rx(skb_new); netif_rx(skb_new);
batadv_dbg(BATADV_DBG_DAT, bat_priv, "ARP request replied locally\n"); batadv_dbg(BATADV_DBG_DAT, bat_priv, "ARP request replied locally\n");
...@@ -1188,6 +1204,7 @@ void batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv, ...@@ -1188,6 +1204,7 @@ void batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv,
bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv, bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv,
struct sk_buff *skb, int hdr_size) struct sk_buff *skb, int hdr_size)
{ {
struct batadv_dat_entry *dat_entry = NULL;
u16 type; u16 type;
__be32 ip_src, ip_dst; __be32 ip_src, ip_dst;
u8 *hw_src, *hw_dst; u8 *hw_src, *hw_dst;
...@@ -1210,12 +1227,41 @@ bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv, ...@@ -1210,12 +1227,41 @@ bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv,
hw_dst = batadv_arp_hw_dst(skb, hdr_size); hw_dst = batadv_arp_hw_dst(skb, hdr_size);
ip_dst = batadv_arp_ip_dst(skb, hdr_size); ip_dst = batadv_arp_ip_dst(skb, hdr_size);
/* If ip_dst is already in cache and has the right mac address,
* drop this frame if this ARP reply is destined for us because it's
* most probably an ARP reply generated by another node of the DHT.
* We have most probably received already a reply earlier. Delivering
* this frame would lead to doubled receive of an ARP reply.
*/
dat_entry = batadv_dat_entry_hash_find(bat_priv, ip_src, vid);
if (dat_entry && batadv_compare_eth(hw_src, dat_entry->mac_addr)) {
batadv_dbg(BATADV_DBG_DAT, bat_priv, "Doubled ARP reply removed: ARP MSG = [src: %pM-%pI4 dst: %pM-%pI4]; dat_entry: %pM-%pI4\n",
hw_src, &ip_src, hw_dst, &ip_dst,
dat_entry->mac_addr, &dat_entry->ip);
dropped = true;
goto out;
}
/* Update our internal cache with both the IP addresses the node got /* Update our internal cache with both the IP addresses the node got
* within the ARP reply * within the ARP reply
*/ */
batadv_dat_entry_add(bat_priv, ip_src, hw_src, vid); batadv_dat_entry_add(bat_priv, ip_src, hw_src, vid);
batadv_dat_entry_add(bat_priv, ip_dst, hw_dst, vid); batadv_dat_entry_add(bat_priv, ip_dst, hw_dst, vid);
/* If BLA is enabled, only forward ARP replies if we have claimed the
* source of the ARP reply or if no one else of the same backbone has
* already claimed that client. This prevents that different gateways
* to the same backbone all forward the ARP reply leading to multiple
* replies in the backbone.
*/
if (!batadv_bla_check_claim(bat_priv, hw_src, vid)) {
batadv_dbg(BATADV_DBG_DAT, bat_priv,
"Device %pM claimed by another backbone gw. Drop ARP reply.\n",
hw_src);
dropped = true;
goto out;
}
/* if this REPLY is directed to a client of mine, let's deliver the /* if this REPLY is directed to a client of mine, let's deliver the
* packet to the interface * packet to the interface
*/ */
...@@ -1228,6 +1274,8 @@ bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv, ...@@ -1228,6 +1274,8 @@ bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv,
out: out:
if (dropped) if (dropped)
kfree_skb(skb); kfree_skb(skb);
if (dat_entry)
batadv_dat_entry_put(dat_entry);
/* if dropped == false -> deliver to the interface */ /* if dropped == false -> deliver to the interface */
return dropped; return dropped;
} }
...@@ -1256,7 +1304,7 @@ bool batadv_dat_drop_broadcast_packet(struct batadv_priv *bat_priv, ...@@ -1256,7 +1304,7 @@ bool batadv_dat_drop_broadcast_packet(struct batadv_priv *bat_priv,
/* If this packet is an ARP_REQUEST and the node already has the /* If this packet is an ARP_REQUEST and the node already has the
* information that it is going to ask, then the packet can be dropped * information that it is going to ask, then the packet can be dropped
*/ */
if (forw_packet->num_packets) if (batadv_forw_packet_is_rebroadcast(forw_packet))
goto out; goto out;
vid = batadv_dat_get_vid(forw_packet->skb, &hdr_size); vid = batadv_dat_get_vid(forw_packet->skb, &hdr_size);
......
...@@ -73,9 +73,10 @@ __printf(2, 3); ...@@ -73,9 +73,10 @@ __printf(2, 3);
/* possibly ratelimited debug output */ /* possibly ratelimited debug output */
#define _batadv_dbg(type, bat_priv, ratelimited, fmt, arg...) \ #define _batadv_dbg(type, bat_priv, ratelimited, fmt, arg...) \
do { \ do { \
if (atomic_read(&(bat_priv)->log_level) & (type) && \ struct batadv_priv *__batpriv = (bat_priv); \
if (atomic_read(&__batpriv->log_level) & (type) && \
(!(ratelimited) || net_ratelimit())) \ (!(ratelimited) || net_ratelimit())) \
batadv_debug_log(bat_priv, fmt, ## arg); \ batadv_debug_log(__batpriv, fmt, ## arg); \
} \ } \
while (0) while (0)
#else /* !CONFIG_BATMAN_ADV_DEBUG */ #else /* !CONFIG_BATMAN_ADV_DEBUG */
......
...@@ -516,6 +516,9 @@ static void batadv_recv_handler_init(void) ...@@ -516,6 +516,9 @@ static void batadv_recv_handler_init(void)
BUILD_BUG_ON(sizeof(struct batadv_tvlv_tt_change) != 12); BUILD_BUG_ON(sizeof(struct batadv_tvlv_tt_change) != 12);
BUILD_BUG_ON(sizeof(struct batadv_tvlv_roam_adv) != 8); BUILD_BUG_ON(sizeof(struct batadv_tvlv_roam_adv) != 8);
i = FIELD_SIZEOF(struct sk_buff, cb);
BUILD_BUG_ON(sizeof(struct batadv_skb_cb) > i);
/* broadcast packet */ /* broadcast packet */
batadv_rx_handler[BATADV_BCAST] = batadv_recv_bcast_packet; batadv_rx_handler[BATADV_BCAST] = batadv_recv_bcast_packet;
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#define BATADV_DRIVER_DEVICE "batman-adv" #define BATADV_DRIVER_DEVICE "batman-adv"
#ifndef BATADV_SOURCE_VERSION #ifndef BATADV_SOURCE_VERSION
#define BATADV_SOURCE_VERSION "2017.0" #define BATADV_SOURCE_VERSION "2017.1"
#endif #endif
/* B.A.T.M.A.N. parameters */ /* B.A.T.M.A.N. parameters */
...@@ -193,6 +193,7 @@ enum batadv_uev_type { ...@@ -193,6 +193,7 @@ enum batadv_uev_type {
#include <linux/percpu.h> #include <linux/percpu.h>
#include <linux/types.h> #include <linux/types.h>
#include "packet.h"
#include "types.h" #include "types.h"
struct net_device; struct net_device;
...@@ -200,8 +201,19 @@ struct packet_type; ...@@ -200,8 +201,19 @@ struct packet_type;
struct seq_file; struct seq_file;
struct sk_buff; struct sk_buff;
#define BATADV_PRINT_VID(vid) (((vid) & BATADV_VLAN_HAS_TAG) ? \ /**
(int)((vid) & VLAN_VID_MASK) : -1) * batadv_print_vid - return printable version of vid information
* @vid: the VLAN identifier
*
* Return: -1 when no VLAN is used, VLAN id otherwise
*/
static inline int batadv_print_vid(unsigned short vid)
{
if (vid & BATADV_VLAN_HAS_TAG)
return (int)(vid & VLAN_VID_MASK);
else
return -1;
}
extern struct list_head batadv_hardif_list; extern struct list_head batadv_hardif_list;
......
...@@ -494,9 +494,8 @@ static bool batadv_mcast_mla_tvlv_update(struct batadv_priv *bat_priv) ...@@ -494,9 +494,8 @@ static bool batadv_mcast_mla_tvlv_update(struct batadv_priv *bat_priv)
if (!bridged) if (!bridged)
goto update; goto update;
#if !IS_ENABLED(CONFIG_BRIDGE_IGMP_SNOOPING) if (!IS_ENABLED(CONFIG_BRIDGE_IGMP_SNOOPING))
pr_warn_once("No bridge IGMP snooping compiled - multicast optimizations disabled\n"); pr_warn_once("No bridge IGMP snooping compiled - multicast optimizations disabled\n");
#endif
querier4.exists = br_multicast_has_querier_anywhere(dev, ETH_P_IP); querier4.exists = br_multicast_has_querier_anywhere(dev, ETH_P_IP);
querier4.shadowing = br_multicast_has_querier_adjacent(dev, ETH_P_IP); querier4.shadowing = br_multicast_has_querier_adjacent(dev, ETH_P_IP);
...@@ -671,7 +670,6 @@ static int batadv_mcast_forw_mode_check_ipv4(struct batadv_priv *bat_priv, ...@@ -671,7 +670,6 @@ static int batadv_mcast_forw_mode_check_ipv4(struct batadv_priv *bat_priv,
return 0; return 0;
} }
#if IS_ENABLED(CONFIG_IPV6)
/** /**
* batadv_mcast_is_report_ipv6 - check for MLD reports * batadv_mcast_is_report_ipv6 - check for MLD reports
* @skb: the ethernet frame destined for the mesh * @skb: the ethernet frame destined for the mesh
...@@ -736,7 +734,6 @@ static int batadv_mcast_forw_mode_check_ipv6(struct batadv_priv *bat_priv, ...@@ -736,7 +734,6 @@ static int batadv_mcast_forw_mode_check_ipv6(struct batadv_priv *bat_priv,
return 0; return 0;
} }
#endif
/** /**
* batadv_mcast_forw_mode_check - check for optimized forwarding potential * batadv_mcast_forw_mode_check - check for optimized forwarding potential
...@@ -765,11 +762,12 @@ static int batadv_mcast_forw_mode_check(struct batadv_priv *bat_priv, ...@@ -765,11 +762,12 @@ static int batadv_mcast_forw_mode_check(struct batadv_priv *bat_priv,
case ETH_P_IP: case ETH_P_IP:
return batadv_mcast_forw_mode_check_ipv4(bat_priv, skb, return batadv_mcast_forw_mode_check_ipv4(bat_priv, skb,
is_unsnoopable); is_unsnoopable);
#if IS_ENABLED(CONFIG_IPV6)
case ETH_P_IPV6: case ETH_P_IPV6:
if (!IS_ENABLED(CONFIG_IPV6))
return -EINVAL;
return batadv_mcast_forw_mode_check_ipv6(bat_priv, skb, return batadv_mcast_forw_mode_check_ipv6(bat_priv, skb,
is_unsnoopable); is_unsnoopable);
#endif
default: default:
return -EINVAL; return -EINVAL;
} }
......
...@@ -941,15 +941,17 @@ int batadv_recv_unicast_packet(struct sk_buff *skb, ...@@ -941,15 +941,17 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface); struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface);
struct batadv_unicast_packet *unicast_packet; struct batadv_unicast_packet *unicast_packet;
struct batadv_unicast_4addr_packet *unicast_4addr_packet; struct batadv_unicast_4addr_packet *unicast_4addr_packet;
u8 *orig_addr; u8 *orig_addr, *orig_addr_gw;
struct batadv_orig_node *orig_node = NULL; struct batadv_orig_node *orig_node = NULL, *orig_node_gw = NULL;
int check, hdr_size = sizeof(*unicast_packet); int check, hdr_size = sizeof(*unicast_packet);
enum batadv_subtype subtype; enum batadv_subtype subtype;
bool is4addr; struct ethhdr *ethhdr;
int ret = NET_RX_DROP; int ret = NET_RX_DROP;
bool is4addr, is_gw;
unicast_packet = (struct batadv_unicast_packet *)skb->data; unicast_packet = (struct batadv_unicast_packet *)skb->data;
unicast_4addr_packet = (struct batadv_unicast_4addr_packet *)skb->data; unicast_4addr_packet = (struct batadv_unicast_4addr_packet *)skb->data;
ethhdr = eth_hdr(skb);
is4addr = unicast_packet->packet_type == BATADV_UNICAST_4ADDR; is4addr = unicast_packet->packet_type == BATADV_UNICAST_4ADDR;
/* the caller function should have already pulled 2 bytes */ /* the caller function should have already pulled 2 bytes */
...@@ -972,6 +974,23 @@ int batadv_recv_unicast_packet(struct sk_buff *skb, ...@@ -972,6 +974,23 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
/* packet for me */ /* packet for me */
if (batadv_is_my_mac(bat_priv, unicast_packet->dest)) { if (batadv_is_my_mac(bat_priv, unicast_packet->dest)) {
/* If this is a unicast packet from another backgone gw,
* drop it.
*/
orig_addr_gw = ethhdr->h_source;
orig_node_gw = batadv_orig_hash_find(bat_priv, orig_addr_gw);
if (orig_node_gw) {
is_gw = batadv_bla_is_backbone_gw(skb, orig_node_gw,
hdr_size);
batadv_orig_node_put(orig_node_gw);
if (is_gw) {
batadv_dbg(BATADV_DBG_BLA, bat_priv,
"recv_unicast_packet(): Dropped unicast pkt received from another backbone gw %pM.\n",
orig_addr_gw);
return NET_RX_DROP;
}
}
if (is4addr) { if (is4addr) {
subtype = unicast_4addr_packet->subtype; subtype = unicast_4addr_packet->subtype;
batadv_dat_inc_counter(bat_priv, subtype); batadv_dat_inc_counter(bat_priv, subtype);
......
...@@ -482,6 +482,7 @@ void batadv_forw_packet_free(struct batadv_forw_packet *forw_packet, ...@@ -482,6 +482,7 @@ void batadv_forw_packet_free(struct batadv_forw_packet *forw_packet,
* @if_outgoing: The (optional) if_outgoing to be grabbed * @if_outgoing: The (optional) if_outgoing to be grabbed
* @queue_left: The (optional) queue counter to decrease * @queue_left: The (optional) queue counter to decrease
* @bat_priv: The bat_priv for the mesh of this forw_packet * @bat_priv: The bat_priv for the mesh of this forw_packet
* @skb: The raw packet this forwarding packet shall contain
* *
* Allocates a forwarding packet and tries to get a reference to the * Allocates a forwarding packet and tries to get a reference to the
* (optional) if_incoming, if_outgoing and queue_left. If queue_left * (optional) if_incoming, if_outgoing and queue_left. If queue_left
...@@ -493,7 +494,8 @@ struct batadv_forw_packet * ...@@ -493,7 +494,8 @@ struct batadv_forw_packet *
batadv_forw_packet_alloc(struct batadv_hard_iface *if_incoming, batadv_forw_packet_alloc(struct batadv_hard_iface *if_incoming,
struct batadv_hard_iface *if_outgoing, struct batadv_hard_iface *if_outgoing,
atomic_t *queue_left, atomic_t *queue_left,
struct batadv_priv *bat_priv) struct batadv_priv *bat_priv,
struct sk_buff *skb)
{ {
struct batadv_forw_packet *forw_packet; struct batadv_forw_packet *forw_packet;
const char *qname; const char *qname;
...@@ -525,7 +527,7 @@ batadv_forw_packet_alloc(struct batadv_hard_iface *if_incoming, ...@@ -525,7 +527,7 @@ batadv_forw_packet_alloc(struct batadv_hard_iface *if_incoming,
INIT_HLIST_NODE(&forw_packet->list); INIT_HLIST_NODE(&forw_packet->list);
INIT_HLIST_NODE(&forw_packet->cleanup_list); INIT_HLIST_NODE(&forw_packet->cleanup_list);
forw_packet->skb = NULL; forw_packet->skb = skb;
forw_packet->queue_left = queue_left; forw_packet->queue_left = queue_left;
forw_packet->if_incoming = if_incoming; forw_packet->if_incoming = if_incoming;
forw_packet->if_outgoing = if_outgoing; forw_packet->if_outgoing = if_outgoing;
...@@ -756,22 +758,23 @@ int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv, ...@@ -756,22 +758,23 @@ int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv,
if (!primary_if) if (!primary_if)
goto err; goto err;
newskb = skb_copy(skb, GFP_ATOMIC);
if (!newskb) {
batadv_hardif_put(primary_if);
goto err;
}
forw_packet = batadv_forw_packet_alloc(primary_if, NULL, forw_packet = batadv_forw_packet_alloc(primary_if, NULL,
&bat_priv->bcast_queue_left, &bat_priv->bcast_queue_left,
bat_priv); bat_priv, newskb);
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
if (!forw_packet) if (!forw_packet)
goto err;
newskb = skb_copy(skb, GFP_ATOMIC);
if (!newskb)
goto err_packet_free; goto err_packet_free;
/* as we have a copy now, it is safe to decrease the TTL */ /* as we have a copy now, it is safe to decrease the TTL */
bcast_packet = (struct batadv_bcast_packet *)newskb->data; bcast_packet = (struct batadv_bcast_packet *)newskb->data;
bcast_packet->ttl--; bcast_packet->ttl--;
forw_packet->skb = newskb;
forw_packet->own = own_packet; forw_packet->own = own_packet;
INIT_DELAYED_WORK(&forw_packet->delayed_work, INIT_DELAYED_WORK(&forw_packet->delayed_work,
...@@ -781,11 +784,60 @@ int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv, ...@@ -781,11 +784,60 @@ int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv,
return NETDEV_TX_OK; return NETDEV_TX_OK;
err_packet_free: err_packet_free:
batadv_forw_packet_free(forw_packet, true); kfree_skb(newskb);
err: err:
return NETDEV_TX_BUSY; return NETDEV_TX_BUSY;
} }
/**
* batadv_forw_packet_bcasts_left - check if a retransmission is necessary
* @forw_packet: the forwarding packet to check
* @hard_iface: the interface to check on
*
* Checks whether a given packet has any (re)transmissions left on the provided
* interface.
*
* hard_iface may be NULL: In that case the number of transmissions this skb had
* so far is compared with the maximum amount of retransmissions independent of
* any interface instead.
*
* Return: True if (re)transmissions are left, false otherwise.
*/
static bool
batadv_forw_packet_bcasts_left(struct batadv_forw_packet *forw_packet,
struct batadv_hard_iface *hard_iface)
{
unsigned int max;
if (hard_iface)
max = hard_iface->num_bcasts;
else
max = BATADV_NUM_BCASTS_MAX;
return BATADV_SKB_CB(forw_packet->skb)->num_bcasts < max;
}
/**
* batadv_forw_packet_bcasts_inc - increment retransmission counter of a packet
* @forw_packet: the packet to increase the counter for
*/
static void
batadv_forw_packet_bcasts_inc(struct batadv_forw_packet *forw_packet)
{
BATADV_SKB_CB(forw_packet->skb)->num_bcasts++;
}
/**
* batadv_forw_packet_is_rebroadcast - check packet for previous transmissions
* @forw_packet: the packet to check
*
* Return: True if this packet was transmitted before, false otherwise.
*/
bool batadv_forw_packet_is_rebroadcast(struct batadv_forw_packet *forw_packet)
{
return BATADV_SKB_CB(forw_packet->skb)->num_bcasts > 0;
}
static void batadv_send_outstanding_bcast_packet(struct work_struct *work) static void batadv_send_outstanding_bcast_packet(struct work_struct *work)
{ {
struct batadv_hard_iface *hard_iface; struct batadv_hard_iface *hard_iface;
...@@ -826,7 +878,7 @@ static void batadv_send_outstanding_bcast_packet(struct work_struct *work) ...@@ -826,7 +878,7 @@ static void batadv_send_outstanding_bcast_packet(struct work_struct *work)
if (hard_iface->soft_iface != soft_iface) if (hard_iface->soft_iface != soft_iface)
continue; continue;
if (forw_packet->num_packets >= hard_iface->num_bcasts) if (!batadv_forw_packet_bcasts_left(forw_packet, hard_iface))
continue; continue;
if (forw_packet->own) { if (forw_packet->own) {
...@@ -884,10 +936,10 @@ static void batadv_send_outstanding_bcast_packet(struct work_struct *work) ...@@ -884,10 +936,10 @@ static void batadv_send_outstanding_bcast_packet(struct work_struct *work)
} }
rcu_read_unlock(); rcu_read_unlock();
forw_packet->num_packets++; batadv_forw_packet_bcasts_inc(forw_packet);
/* if we still have some more bcasts to send */ /* if we still have some more bcasts to send */
if (forw_packet->num_packets < BATADV_NUM_BCASTS_MAX) { if (batadv_forw_packet_bcasts_left(forw_packet, NULL)) {
batadv_forw_packet_bcast_queue(bat_priv, forw_packet, batadv_forw_packet_bcast_queue(bat_priv, forw_packet,
send_time); send_time);
return; return;
......
...@@ -34,11 +34,13 @@ struct batadv_forw_packet * ...@@ -34,11 +34,13 @@ struct batadv_forw_packet *
batadv_forw_packet_alloc(struct batadv_hard_iface *if_incoming, batadv_forw_packet_alloc(struct batadv_hard_iface *if_incoming,
struct batadv_hard_iface *if_outgoing, struct batadv_hard_iface *if_outgoing,
atomic_t *queue_left, atomic_t *queue_left,
struct batadv_priv *bat_priv); struct batadv_priv *bat_priv,
struct sk_buff *skb);
bool batadv_forw_packet_steal(struct batadv_forw_packet *packet, spinlock_t *l); bool batadv_forw_packet_steal(struct batadv_forw_packet *packet, spinlock_t *l);
void batadv_forw_packet_ogmv1_queue(struct batadv_priv *bat_priv, void batadv_forw_packet_ogmv1_queue(struct batadv_priv *bat_priv,
struct batadv_forw_packet *forw_packet, struct batadv_forw_packet *forw_packet,
unsigned long send_time); unsigned long send_time);
bool batadv_forw_packet_is_rebroadcast(struct batadv_forw_packet *forw_packet);
int batadv_send_skb_to_orig(struct sk_buff *skb, int batadv_send_skb_to_orig(struct sk_buff *skb,
struct batadv_orig_node *orig_node, struct batadv_orig_node *orig_node,
......
...@@ -64,28 +64,6 @@ ...@@ -64,28 +64,6 @@
#include "sysfs.h" #include "sysfs.h"
#include "translation-table.h" #include "translation-table.h"
static int batadv_get_settings(struct net_device *dev, struct ethtool_cmd *cmd);
static void batadv_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info);
static u32 batadv_get_msglevel(struct net_device *dev);
static void batadv_set_msglevel(struct net_device *dev, u32 value);
static u32 batadv_get_link(struct net_device *dev);
static void batadv_get_strings(struct net_device *dev, u32 stringset, u8 *data);
static void batadv_get_ethtool_stats(struct net_device *dev,
struct ethtool_stats *stats, u64 *data);
static int batadv_get_sset_count(struct net_device *dev, int stringset);
static const struct ethtool_ops batadv_ethtool_ops = {
.get_settings = batadv_get_settings,
.get_drvinfo = batadv_get_drvinfo,
.get_msglevel = batadv_get_msglevel,
.set_msglevel = batadv_set_msglevel,
.get_link = batadv_get_link,
.get_strings = batadv_get_strings,
.get_ethtool_stats = batadv_get_ethtool_stats,
.get_sset_count = batadv_get_sset_count,
};
int batadv_skb_head_push(struct sk_buff *skb, unsigned int len) int batadv_skb_head_push(struct sk_buff *skb, unsigned int len)
{ {
int result; int result;
...@@ -140,7 +118,7 @@ static u64 batadv_sum_counter(struct batadv_priv *bat_priv, size_t idx) ...@@ -140,7 +118,7 @@ static u64 batadv_sum_counter(struct batadv_priv *bat_priv, size_t idx)
static struct net_device_stats *batadv_interface_stats(struct net_device *dev) static struct net_device_stats *batadv_interface_stats(struct net_device *dev)
{ {
struct batadv_priv *bat_priv = netdev_priv(dev); struct batadv_priv *bat_priv = netdev_priv(dev);
struct net_device_stats *stats = &bat_priv->stats; struct net_device_stats *stats = &dev->stats;
stats->tx_packets = batadv_sum_counter(bat_priv, BATADV_CNT_TX); stats->tx_packets = batadv_sum_counter(bat_priv, BATADV_CNT_TX);
stats->tx_bytes = batadv_sum_counter(bat_priv, BATADV_CNT_TX_BYTES); stats->tx_bytes = batadv_sum_counter(bat_priv, BATADV_CNT_TX_BYTES);
...@@ -230,6 +208,9 @@ static int batadv_interface_tx(struct sk_buff *skb, ...@@ -230,6 +208,9 @@ static int batadv_interface_tx(struct sk_buff *skb,
if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE) if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE)
goto dropped; goto dropped;
/* reset control block to avoid left overs from previous users */
memset(skb->cb, 0, sizeof(struct batadv_skb_cb));
netif_trans_update(soft_iface); netif_trans_update(soft_iface);
vid = batadv_get_vid(skb, 0); vid = batadv_get_vid(skb, 0);
ethhdr = eth_hdr(skb); ethhdr = eth_hdr(skb);
...@@ -947,6 +928,98 @@ static const struct net_device_ops batadv_netdev_ops = { ...@@ -947,6 +928,98 @@ static const struct net_device_ops batadv_netdev_ops = {
.ndo_del_slave = batadv_softif_slave_del, .ndo_del_slave = batadv_softif_slave_del,
}; };
static void batadv_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info)
{
strlcpy(info->driver, "B.A.T.M.A.N. advanced", sizeof(info->driver));
strlcpy(info->version, BATADV_SOURCE_VERSION, sizeof(info->version));
strlcpy(info->fw_version, "N/A", sizeof(info->fw_version));
strlcpy(info->bus_info, "batman", sizeof(info->bus_info));
}
/* Inspired by drivers/net/ethernet/dlink/sundance.c:1702
* Declare each description string in struct.name[] to get fixed sized buffer
* and compile time checking for strings longer than ETH_GSTRING_LEN.
*/
static const struct {
const char name[ETH_GSTRING_LEN];
} batadv_counters_strings[] = {
{ "tx" },
{ "tx_bytes" },
{ "tx_dropped" },
{ "rx" },
{ "rx_bytes" },
{ "forward" },
{ "forward_bytes" },
{ "mgmt_tx" },
{ "mgmt_tx_bytes" },
{ "mgmt_rx" },
{ "mgmt_rx_bytes" },
{ "frag_tx" },
{ "frag_tx_bytes" },
{ "frag_rx" },
{ "frag_rx_bytes" },
{ "frag_fwd" },
{ "frag_fwd_bytes" },
{ "tt_request_tx" },
{ "tt_request_rx" },
{ "tt_response_tx" },
{ "tt_response_rx" },
{ "tt_roam_adv_tx" },
{ "tt_roam_adv_rx" },
#ifdef CONFIG_BATMAN_ADV_DAT
{ "dat_get_tx" },
{ "dat_get_rx" },
{ "dat_put_tx" },
{ "dat_put_rx" },
{ "dat_cached_reply_tx" },
#endif
#ifdef CONFIG_BATMAN_ADV_NC
{ "nc_code" },
{ "nc_code_bytes" },
{ "nc_recode" },
{ "nc_recode_bytes" },
{ "nc_buffer" },
{ "nc_decode" },
{ "nc_decode_bytes" },
{ "nc_decode_failed" },
{ "nc_sniffed" },
#endif
};
static void batadv_get_strings(struct net_device *dev, u32 stringset, u8 *data)
{
if (stringset == ETH_SS_STATS)
memcpy(data, batadv_counters_strings,
sizeof(batadv_counters_strings));
}
static void batadv_get_ethtool_stats(struct net_device *dev,
struct ethtool_stats *stats, u64 *data)
{
struct batadv_priv *bat_priv = netdev_priv(dev);
int i;
for (i = 0; i < BATADV_CNT_NUM; i++)
data[i] = batadv_sum_counter(bat_priv, i);
}
static int batadv_get_sset_count(struct net_device *dev, int stringset)
{
if (stringset == ETH_SS_STATS)
return BATADV_CNT_NUM;
return -EOPNOTSUPP;
}
static const struct ethtool_ops batadv_ethtool_ops = {
.get_drvinfo = batadv_get_drvinfo,
.get_link = ethtool_op_get_link,
.get_strings = batadv_get_strings,
.get_ethtool_stats = batadv_get_ethtool_stats,
.get_sset_count = batadv_get_sset_count,
};
/** /**
* batadv_softif_free - Deconstructor of batadv_soft_interface * batadv_softif_free - Deconstructor of batadv_soft_interface
* @dev: Device to cleanup and remove * @dev: Device to cleanup and remove
...@@ -971,8 +1044,6 @@ static void batadv_softif_free(struct net_device *dev) ...@@ -971,8 +1044,6 @@ static void batadv_softif_free(struct net_device *dev)
*/ */
static void batadv_softif_init_early(struct net_device *dev) static void batadv_softif_init_early(struct net_device *dev)
{ {
struct batadv_priv *priv = netdev_priv(dev);
ether_setup(dev); ether_setup(dev);
dev->netdev_ops = &batadv_netdev_ops; dev->netdev_ops = &batadv_netdev_ops;
...@@ -989,8 +1060,6 @@ static void batadv_softif_init_early(struct net_device *dev) ...@@ -989,8 +1060,6 @@ static void batadv_softif_init_early(struct net_device *dev)
eth_hw_addr_random(dev); eth_hw_addr_random(dev);
dev->ethtool_ops = &batadv_ethtool_ops; dev->ethtool_ops = &batadv_ethtool_ops;
memset(priv, 0, sizeof(*priv));
} }
struct net_device *batadv_softif_create(struct net *net, const char *name) struct net_device *batadv_softif_create(struct net *net, const char *name)
...@@ -1083,118 +1152,3 @@ struct rtnl_link_ops batadv_link_ops __read_mostly = { ...@@ -1083,118 +1152,3 @@ struct rtnl_link_ops batadv_link_ops __read_mostly = {
.setup = batadv_softif_init_early, .setup = batadv_softif_init_early,
.dellink = batadv_softif_destroy_netlink, .dellink = batadv_softif_destroy_netlink,
}; };
/* ethtool */
static int batadv_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
cmd->supported = 0;
cmd->advertising = 0;
ethtool_cmd_speed_set(cmd, SPEED_10);
cmd->duplex = DUPLEX_FULL;
cmd->port = PORT_TP;
cmd->phy_address = 0;
cmd->transceiver = XCVR_INTERNAL;
cmd->autoneg = AUTONEG_DISABLE;
cmd->maxtxpkt = 0;
cmd->maxrxpkt = 0;
return 0;
}
static void batadv_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info)
{
strlcpy(info->driver, "B.A.T.M.A.N. advanced", sizeof(info->driver));
strlcpy(info->version, BATADV_SOURCE_VERSION, sizeof(info->version));
strlcpy(info->fw_version, "N/A", sizeof(info->fw_version));
strlcpy(info->bus_info, "batman", sizeof(info->bus_info));
}
static u32 batadv_get_msglevel(struct net_device *dev)
{
return -EOPNOTSUPP;
}
static void batadv_set_msglevel(struct net_device *dev, u32 value)
{
}
static u32 batadv_get_link(struct net_device *dev)
{
return 1;
}
/* Inspired by drivers/net/ethernet/dlink/sundance.c:1702
* Declare each description string in struct.name[] to get fixed sized buffer
* and compile time checking for strings longer than ETH_GSTRING_LEN.
*/
static const struct {
const char name[ETH_GSTRING_LEN];
} batadv_counters_strings[] = {
{ "tx" },
{ "tx_bytes" },
{ "tx_dropped" },
{ "rx" },
{ "rx_bytes" },
{ "forward" },
{ "forward_bytes" },
{ "mgmt_tx" },
{ "mgmt_tx_bytes" },
{ "mgmt_rx" },
{ "mgmt_rx_bytes" },
{ "frag_tx" },
{ "frag_tx_bytes" },
{ "frag_rx" },
{ "frag_rx_bytes" },
{ "frag_fwd" },
{ "frag_fwd_bytes" },
{ "tt_request_tx" },
{ "tt_request_rx" },
{ "tt_response_tx" },
{ "tt_response_rx" },
{ "tt_roam_adv_tx" },
{ "tt_roam_adv_rx" },
#ifdef CONFIG_BATMAN_ADV_DAT
{ "dat_get_tx" },
{ "dat_get_rx" },
{ "dat_put_tx" },
{ "dat_put_rx" },
{ "dat_cached_reply_tx" },
#endif
#ifdef CONFIG_BATMAN_ADV_NC
{ "nc_code" },
{ "nc_code_bytes" },
{ "nc_recode" },
{ "nc_recode_bytes" },
{ "nc_buffer" },
{ "nc_decode" },
{ "nc_decode_bytes" },
{ "nc_decode_failed" },
{ "nc_sniffed" },
#endif
};
static void batadv_get_strings(struct net_device *dev, u32 stringset, u8 *data)
{
if (stringset == ETH_SS_STATS)
memcpy(data, batadv_counters_strings,
sizeof(batadv_counters_strings));
}
static void batadv_get_ethtool_stats(struct net_device *dev,
struct ethtool_stats *stats, u64 *data)
{
struct batadv_priv *bat_priv = netdev_priv(dev);
int i;
for (i = 0; i < BATADV_CNT_NUM; i++)
data[i] = batadv_sum_counter(bat_priv, i);
}
static int batadv_get_sset_count(struct net_device *dev, int stringset)
{
if (stringset == ETH_SS_STATS)
return BATADV_CNT_NUM;
return -EOPNOTSUPP;
}
...@@ -873,8 +873,8 @@ static int batadv_tp_send(void *arg) ...@@ -873,8 +873,8 @@ static int batadv_tp_send(void *arg)
/* something went wrong during the preparation/transmission */ /* something went wrong during the preparation/transmission */
if (unlikely(err && err != BATADV_TP_REASON_CANT_SEND)) { if (unlikely(err && err != BATADV_TP_REASON_CANT_SEND)) {
batadv_dbg(BATADV_DBG_TP_METER, bat_priv, batadv_dbg(BATADV_DBG_TP_METER, bat_priv,
"Meter: batadv_tp_send() cannot send packets (%d)\n", "Meter: %s() cannot send packets (%d)\n",
err); __func__, err);
/* ensure nobody else tries to stop the thread now */ /* ensure nobody else tries to stop the thread now */
if (atomic_dec_and_test(&tp_vars->sending)) if (atomic_dec_and_test(&tp_vars->sending))
tp_vars->reason = err; tp_vars->reason = err;
...@@ -979,7 +979,8 @@ void batadv_tp_start(struct batadv_priv *bat_priv, const u8 *dst, ...@@ -979,7 +979,8 @@ void batadv_tp_start(struct batadv_priv *bat_priv, const u8 *dst,
if (!tp_vars) { if (!tp_vars) {
spin_unlock_bh(&bat_priv->tp_list_lock); spin_unlock_bh(&bat_priv->tp_list_lock);
batadv_dbg(BATADV_DBG_TP_METER, bat_priv, batadv_dbg(BATADV_DBG_TP_METER, bat_priv,
"Meter: batadv_tp_start cannot allocate list elements\n"); "Meter: %s cannot allocate list elements\n",
__func__);
batadv_tp_batctl_error_notify(BATADV_TP_REASON_MEMORY_ERROR, batadv_tp_batctl_error_notify(BATADV_TP_REASON_MEMORY_ERROR,
dst, bat_priv, session_cookie); dst, bat_priv, session_cookie);
return; return;
......
...@@ -617,7 +617,7 @@ static void batadv_tt_global_free(struct batadv_priv *bat_priv, ...@@ -617,7 +617,7 @@ static void batadv_tt_global_free(struct batadv_priv *bat_priv,
batadv_dbg(BATADV_DBG_TT, bat_priv, batadv_dbg(BATADV_DBG_TT, bat_priv,
"Deleting global tt entry %pM (vid: %d): %s\n", "Deleting global tt entry %pM (vid: %d): %s\n",
tt_global->common.addr, tt_global->common.addr,
BATADV_PRINT_VID(tt_global->common.vid), message); batadv_print_vid(tt_global->common.vid), message);
batadv_hash_remove(bat_priv->tt.global_hash, batadv_compare_tt, batadv_hash_remove(bat_priv->tt.global_hash, batadv_compare_tt,
batadv_choose_tt, &tt_global->common); batadv_choose_tt, &tt_global->common);
...@@ -671,7 +671,7 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr, ...@@ -671,7 +671,7 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr,
if (tt_local->common.flags & BATADV_TT_CLIENT_PENDING) { if (tt_local->common.flags & BATADV_TT_CLIENT_PENDING) {
batadv_dbg(BATADV_DBG_TT, bat_priv, batadv_dbg(BATADV_DBG_TT, bat_priv,
"Re-adding pending client %pM (vid: %d)\n", "Re-adding pending client %pM (vid: %d)\n",
addr, BATADV_PRINT_VID(vid)); addr, batadv_print_vid(vid));
/* whatever the reason why the PENDING flag was set, /* whatever the reason why the PENDING flag was set,
* this is a client which was enqueued to be removed in * this is a client which was enqueued to be removed in
* this orig_interval. Since it popped up again, the * this orig_interval. Since it popped up again, the
...@@ -684,7 +684,7 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr, ...@@ -684,7 +684,7 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr,
if (tt_local->common.flags & BATADV_TT_CLIENT_ROAM) { if (tt_local->common.flags & BATADV_TT_CLIENT_ROAM) {
batadv_dbg(BATADV_DBG_TT, bat_priv, batadv_dbg(BATADV_DBG_TT, bat_priv,
"Roaming client %pM (vid: %d) came back to its original location\n", "Roaming client %pM (vid: %d) came back to its original location\n",
addr, BATADV_PRINT_VID(vid)); addr, batadv_print_vid(vid));
/* the ROAM flag is set because this client roamed away /* the ROAM flag is set because this client roamed away
* and the node got a roaming_advertisement message. Now * and the node got a roaming_advertisement message. Now
* that the client popped up again at its original * that the client popped up again at its original
...@@ -716,7 +716,7 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr, ...@@ -716,7 +716,7 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr,
if (!vlan) { if (!vlan) {
net_ratelimited_function(batadv_info, soft_iface, net_ratelimited_function(batadv_info, soft_iface,
"adding TT local entry %pM to non-existent VLAN %d\n", "adding TT local entry %pM to non-existent VLAN %d\n",
addr, BATADV_PRINT_VID(vid)); addr, batadv_print_vid(vid));
kmem_cache_free(batadv_tl_cache, tt_local); kmem_cache_free(batadv_tl_cache, tt_local);
tt_local = NULL; tt_local = NULL;
goto out; goto out;
...@@ -724,7 +724,7 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr, ...@@ -724,7 +724,7 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr,
batadv_dbg(BATADV_DBG_TT, bat_priv, batadv_dbg(BATADV_DBG_TT, bat_priv,
"Creating new local tt entry: %pM (vid: %d, ttvn: %d)\n", "Creating new local tt entry: %pM (vid: %d, ttvn: %d)\n",
addr, BATADV_PRINT_VID(vid), addr, batadv_print_vid(vid),
(u8)atomic_read(&bat_priv->tt.vn)); (u8)atomic_read(&bat_priv->tt.vn));
ether_addr_copy(tt_local->common.addr, addr); ether_addr_copy(tt_local->common.addr, addr);
...@@ -1097,7 +1097,7 @@ int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset) ...@@ -1097,7 +1097,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%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 &
BATADV_TT_CLIENT_ROAM) ? 'R' : '.'), BATADV_TT_CLIENT_ROAM) ? 'R' : '.'),
no_purge ? 'P' : '.', no_purge ? 'P' : '.',
...@@ -1296,7 +1296,7 @@ batadv_tt_local_set_pending(struct batadv_priv *bat_priv, ...@@ -1296,7 +1296,7 @@ batadv_tt_local_set_pending(struct batadv_priv *bat_priv,
batadv_dbg(BATADV_DBG_TT, bat_priv, batadv_dbg(BATADV_DBG_TT, bat_priv,
"Local tt entry (%pM, vid: %d) pending to be removed: %s\n", "Local tt entry (%pM, vid: %d) pending to be removed: %s\n",
tt_local_entry->common.addr, tt_local_entry->common.addr,
BATADV_PRINT_VID(tt_local_entry->common.vid), message); batadv_print_vid(tt_local_entry->common.vid), message);
} }
/** /**
...@@ -1727,7 +1727,7 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv, ...@@ -1727,7 +1727,7 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
batadv_dbg(BATADV_DBG_TT, bat_priv, batadv_dbg(BATADV_DBG_TT, bat_priv,
"Creating new global tt entry: %pM (vid: %d, via %pM)\n", "Creating new global tt entry: %pM (vid: %d, via %pM)\n",
common->addr, BATADV_PRINT_VID(common->vid), common->addr, batadv_print_vid(common->vid),
orig_node->orig); orig_node->orig);
ret = true; ret = true;
...@@ -1835,7 +1835,7 @@ batadv_tt_global_print_entry(struct batadv_priv *bat_priv, ...@@ -1835,7 +1835,7 @@ batadv_tt_global_print_entry(struct batadv_priv *bat_priv,
if (!vlan) { if (!vlan) {
seq_printf(seq, seq_printf(seq,
" * Cannot retrieve VLAN %d for originator %pM\n", " * Cannot retrieve VLAN %d for originator %pM\n",
BATADV_PRINT_VID(tt_common_entry->vid), batadv_print_vid(tt_common_entry->vid),
best_entry->orig_node->orig); best_entry->orig_node->orig);
goto print_list; goto print_list;
} }
...@@ -1844,7 +1844,7 @@ batadv_tt_global_print_entry(struct batadv_priv *bat_priv, ...@@ -1844,7 +1844,7 @@ batadv_tt_global_print_entry(struct batadv_priv *bat_priv,
seq_printf(seq, seq_printf(seq,
" %c %pM %4i (%3u) via %pM (%3u) (%#.8x) [%c%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' : '.'),
...@@ -1867,7 +1867,7 @@ batadv_tt_global_print_entry(struct batadv_priv *bat_priv, ...@@ -1867,7 +1867,7 @@ batadv_tt_global_print_entry(struct batadv_priv *bat_priv,
if (!vlan) { if (!vlan) {
seq_printf(seq, seq_printf(seq,
" + Cannot retrieve VLAN %d for originator %pM\n", " + Cannot retrieve VLAN %d for originator %pM\n",
BATADV_PRINT_VID(tt_common_entry->vid), batadv_print_vid(tt_common_entry->vid),
orig_entry->orig_node->orig); orig_entry->orig_node->orig);
continue; continue;
} }
...@@ -1876,7 +1876,7 @@ batadv_tt_global_print_entry(struct batadv_priv *bat_priv, ...@@ -1876,7 +1876,7 @@ batadv_tt_global_print_entry(struct batadv_priv *bat_priv,
seq_printf(seq, seq_printf(seq,
" %c %pM %4d (%3u) via %pM (%3u) (%#.8x) [%c%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' : '.'),
...@@ -2213,7 +2213,7 @@ batadv_tt_global_del_orig_node(struct batadv_priv *bat_priv, ...@@ -2213,7 +2213,7 @@ batadv_tt_global_del_orig_node(struct batadv_priv *bat_priv,
"Deleting %pM from global tt entry %pM (vid: %d): %s\n", "Deleting %pM from global tt entry %pM (vid: %d): %s\n",
orig_node->orig, orig_node->orig,
tt_global_entry->common.addr, tt_global_entry->common.addr,
BATADV_PRINT_VID(vid), message); batadv_print_vid(vid), message);
_batadv_tt_global_del_orig_entry(tt_global_entry, _batadv_tt_global_del_orig_entry(tt_global_entry,
orig_entry); orig_entry);
} }
...@@ -2253,12 +2253,13 @@ batadv_tt_global_del_roaming(struct batadv_priv *bat_priv, ...@@ -2253,12 +2253,13 @@ batadv_tt_global_del_roaming(struct batadv_priv *bat_priv,
/* its the last one, mark for roaming. */ /* its the last one, mark for roaming. */
tt_global_entry->common.flags |= BATADV_TT_CLIENT_ROAM; tt_global_entry->common.flags |= BATADV_TT_CLIENT_ROAM;
tt_global_entry->roam_at = jiffies; tt_global_entry->roam_at = jiffies;
} else } else {
/* there is another entry, we can simply delete this /* there is another entry, we can simply delete this
* one and can still use the other one. * one and can still use the other one.
*/ */
batadv_tt_global_del_orig_node(bat_priv, tt_global_entry, batadv_tt_global_del_orig_node(bat_priv, tt_global_entry,
orig_node, message); orig_node, message);
}
} }
/** /**
...@@ -2314,10 +2315,11 @@ static void batadv_tt_global_del(struct batadv_priv *bat_priv, ...@@ -2314,10 +2315,11 @@ static void batadv_tt_global_del(struct batadv_priv *bat_priv,
/* local entry exists, case 2: client roamed to us. */ /* local entry exists, case 2: client roamed to us. */
batadv_tt_global_del_orig_list(tt_global_entry); batadv_tt_global_del_orig_list(tt_global_entry);
batadv_tt_global_free(bat_priv, tt_global_entry, message); batadv_tt_global_free(bat_priv, tt_global_entry, message);
} else } else {
/* no local entry exists, case 1: check for roaming */ /* no local entry exists, case 1: check for roaming */
batadv_tt_global_del_roaming(bat_priv, tt_global_entry, batadv_tt_global_del_roaming(bat_priv, tt_global_entry,
orig_node, message); orig_node, message);
}
out: out:
if (tt_global_entry) if (tt_global_entry)
...@@ -2375,7 +2377,7 @@ void batadv_tt_global_del_orig(struct batadv_priv *bat_priv, ...@@ -2375,7 +2377,7 @@ void batadv_tt_global_del_orig(struct batadv_priv *bat_priv,
batadv_dbg(BATADV_DBG_TT, bat_priv, batadv_dbg(BATADV_DBG_TT, bat_priv,
"Deleting global tt entry %pM (vid: %d): %s\n", "Deleting global tt entry %pM (vid: %d): %s\n",
tt_global->common.addr, tt_global->common.addr,
BATADV_PRINT_VID(vid), message); batadv_print_vid(vid), message);
hlist_del_rcu(&tt_common_entry->hash_entry); hlist_del_rcu(&tt_common_entry->hash_entry);
batadv_tt_global_entry_put(tt_global); batadv_tt_global_entry_put(tt_global);
} }
...@@ -2435,7 +2437,7 @@ static void batadv_tt_global_purge(struct batadv_priv *bat_priv) ...@@ -2435,7 +2437,7 @@ static void batadv_tt_global_purge(struct batadv_priv *bat_priv)
batadv_dbg(BATADV_DBG_TT, bat_priv, batadv_dbg(BATADV_DBG_TT, bat_priv,
"Deleting global tt entry %pM (vid: %d): %s\n", "Deleting global tt entry %pM (vid: %d): %s\n",
tt_global->common.addr, tt_global->common.addr,
BATADV_PRINT_VID(tt_global->common.vid), batadv_print_vid(tt_global->common.vid),
msg); msg);
hlist_del_rcu(&tt_common->hash_entry); hlist_del_rcu(&tt_common->hash_entry);
...@@ -3650,7 +3652,7 @@ static void batadv_send_roam_adv(struct batadv_priv *bat_priv, u8 *client, ...@@ -3650,7 +3652,7 @@ static void batadv_send_roam_adv(struct batadv_priv *bat_priv, u8 *client,
batadv_dbg(BATADV_DBG_TT, bat_priv, batadv_dbg(BATADV_DBG_TT, bat_priv,
"Sending ROAMING_ADV to %pM (client %pM, vid: %d)\n", "Sending ROAMING_ADV to %pM (client %pM, vid: %d)\n",
orig_node->orig, client, BATADV_PRINT_VID(vid)); orig_node->orig, client, batadv_print_vid(vid));
batadv_inc_counter(bat_priv, BATADV_CNT_TT_ROAM_ADV_TX); batadv_inc_counter(bat_priv, BATADV_CNT_TT_ROAM_ADV_TX);
...@@ -3773,7 +3775,7 @@ static void batadv_tt_local_purge_pending_clients(struct batadv_priv *bat_priv) ...@@ -3773,7 +3775,7 @@ static void batadv_tt_local_purge_pending_clients(struct batadv_priv *bat_priv)
batadv_dbg(BATADV_DBG_TT, bat_priv, batadv_dbg(BATADV_DBG_TT, bat_priv,
"Deleting local tt entry (%pM, vid: %d): pending\n", "Deleting local tt entry (%pM, vid: %d): pending\n",
tt_common->addr, tt_common->addr,
BATADV_PRINT_VID(tt_common->vid)); batadv_print_vid(tt_common->vid));
batadv_tt_local_size_dec(bat_priv, tt_common->vid); batadv_tt_local_size_dec(bat_priv, tt_common->vid);
hlist_del_rcu(&tt_common->hash_entry); hlist_del_rcu(&tt_common->hash_entry);
...@@ -4017,7 +4019,7 @@ bool batadv_tt_add_temporary_global_entry(struct batadv_priv *bat_priv, ...@@ -4017,7 +4019,7 @@ bool batadv_tt_add_temporary_global_entry(struct batadv_priv *bat_priv,
batadv_dbg(BATADV_DBG_TT, bat_priv, batadv_dbg(BATADV_DBG_TT, bat_priv,
"Added temporary global client (addr: %pM, vid: %d, orig: %pM)\n", "Added temporary global client (addr: %pM, vid: %d, orig: %pM)\n",
addr, BATADV_PRINT_VID(vid), orig_node->orig); addr, batadv_print_vid(vid), orig_node->orig);
ret = true; ret = true;
out: out:
return ret; return ret;
......
...@@ -1000,7 +1000,6 @@ struct batadv_priv_bat_v { ...@@ -1000,7 +1000,6 @@ struct batadv_priv_bat_v {
* struct batadv_priv - per mesh interface data * struct batadv_priv - per mesh interface data
* @mesh_state: current status of the mesh (inactive/active/deactivating) * @mesh_state: current status of the mesh (inactive/active/deactivating)
* @soft_iface: net device which holds this struct as private data * @soft_iface: net device which holds this struct as private data
* @stats: structure holding the data for the ndo_get_stats() call
* @bat_counters: mesh internal traffic statistic counters (see batadv_counters) * @bat_counters: mesh internal traffic statistic counters (see batadv_counters)
* @aggregated_ogms: bool indicating whether OGM aggregation is enabled * @aggregated_ogms: bool indicating whether OGM aggregation is enabled
* @bonding: bool indicating whether traffic bonding is enabled * @bonding: bool indicating whether traffic bonding is enabled
...@@ -1055,7 +1054,6 @@ struct batadv_priv_bat_v { ...@@ -1055,7 +1054,6 @@ struct batadv_priv_bat_v {
struct batadv_priv { struct batadv_priv {
atomic_t mesh_state; atomic_t mesh_state;
struct net_device *soft_iface; struct net_device *soft_iface;
struct net_device_stats stats;
u64 __percpu *bat_counters; /* Per cpu counters */ u64 __percpu *bat_counters; /* Per cpu counters */
atomic_t aggregated_ogms; atomic_t aggregated_ogms;
atomic_t bonding; atomic_t bonding;
...@@ -1377,9 +1375,11 @@ struct batadv_nc_packet { ...@@ -1377,9 +1375,11 @@ struct batadv_nc_packet {
* relevant to batman-adv in the skb->cb buffer in skbs. * relevant to batman-adv in the skb->cb buffer in skbs.
* @decoded: Marks a skb as decoded, which is checked when searching for coding * @decoded: Marks a skb as decoded, which is checked when searching for coding
* opportunities in network-coding.c * opportunities in network-coding.c
* @num_bcasts: Counter for broadcast packet retransmissions
*/ */
struct batadv_skb_cb { struct batadv_skb_cb {
bool decoded; bool decoded;
unsigned int num_bcasts;
}; };
/** /**
...@@ -1392,7 +1392,7 @@ struct batadv_skb_cb { ...@@ -1392,7 +1392,7 @@ struct batadv_skb_cb {
* @skb: bcast packet's skb buffer * @skb: bcast packet's skb buffer
* @packet_len: size of aggregated OGM packet inside the skb buffer * @packet_len: size of aggregated OGM packet inside the skb buffer
* @direct_link_flags: direct link flags for aggregated OGM packets * @direct_link_flags: direct link flags for aggregated OGM packets
* @num_packets: counter for bcast packet retransmission * @num_packets: counter for aggregated OGMv1 packets
* @delayed_work: work queue callback item for packet sending * @delayed_work: work queue callback item for packet sending
* @if_incoming: pointer to incoming hard-iface or primary iface if * @if_incoming: pointer to incoming hard-iface or primary iface if
* locally generated packet * locally generated packet
......
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