Hello,
here are a set of changes I would like to propose for next-next/3.5. Most of the patches are simple cleanups and small fixes. The only important change is patch 3 which changes the Originator Message sequence number starting value from 0 to a random generated value.
Thank you, Antonio
The following changes since commit ecffe75f934b4e3c5301fe5db278068e0efb0d6b:
hippi: fix printk format in rrunner.c (2012-04-16 23:48:38 -0400)
are available in the git repository at:
git://git.open-mesh.org/linux-merge.git tags/batman-adv-for-davem
for you to fetch changes up to 520ada6df73ab595f7d51378b9df937371f13460:
batman-adv: skip the window protection test when the originator has no neighbours (2012-04-17 13:29:19 +0200)
---------------------------------------------------------------- Included changes: * several cleanups and fixes * OriGinator Message seqno initial value is now random
---------------------------------------------------------------- Antonio Quartulli (3): batman-adv: use ETH_HLEN instead of sizeof(struct ethhdr) batman-adv: print OGM seq numbers as unsigned long batman-adv: skip the window protection test when the originator has no neighbours
Marek Lindner (8): batman-adv: move ogm initialization into the proper function batman-adv: refactoring API: find generalized name for bat_ogm_init callback batman-adv: randomize initial seqno to avoid collision batman-adv: add iface_disable() callback to routing API batman-adv: handle routing code initialization properly batman-adv: refactoring API: find generalized name for bat_ogm_init_primary callback batman-adv: rename BATMAN_OGM_LEN to BATMAN_OGM_HLEN batman-adv: mark existing ogm variables as batman iv
net/batman-adv/bat_iv_ogm.c | 63 +++++++++++++++++++++----------- net/batman-adv/bridge_loop_avoidance.c | 10 ++--- net/batman-adv/hard-interface.c | 33 +++++++++-------- net/batman-adv/icmp_socket.c | 4 +- net/batman-adv/main.c | 5 ++- net/batman-adv/packet.h | 6 +-- net/batman-adv/routing.c | 10 ++--- net/batman-adv/send.c | 14 +++---- net/batman-adv/soft-interface.c | 2 +- net/batman-adv/types.h | 12 +++--- net/batman-adv/vis.c | 8 ++-- 11 files changed, 95 insertions(+), 72 deletions(-)
From: Marek Lindner lindner_marek@yahoo.de
Signed-off-by: Marek Lindner lindner_marek@yahoo.de Signed-off-by: Antonio Quartulli ordex@autistici.org --- net/batman-adv/hard-interface.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index 8c4b790..f152007 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -332,7 +332,6 @@ int hardif_enable_interface(struct 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->seqno, 1); atomic_set(&hard_iface->frag_seqno, 1); bat_info(hard_iface->soft_iface, "Adding interface: %s\n", hard_iface->net_dev->name); @@ -451,6 +450,13 @@ static struct hard_iface *hardif_add_interface(struct net_device *net_dev) check_known_mac_addr(hard_iface->net_dev); list_add_tail_rcu(&hard_iface->list, &hardif_list);
+ /** + * This can't be called via a bat_priv callback because + * we have no bat_priv yet. + */ + atomic_set(&hard_iface->seqno, 1); + hard_iface->packet_buff = NULL; + return hard_iface;
free_if:
From: Marek Lindner lindner_marek@yahoo.de
Signed-off-by: Marek Lindner lindner_marek@yahoo.de Signed-off-by: Antonio Quartulli ordex@autistici.org --- net/batman-adv/bat_iv_ogm.c | 4 ++-- net/batman-adv/hard-interface.c | 2 +- net/batman-adv/main.c | 2 +- net/batman-adv/types.h | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index fab1071..117b831 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -30,7 +30,7 @@ #include "send.h" #include "bat_algo.h"
-static void bat_iv_ogm_init(struct hard_iface *hard_iface) +static void bat_iv_ogm_iface_enable(struct hard_iface *hard_iface) { struct batman_ogm_packet *batman_ogm_packet;
@@ -1169,7 +1169,7 @@ static void bat_iv_ogm_receive(struct hard_iface *if_incoming,
static struct bat_algo_ops batman_iv __read_mostly = { .name = "BATMAN IV", - .bat_ogm_init = bat_iv_ogm_init, + .bat_iface_enable = bat_iv_ogm_iface_enable, .bat_ogm_init_primary = bat_iv_ogm_init_primary, .bat_ogm_update_mac = bat_iv_ogm_update_mac, .bat_ogm_schedule = bat_iv_ogm_schedule, diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index f152007..4d9b85d 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -312,7 +312,7 @@ int hardif_enable_interface(struct hard_iface *hard_iface, hard_iface->soft_iface = soft_iface; bat_priv = netdev_priv(hard_iface->soft_iface);
- bat_priv->bat_algo_ops->bat_ogm_init(hard_iface); + bat_priv->bat_algo_ops->bat_iface_enable(hard_iface);
if (!hard_iface->packet_buff) { bat_err(hard_iface->soft_iface, diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index e67ca96..ca8f395 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c @@ -208,7 +208,7 @@ int bat_algo_register(struct bat_algo_ops *bat_algo_ops) }
/* all algorithms must implement all ops (for now) */ - if (!bat_algo_ops->bat_ogm_init || + if (!bat_algo_ops->bat_iface_enable || !bat_algo_ops->bat_ogm_init_primary || !bat_algo_ops->bat_ogm_update_mac || !bat_algo_ops->bat_ogm_schedule || diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index a5b1a63..4b92248 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h @@ -377,8 +377,8 @@ struct recvlist_node { struct bat_algo_ops { struct hlist_node list; char *name; - /* init OGM when hard-interface is enabled */ - void (*bat_ogm_init)(struct hard_iface *hard_iface); + /* init routing info when hard-interface is enabled */ + void (*bat_iface_enable)(struct hard_iface *hard_iface); /* init primary OGM when primary interface is selected */ void (*bat_ogm_init_primary)(struct hard_iface *hard_iface); /* init mac addresses of the OGM belonging to this hard-interface */
From: Marek Lindner lindner_marek@yahoo.de
Signed-off-by: Marek Lindner lindner_marek@yahoo.de Signed-off-by: Antonio Quartulli ordex@autistici.org --- net/batman-adv/bat_iv_ogm.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 117b831..4661bd4 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -33,6 +33,11 @@ static void bat_iv_ogm_iface_enable(struct hard_iface *hard_iface) { struct batman_ogm_packet *batman_ogm_packet; + unsigned long random_seqno; + + /* randomize initial seqno to avoid collision */ + get_random_bytes(&random_seqno, sizeof(unsigned long)); + atomic_set(&hard_iface->seqno, (uint32_t)random_seqno);
hard_iface->packet_len = BATMAN_OGM_LEN; hard_iface->packet_buff = kmalloc(hard_iface->packet_len, GFP_ATOMIC);
From: Antonio Quartulli ordex@autistici.org Date: Tue, 17 Apr 2012 13:58:19 +0200
@@ -33,6 +33,11 @@ static void bat_iv_ogm_iface_enable(struct hard_iface *hard_iface) { struct batman_ogm_packet *batman_ogm_packet;
- unsigned long random_seqno;
- /* randomize initial seqno to avoid collision */
- get_random_bytes(&random_seqno, sizeof(unsigned long));
- atomic_set(&hard_iface->seqno, (uint32_t)random_seqno);
This is silly.
Just use "uint32_t" for the type of random_seqno and the sizeof passed to get_random_bytes.
And here comes the magic part.
Amazing, no ugly and pointless casts needed!
On Tue, Apr 17, 2012 at 10:45:27 -0400, David Miller wrote:
From: Antonio Quartulli ordex@autistici.org Date: Tue, 17 Apr 2012 13:58:19 +0200
@@ -33,6 +33,11 @@ static void bat_iv_ogm_iface_enable(struct hard_iface *hard_iface) { struct batman_ogm_packet *batman_ogm_packet;
- unsigned long random_seqno;
- /* randomize initial seqno to avoid collision */
- get_random_bytes(&random_seqno, sizeof(unsigned long));
- atomic_set(&hard_iface->seqno, (uint32_t)random_seqno);
This is silly.
Just use "uint32_t" for the type of random_seqno and the sizeof passed to get_random_bytes.
And here comes the magic part.
Amazing, no ugly and pointless casts needed!
I agree :-) Thank you for the suggestion.
Cheers,
From: Marek Lindner lindner_marek@yahoo.de
Signed-off-by: Marek Lindner lindner_marek@yahoo.de Signed-off-by: Antonio Quartulli ordex@autistici.org --- net/batman-adv/bat_iv_ogm.c | 7 +++++++ net/batman-adv/hard-interface.c | 3 +-- net/batman-adv/main.c | 1 + net/batman-adv/types.h | 2 ++ 4 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 4661bd4..b8cb031 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -52,6 +52,12 @@ static void bat_iv_ogm_iface_enable(struct hard_iface *hard_iface) batman_ogm_packet->ttvn = 0; }
+static void bat_iv_ogm_iface_disable(struct hard_iface *hard_iface) +{ + kfree(hard_iface->packet_buff); + hard_iface->packet_buff = NULL; +} + static void bat_iv_ogm_init_primary(struct hard_iface *hard_iface) { struct batman_ogm_packet *batman_ogm_packet; @@ -1175,6 +1181,7 @@ static void bat_iv_ogm_receive(struct hard_iface *if_incoming, static struct bat_algo_ops batman_iv __read_mostly = { .name = "BATMAN IV", .bat_iface_enable = bat_iv_ogm_iface_enable, + .bat_iface_disable = bat_iv_ogm_iface_disable, .bat_ogm_init_primary = bat_iv_ogm_init_primary, .bat_ogm_update_mac = bat_iv_ogm_update_mac, .bat_ogm_schedule = bat_iv_ogm_schedule, diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index 4d9b85d..fd9715e 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -397,8 +397,7 @@ void hardif_disable_interface(struct hard_iface *hard_iface) hardif_free_ref(new_if); }
- kfree(hard_iface->packet_buff); - hard_iface->packet_buff = NULL; + bat_priv->bat_algo_ops->bat_iface_disable(hard_iface); hard_iface->if_status = IF_NOT_IN_USE;
/* delete all references to this hard_iface */ diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index ca8f395..a47a6ce 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c @@ -209,6 +209,7 @@ int bat_algo_register(struct bat_algo_ops *bat_algo_ops)
/* all algorithms must implement all ops (for now) */ if (!bat_algo_ops->bat_iface_enable || + !bat_algo_ops->bat_iface_disable || !bat_algo_ops->bat_ogm_init_primary || !bat_algo_ops->bat_ogm_update_mac || !bat_algo_ops->bat_ogm_schedule || diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index 4b92248..b034cf2 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h @@ -379,6 +379,8 @@ struct bat_algo_ops { char *name; /* init routing info when hard-interface is enabled */ void (*bat_iface_enable)(struct hard_iface *hard_iface); + /* de-init routing info when hard-interface is disabled */ + void (*bat_iface_disable)(struct hard_iface *hard_iface); /* init primary OGM when primary interface is selected */ void (*bat_ogm_init_primary)(struct hard_iface *hard_iface); /* init mac addresses of the OGM belonging to this hard-interface */
From: Marek Lindner lindner_marek@yahoo.de
Signed-off-by: Marek Lindner lindner_marek@yahoo.de Signed-off-by: Antonio Quartulli ordex@autistici.org --- net/batman-adv/bat_iv_ogm.c | 11 ++++++++++- net/batman-adv/hard-interface.c | 15 ++++++--------- net/batman-adv/types.h | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index b8cb031..f31f2e7 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -30,10 +30,11 @@ #include "send.h" #include "bat_algo.h"
-static void bat_iv_ogm_iface_enable(struct hard_iface *hard_iface) +static int bat_iv_ogm_iface_enable(struct hard_iface *hard_iface) { struct batman_ogm_packet *batman_ogm_packet; unsigned long random_seqno; + int res = -1;
/* randomize initial seqno to avoid collision */ get_random_bytes(&random_seqno, sizeof(unsigned long)); @@ -42,6 +43,9 @@ static void bat_iv_ogm_iface_enable(struct hard_iface *hard_iface) hard_iface->packet_len = BATMAN_OGM_LEN; hard_iface->packet_buff = kmalloc(hard_iface->packet_len, GFP_ATOMIC);
+ if (!hard_iface->packet_buff) + goto out; + batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff; batman_ogm_packet->header.packet_type = BAT_OGM; batman_ogm_packet->header.version = COMPAT_VERSION; @@ -50,6 +54,11 @@ static void bat_iv_ogm_iface_enable(struct hard_iface *hard_iface) batman_ogm_packet->tq = TQ_MAX_VALUE; batman_ogm_packet->tt_num_changes = 0; batman_ogm_packet->ttvn = 0; + + res = 0; + +out: + return res; }
static void bat_iv_ogm_iface_disable(struct hard_iface *hard_iface) diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index fd9715e..3b391fd 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -304,22 +304,17 @@ int hardif_enable_interface(struct hard_iface *hard_iface, if (!softif_is_valid(soft_iface)) { pr_err("Can't create batman mesh interface %s: already exists as regular interface\n", soft_iface->name); - dev_put(soft_iface); ret = -EINVAL; - goto err; + goto err_dev; }
hard_iface->soft_iface = soft_iface; bat_priv = netdev_priv(hard_iface->soft_iface);
- bat_priv->bat_algo_ops->bat_iface_enable(hard_iface); - - if (!hard_iface->packet_buff) { - bat_err(hard_iface->soft_iface, - "Can't add interface packet (%s): out of memory\n", - hard_iface->net_dev->name); + ret = bat_priv->bat_algo_ops->bat_iface_enable(hard_iface); + if (ret < 0) { ret = -ENOMEM; - goto err; + goto err_dev; }
hard_iface->if_num = bat_priv->num_ifaces; @@ -363,6 +358,8 @@ int hardif_enable_interface(struct hard_iface *hard_iface, out: return 0;
+err_dev: + dev_put(soft_iface); err: hardif_free_ref(hard_iface); return ret; diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index b034cf2..dd78023 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h @@ -378,7 +378,7 @@ struct bat_algo_ops { struct hlist_node list; char *name; /* init routing info when hard-interface is enabled */ - void (*bat_iface_enable)(struct hard_iface *hard_iface); + int (*bat_iface_enable)(struct hard_iface *hard_iface); /* de-init routing info when hard-interface is disabled */ void (*bat_iface_disable)(struct hard_iface *hard_iface); /* init primary OGM when primary interface is selected */
From: Antonio Quartulli ordex@autistici.org Date: Tue, 17 Apr 2012 13:58:21 +0200
@@ -30,10 +30,11 @@ #include "send.h" #include "bat_algo.h"
-static void bat_iv_ogm_iface_enable(struct hard_iface *hard_iface) +static int bat_iv_ogm_iface_enable(struct hard_iface *hard_iface) { struct batman_ogm_packet *batman_ogm_packet; unsigned long random_seqno;
int res = -1;
/* randomize initial seqno to avoid collision */ get_random_bytes(&random_seqno, sizeof(unsigned long));
Use real error codes, even as a default, instead of meaningless values like -1.
On Tue, Apr 17, 2012 at 10:46:30 -0400, David Miller wrote:
From: Antonio Quartulli ordex@autistici.org Date: Tue, 17 Apr 2012 13:58:21 +0200
@@ -30,10 +30,11 @@ #include "send.h" #include "bat_algo.h"
-static void bat_iv_ogm_iface_enable(struct hard_iface *hard_iface) +static int bat_iv_ogm_iface_enable(struct hard_iface *hard_iface) { struct batman_ogm_packet *batman_ogm_packet; unsigned long random_seqno;
int res = -1;
/* randomize initial seqno to avoid collision */ get_random_bytes(&random_seqno, sizeof(unsigned long));
Use real error codes, even as a default, instead of meaningless values like -1.
Actually all these kind of return values are handled internally the batman-adv code so we didn't care so much to use real error codes. However using real codes will surely increase readability.
I will modify this patch and I'll try to suggest other developers to use real codes too.
Thank you.
From: Marek Lindner lindner_marek@yahoo.de
Signed-off-by: Marek Lindner lindner_marek@yahoo.de Signed-off-by: Antonio Quartulli ordex@autistici.org --- net/batman-adv/bat_iv_ogm.c | 4 ++-- net/batman-adv/hard-interface.c | 2 +- net/batman-adv/main.c | 2 +- net/batman-adv/types.h | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index f31f2e7..9717c7a 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -67,7 +67,7 @@ static void bat_iv_ogm_iface_disable(struct hard_iface *hard_iface) hard_iface->packet_buff = NULL; }
-static void bat_iv_ogm_init_primary(struct hard_iface *hard_iface) +static void bat_iv_ogm_primary_iface_set(struct hard_iface *hard_iface) { struct batman_ogm_packet *batman_ogm_packet;
@@ -1191,7 +1191,7 @@ static struct bat_algo_ops batman_iv __read_mostly = { .name = "BATMAN IV", .bat_iface_enable = bat_iv_ogm_iface_enable, .bat_iface_disable = bat_iv_ogm_iface_disable, - .bat_ogm_init_primary = bat_iv_ogm_init_primary, + .bat_primary_iface_set = bat_iv_ogm_primary_iface_set, .bat_ogm_update_mac = bat_iv_ogm_update_mac, .bat_ogm_schedule = bat_iv_ogm_schedule, .bat_ogm_emit = bat_iv_ogm_emit, diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index 3b391fd..75a555b 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -146,7 +146,7 @@ static void primary_if_select(struct bat_priv *bat_priv, if (!new_hard_iface) goto out;
- bat_priv->bat_algo_ops->bat_ogm_init_primary(new_hard_iface); + bat_priv->bat_algo_ops->bat_primary_iface_set(new_hard_iface); primary_if_update_addr(bat_priv, curr_hard_iface);
out: diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index a47a6ce..7913272 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c @@ -210,7 +210,7 @@ int bat_algo_register(struct bat_algo_ops *bat_algo_ops) /* all algorithms must implement all ops (for now) */ if (!bat_algo_ops->bat_iface_enable || !bat_algo_ops->bat_iface_disable || - !bat_algo_ops->bat_ogm_init_primary || + !bat_algo_ops->bat_primary_iface_set || !bat_algo_ops->bat_ogm_update_mac || !bat_algo_ops->bat_ogm_schedule || !bat_algo_ops->bat_ogm_emit || diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index dd78023..4d93aad 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h @@ -381,8 +381,8 @@ struct bat_algo_ops { int (*bat_iface_enable)(struct hard_iface *hard_iface); /* de-init routing info when hard-interface is disabled */ void (*bat_iface_disable)(struct hard_iface *hard_iface); - /* init primary OGM when primary interface is selected */ - void (*bat_ogm_init_primary)(struct hard_iface *hard_iface); + /* called when primary interface is selected / changed */ + void (*bat_primary_iface_set)(struct hard_iface *hard_iface); /* init mac addresses of the OGM belonging to this hard-interface */ void (*bat_ogm_update_mac)(struct hard_iface *hard_iface); /* prepare a new outgoing OGM for the send queue */
From: Marek Lindner lindner_marek@yahoo.de
Using BATMAN_OGM_LEN leaves one with the impression that this is the full packet size which is not the case. Therefore the variable is renamed.
Signed-off-by: Marek Lindner lindner_marek@yahoo.de Signed-off-by: Antonio Quartulli ordex@autistici.org --- net/batman-adv/bat_iv_ogm.c | 12 ++++++------ net/batman-adv/packet.h | 2 +- net/batman-adv/routing.c | 2 +- net/batman-adv/send.c | 12 ++++++------ 4 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 9717c7a..2e2029c 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -40,7 +40,7 @@ static int bat_iv_ogm_iface_enable(struct hard_iface *hard_iface) get_random_bytes(&random_seqno, sizeof(unsigned long)); atomic_set(&hard_iface->seqno, (uint32_t)random_seqno);
- hard_iface->packet_len = BATMAN_OGM_LEN; + hard_iface->packet_len = BATMAN_OGM_HLEN; hard_iface->packet_buff = kmalloc(hard_iface->packet_len, GFP_ATOMIC);
if (!hard_iface->packet_buff) @@ -112,7 +112,7 @@ static uint8_t hop_penalty(uint8_t tq, const struct bat_priv *bat_priv) static int bat_iv_ogm_aggr_packet(int buff_pos, int packet_len, int tt_num_changes) { - int next_buff_pos = buff_pos + BATMAN_OGM_LEN + tt_len(tt_num_changes); + int next_buff_pos = buff_pos + BATMAN_OGM_HLEN + tt_len(tt_num_changes);
return (next_buff_pos <= packet_len) && (next_buff_pos <= MAX_AGGREGATION_BYTES); @@ -162,7 +162,7 @@ static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet, batman_ogm_packet->ttvn, hard_iface->net_dev->name, hard_iface->net_dev->dev_addr);
- buff_pos += BATMAN_OGM_LEN + + buff_pos += BATMAN_OGM_HLEN + tt_len(batman_ogm_packet->tt_num_changes); packet_num++; batman_ogm_packet = (struct batman_ogm_packet *) @@ -540,7 +540,7 @@ static void bat_iv_ogm_forward(struct orig_node *orig_node, batman_ogm_packet->flags &= ~DIRECTLINK;
bat_iv_ogm_queue_add(bat_priv, (unsigned char *)batman_ogm_packet, - BATMAN_OGM_LEN + tt_len(tt_num_changes), + BATMAN_OGM_HLEN + tt_len(tt_num_changes), if_incoming, 0, bat_iv_ogm_fwd_send_time()); }
@@ -1173,12 +1173,12 @@ static void bat_iv_ogm_receive(struct hard_iface *if_incoming, batman_ogm_packet->seqno = ntohl(batman_ogm_packet->seqno); batman_ogm_packet->tt_crc = ntohs(batman_ogm_packet->tt_crc);
- tt_buff = packet_buff + buff_pos + BATMAN_OGM_LEN; + tt_buff = packet_buff + buff_pos + BATMAN_OGM_HLEN;
bat_iv_ogm_process(ethhdr, batman_ogm_packet, tt_buff, if_incoming);
- buff_pos += BATMAN_OGM_LEN + + buff_pos += BATMAN_OGM_HLEN + tt_len(batman_ogm_packet->tt_num_changes);
batman_ogm_packet = (struct batman_ogm_packet *) diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h index 59800e8..59dec0a 100644 --- a/net/batman-adv/packet.h +++ b/net/batman-adv/packet.h @@ -126,7 +126,7 @@ struct batman_ogm_packet { uint16_t tt_crc; } __packed;
-#define BATMAN_OGM_LEN sizeof(struct batman_ogm_packet) +#define BATMAN_OGM_HLEN sizeof(struct batman_ogm_packet)
struct icmp_packet { struct batman_header header; diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index 78eddc9..ac13a6a 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c @@ -254,7 +254,7 @@ int recv_bat_ogm_packet(struct sk_buff *skb, struct hard_iface *hard_iface) struct ethhdr *ethhdr;
/* drop packet if it has not necessary minimum size */ - if (unlikely(!pskb_may_pull(skb, BATMAN_OGM_LEN))) + if (unlikely(!pskb_may_pull(skb, BATMAN_OGM_HLEN))) return NET_RX_DROP;
ethhdr = (struct ethhdr *)skb_mac_header(skb); diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c index af7a674..b5f078c 100644 --- a/net/batman-adv/send.c +++ b/net/batman-adv/send.c @@ -87,7 +87,7 @@ static void realloc_packet_buffer(struct hard_iface *hard_iface, /* keep old buffer if kmalloc should fail */ if (new_buff) { memcpy(new_buff, hard_iface->packet_buff, - BATMAN_OGM_LEN); + BATMAN_OGM_HLEN);
kfree(hard_iface->packet_buff); hard_iface->packet_buff = new_buff; @@ -101,13 +101,13 @@ static int prepare_packet_buffer(struct bat_priv *bat_priv, { int new_len;
- new_len = BATMAN_OGM_LEN + + new_len = BATMAN_OGM_HLEN + tt_len((uint8_t)atomic_read(&bat_priv->tt_local_changes));
/* if we have too many changes for one packet don't send any * and wait for the tt table request which will be fragmented */ if (new_len > hard_iface->soft_iface->mtu) - new_len = BATMAN_OGM_LEN; + new_len = BATMAN_OGM_HLEN;
realloc_packet_buffer(hard_iface, new_len);
@@ -117,14 +117,14 @@ static int prepare_packet_buffer(struct bat_priv *bat_priv, atomic_set(&bat_priv->tt_ogm_append_cnt, TT_OGM_APPEND_MAX);
return tt_changes_fill_buffer(bat_priv, - hard_iface->packet_buff + BATMAN_OGM_LEN, - hard_iface->packet_len - BATMAN_OGM_LEN); + hard_iface->packet_buff + BATMAN_OGM_HLEN, + hard_iface->packet_len - BATMAN_OGM_HLEN); }
static int reset_packet_buffer(struct bat_priv *bat_priv, struct hard_iface *hard_iface) { - realloc_packet_buffer(hard_iface, BATMAN_OGM_LEN); + realloc_packet_buffer(hard_iface, BATMAN_OGM_HLEN); return 0; }
From: Marek Lindner lindner_marek@yahoo.de
The coming protocol changes also will have a part called "OGM". That makes it necessary to introduce a distinction in the code base.
Signed-off-by: Marek Lindner lindner_marek@yahoo.de Signed-off-by: Antonio Quartulli ordex@autistici.org --- net/batman-adv/bat_iv_ogm.c | 4 ++-- net/batman-adv/hard-interface.c | 2 +- net/batman-adv/packet.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 2e2029c..1d365e2 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -47,7 +47,7 @@ static int bat_iv_ogm_iface_enable(struct hard_iface *hard_iface) goto out;
batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff; - batman_ogm_packet->header.packet_type = BAT_OGM; + batman_ogm_packet->header.packet_type = BAT_IV_OGM; batman_ogm_packet->header.version = COMPAT_VERSION; batman_ogm_packet->header.ttl = 2; batman_ogm_packet->flags = NO_FLAGS; @@ -934,7 +934,7 @@ static void bat_iv_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->header.packet_type != BAT_OGM) + if (batman_ogm_packet->header.packet_type != BAT_IV_OGM) return;
/* could be changed by schedule_own_packet() */ diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index 75a555b..e8c5da3 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -604,7 +604,7 @@ static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
switch (batman_ogm_packet->header.packet_type) { /* batman originator packet */ - case BAT_OGM: + case BAT_IV_OGM: ret = recv_bat_ogm_packet(skb, hard_iface); break;
diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h index 59dec0a..f54969c 100644 --- a/net/batman-adv/packet.h +++ b/net/batman-adv/packet.h @@ -25,7 +25,7 @@ #define ETH_P_BATMAN 0x4305 /* unofficial/not registered Ethertype */
enum bat_packettype { - BAT_OGM = 0x01, + BAT_IV_OGM = 0x01, BAT_ICMP = 0x02, BAT_UNICAST = 0x03, BAT_BCAST = 0x04, @@ -38,7 +38,7 @@ enum bat_packettype { /* this file is included by batctl which needs these defines */ #define COMPAT_VERSION 14
-enum batman_flags { +enum batman_iv_flags { PRIMARIES_FIRST_HOP = 1 << 4, VIS_SERVER = 1 << 5, DIRECTLINK = 1 << 6
Instead of using sizeof(struct ethhdr) it is strongly recommended to use the kernel macro ETH_HLEN. This patch substitute each occurrence of the former expressione with the latter one.
Signed-off-by: Antonio Quartulli ordex@autistici.org --- net/batman-adv/bat_iv_ogm.c | 7 +++---- net/batman-adv/bridge_loop_avoidance.c | 10 ++++------ net/batman-adv/hard-interface.c | 3 +-- net/batman-adv/icmp_socket.c | 4 ++-- net/batman-adv/routing.c | 8 ++++---- net/batman-adv/send.c | 2 +- net/batman-adv/soft-interface.c | 2 +- net/batman-adv/types.h | 2 +- net/batman-adv/vis.c | 8 ++++---- 9 files changed, 21 insertions(+), 25 deletions(-)
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 1d365e2..5bb35df 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -355,10 +355,9 @@ static void bat_iv_ogm_aggregate_new(const unsigned char *packet_buff, if ((atomic_read(&bat_priv->aggregated_ogms)) && (packet_len < MAX_AGGREGATION_BYTES)) forw_packet_aggr->skb = dev_alloc_skb(MAX_AGGREGATION_BYTES + - sizeof(struct ethhdr)); + ETH_HLEN); else - forw_packet_aggr->skb = dev_alloc_skb(packet_len + - sizeof(struct ethhdr)); + forw_packet_aggr->skb = dev_alloc_skb(packet_len + ETH_HLEN);
if (!forw_packet_aggr->skb) { if (!own_packet) @@ -366,7 +365,7 @@ static void bat_iv_ogm_aggregate_new(const unsigned char *packet_buff, kfree(forw_packet_aggr); goto out; } - skb_reserve(forw_packet_aggr->skb, sizeof(struct ethhdr)); + skb_reserve(forw_packet_aggr->skb, ETH_HLEN);
INIT_HLIST_NODE(&forw_packet_aggr->list);
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c index 1cf18ac..6f188f1 100644 --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c @@ -290,9 +290,7 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac, goto out;
ethhdr = (struct ethhdr *)skb->data; - hw_src = (uint8_t *)ethhdr + - sizeof(struct ethhdr) + - sizeof(struct arphdr); + hw_src = (uint8_t *)ethhdr + ETH_HLEN + sizeof(struct arphdr);
/* now we pretend that the client would have sent this ... */ switch (claimtype) { @@ -340,7 +338,7 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac, skb_reset_mac_header(skb); skb->protocol = eth_type_trans(skb, soft_iface); bat_priv->stats.rx_packets++; - bat_priv->stats.rx_bytes += skb->len + sizeof(struct ethhdr); + bat_priv->stats.rx_bytes += skb->len + ETH_HLEN; soft_iface->last_rx = jiffies;
netif_rx(skb); @@ -845,7 +843,7 @@ static int bla_process_claim(struct bat_priv *bat_priv, headlen = sizeof(*vhdr); } else { proto = ntohs(ethhdr->h_proto); - headlen = sizeof(*ethhdr); + headlen = ETH_HLEN; }
if (proto != ETH_P_ARP) @@ -1303,7 +1301,7 @@ int bla_is_backbone_gw(struct sk_buff *skb, return 0;
/* first, find out the vid. */ - if (!pskb_may_pull(skb, hdr_size + sizeof(struct ethhdr))) + if (!pskb_may_pull(skb, hdr_size + ETH_HLEN)) return 0;
ethhdr = (struct ethhdr *)(((uint8_t *)skb->data) + hdr_size); diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index e8c5da3..47c79d7 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -574,8 +574,7 @@ static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, goto err_free;
/* expect a valid ethernet header here. */ - if (unlikely(skb->mac_len != sizeof(struct ethhdr) || - !skb_mac_header(skb))) + if (unlikely(skb->mac_len != ETH_HLEN || !skb_mac_header(skb))) goto err_free;
if (!hard_iface->soft_iface) diff --git a/net/batman-adv/icmp_socket.c b/net/batman-adv/icmp_socket.c index b87518e..2e98a57 100644 --- a/net/batman-adv/icmp_socket.c +++ b/net/batman-adv/icmp_socket.c @@ -175,13 +175,13 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff, if (len >= sizeof(struct icmp_packet_rr)) packet_len = sizeof(struct icmp_packet_rr);
- skb = dev_alloc_skb(packet_len + sizeof(struct ethhdr)); + skb = dev_alloc_skb(packet_len + ETH_HLEN); if (!skb) { len = -ENOMEM; goto out; }
- skb_reserve(skb, sizeof(struct ethhdr)); + skb_reserve(skb, ETH_HLEN); icmp_packet = (struct icmp_packet_rr *)skb_put(skb, packet_len);
if (copy_from_user(icmp_packet, buff, packet_len)) { diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index ac13a6a..ff56086 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c @@ -313,7 +313,7 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv, goto out;
/* create a copy of the skb, if needed, to modify it. */ - if (skb_cow(skb, sizeof(struct ethhdr)) < 0) + if (skb_cow(skb, ETH_HLEN) < 0) goto out;
icmp_packet = (struct icmp_packet_rr *)skb->data; @@ -368,7 +368,7 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv, goto out;
/* create a copy of the skb, if needed, to modify it. */ - if (skb_cow(skb, sizeof(struct ethhdr)) < 0) + if (skb_cow(skb, ETH_HLEN) < 0) goto out;
icmp_packet = (struct icmp_packet *)skb->data; @@ -454,7 +454,7 @@ int recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if) goto out;
/* create a copy of the skb, if needed, to modify it. */ - if (skb_cow(skb, sizeof(struct ethhdr)) < 0) + if (skb_cow(skb, ETH_HLEN) < 0) goto out;
icmp_packet = (struct icmp_packet_rr *)skb->data; @@ -841,7 +841,7 @@ static int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if) goto out;
/* create a copy of the skb, if needed, to modify it. */ - if (skb_cow(skb, sizeof(struct ethhdr)) < 0) + if (skb_cow(skb, ETH_HLEN) < 0) goto out;
unicast_packet = (struct unicast_packet *)skb->data; diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c index b5f078c..7c66b61 100644 --- a/net/batman-adv/send.c +++ b/net/batman-adv/send.c @@ -51,7 +51,7 @@ int send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface, }
/* push to the ethernet header. */ - if (my_skb_head_push(skb, sizeof(*ethhdr)) < 0) + if (my_skb_head_push(skb, ETH_HLEN) < 0) goto send_skb_err;
skb_reset_mac_header(skb); diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index efe0fba..6e2530b 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c @@ -292,7 +292,7 @@ void interface_rx(struct net_device *soft_iface, /* skb->ip_summed = CHECKSUM_UNNECESSARY;*/
bat_priv->stats.rx_packets++; - bat_priv->stats.rx_bytes += skb->len + sizeof(struct ethhdr); + bat_priv->stats.rx_bytes += skb->len + ETH_HLEN;
soft_iface->last_rx = jiffies;
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index 4d93aad..2f4848b 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h @@ -27,7 +27,7 @@ #include "packet.h" #include "bitarray.h"
-#define BAT_HEADER_LEN (sizeof(struct ethhdr) + \ +#define BAT_HEADER_LEN (ETH_HLEN + \ ((sizeof(struct unicast_packet) > sizeof(struct bcast_packet) ? \ sizeof(struct unicast_packet) : \ sizeof(struct bcast_packet)))) diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c index c4a5b8c..cec216f 100644 --- a/net/batman-adv/vis.c +++ b/net/batman-adv/vis.c @@ -434,12 +434,12 @@ static struct vis_info *add_packet(struct bat_priv *bat_priv, return NULL;
info->skb_packet = dev_alloc_skb(sizeof(*packet) + vis_info_len + - sizeof(struct ethhdr)); + ETH_HLEN); if (!info->skb_packet) { kfree(info); return NULL; } - skb_reserve(info->skb_packet, sizeof(struct ethhdr)); + skb_reserve(info->skb_packet, ETH_HLEN); packet = (struct vis_packet *)skb_put(info->skb_packet, sizeof(*packet) + vis_info_len);
@@ -894,11 +894,11 @@ int vis_init(struct bat_priv *bat_priv)
bat_priv->my_vis_info->skb_packet = dev_alloc_skb(sizeof(*packet) + MAX_VIS_PACKET_SIZE + - sizeof(struct ethhdr)); + ETH_HLEN); if (!bat_priv->my_vis_info->skb_packet) goto free_info;
- skb_reserve(bat_priv->my_vis_info->skb_packet, sizeof(struct ethhdr)); + skb_reserve(bat_priv->my_vis_info->skb_packet, ETH_HLEN); packet = (struct vis_packet *)skb_put(bat_priv->my_vis_info->skb_packet, sizeof(*packet));
OGM sequence numbers are declared as uint32_t and so they have to printed using %u instead of %d in order to avoid wrong representations.
Signed-off-by: Antonio Quartulli ordex@autistici.org --- net/batman-adv/bat_iv_ogm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 5bb35df..f36b54c 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -152,7 +152,7 @@ static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet, "Sending own" : "Forwarding")); bat_dbg(DBG_BATMAN, bat_priv, - "%s %spacket (originator %pM, seqno %d, TQ %d, TTL %d, IDF %s, ttvn %d) on interface %s [%pM]\n", + "%s %spacket (originator %pM, seqno %u, TQ %d, TTL %d, IDF %s, ttvn %d) on interface %s [%pM]\n", fwd_str, (packet_num > 0 ? "aggregated " : ""), batman_ogm_packet->orig, ntohl(batman_ogm_packet->seqno), @@ -211,7 +211,7 @@ static void bat_iv_ogm_emit(struct forw_packet *forw_packet)
/* FIXME: what about aggregated packets ? */ bat_dbg(DBG_BATMAN, bat_priv, - "%s packet (originator %pM, seqno %d, TTL %d) on interface %s [%pM]\n", + "%s packet (originator %pM, seqno %u, TTL %d) on interface %s [%pM]\n", (forw_packet->own ? "Sending own" : "Forwarding"), batman_ogm_packet->orig, ntohl(batman_ogm_packet->seqno), @@ -892,7 +892,7 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
if (need_update) { bat_dbg(DBG_BATMAN, bat_priv, - "updating last_seqno: old %d, new %d\n", + "updating last_seqno: old %u, new %u\n", orig_node->last_real_seqno, batman_ogm_packet->seqno); orig_node->last_real_seqno = batman_ogm_packet->seqno; } @@ -945,7 +945,7 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, batman_ogm_packet->orig) ? 1 : 0);
bat_dbg(DBG_BATMAN, bat_priv, - "Received BATMAN packet via NB: %pM, IF: %s [%pM] (from OG: %pM, via prev OG: %pM, seqno %d, ttvn %u, crc %u, changes %u, td %d, TTL %d, V %d, IDF %d)\n", + "Received BATMAN packet via NB: %pM, IF: %s [%pM] (from OG: %pM, via prev OG: %pM, seqno %u, ttvn %u, crc %u, changes %u, td %d, TTL %d, V %d, IDF %d)\n", ethhdr->h_source, if_incoming->net_dev->name, if_incoming->net_dev->dev_addr, batman_ogm_packet->orig, batman_ogm_packet->prev_sender, batman_ogm_packet->seqno,
From: Antonio Quartulli ordex@autistici.org Date: Tue, 17 Apr 2012 13:58:26 +0200
OGM sequence numbers are declared as uint32_t and so they have to printed using %u instead of %d in order to avoid wrong representations.
Signed-off-by: Antonio Quartulli ordex@autistici.org
Fix this commit message subject, "%u" is "unsigned int" not "unsigned long"
"unsigned long" would be "%lu"
On Tue, Apr 17, 2012 at 10:47:46 -0400, David Miller wrote:
From: Antonio Quartulli ordex@autistici.org Date: Tue, 17 Apr 2012 13:58:26 +0200
OGM sequence numbers are declared as uint32_t and so they have to printed using %u instead of %d in order to avoid wrong representations.
Signed-off-by: Antonio Quartulli ordex@autistici.org
Fix this commit message subject, "%u" is "unsigned int" not "unsigned long"
"unsigned long" would be "%lu"
Yap. The broken part is %u, because the data type we are going to print is uint32_t. I'll fix it.
Thank you.
I'll send a new pull request once I'll have fixed these errors.
Cheers,
On Wed, Apr 18, 2012 at 08:47:00AM +0200, Antonio Quartulli wrote:
On Tue, Apr 17, 2012 at 10:47:46 -0400, David Miller wrote:
From: Antonio Quartulli ordex@autistici.org Date: Tue, 17 Apr 2012 13:58:26 +0200
OGM sequence numbers are declared as uint32_t and so they have to printed using %u instead of %d in order to avoid wrong representations.
Signed-off-by: Antonio Quartulli ordex@autistici.org
Fix this commit message subject, "%u" is "unsigned int" not "unsigned long"
"unsigned long" would be "%lu"
There is a problem here. On my machine (x86_64) I have:
typedef unsigned int __u32; typedef __u32 uint32_t;
So I should use %u to print my uint32_t variable (as I reported in my commit message).
Probably this is not the case on each and every architecture? If so, how could I handle it?
Cheers,
On Wed, Apr 18, 2012 at 09:01:35AM +0200, Antonio Quartulli wrote:
On Wed, Apr 18, 2012 at 08:47:00AM +0200, Antonio Quartulli wrote:
On Tue, Apr 17, 2012 at 10:47:46 -0400, David Miller wrote:
From: Antonio Quartulli ordex@autistici.org Date: Tue, 17 Apr 2012 13:58:26 +0200
OGM sequence numbers are declared as uint32_t and so they have to printed using %u instead of %d in order to avoid wrong representations.
Signed-off-by: Antonio Quartulli ordex@autistici.org
Fix this commit message subject, "%u" is "unsigned int" not "unsigned long"
"unsigned long" would be "%lu"
There is a problem here. On my machine (x86_64) I have:
typedef unsigned int __u32; typedef __u32 uint32_t;
So I should use %u to print my uint32_t variable (as I reported in my commit message).
Probably this is not the case on each and every architecture? If so, how could I handle it?
Ok. After digging in the code again I understood that the problem is either in my brain and in the commit subject.
I'll fix both.
Cheers,
From: Antonio Quartulli ordex@autistici.org Date: Wed, 18 Apr 2012 09:01:35 +0200
On Wed, Apr 18, 2012 at 08:47:00AM +0200, Antonio Quartulli wrote:
On Tue, Apr 17, 2012 at 10:47:46 -0400, David Miller wrote:
From: Antonio Quartulli ordex@autistici.org Date: Tue, 17 Apr 2012 13:58:26 +0200
OGM sequence numbers are declared as uint32_t and so they have to printed using %u instead of %d in order to avoid wrong representations.
Signed-off-by: Antonio Quartulli ordex@autistici.org
Fix this commit message subject, "%u" is "unsigned int" not "unsigned long"
"unsigned long" would be "%lu"
There is a problem here. On my machine (x86_64) I have:
typedef unsigned int __u32; typedef __u32 uint32_t;
So I should use %u to print my uint32_t variable (as I reported in my commit message).
Probably this is not the case on each and every architecture? If so, how could I handle it?
The problem is not the patch, it's your commit message you say "print ... as unsigned long", you're not printing it as unsigned long, you're printing it as unsigned int.
When we receive an OGM from from a node for the first time, the last_real_seqno field of the orig_node structure has not been initialised yet. The value of this field is used to compute the current ogm-seqno window and therefore the protection mechanism will probably drop the packet due to an out-of-window error. To avoid this situation this patch adds a check to skip the window protection mechanism if no neighbour nodes have already been added. When the first neighbour node is added, the last_real_seqno field is initialised too.
Reported-by: Marek Lindner lindner_marek@yahoo.de Signed-off-by: Antonio Quartulli ordex@autistici.org --- net/batman-adv/bat_iv_ogm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index f36b54c..873ea40 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -861,7 +861,8 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr, seq_diff = batman_ogm_packet->seqno - orig_node->last_real_seqno;
/* signalize caller that the packet is to be dropped. */ - if (window_protected(bat_priv, seq_diff, + if (!hlist_empty(&orig_node->neigh_list) && + window_protected(bat_priv, seq_diff, &orig_node->batman_seqno_reset)) goto out;
b.a.t.m.a.n@lists.open-mesh.org