Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
kernel_linux
提交
3ccdca77
K
kernel_linux
项目概览
OpenHarmony
/
kernel_linux
上一次同步 3 年多
通知
13
Star
8
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kernel_linux
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
3ccdca77
编写于
2月 17, 2012
作者:
D
David S. Miller
浏览文件
操作
浏览文件
下载
差异文件
Merge tag 'batman-adv-for-davem' of
git://git.open-mesh.org/linux-merge
上级
71cc7c37
ea3d2fd1
变更
18
展开全部
隐藏空白更改
内联
并排
Showing
18 changed file
with
426 addition
and
235 deletion
+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
未找到文件。
Documentation/ABI/testing/sysfs-class-net-mesh
浏览文件 @
3ccdca77
...
...
@@ -65,6 +65,13 @@ Description:
Defines the penalty which will be applied to an
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
Date: May 2010
Contact: Marek Lindner <lindner_marek@yahoo.de>
...
...
net/batman-adv/bat_
ogm
.h
→
net/batman-adv/bat_
algo
.h
浏览文件 @
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
* modify it under the terms of version 2 of the GNU General Public
...
...
@@ -19,17 +19,9 @@
*
*/
#ifndef _NET_BATMAN_ADV_
OGM
_H_
#define _NET_BATMAN_ADV_
OGM
_H_
#ifndef _NET_BATMAN_ADV_
BAT_ALGO
_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
);
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_ */
#endif
/* _NET_BATMAN_ADV_BAT_ALGO_H_ */
net/batman-adv/bat_debugfs.c
浏览文件 @
3ccdca77
...
...
@@ -221,6 +221,11 @@ static void debug_log_cleanup(struct bat_priv *bat_priv)
}
#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
)
{
struct
net_device
*
net_dev
=
(
struct
net_device
*
)
inode
->
i_private
;
...
...
@@ -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
(
gateways
,
S_IRUGO
,
gateways_open
);
static
BAT_DEBUGINFO
(
softif_neigh
,
S_IRUGO
,
softif_neigh_open
);
...
...
@@ -293,9 +299,25 @@ static struct bat_debuginfo *mesh_debuginfos[] = {
void
debugfs_init
(
void
)
{
struct
bat_debuginfo
*
bat_debug
;
struct
dentry
*
file
;
bat_debugfs
=
debugfs_create_dir
(
DEBUGFS_BAT_SUBDIR
,
NULL
);
if
(
bat_debugfs
==
ERR_PTR
(
-
ENODEV
))
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
)
...
...
net/batman-adv/bat_iv_ogm.c
浏览文件 @
3ccdca77
此差异已折叠。
点击以展开。
net/batman-adv/bat_sysfs.c
浏览文件 @
3ccdca77
...
...
@@ -272,6 +272,13 @@ static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr,
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
)
{
struct
bat_priv
*
bat_priv
=
netdev_priv
(
net_dev
);
...
...
@@ -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
(
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
(
routing_algo
,
S_IRUGO
,
show_bat_algo
,
NULL
);
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
(
hop_penalty
,
S_IRUGO
|
S_IWUSR
,
0
,
TQ_MAX_VALUE
,
NULL
);
...
...
@@ -399,6 +407,7 @@ static struct bat_attribute *mesh_attrs[] = {
&
bat_attr_fragmentation
,
&
bat_attr_ap_isolation
,
&
bat_attr_vis_mode
,
&
bat_attr_routing_algo
,
&
bat_attr_gw_mode
,
&
bat_attr_orig_interval
,
&
bat_attr_hop_penalty
,
...
...
net/batman-adv/hard-interface.c
浏览文件 @
3ccdca77
...
...
@@ -28,7 +28,6 @@
#include "bat_sysfs.h"
#include "originator.h"
#include "hash.h"
#include "bat_ogm.h"
#include <linux/if_arp.h>
...
...
@@ -147,7 +146,7 @@ static void primary_if_select(struct bat_priv *bat_priv,
if
(
!
new_hard_iface
)
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
);
}
...
...
@@ -233,7 +232,7 @@ static void hardif_activate_interface(struct hard_iface *hard_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
;
/**
...
...
@@ -281,6 +280,14 @@ int hardif_enable_interface(struct hard_iface *hard_iface,
if
(
!
atomic_inc_not_zero
(
&
hard_iface
->
refcount
))
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
);
if
(
!
soft_iface
)
{
...
...
@@ -307,7 +314,7 @@ int hardif_enable_interface(struct hard_iface *hard_iface,
hard_iface
->
soft_iface
=
soft_iface
;
bat_priv
=
netdev_priv
(
hard_iface
->
soft_iface
);
bat_ogm_init
(
hard_iface
);
bat_
priv
->
bat_algo_ops
->
bat_
ogm_init
(
hard_iface
);
if
(
!
hard_iface
->
packet_buff
)
{
bat_err
(
hard_iface
->
soft_iface
,
"Can't add interface packet "
...
...
@@ -527,9 +534,10 @@ static int hard_if_event(struct notifier_block *this,
goto
hardif_put
;
check_known_mac_addr
(
hard_iface
->
net_dev
);
bat_ogm_update_mac
(
hard_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
);
if
(
!
primary_if
)
goto
hardif_put
;
...
...
@@ -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
;
if
(
batman_ogm_packet
->
version
!=
COMPAT_VERSION
)
{
if
(
batman_ogm_packet
->
header
.
version
!=
COMPAT_VERSION
)
{
bat_dbg
(
DBG_BATMAN
,
bat_priv
,
"Drop packet: incompatible batman version (%i)
\n
"
,
batman_ogm_packet
->
version
);
batman_ogm_packet
->
header
.
version
);
goto
err_free
;
}
/* all receive handlers return whether they received or reused
* the supplied skb. if not, we have to free the skb. */
switch
(
batman_ogm_packet
->
packet_type
)
{
switch
(
batman_ogm_packet
->
header
.
packet_type
)
{
/* batman originator packet */
case
BAT_OGM
:
ret
=
recv_bat_ogm_packet
(
skb
,
hard_iface
);
...
...
net/batman-adv/icmp_socket.c
浏览文件 @
3ccdca77
...
...
@@ -191,7 +191,7 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
goto
free_skb
;
}
if
(
icmp_packet
->
packet_type
!=
BAT_ICMP
)
{
if
(
icmp_packet
->
header
.
packet_type
!=
BAT_ICMP
)
{
bat_dbg
(
DBG_BATMAN
,
bat_priv
,
"Error - can't send packet from char device: "
"got bogus packet type (expected: BAT_ICMP)
\n
"
);
...
...
@@ -209,9 +209,9 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
icmp_packet
->
uid
=
socket_client
->
index
;
if
(
icmp_packet
->
version
!=
COMPAT_VERSION
)
{
if
(
icmp_packet
->
header
.
version
!=
COMPAT_VERSION
)
{
icmp_packet
->
msg_type
=
PARAMETER_PROBLEM
;
icmp_packet
->
version
=
COMPAT_VERSION
;
icmp_packet
->
header
.
version
=
COMPAT_VERSION
;
bat_socket_add_packet
(
socket_client
,
icmp_packet
,
packet_len
);
goto
free_skb
;
}
...
...
net/batman-adv/main.c
浏览文件 @
3ccdca77
...
...
@@ -32,11 +32,14 @@
#include "gateway_client.h"
#include "vis.h"
#include "hash.h"
#include "bat_algo.h"
/* List manipulations on hardif_list have to be rtnl_lock()'ed,
* list traversals just rcu-locked */
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
};
...
...
@@ -45,6 +48,9 @@ struct workqueue_struct *bat_event_workqueue;
static
int
__init
batman_init
(
void
)
{
INIT_LIST_HEAD
(
&
hardif_list
);
INIT_HLIST_HEAD
(
&
bat_algo_list
);
bat_iv_init
();
/* the name should not be longer than 10 chars - see
* http://lwn.net/Articles/23634/ */
...
...
@@ -170,9 +176,110 @@ int is_my_mac(const uint8_t *addr)
}
rcu_read_unlock
();
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_exit
(
batman_exit
);
...
...
net/batman-adv/main.h
浏览文件 @
3ccdca77
...
...
@@ -147,6 +147,7 @@ enum dbg_level {
#include <linux/seq_file.h>
#include "types.h"
extern
char
bat_routing_algo
[];
extern
struct
list_head
hardif_list
;
extern
unsigned
char
broadcast_addr
[];
...
...
@@ -157,6 +158,9 @@ void mesh_free(struct net_device *soft_iface);
void
inc_module_count
(
void
);
void
dec_module_count
(
void
);
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
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)
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)
...
...
net/batman-adv/originator.c
浏览文件 @
3ccdca77
...
...
@@ -219,6 +219,7 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, const uint8_t *addr)
/* extra reference for return */
atomic_set
(
&
orig_node
->
refcount
,
2
);
orig_node
->
tt_initialised
=
false
;
orig_node
->
tt_poss_change
=
false
;
orig_node
->
bat_priv
=
bat_priv
;
memcpy
(
orig_node
->
orig
,
addr
,
ETH_ALEN
);
...
...
net/batman-adv/packet.h
浏览文件 @
3ccdca77
...
...
@@ -90,10 +90,14 @@ enum tt_client_flags {
TT_CLIENT_PENDING
=
1
<<
10
};
struct
batman_
ogm_packet
{
struct
batman_
header
{
uint8_t
packet_type
;
uint8_t
version
;
/* batman version field */
uint8_t
ttl
;
}
__packed
;
struct
batman_ogm_packet
{
struct
batman_header
header
;
uint8_t
flags
;
/* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
uint32_t
seqno
;
uint8_t
orig
[
6
];
...
...
@@ -108,9 +112,7 @@ struct batman_ogm_packet {
#define BATMAN_OGM_LEN sizeof(struct batman_ogm_packet)
struct
icmp_packet
{
uint8_t
packet_type
;
uint8_t
version
;
/* batman version field */
uint8_t
ttl
;
struct
batman_header
header
;
uint8_t
msg_type
;
/* see ICMP message types above */
uint8_t
dst
[
6
];
uint8_t
orig
[
6
];
...
...
@@ -124,9 +126,7 @@ struct icmp_packet {
/* icmp_packet_rr must start with all fields from imcp_packet
* as this is assumed by code that handles ICMP packets */
struct
icmp_packet_rr
{
uint8_t
packet_type
;
uint8_t
version
;
/* batman version field */
uint8_t
ttl
;
struct
batman_header
header
;
uint8_t
msg_type
;
/* see ICMP message types above */
uint8_t
dst
[
6
];
uint8_t
orig
[
6
];
...
...
@@ -137,17 +137,13 @@ struct icmp_packet_rr {
}
__packed
;
struct
unicast_packet
{
uint8_t
packet_type
;
uint8_t
version
;
/* batman version field */
uint8_t
ttl
;
struct
batman_header
header
;
uint8_t
ttvn
;
/* destination translation table version number */
uint8_t
dest
[
6
];
}
__packed
;
struct
unicast_frag_packet
{
uint8_t
packet_type
;
uint8_t
version
;
/* batman version field */
uint8_t
ttl
;
struct
batman_header
header
;
uint8_t
ttvn
;
/* destination translation table version number */
uint8_t
dest
[
6
];
uint8_t
flags
;
...
...
@@ -157,18 +153,14 @@ struct unicast_frag_packet {
}
__packed
;
struct
bcast_packet
{
uint8_t
packet_type
;
uint8_t
version
;
/* batman version field */
uint8_t
ttl
;
struct
batman_header
header
;
uint8_t
reserved
;
uint32_t
seqno
;
uint8_t
orig
[
6
];
}
__packed
;
struct
vis_packet
{
uint8_t
packet_type
;
uint8_t
version
;
/* batman version field */
uint8_t
ttl
;
/* TTL */
struct
batman_header
header
;
uint8_t
vis_type
;
/* which type of vis-participant sent this? */
uint32_t
seqno
;
/* sequence number */
uint8_t
entries
;
/* number of entries behind this struct */
...
...
@@ -179,9 +171,7 @@ struct vis_packet {
}
__packed
;
struct
tt_query_packet
{
uint8_t
packet_type
;
uint8_t
version
;
/* batman version field */
uint8_t
ttl
;
struct
batman_header
header
;
/* the flag field is a combination of:
* - TT_REQUEST or TT_RESPONSE
* - TT_FULL_TABLE */
...
...
@@ -202,9 +192,7 @@ struct tt_query_packet {
}
__packed
;
struct
roam_adv_packet
{
uint8_t
packet_type
;
uint8_t
version
;
uint8_t
ttl
;
struct
batman_header
header
;
uint8_t
reserved
;
uint8_t
dst
[
ETH_ALEN
];
uint8_t
src
[
ETH_ALEN
];
...
...
net/batman-adv/routing.c
浏览文件 @
3ccdca77
...
...
@@ -29,7 +29,6 @@
#include "originator.h"
#include "vis.h"
#include "unicast.h"
#include "bat_ogm.h"
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,
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
;
/* 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)
if
(
skb_linearize
(
skb
)
<
0
)
return
NET_RX_DROP
;
ethhdr
=
(
struct
ethhdr
*
)
skb_mac_header
(
skb
);
bat_ogm_receive
(
ethhdr
,
skb
->
data
,
skb_headlen
(
skb
),
hard_iface
);
bat_priv
->
bat_algo_ops
->
bat_ogm_receive
(
hard_iface
,
skb
);
kfree_skb
(
skb
);
return
NET_RX_SUCCESS
;
...
...
@@ -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
->
orig
,
primary_if
->
net_dev
->
dev_addr
,
ETH_ALEN
);
icmp_packet
->
msg_type
=
ECHO_REPLY
;
icmp_packet
->
ttl
=
TTL
;
icmp_packet
->
header
.
ttl
=
TTL
;
send_skb_packet
(
skb
,
router
->
if_incoming
,
router
->
addr
);
ret
=
NET_RX_SUCCESS
;
...
...
@@ -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
->
orig
,
primary_if
->
net_dev
->
dev_addr
,
ETH_ALEN
);
icmp_packet
->
msg_type
=
TTL_EXCEEDED
;
icmp_packet
->
ttl
=
TTL
;
icmp_packet
->
header
.
ttl
=
TTL
;
send_skb_packet
(
skb
,
router
->
if_incoming
,
router
->
addr
);
ret
=
NET_RX_SUCCESS
;
...
...
@@ -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
);
/* TTL exceeded */
if
(
icmp_packet
->
ttl
<
2
)
if
(
icmp_packet
->
header
.
ttl
<
2
)
return
recv_icmp_ttl_exceeded
(
bat_priv
,
skb
);
/* get routing information */
...
...
@@ -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
;
/* decrement ttl */
icmp_packet
->
ttl
--
;
icmp_packet
->
header
.
ttl
--
;
/* route it */
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)
unicast_packet
=
(
struct
unicast_packet
*
)
skb
->
data
;
/* TTL exceeded */
if
(
unicast_packet
->
ttl
<
2
)
{
if
(
unicast_packet
->
header
.
ttl
<
2
)
{
pr_debug
(
"Warning - can't forward unicast packet from %pM to "
"%pM: ttl exceeded
\n
"
,
ethhdr
->
h_source
,
unicast_packet
->
dest
);
...
...
@@ -840,7 +838,7 @@ int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
unicast_packet
=
(
struct
unicast_packet
*
)
skb
->
data
;
if
(
unicast_packet
->
packet_type
==
BAT_UNICAST
&&
if
(
unicast_packet
->
header
.
packet_type
==
BAT_UNICAST
&&
atomic_read
(
&
bat_priv
->
fragmentation
)
&&
skb
->
len
>
neigh_node
->
if_incoming
->
net_dev
->
mtu
)
{
ret
=
frag_send_skb
(
skb
,
bat_priv
,
...
...
@@ -848,7 +846,7 @@ int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
goto
out
;
}
if
(
unicast_packet
->
packet_type
==
BAT_UNICAST_FRAG
&&
if
(
unicast_packet
->
header
.
packet_type
==
BAT_UNICAST_FRAG
&&
frag_can_reassemble
(
skb
,
neigh_node
->
if_incoming
->
net_dev
->
mtu
))
{
ret
=
frag_reassemble_skb
(
skb
,
bat_priv
,
&
new_skb
);
...
...
@@ -867,7 +865,7 @@ int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
}
/* decrement ttl */
unicast_packet
->
ttl
--
;
unicast_packet
->
header
.
ttl
--
;
/* route it */
send_skb_packet
(
skb
,
neigh_node
->
if_incoming
,
neigh_node
->
addr
);
...
...
@@ -1041,7 +1039,7 @@ int recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
if
(
is_my_mac
(
bcast_packet
->
orig
))
goto
out
;
if
(
bcast_packet
->
ttl
<
2
)
if
(
bcast_packet
->
header
.
ttl
<
2
)
goto
out
;
orig_node
=
orig_hash_find
(
bat_priv
,
bcast_packet
->
orig
);
...
...
net/batman-adv/send.c
浏览文件 @
3ccdca77
...
...
@@ -28,7 +28,6 @@
#include "vis.h"
#include "gateway_common.h"
#include "originator.h"
#include "bat_ogm.h"
static
void
send_outstanding_bcast_packet
(
struct
work_struct
*
work
);
...
...
@@ -168,7 +167,7 @@ void schedule_bat_ogm(struct hard_iface *hard_iface)
if
(
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
)
...
...
@@ -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 */
bcast_packet
=
(
struct
bcast_packet
*
)
newskb
->
data
;
bcast_packet
->
ttl
--
;
bcast_packet
->
header
.
ttl
--
;
skb_reset_mac_header
(
newskb
);
...
...
@@ -318,7 +317,7 @@ void send_outstanding_bat_ogm_packet(struct work_struct *work)
if
(
atomic_read
(
&
bat_priv
->
mesh_state
)
==
MESH_DEACTIVATING
)
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
...
...
net/batman-adv/soft-interface.c
浏览文件 @
3ccdca77
...
...
@@ -457,10 +457,10 @@ static void softif_batman_recv(struct sk_buff *skb, struct net_device *dev,
batman_ogm_packet
=
(
struct
batman_ogm_packet
*
)
(
skb
->
data
+
ETH_HLEN
);
if
(
batman_ogm_packet
->
version
!=
COMPAT_VERSION
)
if
(
batman_ogm_packet
->
header
.
version
!=
COMPAT_VERSION
)
goto
out
;
if
(
batman_ogm_packet
->
packet_type
!=
BAT_OGM
)
if
(
batman_ogm_packet
->
header
.
packet_type
!=
BAT_OGM
)
goto
out
;
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)
goto
dropped
;
bcast_packet
=
(
struct
bcast_packet
*
)
skb
->
data
;
bcast_packet
->
version
=
COMPAT_VERSION
;
bcast_packet
->
ttl
=
TTL
;
bcast_packet
->
header
.
version
=
COMPAT_VERSION
;
bcast_packet
->
header
.
ttl
=
TTL
;
/* 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
* this mac is known throughout the mesh */
...
...
@@ -725,8 +725,8 @@ void interface_rx(struct net_device *soft_iface,
skb_push
(
skb
,
hdr_size
);
unicast_packet
=
(
struct
unicast_packet
*
)
skb
->
data
;
if
((
unicast_packet
->
packet_type
!=
BAT_UNICAST
)
&&
(
unicast_packet
->
packet_type
!=
BAT_UNICAST_FRAG
))
if
((
unicast_packet
->
header
.
packet_type
!=
BAT_UNICAST
)
&&
(
unicast_packet
->
header
.
packet_type
!=
BAT_UNICAST_FRAG
))
goto
dropped
;
skb_reset_mac_header
(
skb
);
...
...
@@ -855,6 +855,10 @@ struct net_device *softif_create(const char *name)
bat_priv
->
primary_if
=
NULL
;
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
);
if
(
ret
<
0
)
goto
unreg_soft_iface
;
...
...
net/batman-adv/translation-table.c
浏览文件 @
3ccdca77
...
...
@@ -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
)
{
if
(
atomic_dec_and_test
(
&
tt_local_entry
->
common
.
refcount
))
...
...
@@ -420,8 +412,8 @@ static void tt_local_purge(struct bat_priv *bat_priv)
if
(
tt_local_entry
->
common
.
flags
&
TT_CLIENT_PENDING
)
continue
;
if
(
!
is_out_of_time
(
tt_local_entry
->
last_seen
,
TT_LOCAL_TIMEOUT
*
1000
))
if
(
!
has_timed_out
(
tt_local_entry
->
last_seen
,
TT_LOCAL_TIMEOUT
*
1000
))
continue
;
tt_local_set_pending
(
bat_priv
,
tt_local_entry
,
...
...
@@ -733,6 +725,7 @@ void tt_global_del_orig(struct bat_priv *bat_priv,
spin_unlock_bh
(
list_lock
);
}
atomic_set
(
&
orig_node
->
tt_size
,
0
);
orig_node
->
tt_initialised
=
false
;
}
static
void
tt_global_roam_purge
(
struct
bat_priv
*
bat_priv
)
...
...
@@ -757,8 +750,8 @@ static void tt_global_roam_purge(struct bat_priv *bat_priv)
common
);
if
(
!
(
tt_global_entry
->
common
.
flags
&
TT_CLIENT_ROAM
))
continue
;
if
(
!
is_out_of_time
(
tt_global_entry
->
roam_at
,
TT_CLIENT_ROAM_TIMEOUT
*
1000
))
if
(
!
has_timed_out
(
tt_global_entry
->
roam_at
,
TT_CLIENT_ROAM_TIMEOUT
*
1000
))
continue
;
bat_dbg
(
DBG_TT
,
bat_priv
,
"Deleting global "
...
...
@@ -977,8 +970,8 @@ static void tt_req_purge(struct bat_priv *bat_priv)
spin_lock_bh
(
&
bat_priv
->
tt_req_list_lock
);
list_for_each_entry_safe
(
node
,
safe
,
&
bat_priv
->
tt_req_list
,
list
)
{
if
(
is_out_of_time
(
node
->
issued_at
,
TT_REQUEST_TIMEOUT
*
1000
))
{
if
(
has_timed_out
(
node
->
issued_at
,
TT_REQUEST_TIMEOUT
*
1000
))
{
list_del
(
&
node
->
list
);
kfree
(
node
);
}
...
...
@@ -996,8 +989,8 @@ static struct tt_req_node *new_tt_req_node(struct bat_priv *bat_priv,
spin_lock_bh
(
&
bat_priv
->
tt_req_list_lock
);
list_for_each_entry
(
tt_req_node_tmp
,
&
bat_priv
->
tt_req_list
,
list
)
{
if
(
compare_eth
(
tt_req_node_tmp
,
orig_node
)
&&
!
is_out_of_time
(
tt_req_node_tmp
->
issued_at
,
TT_REQUEST_TIMEOUT
*
1000
))
!
has_timed_out
(
tt_req_node_tmp
->
issued_at
,
TT_REQUEST_TIMEOUT
*
1000
))
goto
unlock
;
}
...
...
@@ -1134,11 +1127,11 @@ static int send_tt_request(struct bat_priv *bat_priv,
tt_request
=
(
struct
tt_query_packet
*
)
skb_put
(
skb
,
sizeof
(
struct
tt_query_packet
));
tt_request
->
packet_type
=
BAT_TT_QUERY
;
tt_request
->
version
=
COMPAT_VERSION
;
tt_request
->
header
.
packet_type
=
BAT_TT_QUERY
;
tt_request
->
header
.
version
=
COMPAT_VERSION
;
memcpy
(
tt_request
->
src
,
primary_if
->
net_dev
->
dev_addr
,
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
->
tt_data
=
tt_crc
;
tt_request
->
flags
=
TT_REQUEST
;
...
...
@@ -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
->
packet_type
=
BAT_TT_QUERY
;
tt_response
->
version
=
COMPAT_VERSION
;
tt_response
->
ttl
=
TTL
;
tt_response
->
header
.
packet_type
=
BAT_TT_QUERY
;
tt_response
->
header
.
version
=
COMPAT_VERSION
;
tt_response
->
header
.
ttl
=
TTL
;
memcpy
(
tt_response
->
src
,
req_dst_orig_node
->
orig
,
ETH_ALEN
);
memcpy
(
tt_response
->
dst
,
tt_request
->
src
,
ETH_ALEN
);
tt_response
->
flags
=
TT_RESPONSE
;
...
...
@@ -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
->
packet_type
=
BAT_TT_QUERY
;
tt_response
->
version
=
COMPAT_VERSION
;
tt_response
->
ttl
=
TTL
;
tt_response
->
header
.
packet_type
=
BAT_TT_QUERY
;
tt_response
->
header
.
version
=
COMPAT_VERSION
;
tt_response
->
header
.
ttl
=
TTL
;
memcpy
(
tt_response
->
src
,
primary_if
->
net_dev
->
dev_addr
,
ETH_ALEN
);
memcpy
(
tt_response
->
dst
,
tt_request
->
src
,
ETH_ALEN
);
tt_response
->
flags
=
TT_RESPONSE
;
...
...
@@ -1450,6 +1443,7 @@ static void _tt_update_changes(struct bat_priv *bat_priv,
*/
return
;
}
orig_node
->
tt_initialised
=
true
;
}
static
void
tt_fill_gtable
(
struct
bat_priv
*
bat_priv
,
...
...
@@ -1589,8 +1583,8 @@ static void tt_roam_purge(struct bat_priv *bat_priv)
spin_lock_bh
(
&
bat_priv
->
tt_roam_list_lock
);
list_for_each_entry_safe
(
node
,
safe
,
&
bat_priv
->
tt_roam_list
,
list
)
{
if
(
!
is_out_of_time
(
node
->
first_time
,
ROAMING_MAX_TIME
*
1000
))
if
(
!
has_timed_out
(
node
->
first_time
,
ROAMING_MAX_TIME
*
1000
))
continue
;
list_del
(
&
node
->
list
);
...
...
@@ -1617,8 +1611,8 @@ static bool tt_check_roam_count(struct bat_priv *bat_priv,
if
(
!
compare_eth
(
tt_roam_node
->
addr
,
client
))
continue
;
if
(
is_out_of_time
(
tt_roam_node
->
first_time
,
ROAMING_MAX_TIME
*
1000
))
if
(
has_timed_out
(
tt_roam_node
->
first_time
,
ROAMING_MAX_TIME
*
1000
))
continue
;
if
(
!
atomic_dec_not_zero
(
&
tt_roam_node
->
counter
))
...
...
@@ -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
,
sizeof
(
struct
roam_adv_packet
));
roam_adv_packet
->
packet_type
=
BAT_ROAM_ADV
;
roam_adv_packet
->
version
=
COMPAT_VERSION
;
roam_adv_packet
->
ttl
=
TTL
;
roam_adv_packet
->
header
.
packet_type
=
BAT_ROAM_ADV
;
roam_adv_packet
->
header
.
version
=
COMPAT_VERSION
;
roam_adv_packet
->
header
.
ttl
=
TTL
;
primary_if
=
primary_if_get_selected
(
bat_priv
);
if
(
!
primary_if
)
goto
out
;
...
...
@@ -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
);
bool
full_table
=
true
;
/* the ttvn increased by one -> we can apply the attached changes */
if
(
ttvn
-
orig_ttvn
==
1
)
{
/* orig table not initialised AND first diff is in the OGM OR the ttvn
* 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
* because they have already been sent TT_OGM_APPEND_MAX times.
* 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,
}
else
{
/* if we missed more than one change or our tables are not
* 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:
bat_dbg
(
DBG_TT
,
bat_priv
,
"TT inconsistency for %pM. "
"Need to retrieve the correct information "
...
...
net/batman-adv/types.h
浏览文件 @
3ccdca77
...
...
@@ -81,6 +81,7 @@ struct orig_node {
int16_t
tt_buff_len
;
spinlock_t
tt_buff_lock
;
/* protects tt_buff */
atomic_t
tt_size
;
bool
tt_initialised
;
/* 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
* inspect every packet directed to it to check whether it is still
...
...
@@ -205,6 +206,7 @@ struct bat_priv {
atomic_t
gw_reselect
;
struct
hard_iface
__rcu
*
primary_if
;
/* rcu protected pointer */
struct
vis_info
*
my_vis_info
;
struct
bat_algo_ops
*
bat_algo_ops
;
};
struct
socket_client
{
...
...
@@ -343,4 +345,23 @@ struct softif_neigh {
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_ */
net/batman-adv/unicast.c
浏览文件 @
3ccdca77
...
...
@@ -67,7 +67,7 @@ static struct sk_buff *frag_merge_packet(struct list_head *head,
memmove
(
skb
->
data
+
uni_diff
,
skb
->
data
,
hdr_len
);
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
;
...
...
@@ -251,9 +251,9 @@ int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
memcpy
(
frag1
,
&
tmp_uc
,
sizeof
(
tmp_uc
));
frag1
->
ttl
--
;
frag1
->
version
=
COMPAT_VERSION
;
frag1
->
packet_type
=
BAT_UNICAST_FRAG
;
frag1
->
header
.
ttl
--
;
frag1
->
header
.
version
=
COMPAT_VERSION
;
frag1
->
header
.
packet_type
=
BAT_UNICAST_FRAG
;
memcpy
(
frag1
->
orig
,
primary_if
->
net_dev
->
dev_addr
,
ETH_ALEN
);
memcpy
(
frag2
,
frag1
,
sizeof
(
*
frag2
));
...
...
@@ -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
->
version
=
COMPAT_VERSION
;
unicast_packet
->
header
.
version
=
COMPAT_VERSION
;
/* batman packet type: unicast */
unicast_packet
->
packet_type
=
BAT_UNICAST
;
unicast_packet
->
header
.
packet_type
=
BAT_UNICAST
;
/* set unicast ttl */
unicast_packet
->
ttl
=
TTL
;
unicast_packet
->
header
.
ttl
=
TTL
;
/* copy the destination for faster routing */
memcpy
(
unicast_packet
->
dest
,
orig_node
->
orig
,
ETH_ALEN
);
/* set the destination tt version number */
...
...
@@ -335,7 +335,7 @@ int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv)
data_len
+
sizeof
(
*
unicast_packet
)
>
neigh_node
->
if_incoming
->
net_dev
->
mtu
)
{
/* send frag skb decreases ttl */
unicast_packet
->
ttl
++
;
unicast_packet
->
header
.
ttl
++
;
ret
=
frag_send_skb
(
skb
,
bat_priv
,
neigh_node
->
if_incoming
,
neigh_node
->
addr
);
goto
out
;
...
...
net/batman-adv/vis.c
浏览文件 @
3ccdca77
...
...
@@ -617,7 +617,7 @@ static int generate_vis_packet(struct bat_priv *bat_priv)
packet
->
vis_type
=
atomic_read
(
&
bat_priv
->
vis_mode
);
memcpy
(
packet
->
target_orig
,
broadcast_addr
,
ETH_ALEN
);
packet
->
ttl
=
TTL
;
packet
->
header
.
ttl
=
TTL
;
packet
->
seqno
=
htonl
(
ntohl
(
packet
->
seqno
)
+
1
);
packet
->
entries
=
0
;
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)
goto
out
;
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
"
);
goto
out
;
}
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
))
broadcast_vis_packet
(
bat_priv
,
info
);
else
unicast_vis_packet
(
bat_priv
,
info
);
packet
->
ttl
++
;
/* restore TTL */
packet
->
header
.
ttl
++
;
/* restore TTL */
out:
if
(
primary_if
)
...
...
@@ -910,9 +910,9 @@ int vis_init(struct bat_priv *bat_priv)
INIT_LIST_HEAD
(
&
bat_priv
->
my_vis_info
->
send_list
);
kref_init
(
&
bat_priv
->
my_vis_info
->
refcount
);
bat_priv
->
my_vis_info
->
bat_priv
=
bat_priv
;
packet
->
version
=
COMPAT_VERSION
;
packet
->
packet_type
=
BAT_VIS
;
packet
->
ttl
=
TTL
;
packet
->
header
.
version
=
COMPAT_VERSION
;
packet
->
header
.
packet_type
=
BAT_VIS
;
packet
->
header
.
ttl
=
TTL
;
packet
->
seqno
=
0
;
packet
->
entries
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录