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
da7d8e65
Commit
da7d8e65
authored
Sep 07, 2022
by
David S. Miller
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'netlink-be-policy'
Signed-off-by:
David S. Miller
<
davem@davemloft.net
>
parents
98ba8108
e7af210e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
7 deletions
+39
-7
include/net/netlink.h
include/net/netlink.h
+9
-0
lib/nlattr.c
lib/nlattr.c
+27
-4
net/netfilter/nft_payload.c
net/netfilter/nft_payload.c
+3
-3
No files found.
include/net/netlink.h
View file @
da7d8e65
...
...
@@ -325,6 +325,7 @@ struct nla_policy {
struct
netlink_range_validation_signed
*
range_signed
;
struct
{
s16
min
,
max
;
u8
network_byte_order
:
1
;
};
int
(
*
validate
)(
const
struct
nlattr
*
attr
,
struct
netlink_ext_ack
*
extack
);
...
...
@@ -418,6 +419,14 @@ struct nla_policy {
.type = NLA_ENSURE_INT_OR_BINARY_TYPE(tp), \
.validation_type = NLA_VALIDATE_MAX, \
.max = _max, \
.network_byte_order = 0, \
}
#define NLA_POLICY_MAX_BE(tp, _max) { \
.type = NLA_ENSURE_UINT_TYPE(tp), \
.validation_type = NLA_VALIDATE_MAX, \
.max = _max, \
.network_byte_order = 1, \
}
#define NLA_POLICY_MASK(tp, _mask) { \
...
...
lib/nlattr.c
View file @
da7d8e65
...
...
@@ -159,6 +159,31 @@ void nla_get_range_unsigned(const struct nla_policy *pt,
}
}
static
u64
nla_get_attr_bo
(
const
struct
nla_policy
*
pt
,
const
struct
nlattr
*
nla
)
{
switch
(
pt
->
type
)
{
case
NLA_U16
:
if
(
pt
->
network_byte_order
)
return
ntohs
(
nla_get_be16
(
nla
));
return
nla_get_u16
(
nla
);
case
NLA_U32
:
if
(
pt
->
network_byte_order
)
return
ntohl
(
nla_get_be32
(
nla
));
return
nla_get_u32
(
nla
);
case
NLA_U64
:
if
(
pt
->
network_byte_order
)
return
be64_to_cpu
(
nla_get_be64
(
nla
));
return
nla_get_u64
(
nla
);
}
WARN_ON_ONCE
(
1
);
return
0
;
}
static
int
nla_validate_range_unsigned
(
const
struct
nla_policy
*
pt
,
const
struct
nlattr
*
nla
,
struct
netlink_ext_ack
*
extack
,
...
...
@@ -172,12 +197,10 @@ static int nla_validate_range_unsigned(const struct nla_policy *pt,
value
=
nla_get_u8
(
nla
);
break
;
case
NLA_U16
:
value
=
nla_get_u16
(
nla
);
break
;
case
NLA_U32
:
value
=
nla_get_u32
(
nla
);
break
;
case
NLA_U64
:
value
=
nla_get_attr_bo
(
pt
,
nla
);
break
;
case
NLA_MSECS
:
value
=
nla_get_u64
(
nla
);
break
;
...
...
net/netfilter/nft_payload.c
View file @
da7d8e65
...
...
@@ -173,10 +173,10 @@ static const struct nla_policy nft_payload_policy[NFTA_PAYLOAD_MAX + 1] = {
[
NFTA_PAYLOAD_SREG
]
=
{
.
type
=
NLA_U32
},
[
NFTA_PAYLOAD_DREG
]
=
{
.
type
=
NLA_U32
},
[
NFTA_PAYLOAD_BASE
]
=
{
.
type
=
NLA_U32
},
[
NFTA_PAYLOAD_OFFSET
]
=
{
.
type
=
NLA_U32
}
,
[
NFTA_PAYLOAD_LEN
]
=
{
.
type
=
NLA_U32
}
,
[
NFTA_PAYLOAD_OFFSET
]
=
NLA_POLICY_MAX_BE
(
NLA_U32
,
255
)
,
[
NFTA_PAYLOAD_LEN
]
=
NLA_POLICY_MAX_BE
(
NLA_U32
,
255
)
,
[
NFTA_PAYLOAD_CSUM_TYPE
]
=
{
.
type
=
NLA_U32
},
[
NFTA_PAYLOAD_CSUM_OFFSET
]
=
{
.
type
=
NLA_U32
}
,
[
NFTA_PAYLOAD_CSUM_OFFSET
]
=
NLA_POLICY_MAX_BE
(
NLA_U32
,
255
)
,
[
NFTA_PAYLOAD_CSUM_FLAGS
]
=
{
.
type
=
NLA_U32
},
};
...
...
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