[NETFILTER]: nfnetlink: convert to generic netlink attribute functions
Get rid of the duplicated rtnetlink macros and use the generic netlink attribute functions. The old duplicated stuff is moved to a new header file that exists just for userspace. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
7c8d4cb419
commit
df6fb868d6
@ -340,33 +340,33 @@ static ctl_table nf_ct_ipv6_sysctl_table[] = {
|
||||
static int ipv6_tuple_to_nfattr(struct sk_buff *skb,
|
||||
const struct nf_conntrack_tuple *tuple)
|
||||
{
|
||||
NFA_PUT(skb, CTA_IP_V6_SRC, sizeof(u_int32_t) * 4,
|
||||
NLA_PUT(skb, CTA_IP_V6_SRC, sizeof(u_int32_t) * 4,
|
||||
&tuple->src.u3.ip6);
|
||||
NFA_PUT(skb, CTA_IP_V6_DST, sizeof(u_int32_t) * 4,
|
||||
NLA_PUT(skb, CTA_IP_V6_DST, sizeof(u_int32_t) * 4,
|
||||
&tuple->dst.u3.ip6);
|
||||
return 0;
|
||||
|
||||
nfattr_failure:
|
||||
nla_put_failure:
|
||||
return -1;
|
||||
}
|
||||
|
||||
static const size_t cta_min_ip[CTA_IP_MAX] = {
|
||||
[CTA_IP_V6_SRC-1] = sizeof(u_int32_t)*4,
|
||||
[CTA_IP_V6_DST-1] = sizeof(u_int32_t)*4,
|
||||
static const size_t cta_min_ip[CTA_IP_MAX+1] = {
|
||||
[CTA_IP_V6_SRC] = sizeof(u_int32_t)*4,
|
||||
[CTA_IP_V6_DST] = sizeof(u_int32_t)*4,
|
||||
};
|
||||
|
||||
static int ipv6_nfattr_to_tuple(struct nfattr *tb[],
|
||||
static int ipv6_nfattr_to_tuple(struct nlattr *tb[],
|
||||
struct nf_conntrack_tuple *t)
|
||||
{
|
||||
if (!tb[CTA_IP_V6_SRC-1] || !tb[CTA_IP_V6_DST-1])
|
||||
if (!tb[CTA_IP_V6_SRC] || !tb[CTA_IP_V6_DST])
|
||||
return -EINVAL;
|
||||
|
||||
if (nfattr_bad_size(tb, CTA_IP_MAX, cta_min_ip))
|
||||
return -EINVAL;
|
||||
|
||||
memcpy(&t->src.u3.ip6, NFA_DATA(tb[CTA_IP_V6_SRC-1]),
|
||||
memcpy(&t->src.u3.ip6, nla_data(tb[CTA_IP_V6_SRC]),
|
||||
sizeof(u_int32_t) * 4);
|
||||
memcpy(&t->dst.u3.ip6, NFA_DATA(tb[CTA_IP_V6_DST-1]),
|
||||
memcpy(&t->dst.u3.ip6, nla_data(tb[CTA_IP_V6_DST]),
|
||||
sizeof(u_int32_t) * 4);
|
||||
|
||||
return 0;
|
||||
|
@ -213,42 +213,42 @@ icmpv6_error(struct sk_buff *skb, unsigned int dataoff,
|
||||
static int icmpv6_tuple_to_nfattr(struct sk_buff *skb,
|
||||
const struct nf_conntrack_tuple *t)
|
||||
{
|
||||
NFA_PUT(skb, CTA_PROTO_ICMPV6_ID, sizeof(u_int16_t),
|
||||
NLA_PUT(skb, CTA_PROTO_ICMPV6_ID, sizeof(u_int16_t),
|
||||
&t->src.u.icmp.id);
|
||||
NFA_PUT(skb, CTA_PROTO_ICMPV6_TYPE, sizeof(u_int8_t),
|
||||
NLA_PUT(skb, CTA_PROTO_ICMPV6_TYPE, sizeof(u_int8_t),
|
||||
&t->dst.u.icmp.type);
|
||||
NFA_PUT(skb, CTA_PROTO_ICMPV6_CODE, sizeof(u_int8_t),
|
||||
NLA_PUT(skb, CTA_PROTO_ICMPV6_CODE, sizeof(u_int8_t),
|
||||
&t->dst.u.icmp.code);
|
||||
|
||||
return 0;
|
||||
|
||||
nfattr_failure:
|
||||
nla_put_failure:
|
||||
return -1;
|
||||
}
|
||||
|
||||
static const size_t cta_min_proto[CTA_PROTO_MAX] = {
|
||||
[CTA_PROTO_ICMPV6_TYPE-1] = sizeof(u_int8_t),
|
||||
[CTA_PROTO_ICMPV6_CODE-1] = sizeof(u_int8_t),
|
||||
[CTA_PROTO_ICMPV6_ID-1] = sizeof(u_int16_t)
|
||||
static const size_t cta_min_proto[CTA_PROTO_MAX+1] = {
|
||||
[CTA_PROTO_ICMPV6_TYPE] = sizeof(u_int8_t),
|
||||
[CTA_PROTO_ICMPV6_CODE] = sizeof(u_int8_t),
|
||||
[CTA_PROTO_ICMPV6_ID] = sizeof(u_int16_t)
|
||||
};
|
||||
|
||||
static int icmpv6_nfattr_to_tuple(struct nfattr *tb[],
|
||||
static int icmpv6_nfattr_to_tuple(struct nlattr *tb[],
|
||||
struct nf_conntrack_tuple *tuple)
|
||||
{
|
||||
if (!tb[CTA_PROTO_ICMPV6_TYPE-1]
|
||||
|| !tb[CTA_PROTO_ICMPV6_CODE-1]
|
||||
|| !tb[CTA_PROTO_ICMPV6_ID-1])
|
||||
if (!tb[CTA_PROTO_ICMPV6_TYPE]
|
||||
|| !tb[CTA_PROTO_ICMPV6_CODE]
|
||||
|| !tb[CTA_PROTO_ICMPV6_ID])
|
||||
return -EINVAL;
|
||||
|
||||
if (nfattr_bad_size(tb, CTA_PROTO_MAX, cta_min_proto))
|
||||
return -EINVAL;
|
||||
|
||||
tuple->dst.u.icmp.type =
|
||||
*(u_int8_t *)NFA_DATA(tb[CTA_PROTO_ICMPV6_TYPE-1]);
|
||||
*(u_int8_t *)nla_data(tb[CTA_PROTO_ICMPV6_TYPE]);
|
||||
tuple->dst.u.icmp.code =
|
||||
*(u_int8_t *)NFA_DATA(tb[CTA_PROTO_ICMPV6_CODE-1]);
|
||||
*(u_int8_t *)nla_data(tb[CTA_PROTO_ICMPV6_CODE]);
|
||||
tuple->src.u.icmp.id =
|
||||
*(__be16 *)NFA_DATA(tb[CTA_PROTO_ICMPV6_ID-1]);
|
||||
*(__be16 *)nla_data(tb[CTA_PROTO_ICMPV6_ID]);
|
||||
|
||||
if (tuple->dst.u.icmp.type < 128
|
||||
|| tuple->dst.u.icmp.type - 128 >= sizeof(invmap)
|
||||
|
Reference in New Issue
Block a user