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
nexedi
linux
Commits
3ccdca77
Commit
3ccdca77
authored
Feb 17, 2012
by
David S. Miller
Browse files
Options
Browse Files
Download
Plain Diff
Merge tag 'batman-adv-for-davem' of
git://git.open-mesh.org/linux-merge
parents
71cc7c37
ea3d2fd1
Changes
18
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
426 additions
and
235 deletions
+426
-235
Documentation/ABI/testing/sysfs-class-net-mesh
Documentation/ABI/testing/sysfs-class-net-mesh
+7
-0
net/batman-adv/bat_algo.h
net/batman-adv/bat_algo.h
+6
-14
net/batman-adv/bat_debugfs.c
net/batman-adv/bat_debugfs.c
+22
-0
net/batman-adv/bat_iv_ogm.c
net/batman-adv/bat_iv_ogm.c
+134
-111
net/batman-adv/bat_sysfs.c
net/batman-adv/bat_sysfs.c
+9
-0
net/batman-adv/hard-interface.c
net/batman-adv/hard-interface.c
+16
-8
net/batman-adv/icmp_socket.c
net/batman-adv/icmp_socket.c
+3
-3
net/batman-adv/main.c
net/batman-adv/main.c
+107
-0
net/batman-adv/main.h
net/batman-adv/main.h
+15
-0
net/batman-adv/originator.c
net/batman-adv/originator.c
+1
-0
net/batman-adv/packet.h
net/batman-adv/packet.h
+13
-25
net/batman-adv/routing.c
net/batman-adv/routing.c
+11
-13
net/batman-adv/send.c
net/batman-adv/send.c
+3
-4
net/batman-adv/soft-interface.c
net/batman-adv/soft-interface.c
+11
-7
net/batman-adv/translation-table.c
net/batman-adv/translation-table.c
+32
-35
net/batman-adv/types.h
net/batman-adv/types.h
+21
-0
net/batman-adv/unicast.c
net/batman-adv/unicast.c
+8
-8
net/batman-adv/vis.c
net/batman-adv/vis.c
+7
-7
No files found.
Documentation/ABI/testing/sysfs-class-net-mesh
View file @
3ccdca77
...
@@ -65,6 +65,13 @@ Description:
...
@@ -65,6 +65,13 @@ Description:
Defines the penalty which will be applied to an
Defines the penalty which will be applied to an
originator message's tq-field on every hop.
originator message's tq-field on every hop.
What: /sys/class/net/<mesh_iface>/mesh/routing_algo
Date: Dec 2011
Contact: Marek Lindner <lindner_marek@yahoo.de>
Description:
Defines the routing procotol this mesh instance
uses to find the optimal paths through the mesh.
What: /sys/class/net/<mesh_iface>/mesh/vis_mode
What: /sys/class/net/<mesh_iface>/mesh/vis_mode
Date: May 2010
Date: May 2010
Contact: Marek Lindner <lindner_marek@yahoo.de>
Contact: Marek Lindner <lindner_marek@yahoo.de>
...
...
net/batman-adv/bat_
ogm
.h
→
net/batman-adv/bat_
algo
.h
View file @
3ccdca77
/*
/*
* Copyright (C) 20
07-20
11 B.A.T.M.A.N. contributors:
* Copyright (C) 2011 B.A.T.M.A.N. contributors:
*
*
* Marek Lindner
, Simon Wunderlich
* Marek Lindner
*
*
* This program is free software; you can redistribute it and/or
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* modify it under the terms of version 2 of the GNU General Public
...
@@ -19,17 +19,9 @@
...
@@ -19,17 +19,9 @@
*
*
*/
*/
#ifndef _NET_BATMAN_ADV_
OGM
_H_
#ifndef _NET_BATMAN_ADV_
BAT_ALGO
_H_
#define _NET_BATMAN_ADV_
OGM
_H_
#define _NET_BATMAN_ADV_
BAT_ALGO
_H_
#include "main.h"
int
bat_iv_init
(
void
);
void
bat_ogm_init
(
struct
hard_iface
*
hard_iface
);
#endif
/* _NET_BATMAN_ADV_BAT_ALGO_H_ */
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
(
const
struct
ethhdr
*
ethhdr
,
unsigned
char
*
packet_buff
,
int
packet_len
,
struct
hard_iface
*
if_incoming
);
#endif
/* _NET_BATMAN_ADV_OGM_H_ */
net/batman-adv/bat_debugfs.c
View file @
3ccdca77
...
@@ -221,6 +221,11 @@ static void debug_log_cleanup(struct bat_priv *bat_priv)
...
@@ -221,6 +221,11 @@ static void debug_log_cleanup(struct bat_priv *bat_priv)
}
}
#endif
#endif
static
int
bat_algorithms_open
(
struct
inode
*
inode
,
struct
file
*
file
)
{
return
single_open
(
file
,
bat_algo_seq_print_text
,
NULL
);
}
static
int
originators_open
(
struct
inode
*
inode
,
struct
file
*
file
)
static
int
originators_open
(
struct
inode
*
inode
,
struct
file
*
file
)
{
{
struct
net_device
*
net_dev
=
(
struct
net_device
*
)
inode
->
i_private
;
struct
net_device
*
net_dev
=
(
struct
net_device
*
)
inode
->
i_private
;
...
@@ -274,6 +279,7 @@ struct bat_debuginfo bat_debuginfo_##_name = { \
...
@@ -274,6 +279,7 @@ struct bat_debuginfo bat_debuginfo_##_name = { \
} \
} \
};
};
static
BAT_DEBUGINFO
(
routing_algos
,
S_IRUGO
,
bat_algorithms_open
);
static
BAT_DEBUGINFO
(
originators
,
S_IRUGO
,
originators_open
);
static
BAT_DEBUGINFO
(
originators
,
S_IRUGO
,
originators_open
);
static
BAT_DEBUGINFO
(
gateways
,
S_IRUGO
,
gateways_open
);
static
BAT_DEBUGINFO
(
gateways
,
S_IRUGO
,
gateways_open
);
static
BAT_DEBUGINFO
(
softif_neigh
,
S_IRUGO
,
softif_neigh_open
);
static
BAT_DEBUGINFO
(
softif_neigh
,
S_IRUGO
,
softif_neigh_open
);
...
@@ -293,9 +299,25 @@ static struct bat_debuginfo *mesh_debuginfos[] = {
...
@@ -293,9 +299,25 @@ static struct bat_debuginfo *mesh_debuginfos[] = {
void
debugfs_init
(
void
)
void
debugfs_init
(
void
)
{
{
struct
bat_debuginfo
*
bat_debug
;
struct
dentry
*
file
;
bat_debugfs
=
debugfs_create_dir
(
DEBUGFS_BAT_SUBDIR
,
NULL
);
bat_debugfs
=
debugfs_create_dir
(
DEBUGFS_BAT_SUBDIR
,
NULL
);
if
(
bat_debugfs
==
ERR_PTR
(
-
ENODEV
))
if
(
bat_debugfs
==
ERR_PTR
(
-
ENODEV
))
bat_debugfs
=
NULL
;
bat_debugfs
=
NULL
;
if
(
!
bat_debugfs
)
goto
out
;
bat_debug
=
&
bat_debuginfo_routing_algos
;
file
=
debugfs_create_file
(
bat_debug
->
attr
.
name
,
S_IFREG
|
bat_debug
->
attr
.
mode
,
bat_debugfs
,
NULL
,
&
bat_debug
->
fops
);
if
(
!
file
)
pr_err
(
"Can't add debugfs file: %s
\n
"
,
bat_debug
->
attr
.
name
);
out:
return
;
}
}
void
debugfs_destroy
(
void
)
void
debugfs_destroy
(
void
)
...
...
net/batman-adv/bat_iv_ogm.c
View file @
3ccdca77
...
@@ -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"
...
@@ -29,8 +28,9 @@
...
@@ -29,8 +28,9 @@
#include "gateway_client.h"
#include "gateway_client.h"
#include "hard-interface.h"
#include "hard-interface.h"
#include "send.h"
#include "send.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
;
...
@@ -38,25 +38,25 @@ void bat_ogm_init(struct hard_iface *hard_iface)
...
@@ -38,25 +38,25 @@ void bat_ogm_init(struct hard_iface *hard_iface)
hard_iface
->
packet_buff
=
kmalloc
(
hard_iface
->
packet_len
,
GFP_ATOMIC
);
hard_iface
->
packet_buff
=
kmalloc
(
hard_iface
->
packet_len
,
GFP_ATOMIC
);
batman_ogm_packet
=
(
struct
batman_ogm_packet
*
)
hard_iface
->
packet_buff
;
batman_ogm_packet
=
(
struct
batman_ogm_packet
*
)
hard_iface
->
packet_buff
;
batman_ogm_packet
->
packet_type
=
BAT_OGM
;
batman_ogm_packet
->
header
.
packet_type
=
BAT_OGM
;
batman_ogm_packet
->
version
=
COMPAT_VERSION
;
batman_ogm_packet
->
header
.
version
=
COMPAT_VERSION
;
batman_ogm_packet
->
header
.
ttl
=
2
;
batman_ogm_packet
->
flags
=
NO_FLAGS
;
batman_ogm_packet
->
flags
=
NO_FLAGS
;
batman_ogm_packet
->
ttl
=
2
;
batman_ogm_packet
->
tq
=
TQ_MAX_VALUE
;
batman_ogm_packet
->
tq
=
TQ_MAX_VALUE
;
batman_ogm_packet
->
tt_num_changes
=
0
;
batman_ogm_packet
->
tt_num_changes
=
0
;
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
;
batman_ogm_packet
=
(
struct
batman_ogm_packet
*
)
hard_iface
->
packet_buff
;
batman_ogm_packet
=
(
struct
batman_ogm_packet
*
)
hard_iface
->
packet_buff
;
batman_ogm_packet
->
flags
=
PRIMARIES_FIRST_HOP
;
batman_ogm_packet
->
flags
=
PRIMARIES_FIRST_HOP
;
batman_ogm_packet
->
ttl
=
TTL
;
batman_ogm_packet
->
header
.
ttl
=
TTL
;
}
}
void
bat
_ogm_update_mac
(
struct
hard_iface
*
hard_iface
)
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
;
...
@@ -68,7 +68,7 @@ void bat_ogm_update_mac(struct hard_iface *hard_iface)
...
@@ -68,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
)
-
...
@@ -76,7 +76,7 @@ static unsigned long bat_ogm_emit_send_time(const struct bat_priv *bat_priv)
...
@@ -76,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
));
}
}
...
@@ -89,7 +89,7 @@ static uint8_t hop_penalty(uint8_t tq, const struct bat_priv *bat_priv)
...
@@ -89,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
);
...
@@ -99,7 +99,7 @@ static int bat_ogm_aggr_packet(int buff_pos, int packet_len,
...
@@ -99,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
);
...
@@ -117,7 +117,7 @@ static void bat_ogm_send_to_if(struct forw_packet *forw_packet,
...
@@ -117,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
...
@@ -137,7 +137,7 @@ static void bat_ogm_send_to_if(struct forw_packet *forw_packet,
...
@@ -137,7 +137,7 @@ static void bat_ogm_send_to_if(struct forw_packet *forw_packet,
fwd_str
,
(
packet_num
>
0
?
"aggregated "
:
""
),
fwd_str
,
(
packet_num
>
0
?
"aggregated "
:
""
),
batman_ogm_packet
->
orig
,
batman_ogm_packet
->
orig
,
ntohl
(
batman_ogm_packet
->
seqno
),
ntohl
(
batman_ogm_packet
->
seqno
),
batman_ogm_packet
->
tq
,
batman_ogm_packet
->
ttl
,
batman_ogm_packet
->
tq
,
batman_ogm_packet
->
header
.
ttl
,
(
batman_ogm_packet
->
flags
&
DIRECTLINK
?
(
batman_ogm_packet
->
flags
&
DIRECTLINK
?
"on"
:
"off"
),
"on"
:
"off"
),
batman_ogm_packet
->
ttvn
,
hard_iface
->
net_dev
->
name
,
batman_ogm_packet
->
ttvn
,
hard_iface
->
net_dev
->
name
,
...
@@ -157,7 +157,7 @@ static void bat_ogm_send_to_if(struct forw_packet *forw_packet,
...
@@ -157,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
;
...
@@ -188,7 +188,7 @@ void bat_ogm_emit(struct forw_packet *forw_packet)
...
@@ -188,7 +188,7 @@ void bat_ogm_emit(struct forw_packet *forw_packet)
/* multihomed peer assumed */
/* multihomed peer assumed */
/* non-primary OGMs are only broadcasted on their interface */
/* non-primary OGMs are only broadcasted on their interface */
if
((
directlink
&&
(
batman_ogm_packet
->
ttl
==
1
))
||
if
((
directlink
&&
(
batman_ogm_packet
->
header
.
ttl
==
1
))
||
(
forw_packet
->
own
&&
(
forw_packet
->
if_incoming
!=
primary_if
)))
{
(
forw_packet
->
own
&&
(
forw_packet
->
if_incoming
!=
primary_if
)))
{
/* FIXME: what about aggregated packets ? */
/* FIXME: what about aggregated packets ? */
...
@@ -198,7 +198,7 @@ void bat_ogm_emit(struct forw_packet *forw_packet)
...
@@ -198,7 +198,7 @@ void bat_ogm_emit(struct forw_packet *forw_packet)
(
forw_packet
->
own
?
"Sending own"
:
"Forwarding"
),
(
forw_packet
->
own
?
"Sending own"
:
"Forwarding"
),
batman_ogm_packet
->
orig
,
batman_ogm_packet
->
orig
,
ntohl
(
batman_ogm_packet
->
seqno
),
ntohl
(
batman_ogm_packet
->
seqno
),
batman_ogm_packet
->
ttl
,
batman_ogm_packet
->
header
.
ttl
,
forw_packet
->
if_incoming
->
net_dev
->
name
,
forw_packet
->
if_incoming
->
net_dev
->
name
,
forw_packet
->
if_incoming
->
net_dev
->
dev_addr
);
forw_packet
->
if_incoming
->
net_dev
->
dev_addr
);
...
@@ -216,7 +216,7 @@ void bat_ogm_emit(struct forw_packet *forw_packet)
...
@@ -216,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
();
...
@@ -226,7 +226,7 @@ void bat_ogm_emit(struct forw_packet *forw_packet)
...
@@ -226,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
,
...
@@ -272,7 +272,7 @@ static bool bat_ogm_can_aggregate(const struct batman_ogm_packet
...
@@ -272,7 +272,7 @@ static bool bat_ogm_can_aggregate(const struct batman_ogm_packet
* are flooded through the net */
* are flooded through the net */
if
((
!
directlink
)
&&
if
((
!
directlink
)
&&
(
!
(
batman_ogm_packet
->
flags
&
DIRECTLINK
))
&&
(
!
(
batman_ogm_packet
->
flags
&
DIRECTLINK
))
&&
(
batman_ogm_packet
->
ttl
!=
1
)
&&
(
batman_ogm_packet
->
header
.
ttl
!=
1
)
&&
/* own packets originating non-primary
/* own packets originating non-primary
* interfaces leave only that interface */
* interfaces leave only that interface */
...
@@ -285,7 +285,7 @@ static bool bat_ogm_can_aggregate(const struct batman_ogm_packet
...
@@ -285,7 +285,7 @@ static bool bat_ogm_can_aggregate(const struct batman_ogm_packet
/* if the incoming packet is sent via this one
/* if the incoming packet is sent via this one
* interface only - we still can aggregate */
* interface only - we still can aggregate */
if
((
directlink
)
&&
if
((
directlink
)
&&
(
new_batman_ogm_packet
->
ttl
==
1
)
&&
(
new_batman_ogm_packet
->
header
.
ttl
==
1
)
&&
(
forw_packet
->
if_incoming
==
if_incoming
)
&&
(
forw_packet
->
if_incoming
==
if_incoming
)
&&
/* packets from direct neighbors or
/* packets from direct neighbors or
...
@@ -306,7 +306,7 @@ static bool bat_ogm_can_aggregate(const struct batman_ogm_packet
...
@@ -306,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
,
...
@@ -385,7 +385,7 @@ static void bat_ogm_aggregate_new(const unsigned char *packet_buff,
...
@@ -385,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
)
{
{
...
@@ -402,7 +402,7 @@ static void bat_ogm_aggregate(struct forw_packet *forw_packet_aggr,
...
@@ -402,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
)
...
@@ -425,7 +425,7 @@ static void bat_ogm_queue_add(struct bat_priv *bat_priv,
...
@@ -425,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
,
...
@@ -451,17 +451,17 @@ static void bat_ogm_queue_add(struct bat_priv *bat_priv,
...
@@ -451,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
)
...
@@ -471,7 +471,7 @@ static void bat_ogm_forward(struct orig_node *orig_node,
...
@@ -471,7 +471,7 @@ static void bat_ogm_forward(struct orig_node *orig_node,
uint8_t
in_tq
,
in_ttl
,
tq_avg
=
0
;
uint8_t
in_tq
,
in_ttl
,
tq_avg
=
0
;
uint8_t
tt_num_changes
;
uint8_t
tt_num_changes
;
if
(
batman_ogm_packet
->
ttl
<=
1
)
{
if
(
batman_ogm_packet
->
header
.
ttl
<=
1
)
{
bat_dbg
(
DBG_BATMAN
,
bat_priv
,
"ttl exceeded
\n
"
);
bat_dbg
(
DBG_BATMAN
,
bat_priv
,
"ttl exceeded
\n
"
);
return
;
return
;
}
}
...
@@ -479,10 +479,10 @@ static void bat_ogm_forward(struct orig_node *orig_node,
...
@@ -479,10 +479,10 @@ static void bat_ogm_forward(struct orig_node *orig_node,
router
=
orig_node_get_router
(
orig_node
);
router
=
orig_node_get_router
(
orig_node
);
in_tq
=
batman_ogm_packet
->
tq
;
in_tq
=
batman_ogm_packet
->
tq
;
in_ttl
=
batman_ogm_packet
->
ttl
;
in_ttl
=
batman_ogm_packet
->
header
.
ttl
;
tt_num_changes
=
batman_ogm_packet
->
tt_num_changes
;
tt_num_changes
=
batman_ogm_packet
->
tt_num_changes
;
batman_ogm_packet
->
ttl
--
;
batman_ogm_packet
->
header
.
ttl
--
;
memcpy
(
batman_ogm_packet
->
prev_sender
,
ethhdr
->
h_source
,
ETH_ALEN
);
memcpy
(
batman_ogm_packet
->
prev_sender
,
ethhdr
->
h_source
,
ETH_ALEN
);
/* rebroadcast tq of our best ranking neighbor to ensure the rebroadcast
/* rebroadcast tq of our best ranking neighbor to ensure the rebroadcast
...
@@ -494,7 +494,8 @@ static void bat_ogm_forward(struct orig_node *orig_node,
...
@@ -494,7 +494,8 @@ static void bat_ogm_forward(struct orig_node *orig_node,
batman_ogm_packet
->
tq
=
router
->
tq_avg
;
batman_ogm_packet
->
tq
=
router
->
tq_avg
;
if
(
router
->
last_ttl
)
if
(
router
->
last_ttl
)
batman_ogm_packet
->
ttl
=
router
->
last_ttl
-
1
;
batman_ogm_packet
->
header
.
ttl
=
router
->
last_ttl
-
1
;
}
}
tq_avg
=
router
->
tq_avg
;
tq_avg
=
router
->
tq_avg
;
...
@@ -510,7 +511,7 @@ static void bat_ogm_forward(struct orig_node *orig_node,
...
@@ -510,7 +511,7 @@ static void bat_ogm_forward(struct orig_node *orig_node,
"Forwarding packet: tq_orig: %i, tq_avg: %i, "
"Forwarding packet: tq_orig: %i, tq_avg: %i, "
"tq_forw: %i, ttl_orig: %i, ttl_forw: %i
\n
"
,
"tq_forw: %i, ttl_orig: %i, ttl_forw: %i
\n
"
,
in_tq
,
tq_avg
,
batman_ogm_packet
->
tq
,
in_ttl
-
1
,
in_tq
,
tq_avg
,
batman_ogm_packet
->
tq
,
in_ttl
-
1
,
batman_ogm_packet
->
ttl
);
batman_ogm_packet
->
header
.
ttl
);
batman_ogm_packet
->
seqno
=
htonl
(
batman_ogm_packet
->
seqno
);
batman_ogm_packet
->
seqno
=
htonl
(
batman_ogm_packet
->
seqno
);
batman_ogm_packet
->
tt_crc
=
htons
(
batman_ogm_packet
->
tt_crc
);
batman_ogm_packet
->
tt_crc
=
htons
(
batman_ogm_packet
->
tt_crc
);
...
@@ -522,12 +523,13 @@ static void bat_ogm_forward(struct orig_node *orig_node,
...
@@ -522,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
;
...
@@ -564,21 +566,22 @@ void bat_ogm_schedule(struct hard_iface *hard_iface, int tt_num_changes)
...
@@ -564,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
;
...
@@ -642,8 +645,8 @@ static void bat_ogm_orig_update(struct bat_priv *bat_priv,
...
@@ -642,8 +645,8 @@ static void bat_ogm_orig_update(struct bat_priv *bat_priv,
spin_unlock_bh
(
&
neigh_node
->
tq_lock
);
spin_unlock_bh
(
&
neigh_node
->
tq_lock
);
if
(
!
is_duplicate
)
{
if
(
!
is_duplicate
)
{
orig_node
->
last_ttl
=
batman_ogm_packet
->
ttl
;
orig_node
->
last_ttl
=
batman_ogm_packet
->
header
.
ttl
;
neigh_node
->
last_ttl
=
batman_ogm_packet
->
ttl
;
neigh_node
->
last_ttl
=
batman_ogm_packet
->
header
.
ttl
;
}
}
bonding_candidate_add
(
orig_node
,
neigh_node
);
bonding_candidate_add
(
orig_node
,
neigh_node
);
...
@@ -683,7 +686,7 @@ static void bat_ogm_orig_update(struct bat_priv *bat_priv,
...
@@ -683,7 +686,7 @@ static void bat_ogm_orig_update(struct bat_priv *bat_priv,
/* I have to check for transtable changes only if the OGM has been
/* I have to check for transtable changes only if the OGM has been
* sent through a primary interface */
* sent through a primary interface */
if
(((
batman_ogm_packet
->
orig
!=
ethhdr
->
h_source
)
&&
if
(((
batman_ogm_packet
->
orig
!=
ethhdr
->
h_source
)
&&
(
batman_ogm_packet
->
ttl
>
2
))
||
(
batman_ogm_packet
->
header
.
ttl
>
2
))
||
(
batman_ogm_packet
->
flags
&
PRIMARIES_FIRST_HOP
))
(
batman_ogm_packet
->
flags
&
PRIMARIES_FIRST_HOP
))
tt_update_orig
(
bat_priv
,
orig_node
,
tt_buff
,
tt_update_orig
(
bat_priv
,
orig_node
,
tt_buff
,
batman_ogm_packet
->
tt_num_changes
,
batman_ogm_packet
->
tt_num_changes
,
...
@@ -713,7 +716,7 @@ static void bat_ogm_orig_update(struct bat_priv *bat_priv,
...
@@ -713,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
)
...
@@ -825,7 +828,7 @@ static int bat_ogm_calc_tq(struct orig_node *orig_node,
...
@@ -825,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
)
...
@@ -890,7 +893,7 @@ static int bat_ogm_update_seqnos(const struct ethhdr *ethhdr,
...
@@ -890,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
)
...
@@ -918,7 +921,7 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
...
@@ -918,7 +921,7 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
* packet in an aggregation. Here we expect that the padding
* packet in an aggregation. Here we expect that the padding
* is always zero (or not 0x01)
* is always zero (or not 0x01)
*/
*/
if
(
batman_ogm_packet
->
packet_type
!=
BAT_OGM
)
if
(
batman_ogm_packet
->
header
.
packet_type
!=
BAT_OGM
)
return
;
return
;
/* could be changed by schedule_own_packet() */
/* could be changed by schedule_own_packet() */
...
@@ -938,8 +941,8 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
...
@@ -938,8 +941,8 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
batman_ogm_packet
->
prev_sender
,
batman_ogm_packet
->
seqno
,
batman_ogm_packet
->
prev_sender
,
batman_ogm_packet
->
seqno
,
batman_ogm_packet
->
ttvn
,
batman_ogm_packet
->
tt_crc
,
batman_ogm_packet
->
ttvn
,
batman_ogm_packet
->
tt_crc
,
batman_ogm_packet
->
tt_num_changes
,
batman_ogm_packet
->
tq
,
batman_ogm_packet
->
tt_num_changes
,
batman_ogm_packet
->
tq
,
batman_ogm_packet
->
ttl
,
batman_ogm_packet
->
version
,
batman_ogm_packet
->
header
.
ttl
,
has_directlink_flag
);
batman_ogm_packet
->
header
.
version
,
has_directlink_flag
);
rcu_read_lock
();
rcu_read_lock
();
list_for_each_entry_rcu
(
hard_iface
,
&
hardif_list
,
list
)
{
list_for_each_entry_rcu
(
hard_iface
,
&
hardif_list
,
list
)
{
...
@@ -966,10 +969,10 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
...
@@ -966,10 +969,10 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
}
}
rcu_read_unlock
();
rcu_read_unlock
();
if
(
batman_ogm_packet
->
version
!=
COMPAT_VERSION
)
{
if
(
batman_ogm_packet
->
header
.
version
!=
COMPAT_VERSION
)
{
bat_dbg
(
DBG_BATMAN
,
bat_priv
,
bat_dbg
(
DBG_BATMAN
,
bat_priv
,
"Drop packet: incompatible batman version (%i)
\n
"
,
"Drop packet: incompatible batman version (%i)
\n
"
,
batman_ogm_packet
->
version
);
batman_ogm_packet
->
header
.
version
);
return
;
return
;
}
}
...
@@ -1031,7 +1034,7 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
...
@@ -1031,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
)
{
...
@@ -1081,7 +1084,7 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
...
@@ -1081,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
);
...
@@ -1091,8 +1094,8 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
...
@@ -1091,8 +1094,8 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
if
(
is_bidirectional
&&
if
(
is_bidirectional
&&
(
!
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
->
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
);
...
@@ -1100,7 +1103,7 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
...
@@ -1100,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: "
...
@@ -1123,7 +1126,8 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
...
@@ -1123,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
))
...
@@ -1139,13 +1143,17 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
...
@@ -1139,13 +1143,17 @@ 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
(
const
struct
ethhdr
*
ethhdr
,
unsigned
char
*
packet_buff
,
static
void
bat_iv_ogm_receive
(
struct
hard_iface
*
if_incoming
,
int
packet_len
,
struct
hard_iface
*
if_incoming
)
struct
sk_buff
*
skb
)
{
{
struct
batman_ogm_packet
*
batman_ogm_packet
;
struct
batman_ogm_packet
*
batman_ogm_packet
;
int
buff_pos
=
0
;
struct
ethhdr
*
ethhdr
;
unsigned
char
*
tt_buff
;
int
buff_pos
=
0
,
packet_len
;
unsigned
char
*
tt_buff
,
*
packet_buff
;
packet_len
=
skb_headlen
(
skb
);
ethhdr
=
(
struct
ethhdr
*
)
skb_mac_header
(
skb
);
packet_buff
=
skb
->
data
;
batman_ogm_packet
=
(
struct
batman_ogm_packet
*
)
packet_buff
;
batman_ogm_packet
=
(
struct
batman_ogm_packet
*
)
packet_buff
;
/* unpack the aggregated packets and process them one by one */
/* unpack the aggregated packets and process them one by one */
...
@@ -1157,7 +1165,7 @@ void bat_ogm_receive(const struct ethhdr *ethhdr, unsigned char *packet_buff,
...
@@ -1157,7 +1165,7 @@ void bat_ogm_receive(const struct ethhdr *ethhdr, unsigned char *packet_buff,
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
+
...
@@ -1165,6 +1173,21 @@ void bat_ogm_receive(const struct ethhdr *ethhdr, unsigned char *packet_buff,
...
@@ -1165,6 +1173,21 @@ void bat_ogm_receive(const struct ethhdr *ethhdr, unsigned char *packet_buff,
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
=
{
.
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
)
{
return
bat_algo_register
(
&
batman_iv
);
}
net/batman-adv/bat_sysfs.c
View file @
3ccdca77
...
@@ -272,6 +272,13 @@ static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr,
...
@@ -272,6 +272,13 @@ static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr,
return
count
;
return
count
;
}
}
static
ssize_t
show_bat_algo
(
struct
kobject
*
kobj
,
struct
attribute
*
attr
,
char
*
buff
)
{
struct
bat_priv
*
bat_priv
=
kobj_to_batpriv
(
kobj
);
return
sprintf
(
buff
,
"%s
\n
"
,
bat_priv
->
bat_algo_ops
->
name
);
}
static
void
post_gw_deselect
(
struct
net_device
*
net_dev
)
static
void
post_gw_deselect
(
struct
net_device
*
net_dev
)
{
{
struct
bat_priv
*
bat_priv
=
netdev_priv
(
net_dev
);
struct
bat_priv
*
bat_priv
=
netdev_priv
(
net_dev
);
...
@@ -382,6 +389,7 @@ BAT_ATTR_BOOL(bonding, S_IRUGO | S_IWUSR, NULL);
...
@@ -382,6 +389,7 @@ BAT_ATTR_BOOL(bonding, S_IRUGO | S_IWUSR, NULL);
BAT_ATTR_BOOL
(
fragmentation
,
S_IRUGO
|
S_IWUSR
,
update_min_mtu
);
BAT_ATTR_BOOL
(
fragmentation
,
S_IRUGO
|
S_IWUSR
,
update_min_mtu
);
BAT_ATTR_BOOL
(
ap_isolation
,
S_IRUGO
|
S_IWUSR
,
NULL
);
BAT_ATTR_BOOL
(
ap_isolation
,
S_IRUGO
|
S_IWUSR
,
NULL
);
static
BAT_ATTR
(
vis_mode
,
S_IRUGO
|
S_IWUSR
,
show_vis_mode
,
store_vis_mode
);
static
BAT_ATTR
(
vis_mode
,
S_IRUGO
|
S_IWUSR
,
show_vis_mode
,
store_vis_mode
);
static
BAT_ATTR
(
routing_algo
,
S_IRUGO
,
show_bat_algo
,
NULL
);
static
BAT_ATTR
(
gw_mode
,
S_IRUGO
|
S_IWUSR
,
show_gw_mode
,
store_gw_mode
);
static
BAT_ATTR
(
gw_mode
,
S_IRUGO
|
S_IWUSR
,
show_gw_mode
,
store_gw_mode
);
BAT_ATTR_UINT
(
orig_interval
,
S_IRUGO
|
S_IWUSR
,
2
*
JITTER
,
INT_MAX
,
NULL
);
BAT_ATTR_UINT
(
orig_interval
,
S_IRUGO
|
S_IWUSR
,
2
*
JITTER
,
INT_MAX
,
NULL
);
BAT_ATTR_UINT
(
hop_penalty
,
S_IRUGO
|
S_IWUSR
,
0
,
TQ_MAX_VALUE
,
NULL
);
BAT_ATTR_UINT
(
hop_penalty
,
S_IRUGO
|
S_IWUSR
,
0
,
TQ_MAX_VALUE
,
NULL
);
...
@@ -399,6 +407,7 @@ static struct bat_attribute *mesh_attrs[] = {
...
@@ -399,6 +407,7 @@ static struct bat_attribute *mesh_attrs[] = {
&
bat_attr_fragmentation
,
&
bat_attr_fragmentation
,
&
bat_attr_ap_isolation
,
&
bat_attr_ap_isolation
,
&
bat_attr_vis_mode
,
&
bat_attr_vis_mode
,
&
bat_attr_routing_algo
,
&
bat_attr_gw_mode
,
&
bat_attr_gw_mode
,
&
bat_attr_orig_interval
,
&
bat_attr_orig_interval
,
&
bat_attr_hop_penalty
,
&
bat_attr_hop_penalty
,
...
...
net/batman-adv/hard-interface.c
View file @
3ccdca77
...
@@ -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
;
/**
/**
...
@@ -281,6 +280,14 @@ int hardif_enable_interface(struct hard_iface *hard_iface,
...
@@ -281,6 +280,14 @@ int hardif_enable_interface(struct hard_iface *hard_iface,
if
(
!
atomic_inc_not_zero
(
&
hard_iface
->
refcount
))
if
(
!
atomic_inc_not_zero
(
&
hard_iface
->
refcount
))
goto
out
;
goto
out
;
/* hard-interface is part of a bridge */
if
(
hard_iface
->
net_dev
->
priv_flags
&
IFF_BRIDGE_PORT
)
pr_err
(
"You are about to enable batman-adv on '%s' which "
"already is part of a bridge. Unless you know exactly "
"what you are doing this is probably wrong and won't "
"work the way you think it would.
\n
"
,
hard_iface
->
net_dev
->
name
);
soft_iface
=
dev_get_by_name
(
&
init_net
,
iface_name
);
soft_iface
=
dev_get_by_name
(
&
init_net
,
iface_name
);
if
(
!
soft_iface
)
{
if
(
!
soft_iface
)
{
...
@@ -307,7 +314,7 @@ int hardif_enable_interface(struct hard_iface *hard_iface,
...
@@ -307,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 "
...
@@ -527,9 +534,10 @@ static int hard_if_event(struct notifier_block *this,
...
@@ -527,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
;
...
@@ -590,17 +598,17 @@ static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
...
@@ -590,17 +598,17 @@ static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
batman_ogm_packet
=
(
struct
batman_ogm_packet
*
)
skb
->
data
;
batman_ogm_packet
=
(
struct
batman_ogm_packet
*
)
skb
->
data
;
if
(
batman_ogm_packet
->
version
!=
COMPAT_VERSION
)
{
if
(
batman_ogm_packet
->
header
.
version
!=
COMPAT_VERSION
)
{
bat_dbg
(
DBG_BATMAN
,
bat_priv
,
bat_dbg
(
DBG_BATMAN
,
bat_priv
,
"Drop packet: incompatible batman version (%i)
\n
"
,
"Drop packet: incompatible batman version (%i)
\n
"
,
batman_ogm_packet
->
version
);
batman_ogm_packet
->
header
.
version
);
goto
err_free
;
goto
err_free
;
}
}
/* all receive handlers return whether they received or reused
/* all receive handlers return whether they received or reused
* the supplied skb. if not, we have to free the skb. */
* the supplied skb. if not, we have to free the skb. */
switch
(
batman_ogm_packet
->
packet_type
)
{
switch
(
batman_ogm_packet
->
header
.
packet_type
)
{
/* batman originator packet */
/* batman originator packet */
case
BAT_OGM
:
case
BAT_OGM
:
ret
=
recv_bat_ogm_packet
(
skb
,
hard_iface
);
ret
=
recv_bat_ogm_packet
(
skb
,
hard_iface
);
...
...
net/batman-adv/icmp_socket.c
View file @
3ccdca77
...
@@ -191,7 +191,7 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
...
@@ -191,7 +191,7 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
goto
free_skb
;
goto
free_skb
;
}
}
if
(
icmp_packet
->
packet_type
!=
BAT_ICMP
)
{
if
(
icmp_packet
->
header
.
packet_type
!=
BAT_ICMP
)
{
bat_dbg
(
DBG_BATMAN
,
bat_priv
,
bat_dbg
(
DBG_BATMAN
,
bat_priv
,
"Error - can't send packet from char device: "
"Error - can't send packet from char device: "
"got bogus packet type (expected: BAT_ICMP)
\n
"
);
"got bogus packet type (expected: BAT_ICMP)
\n
"
);
...
@@ -209,9 +209,9 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
...
@@ -209,9 +209,9 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
icmp_packet
->
uid
=
socket_client
->
index
;
icmp_packet
->
uid
=
socket_client
->
index
;
if
(
icmp_packet
->
version
!=
COMPAT_VERSION
)
{
if
(
icmp_packet
->
header
.
version
!=
COMPAT_VERSION
)
{
icmp_packet
->
msg_type
=
PARAMETER_PROBLEM
;
icmp_packet
->
msg_type
=
PARAMETER_PROBLEM
;
icmp_packet
->
version
=
COMPAT_VERSION
;
icmp_packet
->
header
.
version
=
COMPAT_VERSION
;
bat_socket_add_packet
(
socket_client
,
icmp_packet
,
packet_len
);
bat_socket_add_packet
(
socket_client
,
icmp_packet
,
packet_len
);
goto
free_skb
;
goto
free_skb
;
}
}
...
...
net/batman-adv/main.c
View file @
3ccdca77
...
@@ -32,11 +32,14 @@
...
@@ -32,11 +32,14 @@
#include "gateway_client.h"
#include "gateway_client.h"
#include "vis.h"
#include "vis.h"
#include "hash.h"
#include "hash.h"
#include "bat_algo.h"
/* List manipulations on hardif_list have to be rtnl_lock()'ed,
/* List manipulations on hardif_list have to be rtnl_lock()'ed,
* list traversals just rcu-locked */
* list traversals just rcu-locked */
struct
list_head
hardif_list
;
struct
list_head
hardif_list
;
char
bat_routing_algo
[
20
]
=
"BATMAN IV"
;
static
struct
hlist_head
bat_algo_list
;
unsigned
char
broadcast_addr
[]
=
{
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
};
unsigned
char
broadcast_addr
[]
=
{
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
};
...
@@ -45,6 +48,9 @@ struct workqueue_struct *bat_event_workqueue;
...
@@ -45,6 +48,9 @@ struct workqueue_struct *bat_event_workqueue;
static
int
__init
batman_init
(
void
)
static
int
__init
batman_init
(
void
)
{
{
INIT_LIST_HEAD
(
&
hardif_list
);
INIT_LIST_HEAD
(
&
hardif_list
);
INIT_HLIST_HEAD
(
&
bat_algo_list
);
bat_iv_init
();
/* the name should not be longer than 10 chars - see
/* the name should not be longer than 10 chars - see
* http://lwn.net/Articles/23634/ */
* http://lwn.net/Articles/23634/ */
...
@@ -170,9 +176,110 @@ int is_my_mac(const uint8_t *addr)
...
@@ -170,9 +176,110 @@ int is_my_mac(const uint8_t *addr)
}
}
rcu_read_unlock
();
rcu_read_unlock
();
return
0
;
return
0
;
}
static
struct
bat_algo_ops
*
bat_algo_get
(
char
*
name
)
{
struct
bat_algo_ops
*
bat_algo_ops
=
NULL
,
*
bat_algo_ops_tmp
;
struct
hlist_node
*
node
;
hlist_for_each_entry
(
bat_algo_ops_tmp
,
node
,
&
bat_algo_list
,
list
)
{
if
(
strcmp
(
bat_algo_ops_tmp
->
name
,
name
)
!=
0
)
continue
;
bat_algo_ops
=
bat_algo_ops_tmp
;
break
;
}
return
bat_algo_ops
;
}
int
bat_algo_register
(
struct
bat_algo_ops
*
bat_algo_ops
)
{
struct
bat_algo_ops
*
bat_algo_ops_tmp
;
int
ret
=
-
1
;
bat_algo_ops_tmp
=
bat_algo_get
(
bat_algo_ops
->
name
);
if
(
bat_algo_ops_tmp
)
{
pr_info
(
"Trying to register already registered routing "
"algorithm: %s
\n
"
,
bat_algo_ops
->
name
);
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
);
hlist_add_head
(
&
bat_algo_ops
->
list
,
&
bat_algo_list
);
ret
=
0
;
out:
return
ret
;
}
int
bat_algo_select
(
struct
bat_priv
*
bat_priv
,
char
*
name
)
{
struct
bat_algo_ops
*
bat_algo_ops
;
int
ret
=
-
1
;
bat_algo_ops
=
bat_algo_get
(
name
);
if
(
!
bat_algo_ops
)
goto
out
;
bat_priv
->
bat_algo_ops
=
bat_algo_ops
;
ret
=
0
;
out:
return
ret
;
}
int
bat_algo_seq_print_text
(
struct
seq_file
*
seq
,
void
*
offset
)
{
struct
bat_algo_ops
*
bat_algo_ops
;
struct
hlist_node
*
node
;
seq_printf
(
seq
,
"Available routing algorithms:
\n
"
);
hlist_for_each_entry
(
bat_algo_ops
,
node
,
&
bat_algo_list
,
list
)
{
seq_printf
(
seq
,
"%s
\n
"
,
bat_algo_ops
->
name
);
}
return
0
;
}
static
int
param_set_ra
(
const
char
*
val
,
const
struct
kernel_param
*
kp
)
{
struct
bat_algo_ops
*
bat_algo_ops
;
bat_algo_ops
=
bat_algo_get
((
char
*
)
val
);
if
(
!
bat_algo_ops
)
{
pr_err
(
"Routing algorithm '%s' is not supported
\n
"
,
val
);
return
-
EINVAL
;
}
return
param_set_copystring
(
val
,
kp
);
}
}
static
const
struct
kernel_param_ops
param_ops_ra
=
{
.
set
=
param_set_ra
,
.
get
=
param_get_string
,
};
static
struct
kparam_string
__param_string_ra
=
{
.
maxlen
=
sizeof
(
bat_routing_algo
),
.
string
=
bat_routing_algo
,
};
module_param_cb
(
routing_algo
,
&
param_ops_ra
,
&
__param_string_ra
,
0644
);
module_init
(
batman_init
);
module_init
(
batman_init
);
module_exit
(
batman_exit
);
module_exit
(
batman_exit
);
...
...
net/batman-adv/main.h
View file @
3ccdca77
...
@@ -147,6 +147,7 @@ enum dbg_level {
...
@@ -147,6 +147,7 @@ enum dbg_level {
#include <linux/seq_file.h>
#include <linux/seq_file.h>
#include "types.h"
#include "types.h"
extern
char
bat_routing_algo
[];
extern
struct
list_head
hardif_list
;
extern
struct
list_head
hardif_list
;
extern
unsigned
char
broadcast_addr
[];
extern
unsigned
char
broadcast_addr
[];
...
@@ -157,6 +158,9 @@ void mesh_free(struct net_device *soft_iface);
...
@@ -157,6 +158,9 @@ void mesh_free(struct net_device *soft_iface);
void
inc_module_count
(
void
);
void
inc_module_count
(
void
);
void
dec_module_count
(
void
);
void
dec_module_count
(
void
);
int
is_my_mac
(
const
uint8_t
*
addr
);
int
is_my_mac
(
const
uint8_t
*
addr
);
int
bat_algo_register
(
struct
bat_algo_ops
*
bat_algo_ops
);
int
bat_algo_select
(
struct
bat_priv
*
bat_priv
,
char
*
name
);
int
bat_algo_seq_print_text
(
struct
seq_file
*
seq
,
void
*
offset
);
#ifdef CONFIG_BATMAN_ADV_DEBUG
#ifdef CONFIG_BATMAN_ADV_DEBUG
int
debug_log
(
struct
bat_priv
*
bat_priv
,
const
char
*
fmt
,
...)
__printf
(
2
,
3
);
int
debug_log
(
struct
bat_priv
*
bat_priv
,
const
char
*
fmt
,
...)
__printf
(
2
,
3
);
...
@@ -202,6 +206,17 @@ static inline int compare_eth(const void *data1, const void *data2)
...
@@ -202,6 +206,17 @@ static inline int compare_eth(const void *data1, const void *data2)
return
(
memcmp
(
data1
,
data2
,
ETH_ALEN
)
==
0
?
1
:
0
);
return
(
memcmp
(
data1
,
data2
,
ETH_ALEN
)
==
0
?
1
:
0
);
}
}
/**
* has_timed_out - compares current time (jiffies) and timestamp + timeout
* @timestamp: base value to compare with (in jiffies)
* @timeout: added to base value before comparing (in milliseconds)
*
* Returns true if current time is after timestamp + timeout
*/
static
inline
bool
has_timed_out
(
unsigned
long
timestamp
,
unsigned
int
timeout
)
{
return
time_is_before_jiffies
(
timestamp
+
msecs_to_jiffies
(
timeout
));
}
#define atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0)
#define atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0)
...
...
net/batman-adv/originator.c
View file @
3ccdca77
...
@@ -219,6 +219,7 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, const uint8_t *addr)
...
@@ -219,6 +219,7 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, const uint8_t *addr)
/* extra reference for return */
/* extra reference for return */
atomic_set
(
&
orig_node
->
refcount
,
2
);
atomic_set
(
&
orig_node
->
refcount
,
2
);
orig_node
->
tt_initialised
=
false
;
orig_node
->
tt_poss_change
=
false
;
orig_node
->
tt_poss_change
=
false
;
orig_node
->
bat_priv
=
bat_priv
;
orig_node
->
bat_priv
=
bat_priv
;
memcpy
(
orig_node
->
orig
,
addr
,
ETH_ALEN
);
memcpy
(
orig_node
->
orig
,
addr
,
ETH_ALEN
);
...
...
net/batman-adv/packet.h
View file @
3ccdca77
...
@@ -90,10 +90,14 @@ enum tt_client_flags {
...
@@ -90,10 +90,14 @@ enum tt_client_flags {
TT_CLIENT_PENDING
=
1
<<
10
TT_CLIENT_PENDING
=
1
<<
10
};
};
struct
batman_
ogm_packet
{
struct
batman_
header
{
uint8_t
packet_type
;
uint8_t
packet_type
;
uint8_t
version
;
/* batman version field */
uint8_t
version
;
/* batman version field */
uint8_t
ttl
;
uint8_t
ttl
;
}
__packed
;
struct
batman_ogm_packet
{
struct
batman_header
header
;
uint8_t
flags
;
/* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
uint8_t
flags
;
/* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
uint32_t
seqno
;
uint32_t
seqno
;
uint8_t
orig
[
6
];
uint8_t
orig
[
6
];
...
@@ -108,9 +112,7 @@ struct batman_ogm_packet {
...
@@ -108,9 +112,7 @@ struct batman_ogm_packet {
#define BATMAN_OGM_LEN sizeof(struct batman_ogm_packet)
#define BATMAN_OGM_LEN sizeof(struct batman_ogm_packet)
struct
icmp_packet
{
struct
icmp_packet
{
uint8_t
packet_type
;
struct
batman_header
header
;
uint8_t
version
;
/* batman version field */
uint8_t
ttl
;
uint8_t
msg_type
;
/* see ICMP message types above */
uint8_t
msg_type
;
/* see ICMP message types above */
uint8_t
dst
[
6
];
uint8_t
dst
[
6
];
uint8_t
orig
[
6
];
uint8_t
orig
[
6
];
...
@@ -124,9 +126,7 @@ struct icmp_packet {
...
@@ -124,9 +126,7 @@ struct icmp_packet {
/* icmp_packet_rr must start with all fields from imcp_packet
/* icmp_packet_rr must start with all fields from imcp_packet
* as this is assumed by code that handles ICMP packets */
* as this is assumed by code that handles ICMP packets */
struct
icmp_packet_rr
{
struct
icmp_packet_rr
{
uint8_t
packet_type
;
struct
batman_header
header
;
uint8_t
version
;
/* batman version field */
uint8_t
ttl
;
uint8_t
msg_type
;
/* see ICMP message types above */
uint8_t
msg_type
;
/* see ICMP message types above */
uint8_t
dst
[
6
];
uint8_t
dst
[
6
];
uint8_t
orig
[
6
];
uint8_t
orig
[
6
];
...
@@ -137,17 +137,13 @@ struct icmp_packet_rr {
...
@@ -137,17 +137,13 @@ struct icmp_packet_rr {
}
__packed
;
}
__packed
;
struct
unicast_packet
{
struct
unicast_packet
{
uint8_t
packet_type
;
struct
batman_header
header
;
uint8_t
version
;
/* batman version field */
uint8_t
ttl
;
uint8_t
ttvn
;
/* destination translation table version number */
uint8_t
ttvn
;
/* destination translation table version number */
uint8_t
dest
[
6
];
uint8_t
dest
[
6
];
}
__packed
;
}
__packed
;
struct
unicast_frag_packet
{
struct
unicast_frag_packet
{
uint8_t
packet_type
;
struct
batman_header
header
;
uint8_t
version
;
/* batman version field */
uint8_t
ttl
;
uint8_t
ttvn
;
/* destination translation table version number */
uint8_t
ttvn
;
/* destination translation table version number */
uint8_t
dest
[
6
];
uint8_t
dest
[
6
];
uint8_t
flags
;
uint8_t
flags
;
...
@@ -157,18 +153,14 @@ struct unicast_frag_packet {
...
@@ -157,18 +153,14 @@ struct unicast_frag_packet {
}
__packed
;
}
__packed
;
struct
bcast_packet
{
struct
bcast_packet
{
uint8_t
packet_type
;
struct
batman_header
header
;
uint8_t
version
;
/* batman version field */
uint8_t
ttl
;
uint8_t
reserved
;
uint8_t
reserved
;
uint32_t
seqno
;
uint32_t
seqno
;
uint8_t
orig
[
6
];
uint8_t
orig
[
6
];
}
__packed
;
}
__packed
;
struct
vis_packet
{
struct
vis_packet
{
uint8_t
packet_type
;
struct
batman_header
header
;
uint8_t
version
;
/* batman version field */
uint8_t
ttl
;
/* TTL */
uint8_t
vis_type
;
/* which type of vis-participant sent this? */
uint8_t
vis_type
;
/* which type of vis-participant sent this? */
uint32_t
seqno
;
/* sequence number */
uint32_t
seqno
;
/* sequence number */
uint8_t
entries
;
/* number of entries behind this struct */
uint8_t
entries
;
/* number of entries behind this struct */
...
@@ -179,9 +171,7 @@ struct vis_packet {
...
@@ -179,9 +171,7 @@ struct vis_packet {
}
__packed
;
}
__packed
;
struct
tt_query_packet
{
struct
tt_query_packet
{
uint8_t
packet_type
;
struct
batman_header
header
;
uint8_t
version
;
/* batman version field */
uint8_t
ttl
;
/* the flag field is a combination of:
/* the flag field is a combination of:
* - TT_REQUEST or TT_RESPONSE
* - TT_REQUEST or TT_RESPONSE
* - TT_FULL_TABLE */
* - TT_FULL_TABLE */
...
@@ -202,9 +192,7 @@ struct tt_query_packet {
...
@@ -202,9 +192,7 @@ struct tt_query_packet {
}
__packed
;
}
__packed
;
struct
roam_adv_packet
{
struct
roam_adv_packet
{
uint8_t
packet_type
;
struct
batman_header
header
;
uint8_t
version
;
uint8_t
ttl
;
uint8_t
reserved
;
uint8_t
reserved
;
uint8_t
dst
[
ETH_ALEN
];
uint8_t
dst
[
ETH_ALEN
];
uint8_t
src
[
ETH_ALEN
];
uint8_t
src
[
ETH_ALEN
];
...
...
net/batman-adv/routing.c
View file @
3ccdca77
...
@@ -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,9 +272,7 @@ int recv_bat_ogm_packet(struct sk_buff *skb, struct hard_iface *hard_iface)
...
@@ -272,9 +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
;
ethhdr
=
(
struct
ethhdr
*
)
skb_mac_header
(
skb
);
bat_priv
->
bat_algo_ops
->
bat_ogm_receive
(
hard_iface
,
skb
);
bat_ogm_receive
(
ethhdr
,
skb
->
data
,
skb_headlen
(
skb
),
hard_iface
);
kfree_skb
(
skb
);
kfree_skb
(
skb
);
return
NET_RX_SUCCESS
;
return
NET_RX_SUCCESS
;
...
@@ -320,7 +318,7 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv,
...
@@ -320,7 +318,7 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv,
memcpy
(
icmp_packet
->
dst
,
icmp_packet
->
orig
,
ETH_ALEN
);
memcpy
(
icmp_packet
->
dst
,
icmp_packet
->
orig
,
ETH_ALEN
);
memcpy
(
icmp_packet
->
orig
,
primary_if
->
net_dev
->
dev_addr
,
ETH_ALEN
);
memcpy
(
icmp_packet
->
orig
,
primary_if
->
net_dev
->
dev_addr
,
ETH_ALEN
);
icmp_packet
->
msg_type
=
ECHO_REPLY
;
icmp_packet
->
msg_type
=
ECHO_REPLY
;
icmp_packet
->
ttl
=
TTL
;
icmp_packet
->
header
.
ttl
=
TTL
;
send_skb_packet
(
skb
,
router
->
if_incoming
,
router
->
addr
);
send_skb_packet
(
skb
,
router
->
if_incoming
,
router
->
addr
);
ret
=
NET_RX_SUCCESS
;
ret
=
NET_RX_SUCCESS
;
...
@@ -376,7 +374,7 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv,
...
@@ -376,7 +374,7 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv,
memcpy
(
icmp_packet
->
dst
,
icmp_packet
->
orig
,
ETH_ALEN
);
memcpy
(
icmp_packet
->
dst
,
icmp_packet
->
orig
,
ETH_ALEN
);
memcpy
(
icmp_packet
->
orig
,
primary_if
->
net_dev
->
dev_addr
,
ETH_ALEN
);
memcpy
(
icmp_packet
->
orig
,
primary_if
->
net_dev
->
dev_addr
,
ETH_ALEN
);
icmp_packet
->
msg_type
=
TTL_EXCEEDED
;
icmp_packet
->
msg_type
=
TTL_EXCEEDED
;
icmp_packet
->
ttl
=
TTL
;
icmp_packet
->
header
.
ttl
=
TTL
;
send_skb_packet
(
skb
,
router
->
if_incoming
,
router
->
addr
);
send_skb_packet
(
skb
,
router
->
if_incoming
,
router
->
addr
);
ret
=
NET_RX_SUCCESS
;
ret
=
NET_RX_SUCCESS
;
...
@@ -441,7 +439,7 @@ int recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if)
...
@@ -441,7 +439,7 @@ int recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if)
return
recv_my_icmp_packet
(
bat_priv
,
skb
,
hdr_size
);
return
recv_my_icmp_packet
(
bat_priv
,
skb
,
hdr_size
);
/* TTL exceeded */
/* TTL exceeded */
if
(
icmp_packet
->
ttl
<
2
)
if
(
icmp_packet
->
header
.
ttl
<
2
)
return
recv_icmp_ttl_exceeded
(
bat_priv
,
skb
);
return
recv_icmp_ttl_exceeded
(
bat_priv
,
skb
);
/* get routing information */
/* get routing information */
...
@@ -460,7 +458,7 @@ int recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if)
...
@@ -460,7 +458,7 @@ int recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if)
icmp_packet
=
(
struct
icmp_packet_rr
*
)
skb
->
data
;
icmp_packet
=
(
struct
icmp_packet_rr
*
)
skb
->
data
;
/* decrement ttl */
/* decrement ttl */
icmp_packet
->
ttl
--
;
icmp_packet
->
header
.
ttl
--
;
/* route it */
/* route it */
send_skb_packet
(
skb
,
router
->
if_incoming
,
router
->
addr
);
send_skb_packet
(
skb
,
router
->
if_incoming
,
router
->
addr
);
...
@@ -815,7 +813,7 @@ int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
...
@@ -815,7 +813,7 @@ int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
unicast_packet
=
(
struct
unicast_packet
*
)
skb
->
data
;
unicast_packet
=
(
struct
unicast_packet
*
)
skb
->
data
;
/* TTL exceeded */
/* TTL exceeded */
if
(
unicast_packet
->
ttl
<
2
)
{
if
(
unicast_packet
->
header
.
ttl
<
2
)
{
pr_debug
(
"Warning - can't forward unicast packet from %pM to "
pr_debug
(
"Warning - can't forward unicast packet from %pM to "
"%pM: ttl exceeded
\n
"
,
ethhdr
->
h_source
,
"%pM: ttl exceeded
\n
"
,
ethhdr
->
h_source
,
unicast_packet
->
dest
);
unicast_packet
->
dest
);
...
@@ -840,7 +838,7 @@ int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
...
@@ -840,7 +838,7 @@ int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
unicast_packet
=
(
struct
unicast_packet
*
)
skb
->
data
;
unicast_packet
=
(
struct
unicast_packet
*
)
skb
->
data
;
if
(
unicast_packet
->
packet_type
==
BAT_UNICAST
&&
if
(
unicast_packet
->
header
.
packet_type
==
BAT_UNICAST
&&
atomic_read
(
&
bat_priv
->
fragmentation
)
&&
atomic_read
(
&
bat_priv
->
fragmentation
)
&&
skb
->
len
>
neigh_node
->
if_incoming
->
net_dev
->
mtu
)
{
skb
->
len
>
neigh_node
->
if_incoming
->
net_dev
->
mtu
)
{
ret
=
frag_send_skb
(
skb
,
bat_priv
,
ret
=
frag_send_skb
(
skb
,
bat_priv
,
...
@@ -848,7 +846,7 @@ int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
...
@@ -848,7 +846,7 @@ int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
goto
out
;
goto
out
;
}
}
if
(
unicast_packet
->
packet_type
==
BAT_UNICAST_FRAG
&&
if
(
unicast_packet
->
header
.
packet_type
==
BAT_UNICAST_FRAG
&&
frag_can_reassemble
(
skb
,
neigh_node
->
if_incoming
->
net_dev
->
mtu
))
{
frag_can_reassemble
(
skb
,
neigh_node
->
if_incoming
->
net_dev
->
mtu
))
{
ret
=
frag_reassemble_skb
(
skb
,
bat_priv
,
&
new_skb
);
ret
=
frag_reassemble_skb
(
skb
,
bat_priv
,
&
new_skb
);
...
@@ -867,7 +865,7 @@ int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
...
@@ -867,7 +865,7 @@ int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
}
}
/* decrement ttl */
/* decrement ttl */
unicast_packet
->
ttl
--
;
unicast_packet
->
header
.
ttl
--
;
/* route it */
/* route it */
send_skb_packet
(
skb
,
neigh_node
->
if_incoming
,
neigh_node
->
addr
);
send_skb_packet
(
skb
,
neigh_node
->
if_incoming
,
neigh_node
->
addr
);
...
@@ -1041,7 +1039,7 @@ int recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
...
@@ -1041,7 +1039,7 @@ int recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
if
(
is_my_mac
(
bcast_packet
->
orig
))
if
(
is_my_mac
(
bcast_packet
->
orig
))
goto
out
;
goto
out
;
if
(
bcast_packet
->
ttl
<
2
)
if
(
bcast_packet
->
header
.
ttl
<
2
)
goto
out
;
goto
out
;
orig_node
=
orig_hash_find
(
bat_priv
,
bcast_packet
->
orig
);
orig_node
=
orig_hash_find
(
bat_priv
,
bcast_packet
->
orig
);
...
...
net/batman-adv/send.c
View file @
3ccdca77
...
@@ -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
)
...
@@ -234,7 +233,7 @@ int add_bcast_packet_to_list(struct bat_priv *bat_priv,
...
@@ -234,7 +233,7 @@ int add_bcast_packet_to_list(struct bat_priv *bat_priv,
/* as we have a copy now, it is safe to decrease the TTL */
/* as we have a copy now, it is safe to decrease the TTL */
bcast_packet
=
(
struct
bcast_packet
*
)
newskb
->
data
;
bcast_packet
=
(
struct
bcast_packet
*
)
newskb
->
data
;
bcast_packet
->
ttl
--
;
bcast_packet
->
header
.
ttl
--
;
skb_reset_mac_header
(
newskb
);
skb_reset_mac_header
(
newskb
);
...
@@ -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/soft-interface.c
View file @
3ccdca77
...
@@ -457,10 +457,10 @@ static void softif_batman_recv(struct sk_buff *skb, struct net_device *dev,
...
@@ -457,10 +457,10 @@ static void softif_batman_recv(struct sk_buff *skb, struct net_device *dev,
batman_ogm_packet
=
(
struct
batman_ogm_packet
*
)
batman_ogm_packet
=
(
struct
batman_ogm_packet
*
)
(
skb
->
data
+
ETH_HLEN
);
(
skb
->
data
+
ETH_HLEN
);
if
(
batman_ogm_packet
->
version
!=
COMPAT_VERSION
)
if
(
batman_ogm_packet
->
header
.
version
!=
COMPAT_VERSION
)
goto
out
;
goto
out
;
if
(
batman_ogm_packet
->
packet_type
!=
BAT_OGM
)
if
(
batman_ogm_packet
->
header
.
packet_type
!=
BAT_OGM
)
goto
out
;
goto
out
;
if
(
!
(
batman_ogm_packet
->
flags
&
PRIMARIES_FIRST_HOP
))
if
(
!
(
batman_ogm_packet
->
flags
&
PRIMARIES_FIRST_HOP
))
...
@@ -632,11 +632,11 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
...
@@ -632,11 +632,11 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
goto
dropped
;
goto
dropped
;
bcast_packet
=
(
struct
bcast_packet
*
)
skb
->
data
;
bcast_packet
=
(
struct
bcast_packet
*
)
skb
->
data
;
bcast_packet
->
version
=
COMPAT_VERSION
;
bcast_packet
->
header
.
version
=
COMPAT_VERSION
;
bcast_packet
->
ttl
=
TTL
;
bcast_packet
->
header
.
ttl
=
TTL
;
/* batman packet type: broadcast */
/* batman packet type: broadcast */
bcast_packet
->
packet_type
=
BAT_BCAST
;
bcast_packet
->
header
.
packet_type
=
BAT_BCAST
;
/* hw address of first interface is the orig mac because only
/* hw address of first interface is the orig mac because only
* this mac is known throughout the mesh */
* this mac is known throughout the mesh */
...
@@ -725,8 +725,8 @@ void interface_rx(struct net_device *soft_iface,
...
@@ -725,8 +725,8 @@ void interface_rx(struct net_device *soft_iface,
skb_push
(
skb
,
hdr_size
);
skb_push
(
skb
,
hdr_size
);
unicast_packet
=
(
struct
unicast_packet
*
)
skb
->
data
;
unicast_packet
=
(
struct
unicast_packet
*
)
skb
->
data
;
if
((
unicast_packet
->
packet_type
!=
BAT_UNICAST
)
&&
if
((
unicast_packet
->
header
.
packet_type
!=
BAT_UNICAST
)
&&
(
unicast_packet
->
packet_type
!=
BAT_UNICAST_FRAG
))
(
unicast_packet
->
header
.
packet_type
!=
BAT_UNICAST_FRAG
))
goto
dropped
;
goto
dropped
;
skb_reset_mac_header
(
skb
);
skb_reset_mac_header
(
skb
);
...
@@ -855,6 +855,10 @@ struct net_device *softif_create(const char *name)
...
@@ -855,6 +855,10 @@ struct net_device *softif_create(const char *name)
bat_priv
->
primary_if
=
NULL
;
bat_priv
->
primary_if
=
NULL
;
bat_priv
->
num_ifaces
=
0
;
bat_priv
->
num_ifaces
=
0
;
ret
=
bat_algo_select
(
bat_priv
,
bat_routing_algo
);
if
(
ret
<
0
)
goto
unreg_soft_iface
;
ret
=
sysfs_add_meshif
(
soft_iface
);
ret
=
sysfs_add_meshif
(
soft_iface
);
if
(
ret
<
0
)
if
(
ret
<
0
)
goto
unreg_soft_iface
;
goto
unreg_soft_iface
;
...
...
net/batman-adv/translation-table.c
View file @
3ccdca77
...
@@ -108,14 +108,6 @@ static struct tt_global_entry *tt_global_hash_find(struct bat_priv *bat_priv,
...
@@ -108,14 +108,6 @@ static struct tt_global_entry *tt_global_hash_find(struct bat_priv *bat_priv,
}
}
static
bool
is_out_of_time
(
unsigned
long
starting_time
,
unsigned
long
timeout
)
{
unsigned
long
deadline
;
deadline
=
starting_time
+
msecs_to_jiffies
(
timeout
);
return
time_after
(
jiffies
,
deadline
);
}
static
void
tt_local_entry_free_ref
(
struct
tt_local_entry
*
tt_local_entry
)
static
void
tt_local_entry_free_ref
(
struct
tt_local_entry
*
tt_local_entry
)
{
{
if
(
atomic_dec_and_test
(
&
tt_local_entry
->
common
.
refcount
))
if
(
atomic_dec_and_test
(
&
tt_local_entry
->
common
.
refcount
))
...
@@ -420,7 +412,7 @@ static void tt_local_purge(struct bat_priv *bat_priv)
...
@@ -420,7 +412,7 @@ static void tt_local_purge(struct bat_priv *bat_priv)
if
(
tt_local_entry
->
common
.
flags
&
TT_CLIENT_PENDING
)
if
(
tt_local_entry
->
common
.
flags
&
TT_CLIENT_PENDING
)
continue
;
continue
;
if
(
!
is_out_of_time
(
tt_local_entry
->
last_seen
,
if
(
!
has_timed_out
(
tt_local_entry
->
last_seen
,
TT_LOCAL_TIMEOUT
*
1000
))
TT_LOCAL_TIMEOUT
*
1000
))
continue
;
continue
;
...
@@ -733,6 +725,7 @@ void tt_global_del_orig(struct bat_priv *bat_priv,
...
@@ -733,6 +725,7 @@ void tt_global_del_orig(struct bat_priv *bat_priv,
spin_unlock_bh
(
list_lock
);
spin_unlock_bh
(
list_lock
);
}
}
atomic_set
(
&
orig_node
->
tt_size
,
0
);
atomic_set
(
&
orig_node
->
tt_size
,
0
);
orig_node
->
tt_initialised
=
false
;
}
}
static
void
tt_global_roam_purge
(
struct
bat_priv
*
bat_priv
)
static
void
tt_global_roam_purge
(
struct
bat_priv
*
bat_priv
)
...
@@ -757,7 +750,7 @@ static void tt_global_roam_purge(struct bat_priv *bat_priv)
...
@@ -757,7 +750,7 @@ static void tt_global_roam_purge(struct bat_priv *bat_priv)
common
);
common
);
if
(
!
(
tt_global_entry
->
common
.
flags
&
TT_CLIENT_ROAM
))
if
(
!
(
tt_global_entry
->
common
.
flags
&
TT_CLIENT_ROAM
))
continue
;
continue
;
if
(
!
is_out_of_time
(
tt_global_entry
->
roam_at
,
if
(
!
has_timed_out
(
tt_global_entry
->
roam_at
,
TT_CLIENT_ROAM_TIMEOUT
*
1000
))
TT_CLIENT_ROAM_TIMEOUT
*
1000
))
continue
;
continue
;
...
@@ -977,7 +970,7 @@ static void tt_req_purge(struct bat_priv *bat_priv)
...
@@ -977,7 +970,7 @@ static void tt_req_purge(struct bat_priv *bat_priv)
spin_lock_bh
(
&
bat_priv
->
tt_req_list_lock
);
spin_lock_bh
(
&
bat_priv
->
tt_req_list_lock
);
list_for_each_entry_safe
(
node
,
safe
,
&
bat_priv
->
tt_req_list
,
list
)
{
list_for_each_entry_safe
(
node
,
safe
,
&
bat_priv
->
tt_req_list
,
list
)
{
if
(
is_out_of_time
(
node
->
issued_at
,
if
(
has_timed_out
(
node
->
issued_at
,
TT_REQUEST_TIMEOUT
*
1000
))
{
TT_REQUEST_TIMEOUT
*
1000
))
{
list_del
(
&
node
->
list
);
list_del
(
&
node
->
list
);
kfree
(
node
);
kfree
(
node
);
...
@@ -996,7 +989,7 @@ static struct tt_req_node *new_tt_req_node(struct bat_priv *bat_priv,
...
@@ -996,7 +989,7 @@ static struct tt_req_node *new_tt_req_node(struct bat_priv *bat_priv,
spin_lock_bh
(
&
bat_priv
->
tt_req_list_lock
);
spin_lock_bh
(
&
bat_priv
->
tt_req_list_lock
);
list_for_each_entry
(
tt_req_node_tmp
,
&
bat_priv
->
tt_req_list
,
list
)
{
list_for_each_entry
(
tt_req_node_tmp
,
&
bat_priv
->
tt_req_list
,
list
)
{
if
(
compare_eth
(
tt_req_node_tmp
,
orig_node
)
&&
if
(
compare_eth
(
tt_req_node_tmp
,
orig_node
)
&&
!
is_out_of_time
(
tt_req_node_tmp
->
issued_at
,
!
has_timed_out
(
tt_req_node_tmp
->
issued_at
,
TT_REQUEST_TIMEOUT
*
1000
))
TT_REQUEST_TIMEOUT
*
1000
))
goto
unlock
;
goto
unlock
;
}
}
...
@@ -1134,11 +1127,11 @@ static int send_tt_request(struct bat_priv *bat_priv,
...
@@ -1134,11 +1127,11 @@ static int send_tt_request(struct bat_priv *bat_priv,
tt_request
=
(
struct
tt_query_packet
*
)
skb_put
(
skb
,
tt_request
=
(
struct
tt_query_packet
*
)
skb_put
(
skb
,
sizeof
(
struct
tt_query_packet
));
sizeof
(
struct
tt_query_packet
));
tt_request
->
packet_type
=
BAT_TT_QUERY
;
tt_request
->
header
.
packet_type
=
BAT_TT_QUERY
;
tt_request
->
version
=
COMPAT_VERSION
;
tt_request
->
header
.
version
=
COMPAT_VERSION
;
memcpy
(
tt_request
->
src
,
primary_if
->
net_dev
->
dev_addr
,
ETH_ALEN
);
memcpy
(
tt_request
->
src
,
primary_if
->
net_dev
->
dev_addr
,
ETH_ALEN
);
memcpy
(
tt_request
->
dst
,
dst_orig_node
->
orig
,
ETH_ALEN
);
memcpy
(
tt_request
->
dst
,
dst_orig_node
->
orig
,
ETH_ALEN
);
tt_request
->
ttl
=
TTL
;
tt_request
->
header
.
ttl
=
TTL
;
tt_request
->
ttvn
=
ttvn
;
tt_request
->
ttvn
=
ttvn
;
tt_request
->
tt_data
=
tt_crc
;
tt_request
->
tt_data
=
tt_crc
;
tt_request
->
flags
=
TT_REQUEST
;
tt_request
->
flags
=
TT_REQUEST
;
...
@@ -1264,9 +1257,9 @@ static bool send_other_tt_response(struct bat_priv *bat_priv,
...
@@ -1264,9 +1257,9 @@ static bool send_other_tt_response(struct bat_priv *bat_priv,
tt_response
=
(
struct
tt_query_packet
*
)
skb
->
data
;
tt_response
=
(
struct
tt_query_packet
*
)
skb
->
data
;
}
}
tt_response
->
packet_type
=
BAT_TT_QUERY
;
tt_response
->
header
.
packet_type
=
BAT_TT_QUERY
;
tt_response
->
version
=
COMPAT_VERSION
;
tt_response
->
header
.
version
=
COMPAT_VERSION
;
tt_response
->
ttl
=
TTL
;
tt_response
->
header
.
ttl
=
TTL
;
memcpy
(
tt_response
->
src
,
req_dst_orig_node
->
orig
,
ETH_ALEN
);
memcpy
(
tt_response
->
src
,
req_dst_orig_node
->
orig
,
ETH_ALEN
);
memcpy
(
tt_response
->
dst
,
tt_request
->
src
,
ETH_ALEN
);
memcpy
(
tt_response
->
dst
,
tt_request
->
src
,
ETH_ALEN
);
tt_response
->
flags
=
TT_RESPONSE
;
tt_response
->
flags
=
TT_RESPONSE
;
...
@@ -1381,9 +1374,9 @@ static bool send_my_tt_response(struct bat_priv *bat_priv,
...
@@ -1381,9 +1374,9 @@ static bool send_my_tt_response(struct bat_priv *bat_priv,
tt_response
=
(
struct
tt_query_packet
*
)
skb
->
data
;
tt_response
=
(
struct
tt_query_packet
*
)
skb
->
data
;
}
}
tt_response
->
packet_type
=
BAT_TT_QUERY
;
tt_response
->
header
.
packet_type
=
BAT_TT_QUERY
;
tt_response
->
version
=
COMPAT_VERSION
;
tt_response
->
header
.
version
=
COMPAT_VERSION
;
tt_response
->
ttl
=
TTL
;
tt_response
->
header
.
ttl
=
TTL
;
memcpy
(
tt_response
->
src
,
primary_if
->
net_dev
->
dev_addr
,
ETH_ALEN
);
memcpy
(
tt_response
->
src
,
primary_if
->
net_dev
->
dev_addr
,
ETH_ALEN
);
memcpy
(
tt_response
->
dst
,
tt_request
->
src
,
ETH_ALEN
);
memcpy
(
tt_response
->
dst
,
tt_request
->
src
,
ETH_ALEN
);
tt_response
->
flags
=
TT_RESPONSE
;
tt_response
->
flags
=
TT_RESPONSE
;
...
@@ -1450,6 +1443,7 @@ static void _tt_update_changes(struct bat_priv *bat_priv,
...
@@ -1450,6 +1443,7 @@ static void _tt_update_changes(struct bat_priv *bat_priv,
*/
*/
return
;
return
;
}
}
orig_node
->
tt_initialised
=
true
;
}
}
static
void
tt_fill_gtable
(
struct
bat_priv
*
bat_priv
,
static
void
tt_fill_gtable
(
struct
bat_priv
*
bat_priv
,
...
@@ -1589,7 +1583,7 @@ static void tt_roam_purge(struct bat_priv *bat_priv)
...
@@ -1589,7 +1583,7 @@ static void tt_roam_purge(struct bat_priv *bat_priv)
spin_lock_bh
(
&
bat_priv
->
tt_roam_list_lock
);
spin_lock_bh
(
&
bat_priv
->
tt_roam_list_lock
);
list_for_each_entry_safe
(
node
,
safe
,
&
bat_priv
->
tt_roam_list
,
list
)
{
list_for_each_entry_safe
(
node
,
safe
,
&
bat_priv
->
tt_roam_list
,
list
)
{
if
(
!
is_out_of_time
(
node
->
first_time
,
if
(
!
has_timed_out
(
node
->
first_time
,
ROAMING_MAX_TIME
*
1000
))
ROAMING_MAX_TIME
*
1000
))
continue
;
continue
;
...
@@ -1617,7 +1611,7 @@ static bool tt_check_roam_count(struct bat_priv *bat_priv,
...
@@ -1617,7 +1611,7 @@ static bool tt_check_roam_count(struct bat_priv *bat_priv,
if
(
!
compare_eth
(
tt_roam_node
->
addr
,
client
))
if
(
!
compare_eth
(
tt_roam_node
->
addr
,
client
))
continue
;
continue
;
if
(
is_out_of_time
(
tt_roam_node
->
first_time
,
if
(
has_timed_out
(
tt_roam_node
->
first_time
,
ROAMING_MAX_TIME
*
1000
))
ROAMING_MAX_TIME
*
1000
))
continue
;
continue
;
...
@@ -1669,9 +1663,9 @@ void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client,
...
@@ -1669,9 +1663,9 @@ void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client,
roam_adv_packet
=
(
struct
roam_adv_packet
*
)
skb_put
(
skb
,
roam_adv_packet
=
(
struct
roam_adv_packet
*
)
skb_put
(
skb
,
sizeof
(
struct
roam_adv_packet
));
sizeof
(
struct
roam_adv_packet
));
roam_adv_packet
->
packet_type
=
BAT_ROAM_ADV
;
roam_adv_packet
->
header
.
packet_type
=
BAT_ROAM_ADV
;
roam_adv_packet
->
version
=
COMPAT_VERSION
;
roam_adv_packet
->
header
.
version
=
COMPAT_VERSION
;
roam_adv_packet
->
ttl
=
TTL
;
roam_adv_packet
->
header
.
ttl
=
TTL
;
primary_if
=
primary_if_get_selected
(
bat_priv
);
primary_if
=
primary_if_get_selected
(
bat_priv
);
if
(
!
primary_if
)
if
(
!
primary_if
)
goto
out
;
goto
out
;
...
@@ -1854,8 +1848,10 @@ void tt_update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node,
...
@@ -1854,8 +1848,10 @@ void tt_update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node,
uint8_t
orig_ttvn
=
(
uint8_t
)
atomic_read
(
&
orig_node
->
last_ttvn
);
uint8_t
orig_ttvn
=
(
uint8_t
)
atomic_read
(
&
orig_node
->
last_ttvn
);
bool
full_table
=
true
;
bool
full_table
=
true
;
/* the ttvn increased by one -> we can apply the attached changes */
/* orig table not initialised AND first diff is in the OGM OR the ttvn
if
(
ttvn
-
orig_ttvn
==
1
)
{
* increased by one -> we can apply the attached changes */
if
((
!
orig_node
->
tt_initialised
&&
ttvn
==
1
)
||
ttvn
-
orig_ttvn
==
1
)
{
/* the OGM could not contain the changes due to their size or
/* the OGM could not contain the changes due to their size or
* because they have already been sent TT_OGM_APPEND_MAX times.
* because they have already been sent TT_OGM_APPEND_MAX times.
* In this case send a tt request */
* In this case send a tt request */
...
@@ -1889,7 +1885,8 @@ void tt_update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node,
...
@@ -1889,7 +1885,8 @@ void tt_update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node,
}
else
{
}
else
{
/* if we missed more than one change or our tables are not
/* if we missed more than one change or our tables are not
* in sync anymore -> request fresh tt data */
* in sync anymore -> request fresh tt data */
if
(
ttvn
!=
orig_ttvn
||
orig_node
->
tt_crc
!=
tt_crc
)
{
if
(
!
orig_node
->
tt_initialised
||
ttvn
!=
orig_ttvn
||
orig_node
->
tt_crc
!=
tt_crc
)
{
request_table:
request_table:
bat_dbg
(
DBG_TT
,
bat_priv
,
"TT inconsistency for %pM. "
bat_dbg
(
DBG_TT
,
bat_priv
,
"TT inconsistency for %pM. "
"Need to retrieve the correct information "
"Need to retrieve the correct information "
...
...
net/batman-adv/types.h
View file @
3ccdca77
...
@@ -81,6 +81,7 @@ struct orig_node {
...
@@ -81,6 +81,7 @@ struct orig_node {
int16_t
tt_buff_len
;
int16_t
tt_buff_len
;
spinlock_t
tt_buff_lock
;
/* protects tt_buff */
spinlock_t
tt_buff_lock
;
/* protects tt_buff */
atomic_t
tt_size
;
atomic_t
tt_size
;
bool
tt_initialised
;
/* The tt_poss_change flag is used to detect an ongoing roaming phase.
/* The tt_poss_change flag is used to detect an ongoing roaming phase.
* If true, then I sent a Roaming_adv to this orig_node and I have to
* If true, then I sent a Roaming_adv to this orig_node and I have to
* inspect every packet directed to it to check whether it is still
* inspect every packet directed to it to check whether it is still
...
@@ -205,6 +206,7 @@ struct bat_priv {
...
@@ -205,6 +206,7 @@ struct bat_priv {
atomic_t
gw_reselect
;
atomic_t
gw_reselect
;
struct
hard_iface
__rcu
*
primary_if
;
/* rcu protected pointer */
struct
hard_iface
__rcu
*
primary_if
;
/* rcu protected pointer */
struct
vis_info
*
my_vis_info
;
struct
vis_info
*
my_vis_info
;
struct
bat_algo_ops
*
bat_algo_ops
;
};
};
struct
socket_client
{
struct
socket_client
{
...
@@ -343,4 +345,23 @@ struct softif_neigh {
...
@@ -343,4 +345,23 @@ struct softif_neigh {
struct
rcu_head
rcu
;
struct
rcu_head
rcu
;
};
};
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 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_ */
net/batman-adv/unicast.c
View file @
3ccdca77
...
@@ -67,7 +67,7 @@ static struct sk_buff *frag_merge_packet(struct list_head *head,
...
@@ -67,7 +67,7 @@ static struct sk_buff *frag_merge_packet(struct list_head *head,
memmove
(
skb
->
data
+
uni_diff
,
skb
->
data
,
hdr_len
);
memmove
(
skb
->
data
+
uni_diff
,
skb
->
data
,
hdr_len
);
unicast_packet
=
(
struct
unicast_packet
*
)
skb_pull
(
skb
,
uni_diff
);
unicast_packet
=
(
struct
unicast_packet
*
)
skb_pull
(
skb
,
uni_diff
);
unicast_packet
->
packet_type
=
BAT_UNICAST
;
unicast_packet
->
header
.
packet_type
=
BAT_UNICAST
;
return
skb
;
return
skb
;
...
@@ -251,9 +251,9 @@ int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
...
@@ -251,9 +251,9 @@ int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
memcpy
(
frag1
,
&
tmp_uc
,
sizeof
(
tmp_uc
));
memcpy
(
frag1
,
&
tmp_uc
,
sizeof
(
tmp_uc
));
frag1
->
ttl
--
;
frag1
->
header
.
ttl
--
;
frag1
->
version
=
COMPAT_VERSION
;
frag1
->
header
.
version
=
COMPAT_VERSION
;
frag1
->
packet_type
=
BAT_UNICAST_FRAG
;
frag1
->
header
.
packet_type
=
BAT_UNICAST_FRAG
;
memcpy
(
frag1
->
orig
,
primary_if
->
net_dev
->
dev_addr
,
ETH_ALEN
);
memcpy
(
frag1
->
orig
,
primary_if
->
net_dev
->
dev_addr
,
ETH_ALEN
);
memcpy
(
frag2
,
frag1
,
sizeof
(
*
frag2
));
memcpy
(
frag2
,
frag1
,
sizeof
(
*
frag2
));
...
@@ -320,11 +320,11 @@ int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv)
...
@@ -320,11 +320,11 @@ int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv)
unicast_packet
=
(
struct
unicast_packet
*
)
skb
->
data
;
unicast_packet
=
(
struct
unicast_packet
*
)
skb
->
data
;
unicast_packet
->
version
=
COMPAT_VERSION
;
unicast_packet
->
header
.
version
=
COMPAT_VERSION
;
/* batman packet type: unicast */
/* batman packet type: unicast */
unicast_packet
->
packet_type
=
BAT_UNICAST
;
unicast_packet
->
header
.
packet_type
=
BAT_UNICAST
;
/* set unicast ttl */
/* set unicast ttl */
unicast_packet
->
ttl
=
TTL
;
unicast_packet
->
header
.
ttl
=
TTL
;
/* copy the destination for faster routing */
/* copy the destination for faster routing */
memcpy
(
unicast_packet
->
dest
,
orig_node
->
orig
,
ETH_ALEN
);
memcpy
(
unicast_packet
->
dest
,
orig_node
->
orig
,
ETH_ALEN
);
/* set the destination tt version number */
/* set the destination tt version number */
...
@@ -335,7 +335,7 @@ int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv)
...
@@ -335,7 +335,7 @@ int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv)
data_len
+
sizeof
(
*
unicast_packet
)
>
data_len
+
sizeof
(
*
unicast_packet
)
>
neigh_node
->
if_incoming
->
net_dev
->
mtu
)
{
neigh_node
->
if_incoming
->
net_dev
->
mtu
)
{
/* send frag skb decreases ttl */
/* send frag skb decreases ttl */
unicast_packet
->
ttl
++
;
unicast_packet
->
header
.
ttl
++
;
ret
=
frag_send_skb
(
skb
,
bat_priv
,
ret
=
frag_send_skb
(
skb
,
bat_priv
,
neigh_node
->
if_incoming
,
neigh_node
->
addr
);
neigh_node
->
if_incoming
,
neigh_node
->
addr
);
goto
out
;
goto
out
;
...
...
net/batman-adv/vis.c
View file @
3ccdca77
...
@@ -617,7 +617,7 @@ static int generate_vis_packet(struct bat_priv *bat_priv)
...
@@ -617,7 +617,7 @@ static int generate_vis_packet(struct bat_priv *bat_priv)
packet
->
vis_type
=
atomic_read
(
&
bat_priv
->
vis_mode
);
packet
->
vis_type
=
atomic_read
(
&
bat_priv
->
vis_mode
);
memcpy
(
packet
->
target_orig
,
broadcast_addr
,
ETH_ALEN
);
memcpy
(
packet
->
target_orig
,
broadcast_addr
,
ETH_ALEN
);
packet
->
ttl
=
TTL
;
packet
->
header
.
ttl
=
TTL
;
packet
->
seqno
=
htonl
(
ntohl
(
packet
->
seqno
)
+
1
);
packet
->
seqno
=
htonl
(
ntohl
(
packet
->
seqno
)
+
1
);
packet
->
entries
=
0
;
packet
->
entries
=
0
;
skb_trim
(
info
->
skb_packet
,
sizeof
(
*
packet
));
skb_trim
(
info
->
skb_packet
,
sizeof
(
*
packet
));
...
@@ -818,19 +818,19 @@ static void send_vis_packet(struct bat_priv *bat_priv, struct vis_info *info)
...
@@ -818,19 +818,19 @@ static void send_vis_packet(struct bat_priv *bat_priv, struct vis_info *info)
goto
out
;
goto
out
;
packet
=
(
struct
vis_packet
*
)
info
->
skb_packet
->
data
;
packet
=
(
struct
vis_packet
*
)
info
->
skb_packet
->
data
;
if
(
packet
->
ttl
<
2
)
{
if
(
packet
->
header
.
ttl
<
2
)
{
pr_debug
(
"Error - can't send vis packet: ttl exceeded
\n
"
);
pr_debug
(
"Error - can't send vis packet: ttl exceeded
\n
"
);
goto
out
;
goto
out
;
}
}
memcpy
(
packet
->
sender_orig
,
primary_if
->
net_dev
->
dev_addr
,
ETH_ALEN
);
memcpy
(
packet
->
sender_orig
,
primary_if
->
net_dev
->
dev_addr
,
ETH_ALEN
);
packet
->
ttl
--
;
packet
->
header
.
ttl
--
;
if
(
is_broadcast_ether_addr
(
packet
->
target_orig
))
if
(
is_broadcast_ether_addr
(
packet
->
target_orig
))
broadcast_vis_packet
(
bat_priv
,
info
);
broadcast_vis_packet
(
bat_priv
,
info
);
else
else
unicast_vis_packet
(
bat_priv
,
info
);
unicast_vis_packet
(
bat_priv
,
info
);
packet
->
ttl
++
;
/* restore TTL */
packet
->
header
.
ttl
++
;
/* restore TTL */
out:
out:
if
(
primary_if
)
if
(
primary_if
)
...
@@ -910,9 +910,9 @@ int vis_init(struct bat_priv *bat_priv)
...
@@ -910,9 +910,9 @@ int vis_init(struct bat_priv *bat_priv)
INIT_LIST_HEAD
(
&
bat_priv
->
my_vis_info
->
send_list
);
INIT_LIST_HEAD
(
&
bat_priv
->
my_vis_info
->
send_list
);
kref_init
(
&
bat_priv
->
my_vis_info
->
refcount
);
kref_init
(
&
bat_priv
->
my_vis_info
->
refcount
);
bat_priv
->
my_vis_info
->
bat_priv
=
bat_priv
;
bat_priv
->
my_vis_info
->
bat_priv
=
bat_priv
;
packet
->
version
=
COMPAT_VERSION
;
packet
->
header
.
version
=
COMPAT_VERSION
;
packet
->
packet_type
=
BAT_VIS
;
packet
->
header
.
packet_type
=
BAT_VIS
;
packet
->
ttl
=
TTL
;
packet
->
header
.
ttl
=
TTL
;
packet
->
seqno
=
0
;
packet
->
seqno
=
0
;
packet
->
entries
=
0
;
packet
->
entries
=
0
;
...
...
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