Skip to content

Commit

Permalink
batman-adv: Remove old fragmentation code
Browse files Browse the repository at this point in the history
Remove the existing fragmentation code before adding the new version
and delete unicast.{h,c}.

batadv_unicast_send_skb() is moved to send.c and renamed to
batadv_send_skb_unicast().

fragmentation entry in sysfs (bat_priv->fragmentation) is kept for use in
the new fragmentation code.

BATADV_UNICAST_FRAG packet type is renamed to BATADV_FRAG for use in the
new fragmentation code.

Signed-off-by: Martin Hundebøll <martin@hundeboll.net>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
  • Loading branch information
Martin Hundebøll authored and Antonio Quartulli committed Oct 12, 2013
1 parent 2c59866 commit f097e25
Show file tree
Hide file tree
Showing 14 changed files with 221 additions and 729 deletions.
1 change: 0 additions & 1 deletion net/batman-adv/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,3 @@ batman-adv-y += send.o
batman-adv-y += soft-interface.o
batman-adv-y += sysfs.o
batman-adv-y += translation-table.o
batman-adv-y += unicast.o
11 changes: 5 additions & 6 deletions net/batman-adv/distributed-arp-table.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "send.h"
#include "types.h"
#include "translation-table.h"
#include "unicast.h"

static void batadv_dat_purge(struct work_struct *work);

