Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
5aa04d3a
Commit
5aa04d3a
authored
Jun 12, 2012
by
David S. Miller
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
git://1984.lsi.us.es/net
parents
e3d62d7e
d109e9af
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
34 deletions
+48
-34
include/linux/netfilter/xt_HMARK.h
include/linux/netfilter/xt_HMARK.h
+5
-0
net/netfilter/nf_conntrack_h323_main.c
net/netfilter/nf_conntrack_h323_main.c
+2
-3
net/netfilter/xt_HMARK.c
net/netfilter/xt_HMARK.c
+41
-31
No files found.
include/linux/netfilter/xt_HMARK.h
View file @
5aa04d3a
...
...
@@ -27,7 +27,12 @@ union hmark_ports {
__u16
src
;
__u16
dst
;
}
p16
;
struct
{
__be16
src
;
__be16
dst
;
}
b16
;
__u32
v32
;
__be32
b32
;
};
struct
xt_hmark_info
{
...
...
net/netfilter/nf_conntrack_h323_main.c
View file @
5aa04d3a
...
...
@@ -270,9 +270,8 @@ static int expect_rtp_rtcp(struct sk_buff *skb, struct nf_conn *ct,
return
0
;
/* RTP port is even */
port
&=
htons
(
~
1
);
rtp_port
=
port
;
rtcp_port
=
htons
(
ntohs
(
port
)
+
1
);
rtp_port
=
port
&
~
htons
(
1
);
rtcp_port
=
port
|
htons
(
1
);
/* Create expect for RTP */
if
((
rtp_exp
=
nf_ct_expect_alloc
(
ct
))
==
NULL
)
...
...
net/netfilter/xt_HMARK.c
View file @
5aa04d3a
...
...
@@ -32,13 +32,13 @@ MODULE_ALIAS("ipt_HMARK");
MODULE_ALIAS
(
"ip6t_HMARK"
);
struct
hmark_tuple
{
u
32
src
;
u
32
dst
;
__be
32
src
;
__be
32
dst
;
union
hmark_ports
uports
;
u
int8_t
proto
;
u
8
proto
;
};
static
inline
u32
hmark_addr6_mask
(
const
__u32
*
addr32
,
const
__u
32
*
mask
)
static
inline
__be32
hmark_addr6_mask
(
const
__be32
*
addr32
,
const
__be
32
*
mask
)
{
return
(
addr32
[
0
]
&
mask
[
0
])
^
(
addr32
[
1
]
&
mask
[
1
])
^
...
...
@@ -46,8 +46,8 @@ static inline u32 hmark_addr6_mask(const __u32 *addr32, const __u32 *mask)
(
addr32
[
3
]
&
mask
[
3
]);
}
static
inline
u
32
hmark_addr_mask
(
int
l3num
,
const
__
u32
*
addr32
,
const
__u
32
*
mask
)
static
inline
__be
32
hmark_addr_mask
(
int
l3num
,
const
__
be32
*
addr32
,
const
__be
32
*
mask
)
{
switch
(
l3num
)
{
case
AF_INET
:
...
...
@@ -58,6 +58,22 @@ hmark_addr_mask(int l3num, const __u32 *addr32, const __u32 *mask)
return
0
;
}
static
inline
void
hmark_swap_ports
(
union
hmark_ports
*
uports
,
const
struct
xt_hmark_info
*
info
)
{
union
hmark_ports
hp
;
u16
src
,
dst
;
hp
.
b32
=
(
uports
->
b32
&
info
->
port_mask
.
b32
)
|
info
->
port_set
.
b32
;
src
=
ntohs
(
hp
.
b16
.
src
);
dst
=
ntohs
(
hp
.
b16
.
dst
);
if
(
dst
>
src
)
uports
->
v32
=
(
dst
<<
16
)
|
src
;
else
uports
->
v32
=
(
src
<<
16
)
|
dst
;
}
static
int
hmark_ct_set_htuple
(
const
struct
sk_buff
*
skb
,
struct
hmark_tuple
*
t
,
const
struct
xt_hmark_info
*
info
)
...
...
@@ -74,22 +90,19 @@ hmark_ct_set_htuple(const struct sk_buff *skb, struct hmark_tuple *t,
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
);
t
->
src
=
hmark_addr_mask
(
otuple
->
src
.
l3num
,
otuple
->
src
.
u3
.
ip6
,
info
->
src_mask
.
ip6
);
t
->
dst
=
hmark_addr_mask
(
otuple
->
src
.
l3num
,
rtuple
->
src
.
u3
.
ip6
,
info
->
dst_mask
.
ip6
);
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
);
t
->
uports
.
b16
.
src
=
otuple
->
src
.
u
.
all
;
t
->
uports
.
b16
.
dst
=
rtuple
->
src
.
u
.
all
;
hmark_swap_ports
(
&
t
->
uports
,
info
);
}
return
0
;
...
...
@@ -98,15 +111,19 @@ hmark_ct_set_htuple(const struct sk_buff *skb, struct hmark_tuple *t,
#endif
}
/* This hash function is endian independent, to ensure consistent hashing if
* the cluster is composed of big and little endian systems. */
static
inline
u32
hmark_hash
(
struct
hmark_tuple
*
t
,
const
struct
xt_hmark_info
*
info
)
{
u32
hash
;
u32
src
=
ntohl
(
t
->
src
);
u32
dst
=
ntohl
(
t
->
dst
);
if
(
t
->
dst
<
t
->
src
)
swap
(
t
->
src
,
t
->
dst
);
if
(
dst
<
src
)
swap
(
src
,
dst
);
hash
=
jhash_3words
(
t
->
src
,
t
->
dst
,
t
->
uports
.
v32
,
info
->
hashrnd
);
hash
=
jhash_3words
(
src
,
dst
,
t
->
uports
.
v32
,
info
->
hashrnd
);
hash
=
hash
^
(
t
->
proto
&
info
->
proto_mask
);
return
(((
u64
)
hash
*
info
->
hmodulus
)
>>
32
)
+
info
->
hoffset
;
...
...
@@ -126,11 +143,7 @@ hmark_set_tuple_ports(const struct sk_buff *skb, unsigned int nhoff,
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
);
hmark_swap_ports
(
&
t
->
uports
,
info
);
}
#if IS_ENABLED(CONFIG_IP6_NF_IPTABLES)
...
...
@@ -178,8 +191,8 @@ hmark_pkt_set_htuple_ipv6(const struct sk_buff *skb, struct hmark_tuple *t,
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
);
t
->
src
=
hmark_addr6_mask
(
ip6
->
saddr
.
s6_addr32
,
info
->
src_mask
.
ip6
);
t
->
dst
=
hmark_addr6_mask
(
ip6
->
daddr
.
s6_addr32
,
info
->
dst_mask
.
ip6
);
if
(
info
->
flags
&
XT_HMARK_FLAG
(
XT_HMARK_METHOD_L3
))
return
0
;
...
...
@@ -255,11 +268,8 @@ hmark_pkt_set_htuple_ipv4(const struct sk_buff *skb, struct hmark_tuple *t,
}
}
t
->
src
=
(
__force
u32
)
ip
->
saddr
;
t
->
dst
=
(
__force
u32
)
ip
->
daddr
;
t
->
src
&=
info
->
src_mask
.
ip
;
t
->
dst
&=
info
->
dst_mask
.
ip
;
t
->
src
=
ip
->
saddr
&
info
->
src_mask
.
ip
;
t
->
dst
=
ip
->
daddr
&
info
->
dst_mask
.
ip
;
if
(
info
->
flags
&
XT_HMARK_FLAG
(
XT_HMARK_METHOD_L3
))
return
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment