Hi folks,
after having the B.A.T.M.A.N. IV routing code moved into one single file, a preliminary routing protocol API and an easy to use routing protocol switch it is time to move forward with B.A.T.M.A.N. V.
B.A.T.M.A.N. V is going to split the various tasks handled by the B.A.T.M.A.N. IV OGM protocol into subprotocols which will allow us to optimize each protocol much better. The ELP protocol is the first of these subprotocols to come. The initial ideas surrounding this protocol type are more than 2-3 years old. At some point Linus was the driving force behind the protocol development. Thanks to him we have proper documentation[1] as well as some code in his repository[2] (still called ndp). I began rebasing and integrating his code [3]. It will take a couple of patch series to get the API and the old ELP code base into shape.
Cheers, Marek
[1] http://www.open-mesh.org/wiki/batman-adv/ELP [2] http://git.open-mesh.org/?p=t_x/batman-adv.git;a=summary [3] http://git.open-mesh.org/?p=marek/batman-adv.git;a=summary
Signed-of-by: Marek Lindner lindner_marek@yahoo.de --- hard-interface.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/hard-interface.c b/hard-interface.c index 612f2c8..e16c996 100644 --- a/hard-interface.c +++ b/hard-interface.c @@ -337,7 +337,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); @@ -463,6 +462,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:
On Tuesday, February 07, 2012 17:19:58 Marek Lindner wrote:
Signed-of-by: Marek Lindner lindner_marek@yahoo.de
hard-interface.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)
Applied in revision 5ab6f11.
Regards, Marek
Signed-off-by: Marek Lindner lindner_marek@yahoo.de --- bat_iv_ogm.c | 4 ++-- hard-interface.c | 2 +- main.c | 2 +- types.h | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c index bbab00b..3eff7f0 100644 --- a/bat_iv_ogm.c +++ b/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;
@@ -1180,7 +1180,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/hard-interface.c b/hard-interface.c index e16c996..4052444 100644 --- a/hard-interface.c +++ b/hard-interface.c @@ -318,7 +318,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, "Can't add interface packet " diff --git a/main.c b/main.c index 7750bca..8bc27e1 100644 --- a/main.c +++ b/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/types.h b/types.h index 7f7f610..c78b925 100644 --- a/types.h +++ b/types.h @@ -369,8 +369,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 */
Signed-off-by: Marek Lindner lindner_marek@yahoo.de --- bat_iv_ogm.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c index 3eff7f0..4ac2d1d 100644 --- a/bat_iv_ogm.c +++ b/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);
On 2012-02-07 10:20, Marek Lindner wrote:
Signed-off-by: Marek Lindnerlindner_marek@yahoo.de
bat_iv_ogm.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c index 3eff7f0..4ac2d1d 100644 --- a/bat_iv_ogm.c +++ b/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);
Wouldn't it be better to cast "unsigned long" in the call to atomic_set()?
On Tuesday, February 07, 2012 17:33:14 Martin Hundebøll wrote:
On 2012-02-07 10:20, Marek Lindner wrote:
Signed-off-by: Marek Lindnerlindner_marek@yahoo.de
bat_iv_ogm.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c index 3eff7f0..4ac2d1d 100644 --- a/bat_iv_ogm.c +++ b/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);
Wouldn't it be better to cast "unsigned long" in the call to atomic_set()?
Why should it better ?
Regards, Marek
On 2012-02-07 12:10, Marek Lindner wrote:
- 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);
Wouldn't it be better to cast "unsigned long" in the call to atomic_set()?
Why should it better ?
Maybe not better, but at least it is consistent with the type of random_seqno, which is unsigned long. I know the two types are identical, but nevertheless, I like to use the same type of type :)
On Tuesday, February 07, 2012 19:13:27 Martin Hundebøll wrote:
On 2012-02-07 12:10, Marek Lindner wrote:
- 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);
Wouldn't it be better to cast "unsigned long" in the call to atomic_set()?
Why should it better ?
Maybe not better, but at least it is consistent with the type of random_seqno, which is unsigned long. I know the two types are identical, but nevertheless, I like to use the same type of type :)
You lost me somewhere. Yes, random_seqno is unsigned long. If we wanted to store unsigned long we would not need a cast. However, in my kernel the second argument for atomic_set() is "int" and not "unsigned long" which why we have a cast there.
Regards, Marek
On Tue, Feb 07, 2012 at 05:20:46PM +0800, Marek Lindner wrote:
Signed-off-by: Marek Lindner lindner_marek@yahoo.de
bat_iv_ogm.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c index 3eff7f0..4ac2d1d 100644 --- a/bat_iv_ogm.c +++ b/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);
Hi Marek
Does this sequence number have any security relevance? Does it make sense to use the TCP sequence number generation code?
Andrew
On Tuesday, February 07, 2012 20:12:00 Andrew Lunn wrote:
Does this sequence number have any security relevance? Does it make sense to use the TCP sequence number generation code?
There is no security relevance I know of. The idea was simply to start with random number. Random is a bit better than 1. ;-)
Where can I find the TCP sequence number code you are referring to ?
Regards, Marek
On Tue, Feb 07, 2012 at 08:21:55PM +0800, Marek Lindner wrote:
On Tuesday, February 07, 2012 20:12:00 Andrew Lunn wrote:
Does this sequence number have any security relevance? Does it make sense to use the TCP sequence number generation code?
There is no security relevance I know of. The idea was simply to start with random number. Random is a bit better than 1. ;-)
Where can I find the TCP sequence number code you are referring to ?
I had to go find it, since i've never looked at it before.
net/core/secure_seq.c:
__u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr, __be16 sport, __be16 dport)
but it does not look very re-usable, since it takes all these addresses. What might be usable is:
__u32 secure_ip_id(__be32 daddr) { u32 hash[MD5_DIGEST_WORDS];
hash[0] = (__force __u32) daddr; hash[1] = net_secret[13]; hash[2] = net_secret[14]; hash[3] = net_secret[15];
md5_transform(hash, net_secret);
return hash[0]; }
passing it the last four bytes of the originator MAC address?
Andrew
On Tuesday, February 07, 2012 17:20:46 Marek Lindner wrote:
Signed-off-by: Marek Lindner lindner_marek@yahoo.de
bat_iv_ogm.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
Applied in revision 852b9dc.
Regards, Marek
Signed-off-by: Marek Lindner lindner_marek@yahoo.de --- bat_iv_ogm.c | 7 +++++++ hard-interface.c | 3 +-- main.c | 1 + types.h | 2 ++ 4 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c index 4ac2d1d..98c41f5 100644 --- a/bat_iv_ogm.c +++ b/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; @@ -1186,6 +1192,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/hard-interface.c b/hard-interface.c index 4052444..ec2f478 100644 --- a/hard-interface.c +++ b/hard-interface.c @@ -409,8 +409,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/main.c b/main.c index 8bc27e1..c4a9b2b 100644 --- a/main.c +++ b/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/types.h b/types.h index c78b925..5e8de0e 100644 --- a/types.h +++ b/types.h @@ -371,6 +371,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 */
On Tuesday, February 07, 2012 17:20:47 Marek Lindner wrote:
Signed-off-by: Marek Lindner lindner_marek@yahoo.de
bat_iv_ogm.c | 7 +++++++ hard-interface.c | 3 +-- main.c | 1 + types.h | 2 ++ 4 files changed, 11 insertions(+), 2 deletions(-)
Applied in revision 4348aad.
Regards, Marek
Signed-off-by: Marek Lindner lindner_marek@yahoo.de --- bat_iv_ogm.c | 11 ++++++++++- hard-interface.c | 14 ++++++-------- types.h | 2 +- 3 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c index 98c41f5..d944a0b 100644 --- a/bat_iv_ogm.c +++ b/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/hard-interface.c b/hard-interface.c index ec2f478..d6b25e0 100644 --- a/hard-interface.c +++ b/hard-interface.c @@ -310,21 +310,17 @@ int hardif_enable_interface(struct hard_iface *hard_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; @@ -375,6 +371,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/types.h b/types.h index 5e8de0e..3df38df 100644 --- a/types.h +++ b/types.h @@ -370,7 +370,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 */
On Tuesday, February 07, 2012 17:20:48 Marek Lindner wrote:
Signed-off-by: Marek Lindner lindner_marek@yahoo.de
bat_iv_ogm.c | 11 ++++++++++- hard-interface.c | 14 ++++++-------- types.h | 2 +- 3 files changed, 17 insertions(+), 10 deletions(-)
Applied in revision 13cbee1.
Regards, Marek
Signed-off-by: Marek Lindner lindner_marek@yahoo.de --- bat_iv_ogm.c | 4 ++-- hard-interface.c | 2 +- main.c | 2 +- types.h | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c index d944a0b..b82a772 100644 --- a/bat_iv_ogm.c +++ b/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;
@@ -1202,7 +1202,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/hard-interface.c b/hard-interface.c index d6b25e0..2a435ec 100644 --- a/hard-interface.c +++ b/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/main.c b/main.c index c4a9b2b..87b75a9 100644 --- a/main.c +++ b/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/types.h b/types.h index 3df38df..e3d2f1f 100644 --- a/types.h +++ b/types.h @@ -373,8 +373,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 */
On Tuesday, February 07, 2012 17:20:49 Marek Lindner wrote:
Signed-off-by: Marek Lindner lindner_marek@yahoo.de
bat_iv_ogm.c | 4 ++-- hard-interface.c | 2 +- main.c | 2 +- types.h | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-)
Applied in revision 0b751f1.
Regards, Marek
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 --- bat_iv_ogm.c | 12 ++++++------ packet.h | 2 +- routing.c | 2 +- send.c | 12 ++++++------ 4 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c index b82a772..da93525 100644 --- a/bat_iv_ogm.c +++ b/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); @@ -163,7 +163,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 *) @@ -544,7 +544,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()); }
@@ -1184,12 +1184,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/packet.h b/packet.h index caa12fe..ed16ec3 100644 --- a/packet.h +++ b/packet.h @@ -125,7 +125,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/routing.c b/routing.c index 7b7fcbe..92fe20b 100644 --- a/routing.c +++ b/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/send.c b/send.c index 4137580..36e1d27 100644 --- a/send.c +++ b/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; }
On Tuesday, February 07, 2012 17:20:50 Marek Lindner wrote:
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.
Applied in revision 76cdf0e.
Regards, Marek
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 --- bat_iv_ogm.c | 4 ++-- hard-interface.c | 2 +- packet.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c index da93525..caa67e4 100644 --- a/bat_iv_ogm.c +++ b/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; @@ -942,7 +942,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/hard-interface.c b/hard-interface.c index 2a435ec..30b1c07 100644 --- a/hard-interface.c +++ b/hard-interface.c @@ -617,7 +617,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/packet.h b/packet.h index ed16ec3..7971a69 100644 --- a/packet.h +++ b/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
On Tuesday, February 07, 2012 17:20:51 Marek Lindner wrote:
The coming protocol changes also will have a part called "OGM". That makes it necessary to introduce a distinction in the code base.
Applied in revision fc320c7.
Regards, Marek
On Tuesday, February 07, 2012 17:20:45 Marek Lindner wrote:
Signed-off-by: Marek Lindner lindner_marek@yahoo.de
bat_iv_ogm.c | 4 ++-- hard-interface.c | 2 +- main.c | 2 +- types.h | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-)
Applied in revision 7deba89.
Regards, Marek
b.a.t.m.a.n@lists.open-mesh.org