mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-25 16:11:45 +00:00
netfilter: nat: merge nf_nat_ipv4,6 into nat core
before: text data bss dec hex filename 16566 1576 4136 22278 5706 nf_nat.ko 3598 844 0 4442 115a nf_nat_ipv6.ko 3187 844 0 4031 fbf nf_nat_ipv4.ko after: text data bss dec hex filename 22948 1612 4136 28696 7018 nf_nat.ko ... with ipv4/v6 nat now provided directly via nf_nat.ko. Also changes: ret = nf_nat_ipv4_fn(priv, skb, state); if (ret != NF_DROP && ret != NF_STOLEN && into if (ret != NF_ACCEPT) return ret; everywhere. The nat hooks never should return anything other than ACCEPT or DROP (and the latter only in rare error cases). The original code uses multi-line ANDing including assignment-in-if: if (ret != NF_DROP && ret != NF_STOLEN && !(IPCB(skb)->flags & IPSKB_XFRM_TRANSFORMED) && (ct = nf_ct_get(skb, &ctinfo)) != NULL) { I removed this while moving, breaking those in separate conditionals and moving the assignments into extra lines. checkpatch still generates some warnings: 1. Overly long lines (of moved code). Breaking them is even more ugly. so I kept this as-is. 2. use of extern function declarations in a .c file. This is necessary evil, we must call nf_nat_l3proto_register() from the nat core now. All l3proto related functions are removed later in this series, those prototypes are then removed as well. v2: keep empty nf_nat_ipv6_csum_update stub for CONFIG_IPV6=n case. v3: remove IS_ENABLED(NF_NAT_IPV4/6) tests, NF_NAT_IPVx toggles are removed here. v4: also get rid of the assignments in conditionals. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
parent
096d09067a
commit
3bf195ae60
12 changed files with 711 additions and 738 deletions
|
@ -8,8 +8,6 @@ config OPENVSWITCH
|
|||
depends on !NF_CONNTRACK || \
|
||||
(NF_CONNTRACK && ((!NF_DEFRAG_IPV6 || NF_DEFRAG_IPV6) && \
|
||||
(!NF_NAT || NF_NAT) && \
|
||||
(!NF_NAT_IPV4 || NF_NAT_IPV4) && \
|
||||
(!NF_NAT_IPV6 || NF_NAT_IPV6) && \
|
||||
(!NETFILTER_CONNCOUNT || NETFILTER_CONNCOUNT)))
|
||||
select LIBCRC32C
|
||||
select MPLS
|
||||
|
|
|
@ -745,14 +745,14 @@ static int ovs_ct_nat_execute(struct sk_buff *skb, struct nf_conn *ct,
|
|||
switch (ctinfo) {
|
||||
case IP_CT_RELATED:
|
||||
case IP_CT_RELATED_REPLY:
|
||||
if (IS_ENABLED(CONFIG_NF_NAT_IPV4) &&
|
||||
if (IS_ENABLED(CONFIG_NF_NAT) &&
|
||||
skb->protocol == htons(ETH_P_IP) &&
|
||||
ip_hdr(skb)->protocol == IPPROTO_ICMP) {
|
||||
if (!nf_nat_icmp_reply_translation(skb, ct, ctinfo,
|
||||
hooknum))
|
||||
err = NF_DROP;
|
||||
goto push;
|
||||
} else if (IS_ENABLED(CONFIG_NF_NAT_IPV6) &&
|
||||
} else if (IS_ENABLED(CONFIG_IPV6) &&
|
||||
skb->protocol == htons(ETH_P_IPV6)) {
|
||||
__be16 frag_off;
|
||||
u8 nexthdr = ipv6_hdr(skb)->nexthdr;
|
||||
|
@ -1673,7 +1673,7 @@ static bool ovs_ct_nat_to_attr(const struct ovs_conntrack_info *info,
|
|||
}
|
||||
|
||||
if (info->range.flags & NF_NAT_RANGE_MAP_IPS) {
|
||||
if (IS_ENABLED(CONFIG_NF_NAT_IPV4) &&
|
||||
if (IS_ENABLED(CONFIG_NF_NAT) &&
|
||||
info->family == NFPROTO_IPV4) {
|
||||
if (nla_put_in_addr(skb, OVS_NAT_ATTR_IP_MIN,
|
||||
info->range.min_addr.ip) ||
|
||||
|
@ -1682,7 +1682,7 @@ static bool ovs_ct_nat_to_attr(const struct ovs_conntrack_info *info,
|
|||
(nla_put_in_addr(skb, OVS_NAT_ATTR_IP_MAX,
|
||||
info->range.max_addr.ip))))
|
||||
return false;
|
||||
} else if (IS_ENABLED(CONFIG_NF_NAT_IPV6) &&
|
||||
} else if (IS_ENABLED(CONFIG_IPV6) &&
|
||||
info->family == NFPROTO_IPV6) {
|
||||
if (nla_put_in6_addr(skb, OVS_NAT_ATTR_IP_MIN,
|
||||
&info->range.min_addr.in6) ||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue