Commit 76b90019 authored by Florian Westphal's avatar Florian Westphal Committed by Pablo Neira Ayuso
Browse files

netfilter: nat: remove l4proto->nlattr_to_range



all protocols did set this to nf_nat_l4proto_nlattr_to_range, so
just call it directly.

The important difference is that we'll now also call it for
protocols that we don't support (i.e., nf_nat_proto_unknown did
not provide .nlattr_to_range).

However, there should be no harm, even icmp provided this callback.
If we don't implement a specific l4nat for this, nothing would make
use of this information, so adding a big switch/case construct listing
all supported l4protocols seems a bit pointless.

This change leaves a single function pointer in the l4proto struct.

Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent fe2d0020
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -20,9 +20,6 @@ struct nf_nat_l4proto {
			  unsigned int iphdroff, unsigned int hdroff,
			  const struct nf_conntrack_tuple *tuple,
			  enum nf_nat_manip_type maniptype);

	int (*nlattr_to_range)(struct nlattr *tb[],
			       struct nf_nat_range2 *range);
};

/* Protocol registration. */
@@ -48,7 +45,4 @@ extern const struct nf_nat_l4proto nf_nat_l4proto_sctp;
extern const struct nf_nat_l4proto nf_nat_l4proto_udplite;
#endif

int nf_nat_l4proto_nlattr_to_range(struct nlattr *tb[],
				   struct nf_nat_range2 *range);

#endif /*_NF_NAT_L4PROTO_H*/
+0 −3
Original line number Diff line number Diff line
@@ -80,9 +80,6 @@ gre_manip_pkt(struct sk_buff *skb,
static const struct nf_nat_l4proto gre = {
	.l4proto		= IPPROTO_GRE,
	.manip_pkt		= gre_manip_pkt,
#if IS_ENABLED(CONFIG_NF_CT_NETLINK)
	.nlattr_to_range	= nf_nat_l4proto_nlattr_to_range,
#endif
};

static int __init nf_nat_proto_gre_init(void)
+0 −3
Original line number Diff line number Diff line
@@ -39,7 +39,4 @@ icmp_manip_pkt(struct sk_buff *skb,
const struct nf_nat_l4proto nf_nat_l4proto_icmp = {
	.l4proto		= IPPROTO_ICMP,
	.manip_pkt		= icmp_manip_pkt,
#if IS_ENABLED(CONFIG_NF_CT_NETLINK)
	.nlattr_to_range	= nf_nat_l4proto_nlattr_to_range,
#endif
};
+0 −3
Original line number Diff line number Diff line
@@ -47,7 +47,4 @@ icmpv6_manip_pkt(struct sk_buff *skb,
const struct nf_nat_l4proto nf_nat_l4proto_icmpv6 = {
	.l4proto		= IPPROTO_ICMPV6,
	.manip_pkt		= icmpv6_manip_pkt,
#if IS_ENABLED(CONFIG_NF_CT_NETLINK)
	.nlattr_to_range	= nf_nat_l4proto_nlattr_to_range,
#endif
};
+1 −1
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ obj-$(CONFIG_NF_CONNTRACK_SANE) += nf_conntrack_sane.o
obj-$(CONFIG_NF_CONNTRACK_SIP) += nf_conntrack_sip.o
obj-$(CONFIG_NF_CONNTRACK_TFTP) += nf_conntrack_tftp.o

nf_nat-y	:= nf_nat_core.o nf_nat_proto_unknown.o nf_nat_proto_common.o \
nf_nat-y	:= nf_nat_core.o nf_nat_proto_unknown.o \
		   nf_nat_proto_udp.o nf_nat_proto_tcp.o nf_nat_helper.o

# NAT protocols (nf_nat)
Loading