Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
01c4224b
Commit
01c4224b
authored
Nov 28, 2011
by
Marek Lindner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
batman-adv: convert batman iv algorithm to use dynamic infrastructure
Signed-off-by:
Marek Lindner
<
lindner_marek@yahoo.de
>
parent
1c280471
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
129 additions
and
129 deletions
+129
-129
net/batman-adv/bat_iv_ogm.c
net/batman-adv/bat_iv_ogm.c
+94
-85
net/batman-adv/bat_ogm.h
net/batman-adv/bat_ogm.h
+0
-34
net/batman-adv/hard-interface.c
net/batman-adv/hard-interface.c
+5
-5
net/batman-adv/main.c
net/batman-adv/main.c
+12
-0
net/batman-adv/routing.c
net/batman-adv/routing.c
+2
-2
net/batman-adv/send.c
net/batman-adv/send.c
+2
-3
net/batman-adv/types.h
net/batman-adv/types.h
+14
-0
No files found.
net/batman-adv/bat_iv_ogm.c
View file @
01c4224b
...
@@ -20,7 +20,6 @@
...
@@ -20,7 +20,6 @@
*/
*/
#include "main.h"
#include "main.h"
#include "bat_ogm.h"
#include "translation-table.h"
#include "translation-table.h"
#include "ring_buffer.h"
#include "ring_buffer.h"
#include "originator.h"
#include "originator.h"
...
@@ -31,7 +30,7 @@
...
@@ -31,7 +30,7 @@
#include "send.h"
#include "send.h"
#include "bat_algo.h"
#include "bat_algo.h"
void
bat
_ogm_init
(
struct
hard_iface
*
hard_iface
)
static
void
bat_iv
_ogm_init
(
struct
hard_iface
*
hard_iface
)
{
{
struct
batman_ogm_packet
*
batman_ogm_packet
;
struct
batman_ogm_packet
*
batman_ogm_packet
;
...
@@ -48,7 +47,7 @@ void bat_ogm_init(struct hard_iface *hard_iface)
...
@@ -48,7 +47,7 @@ void bat_ogm_init(struct hard_iface *hard_iface)
batman_ogm_packet
->
ttvn
=
0
;
batman_ogm_packet
->
ttvn
=
0
;
}
}
void
bat
_ogm_init_primary
(
struct
hard_iface
*
hard_iface
)
static
void
bat_iv
_ogm_init_primary
(
struct
hard_iface
*
hard_iface
)
{
{
struct
batman_ogm_packet
*
batman_ogm_packet
;
struct
batman_ogm_packet
*
batman_ogm_packet
;
...
@@ -57,7 +56,7 @@ void bat_ogm_init_primary(struct hard_iface *hard_iface)
...
@@ -57,7 +56,7 @@ void bat_ogm_init_primary(struct hard_iface *hard_iface)
batman_ogm_packet
->
header
.
ttl
=
TTL
;
batman_ogm_packet
->
header
.
ttl
=
TTL
;
}
}
void
bat
_ogm_update_mac
(
struct
hard_iface
*
hard_iface
)
static
void
bat_iv
_ogm_update_mac
(
struct
hard_iface
*
hard_iface
)
{
{
struct
batman_ogm_packet
*
batman_ogm_packet
;
struct
batman_ogm_packet
*
batman_ogm_packet
;
...
@@ -69,7 +68,7 @@ void bat_ogm_update_mac(struct hard_iface *hard_iface)
...
@@ -69,7 +68,7 @@ void bat_ogm_update_mac(struct hard_iface *hard_iface)
}
}
/* when do we schedule our own ogm to be sent */
/* when do we schedule our own ogm to be sent */
static
unsigned
long
bat_ogm_emit_send_time
(
const
struct
bat_priv
*
bat_priv
)
static
unsigned
long
bat_
iv_
ogm_emit_send_time
(
const
struct
bat_priv
*
bat_priv
)
{
{
return
jiffies
+
msecs_to_jiffies
(
return
jiffies
+
msecs_to_jiffies
(
atomic_read
(
&
bat_priv
->
orig_interval
)
-
atomic_read
(
&
bat_priv
->
orig_interval
)
-
...
@@ -77,7 +76,7 @@ static unsigned long bat_ogm_emit_send_time(const struct bat_priv *bat_priv)
...
@@ -77,7 +76,7 @@ static unsigned long bat_ogm_emit_send_time(const struct bat_priv *bat_priv)
}
}
/* when do we schedule a ogm packet to be sent */
/* when do we schedule a ogm packet to be sent */
static
unsigned
long
bat_ogm_fwd_send_time
(
void
)
static
unsigned
long
bat_
iv_
ogm_fwd_send_time
(
void
)
{
{
return
jiffies
+
msecs_to_jiffies
(
random32
()
%
(
JITTER
/
2
));
return
jiffies
+
msecs_to_jiffies
(
random32
()
%
(
JITTER
/
2
));
}
}
...
@@ -90,7 +89,7 @@ static uint8_t hop_penalty(uint8_t tq, const struct bat_priv *bat_priv)
...
@@ -90,7 +89,7 @@ static uint8_t hop_penalty(uint8_t tq, const struct bat_priv *bat_priv)
}
}
/* is there another aggregated packet here? */
/* is there another aggregated packet here? */
static
int
bat_ogm_aggr_packet
(
int
buff_pos
,
int
packet_len
,
static
int
bat_
iv_
ogm_aggr_packet
(
int
buff_pos
,
int
packet_len
,
int
tt_num_changes
)
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_LEN
+
tt_len
(
tt_num_changes
);
...
@@ -100,7 +99,7 @@ static int bat_ogm_aggr_packet(int buff_pos, int packet_len,
...
@@ -100,7 +99,7 @@ static int bat_ogm_aggr_packet(int buff_pos, int packet_len,
}
}
/* send a batman ogm to a given interface */
/* send a batman ogm to a given interface */
static
void
bat_ogm_send_to_if
(
struct
forw_packet
*
forw_packet
,
static
void
bat_
iv_
ogm_send_to_if
(
struct
forw_packet
*
forw_packet
,
struct
hard_iface
*
hard_iface
)
struct
hard_iface
*
hard_iface
)
{
{
struct
bat_priv
*
bat_priv
=
netdev_priv
(
hard_iface
->
soft_iface
);
struct
bat_priv
*
bat_priv
=
netdev_priv
(
hard_iface
->
soft_iface
);
...
@@ -118,7 +117,7 @@ static void bat_ogm_send_to_if(struct forw_packet *forw_packet,
...
@@ -118,7 +117,7 @@ static void bat_ogm_send_to_if(struct forw_packet *forw_packet,
batman_ogm_packet
=
(
struct
batman_ogm_packet
*
)
forw_packet
->
skb
->
data
;
batman_ogm_packet
=
(
struct
batman_ogm_packet
*
)
forw_packet
->
skb
->
data
;
/* adjust all flags and log packets */
/* adjust all flags and log packets */
while
(
bat_ogm_aggr_packet
(
buff_pos
,
forw_packet
->
packet_len
,
while
(
bat_
iv_
ogm_aggr_packet
(
buff_pos
,
forw_packet
->
packet_len
,
batman_ogm_packet
->
tt_num_changes
))
{
batman_ogm_packet
->
tt_num_changes
))
{
/* we might have aggregated direct link packets with an
/* we might have aggregated direct link packets with an
...
@@ -158,7 +157,7 @@ static void bat_ogm_send_to_if(struct forw_packet *forw_packet,
...
@@ -158,7 +157,7 @@ static void bat_ogm_send_to_if(struct forw_packet *forw_packet,
}
}
/* send a batman ogm packet */
/* send a batman ogm packet */
void
bat
_ogm_emit
(
struct
forw_packet
*
forw_packet
)
static
void
bat_iv
_ogm_emit
(
struct
forw_packet
*
forw_packet
)
{
{
struct
hard_iface
*
hard_iface
;
struct
hard_iface
*
hard_iface
;
struct
net_device
*
soft_iface
;
struct
net_device
*
soft_iface
;
...
@@ -217,7 +216,7 @@ void bat_ogm_emit(struct forw_packet *forw_packet)
...
@@ -217,7 +216,7 @@ void bat_ogm_emit(struct forw_packet *forw_packet)
if
(
hard_iface
->
soft_iface
!=
soft_iface
)
if
(
hard_iface
->
soft_iface
!=
soft_iface
)
continue
;
continue
;
bat_ogm_send_to_if
(
forw_packet
,
hard_iface
);
bat_
iv_
ogm_send_to_if
(
forw_packet
,
hard_iface
);
}
}
rcu_read_unlock
();
rcu_read_unlock
();
...
@@ -227,7 +226,7 @@ void bat_ogm_emit(struct forw_packet *forw_packet)
...
@@ -227,7 +226,7 @@ void bat_ogm_emit(struct forw_packet *forw_packet)
}
}
/* return true if new_packet can be aggregated with forw_packet */
/* return true if new_packet can be aggregated with forw_packet */
static
bool
bat_ogm_can_aggregate
(
const
struct
batman_ogm_packet
static
bool
bat_
iv_
ogm_can_aggregate
(
const
struct
batman_ogm_packet
*
new_batman_ogm_packet
,
*
new_batman_ogm_packet
,
struct
bat_priv
*
bat_priv
,
struct
bat_priv
*
bat_priv
,
int
packet_len
,
unsigned
long
send_time
,
int
packet_len
,
unsigned
long
send_time
,
...
@@ -307,7 +306,7 @@ static bool bat_ogm_can_aggregate(const struct batman_ogm_packet
...
@@ -307,7 +306,7 @@ static bool bat_ogm_can_aggregate(const struct batman_ogm_packet
}
}
/* create a new aggregated packet and add this packet to it */
/* create a new aggregated packet and add this packet to it */
static
void
bat_ogm_aggregate_new
(
const
unsigned
char
*
packet_buff
,
static
void
bat_
iv_
ogm_aggregate_new
(
const
unsigned
char
*
packet_buff
,
int
packet_len
,
unsigned
long
send_time
,
int
packet_len
,
unsigned
long
send_time
,
bool
direct_link
,
bool
direct_link
,
struct
hard_iface
*
if_incoming
,
struct
hard_iface
*
if_incoming
,
...
@@ -386,7 +385,7 @@ static void bat_ogm_aggregate_new(const unsigned char *packet_buff,
...
@@ -386,7 +385,7 @@ static void bat_ogm_aggregate_new(const unsigned char *packet_buff,
}
}
/* aggregate a new packet into the existing ogm packet */
/* aggregate a new packet into the existing ogm packet */
static
void
bat_ogm_aggregate
(
struct
forw_packet
*
forw_packet_aggr
,
static
void
bat_
iv_
ogm_aggregate
(
struct
forw_packet
*
forw_packet_aggr
,
const
unsigned
char
*
packet_buff
,
const
unsigned
char
*
packet_buff
,
int
packet_len
,
bool
direct_link
)
int
packet_len
,
bool
direct_link
)
{
{
...
@@ -403,7 +402,7 @@ static void bat_ogm_aggregate(struct forw_packet *forw_packet_aggr,
...
@@ -403,7 +402,7 @@ static void bat_ogm_aggregate(struct forw_packet *forw_packet_aggr,
(
1
<<
forw_packet_aggr
->
num_packets
);
(
1
<<
forw_packet_aggr
->
num_packets
);
}
}
static
void
bat_ogm_queue_add
(
struct
bat_priv
*
bat_priv
,
static
void
bat_
iv_
ogm_queue_add
(
struct
bat_priv
*
bat_priv
,
unsigned
char
*
packet_buff
,
unsigned
char
*
packet_buff
,
int
packet_len
,
struct
hard_iface
*
if_incoming
,
int
packet_len
,
struct
hard_iface
*
if_incoming
,
int
own_packet
,
unsigned
long
send_time
)
int
own_packet
,
unsigned
long
send_time
)
...
@@ -426,7 +425,7 @@ static void bat_ogm_queue_add(struct bat_priv *bat_priv,
...
@@ -426,7 +425,7 @@ static void bat_ogm_queue_add(struct bat_priv *bat_priv,
if
((
atomic_read
(
&
bat_priv
->
aggregated_ogms
))
&&
(
!
own_packet
))
{
if
((
atomic_read
(
&
bat_priv
->
aggregated_ogms
))
&&
(
!
own_packet
))
{
hlist_for_each_entry
(
forw_packet_pos
,
tmp_node
,
hlist_for_each_entry
(
forw_packet_pos
,
tmp_node
,
&
bat_priv
->
forw_bat_list
,
list
)
{
&
bat_priv
->
forw_bat_list
,
list
)
{
if
(
bat_ogm_can_aggregate
(
batman_ogm_packet
,
if
(
bat_
iv_
ogm_can_aggregate
(
batman_ogm_packet
,
bat_priv
,
packet_len
,
bat_priv
,
packet_len
,
send_time
,
direct_link
,
send_time
,
direct_link
,
if_incoming
,
if_incoming
,
...
@@ -452,17 +451,17 @@ static void bat_ogm_queue_add(struct bat_priv *bat_priv,
...
@@ -452,17 +451,17 @@ static void bat_ogm_queue_add(struct bat_priv *bat_priv,
(
atomic_read
(
&
bat_priv
->
aggregated_ogms
)))
(
atomic_read
(
&
bat_priv
->
aggregated_ogms
)))
send_time
+=
msecs_to_jiffies
(
MAX_AGGREGATION_MS
);
send_time
+=
msecs_to_jiffies
(
MAX_AGGREGATION_MS
);
bat_ogm_aggregate_new
(
packet_buff
,
packet_len
,
bat_
iv_
ogm_aggregate_new
(
packet_buff
,
packet_len
,
send_time
,
direct_link
,
send_time
,
direct_link
,
if_incoming
,
own_packet
);
if_incoming
,
own_packet
);
}
else
{
}
else
{
bat_
ogm_aggregate
(
forw_packet_aggr
,
packet_buff
,
packet_len
,
bat_
iv_ogm_aggregate
(
forw_packet_aggr
,
packet_buff
,
direct_link
);
packet_len
,
direct_link
);
spin_unlock_bh
(
&
bat_priv
->
forw_bat_list_lock
);
spin_unlock_bh
(
&
bat_priv
->
forw_bat_list_lock
);
}
}
}
}
static
void
bat_ogm_forward
(
struct
orig_node
*
orig_node
,
static
void
bat_
iv_
ogm_forward
(
struct
orig_node
*
orig_node
,
const
struct
ethhdr
*
ethhdr
,
const
struct
ethhdr
*
ethhdr
,
struct
batman_ogm_packet
*
batman_ogm_packet
,
struct
batman_ogm_packet
*
batman_ogm_packet
,
int
directlink
,
struct
hard_iface
*
if_incoming
)
int
directlink
,
struct
hard_iface
*
if_incoming
)
...
@@ -524,12 +523,13 @@ static void bat_ogm_forward(struct orig_node *orig_node,
...
@@ -524,12 +523,13 @@ static void bat_ogm_forward(struct orig_node *orig_node,
else
else
batman_ogm_packet
->
flags
&=
~
DIRECTLINK
;
batman_ogm_packet
->
flags
&=
~
DIRECTLINK
;
bat_ogm_queue_add
(
bat_priv
,
(
unsigned
char
*
)
batman_ogm_packet
,
bat_
iv_
ogm_queue_add
(
bat_priv
,
(
unsigned
char
*
)
batman_ogm_packet
,
BATMAN_OGM_LEN
+
tt_len
(
tt_num_changes
),
BATMAN_OGM_LEN
+
tt_len
(
tt_num_changes
),
if_incoming
,
0
,
bat
_ogm_fwd_send_time
());
if_incoming
,
0
,
bat_iv
_ogm_fwd_send_time
());
}
}
void
bat_ogm_schedule
(
struct
hard_iface
*
hard_iface
,
int
tt_num_changes
)
static
void
bat_iv_ogm_schedule
(
struct
hard_iface
*
hard_iface
,
int
tt_num_changes
)
{
{
struct
bat_priv
*
bat_priv
=
netdev_priv
(
hard_iface
->
soft_iface
);
struct
bat_priv
*
bat_priv
=
netdev_priv
(
hard_iface
->
soft_iface
);
struct
batman_ogm_packet
*
batman_ogm_packet
;
struct
batman_ogm_packet
*
batman_ogm_packet
;
...
@@ -566,21 +566,22 @@ void bat_ogm_schedule(struct hard_iface *hard_iface, int tt_num_changes)
...
@@ -566,21 +566,22 @@ void bat_ogm_schedule(struct hard_iface *hard_iface, int tt_num_changes)
atomic_inc
(
&
hard_iface
->
seqno
);
atomic_inc
(
&
hard_iface
->
seqno
);
slide_own_bcast_window
(
hard_iface
);
slide_own_bcast_window
(
hard_iface
);
bat_ogm_queue_add
(
bat_priv
,
hard_iface
->
packet_buff
,
bat_
iv_
ogm_queue_add
(
bat_priv
,
hard_iface
->
packet_buff
,
hard_iface
->
packet_len
,
hard_iface
,
1
,
hard_iface
->
packet_len
,
hard_iface
,
1
,
bat
_ogm_emit_send_time
(
bat_priv
));
bat_iv
_ogm_emit_send_time
(
bat_priv
));
if
(
primary_if
)
if
(
primary_if
)
hardif_free_ref
(
primary_if
);
hardif_free_ref
(
primary_if
);
}
}
static
void
bat_ogm_orig_update
(
struct
bat_priv
*
bat_priv
,
static
void
bat_
iv_
ogm_orig_update
(
struct
bat_priv
*
bat_priv
,
struct
orig_node
*
orig_node
,
struct
orig_node
*
orig_node
,
const
struct
ethhdr
*
ethhdr
,
const
struct
ethhdr
*
ethhdr
,
const
struct
batman_ogm_packet
const
struct
batman_ogm_packet
*
batman_ogm_packet
,
*
batman_ogm_packet
,
struct
hard_iface
*
if_incoming
,
struct
hard_iface
*
if_incoming
,
const
unsigned
char
*
tt_buff
,
int
is_duplicate
)
const
unsigned
char
*
tt_buff
,
int
is_duplicate
)
{
{
struct
neigh_node
*
neigh_node
=
NULL
,
*
tmp_neigh_node
=
NULL
;
struct
neigh_node
*
neigh_node
=
NULL
,
*
tmp_neigh_node
=
NULL
;
struct
neigh_node
*
router
=
NULL
;
struct
neigh_node
*
router
=
NULL
;
...
@@ -715,7 +716,7 @@ static void bat_ogm_orig_update(struct bat_priv *bat_priv,
...
@@ -715,7 +716,7 @@ static void bat_ogm_orig_update(struct bat_priv *bat_priv,
neigh_node_free_ref
(
router
);
neigh_node_free_ref
(
router
);
}
}
static
int
bat_ogm_calc_tq
(
struct
orig_node
*
orig_node
,
static
int
bat_
iv_
ogm_calc_tq
(
struct
orig_node
*
orig_node
,
struct
orig_node
*
orig_neigh_node
,
struct
orig_node
*
orig_neigh_node
,
struct
batman_ogm_packet
*
batman_ogm_packet
,
struct
batman_ogm_packet
*
batman_ogm_packet
,
struct
hard_iface
*
if_incoming
)
struct
hard_iface
*
if_incoming
)
...
@@ -827,7 +828,7 @@ static int bat_ogm_calc_tq(struct orig_node *orig_node,
...
@@ -827,7 +828,7 @@ static int bat_ogm_calc_tq(struct orig_node *orig_node,
* -1 the packet is old and has been received while the seqno window
* -1 the packet is old and has been received while the seqno window
* was protected. Caller should drop it.
* was protected. Caller should drop it.
*/
*/
static
int
bat_ogm_update_seqnos
(
const
struct
ethhdr
*
ethhdr
,
static
int
bat_
iv_
ogm_update_seqnos
(
const
struct
ethhdr
*
ethhdr
,
const
struct
batman_ogm_packet
const
struct
batman_ogm_packet
*
batman_ogm_packet
,
*
batman_ogm_packet
,
const
struct
hard_iface
*
if_incoming
)
const
struct
hard_iface
*
if_incoming
)
...
@@ -892,7 +893,7 @@ static int bat_ogm_update_seqnos(const struct ethhdr *ethhdr,
...
@@ -892,7 +893,7 @@ static int bat_ogm_update_seqnos(const struct ethhdr *ethhdr,
return
ret
;
return
ret
;
}
}
static
void
bat_ogm_process
(
const
struct
ethhdr
*
ethhdr
,
static
void
bat_
iv_
ogm_process
(
const
struct
ethhdr
*
ethhdr
,
struct
batman_ogm_packet
*
batman_ogm_packet
,
struct
batman_ogm_packet
*
batman_ogm_packet
,
const
unsigned
char
*
tt_buff
,
const
unsigned
char
*
tt_buff
,
struct
hard_iface
*
if_incoming
)
struct
hard_iface
*
if_incoming
)
...
@@ -1033,7 +1034,7 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
...
@@ -1033,7 +1034,7 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
if
(
!
orig_node
)
if
(
!
orig_node
)
return
;
return
;
is_duplicate
=
bat_ogm_update_seqnos
(
ethhdr
,
batman_ogm_packet
,
is_duplicate
=
bat_
iv_
ogm_update_seqnos
(
ethhdr
,
batman_ogm_packet
,
if_incoming
);
if_incoming
);
if
(
is_duplicate
==
-
1
)
{
if
(
is_duplicate
==
-
1
)
{
...
@@ -1083,7 +1084,7 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
...
@@ -1083,7 +1084,7 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
goto
out_neigh
;
goto
out_neigh
;
}
}
is_bidirectional
=
bat_ogm_calc_tq
(
orig_node
,
orig_neigh_node
,
is_bidirectional
=
bat_
iv_
ogm_calc_tq
(
orig_node
,
orig_neigh_node
,
batman_ogm_packet
,
if_incoming
);
batman_ogm_packet
,
if_incoming
);
bonding_save_primary
(
orig_node
,
orig_neigh_node
,
batman_ogm_packet
);
bonding_save_primary
(
orig_node
,
orig_neigh_node
,
batman_ogm_packet
);
...
@@ -1094,7 +1095,7 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
...
@@ -1094,7 +1095,7 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
(
!
is_duplicate
||
(
!
is_duplicate
||
((
orig_node
->
last_real_seqno
==
batman_ogm_packet
->
seqno
)
&&
((
orig_node
->
last_real_seqno
==
batman_ogm_packet
->
seqno
)
&&
(
orig_node
->
last_ttl
-
3
<=
batman_ogm_packet
->
header
.
ttl
))))
(
orig_node
->
last_ttl
-
3
<=
batman_ogm_packet
->
header
.
ttl
))))
bat_ogm_orig_update
(
bat_priv
,
orig_node
,
ethhdr
,
bat_
iv_
ogm_orig_update
(
bat_priv
,
orig_node
,
ethhdr
,
batman_ogm_packet
,
if_incoming
,
batman_ogm_packet
,
if_incoming
,
tt_buff
,
is_duplicate
);
tt_buff
,
is_duplicate
);
...
@@ -1102,7 +1103,7 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
...
@@ -1102,7 +1103,7 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
if
(
is_single_hop_neigh
)
{
if
(
is_single_hop_neigh
)
{
/* mark direct link on incoming interface */
/* mark direct link on incoming interface */
bat_ogm_forward
(
orig_node
,
ethhdr
,
batman_ogm_packet
,
bat_
iv_
ogm_forward
(
orig_node
,
ethhdr
,
batman_ogm_packet
,
1
,
if_incoming
);
1
,
if_incoming
);
bat_dbg
(
DBG_BATMAN
,
bat_priv
,
"Forwarding packet: "
bat_dbg
(
DBG_BATMAN
,
bat_priv
,
"Forwarding packet: "
...
@@ -1125,7 +1126,8 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
...
@@ -1125,7 +1126,8 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
bat_dbg
(
DBG_BATMAN
,
bat_priv
,
bat_dbg
(
DBG_BATMAN
,
bat_priv
,
"Forwarding packet: rebroadcast originator packet
\n
"
);
"Forwarding packet: rebroadcast originator packet
\n
"
);
bat_ogm_forward
(
orig_node
,
ethhdr
,
batman_ogm_packet
,
0
,
if_incoming
);
bat_iv_ogm_forward
(
orig_node
,
ethhdr
,
batman_ogm_packet
,
0
,
if_incoming
);
out_neigh:
out_neigh:
if
((
orig_neigh_node
)
&&
(
!
is_single_hop_neigh
))
if
((
orig_neigh_node
)
&&
(
!
is_single_hop_neigh
))
...
@@ -1141,7 +1143,8 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
...
@@ -1141,7 +1143,8 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
orig_node_free_ref
(
orig_node
);
orig_node_free_ref
(
orig_node
);
}
}
void
bat_ogm_receive
(
struct
hard_iface
*
if_incoming
,
struct
sk_buff
*
skb
)
static
void
bat_iv_ogm_receive
(
struct
hard_iface
*
if_incoming
,
struct
sk_buff
*
skb
)
{
{
struct
batman_ogm_packet
*
batman_ogm_packet
;
struct
batman_ogm_packet
*
batman_ogm_packet
;
struct
ethhdr
*
ethhdr
;
struct
ethhdr
*
ethhdr
;
...
@@ -1162,7 +1165,7 @@ void bat_ogm_receive(struct hard_iface *if_incoming, struct sk_buff *skb)
...
@@ -1162,7 +1165,7 @@ void bat_ogm_receive(struct hard_iface *if_incoming, struct sk_buff *skb)
tt_buff
=
packet_buff
+
buff_pos
+
BATMAN_OGM_LEN
;
tt_buff
=
packet_buff
+
buff_pos
+
BATMAN_OGM_LEN
;
bat_ogm_process
(
ethhdr
,
batman_ogm_packet
,
bat_
iv_
ogm_process
(
ethhdr
,
batman_ogm_packet
,
tt_buff
,
if_incoming
);
tt_buff
,
if_incoming
);
buff_pos
+=
BATMAN_OGM_LEN
+
buff_pos
+=
BATMAN_OGM_LEN
+
...
@@ -1170,12 +1173,18 @@ void bat_ogm_receive(struct hard_iface *if_incoming, struct sk_buff *skb)
...
@@ -1170,12 +1173,18 @@ void bat_ogm_receive(struct hard_iface *if_incoming, struct sk_buff *skb)
batman_ogm_packet
=
(
struct
batman_ogm_packet
*
)
batman_ogm_packet
=
(
struct
batman_ogm_packet
*
)
(
packet_buff
+
buff_pos
);
(
packet_buff
+
buff_pos
);
}
while
(
bat_ogm_aggr_packet
(
buff_pos
,
packet_len
,
}
while
(
bat_
iv_
ogm_aggr_packet
(
buff_pos
,
packet_len
,
batman_ogm_packet
->
tt_num_changes
));
batman_ogm_packet
->
tt_num_changes
));
}
}
static
struct
bat_algo_ops
batman_iv
__read_mostly
=
{
static
struct
bat_algo_ops
batman_iv
__read_mostly
=
{
.
name
=
"BATMAN IV"
,
.
name
=
"BATMAN IV"
,
.
bat_ogm_init
=
bat_iv_ogm_init
,
.
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
,
.
bat_ogm_emit
=
bat_iv_ogm_emit
,
.
bat_ogm_receive
=
bat_iv_ogm_receive
,
};
};
int
__init
bat_iv_init
(
void
)
int
__init
bat_iv_init
(
void
)
...
...
net/batman-adv/bat_ogm.h
deleted
100644 → 0
View file @
1c280471
/*
* Copyright (C) 2007-2011 B.A.T.M.A.N. contributors:
*
* Marek Lindner, Simon Wunderlich
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*
*/
#ifndef _NET_BATMAN_ADV_OGM_H_
#define _NET_BATMAN_ADV_OGM_H_
#include "main.h"
void
bat_ogm_init
(
struct
hard_iface
*
hard_iface
);
void
bat_ogm_init_primary
(
struct
hard_iface
*
hard_iface
);
void
bat_ogm_update_mac
(
struct
hard_iface
*
hard_iface
);
void
bat_ogm_schedule
(
struct
hard_iface
*
hard_iface
,
int
tt_num_changes
);
void
bat_ogm_emit
(
struct
forw_packet
*
forw_packet
);
void
bat_ogm_receive
(
struct
hard_iface
*
if_incoming
,
struct
sk_buff
*
skb
);
#endif
/* _NET_BATMAN_ADV_OGM_H_ */
net/batman-adv/hard-interface.c
View file @
01c4224b
...
@@ -28,7 +28,6 @@
...
@@ -28,7 +28,6 @@
#include "bat_sysfs.h"
#include "bat_sysfs.h"
#include "originator.h"
#include "originator.h"
#include "hash.h"
#include "hash.h"
#include "bat_ogm.h"
#include <linux/if_arp.h>
#include <linux/if_arp.h>
...
@@ -147,7 +146,7 @@ static void primary_if_select(struct bat_priv *bat_priv,
...
@@ -147,7 +146,7 @@ static void primary_if_select(struct bat_priv *bat_priv,
if
(
!
new_hard_iface
)
if
(
!
new_hard_iface
)
return
;
return
;
bat_ogm_init_primary
(
new_hard_iface
);
bat_
priv
->
bat_algo_ops
->
bat_
ogm_init_primary
(
new_hard_iface
);
primary_if_update_addr
(
bat_priv
);
primary_if_update_addr
(
bat_priv
);
}
}
...
@@ -233,7 +232,7 @@ static void hardif_activate_interface(struct hard_iface *hard_iface)
...
@@ -233,7 +232,7 @@ static void hardif_activate_interface(struct hard_iface *hard_iface)
bat_priv
=
netdev_priv
(
hard_iface
->
soft_iface
);
bat_priv
=
netdev_priv
(
hard_iface
->
soft_iface
);
bat_ogm_update_mac
(
hard_iface
);
bat_
priv
->
bat_algo_ops
->
bat_
ogm_update_mac
(
hard_iface
);
hard_iface
->
if_status
=
IF_TO_BE_ACTIVATED
;
hard_iface
->
if_status
=
IF_TO_BE_ACTIVATED
;
/**
/**
...
@@ -315,7 +314,7 @@ int hardif_enable_interface(struct hard_iface *hard_iface,
...
@@ -315,7 +314,7 @@ int hardif_enable_interface(struct hard_iface *hard_iface,
hard_iface
->
soft_iface
=
soft_iface
;
hard_iface
->
soft_iface
=
soft_iface
;
bat_priv
=
netdev_priv
(
hard_iface
->
soft_iface
);
bat_priv
=
netdev_priv
(
hard_iface
->
soft_iface
);
bat_ogm_init
(
hard_iface
);
bat_
priv
->
bat_algo_ops
->
bat_
ogm_init
(
hard_iface
);
if
(
!
hard_iface
->
packet_buff
)
{
if
(
!
hard_iface
->
packet_buff
)
{
bat_err
(
hard_iface
->
soft_iface
,
"Can't add interface packet "
bat_err
(
hard_iface
->
soft_iface
,
"Can't add interface packet "
...
@@ -535,9 +534,10 @@ static int hard_if_event(struct notifier_block *this,
...
@@ -535,9 +534,10 @@ static int hard_if_event(struct notifier_block *this,
goto
hardif_put
;
goto
hardif_put
;
check_known_mac_addr
(
hard_iface
->
net_dev
);
check_known_mac_addr
(
hard_iface
->
net_dev
);
bat_ogm_update_mac
(
hard_iface
);
bat_priv
=
netdev_priv
(
hard_iface
->
soft_iface
);
bat_priv
=
netdev_priv
(
hard_iface
->
soft_iface
);
bat_priv
->
bat_algo_ops
->
bat_ogm_update_mac
(
hard_iface
);
primary_if
=
primary_if_get_selected
(
bat_priv
);
primary_if
=
primary_if_get_selected
(
bat_priv
);
if
(
!
primary_if
)
if
(
!
primary_if
)
goto
hardif_put
;
goto
hardif_put
;
...
...
net/batman-adv/main.c
View file @
01c4224b
...
@@ -206,6 +206,18 @@ int bat_algo_register(struct bat_algo_ops *bat_algo_ops)
...
@@ -206,6 +206,18 @@ int bat_algo_register(struct bat_algo_ops *bat_algo_ops)
goto
out
;
goto
out
;
}
}
/* all algorithms must implement all ops (for now) */
if
(
!
bat_algo_ops
->
bat_ogm_init
||
!
bat_algo_ops
->
bat_ogm_init_primary
||
!
bat_algo_ops
->
bat_ogm_update_mac
||
!
bat_algo_ops
->
bat_ogm_schedule
||
!
bat_algo_ops
->
bat_ogm_emit
||
!
bat_algo_ops
->
bat_ogm_receive
)
{
pr_info
(
"Routing algo '%s' does not implement required ops
\n
"
,
bat_algo_ops
->
name
);
goto
out
;
}
INIT_HLIST_NODE
(
&
bat_algo_ops
->
list
);
INIT_HLIST_NODE
(
&
bat_algo_ops
->
list
);
hlist_add_head
(
&
bat_algo_ops
->
list
,
&
bat_algo_list
);
hlist_add_head
(
&
bat_algo_ops
->
list
,
&
bat_algo_list
);
ret
=
0
;
ret
=
0
;
...
...
net/batman-adv/routing.c
View file @
01c4224b
...
@@ -29,7 +29,6 @@
...
@@ -29,7 +29,6 @@
#include "originator.h"
#include "originator.h"
#include "vis.h"
#include "vis.h"
#include "unicast.h"
#include "unicast.h"
#include "bat_ogm.h"
void
slide_own_bcast_window
(
struct
hard_iface
*
hard_iface
)
void
slide_own_bcast_window
(
struct
hard_iface
*
hard_iface
)
{
{
...
@@ -248,6 +247,7 @@ int window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff,
...
@@ -248,6 +247,7 @@ int window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff,
int
recv_bat_ogm_packet
(
struct
sk_buff
*
skb
,
struct
hard_iface
*
hard_iface
)
int
recv_bat_ogm_packet
(
struct
sk_buff
*
skb
,
struct
hard_iface
*
hard_iface
)
{
{
struct
bat_priv
*
bat_priv
=
netdev_priv
(
hard_iface
->
soft_iface
);
struct
ethhdr
*
ethhdr
;
struct
ethhdr
*
ethhdr
;
/* drop packet if it has not necessary minimum size */
/* drop packet if it has not necessary minimum size */
...
@@ -272,7 +272,7 @@ int recv_bat_ogm_packet(struct sk_buff *skb, struct hard_iface *hard_iface)
...
@@ -272,7 +272,7 @@ int recv_bat_ogm_packet(struct sk_buff *skb, struct hard_iface *hard_iface)
if
(
skb_linearize
(
skb
)
<
0
)
if
(
skb_linearize
(
skb
)
<
0
)
return
NET_RX_DROP
;
return
NET_RX_DROP
;
bat_ogm_receive
(
hard_iface
,
skb
);
bat_
priv
->
bat_algo_ops
->
bat_
ogm_receive
(
hard_iface
,
skb
);
kfree_skb
(
skb
);
kfree_skb
(
skb
);
return
NET_RX_SUCCESS
;
return
NET_RX_SUCCESS
;
...
...
net/batman-adv/send.c
View file @
01c4224b
...
@@ -28,7 +28,6 @@
...
@@ -28,7 +28,6 @@
#include "vis.h"
#include "vis.h"
#include "gateway_common.h"
#include "gateway_common.h"
#include "originator.h"
#include "originator.h"
#include "bat_ogm.h"
static
void
send_outstanding_bcast_packet
(
struct
work_struct
*
work
);
static
void
send_outstanding_bcast_packet
(
struct
work_struct
*
work
);
...
@@ -168,7 +167,7 @@ void schedule_bat_ogm(struct hard_iface *hard_iface)
...
@@ -168,7 +167,7 @@ void schedule_bat_ogm(struct hard_iface *hard_iface)
if
(
primary_if
)
if
(
primary_if
)
hardif_free_ref
(
primary_if
);
hardif_free_ref
(
primary_if
);
bat_ogm_schedule
(
hard_iface
,
tt_num_changes
);
bat_
priv
->
bat_algo_ops
->
bat_
ogm_schedule
(
hard_iface
,
tt_num_changes
);
}
}
static
void
forw_packet_free
(
struct
forw_packet
*
forw_packet
)
static
void
forw_packet_free
(
struct
forw_packet
*
forw_packet
)
...
@@ -318,7 +317,7 @@ void send_outstanding_bat_ogm_packet(struct work_struct *work)
...
@@ -318,7 +317,7 @@ void send_outstanding_bat_ogm_packet(struct work_struct *work)
if
(
atomic_read
(
&
bat_priv
->
mesh_state
)
==
MESH_DEACTIVATING
)
if
(
atomic_read
(
&
bat_priv
->
mesh_state
)
==
MESH_DEACTIVATING
)
goto
out
;
goto
out
;
bat_ogm_emit
(
forw_packet
);
bat_
priv
->
bat_algo_ops
->
bat_
ogm_emit
(
forw_packet
);
/**
/**
* we have to have at least one packet in the queue
* we have to have at least one packet in the queue
...
...
net/batman-adv/types.h
View file @
01c4224b
...
@@ -348,6 +348,20 @@ struct softif_neigh {
...
@@ -348,6 +348,20 @@ struct softif_neigh {
struct
bat_algo_ops
{
struct
bat_algo_ops
{
struct
hlist_node
list
;
struct
hlist_node
list
;
char
*
name
;
char
*
name
;
/* init OGM when hard-interface is enabled */
void
(
*
bat_ogm_init
)(
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 */
void
(
*
bat_ogm_update_mac
)(
struct
hard_iface
*
hard_iface
);
/* prepare a new outgoing OGM for the send queue */
void
(
*
bat_ogm_schedule
)(
struct
hard_iface
*
hard_iface
,
int
tt_num_changes
);
/* send scheduled OGM */
void
(
*
bat_ogm_emit
)(
struct
forw_packet
*
forw_packet
);
/* receive incoming OGM */
void
(
*
bat_ogm_receive
)(
struct
hard_iface
*
if_incoming
,
struct
sk_buff
*
skb
);
};
};
#endif
/* _NET_BATMAN_ADV_TYPES_H_ */
#endif
/* _NET_BATMAN_ADV_TYPES_H_ */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment