Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 290188
b: refs/heads/master
c: 76543d1
h: refs/heads/master
v: v3
  • Loading branch information
Sven Eckelmann authored and Marek Lindner committed Feb 16, 2012
1 parent b836f76 commit fa97a98
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 99 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 17071578888c7c18709e48e74fae228c04581b9a
refs/heads/master: 76543d14aec6ce5cb3fc7be9b39c50fcebd2043b
47 changes: 24 additions & 23 deletions trunk/net/batman-adv/bat_iv_ogm.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ void bat_ogm_init(struct hard_iface *hard_iface)
hard_iface->packet_buff = kmalloc(hard_iface->packet_len, GFP_ATOMIC);

batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff;
batman_ogm_packet->packet_type = BAT_OGM;
batman_ogm_packet->version = COMPAT_VERSION;
batman_ogm_packet->header.packet_type = BAT_OGM;
batman_ogm_packet->header.version = COMPAT_VERSION;
batman_ogm_packet->header.ttl = 2;
batman_ogm_packet->flags = NO_FLAGS;
batman_ogm_packet->ttl = 2;
batman_ogm_packet->tq = TQ_MAX_VALUE;
batman_ogm_packet->tt_num_changes = 0;
batman_ogm_packet->ttvn = 0;
Expand All @@ -53,7 +53,7 @@ void bat_ogm_init_primary(struct hard_iface *hard_iface)

batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff;
batman_ogm_packet->flags = PRIMARIES_FIRST_HOP;
batman_ogm_packet->ttl = TTL;
batman_ogm_packet->header.ttl = TTL;
}

