Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
958a7586
cloud-kernel
项目概览
openanolis
/
cloud-kernel
大约 1 年 前同步成功
通知
158
Star
36
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
cloud-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
958a7586
编写于
5月 09, 2012
作者:
J
Jeff Kirsher
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
上级
eeb0d013
8feedbb4
变更
52
隐藏空白更改
内联
并排
Showing
52 changed file
with
735 addition
and
193 deletion
+735
-193
include/linux/etherdevice.h
include/linux/etherdevice.h
+12
-0
include/linux/netfilter/xt_HMARK.h
include/linux/netfilter/xt_HMARK.h
+45
-0
include/linux/netfilter/xt_hashlimit.h
include/linux/netfilter/xt_hashlimit.h
+9
-1
include/linux/netfilter_ipv6/ip6_tables.h
include/linux/netfilter_ipv6/ip6_tables.h
+6
-1
net/802/stp.c
net/802/stp.c
+1
-1
net/8021q/vlan.c
net/8021q/vlan.c
+5
-5
net/8021q/vlan_core.c
net/8021q/vlan_core.c
+1
-2
net/8021q/vlan_dev.c
net/8021q/vlan_dev.c
+5
-5
net/atm/lec.c
net/atm/lec.c
+3
-3
net/atm/mpc.c
net/atm/mpc.c
+1
-2
net/bluetooth/bnep/core.c
net/bluetooth/bnep/core.c
+3
-3
net/bridge/br_device.c
net/bridge/br_device.c
+1
-1
net/bridge/br_fdb.c
net/bridge/br_fdb.c
+7
-7
net/bridge/br_input.c
net/bridge/br_input.c
+1
-1
net/bridge/br_stp_bpdu.c
net/bridge/br_stp_bpdu.c
+1
-1
net/bridge/br_stp_if.c
net/bridge/br_stp_if.c
+5
-6
net/bridge/netfilter/ebt_stp.c
net/bridge/netfilter/ebt_stp.c
+2
-2
net/dsa/slave.c
net/dsa/slave.c
+5
-5
net/ipv6/netfilter/ip6_tables.c
net/ipv6/netfilter/ip6_tables.c
+31
-5
net/ipv6/netfilter/ip6t_ah.c
net/ipv6/netfilter/ip6t_ah.c
+2
-2
net/ipv6/netfilter/ip6t_frag.c
net/ipv6/netfilter/ip6t_frag.c
+2
-2
net/ipv6/netfilter/ip6t_hbh.c
net/ipv6/netfilter/ip6t_hbh.c
+2
-2
net/ipv6/netfilter/ip6t_rt.c
net/ipv6/netfilter/ip6t_rt.c
+2
-2
net/mac80211/cfg.c
net/mac80211/cfg.c
+1
-1
net/mac80211/ibss.c
net/mac80211/ibss.c
+6
-6
net/mac80211/ieee80211_i.h
net/mac80211/ieee80211_i.h
+1
-1
net/mac80211/iface.c
net/mac80211/iface.c
+1
-1
net/mac80211/mesh.c
net/mac80211/mesh.c
+2
-2
net/mac80211/mesh_hwmp.c
net/mac80211/mesh_hwmp.c
+7
-7
net/mac80211/mesh_pathtbl.c
net/mac80211/mesh_pathtbl.c
+6
-6
net/mac80211/mlme.c
net/mac80211/mlme.c
+13
-16
net/mac80211/rx.c
net/mac80211/rx.c
+18
-21
net/mac80211/scan.c
net/mac80211/scan.c
+1
-1
net/mac80211/sta_info.c
net/mac80211/sta_info.c
+4
-4
net/mac80211/sta_info.h
net/mac80211/sta_info.h
+1
-1
net/mac80211/status.c
net/mac80211/status.c
+1
-1
net/mac80211/tx.c
net/mac80211/tx.c
+5
-6
net/netfilter/Kconfig
net/netfilter/Kconfig
+15
-0
net/netfilter/Makefile
net/netfilter/Makefile
+1
-0
net/netfilter/ipset/ip_set_bitmap_ipmac.c
net/netfilter/ipset/ip_set_bitmap_ipmac.c
+2
-2
net/netfilter/xt_HMARK.c
net/netfilter/xt_HMARK.c
+362
-0
net/netfilter/xt_TPROXY.c
net/netfilter/xt_TPROXY.c
+2
-2
net/netfilter/xt_hashlimit.c
net/netfilter/xt_hashlimit.c
+105
-24
net/netfilter/xt_limit.c
net/netfilter/xt_limit.c
+2
-3
net/netfilter/xt_mac.c
net/netfilter/xt_mac.c
+1
-1
net/netfilter/xt_socket.c
net/netfilter/xt_socket.c
+2
-2
net/wireless/ibss.c
net/wireless/ibss.c
+1
-1
net/wireless/mlme.c
net/wireless/mlme.c
+15
-16
net/wireless/scan.c
net/wireless/scan.c
+1
-1
net/wireless/util.c
net/wireless/util.c
+5
-6
net/wireless/wext-sme.c
net/wireless/wext-sme.c
+1
-1
net/wireless/wext-spy.c
net/wireless/wext-spy.c
+1
-1
未找到文件。
include/linux/etherdevice.h
浏览文件 @
958a7586
...
...
@@ -171,6 +171,18 @@ static inline unsigned compare_ether_addr(const u8 *addr1, const u8 *addr2)
return
((
a
[
0
]
^
b
[
0
])
|
(
a
[
1
]
^
b
[
1
])
|
(
a
[
2
]
^
b
[
2
]))
!=
0
;
}
/**
* ether_addr_equal - Compare two Ethernet addresses
* @addr1: Pointer to a six-byte array containing the Ethernet address
* @addr2: Pointer other six-byte array containing the Ethernet address
*
* Compare two ethernet addresses, returns true if equal
*/
static
inline
bool
ether_addr_equal
(
const
u8
*
addr1
,
const
u8
*
addr2
)
{
return
!
compare_ether_addr
(
addr1
,
addr2
);
}
static
inline
unsigned
long
zap_last_2bytes
(
unsigned
long
value
)
{
#ifdef __BIG_ENDIAN
...
...
include/linux/netfilter/xt_HMARK.h
0 → 100644
浏览文件 @
958a7586
#ifndef XT_HMARK_H_
#define XT_HMARK_H_
#include <linux/types.h>
enum
{
XT_HMARK_SADDR_MASK
,
XT_HMARK_DADDR_MASK
,
XT_HMARK_SPI
,
XT_HMARK_SPI_MASK
,
XT_HMARK_SPORT
,
XT_HMARK_DPORT
,
XT_HMARK_SPORT_MASK
,
XT_HMARK_DPORT_MASK
,
XT_HMARK_PROTO_MASK
,
XT_HMARK_RND
,
XT_HMARK_MODULUS
,
XT_HMARK_OFFSET
,
XT_HMARK_CT
,
XT_HMARK_METHOD_L3
,
XT_HMARK_METHOD_L3_4
,
};
#define XT_HMARK_FLAG(flag) (1 << flag)
union
hmark_ports
{
struct
{
__u16
src
;
__u16
dst
;
}
p16
;
__u32
v32
;
};
struct
xt_hmark_info
{
union
nf_inet_addr
src_mask
;
union
nf_inet_addr
dst_mask
;
union
hmark_ports
port_mask
;
union
hmark_ports
port_set
;
__u32
flags
;
__u16
proto_mask
;
__u32
hashrnd
;
__u32
hmodulus
;
__u32
hoffset
;
/* Mark offset to start from */
};
#endif
/* XT_HMARK_H_ */
include/linux/netfilter/xt_hashlimit.h
浏览文件 @
958a7586
...
...
@@ -6,7 +6,11 @@
/* timings are in milliseconds. */
#define XT_HASHLIMIT_SCALE 10000
/* 1/10,000 sec period => max of 10,000/sec. Min rate is then 429490
seconds, or one every 59 hours. */
* seconds, or one packet every 59 hours.
*/
/* packet length accounting is done in 16-byte steps */
#define XT_HASHLIMIT_BYTE_SHIFT 4
/* details of this structure hidden by the implementation */
struct
xt_hashlimit_htable
;
...
...
@@ -17,6 +21,10 @@ enum {
XT_HASHLIMIT_HASH_SIP
=
1
<<
2
,
XT_HASHLIMIT_HASH_SPT
=
1
<<
3
,
XT_HASHLIMIT_INVERT
=
1
<<
4
,
XT_HASHLIMIT_BYTES
=
1
<<
5
,
#ifdef __KERNEL__
XT_HASHLIMIT_MAX
=
1
<<
6
,
#endif
};
struct
hashlimit_cfg
{
...
...
include/linux/netfilter_ipv6/ip6_tables.h
浏览文件 @
958a7586
...
...
@@ -298,9 +298,14 @@ ip6t_ext_hdr(u8 nexthdr)
(
nexthdr
==
IPPROTO_DSTOPTS
);
}
enum
{
IP6T_FH_F_FRAG
=
(
1
<<
0
),
IP6T_FH_F_AUTH
=
(
1
<<
1
),
};
/* find specified header and get offset to it */
extern
int
ipv6_find_hdr
(
const
struct
sk_buff
*
skb
,
unsigned
int
*
offset
,
int
target
,
unsigned
short
*
fragoff
);
int
target
,
unsigned
short
*
fragoff
,
int
*
fragflg
);
#ifdef CONFIG_COMPAT
#include <net/compat.h>
...
...
net/802/stp.c
浏览文件 @
958a7586
...
...
@@ -46,7 +46,7 @@ static int stp_pdu_rcv(struct sk_buff *skb, struct net_device *dev,
proto
=
rcu_dereference
(
garp_protos
[
eh
->
h_dest
[
5
]
-
GARP_ADDR_MIN
]);
if
(
proto
&&
compare_ether_addr
(
eh
->
h_dest
,
proto
->
group_address
))
!
ether_addr_equal
(
eh
->
h_dest
,
proto
->
group_address
))
goto
err
;
}
else
proto
=
rcu_dereference
(
stp_proto
);
...
...
net/8021q/vlan.c
浏览文件 @
958a7586
...
...
@@ -266,19 +266,19 @@ static void vlan_sync_address(struct net_device *dev,
struct
vlan_dev_priv
*
vlan
=
vlan_dev_priv
(
vlandev
);
/* May be called without an actual change */
if
(
!
compare_ether_addr
(
vlan
->
real_dev_addr
,
dev
->
dev_addr
))
if
(
ether_addr_equal
(
vlan
->
real_dev_addr
,
dev
->
dev_addr
))
return
;
/* vlan address was different from the old address and is equal to
* the new address */
if
(
compare_ether_addr
(
vlandev
->
dev_addr
,
vlan
->
real_dev_addr
)
&&
!
compare_ether_addr
(
vlandev
->
dev_addr
,
dev
->
dev_addr
))
if
(
!
ether_addr_equal
(
vlandev
->
dev_addr
,
vlan
->
real_dev_addr
)
&&
ether_addr_equal
(
vlandev
->
dev_addr
,
dev
->
dev_addr
))
dev_uc_del
(
dev
,
vlandev
->
dev_addr
);
/* vlan address was equal to the old address and is different from
* the new address */
if
(
!
compare_ether_addr
(
vlandev
->
dev_addr
,
vlan
->
real_dev_addr
)
&&
compare_ether_addr
(
vlandev
->
dev_addr
,
dev
->
dev_addr
))
if
(
ether_addr_equal
(
vlandev
->
dev_addr
,
vlan
->
real_dev_addr
)
&&
!
ether_addr_equal
(
vlandev
->
dev_addr
,
dev
->
dev_addr
))
dev_uc_add
(
dev
,
vlandev
->
dev_addr
);
memcpy
(
vlan
->
real_dev_addr
,
dev
->
dev_addr
,
ETH_ALEN
);
...
...
net/8021q/vlan_core.c
浏览文件 @
958a7586
...
...
@@ -31,8 +31,7 @@ bool vlan_do_receive(struct sk_buff **skbp, bool last_handler)
/* Our lower layer thinks this is not local, let's make sure.
* This allows the VLAN to have a different MAC than the
* underlying device, and still route correctly. */
if
(
!
compare_ether_addr
(
eth_hdr
(
skb
)
->
h_dest
,
vlan_dev
->
dev_addr
))
if
(
ether_addr_equal
(
eth_hdr
(
skb
)
->
h_dest
,
vlan_dev
->
dev_addr
))
skb
->
pkt_type
=
PACKET_HOST
;
}
...
...
net/8021q/vlan_dev.c
浏览文件 @
958a7586
...
...
@@ -277,7 +277,7 @@ static int vlan_dev_open(struct net_device *dev)
!
(
vlan
->
flags
&
VLAN_FLAG_LOOSE_BINDING
))
return
-
ENETDOWN
;
if
(
compare_ether_addr
(
dev
->
dev_addr
,
real_dev
->
dev_addr
))
{
if
(
!
ether_addr_equal
(
dev
->
dev_addr
,
real_dev
->
dev_addr
))
{
err
=
dev_uc_add
(
real_dev
,
dev
->
dev_addr
);
if
(
err
<
0
)
goto
out
;
...
...
@@ -307,7 +307,7 @@ static int vlan_dev_open(struct net_device *dev)
if
(
dev
->
flags
&
IFF_ALLMULTI
)
dev_set_allmulti
(
real_dev
,
-
1
);
del_unicast:
if
(
compare_ether_addr
(
dev
->
dev_addr
,
real_dev
->
dev_addr
))
if
(
!
ether_addr_equal
(
dev
->
dev_addr
,
real_dev
->
dev_addr
))
dev_uc_del
(
real_dev
,
dev
->
dev_addr
);
out:
netif_carrier_off
(
dev
);
...
...
@@ -326,7 +326,7 @@ static int vlan_dev_stop(struct net_device *dev)
if
(
dev
->
flags
&
IFF_PROMISC
)
dev_set_promiscuity
(
real_dev
,
-
1
);
if
(
compare_ether_addr
(
dev
->
dev_addr
,
real_dev
->
dev_addr
))
if
(
!
ether_addr_equal
(
dev
->
dev_addr
,
real_dev
->
dev_addr
))
dev_uc_del
(
real_dev
,
dev
->
dev_addr
);
netif_carrier_off
(
dev
);
...
...
@@ -345,13 +345,13 @@ static int vlan_dev_set_mac_address(struct net_device *dev, void *p)
if
(
!
(
dev
->
flags
&
IFF_UP
))
goto
out
;
if
(
compare_ether_addr
(
addr
->
sa_data
,
real_dev
->
dev_addr
))
{
if
(
!
ether_addr_equal
(
addr
->
sa_data
,
real_dev
->
dev_addr
))
{
err
=
dev_uc_add
(
real_dev
,
addr
->
sa_data
);
if
(
err
<
0
)
return
err
;
}
if
(
compare_ether_addr
(
dev
->
dev_addr
,
real_dev
->
dev_addr
))
if
(
!
ether_addr_equal
(
dev
->
dev_addr
,
real_dev
->
dev_addr
))
dev_uc_del
(
real_dev
,
dev
->
dev_addr
);
out:
...
...
net/atm/lec.c
浏览文件 @
958a7586
...
...
@@ -1255,7 +1255,7 @@ static int lane2_associate_req(struct net_device *dev, const u8 *lan_dst,
struct
sk_buff
*
skb
;
struct
lec_priv
*
priv
=
netdev_priv
(
dev
);
if
(
compare_ether_addr
(
lan_dst
,
dev
->
dev_addr
))
if
(
!
ether_addr_equal
(
lan_dst
,
dev
->
dev_addr
))
return
0
;
/* not our mac address */
kfree
(
priv
->
tlvs
);
/* NULL if there was no previous association */
...
...
@@ -1662,7 +1662,7 @@ static struct lec_arp_table *lec_arp_find(struct lec_priv *priv,
head
=
&
priv
->
lec_arp_tables
[
HASH
(
mac_addr
[
ETH_ALEN
-
1
])];
hlist_for_each_entry
(
entry
,
node
,
head
,
next
)
{
if
(
!
compare_ether_addr
(
mac_addr
,
entry
->
mac_addr
))
if
(
ether_addr_equal
(
mac_addr
,
entry
->
mac_addr
))
return
entry
;
}
return
NULL
;
...
...
@@ -1849,7 +1849,7 @@ static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv,
case
1
:
return
priv
->
mcast_vcc
;
case
2
:
/* LANE2 wants arp for multicast addresses */
if
(
!
compare_ether_addr
(
mac_to_find
,
bus_mac
))
if
(
ether_addr_equal
(
mac_to_find
,
bus_mac
))
return
priv
->
mcast_vcc
;
break
;
default:
...
...
net/atm/mpc.c
浏览文件 @
958a7586
...
...
@@ -592,8 +592,7 @@ static netdev_tx_t mpc_send_packet(struct sk_buff *skb,
goto
non_ip
;
while
(
i
<
mpc
->
number_of_mps_macs
)
{
if
(
!
compare_ether_addr
(
eth
->
h_dest
,
(
mpc
->
mps_macs
+
i
*
ETH_ALEN
)))
if
(
ether_addr_equal
(
eth
->
h_dest
,
mpc
->
mps_macs
+
i
*
ETH_ALEN
))
if
(
send_via_shortcut
(
skb
,
mpc
)
==
0
)
/* try shortcut */
return
NETDEV_TX_OK
;
i
++
;
...
...
net/bluetooth/bnep/core.c
浏览文件 @
958a7586
...
...
@@ -69,7 +69,7 @@ static struct bnep_session *__bnep_get_session(u8 *dst)
BT_DBG
(
""
);
list_for_each_entry
(
s
,
&
bnep_session_list
,
list
)
if
(
!
compare_ether_addr
(
dst
,
s
->
eh
.
h_source
))
if
(
ether_addr_equal
(
dst
,
s
->
eh
.
h_source
))
return
s
;
return
NULL
;
...
...
@@ -422,10 +422,10 @@ static inline int bnep_tx_frame(struct bnep_session *s, struct sk_buff *skb)
iv
[
il
++
]
=
(
struct
kvec
)
{
&
type
,
1
};
len
++
;
if
(
compress_src
&&
!
compare_ether_addr
(
eh
->
h_dest
,
s
->
eh
.
h_source
))
if
(
compress_src
&&
ether_addr_equal
(
eh
->
h_dest
,
s
->
eh
.
h_source
))
type
|=
0x01
;
if
(
compress_dst
&&
!
compare_ether_addr
(
eh
->
h_source
,
s
->
eh
.
h_dest
))
if
(
compress_dst
&&
ether_addr_equal
(
eh
->
h_source
,
s
->
eh
.
h_dest
))
type
|=
0x02
;
if
(
type
)
...
...
net/bridge/br_device.c
浏览文件 @
958a7586
...
...
@@ -170,7 +170,7 @@ static int br_set_mac_address(struct net_device *dev, void *p)
return
-
EADDRNOTAVAIL
;
spin_lock_bh
(
&
br
->
lock
);
if
(
compare_ether_addr
(
dev
->
dev_addr
,
addr
->
sa_data
))
{
if
(
!
ether_addr_equal
(
dev
->
dev_addr
,
addr
->
sa_data
))
{
dev
->
addr_assign_type
&=
~
NET_ADDR_RANDOM
;
memcpy
(
dev
->
dev_addr
,
addr
->
sa_data
,
ETH_ALEN
);
br_fdb_change_mac_address
(
br
,
addr
->
sa_data
);
...
...
net/bridge/br_fdb.c
浏览文件 @
958a7586
...
...
@@ -107,8 +107,8 @@ void br_fdb_changeaddr(struct net_bridge_port *p, const unsigned char *newaddr)
struct
net_bridge_port
*
op
;
list_for_each_entry
(
op
,
&
br
->
port_list
,
list
)
{
if
(
op
!=
p
&&
!
compare_ether_addr
(
op
->
dev
->
dev_addr
,
f
->
addr
.
addr
))
{
ether_addr_equal
(
op
->
dev
->
dev_addr
,
f
->
addr
.
addr
))
{
f
->
dst
=
op
;
goto
insert
;
}
...
...
@@ -214,8 +214,8 @@ void br_fdb_delete_by_port(struct net_bridge *br,
struct
net_bridge_port
*
op
;
list_for_each_entry
(
op
,
&
br
->
port_list
,
list
)
{
if
(
op
!=
p
&&
!
compare_ether_addr
(
op
->
dev
->
dev_addr
,
f
->
addr
.
addr
))
{
ether_addr_equal
(
op
->
dev
->
dev_addr
,
f
->
addr
.
addr
))
{
f
->
dst
=
op
;
goto
skip_delete
;
}
...
...
@@ -237,7 +237,7 @@ struct net_bridge_fdb_entry *__br_fdb_get(struct net_bridge *br,
struct
net_bridge_fdb_entry
*
fdb
;
hlist_for_each_entry_rcu
(
fdb
,
h
,
&
br
->
hash
[
br_mac_hash
(
addr
)],
hlist
)
{
if
(
!
compare_ether_addr
(
fdb
->
addr
.
addr
,
addr
))
{
if
(
ether_addr_equal
(
fdb
->
addr
.
addr
,
addr
))
{
if
(
unlikely
(
has_expired
(
br
,
fdb
)))
break
;
return
fdb
;
...
...
@@ -331,7 +331,7 @@ static struct net_bridge_fdb_entry *fdb_find(struct hlist_head *head,
struct
net_bridge_fdb_entry
*
fdb
;
hlist_for_each_entry
(
fdb
,
h
,
head
,
hlist
)
{
if
(
!
compare_ether_addr
(
fdb
->
addr
.
addr
,
addr
))
if
(
ether_addr_equal
(
fdb
->
addr
.
addr
,
addr
))
return
fdb
;
}
return
NULL
;
...
...
@@ -344,7 +344,7 @@ static struct net_bridge_fdb_entry *fdb_find_rcu(struct hlist_head *head,
struct
net_bridge_fdb_entry
*
fdb
;
hlist_for_each_entry_rcu
(
fdb
,
h
,
head
,
hlist
)
{
if
(
!
compare_ether_addr
(
fdb
->
addr
.
addr
,
addr
))
if
(
ether_addr_equal
(
fdb
->
addr
.
addr
,
addr
))
return
fdb
;
}
return
NULL
;
...
...
net/bridge/br_input.c
浏览文件 @
958a7586
...
...
@@ -216,7 +216,7 @@ rx_handler_result_t br_handle_frame(struct sk_buff **pskb)
}
/* fall through */
case
BR_STATE_LEARNING
:
if
(
!
compare_ether_addr
(
p
->
br
->
dev
->
dev_addr
,
dest
))
if
(
ether_addr_equal
(
p
->
br
->
dev
->
dev_addr
,
dest
))
skb
->
pkt_type
=
PACKET_HOST
;
NF_HOOK
(
NFPROTO_BRIDGE
,
NF_BR_PRE_ROUTING
,
skb
,
skb
->
dev
,
NULL
,
...
...
net/bridge/br_stp_bpdu.c
浏览文件 @
958a7586
...
...
@@ -167,7 +167,7 @@ void br_stp_rcv(const struct stp_proto *proto, struct sk_buff *skb,
if
(
p
->
state
==
BR_STATE_DISABLED
)
goto
out
;
if
(
compare_ether_addr
(
dest
,
br
->
group_addr
)
!=
0
)
if
(
!
ether_addr_equal
(
dest
,
br
->
group_addr
)
)
goto
out
;
buf
=
skb_pull
(
skb
,
3
);
...
...
net/bridge/br_stp_if.c
浏览文件 @
958a7586
...
...
@@ -178,7 +178,7 @@ void br_stp_set_enabled(struct net_bridge *br, unsigned long val)
/* called under bridge lock */
void
br_stp_change_bridge_id
(
struct
net_bridge
*
br
,
const
unsigned
char
*
addr
)
{
/* should be aligned on 2 bytes for
compare_ether_addr
() */
/* should be aligned on 2 bytes for
ether_addr_equal
() */
unsigned
short
oldaddr_aligned
[
ETH_ALEN
>>
1
];
unsigned
char
*
oldaddr
=
(
unsigned
char
*
)
oldaddr_aligned
;
struct
net_bridge_port
*
p
;
...
...
@@ -191,12 +191,11 @@ void br_stp_change_bridge_id(struct net_bridge *br, const unsigned char *addr)
memcpy
(
br
->
dev
->
dev_addr
,
addr
,
ETH_ALEN
);
list_for_each_entry
(
p
,
&
br
->
port_list
,
list
)
{
if
(
!
compare_ether_addr
(
p
->
designated_bridge
.
addr
,
oldaddr
))
if
(
ether_addr_equal
(
p
->
designated_bridge
.
addr
,
oldaddr
))
memcpy
(
p
->
designated_bridge
.
addr
,
addr
,
ETH_ALEN
);
if
(
!
compare_ether_addr
(
p
->
designated_root
.
addr
,
oldaddr
))
if
(
ether_addr_equal
(
p
->
designated_root
.
addr
,
oldaddr
))
memcpy
(
p
->
designated_root
.
addr
,
addr
,
ETH_ALEN
);
}
br_configuration_update
(
br
);
...
...
@@ -205,7 +204,7 @@ void br_stp_change_bridge_id(struct net_bridge *br, const unsigned char *addr)
br_become_root_bridge
(
br
);
}
/* should be aligned on 2 bytes for
compare_ether_addr
() */
/* should be aligned on 2 bytes for
ether_addr_equal
() */
static
const
unsigned
short
br_mac_zero_aligned
[
ETH_ALEN
>>
1
];
/* called under bridge lock */
...
...
@@ -227,7 +226,7 @@ bool br_stp_recalculate_bridge_id(struct net_bridge *br)
}
if
(
compare_ether_addr
(
br
->
bridge_id
.
addr
,
addr
)
==
0
)
if
(
ether_addr_equal
(
br
->
bridge_id
.
addr
,
addr
)
)
return
false
;
/* no change */
br_stp_change_bridge_id
(
br
,
addr
);
...
...
net/bridge/netfilter/ebt_stp.c
浏览文件 @
958a7586
...
...
@@ -164,8 +164,8 @@ static int ebt_stp_mt_check(const struct xt_mtchk_param *par)
!
(
info
->
bitmask
&
EBT_STP_MASK
))
return
-
EINVAL
;
/* Make sure the match only receives stp frames */
if
(
compare_ether_addr
(
e
->
destmac
,
bridge_ula
)
||
compare_ether_addr
(
e
->
destmsk
,
msk
)
||
!
(
e
->
bitmask
&
EBT_DESTMAC
))
if
(
!
ether_addr_equal
(
e
->
destmac
,
bridge_ula
)
||
!
ether_addr_equal
(
e
->
destmsk
,
msk
)
||
!
(
e
->
bitmask
&
EBT_DESTMAC
))
return
-
EINVAL
;
return
0
;
...
...
net/dsa/slave.c
浏览文件 @
958a7586
...
...
@@ -66,7 +66,7 @@ static int dsa_slave_open(struct net_device *dev)
if
(
!
(
master
->
flags
&
IFF_UP
))
return
-
ENETDOWN
;
if
(
compare_ether_addr
(
dev
->
dev_addr
,
master
->
dev_addr
))
{
if
(
!
ether_addr_equal
(
dev
->
dev_addr
,
master
->
dev_addr
))
{
err
=
dev_uc_add
(
master
,
dev
->
dev_addr
);
if
(
err
<
0
)
goto
out
;
...
...
@@ -89,7 +89,7 @@ static int dsa_slave_open(struct net_device *dev)
if
(
dev
->
flags
&
IFF_ALLMULTI
)
dev_set_allmulti
(
master
,
-
1
);
del_unicast:
if
(
compare_ether_addr
(
dev
->
dev_addr
,
master
->
dev_addr
))
if
(
!
ether_addr_equal
(
dev
->
dev_addr
,
master
->
dev_addr
))
dev_uc_del
(
master
,
dev
->
dev_addr
);
out:
return
err
;
...
...
@@ -107,7 +107,7 @@ static int dsa_slave_close(struct net_device *dev)
if
(
dev
->
flags
&
IFF_PROMISC
)
dev_set_promiscuity
(
master
,
-
1
);
if
(
compare_ether_addr
(
dev
->
dev_addr
,
master
->
dev_addr
))
if
(
!
ether_addr_equal
(
dev
->
dev_addr
,
master
->
dev_addr
))
dev_uc_del
(
master
,
dev
->
dev_addr
);
return
0
;
...
...
@@ -146,13 +146,13 @@ static int dsa_slave_set_mac_address(struct net_device *dev, void *a)
if
(
!
(
dev
->
flags
&
IFF_UP
))
goto
out
;
if
(
compare_ether_addr
(
addr
->
sa_data
,
master
->
dev_addr
))
{
if
(
!
ether_addr_equal
(
addr
->
sa_data
,
master
->
dev_addr
))
{
err
=
dev_uc_add
(
master
,
addr
->
sa_data
);
if
(
err
<
0
)
return
err
;
}
if
(
compare_ether_addr
(
dev
->
dev_addr
,
master
->
dev_addr
))
if
(
!
ether_addr_equal
(
dev
->
dev_addr
,
master
->
dev_addr
))
dev_uc_del
(
master
,
dev
->
dev_addr
);
out:
...
...
net/ipv6/netfilter/ip6_tables.c
浏览文件 @
958a7586
...
...
@@ -133,7 +133,7 @@ ip6_packet_match(const struct sk_buff *skb,
int
protohdr
;
unsigned
short
_frag_off
;
protohdr
=
ipv6_find_hdr
(
skb
,
protoff
,
-
1
,
&
_frag_off
);
protohdr
=
ipv6_find_hdr
(
skb
,
protoff
,
-
1
,
&
_frag_off
,
NULL
);
if
(
protohdr
<
0
)
{
if
(
_frag_off
==
0
)
*
hotdrop
=
true
;
...
...
@@ -362,6 +362,7 @@ ip6t_do_table(struct sk_buff *skb,
const
struct
xt_entry_match
*
ematch
;
IP_NF_ASSERT
(
e
);
acpar
.
thoff
=
0
;
if
(
!
ip6_packet_match
(
skb
,
indev
,
outdev
,
&
e
->
ipv6
,
&
acpar
.
thoff
,
&
acpar
.
fragoff
,
&
acpar
.
hotdrop
))
{
no_match:
...
...
@@ -2278,6 +2279,10 @@ static void __exit ip6_tables_fini(void)
* if target < 0. "last header" is transport protocol header, ESP, or
* "No next header".
*
* Note that *offset is used as input/output parameter. an if it is not zero,
* then it must be a valid offset to an inner IPv6 header. This can be used
* to explore inner IPv6 header, eg. ICMPv6 error messages.
*
* If target header is found, its offset is set in *offset and return protocol
* number. Otherwise, return -1.
*
...
...
@@ -2289,17 +2294,33 @@ static void __exit ip6_tables_fini(void)
* *offset is meaningless and fragment offset is stored in *fragoff if fragoff
* isn't NULL.
*
* if flags is not NULL and it's a fragment, then the frag flag IP6T_FH_F_FRAG
* will be set. If it's an AH header, the IP6T_FH_F_AUTH flag is set and
* target < 0, then this function will stop at the AH header.
*/
int
ipv6_find_hdr
(
const
struct
sk_buff
*
skb
,
unsigned
int
*
offset
,
int
target
,
unsigned
short
*
fragoff
)
int
target
,
unsigned
short
*
fragoff
,
int
*
flags
)
{
unsigned
int
start
=
skb_network_offset
(
skb
)
+
sizeof
(
struct
ipv6hdr
);
u8
nexthdr
=
ipv6_hdr
(
skb
)
->
nexthdr
;
unsigned
int
len
=
skb
->
len
-
start
;
unsigned
int
len
;
if
(
fragoff
)
*
fragoff
=
0
;
if
(
*
offset
)
{
struct
ipv6hdr
_ip6
,
*
ip6
;
ip6
=
skb_header_pointer
(
skb
,
*
offset
,
sizeof
(
_ip6
),
&
_ip6
);
if
(
!
ip6
||
(
ip6
->
version
!=
6
))
{
printk
(
KERN_ERR
"IPv6 header not found
\n
"
);
return
-
EBADMSG
;
}
start
=
*
offset
+
sizeof
(
struct
ipv6hdr
);
nexthdr
=
ip6
->
nexthdr
;
}
len
=
skb
->
len
-
start
;
while
(
nexthdr
!=
target
)
{
struct
ipv6_opt_hdr
_hdr
,
*
hp
;
unsigned
int
hdrlen
;
...
...
@@ -2316,6 +2337,9 @@ int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset,
if
(
nexthdr
==
NEXTHDR_FRAGMENT
)
{
unsigned
short
_frag_off
;
__be16
*
fp
;
if
(
flags
)
/* Indicate that this is a fragment */
*
flags
|=
IP6T_FH_F_FRAG
;
fp
=
skb_header_pointer
(
skb
,
start
+
offsetof
(
struct
frag_hdr
,
frag_off
),
...
...
@@ -2336,9 +2360,11 @@ int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset,
return
-
ENOENT
;
}
hdrlen
=
8
;
}
else
if
(
nexthdr
==
NEXTHDR_AUTH
)
}
else
if
(
nexthdr
==
NEXTHDR_AUTH
)
{
if
(
flags
&&
(
*
flags
&
IP6T_FH_F_AUTH
)
&&
(
target
<
0
))
break
;
hdrlen
=
(
hp
->
hdrlen
+
2
)
<<
2
;
else
}
else
hdrlen
=
ipv6_optlen
(
hp
);
nexthdr
=
hp
->
nexthdr
;
...
...
net/ipv6/netfilter/ip6t_ah.c
浏览文件 @
958a7586
...
...
@@ -41,11 +41,11 @@ static bool ah_mt6(const struct sk_buff *skb, struct xt_action_param *par)
struct
ip_auth_hdr
_ah
;
const
struct
ip_auth_hdr
*
ah
;
const
struct
ip6t_ah
*
ahinfo
=
par
->
matchinfo
;
unsigned
int
ptr
;
unsigned
int
ptr
=
0
;
unsigned
int
hdrlen
=
0
;
int
err
;
err
=
ipv6_find_hdr
(
skb
,
&
ptr
,
NEXTHDR_AUTH
,
NULL
);
err
=
ipv6_find_hdr
(
skb
,
&
ptr
,
NEXTHDR_AUTH
,
NULL
,
NULL
);
if
(
err
<
0
)
{
if
(
err
!=
-
ENOENT
)
par
->
hotdrop
=
true
;
...
...
net/ipv6/netfilter/ip6t_frag.c
浏览文件 @
958a7586
...
...
@@ -40,10 +40,10 @@ frag_mt6(const struct sk_buff *skb, struct xt_action_param *par)
struct
frag_hdr
_frag
;
const
struct
frag_hdr
*
fh
;
const
struct
ip6t_frag
*
fraginfo
=
par
->
matchinfo
;
unsigned
int
ptr
;
unsigned
int
ptr
=
0
;
int
err
;
err
=
ipv6_find_hdr
(
skb
,
&
ptr
,
NEXTHDR_FRAGMENT
,
NULL
);
err
=
ipv6_find_hdr
(
skb
,
&
ptr
,
NEXTHDR_FRAGMENT
,
NULL
,
NULL
);
if
(
err
<
0
)
{
if
(
err
!=
-
ENOENT
)
par
->
hotdrop
=
true
;
...
...
net/ipv6/netfilter/ip6t_hbh.c
浏览文件 @
958a7586
...
...
@@ -50,7 +50,7 @@ hbh_mt6(const struct sk_buff *skb, struct xt_action_param *par)
const
struct
ipv6_opt_hdr
*
oh
;
const
struct
ip6t_opts
*
optinfo
=
par
->
matchinfo
;
unsigned
int
temp
;
unsigned
int
ptr
;
unsigned
int
ptr
=
0
;
unsigned
int
hdrlen
=
0
;
bool
ret
=
false
;
u8
_opttype
;
...
...
@@ -62,7 +62,7 @@ hbh_mt6(const struct sk_buff *skb, struct xt_action_param *par)
err
=
ipv6_find_hdr
(
skb
,
&
ptr
,
(
par
->
match
==
&
hbh_mt6_reg
[
0
])
?
NEXTHDR_HOP
:
NEXTHDR_DEST
,
NULL
);
NEXTHDR_HOP
:
NEXTHDR_DEST
,
NULL
,
NULL
);
if
(
err
<
0
)
{
if
(
err
!=
-
ENOENT
)
par
->
hotdrop
=
true
;
...
...
net/ipv6/netfilter/ip6t_rt.c
浏览文件 @
958a7586
...
...
@@ -42,14 +42,14 @@ static bool rt_mt6(const struct sk_buff *skb, struct xt_action_param *par)
const
struct
ipv6_rt_hdr
*
rh
;
const
struct
ip6t_rt
*
rtinfo
=
par
->
matchinfo
;
unsigned
int
temp
;
unsigned
int
ptr
;
unsigned
int
ptr
=
0
;
unsigned
int
hdrlen
=
0
;
bool
ret
=
false
;
struct
in6_addr
_addr
;
const
struct
in6_addr
*
ap
;
int
err
;
err
=
ipv6_find_hdr
(
skb
,
&
ptr
,
NEXTHDR_ROUTING
,
NULL
);
err
=
ipv6_find_hdr
(
skb
,
&
ptr
,
NEXTHDR_ROUTING
,
NULL
,
NULL
);
if
(
err
<
0
)
{
if
(
err
!=
-
ENOENT
)
par
->
hotdrop
=
true
;
...
...
net/mac80211/cfg.c
浏览文件 @
958a7586
...
...
@@ -919,7 +919,7 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
}
else
sdata
=
IEEE80211_DEV_TO_SUB_IF
(
dev
);
if
(
compare_ether_addr
(
mac
,
sdata
->
vif
.
addr
)
==
0
)
if
(
ether_addr_equal
(
mac
,
sdata
->
vif
.
addr
)
)
return
-
EINVAL
;
if
(
is_multicast_ether_addr
(
mac
))
...
...
net/mac80211/ibss.c
浏览文件 @
958a7586
...
...
@@ -66,7 +66,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
skb_reset_tail_pointer
(
skb
);
skb_reserve
(
skb
,
sdata
->
local
->
hw
.
extra_tx_headroom
);
if
(
compare_ether_addr
(
ifibss
->
bssid
,
bssid
))
if
(
!
ether_addr_equal
(
ifibss
->
bssid
,
bssid
))
sta_info_flush
(
sdata
->
local
,
sdata
);
/* if merging, indicate to driver that we leave the old IBSS */
...
...
@@ -315,7 +315,7 @@ ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
return
NULL
;
}
if
(
compare_ether_addr
(
bssid
,
sdata
->
u
.
ibss
.
bssid
))
{
if
(
!
ether_addr_equal
(
bssid
,
sdata
->
u
.
ibss
.
bssid
))
{
rcu_read_lock
();
return
NULL
;
}
...
...
@@ -401,7 +401,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
return
;
if
(
sdata
->
vif
.
type
==
NL80211_IFTYPE_ADHOC
&&
compare_ether_addr
(
mgmt
->
bssid
,
sdata
->
u
.
ibss
.
bssid
)
==
0
)
{
ether_addr_equal
(
mgmt
->
bssid
,
sdata
->
u
.
ibss
.
bssid
)
)
{
rcu_read_lock
();
sta
=
sta_info_get
(
sdata
,
mgmt
->
sa
);
...
...
@@ -506,7 +506,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
goto
put_bss
;
/* same BSSID */
if
(
compare_ether_addr
(
cbss
->
bssid
,
sdata
->
u
.
ibss
.
bssid
)
==
0
)
if
(
ether_addr_equal
(
cbss
->
bssid
,
sdata
->
u
.
ibss
.
bssid
)
)
goto
put_bss
;
if
(
rx_status
->
flag
&
RX_FLAG_MACTIME_MPDU
)
{
...
...
@@ -591,7 +591,7 @@ void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
if
(
ifibss
->
state
==
IEEE80211_IBSS_MLME_SEARCH
)
return
;
if
(
compare_ether_addr
(
bssid
,
sdata
->
u
.
ibss
.
bssid
))
if
(
!
ether_addr_equal
(
bssid
,
sdata
->
u
.
ibss
.
bssid
))
return
;
sta
=
sta_info_alloc
(
sdata
,
addr
,
GFP_ATOMIC
);
...
...
@@ -829,7 +829,7 @@ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata,
if
(
!
tx_last_beacon
&&
is_multicast_ether_addr
(
mgmt
->
da
))
return
;
if
(
compare_ether_addr
(
mgmt
->
bssid
,
ifibss
->
bssid
)
!=
0
&&
if
(
!
ether_addr_equal
(
mgmt
->
bssid
,
ifibss
->
bssid
)
&&
!
is_broadcast_ether_addr
(
mgmt
->
bssid
))
return
;
...
...
net/mac80211/ieee80211_i.h
浏览文件 @
958a7586
...
...
@@ -1195,7 +1195,7 @@ static inline struct ieee80211_local *hw_to_local(
static
inline
int
ieee80211_bssid_match
(
const
u8
*
raddr
,
const
u8
*
addr
)
{
return
compare_ether_addr
(
raddr
,
addr
)
==
0
||
return
ether_addr_equal
(
raddr
,
addr
)
||
is_broadcast_ether_addr
(
raddr
);
}
...
...
net/mac80211/iface.c
浏览文件 @
958a7586
...
...
@@ -127,7 +127,7 @@ static int ieee80211_check_concurrent_iface(struct ieee80211_sub_if_data *sdata,
* The remaining checks are only performed for interfaces
* with the same MAC address.
*/
if
(
compare_ether_addr
(
dev
->
dev_addr
,
ndev
->
dev_addr
))
if
(
!
ether_addr_equal
(
dev
->
dev_addr
,
ndev
->
dev_addr
))
continue
;
/*
...
...
net/mac80211/mesh.c
浏览文件 @
958a7586
...
...
@@ -209,7 +209,7 @@ int mesh_rmc_check(u8 *sa, struct ieee80211s_hdr *mesh_hdr,
kmem_cache_free
(
rm_cache
,
p
);
--
entries
;
}
else
if
((
seqnum
==
p
->
seqnum
)
&&
(
compare_ether_addr
(
sa
,
p
->
sa
)
==
0
))
(
ether_addr_equal
(
sa
,
p
->
sa
)
))
return
-
1
;
}
...
...
@@ -639,7 +639,7 @@ static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata,
/* ignore ProbeResp to foreign address */
if
(
stype
==
IEEE80211_STYPE_PROBE_RESP
&&
compare_ether_addr
(
mgmt
->
da
,
sdata
->
vif
.
addr
))
!
ether_addr_equal
(
mgmt
->
da
,
sdata
->
vif
.
addr
))
return
;
baselen
=
(
u8
*
)
mgmt
->
u
.
probe_resp
.
variable
-
(
u8
*
)
mgmt
;
...
...
net/mac80211/mesh_hwmp.c
浏览文件 @
958a7586
...
...
@@ -422,7 +422,7 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata,
new_metric
=
MAX_METRIC
;
exp_time
=
TU_TO_EXP_TIME
(
orig_lifetime
);
if
(
compare_ether_addr
(
orig_addr
,
sdata
->
vif
.
addr
)
==
0
)
{
if
(
ether_addr_equal
(
orig_addr
,
sdata
->
vif
.
addr
)
)
{
/* This MP is the originator, we are not interested in this
* frame, except for updating transmitter's path info.
*/
...
...
@@ -472,7 +472,7 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata,
/* Update and check transmitter routing info */
ta
=
mgmt
->
sa
;
if
(
compare_ether_addr
(
orig_addr
,
ta
)
==
0
)
if
(
ether_addr_equal
(
orig_addr
,
ta
)
)
fresh_info
=
false
;
else
{
fresh_info
=
true
;
...
...
@@ -533,7 +533,7 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata,
mhwmp_dbg
(
"received PREQ from %pM"
,
orig_addr
);
if
(
compare_ether_addr
(
target_addr
,
sdata
->
vif
.
addr
)
==
0
)
{
if
(
ether_addr_equal
(
target_addr
,
sdata
->
vif
.
addr
)
)
{
mhwmp_dbg
(
"PREQ is for us"
);
forward
=
false
;
reply
=
true
;
...
...
@@ -631,7 +631,7 @@ static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata,
mhwmp_dbg
(
"received PREP from %pM"
,
PREP_IE_ORIG_ADDR
(
prep_elem
));
orig_addr
=
PREP_IE_ORIG_ADDR
(
prep_elem
);
if
(
compare_ether_addr
(
orig_addr
,
sdata
->
vif
.
addr
)
==
0
)
if
(
ether_addr_equal
(
orig_addr
,
sdata
->
vif
.
addr
)
)
/* destination, no forwarding required */
return
;
...
...
@@ -709,7 +709,7 @@ static void hwmp_perr_frame_process(struct ieee80211_sub_if_data *sdata,
spin_lock_bh
(
&
mpath
->
state_lock
);
sta
=
next_hop_deref_protected
(
mpath
);
if
(
mpath
->
flags
&
MESH_PATH_ACTIVE
&&
compare_ether_addr
(
ta
,
sta
->
sta
.
addr
)
==
0
&&
ether_addr_equal
(
ta
,
sta
->
sta
.
addr
)
&&
(
!
(
mpath
->
flags
&
MESH_PATH_SN_VALID
)
||
SN_GT
(
target_sn
,
mpath
->
sn
)))
{
mpath
->
flags
&=
~
MESH_PATH_ACTIVE
;
...
...
@@ -756,7 +756,7 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata,
metric
=
le32_to_cpu
(
rann
->
rann_metric
);
/* Ignore our own RANNs */
if
(
compare_ether_addr
(
orig_addr
,
sdata
->
vif
.
addr
)
==
0
)
if
(
ether_addr_equal
(
orig_addr
,
sdata
->
vif
.
addr
)
)
return
;
mhwmp_dbg
(
"received RANN from %pM via neighbour %pM (is_gate=%d)"
,
...
...
@@ -1099,7 +1099,7 @@ int mesh_nexthop_lookup(struct sk_buff *skb,
if
(
time_after
(
jiffies
,
mpath
->
exp_time
-
msecs_to_jiffies
(
sdata
->
u
.
mesh
.
mshcfg
.
path_refresh_time
))
&&
!
compare_ether_addr
(
sdata
->
vif
.
addr
,
hdr
->
addr4
)
&&
ether_addr_equal
(
sdata
->
vif
.
addr
,
hdr
->
addr4
)
&&
!
(
mpath
->
flags
&
MESH_PATH_RESOLVING
)
&&
!
(
mpath
->
flags
&
MESH_PATH_FIXED
))
mesh_queue_preq
(
mpath
,
PREQ_Q_F_START
|
PREQ_Q_F_REFRESH
);
...
...
net/mac80211/mesh_pathtbl.c
浏览文件 @
958a7586
...
...
@@ -348,7 +348,7 @@ static struct mesh_path *mpath_lookup(struct mesh_table *tbl, u8 *dst,
hlist_for_each_entry_rcu
(
node
,
n
,
bucket
,
list
)
{
mpath
=
node
->
mpath
;
if
(
mpath
->
sdata
==
sdata
&&
compare_ether_addr
(
dst
,
mpath
->
dst
)
==
0
)
{
ether_addr_equal
(
dst
,
mpath
->
dst
)
)
{
if
(
MPATH_EXPIRED
(
mpath
))
{
spin_lock_bh
(
&
mpath
->
state_lock
);
mpath
->
flags
&=
~
MESH_PATH_ACTIVE
;
...
...
@@ -517,7 +517,7 @@ int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata)
int
err
=
0
;
u32
hash_idx
;
if
(
compare_ether_addr
(
dst
,
sdata
->
vif
.
addr
)
==
0
)
if
(
ether_addr_equal
(
dst
,
sdata
->
vif
.
addr
)
)
/* never add ourselves as neighbours */
return
-
ENOTSUPP
;
...
...
@@ -561,7 +561,7 @@ int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata)
hlist_for_each_entry
(
node
,
n
,
bucket
,
list
)
{
mpath
=
node
->
mpath
;
if
(
mpath
->
sdata
==
sdata
&&
compare_ether_addr
(
dst
,
mpath
->
dst
)
==
0
)
ether_addr_equal
(
dst
,
mpath
->
dst
)
)
goto
err_exists
;
}
...
...
@@ -652,7 +652,7 @@ int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata)
int
err
=
0
;
u32
hash_idx
;
if
(
compare_ether_addr
(
dst
,
sdata
->
vif
.
addr
)
==
0
)
if
(
ether_addr_equal
(
dst
,
sdata
->
vif
.
addr
)
)
/* never add ourselves as neighbours */
return
-
ENOTSUPP
;
...
...
@@ -690,7 +690,7 @@ int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata)
hlist_for_each_entry
(
node
,
n
,
bucket
,
list
)
{
mpath
=
node
->
mpath
;
if
(
mpath
->
sdata
==
sdata
&&
compare_ether_addr
(
dst
,
mpath
->
dst
)
==
0
)
ether_addr_equal
(
dst
,
mpath
->
dst
)
)
goto
err_exists
;
}
...
...
@@ -884,7 +884,7 @@ int mesh_path_del(u8 *addr, struct ieee80211_sub_if_data *sdata)
hlist_for_each_entry
(
node
,
n
,
bucket
,
list
)
{
mpath
=
node
->
mpath
;
if
(
mpath
->
sdata
==
sdata
&&
compare_ether_addr
(
addr
,
mpath
->
dst
)
==
0
)
{
ether_addr_equal
(
addr
,
mpath
->
dst
)
)
{
__mesh_path_del
(
tbl
,
node
);
goto
enddel
;
}
...
...
net/mac80211/mlme.c
浏览文件 @
958a7586
...
...
@@ -1776,7 +1776,7 @@ ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata,
memcpy
(
bssid
,
ifmgd
->
auth_data
->
bss
->
bssid
,
ETH_ALEN
);
if
(
compare_ether_addr
(
bssid
,
mgmt
->
bssid
))
if
(
!
ether_addr_equal
(
bssid
,
mgmt
->
bssid
))
return
RX_MGMT_NONE
;
auth_alg
=
le16_to_cpu
(
mgmt
->
u
.
auth
.
auth_alg
);
...
...
@@ -1853,7 +1853,7 @@ ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata,
return
RX_MGMT_NONE
;
if
(
!
ifmgd
->
associated
||
compare_ether_addr
(
mgmt
->
bssid
,
ifmgd
->
associated
->
bssid
))
!
ether_addr_equal
(
mgmt
->
bssid
,
ifmgd
->
associated
->
bssid
))
return
RX_MGMT_NONE
;
bssid
=
ifmgd
->
associated
->
bssid
;
...
...
@@ -1886,7 +1886,7 @@ ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata,
return
RX_MGMT_NONE
;
if
(
!
ifmgd
->
associated
||
compare_ether_addr
(
mgmt
->
bssid
,
ifmgd
->
associated
->
bssid
))
!
ether_addr_equal
(
mgmt
->
bssid
,
ifmgd
->
associated
->
bssid
))
return
RX_MGMT_NONE
;
reason_code
=
le16_to_cpu
(
mgmt
->
u
.
disassoc
.
reason_code
);
...
...
@@ -2113,7 +2113,7 @@ ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
if
(
!
assoc_data
)
return
RX_MGMT_NONE
;
if
(
compare_ether_addr
(
assoc_data
->
bss
->
bssid
,
mgmt
->
bssid
))
if
(
!
ether_addr_equal
(
assoc_data
->
bss
->
bssid
,
mgmt
->
bssid
))
return
RX_MGMT_NONE
;
/*
...
...
@@ -2193,8 +2193,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
bool
need_ps
=
false
;
if
(
sdata
->
u
.
mgd
.
associated
&&
compare_ether_addr
(
mgmt
->
bssid
,
sdata
->
u
.
mgd
.
associated
->
bssid
)
==
0
)
{
ether_addr_equal
(
mgmt
->
bssid
,
sdata
->
u
.
mgd
.
associated
->
bssid
))
{
bss
=
(
void
*
)
sdata
->
u
.
mgd
.
associated
->
priv
;
/* not previously set so we may need to recalc */
need_ps
=
!
bss
->
dtim_period
;
...
...
@@ -2249,7 +2248,7 @@ static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata,
ASSERT_MGD_MTX
(
ifmgd
);
if
(
compare_ether_addr
(
mgmt
->
da
,
sdata
->
vif
.
addr
))
if
(
!
ether_addr_equal
(
mgmt
->
da
,
sdata
->
vif
.
addr
))
return
;
/* ignore ProbeResp to foreign address */
baselen
=
(
u8
*
)
mgmt
->
u
.
probe_resp
.
variable
-
(
u8
*
)
mgmt
;
...
...
@@ -2262,12 +2261,11 @@ static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata,
ieee80211_rx_bss_info
(
sdata
,
mgmt
,
len
,
rx_status
,
&
elems
,
false
);
if
(
ifmgd
->
associated
&&
compare_ether_addr
(
mgmt
->
bssid
,
ifmgd
->
associated
->
bssid
)
==
0
)
ether_addr_equal
(
mgmt
->
bssid
,
ifmgd
->
associated
->
bssid
)
)
ieee80211_reset_ap_probe
(
sdata
);
if
(
ifmgd
->
auth_data
&&
!
ifmgd
->
auth_data
->
bss
->
proberesp_ies
&&
compare_ether_addr
(
mgmt
->
bssid
,
ifmgd
->
auth_data
->
bss
->
bssid
)
==
0
)
{
ether_addr_equal
(
mgmt
->
bssid
,
ifmgd
->
auth_data
->
bss
->
bssid
))
{
/* got probe response, continue with auth */
printk
(
KERN_DEBUG
"%s: direct probe responded
\n
"
,
sdata
->
name
);
ifmgd
->
auth_data
->
tries
=
0
;
...
...
@@ -2324,8 +2322,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
return
;
if
(
ifmgd
->
assoc_data
&&
!
ifmgd
->
assoc_data
->
have_beacon
&&
compare_ether_addr
(
mgmt
->
bssid
,
ifmgd
->
assoc_data
->
bss
->
bssid
)
==
0
)
{
ether_addr_equal
(
mgmt
->
bssid
,
ifmgd
->
assoc_data
->
bss
->
bssid
))
{
ieee802_11_parse_elems
(
mgmt
->
u
.
beacon
.
variable
,
len
-
baselen
,
&
elems
);
...
...
@@ -2340,7 +2337,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
}
if
(
!
ifmgd
->
associated
||
compare_ether_addr
(
mgmt
->
bssid
,
ifmgd
->
associated
->
bssid
))
!
ether_addr_equal
(
mgmt
->
bssid
,
ifmgd
->
associated
->
bssid
))
return
;
bssid
=
ifmgd
->
associated
->
bssid
;
...
...
@@ -3166,7 +3163,7 @@ static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata,
return
err
;
}
}
else
WARN_ON_ONCE
(
compare_ether_addr
(
ifmgd
->
bssid
,
cbss
->
bssid
));
WARN_ON_ONCE
(
!
ether_addr_equal
(
ifmgd
->
bssid
,
cbss
->
bssid
));
return
0
;
}
...
...
@@ -3306,7 +3303,7 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
bool
match
;
/* keep sta info, bssid if matching */
match
=
compare_ether_addr
(
ifmgd
->
bssid
,
req
->
bss
->
bssid
)
==
0
;
match
=
ether_addr_equal
(
ifmgd
->
bssid
,
req
->
bss
->
bssid
)
;
ieee80211_destroy_auth_data
(
sdata
,
match
);
}
...
...
@@ -3466,7 +3463,7 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
sdata
->
name
,
req
->
bssid
,
req
->
reason_code
);
if
(
ifmgd
->
associated
&&
compare_ether_addr
(
ifmgd
->
associated
->
bssid
,
req
->
bssid
)
==
0
)
ether_addr_equal
(
ifmgd
->
associated
->
bssid
,
req
->
bssid
)
)
ieee80211_set_disassoc
(
sdata
,
IEEE80211_STYPE_DEAUTH
,
req
->
reason_code
,
true
,
frame_buf
);
else
...
...
net/mac80211/rx.c
浏览文件 @
958a7586
...
...
@@ -492,12 +492,12 @@ ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx)
if
(
ieee80211_has_tods
(
hdr
->
frame_control
)
||
!
ieee80211_has_fromds
(
hdr
->
frame_control
))
return
RX_DROP_MONITOR
;
if
(
compare_ether_addr
(
hdr
->
addr3
,
dev_addr
)
==
0
)
if
(
ether_addr_equal
(
hdr
->
addr3
,
dev_addr
)
)
return
RX_DROP_MONITOR
;
}
else
{
if
(
!
ieee80211_has_a4
(
hdr
->
frame_control
))
return
RX_DROP_MONITOR
;
if
(
compare_ether_addr
(
hdr
->
addr4
,
dev_addr
)
==
0
)
if
(
ether_addr_equal
(
hdr
->
addr4
,
dev_addr
)
)
return
RX_DROP_MONITOR
;
}
}
...
...
@@ -1275,7 +1275,7 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
if
(
rx
->
sdata
->
vif
.
type
==
NL80211_IFTYPE_ADHOC
)
{
u8
*
bssid
=
ieee80211_get_bssid
(
hdr
,
rx
->
skb
->
len
,
NL80211_IFTYPE_ADHOC
);
if
(
compare_ether_addr
(
bssid
,
rx
->
sdata
->
u
.
ibss
.
bssid
)
==
0
)
{
if
(
ether_addr_equal
(
bssid
,
rx
->
sdata
->
u
.
ibss
.
bssid
)
)
{
sta
->
last_rx
=
jiffies
;
if
(
ieee80211_is_data
(
hdr
->
frame_control
))
{
sta
->
last_rx_rate_idx
=
status
->
rate_idx
;
...
...
@@ -1438,8 +1438,8 @@ ieee80211_reassemble_find(struct ieee80211_sub_if_data *sdata,
*/
if
(((
hdr
->
frame_control
^
f_hdr
->
frame_control
)
&
cpu_to_le16
(
IEEE80211_FCTL_FTYPE
))
||
compare_ether_addr
(
hdr
->
addr1
,
f_hdr
->
addr1
)
!=
0
||
compare_ether_addr
(
hdr
->
addr2
,
f_hdr
->
addr2
)
!=
0
)
!
ether_addr_equal
(
hdr
->
addr1
,
f_hdr
->
addr1
)
||
!
ether_addr_equal
(
hdr
->
addr2
,
f_hdr
->
addr2
)
)
continue
;
if
(
time_after
(
jiffies
,
entry
->
first_frag_time
+
2
*
HZ
))
{
...
...
@@ -1714,8 +1714,8 @@ static bool ieee80211_frame_allowed(struct ieee80211_rx_data *rx, __le16 fc)
* of whether the frame was encrypted or not.
*/
if
(
ehdr
->
h_proto
==
rx
->
sdata
->
control_port_protocol
&&
(
compare_ether_addr
(
ehdr
->
h_dest
,
rx
->
sdata
->
vif
.
addr
)
==
0
||
compare_ether_addr
(
ehdr
->
h_dest
,
pae_group_addr
)
==
0
))
(
ether_addr_equal
(
ehdr
->
h_dest
,
rx
->
sdata
->
vif
.
addr
)
||
ether_addr_equal
(
ehdr
->
h_dest
,
pae_group_addr
)
))
return
true
;
if
(
ieee80211_802_1x_port_control
(
rx
)
||
...
...
@@ -1925,7 +1925,7 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
mpp_path_add
(
proxied_addr
,
mpp_addr
,
sdata
);
}
else
{
spin_lock_bh
(
&
mppath
->
state_lock
);
if
(
compare_ether_addr
(
mppath
->
mpp
,
mpp_addr
)
!=
0
)
if
(
!
ether_addr_equal
(
mppath
->
mpp
,
mpp_addr
)
)
memcpy
(
mppath
->
mpp
,
mpp_addr
,
ETH_ALEN
);
spin_unlock_bh
(
&
mppath
->
state_lock
);
}
...
...
@@ -1934,7 +1934,7 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
/* Frame has reached destination. Don't forward */
if
(
!
is_multicast_ether_addr
(
hdr
->
addr1
)
&&
compare_ether_addr
(
sdata
->
vif
.
addr
,
hdr
->
addr3
)
==
0
)
ether_addr_equal
(
sdata
->
vif
.
addr
,
hdr
->
addr3
)
)
return
RX_CONTINUE
;
q
=
ieee80211_select_queue_80211
(
local
,
skb
,
hdr
);
...
...
@@ -2122,13 +2122,13 @@ static void ieee80211_process_sa_query_req(struct ieee80211_sub_if_data *sdata,
struct
sk_buff
*
skb
;
struct
ieee80211_mgmt
*
resp
;
if
(
compare_ether_addr
(
mgmt
->
da
,
sdata
->
vif
.
addr
)
!=
0
)
{
if
(
!
ether_addr_equal
(
mgmt
->
da
,
sdata
->
vif
.
addr
)
)
{
/* Not to own unicast address */
return
;
}
if
(
compare_ether_addr
(
mgmt
->
sa
,
sdata
->
u
.
mgd
.
bssid
)
!=
0
||
compare_ether_addr
(
mgmt
->
bssid
,
sdata
->
u
.
mgd
.
bssid
)
!=
0
)
{
if
(
!
ether_addr_equal
(
mgmt
->
sa
,
sdata
->
u
.
mgd
.
bssid
)
||
!
ether_addr_equal
(
mgmt
->
bssid
,
sdata
->
u
.
mgd
.
bssid
)
)
{
/* Not from the current AP or not associated yet. */
return
;
}
...
...
@@ -2338,7 +2338,7 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx)
if
(
sdata
->
vif
.
type
!=
NL80211_IFTYPE_STATION
)
break
;
if
(
compare_ether_addr
(
mgmt
->
bssid
,
sdata
->
u
.
mgd
.
bssid
))
if
(
!
ether_addr_equal
(
mgmt
->
bssid
,
sdata
->
u
.
mgd
.
bssid
))
break
;
goto
queue
;
...
...
@@ -2772,7 +2772,7 @@ static int prepare_for_handlers(struct ieee80211_rx_data *rx,
if
(
!
bssid
&&
!
sdata
->
u
.
mgd
.
use_4addr
)
return
0
;
if
(
!
multicast
&&
compare_ether_addr
(
sdata
->
vif
.
addr
,
hdr
->
addr1
)
!=
0
)
{
!
ether_addr_equal
(
sdata
->
vif
.
addr
,
hdr
->
addr1
)
)
{
if
(
!
(
sdata
->
dev
->
flags
&
IFF_PROMISC
)
||
sdata
->
u
.
mgd
.
use_4addr
)
return
0
;
...
...
@@ -2790,8 +2790,7 @@ static int prepare_for_handlers(struct ieee80211_rx_data *rx,
return
0
;
status
->
rx_flags
&=
~
IEEE80211_RX_RA_MATCH
;
}
else
if
(
!
multicast
&&
compare_ether_addr
(
sdata
->
vif
.
addr
,
hdr
->
addr1
)
!=
0
)
{
!
ether_addr_equal
(
sdata
->
vif
.
addr
,
hdr
->
addr1
))
{
if
(
!
(
sdata
->
dev
->
flags
&
IFF_PROMISC
))
return
0
;
status
->
rx_flags
&=
~
IEEE80211_RX_RA_MATCH
;
...
...
@@ -2807,8 +2806,7 @@ static int prepare_for_handlers(struct ieee80211_rx_data *rx,
break
;
case
NL80211_IFTYPE_MESH_POINT
:
if
(
!
multicast
&&
compare_ether_addr
(
sdata
->
vif
.
addr
,
hdr
->
addr1
)
!=
0
)
{
!
ether_addr_equal
(
sdata
->
vif
.
addr
,
hdr
->
addr1
))
{
if
(
!
(
sdata
->
dev
->
flags
&
IFF_PROMISC
))
return
0
;
...
...
@@ -2818,8 +2816,7 @@ static int prepare_for_handlers(struct ieee80211_rx_data *rx,
case
NL80211_IFTYPE_AP_VLAN
:
case
NL80211_IFTYPE_AP
:
if
(
!
bssid
)
{
if
(
compare_ether_addr
(
sdata
->
vif
.
addr
,
hdr
->
addr1
))
if
(
!
ether_addr_equal
(
sdata
->
vif
.
addr
,
hdr
->
addr1
))
return
0
;
}
else
if
(
!
ieee80211_bssid_match
(
bssid
,
sdata
->
vif
.
addr
))
{
...
...
@@ -2841,7 +2838,7 @@ static int prepare_for_handlers(struct ieee80211_rx_data *rx,
case
NL80211_IFTYPE_WDS
:
if
(
bssid
||
!
ieee80211_is_data
(
hdr
->
frame_control
))
return
0
;
if
(
compare_ether_addr
(
sdata
->
u
.
wds
.
remote_addr
,
hdr
->
addr2
))
if
(
!
ether_addr_equal
(
sdata
->
u
.
wds
.
remote_addr
,
hdr
->
addr2
))
return
0
;
break
;
default:
...
...
net/mac80211/scan.c
浏览文件 @
958a7586
...
...
@@ -194,7 +194,7 @@ ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb)
presp
=
ieee80211_is_probe_resp
(
fc
);
if
(
presp
)
{
/* ignore ProbeResp to foreign address */
if
(
compare_ether_addr
(
mgmt
->
da
,
sdata
->
vif
.
addr
))
if
(
!
ether_addr_equal
(
mgmt
->
da
,
sdata
->
vif
.
addr
))
return
RX_DROP_MONITOR
;
presp
=
true
;
...
...
net/mac80211/sta_info.c
浏览文件 @
958a7586
...
...
@@ -102,7 +102,7 @@ struct sta_info *sta_info_get(struct ieee80211_sub_if_data *sdata,
lockdep_is_held
(
&
local
->
sta_mtx
));
while
(
sta
)
{
if
(
sta
->
sdata
==
sdata
&&
compare_ether_addr
(
sta
->
sta
.
addr
,
addr
)
==
0
)
ether_addr_equal
(
sta
->
sta
.
addr
,
addr
)
)
break
;
sta
=
rcu_dereference_check
(
sta
->
hnext
,
lockdep_is_held
(
&
local
->
sta_mtx
));
...
...
@@ -125,7 +125,7 @@ struct sta_info *sta_info_get_bss(struct ieee80211_sub_if_data *sdata,
while
(
sta
)
{
if
((
sta
->
sdata
==
sdata
||
(
sta
->
sdata
->
bss
&&
sta
->
sdata
->
bss
==
sdata
->
bss
))
&&
compare_ether_addr
(
sta
->
sta
.
addr
,
addr
)
==
0
)
ether_addr_equal
(
sta
->
sta
.
addr
,
addr
)
)
break
;
sta
=
rcu_dereference_check
(
sta
->
hnext
,
lockdep_is_held
(
&
local
->
sta_mtx
));
...
...
@@ -302,7 +302,7 @@ static int sta_info_insert_check(struct sta_info *sta)
if
(
unlikely
(
!
ieee80211_sdata_running
(
sdata
)))
return
-
ENETDOWN
;
if
(
WARN_ON
(
compare_ether_addr
(
sta
->
sta
.
addr
,
sdata
->
vif
.
addr
)
==
0
||
if
(
WARN_ON
(
ether_addr_equal
(
sta
->
sta
.
addr
,
sdata
->
vif
.
addr
)
||
is_multicast_ether_addr
(
sta
->
sta
.
addr
)))
return
-
EINVAL
;
...
...
@@ -912,7 +912,7 @@ struct ieee80211_sta *ieee80211_find_sta_by_ifaddr(struct ieee80211_hw *hw,
*/
for_each_sta_info
(
hw_to_local
(
hw
),
addr
,
sta
,
nxt
)
{
if
(
localaddr
&&
compare_ether_addr
(
sta
->
sdata
->
vif
.
addr
,
localaddr
)
!=
0
)
!
ether_addr_equal
(
sta
->
sdata
->
vif
.
addr
,
localaddr
)
)
continue
;
if
(
!
sta
->
uploaded
)
return
NULL
;
...
...
net/mac80211/sta_info.h
浏览文件 @
958a7586
...
...
@@ -501,7 +501,7 @@ void for_each_sta_info_type_check(struct ieee80211_local *local,
nxt = _sta ? rcu_dereference(_sta->hnext) : NULL \
) \
/* compare address and run code only if it matches */
\
if (
compare_ether_addr(_sta->sta.addr, (_addr)) == 0
)
if (
ether_addr_equal(_sta->sta.addr, (_addr))
)
/*
* Get STA info by index, BROKEN!
...
...
net/mac80211/status.c
浏览文件 @
958a7586
...
...
@@ -384,7 +384,7 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
for_each_sta_info
(
local
,
hdr
->
addr1
,
sta
,
tmp
)
{
/* skip wrong virtual interface */
if
(
compare_ether_addr
(
hdr
->
addr2
,
sta
->
sdata
->
vif
.
addr
))
if
(
!
ether_addr_equal
(
hdr
->
addr2
,
sta
->
sdata
->
vif
.
addr
))
continue
;
if
(
info
->
flags
&
IEEE80211_TX_STATUS_EOSP
)
...
...
net/mac80211/tx.c
浏览文件 @
958a7586
...
...
@@ -1665,7 +1665,7 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
skb
->
len
>=
len_rthdr
+
hdrlen
+
sizeof
(
rfc1042_header
)
+
2
)
{
u8
*
payload
=
(
u8
*
)
hdr
+
hdrlen
;
if
(
compare_ether_addr
(
payload
,
rfc1042_header
)
==
0
)
if
(
ether_addr_equal
(
payload
,
rfc1042_header
)
)
skb
->
protocol
=
cpu_to_be16
((
payload
[
6
]
<<
8
)
|
payload
[
7
]);
}
...
...
@@ -1698,7 +1698,7 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
tmp_sdata
->
vif
.
type
==
NL80211_IFTYPE_AP_VLAN
||
tmp_sdata
->
vif
.
type
==
NL80211_IFTYPE_WDS
)
continue
;
if
(
compare_ether_addr
(
tmp_sdata
->
vif
.
addr
,
hdr
->
addr2
)
==
0
)
{
if
(
ether_addr_equal
(
tmp_sdata
->
vif
.
addr
,
hdr
->
addr2
)
)
{
sdata
=
tmp_sdata
;
break
;
}
...
...
@@ -1815,9 +1815,8 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
* is being proxied by a portal (i.e. portal address
* differs from proxied address)
*/
if
(
compare_ether_addr
(
sdata
->
vif
.
addr
,
skb
->
data
+
ETH_ALEN
)
==
0
&&
!
(
mppath
&&
compare_ether_addr
(
mppath
->
mpp
,
skb
->
data
)))
{
if
(
ether_addr_equal
(
sdata
->
vif
.
addr
,
skb
->
data
+
ETH_ALEN
)
&&
!
(
mppath
&&
!
ether_addr_equal
(
mppath
->
mpp
,
skb
->
data
)))
{
hdrlen
=
ieee80211_fill_mesh_addresses
(
&
hdr
,
&
fc
,
skb
->
data
,
skb
->
data
+
ETH_ALEN
);
rcu_read_unlock
();
...
...
@@ -1964,7 +1963,7 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
if
(
unlikely
(
!
ieee80211_vif_is_mesh
(
&
sdata
->
vif
)
&&
!
is_multicast_ether_addr
(
hdr
.
addr1
)
&&
!
authorized
&&
(
cpu_to_be16
(
ethertype
)
!=
sdata
->
control_port_protocol
||
compare_ether_addr
(
sdata
->
vif
.
addr
,
skb
->
data
+
ETH_ALEN
))))
{
!
ether_addr_equal
(
sdata
->
vif
.
addr
,
skb
->
data
+
ETH_ALEN
))))
{
#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
if
(
net_ratelimit
())
printk
(
KERN_DEBUG
"%s: dropped frame to %pM"
...
...
net/netfilter/Kconfig
浏览文件 @
958a7586
...
...
@@ -509,6 +509,21 @@ config NETFILTER_XT_TARGET_HL
since you can easily create immortal packets that loop
forever on the network.
config NETFILTER_XT_TARGET_HMARK
tristate '"HMARK" target support'
depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
depends on NETFILTER_ADVANCED
---help---
This option adds the "HMARK" target.
The target allows you to create rules in the "raw" and "mangle" tables
which set the skbuff mark by means of hash calculation within a given
range. The nfmark can influence the routing method (see "Use netfilter
MARK value as routing key") and can also be used by other subsystems to
change their behaviour.
To compile it as a module, choose M here. If unsure, say N.
config NETFILTER_XT_TARGET_IDLETIMER
tristate "IDLETIMER target support"
depends on NETFILTER_ADVANCED
...
...
net/netfilter/Makefile
浏览文件 @
958a7586
...
...
@@ -59,6 +59,7 @@ obj-$(CONFIG_NETFILTER_XT_TARGET_CONNSECMARK) += xt_CONNSECMARK.o
obj-$(CONFIG_NETFILTER_XT_TARGET_CT)
+=
xt_CT.o
obj-$(CONFIG_NETFILTER_XT_TARGET_DSCP)
+=
xt_DSCP.o
obj-$(CONFIG_NETFILTER_XT_TARGET_HL)
+=
xt_HL.o
obj-$(CONFIG_NETFILTER_XT_TARGET_HMARK)
+=
xt_HMARK.o
obj-$(CONFIG_NETFILTER_XT_TARGET_LED)
+=
xt_LED.o
obj-$(CONFIG_NETFILTER_XT_TARGET_LOG)
+=
xt_LOG.o
obj-$(CONFIG_NETFILTER_XT_TARGET_NFLOG)
+=
xt_NFLOG.o
...
...
net/netfilter/ipset/ip_set_bitmap_ipmac.c
浏览文件 @
958a7586
...
...
@@ -111,7 +111,7 @@ bitmap_ipmac_test(struct ip_set *set, void *value, u32 timeout, u32 flags)
return
-
EAGAIN
;
case
MAC_FILLED
:
return
data
->
ether
==
NULL
||
compare_ether_addr
(
data
->
ether
,
elem
->
ether
)
==
0
;
ether_addr_equal
(
data
->
ether
,
elem
->
ether
)
;
}
return
0
;
}
...
...
@@ -225,7 +225,7 @@ bitmap_ipmac_ttest(struct ip_set *set, void *value, u32 timeout, u32 flags)
return
-
EAGAIN
;
case
MAC_FILLED
:
return
(
data
->
ether
==
NULL
||
compare_ether_addr
(
data
->
ether
,
elem
->
ether
)
==
0
)
&&
ether_addr_equal
(
data
->
ether
,
elem
->
ether
)
)
&&
!
bitmap_expired
(
map
,
data
->
id
);
}
return
0
;
...
...
net/netfilter/xt_HMARK.c
0 → 100644
浏览文件 @
958a7586
/*
* xt_HMARK - Netfilter module to set mark by means of hashing
*
* (C) 2012 by Hans Schillstrom <hans.schillstrom@ericsson.com>
* (C) 2012 by Pablo Neira Ayuso <pablo@netfilter.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*/
#include <linux/module.h>
#include <linux/skbuff.h>
#include <linux/icmp.h>
#include <linux/netfilter/x_tables.h>
#include <linux/netfilter/xt_HMARK.h>
#include <net/ip.h>
#if IS_ENABLED(CONFIG_NF_CONNTRACK)
#include <net/netfilter/nf_conntrack.h>
#endif
#if IS_ENABLED(CONFIG_IP6_NF_IPTABLES)
#include <net/ipv6.h>
#include <linux/netfilter_ipv6/ip6_tables.h>
#endif
MODULE_LICENSE
(
"GPL"
);
MODULE_AUTHOR
(
"Hans Schillstrom <hans.schillstrom@ericsson.com>"
);
MODULE_DESCRIPTION
(
"Xtables: packet marking using hash calculation"
);
MODULE_ALIAS
(
"ipt_HMARK"
);
MODULE_ALIAS
(
"ip6t_HMARK"
);
struct
hmark_tuple
{
u32
src
;
u32
dst
;
union
hmark_ports
uports
;
uint8_t
proto
;
};
static
inline
u32
hmark_addr6_mask
(
const
__u32
*
addr32
,
const
__u32
*
mask
)
{
return
(
addr32
[
0
]
&
mask
[
0
])
^
(
addr32
[
1
]
&
mask
[
1
])
^
(
addr32
[
2
]
&
mask
[
2
])
^
(
addr32
[
3
]
&
mask
[
3
]);
}
static
inline
u32
hmark_addr_mask
(
int
l3num
,
const
__u32
*
addr32
,
const
__u32
*
mask
)
{
switch
(
l3num
)
{
case
AF_INET
:
return
*
addr32
&
*
mask
;
case
AF_INET6
:
return
hmark_addr6_mask
(
addr32
,
mask
);
}
return
0
;
}
static
int
hmark_ct_set_htuple
(
const
struct
sk_buff
*
skb
,
struct
hmark_tuple
*
t
,
const
struct
xt_hmark_info
*
info
)
{
#if IS_ENABLED(CONFIG_NF_CONNTRACK)
enum
ip_conntrack_info
ctinfo
;
struct
nf_conn
*
ct
=
nf_ct_get
(
skb
,
&
ctinfo
);
struct
nf_conntrack_tuple
*
otuple
;
struct
nf_conntrack_tuple
*
rtuple
;
if
(
ct
==
NULL
||
nf_ct_is_untracked
(
ct
))
return
-
1
;
otuple
=
&
ct
->
tuplehash
[
IP_CT_DIR_ORIGINAL
].
tuple
;
rtuple
=
&
ct
->
tuplehash
[
IP_CT_DIR_REPLY
].
tuple
;
t
->
src
=
hmark_addr_mask
(
otuple
->
src
.
l3num
,
otuple
->
src
.
u3
.
all
,
info
->
src_mask
.
all
);
t
->
dst
=
hmark_addr_mask
(
otuple
->
src
.
l3num
,
rtuple
->
src
.
u3
.
all
,
info
->
dst_mask
.
all
);
if
(
info
->
flags
&
XT_HMARK_FLAG
(
XT_HMARK_METHOD_L3
))
return
0
;
t
->
proto
=
nf_ct_protonum
(
ct
);
if
(
t
->
proto
!=
IPPROTO_ICMP
)
{
t
->
uports
.
p16
.
src
=
otuple
->
src
.
u
.
all
;
t
->
uports
.
p16
.
dst
=
rtuple
->
src
.
u
.
all
;
t
->
uports
.
v32
=
(
t
->
uports
.
v32
&
info
->
port_mask
.
v32
)
|
info
->
port_set
.
v32
;
if
(
t
->
uports
.
p16
.
dst
<
t
->
uports
.
p16
.
src
)
swap
(
t
->
uports
.
p16
.
dst
,
t
->
uports
.
p16
.
src
);
}
return
0
;
#else
return
-
1
;
#endif
}
static
inline
u32
hmark_hash
(
struct
hmark_tuple
*
t
,
const
struct
xt_hmark_info
*
info
)
{
u32
hash
;
if
(
t
->
dst
<
t
->
src
)
swap
(
t
->
src
,
t
->
dst
);
hash
=
jhash_3words
(
t
->
src
,
t
->
dst
,
t
->
uports
.
v32
,
info
->
hashrnd
);
hash
=
hash
^
(
t
->
proto
&
info
->
proto_mask
);
return
(
hash
%
info
->
hmodulus
)
+
info
->
hoffset
;
}
static
void
hmark_set_tuple_ports
(
const
struct
sk_buff
*
skb
,
unsigned
int
nhoff
,
struct
hmark_tuple
*
t
,
const
struct
xt_hmark_info
*
info
)
{
int
protoff
;
protoff
=
proto_ports_offset
(
t
->
proto
);
if
(
protoff
<
0
)
return
;
nhoff
+=
protoff
;
if
(
skb_copy_bits
(
skb
,
nhoff
,
&
t
->
uports
,
sizeof
(
t
->
uports
))
<
0
)
return
;
t
->
uports
.
v32
=
(
t
->
uports
.
v32
&
info
->
port_mask
.
v32
)
|
info
->
port_set
.
v32
;
if
(
t
->
uports
.
p16
.
dst
<
t
->
uports
.
p16
.
src
)
swap
(
t
->
uports
.
p16
.
dst
,
t
->
uports
.
p16
.
src
);
}
#if IS_ENABLED(CONFIG_IP6_NF_IPTABLES)
static
int
get_inner6_hdr
(
const
struct
sk_buff
*
skb
,
int
*
offset
)
{
struct
icmp6hdr
*
icmp6h
,
_ih6
;
icmp6h
=
skb_header_pointer
(
skb
,
*
offset
,
sizeof
(
_ih6
),
&
_ih6
);
if
(
icmp6h
==
NULL
)
return
0
;
if
(
icmp6h
->
icmp6_type
&&
icmp6h
->
icmp6_type
<
128
)
{
*
offset
+=
sizeof
(
struct
icmp6hdr
);
return
1
;
}
return
0
;
}
static
int
hmark_pkt_set_htuple_ipv6
(
const
struct
sk_buff
*
skb
,
struct
hmark_tuple
*
t
,
const
struct
xt_hmark_info
*
info
)
{
struct
ipv6hdr
*
ip6
,
_ip6
;
int
flag
=
IP6T_FH_F_AUTH
;
unsigned
int
nhoff
=
0
;
u16
fragoff
=
0
;
int
nexthdr
;
ip6
=
(
struct
ipv6hdr
*
)
(
skb
->
data
+
skb_network_offset
(
skb
));
nexthdr
=
ipv6_find_hdr
(
skb
,
&
nhoff
,
-
1
,
&
fragoff
,
&
flag
);
if
(
nexthdr
<
0
)
return
0
;
/* No need to check for icmp errors on fragments */
if
((
flag
&
IP6T_FH_F_FRAG
)
||
(
nexthdr
!=
IPPROTO_ICMPV6
))
goto
noicmp
;
/* Use inner header in case of ICMP errors */
if
(
get_inner6_hdr
(
skb
,
&
nhoff
))
{
ip6
=
skb_header_pointer
(
skb
,
nhoff
,
sizeof
(
_ip6
),
&
_ip6
);
if
(
ip6
==
NULL
)
return
-
1
;
/* If AH present, use SPI like in ESP. */
flag
=
IP6T_FH_F_AUTH
;
nexthdr
=
ipv6_find_hdr
(
skb
,
&
nhoff
,
-
1
,
&
fragoff
,
&
flag
);
if
(
nexthdr
<
0
)
return
-
1
;
}
noicmp:
t
->
src
=
hmark_addr6_mask
(
ip6
->
saddr
.
s6_addr32
,
info
->
src_mask
.
all
);
t
->
dst
=
hmark_addr6_mask
(
ip6
->
daddr
.
s6_addr32
,
info
->
dst_mask
.
all
);
if
(
info
->
flags
&
XT_HMARK_FLAG
(
XT_HMARK_METHOD_L3
))
return
0
;
t
->
proto
=
nexthdr
;
if
(
t
->
proto
==
IPPROTO_ICMPV6
)
return
0
;
if
(
flag
&
IP6T_FH_F_FRAG
)
return
0
;
hmark_set_tuple_ports
(
skb
,
nhoff
,
t
,
info
);
return
0
;
}
static
unsigned
int
hmark_tg_v6
(
struct
sk_buff
*
skb
,
const
struct
xt_action_param
*
par
)
{
const
struct
xt_hmark_info
*
info
=
par
->
targinfo
;
struct
hmark_tuple
t
;
memset
(
&
t
,
0
,
sizeof
(
struct
hmark_tuple
));
if
(
info
->
flags
&
XT_HMARK_FLAG
(
XT_HMARK_CT
))
{
if
(
hmark_ct_set_htuple
(
skb
,
&
t
,
info
)
<
0
)
return
XT_CONTINUE
;
}
else
{
if
(
hmark_pkt_set_htuple_ipv6
(
skb
,
&
t
,
info
)
<
0
)
return
XT_CONTINUE
;
}
skb
->
mark
=
hmark_hash
(
&
t
,
info
);
return
XT_CONTINUE
;
}
#endif
static
int
get_inner_hdr
(
const
struct
sk_buff
*
skb
,
int
iphsz
,
int
*
nhoff
)
{
const
struct
icmphdr
*
icmph
;
struct
icmphdr
_ih
;
/* Not enough header? */
icmph
=
skb_header_pointer
(
skb
,
*
nhoff
+
iphsz
,
sizeof
(
_ih
),
&
_ih
);
if
(
icmph
==
NULL
&&
icmph
->
type
>
NR_ICMP_TYPES
)
return
0
;
/* Error message? */
if
(
icmph
->
type
!=
ICMP_DEST_UNREACH
&&
icmph
->
type
!=
ICMP_SOURCE_QUENCH
&&
icmph
->
type
!=
ICMP_TIME_EXCEEDED
&&
icmph
->
type
!=
ICMP_PARAMETERPROB
&&
icmph
->
type
!=
ICMP_REDIRECT
)
return
0
;
*
nhoff
+=
iphsz
+
sizeof
(
_ih
);
return
1
;
}
static
int
hmark_pkt_set_htuple_ipv4
(
const
struct
sk_buff
*
skb
,
struct
hmark_tuple
*
t
,
const
struct
xt_hmark_info
*
info
)
{
struct
iphdr
*
ip
,
_ip
;
int
nhoff
=
skb_network_offset
(
skb
);
ip
=
(
struct
iphdr
*
)
(
skb
->
data
+
nhoff
);
if
(
ip
->
protocol
==
IPPROTO_ICMP
)
{
/* Use inner header in case of ICMP errors */
if
(
get_inner_hdr
(
skb
,
ip
->
ihl
*
4
,
&
nhoff
))
{
ip
=
skb_header_pointer
(
skb
,
nhoff
,
sizeof
(
_ip
),
&
_ip
);
if
(
ip
==
NULL
)
return
-
1
;
}
}
t
->
src
=
(
__force
u32
)
ip
->
saddr
;
t
->
dst
=
(
__force
u32
)
ip
->
daddr
;
t
->
src
&=
info
->
src_mask
.
ip
;
t
->
dst
&=
info
->
dst_mask
.
ip
;
if
(
info
->
flags
&
XT_HMARK_FLAG
(
XT_HMARK_METHOD_L3
))
return
0
;
t
->
proto
=
ip
->
protocol
;
/* ICMP has no ports, skip */
if
(
t
->
proto
==
IPPROTO_ICMP
)
return
0
;
/* follow-up fragments don't contain ports, skip all fragments */
if
(
ip
->
frag_off
&
htons
(
IP_MF
|
IP_OFFSET
))
return
0
;
hmark_set_tuple_ports
(
skb
,
(
ip
->
ihl
*
4
)
+
nhoff
,
t
,
info
);
return
0
;
}
static
unsigned
int
hmark_tg_v4
(
struct
sk_buff
*
skb
,
const
struct
xt_action_param
*
par
)
{
const
struct
xt_hmark_info
*
info
=
par
->
targinfo
;
struct
hmark_tuple
t
;
memset
(
&
t
,
0
,
sizeof
(
struct
hmark_tuple
));
if
(
info
->
flags
&
XT_HMARK_FLAG
(
XT_HMARK_CT
))
{
if
(
hmark_ct_set_htuple
(
skb
,
&
t
,
info
)
<
0
)
return
XT_CONTINUE
;
}
else
{
if
(
hmark_pkt_set_htuple_ipv4
(
skb
,
&
t
,
info
)
<
0
)
return
XT_CONTINUE
;
}
skb
->
mark
=
hmark_hash
(
&
t
,
info
);
return
XT_CONTINUE
;
}
static
int
hmark_tg_check
(
const
struct
xt_tgchk_param
*
par
)
{
const
struct
xt_hmark_info
*
info
=
par
->
targinfo
;
if
(
!
info
->
hmodulus
)
{
pr_info
(
"xt_HMARK: hash modulus can't be zero
\n
"
);
return
-
EINVAL
;
}
if
(
info
->
proto_mask
&&
(
info
->
flags
&
XT_HMARK_FLAG
(
XT_HMARK_METHOD_L3
)))
{
pr_info
(
"xt_HMARK: proto mask must be zero with L3 mode
\n
"
);
return
-
EINVAL
;
}
if
(
info
->
flags
&
XT_HMARK_FLAG
(
XT_HMARK_SPI_MASK
)
&&
(
info
->
flags
&
(
XT_HMARK_FLAG
(
XT_HMARK_SPORT_MASK
)
|
XT_HMARK_FLAG
(
XT_HMARK_DPORT_MASK
))))
{
pr_info
(
"xt_HMARK: spi-mask and port-mask can't be combined
\n
"
);
return
-
EINVAL
;
}
if
(
info
->
flags
&
XT_HMARK_FLAG
(
XT_HMARK_SPI
)
&&
(
info
->
flags
&
(
XT_HMARK_FLAG
(
XT_HMARK_SPORT
)
|
XT_HMARK_FLAG
(
XT_HMARK_DPORT
))))
{
pr_info
(
"xt_HMARK: spi-set and port-set can't be combined
\n
"
);
return
-
EINVAL
;
}
return
0
;
}
static
struct
xt_target
hmark_tg_reg
[]
__read_mostly
=
{
{
.
name
=
"HMARK"
,
.
family
=
NFPROTO_IPV4
,
.
target
=
hmark_tg_v4
,
.
targetsize
=
sizeof
(
struct
xt_hmark_info
),
.
checkentry
=
hmark_tg_check
,
.
me
=
THIS_MODULE
,
},
#if IS_ENABLED(CONFIG_IP6_NF_IPTABLES)
{
.
name
=
"HMARK"
,
.
family
=
NFPROTO_IPV6
,
.
target
=
hmark_tg_v6
,
.
targetsize
=
sizeof
(
struct
xt_hmark_info
),
.
checkentry
=
hmark_tg_check
,
.
me
=
THIS_MODULE
,
},
#endif
};
static
int
__init
hmark_tg_init
(
void
)
{
return
xt_register_targets
(
hmark_tg_reg
,
ARRAY_SIZE
(
hmark_tg_reg
));
}
static
void
__exit
hmark_tg_exit
(
void
)
{
xt_unregister_targets
(
hmark_tg_reg
,
ARRAY_SIZE
(
hmark_tg_reg
));
}
module_init
(
hmark_tg_init
);
module_exit
(
hmark_tg_exit
);
net/netfilter/xt_TPROXY.c
浏览文件 @
958a7586
...
...
@@ -282,10 +282,10 @@ tproxy_tg6_v1(struct sk_buff *skb, const struct xt_action_param *par)
struct
sock
*
sk
;
const
struct
in6_addr
*
laddr
;
__be16
lport
;
int
thoff
;
int
thoff
=
0
;
int
tproto
;
tproto
=
ipv6_find_hdr
(
skb
,
&
thoff
,
-
1
,
NULL
);
tproto
=
ipv6_find_hdr
(
skb
,
&
thoff
,
-
1
,
NULL
,
NULL
);
if
(
tproto
<
0
)
{
pr_debug
(
"unable to find transport header in IPv6 packet, dropping
\n
"
);
return
NF_DROP
;
...
...
net/netfilter/xt_hashlimit.c
浏览文件 @
958a7586
...
...
@@ -388,9 +388,20 @@ static void htable_put(struct xt_hashlimit_htable *hinfo)
#define CREDITS_PER_JIFFY POW2_BELOW32(MAX_CPJ)
/* in byte mode, the lowest possible rate is one packet/second.
* credit_cap is used as a counter that tells us how many times we can
* refill the "credits available" counter when it becomes empty.
*/
#define MAX_CPJ_BYTES (0xFFFFFFFF / HZ)
#define CREDITS_PER_JIFFY_BYTES POW2_BELOW32(MAX_CPJ_BYTES)
static
u32
xt_hashlimit_len_to_chunks
(
u32
len
)
{
return
(
len
>>
XT_HASHLIMIT_BYTE_SHIFT
)
+
1
;
}
/* Precision saver. */
static
inline
u_int32_t
user2credits
(
u_int32_t
user
)
static
u32
user2credits
(
u32
user
)
{
/* If multiplying would overflow... */
if
(
user
>
0xFFFFFFFF
/
(
HZ
*
CREDITS_PER_JIFFY
))
...
...
@@ -400,12 +411,53 @@ user2credits(u_int32_t user)
return
(
user
*
HZ
*
CREDITS_PER_JIFFY
)
/
XT_HASHLIMIT_SCALE
;
}
static
inline
void
rateinfo_recalc
(
struct
dsthash_ent
*
dh
,
unsigned
long
now
)
static
u32
user2credits_byte
(
u32
user
)
{
dh
->
rateinfo
.
credit
+=
(
now
-
dh
->
rateinfo
.
prev
)
*
CREDITS_PER_JIFFY
;
if
(
dh
->
rateinfo
.
credit
>
dh
->
rateinfo
.
credit_cap
)
dh
->
rateinfo
.
credit
=
dh
->
rateinfo
.
credit_cap
;
u64
us
=
user
;
us
*=
HZ
*
CREDITS_PER_JIFFY_BYTES
;
return
(
u32
)
(
us
>>
32
);
}
static
void
rateinfo_recalc
(
struct
dsthash_ent
*
dh
,
unsigned
long
now
,
u32
mode
)
{
unsigned
long
delta
=
now
-
dh
->
rateinfo
.
prev
;
u32
cap
;
if
(
delta
==
0
)
return
;
dh
->
rateinfo
.
prev
=
now
;
if
(
mode
&
XT_HASHLIMIT_BYTES
)
{
u32
tmp
=
dh
->
rateinfo
.
credit
;
dh
->
rateinfo
.
credit
+=
CREDITS_PER_JIFFY_BYTES
*
delta
;
cap
=
CREDITS_PER_JIFFY_BYTES
*
HZ
;
if
(
tmp
>=
dh
->
rateinfo
.
credit
)
{
/* overflow */
dh
->
rateinfo
.
credit
=
cap
;
return
;
}
}
else
{
dh
->
rateinfo
.
credit
+=
delta
*
CREDITS_PER_JIFFY
;
cap
=
dh
->
rateinfo
.
credit_cap
;
}
if
(
dh
->
rateinfo
.
credit
>
cap
)
dh
->
rateinfo
.
credit
=
cap
;
}
static
void
rateinfo_init
(
struct
dsthash_ent
*
dh
,
struct
xt_hashlimit_htable
*
hinfo
)
{
dh
->
rateinfo
.
prev
=
jiffies
;
if
(
hinfo
->
cfg
.
mode
&
XT_HASHLIMIT_BYTES
)
{
dh
->
rateinfo
.
credit
=
CREDITS_PER_JIFFY_BYTES
*
HZ
;
dh
->
rateinfo
.
cost
=
user2credits_byte
(
hinfo
->
cfg
.
avg
);
dh
->
rateinfo
.
credit_cap
=
hinfo
->
cfg
.
burst
;
}
else
{
dh
->
rateinfo
.
credit
=
user2credits
(
hinfo
->
cfg
.
avg
*
hinfo
->
cfg
.
burst
);
dh
->
rateinfo
.
cost
=
user2credits
(
hinfo
->
cfg
.
avg
);
dh
->
rateinfo
.
credit_cap
=
dh
->
rateinfo
.
credit
;
}
}
static
inline
__be32
maskl
(
__be32
a
,
unsigned
int
l
)
...
...
@@ -511,6 +563,21 @@ hashlimit_init_dst(const struct xt_hashlimit_htable *hinfo,
return
0
;
}
static
u32
hashlimit_byte_cost
(
unsigned
int
len
,
struct
dsthash_ent
*
dh
)
{
u64
tmp
=
xt_hashlimit_len_to_chunks
(
len
);
tmp
=
tmp
*
dh
->
rateinfo
.
cost
;
if
(
unlikely
(
tmp
>
CREDITS_PER_JIFFY_BYTES
*
HZ
))
tmp
=
CREDITS_PER_JIFFY_BYTES
*
HZ
;
if
(
dh
->
rateinfo
.
credit
<
tmp
&&
dh
->
rateinfo
.
credit_cap
)
{
dh
->
rateinfo
.
credit_cap
--
;
dh
->
rateinfo
.
credit
=
CREDITS_PER_JIFFY_BYTES
*
HZ
;
}
return
(
u32
)
tmp
;
}
static
bool
hashlimit_mt
(
const
struct
sk_buff
*
skb
,
struct
xt_action_param
*
par
)
{
...
...
@@ -519,6 +586,7 @@ hashlimit_mt(const struct sk_buff *skb, struct xt_action_param *par)
unsigned
long
now
=
jiffies
;
struct
dsthash_ent
*
dh
;
struct
dsthash_dst
dst
;
u32
cost
;
if
(
hashlimit_init_dst
(
hinfo
,
&
dst
,
skb
,
par
->
thoff
)
<
0
)
goto
hotdrop
;
...
...
@@ -532,21 +600,21 @@ hashlimit_mt(const struct sk_buff *skb, struct xt_action_param *par)
goto
hotdrop
;
}
dh
->
expires
=
jiffies
+
msecs_to_jiffies
(
hinfo
->
cfg
.
expire
);
dh
->
rateinfo
.
prev
=
jiffies
;
dh
->
rateinfo
.
credit
=
user2credits
(
hinfo
->
cfg
.
avg
*
hinfo
->
cfg
.
burst
);
dh
->
rateinfo
.
credit_cap
=
user2credits
(
hinfo
->
cfg
.
avg
*
hinfo
->
cfg
.
burst
);
dh
->
rateinfo
.
cost
=
user2credits
(
hinfo
->
cfg
.
avg
);
rateinfo_init
(
dh
,
hinfo
);
}
else
{
/* update expiration timeout */
dh
->
expires
=
now
+
msecs_to_jiffies
(
hinfo
->
cfg
.
expire
);
rateinfo_recalc
(
dh
,
now
);
rateinfo_recalc
(
dh
,
now
,
hinfo
->
cfg
.
mode
);
}
if
(
dh
->
rateinfo
.
credit
>=
dh
->
rateinfo
.
cost
)
{
if
(
info
->
cfg
.
mode
&
XT_HASHLIMIT_BYTES
)
cost
=
hashlimit_byte_cost
(
skb
->
len
,
dh
);
else
cost
=
dh
->
rateinfo
.
cost
;
if
(
dh
->
rateinfo
.
credit
>=
cost
)
{
/* below the limit */
dh
->
rateinfo
.
credit
-=
dh
->
rateinfo
.
cost
;
dh
->
rateinfo
.
credit
-=
cost
;
spin_unlock
(
&
dh
->
lock
);
rcu_read_unlock_bh
();
return
!
(
info
->
cfg
.
mode
&
XT_HASHLIMIT_INVERT
);
...
...
@@ -568,14 +636,6 @@ static int hashlimit_mt_check(const struct xt_mtchk_param *par)
struct
xt_hashlimit_mtinfo1
*
info
=
par
->
matchinfo
;
int
ret
;
/* Check for overflow. */
if
(
info
->
cfg
.
burst
==
0
||
user2credits
(
info
->
cfg
.
avg
*
info
->
cfg
.
burst
)
<
user2credits
(
info
->
cfg
.
avg
))
{
pr_info
(
"overflow, try lower: %u/%u
\n
"
,
info
->
cfg
.
avg
,
info
->
cfg
.
burst
);
return
-
ERANGE
;
}
if
(
info
->
cfg
.
gc_interval
==
0
||
info
->
cfg
.
expire
==
0
)
return
-
EINVAL
;
if
(
info
->
name
[
sizeof
(
info
->
name
)
-
1
]
!=
'\0'
)
...
...
@@ -588,6 +648,26 @@ static int hashlimit_mt_check(const struct xt_mtchk_param *par)
return
-
EINVAL
;
}
if
(
info
->
cfg
.
mode
>=
XT_HASHLIMIT_MAX
)
{
pr_info
(
"Unknown mode mask %X, kernel too old?
\n
"
,
info
->
cfg
.
mode
);
return
-
EINVAL
;
}
/* Check for overflow. */
if
(
info
->
cfg
.
mode
&
XT_HASHLIMIT_BYTES
)
{
if
(
user2credits_byte
(
info
->
cfg
.
avg
)
==
0
)
{
pr_info
(
"overflow, rate too high: %u
\n
"
,
info
->
cfg
.
avg
);
return
-
EINVAL
;
}
}
else
if
(
info
->
cfg
.
burst
==
0
||
user2credits
(
info
->
cfg
.
avg
*
info
->
cfg
.
burst
)
<
user2credits
(
info
->
cfg
.
avg
))
{
pr_info
(
"overflow, try lower: %u/%u
\n
"
,
info
->
cfg
.
avg
,
info
->
cfg
.
burst
);
return
-
ERANGE
;
}
mutex_lock
(
&
hashlimit_mutex
);
info
->
hinfo
=
htable_find_get
(
net
,
info
->
name
,
par
->
family
);
if
(
info
->
hinfo
==
NULL
)
{
...
...
@@ -680,10 +760,11 @@ static int dl_seq_real_show(struct dsthash_ent *ent, u_int8_t family,
struct
seq_file
*
s
)
{
int
res
;
const
struct
xt_hashlimit_htable
*
ht
=
s
->
private
;
spin_lock
(
&
ent
->
lock
);
/* recalculate to show accurate numbers */
rateinfo_recalc
(
ent
,
jiffies
);
rateinfo_recalc
(
ent
,
jiffies
,
ht
->
cfg
.
mode
);
switch
(
family
)
{
case
NFPROTO_IPV4
:
...
...
net/netfilter/xt_limit.c
浏览文件 @
958a7586
...
...
@@ -88,8 +88,7 @@ limit_mt(const struct sk_buff *skb, struct xt_action_param *par)
}
/* Precision saver. */
static
u_int32_t
user2credits
(
u_int32_t
user
)
static
u32
user2credits
(
u32
user
)
{
/* If multiplying would overflow... */
if
(
user
>
0xFFFFFFFF
/
(
HZ
*
CREDITS_PER_JIFFY
))
...
...
@@ -123,7 +122,7 @@ static int limit_mt_check(const struct xt_mtchk_param *par)
128. */
priv
->
prev
=
jiffies
;
priv
->
credit
=
user2credits
(
r
->
avg
*
r
->
burst
);
/* Credits full. */
r
->
credit_cap
=
user2credits
(
r
->
avg
*
r
->
burst
)
;
/* Credits full. */
r
->
credit_cap
=
priv
->
credit
;
/* Credits full. */
r
->
cost
=
user2credits
(
r
->
avg
);
}
return
0
;
...
...
net/netfilter/xt_mac.c
浏览文件 @
958a7586
...
...
@@ -36,7 +36,7 @@ static bool mac_mt(const struct sk_buff *skb, struct xt_action_param *par)
return
false
;
if
(
skb_mac_header
(
skb
)
+
ETH_HLEN
>
skb
->
data
)
return
false
;
ret
=
compare_ether_addr
(
eth_hdr
(
skb
)
->
h_source
,
info
->
srcaddr
)
==
0
;
ret
=
ether_addr_equal
(
eth_hdr
(
skb
)
->
h_source
,
info
->
srcaddr
)
;
ret
^=
info
->
invert
;
return
ret
;
}
...
...
net/netfilter/xt_socket.c
浏览文件 @
958a7586
...
...
@@ -263,10 +263,10 @@ socket_mt6_v1(const struct sk_buff *skb, struct xt_action_param *par)
struct
sock
*
sk
;
struct
in6_addr
*
daddr
,
*
saddr
;
__be16
dport
,
sport
;
int
thoff
,
tproto
;
int
thoff
=
0
,
tproto
;
const
struct
xt_socket_mtinfo1
*
info
=
(
struct
xt_socket_mtinfo1
*
)
par
->
matchinfo
;
tproto
=
ipv6_find_hdr
(
skb
,
&
thoff
,
-
1
,
NULL
);
tproto
=
ipv6_find_hdr
(
skb
,
&
thoff
,
-
1
,
NULL
,
NULL
);
if
(
tproto
<
0
)
{
pr_debug
(
"unable to find transport header in IPv6 packet, dropping
\n
"
);
return
NF_DROP
;
...
...
net/wireless/ibss.c
浏览文件 @
958a7586
...
...
@@ -473,7 +473,7 @@ int cfg80211_ibss_wext_siwap(struct net_device *dev,
/* fixed already - and no change */
if
(
wdev
->
wext
.
ibss
.
bssid
&&
bssid
&&
compare_ether_addr
(
bssid
,
wdev
->
wext
.
ibss
.
bssid
)
==
0
)
ether_addr_equal
(
bssid
,
wdev
->
wext
.
ibss
.
bssid
)
)
return
0
;
wdev_lock
(
wdev
);
...
...
net/wireless/mlme.c
浏览文件 @
958a7586
...
...
@@ -101,7 +101,7 @@ void __cfg80211_send_deauth(struct net_device *dev,
ASSERT_WDEV_LOCK
(
wdev
);
if
(
wdev
->
current_bss
&&
compare_ether_addr
(
wdev
->
current_bss
->
pub
.
bssid
,
bssid
)
==
0
)
{
ether_addr_equal
(
wdev
->
current_bss
->
pub
.
bssid
,
bssid
)
)
{
cfg80211_unhold_bss
(
wdev
->
current_bss
);
cfg80211_put_bss
(
&
wdev
->
current_bss
->
pub
);
wdev
->
current_bss
=
NULL
;
...
...
@@ -116,7 +116,7 @@ void __cfg80211_send_deauth(struct net_device *dev,
reason_code
=
le16_to_cpu
(
mgmt
->
u
.
deauth
.
reason_code
);
from_ap
=
compare_ether_addr
(
mgmt
->
sa
,
dev
->
dev_addr
)
!=
0
;
from_ap
=
!
ether_addr_equal
(
mgmt
->
sa
,
dev
->
dev_addr
)
;
__cfg80211_disconnected
(
dev
,
NULL
,
0
,
reason_code
,
from_ap
);
}
else
if
(
wdev
->
sme_state
==
CFG80211_SME_CONNECTING
)
{
__cfg80211_connect_result
(
dev
,
mgmt
->
bssid
,
NULL
,
0
,
NULL
,
0
,
...
...
@@ -155,7 +155,7 @@ void __cfg80211_send_disassoc(struct net_device *dev,
return
;
if
(
wdev
->
current_bss
&&
compare_ether_addr
(
wdev
->
current_bss
->
pub
.
bssid
,
bssid
)
==
0
)
{
ether_addr_equal
(
wdev
->
current_bss
->
pub
.
bssid
,
bssid
)
)
{
cfg80211_sme_disassoc
(
dev
,
wdev
->
current_bss
);
cfg80211_unhold_bss
(
wdev
->
current_bss
);
cfg80211_put_bss
(
&
wdev
->
current_bss
->
pub
);
...
...
@@ -166,7 +166,7 @@ void __cfg80211_send_disassoc(struct net_device *dev,
reason_code
=
le16_to_cpu
(
mgmt
->
u
.
disassoc
.
reason_code
);
from_ap
=
compare_ether_addr
(
mgmt
->
sa
,
dev
->
dev_addr
)
!=
0
;
from_ap
=
!
ether_addr_equal
(
mgmt
->
sa
,
dev
->
dev_addr
)
;
__cfg80211_disconnected
(
dev
,
NULL
,
0
,
reason_code
,
from_ap
);
}
EXPORT_SYMBOL
(
__cfg80211_send_disassoc
);
...
...
@@ -286,7 +286,7 @@ int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
return
-
EINVAL
;
if
(
wdev
->
current_bss
&&
compare_ether_addr
(
bssid
,
wdev
->
current_bss
->
pub
.
bssid
)
==
0
)
ether_addr_equal
(
bssid
,
wdev
->
current_bss
->
pub
.
bssid
)
)
return
-
EALREADY
;
memset
(
&
req
,
0
,
sizeof
(
req
));
...
...
@@ -363,7 +363,7 @@ int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
memset
(
&
req
,
0
,
sizeof
(
req
));
if
(
wdev
->
current_bss
&&
prev_bssid
&&
compare_ether_addr
(
wdev
->
current_bss
->
pub
.
bssid
,
prev_bssid
)
==
0
)
{
ether_addr_equal
(
wdev
->
current_bss
->
pub
.
bssid
,
prev_bssid
)
)
{
/*
* Trying to reassociate: Allow this to proceed and let the old
* association to be dropped when the new one is completed.
...
...
@@ -447,8 +447,7 @@ int __cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev,
if
(
local_state_change
)
{
if
(
wdev
->
current_bss
&&
compare_ether_addr
(
wdev
->
current_bss
->
pub
.
bssid
,
bssid
)
==
0
)
{
ether_addr_equal
(
wdev
->
current_bss
->
pub
.
bssid
,
bssid
))
{
cfg80211_unhold_bss
(
wdev
->
current_bss
);
cfg80211_put_bss
(
&
wdev
->
current_bss
->
pub
);
wdev
->
current_bss
=
NULL
;
...
...
@@ -497,7 +496,7 @@ static int __cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev,
req
.
local_state_change
=
local_state_change
;
req
.
ie
=
ie
;
req
.
ie_len
=
ie_len
;
if
(
compare_ether_addr
(
wdev
->
current_bss
->
pub
.
bssid
,
bssid
)
==
0
)
if
(
ether_addr_equal
(
wdev
->
current_bss
->
pub
.
bssid
,
bssid
)
)
req
.
bss
=
&
wdev
->
current_bss
->
pub
;
else
return
-
ENOTCONN
;
...
...
@@ -760,8 +759,8 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev,
break
;
}
if
(
compare_ether_addr
(
wdev
->
current_bss
->
pub
.
bssid
,
mgmt
->
bssid
))
{
if
(
!
ether_addr_equal
(
wdev
->
current_bss
->
pub
.
bssid
,
mgmt
->
bssid
))
{
err
=
-
ENOTCONN
;
break
;
}
...
...
@@ -774,8 +773,8 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev,
break
;
/* for station, check that DA is the AP */
if
(
compare_ether_addr
(
wdev
->
current_bss
->
pub
.
bssid
,
mgmt
->
da
))
{
if
(
!
ether_addr_equal
(
wdev
->
current_bss
->
pub
.
bssid
,
mgmt
->
da
))
{
err
=
-
ENOTCONN
;
break
;
}
...
...
@@ -783,11 +782,11 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev,
case
NL80211_IFTYPE_AP
:
case
NL80211_IFTYPE_P2P_GO
:
case
NL80211_IFTYPE_AP_VLAN
:
if
(
compare_ether_addr
(
mgmt
->
bssid
,
dev
->
dev_addr
))
if
(
!
ether_addr_equal
(
mgmt
->
bssid
,
dev
->
dev_addr
))
err
=
-
EINVAL
;
break
;
case
NL80211_IFTYPE_MESH_POINT
:
if
(
compare_ether_addr
(
mgmt
->
sa
,
mgmt
->
bssid
))
{
if
(
!
ether_addr_equal
(
mgmt
->
sa
,
mgmt
->
bssid
))
{
err
=
-
EINVAL
;
break
;
}
...
...
@@ -806,7 +805,7 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev,
return
err
;
}
if
(
compare_ether_addr
(
mgmt
->
sa
,
dev
->
dev_addr
)
!=
0
)
if
(
!
ether_addr_equal
(
mgmt
->
sa
,
dev
->
dev_addr
)
)
return
-
EINVAL
;
/* Transmit the Action frame as requested by user space */
...
...
net/wireless/scan.c
浏览文件 @
958a7586
...
...
@@ -281,7 +281,7 @@ static bool is_bss(struct cfg80211_bss *a,
{
const
u8
*
ssidie
;
if
(
bssid
&&
compare_ether_addr
(
a
->
bssid
,
bssid
))
if
(
bssid
&&
!
ether_addr_equal
(
a
->
bssid
,
bssid
))
return
false
;
if
(
!
ssid
)
...
...
net/wireless/util.c
浏览文件 @
958a7586
...
...
@@ -370,7 +370,7 @@ int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr,
iftype
!=
NL80211_IFTYPE_P2P_CLIENT
&&
iftype
!=
NL80211_IFTYPE_MESH_POINT
)
||
(
is_multicast_ether_addr
(
dst
)
&&
!
compare_ether_addr
(
src
,
addr
)))
ether_addr_equal
(
src
,
addr
)))
return
-
1
;
if
(
iftype
==
NL80211_IFTYPE_MESH_POINT
)
{
struct
ieee80211s_hdr
*
meshdr
=
...
...
@@ -398,9 +398,9 @@ int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr,
payload
=
skb
->
data
+
hdrlen
;
ethertype
=
(
payload
[
6
]
<<
8
)
|
payload
[
7
];
if
(
likely
((
compare_ether_addr
(
payload
,
rfc1042_header
)
==
0
&&
if
(
likely
((
ether_addr_equal
(
payload
,
rfc1042_header
)
&&
ethertype
!=
ETH_P_AARP
&&
ethertype
!=
ETH_P_IPX
)
||
compare_ether_addr
(
payload
,
bridge_tunnel_header
)
==
0
))
{
ether_addr_equal
(
payload
,
bridge_tunnel_header
)
))
{
/* remove RFC1042 or Bridge-Tunnel encapsulation and
* replace EtherType */
skb_pull
(
skb
,
hdrlen
+
6
);
...
...
@@ -609,10 +609,9 @@ void ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list,
payload
=
frame
->
data
;
ethertype
=
(
payload
[
6
]
<<
8
)
|
payload
[
7
];
if
(
likely
((
compare_ether_addr
(
payload
,
rfc1042_header
)
==
0
&&
if
(
likely
((
ether_addr_equal
(
payload
,
rfc1042_header
)
&&
ethertype
!=
ETH_P_AARP
&&
ethertype
!=
ETH_P_IPX
)
||
compare_ether_addr
(
payload
,
bridge_tunnel_header
)
==
0
))
{
ether_addr_equal
(
payload
,
bridge_tunnel_header
)))
{
/* remove RFC1042 or Bridge-Tunnel
* encapsulation and replace EtherType */
skb_pull
(
frame
,
6
);
...
...
net/wireless/wext-sme.c
浏览文件 @
958a7586
...
...
@@ -276,7 +276,7 @@ int cfg80211_mgd_wext_siwap(struct net_device *dev,
/* fixed already - and no change */
if
(
wdev
->
wext
.
connect
.
bssid
&&
bssid
&&
compare_ether_addr
(
bssid
,
wdev
->
wext
.
connect
.
bssid
)
==
0
)
ether_addr_equal
(
bssid
,
wdev
->
wext
.
connect
.
bssid
)
)
goto
out
;
err
=
__cfg80211_disconnect
(
rdev
,
dev
,
...
...
net/wireless/wext-spy.c
浏览文件 @
958a7586
...
...
@@ -203,7 +203,7 @@ void wireless_spy_update(struct net_device * dev,
/* Update all records that match */
for
(
i
=
0
;
i
<
spydata
->
spy_number
;
i
++
)
if
(
!
compare_ether_addr
(
address
,
spydata
->
spy_address
[
i
]))
{
if
(
ether_addr_equal
(
address
,
spydata
->
spy_address
[
i
]))
{
memcpy
(
&
(
spydata
->
spy_stat
[
i
]),
wstats
,
sizeof
(
struct
iw_quality
));
match
=
i
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录