Expand Down Expand Up @@ -592,9 +591,9 @@ static bool batadv_dat_send_data(struct batadv_priv *bat_priv,
goto free_orig;

tmp_skb = pskb_copy(skb, GFP_ATOMIC);
if (!batadv_unicast_4addr_prepare_skb(bat_priv, tmp_skb,
cand[i].orig_node,
packet_subtype)) {
if (!batadv_send_skb_prepare_unicast_4addr(bat_priv, tmp_skb,
cand[i].orig_node,
packet_subtype)) {
kfree_skb(tmp_skb);
goto free_neigh;
}
Expand Down Expand Up @@ -990,10 +989,10 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
* that a node not using the 4addr packet format doesn't support it.
*/
if (hdr_size == sizeof(struct batadv_unicast_4addr_packet))
err = batadv_unicast_4addr_send_skb(bat_priv, skb_new,
err = batadv_send_skb_unicast_4addr(bat_priv, skb_new,
BATADV_P_DAT_CACHE_REPLY);
else
err = batadv_unicast_send_skb(bat_priv, skb_new);
err = batadv_send_skb_unicast(bat_priv, skb_new);

if (!err) {
batadv_inc_counter(bat_priv, BATADV_CNT_DAT_CACHED_REPLY_TX);
Expand Down
1 change: 0 additions & 1 deletion net/batman-adv/hard-interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,6 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
dev_add_pack(&hard_iface->batman_adv_ptype);

atomic_set(&hard_iface->frag_seqno, 1);
batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
hard_iface->net_dev->name);

Expand Down
4 changes: 0 additions & 4 deletions net/batman-adv/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include "gateway_client.h"
#include "bridge_loop_avoidance.h"
#include "distributed-arp-table.h"
#include "unicast.h"
#include "gateway_common.h"
#include "hash.h"
#include "bat_algo.h"
Expand Down Expand Up @@ -399,7 +398,6 @@ static void batadv_recv_handler_init(void)
/* compile time checks for struct member offsets */
BUILD_BUG_ON(offsetof(struct batadv_unicast_4addr_packet, src) != 10);
BUILD_BUG_ON(offsetof(struct batadv_unicast_packet, dest) != 4);
BUILD_BUG_ON(offsetof(struct batadv_unicast_frag_packet, dest) != 4);
BUILD_BUG_ON(offsetof(struct batadv_unicast_tvlv_packet, dst) != 4);
BUILD_BUG_ON(offsetof(struct batadv_icmp_packet, dst) != 4);
BUILD_BUG_ON(offsetof(struct batadv_icmp_packet_rr, dst) != 4);
Expand All @@ -412,8 +410,6 @@ static void batadv_recv_handler_init(void)
batadv_rx_handler[BATADV_UNICAST_4ADDR] = batadv_recv_unicast_packet;
/* unicast packet */
batadv_rx_handler[BATADV_UNICAST] = batadv_recv_unicast_packet;
/* fragmented unicast packet */
batadv_rx_handler[BATADV_UNICAST_FRAG] = batadv_recv_ucast_frag_packet;
/* unicast tvlv packet */
batadv_rx_handler[BATADV_UNICAST_TVLV] = batadv_recv_unicast_tvlv;
/* batman icmp packet */
Expand Down
9 changes: 0 additions & 9 deletions net/batman-adv/originator.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "routing.h"
#include "gateway_client.h"
#include "hard-interface.h"
#include "unicast.h"
#include "soft-interface.h"
#include "bridge_loop_avoidance.h"
#include "network-coding.h"
Expand Down Expand Up @@ -146,7 +145,6 @@ static void batadv_orig_node_free_rcu(struct rcu_head *rcu)
/* Free nc_nodes */
batadv_nc_purge_orig(orig_node->bat_priv, orig_node, NULL);

batadv_frag_list_free(&orig_node->frag_list);
batadv_tt_global_del_orig(orig_node->bat_priv, orig_node,
"originator timed out");

Expand Down Expand Up @@ -269,9 +267,6 @@ struct batadv_orig_node *batadv_get_orig_node(struct batadv_priv *bat_priv,
size = bat_priv->num_ifaces * sizeof(uint8_t);
orig_node->bcast_own_sum = kzalloc(size, GFP_ATOMIC);

INIT_LIST_HEAD(&orig_node->frag_list);
orig_node->last_frag_packet = 0;

if (!orig_node->bcast_own_sum)
goto free_bcast_own;

Expand Down Expand Up @@ -393,10 +388,6 @@ static void _batadv_purge_orig(struct batadv_priv *bat_priv)
batadv_orig_node_free_ref(orig_node);
continue;
}

if (batadv_has_timed_out(orig_node->last_frag_packet,
BATADV_FRAG_TIMEOUT))
batadv_frag_list_free(&orig_node->frag_list);
}
spin_unlock_bh(list_lock);
}
Expand Down
16 changes: 0 additions & 16 deletions net/batman-adv/packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,6 @@ enum batadv_icmp_packettype {
BATADV_PARAMETER_PROBLEM = 12,
};

/* fragmentation defines */
enum batadv_unicast_frag_flags {
BATADV_UNI_FRAG_HEAD = BIT(0),
BATADV_UNI_FRAG_LARGETAIL = BIT(1),
};

/* tt data subtypes */
#define BATADV_TT_DATA_TYPE_MASK 0x0F

Expand Down Expand Up @@ -255,16 +249,6 @@ struct batadv_unicast_4addr_packet {
*/
};

struct batadv_unicast_frag_packet {
struct batadv_header header;
uint8_t ttvn; /* destination translation table version number */
uint8_t dest[ETH_ALEN];
uint8_t flags;
uint8_t align;
uint8_t orig[ETH_ALEN];
__be16 seqno;
} __packed;

struct batadv_bcast_packet {
struct batadv_header header;
uint8_t reserved;
Expand Down
86 changes: 1 addition & 85 deletions net/batman-adv/routing.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "icmp_socket.h"
#include "translation-table.h"
#include "originator.h"
#include "unicast.h"
#include "bridge_loop_avoidance.h"
#include "distributed-arp-table.h"
#include "network-coding.h"
Expand Down Expand Up @@ -653,11 +652,9 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
{
struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface);
struct batadv_orig_node *orig_node = NULL;
struct batadv_neigh_node *neigh_node = NULL;
struct batadv_unicast_packet *unicast_packet;
struct ethhdr *ethhdr = eth_hdr(skb);
int res, hdr_len, ret = NET_RX_DROP;
struct sk_buff *new_skb;

unicast_packet = (struct batadv_unicast_packet *)skb->data;

Expand All @@ -674,46 +671,12 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
if (!orig_node)
goto out;

/* find_router() increases neigh_nodes refcount if found. */
neigh_node = batadv_find_router(bat_priv, orig_node, recv_if);

if (!neigh_node)
goto out;

/* create a copy of the skb, if needed, to modify it. */
if (skb_cow(skb, ETH_HLEN) < 0)
goto out;

unicast_packet = (struct batadv_unicast_packet *)skb->data;

if (unicast_packet->header.packet_type == BATADV_UNICAST &&
atomic_read(&bat_priv->fragmentation) &&
skb->len > neigh_node->if_incoming->net_dev->mtu) {
ret = batadv_frag_send_skb(skb, bat_priv,
neigh_node->if_incoming,
neigh_node->addr);
goto out;
}

if (unicast_packet->header.packet_type == BATADV_UNICAST_FRAG &&
batadv_frag_can_reassemble(skb,
neigh_node->if_incoming->net_dev->mtu)) {
ret = batadv_frag_reassemble_skb(skb, bat_priv, &new_skb);

if (ret == NET_RX_DROP)
goto out;

/* packet was buffered for late merge */
if (!new_skb) {
ret = NET_RX_SUCCESS;
goto out;
}

skb = new_skb;
unicast_packet = (struct batadv_unicast_packet *)skb->data;
}

/* decrement ttl */
unicast_packet = (struct batadv_unicast_packet *)skb->data;
unicast_packet->header.ttl--;

switch (unicast_packet->header.packet_type) {
Expand Down Expand Up @@ -748,8 +711,6 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
}

out:
if (neigh_node)
batadv_neigh_node_free_ref(neigh_node);
if (orig_node)
batadv_orig_node_free_ref(orig_node);
return ret;
Expand Down Expand Up @@ -1003,51 +964,6 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
return batadv_route_unicast_packet(skb, recv_if);
}

int batadv_recv_ucast_frag_packet(struct sk_buff *skb,
struct batadv_hard_iface *recv_if)
{
struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface);
struct batadv_unicast_frag_packet *unicast_packet;
int hdr_size = sizeof(*unicast_packet);
struct sk_buff *new_skb = NULL;
int ret;

if (batadv_check_unicast_packet(bat_priv, skb, hdr_size) < 0)
return NET_RX_DROP;

if (!batadv_check_unicast_ttvn(bat_priv, skb, hdr_size))
return NET_RX_DROP;

unicast_packet = (struct batadv_unicast_frag_packet *)skb->data;

/* packet for me */
if (batadv_is_my_mac(bat_priv, unicast_packet->dest)) {
ret = batadv_frag_reassemble_skb(skb, bat_priv, &new_skb);

if (ret == NET_RX_DROP)
return NET_RX_DROP;

/* packet was buffered for late merge */
if (!new_skb)
return NET_RX_SUCCESS;

if (batadv_dat_snoop_incoming_arp_request(bat_priv, new_skb,
hdr_size))
goto rx_success;
if (batadv_dat_snoop_incoming_arp_reply(bat_priv, new_skb,
hdr_size))
goto rx_success;

batadv_interface_rx(recv_if->soft_iface, new_skb, recv_if,
sizeof(struct batadv_unicast_packet), NULL);

rx_success:
return NET_RX_SUCCESS;
}

return batadv_route_unicast_packet(skb, recv_if);
}

/**
* batadv_recv_unicast_tvlv - receive and process unicast tvlv packets
* @skb: unicast tvlv packet to process
Expand Down
2 changes: 0 additions & 2 deletions net/batman-adv/routing.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ int batadv_recv_icmp_packet(struct sk_buff *skb,
struct batadv_hard_iface *recv_if);
int batadv_recv_unicast_packet(struct sk_buff *skb,
struct batadv_hard_iface *recv_if);
int batadv_recv_ucast_frag_packet(struct sk_buff *skb,
struct batadv_hard_iface *recv_if);
int batadv_recv_bcast_packet(struct sk_buff *skb,
struct batadv_hard_iface *recv_if);
int batadv_recv_tt_query(struct sk_buff *skb,
Expand Down
Loading

0 comments on commit f097e25

Please sign in to comment.