Skip to content

Commit

Permalink
batman-adv: tvlv - convert tt query packet to use tvlv unicast packets
Browse files Browse the repository at this point in the history
Instead of generating TT specific packets the TVLV unicast API is used
to send translation table data.

Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
  • Loading branch information
Marek Lindner authored and Antonio Quartulli committed Oct 9, 2013
1 parent e1bf0c1 commit 335fbe0
Show file tree
Hide file tree
Showing 5 changed files with 286 additions and 334 deletions.
2 changes: 0 additions & 2 deletions net/batman-adv/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,6 @@ static void batadv_recv_handler_init(void)
batadv_rx_handler[BATADV_BCAST] = batadv_recv_bcast_packet;
/* vis packet */
batadv_rx_handler[BATADV_VIS] = batadv_recv_vis_packet;
/* Translation table query (request or response) */
batadv_rx_handler[BATADV_TT_QUERY] = batadv_recv_tt_query;
/* Roaming advertisement */
batadv_rx_handler[BATADV_ROAM_ADV] = batadv_recv_roam_adv;
/* unicast tvlv packet */
Expand Down
33 changes: 0 additions & 33 deletions net/batman-adv/packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ enum batadv_packettype {
BATADV_BCAST = 0x04,
BATADV_VIS = 0x05,
BATADV_UNICAST_FRAG = 0x06,
BATADV_TT_QUERY = 0x07,
BATADV_ROAM_ADV = 0x08,
BATADV_UNICAST_4ADDR = 0x09,
BATADV_CODED = 0x0a,
Expand Down Expand Up @@ -83,9 +82,6 @@ enum batadv_unicast_frag_flags {
BATADV_UNI_FRAG_LARGETAIL = BIT(1),
};

/* TT_QUERY subtypes */
#define BATADV_TT_QUERY_TYPE_MASK 0x3

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

Expand Down Expand Up @@ -271,30 +267,6 @@ struct batadv_vis_packet {
uint8_t sender_orig[ETH_ALEN]; /* who sent or forwarded this packet */
};

struct batadv_tt_query_packet {
struct batadv_header header;
/* the flag field is a combination of:
* - TT_REQUEST or TT_RESPONSE
* - TT_FULL_TABLE
*/
uint8_t flags;
uint8_t dst[ETH_ALEN];
uint8_t src[ETH_ALEN];
/* the ttvn field is:
* if TT_REQUEST: ttvn that triggered the
* request
* if TT_RESPONSE: new ttvn for the src
* orig_node
*/
uint8_t ttvn;
/* tt_data field is:
* if TT_REQUEST: crc associated with the
* ttvn
* if TT_RESPONSE: table_size
*/
__be16 tt_data;
} __packed;

struct batadv_roam_adv_packet {
struct batadv_header header;
uint8_t reserved;
Expand All @@ -303,11 +275,6 @@ struct batadv_roam_adv_packet {
uint8_t client[ETH_ALEN];
} __packed;

struct batadv_tt_change {
uint8_t flags;
uint8_t addr[ETH_ALEN];
} __packed;

/**
* struct batadv_coded_packet - network coded packet
* @header: common batman packet header and ttl of first included packet
Expand Down
78 changes: 0 additions & 78 deletions net/batman-adv/routing.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,84 +557,6 @@ static int batadv_check_unicast_packet(struct batadv_priv *bat_priv,
return 0;
}

int batadv_recv_tt_query(struct sk_buff *skb, struct batadv_hard_iface *recv_if)
{
struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface);
struct batadv_tt_query_packet *tt_query;
uint16_t tt_size;
int hdr_size = sizeof(*tt_query);
char tt_flag;
size_t packet_size;

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

/* I could need to modify it */
if (skb_cow(skb, sizeof(struct batadv_tt_query_packet)) < 0)
goto out;

tt_query = (struct batadv_tt_query_packet *)skb->data;

switch (tt_query->flags & BATADV_TT_QUERY_TYPE_MASK) {
case BATADV_TT_REQUEST:
batadv_inc_counter(bat_priv, BATADV_CNT_TT_REQUEST_RX);

/* If we cannot provide an answer the tt_request is
* forwarded
*/
if (!batadv_send_tt_response(bat_priv, tt_query)) {
if (tt_query->flags & BATADV_TT_FULL_TABLE)
tt_flag = 'F';
else
tt_flag = '.';

batadv_dbg(BATADV_DBG_TT, bat_priv,
"Routing TT_REQUEST to %pM [%c]\n",
tt_query->dst,
tt_flag);
return batadv_route_unicast_packet(skb, recv_if);
}
break;
case BATADV_TT_RESPONSE:
batadv_inc_counter(bat_priv, BATADV_CNT_TT_RESPONSE_RX);

if (batadv_is_my_mac(bat_priv, tt_query->dst)) {
/* packet needs to be linearized to access the TT
* changes
*/
if (skb_linearize(skb) < 0)
goto out;
/* skb_linearize() possibly changed skb->data */
tt_query = (struct batadv_tt_query_packet *)skb->data;

tt_size = batadv_tt_len(ntohs(tt_query->tt_data));

/* Ensure we have all the claimed data */
packet_size = sizeof(struct batadv_tt_query_packet);
packet_size += tt_size;
if (unlikely(skb_headlen(skb) < packet_size))
goto out;

batadv_handle_tt_response(bat_priv, tt_query);
} else {
if (tt_query->flags & BATADV_TT_FULL_TABLE)
tt_flag = 'F';
else
tt_flag = '.';
batadv_dbg(BATADV_DBG_TT, bat_priv,
"Routing TT_RESPONSE to %pM [%c]\n",
tt_query->dst,
tt_flag);
return batadv_route_unicast_packet(skb, recv_if);
}
break;
}

out:
/* returning NET_RX_DROP will make the caller function kfree the skb */
return NET_RX_DROP;
}

int batadv_recv_roam_adv(struct sk_buff *skb, struct batadv_hard_iface *recv_if)
{
struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface);
Expand Down
Loading

0 comments on commit 335fbe0

Please sign in to comment.