mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
[NETFILTER]: ctnetlink: use netlink attribute helpers
Use NLA_PUT_BE32, nla_get_be32() etc. Signed-off-by: Patrick McHardy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
parent
838965ba22
commit
77236b6e33
7 changed files with 70 additions and 107 deletions
|
|
@ -363,10 +363,8 @@ getorigdst(struct sock *sk, int optval, void __user *user, int *len)
|
|||
static int ipv4_tuple_to_nlattr(struct sk_buff *skb,
|
||||
const struct nf_conntrack_tuple *tuple)
|
||||
{
|
||||
NLA_PUT(skb, CTA_IP_V4_SRC, sizeof(u_int32_t),
|
||||
&tuple->src.u3.ip);
|
||||
NLA_PUT(skb, CTA_IP_V4_DST, sizeof(u_int32_t),
|
||||
&tuple->dst.u3.ip);
|
||||
NLA_PUT_BE32(skb, CTA_IP_V4_SRC, tuple->src.u3.ip);
|
||||
NLA_PUT_BE32(skb, CTA_IP_V4_DST, tuple->dst.u3.ip);
|
||||
return 0;
|
||||
|
||||
nla_put_failure:
|
||||
|
|
@ -384,8 +382,8 @@ static int ipv4_nlattr_to_tuple(struct nlattr *tb[],
|
|||
if (!tb[CTA_IP_V4_SRC] || !tb[CTA_IP_V4_DST])
|
||||
return -EINVAL;
|
||||
|
||||
t->src.u3.ip = *(__be32 *)nla_data(tb[CTA_IP_V4_SRC]);
|
||||
t->dst.u3.ip = *(__be32 *)nla_data(tb[CTA_IP_V4_DST]);
|
||||
t->src.u3.ip = nla_get_be32(tb[CTA_IP_V4_SRC]);
|
||||
t->dst.u3.ip = nla_get_be32(tb[CTA_IP_V4_DST]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -234,12 +234,9 @@ icmp_error(struct sk_buff *skb, unsigned int dataoff,
|
|||
static int icmp_tuple_to_nlattr(struct sk_buff *skb,
|
||||
const struct nf_conntrack_tuple *t)
|
||||
{
|
||||
NLA_PUT(skb, CTA_PROTO_ICMP_ID, sizeof(u_int16_t),
|
||||
&t->src.u.icmp.id);
|
||||
NLA_PUT(skb, CTA_PROTO_ICMP_TYPE, sizeof(u_int8_t),
|
||||
&t->dst.u.icmp.type);
|
||||
NLA_PUT(skb, CTA_PROTO_ICMP_CODE, sizeof(u_int8_t),
|
||||
&t->dst.u.icmp.code);
|
||||
NLA_PUT_BE16(skb, CTA_PROTO_ICMP_ID, t->src.u.icmp.id);
|
||||
NLA_PUT_U8(skb, CTA_PROTO_ICMP_TYPE, t->dst.u.icmp.type);
|
||||
NLA_PUT_U8(skb, CTA_PROTO_ICMP_CODE, t->dst.u.icmp.code);
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
@ -261,12 +258,9 @@ static int icmp_nlattr_to_tuple(struct nlattr *tb[],
|
|||
|| !tb[CTA_PROTO_ICMP_ID])
|
||||
return -EINVAL;
|
||||
|
||||
tuple->dst.u.icmp.type =
|
||||
*(u_int8_t *)nla_data(tb[CTA_PROTO_ICMP_TYPE]);
|
||||
tuple->dst.u.icmp.code =
|
||||
*(u_int8_t *)nla_data(tb[CTA_PROTO_ICMP_CODE]);
|
||||
tuple->src.u.icmp.id =
|
||||
*(__be16 *)nla_data(tb[CTA_PROTO_ICMP_ID]);
|
||||
tuple->dst.u.icmp.type = nla_get_u8(tb[CTA_PROTO_ICMP_TYPE]);
|
||||
tuple->dst.u.icmp.code = nla_get_u8(tb[CTA_PROTO_ICMP_CODE]);
|
||||
tuple->src.u.icmp.id = nla_get_be16(tb[CTA_PROTO_ICMP_ID]);
|
||||
|
||||
if (tuple->dst.u.icmp.type >= sizeof(invmap)
|
||||
|| !invmap[tuple->dst.u.icmp.type])
|
||||
|
|
|
|||
|
|
@ -547,10 +547,8 @@ int
|
|||
nf_nat_port_range_to_nlattr(struct sk_buff *skb,
|
||||
const struct nf_nat_range *range)
|
||||
{
|
||||
NLA_PUT(skb, CTA_PROTONAT_PORT_MIN, sizeof(__be16),
|
||||
&range->min.tcp.port);
|
||||
NLA_PUT(skb, CTA_PROTONAT_PORT_MAX, sizeof(__be16),
|
||||
&range->max.tcp.port);
|
||||
NLA_PUT_BE16(skb, CTA_PROTONAT_PORT_MIN, range->min.tcp.port);
|
||||
NLA_PUT_BE16(skb, CTA_PROTONAT_PORT_MAX, range->max.tcp.port);
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
@ -568,8 +566,7 @@ nf_nat_port_nlattr_to_range(struct nlattr *tb[], struct nf_nat_range *range)
|
|||
|
||||
if (tb[CTA_PROTONAT_PORT_MIN]) {
|
||||
ret = 1;
|
||||
range->min.tcp.port =
|
||||
*(__be16 *)nla_data(tb[CTA_PROTONAT_PORT_MIN]);
|
||||
range->min.tcp.port = nla_get_be16(tb[CTA_PROTONAT_PORT_MIN]);
|
||||
}
|
||||
|
||||
if (!tb[CTA_PROTONAT_PORT_MAX]) {
|
||||
|
|
@ -577,8 +574,7 @@ nf_nat_port_nlattr_to_range(struct nlattr *tb[], struct nf_nat_range *range)
|
|||
range->max.tcp.port = range->min.tcp.port;
|
||||
} else {
|
||||
ret = 1;
|
||||
range->max.tcp.port =
|
||||
*(__be16 *)nla_data(tb[CTA_PROTONAT_PORT_MAX]);
|
||||
range->max.tcp.port = nla_get_be16(tb[CTA_PROTONAT_PORT_MAX]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
|||
Loading…
Reference in a new issue