void bat_ogm_update_mac(struct hard_iface *hard_iface)
Expand Down Expand Up @@ -137,7 +137,7 @@ static void bat_ogm_send_to_if(struct forw_packet *forw_packet,
fwd_str, (packet_num > 0 ? "aggregated " : ""),
batman_ogm_packet->orig,
ntohl(batman_ogm_packet->seqno),
batman_ogm_packet->tq, batman_ogm_packet->ttl,
batman_ogm_packet->tq, batman_ogm_packet->header.ttl,
(batman_ogm_packet->flags & DIRECTLINK ?
"on" : "off"),
batman_ogm_packet->ttvn, hard_iface->net_dev->name,
Expand Down Expand Up @@ -188,7 +188,7 @@ void bat_ogm_emit(struct forw_packet *forw_packet)

/* multihomed peer assumed */
/* non-primary OGMs are only broadcasted on their interface */
if ((directlink && (batman_ogm_packet->ttl == 1)) ||
if ((directlink && (batman_ogm_packet->header.ttl == 1)) ||
(forw_packet->own && (forw_packet->if_incoming != primary_if))) {

/* FIXME: what about aggregated packets ? */
Expand All @@ -198,7 +198,7 @@ void bat_ogm_emit(struct forw_packet *forw_packet)
(forw_packet->own ? "Sending own" : "Forwarding"),
batman_ogm_packet->orig,
ntohl(batman_ogm_packet->seqno),
batman_ogm_packet->ttl,
batman_ogm_packet->header.ttl,
forw_packet->if_incoming->net_dev->name,
forw_packet->if_incoming->net_dev->dev_addr);

Expand Down Expand Up @@ -272,7 +272,7 @@ static bool bat_ogm_can_aggregate(const struct batman_ogm_packet
* are flooded through the net */
if ((!directlink) &&
(!(batman_ogm_packet->flags & DIRECTLINK)) &&
(batman_ogm_packet->ttl != 1) &&
(batman_ogm_packet->header.ttl != 1) &&

/* own packets originating non-primary
* interfaces leave only that interface */
Expand All @@ -285,7 +285,7 @@ static bool bat_ogm_can_aggregate(const struct batman_ogm_packet
/* if the incoming packet is sent via this one
* interface only - we still can aggregate */
if ((directlink) &&
(new_batman_ogm_packet->ttl == 1) &&
(new_batman_ogm_packet->header.ttl == 1) &&
(forw_packet->if_incoming == if_incoming) &&

/* packets from direct neighbors or
Expand Down Expand Up @@ -471,18 +471,18 @@ static void bat_ogm_forward(struct orig_node *orig_node,
uint8_t in_tq, in_ttl, tq_avg = 0;
uint8_t tt_num_changes;

if (batman_ogm_packet->ttl <= 1) {
if (batman_ogm_packet->header.ttl <= 1) {
bat_dbg(DBG_BATMAN, bat_priv, "ttl exceeded\n");
return;
}

router = orig_node_get_router(orig_node);

in_tq = batman_ogm_packet->tq;
in_ttl = batman_ogm_packet->ttl;
in_ttl = batman_ogm_packet->header.ttl;
tt_num_changes = batman_ogm_packet->tt_num_changes;

batman_ogm_packet->ttl--;
batman_ogm_packet->header.ttl--;
memcpy(batman_ogm_packet->prev_sender, ethhdr->h_source, ETH_ALEN);

/* rebroadcast tq of our best ranking neighbor to ensure the rebroadcast
Expand All @@ -494,7 +494,8 @@ static void bat_ogm_forward(struct orig_node *orig_node,
batman_ogm_packet->tq = router->tq_avg;

if (router->last_ttl)
batman_ogm_packet->ttl = router->last_ttl - 1;
batman_ogm_packet->header.ttl =
router->last_ttl - 1;
}

tq_avg = router->tq_avg;
Expand All @@ -510,7 +511,7 @@ static void bat_ogm_forward(struct orig_node *orig_node,
"Forwarding packet: tq_orig: %i, tq_avg: %i, "
"tq_forw: %i, ttl_orig: %i, ttl_forw: %i\n",
in_tq, tq_avg, batman_ogm_packet->tq, in_ttl - 1,
batman_ogm_packet->ttl);
batman_ogm_packet->header.ttl);

batman_ogm_packet->seqno = htonl(batman_ogm_packet->seqno);
batman_ogm_packet->tt_crc = htons(batman_ogm_packet->tt_crc);
Expand Down Expand Up @@ -642,8 +643,8 @@ static void bat_ogm_orig_update(struct bat_priv *bat_priv,
spin_unlock_bh(&neigh_node->tq_lock);

if (!is_duplicate) {
orig_node->last_ttl = batman_ogm_packet->ttl;
neigh_node->last_ttl = batman_ogm_packet->ttl;
orig_node->last_ttl = batman_ogm_packet->header.ttl;
neigh_node->last_ttl = batman_ogm_packet->header.ttl;
}

bonding_candidate_add(orig_node, neigh_node);
Expand Down Expand Up @@ -683,7 +684,7 @@ static void bat_ogm_orig_update(struct bat_priv *bat_priv,
/* I have to check for transtable changes only if the OGM has been
* sent through a primary interface */
if (((batman_ogm_packet->orig != ethhdr->h_source) &&
(batman_ogm_packet->ttl > 2)) ||
(batman_ogm_packet->header.ttl > 2)) ||
(batman_ogm_packet->flags & PRIMARIES_FIRST_HOP))
tt_update_orig(bat_priv, orig_node, tt_buff,
batman_ogm_packet->tt_num_changes,
Expand Down Expand Up @@ -918,7 +919,7 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
* packet in an aggregation. Here we expect that the padding
* is always zero (or not 0x01)
*/
if (batman_ogm_packet->packet_type != BAT_OGM)
if (batman_ogm_packet->header.packet_type != BAT_OGM)
return;

/* could be changed by schedule_own_packet() */
Expand All @@ -938,8 +939,8 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
batman_ogm_packet->prev_sender, batman_ogm_packet->seqno,
batman_ogm_packet->ttvn, batman_ogm_packet->tt_crc,
batman_ogm_packet->tt_num_changes, batman_ogm_packet->tq,
batman_ogm_packet->ttl, batman_ogm_packet->version,
has_directlink_flag);
batman_ogm_packet->header.ttl,
batman_ogm_packet->header.version, has_directlink_flag);

rcu_read_lock();
list_for_each_entry_rcu(hard_iface, &hardif_list, list) {
Expand All @@ -966,10 +967,10 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
}
rcu_read_unlock();

if (batman_ogm_packet->version != COMPAT_VERSION) {
if (batman_ogm_packet->header.version != COMPAT_VERSION) {
bat_dbg(DBG_BATMAN, bat_priv,
"Drop packet: incompatible batman version (%i)\n",
batman_ogm_packet->version);
batman_ogm_packet->header.version);
return;
}

Expand Down Expand Up @@ -1091,7 +1092,7 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
if (is_bidirectional &&
(!is_duplicate ||
((orig_node->last_real_seqno == batman_ogm_packet->seqno) &&
(orig_node->last_ttl - 3 <= batman_ogm_packet->ttl))))
(orig_node->last_ttl - 3 <= batman_ogm_packet->header.ttl))))
bat_ogm_orig_update(bat_priv, orig_node, ethhdr,
batman_ogm_packet, if_incoming,
tt_buff, is_duplicate);
Expand Down
6 changes: 3 additions & 3 deletions trunk/net/batman-adv/hard-interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -590,17 +590,17 @@ static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,

batman_ogm_packet = (struct batman_ogm_packet *)skb->data;

if (batman_ogm_packet->version != COMPAT_VERSION) {
if (batman_ogm_packet->header.version != COMPAT_VERSION) {
bat_dbg(DBG_BATMAN, bat_priv,
"Drop packet: incompatible batman version (%i)\n",
batman_ogm_packet->version);
batman_ogm_packet->header.version);
goto err_free;
}

/* all receive handlers return whether they received or reused
* the supplied skb. if not, we have to free the skb. */

switch (batman_ogm_packet->packet_type) {
switch (batman_ogm_packet->header.packet_type) {
/* batman originator packet */
case BAT_OGM:
ret = recv_bat_ogm_packet(skb, hard_iface);
Expand Down
6 changes: 3 additions & 3 deletions trunk/net/batman-adv/icmp_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
goto free_skb;
}

if (icmp_packet->packet_type != BAT_ICMP) {
if (icmp_packet->header.packet_type != BAT_ICMP) {
bat_dbg(DBG_BATMAN, bat_priv,
"Error - can't send packet from char device: "
"got bogus packet type (expected: BAT_ICMP)\n");
Expand All @@ -209,9 +209,9 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,

icmp_packet->uid = socket_client->index;

if (icmp_packet->version != COMPAT_VERSION) {
if (icmp_packet->header.version != COMPAT_VERSION) {
icmp_packet->msg_type = PARAMETER_PROBLEM;
icmp_packet->version = COMPAT_VERSION;
icmp_packet->header.version = COMPAT_VERSION;
bat_socket_add_packet(socket_client, icmp_packet, packet_len);
goto free_skb;
}
Expand Down
38 changes: 13 additions & 25 deletions trunk/net/batman-adv/packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,14 @@ enum tt_client_flags {
TT_CLIENT_PENDING = 1 << 10
};

struct batman_ogm_packet {
struct batman_header {
uint8_t packet_type;
uint8_t version; /* batman version field */
uint8_t ttl;
} __packed;

struct batman_ogm_packet {
struct batman_header header;
uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
uint32_t seqno;
uint8_t orig[6];
Expand All @@ -108,9 +112,7 @@ struct batman_ogm_packet {
#define BATMAN_OGM_LEN sizeof(struct batman_ogm_packet)

struct icmp_packet {
uint8_t packet_type;
uint8_t version; /* batman version field */
uint8_t ttl;
struct batman_header header;
uint8_t msg_type; /* see ICMP message types above */
uint8_t dst[6];
uint8_t orig[6];
Expand All @@ -124,9 +126,7 @@ struct icmp_packet {
/* icmp_packet_rr must start with all fields from imcp_packet
* as this is assumed by code that handles ICMP packets */
struct icmp_packet_rr {
uint8_t packet_type;
uint8_t version; /* batman version field */
uint8_t ttl;
struct batman_header header;
uint8_t msg_type; /* see ICMP message types above */
uint8_t dst[6];
uint8_t orig[6];
Expand All @@ -137,17 +137,13 @@ struct icmp_packet_rr {
} __packed;

struct unicast_packet {
uint8_t packet_type;
uint8_t version; /* batman version field */
uint8_t ttl;
struct batman_header header;
uint8_t ttvn; /* destination translation table version number */
uint8_t dest[6];
} __packed;

struct unicast_frag_packet {
uint8_t packet_type;
uint8_t version; /* batman version field */
uint8_t ttl;
struct batman_header header;
uint8_t ttvn; /* destination translation table version number */
uint8_t dest[6];
uint8_t flags;
Expand All @@ -157,18 +153,14 @@ struct unicast_frag_packet {
} __packed;

struct bcast_packet {
uint8_t packet_type;
uint8_t version; /* batman version field */
uint8_t ttl;
struct batman_header header;
uint8_t reserved;
uint32_t seqno;
uint8_t orig[6];
} __packed;

struct vis_packet {
uint8_t packet_type;
uint8_t version; /* batman version field */
uint8_t ttl; /* TTL */
struct batman_header header;
uint8_t vis_type; /* which type of vis-participant sent this? */
uint32_t seqno; /* sequence number */
uint8_t entries; /* number of entries behind this struct */
Expand All @@ -179,9 +171,7 @@ struct vis_packet {
} __packed;

struct tt_query_packet {
uint8_t packet_type;
uint8_t version; /* batman version field */
uint8_t ttl;
struct batman_header header;
/* the flag field is a combination of:
* - TT_REQUEST or TT_RESPONSE
* - TT_FULL_TABLE */
Expand All @@ -202,9 +192,7 @@ struct tt_query_packet {
} __packed;

struct roam_adv_packet {
uint8_t packet_type;
uint8_t version;
uint8_t ttl;
struct batman_header header;
uint8_t reserved;
uint8_t dst[ETH_ALEN];
uint8_t src[ETH_ALEN];
Expand Down
18 changes: 9 additions & 9 deletions trunk/net/batman-adv/routing.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv,
memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN);
memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN);
icmp_packet->msg_type = ECHO_REPLY;
icmp_packet->ttl = TTL;
icmp_packet->header.ttl = TTL;

send_skb_packet(skb, router->if_incoming, router->addr);
ret = NET_RX_SUCCESS;
Expand Down Expand Up @@ -376,7 +376,7 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv,
memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN);
memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN);
icmp_packet->msg_type = TTL_EXCEEDED;
icmp_packet->ttl = TTL;
icmp_packet->header.ttl = TTL;

send_skb_packet(skb, router->if_incoming, router->addr);
ret = NET_RX_SUCCESS;
Expand Down Expand Up @@ -441,7 +441,7 @@ int recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if)
return recv_my_icmp_packet(bat_priv, skb, hdr_size);

/* TTL exceeded */
if (icmp_packet->ttl < 2)
if (icmp_packet->header.ttl < 2)
return recv_icmp_ttl_exceeded(bat_priv, skb);

/* get routing information */
Expand All @@ -460,7 +460,7 @@ int recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if)
icmp_packet = (struct icmp_packet_rr *)skb->data;

/* decrement ttl */
icmp_packet->ttl--;
icmp_packet->header.ttl--;

/* route it */
send_skb_packet(skb, router->if_incoming, router->addr);
Expand Down Expand Up @@ -815,7 +815,7 @@ int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
unicast_packet = (struct unicast_packet *)skb->data;

/* TTL exceeded */
if (unicast_packet->ttl < 2) {
if (unicast_packet->header.ttl < 2) {
pr_debug("Warning - can't forward unicast packet from %pM to "
"%pM: ttl exceeded\n", ethhdr->h_source,
unicast_packet->dest);
Expand All @@ -840,15 +840,15 @@ int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)

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

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

if (unicast_packet->packet_type == BAT_UNICAST_FRAG &&
if (unicast_packet->header.packet_type == BAT_UNICAST_FRAG &&
frag_can_reassemble(skb, neigh_node->if_incoming->net_dev->mtu)) {

ret = frag_reassemble_skb(skb, bat_priv, &new_skb);
Expand All @@ -867,7 +867,7 @@ int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
}

/* decrement ttl */
unicast_packet->ttl--;
unicast_packet->header.ttl--;

/* route it */
send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
Expand Down Expand Up @@ -1041,7 +1041,7 @@ int recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
if (is_my_mac(bcast_packet->orig))
goto out;

if (bcast_packet->ttl < 2)
if (bcast_packet->header.ttl < 2)
goto out;

orig_node = orig_hash_find(bat_priv, bcast_packet->orig);
Expand Down
Loading

0 comments on commit fa97a98

Please sign in to comment.