aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/openvswitch/Kconfig4
-rw-r--r--net/openvswitch/conntrack.c16
2 files changed, 11 insertions, 9 deletions
diff --git a/net/openvswitch/Kconfig b/net/openvswitch/Kconfig
index 234a73344c6e..ce947292ae77 100644
--- a/net/openvswitch/Kconfig
+++ b/net/openvswitch/Kconfig
@@ -7,7 +7,9 @@ config OPENVSWITCH
7 depends on INET 7 depends on INET
8 depends on !NF_CONNTRACK || \ 8 depends on !NF_CONNTRACK || \
9 (NF_CONNTRACK && ((!NF_DEFRAG_IPV6 || NF_DEFRAG_IPV6) && \ 9 (NF_CONNTRACK && ((!NF_DEFRAG_IPV6 || NF_DEFRAG_IPV6) && \
10 (!NF_NAT || NF_NAT))) 10 (!NF_NAT || NF_NAT) && \
11 (!NF_NAT_IPV4 || NF_NAT_IPV4) && \
12 (!NF_NAT_IPV6 || NF_NAT_IPV6)))
11 select LIBCRC32C 13 select LIBCRC32C
12 select MPLS 14 select MPLS
13 select NET_MPLS_GSO 15 select NET_MPLS_GSO
diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index 47f7c62761d2..3797879b0bf8 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -535,14 +535,15 @@ static int ovs_ct_nat_execute(struct sk_buff *skb, struct nf_conn *ct,
535 switch (ctinfo) { 535 switch (ctinfo) {
536 case IP_CT_RELATED: 536 case IP_CT_RELATED:
537 case IP_CT_RELATED_REPLY: 537 case IP_CT_RELATED_REPLY:
538 if (skb->protocol == htons(ETH_P_IP) && 538 if (IS_ENABLED(CONFIG_NF_NAT_IPV4) &&
539 skb->protocol == htons(ETH_P_IP) &&
539 ip_hdr(skb)->protocol == IPPROTO_ICMP) { 540 ip_hdr(skb)->protocol == IPPROTO_ICMP) {
540 if (!nf_nat_icmp_reply_translation(skb, ct, ctinfo, 541 if (!nf_nat_icmp_reply_translation(skb, ct, ctinfo,
541 hooknum)) 542 hooknum))
542 err = NF_DROP; 543 err = NF_DROP;
543 goto push; 544 goto push;
544#if IS_ENABLED(CONFIG_NF_NAT_IPV6) 545 } else if (IS_ENABLED(CONFIG_NF_NAT_IPV6) &&
545 } else if (skb->protocol == htons(ETH_P_IPV6)) { 546 skb->protocol == htons(ETH_P_IPV6)) {
546 __be16 frag_off; 547 __be16 frag_off;
547 u8 nexthdr = ipv6_hdr(skb)->nexthdr; 548 u8 nexthdr = ipv6_hdr(skb)->nexthdr;
548 int hdrlen = ipv6_skip_exthdr(skb, 549 int hdrlen = ipv6_skip_exthdr(skb,
@@ -557,7 +558,6 @@ static int ovs_ct_nat_execute(struct sk_buff *skb, struct nf_conn *ct,
557 err = NF_DROP; 558 err = NF_DROP;
558 goto push; 559 goto push;
559 } 560 }
560#endif
561 } 561 }
562 /* Non-ICMP, fall thru to initialize if needed. */ 562 /* Non-ICMP, fall thru to initialize if needed. */
563 case IP_CT_NEW: 563 case IP_CT_NEW:
@@ -1239,7 +1239,8 @@ static bool ovs_ct_nat_to_attr(const struct ovs_conntrack_info *info,
1239 } 1239 }
1240 1240
1241 if (info->range.flags & NF_NAT_RANGE_MAP_IPS) { 1241 if (info->range.flags & NF_NAT_RANGE_MAP_IPS) {
1242 if (info->family == NFPROTO_IPV4) { 1242 if (IS_ENABLED(CONFIG_NF_NAT_IPV4) &&
1243 info->family == NFPROTO_IPV4) {
1243 if (nla_put_in_addr(skb, OVS_NAT_ATTR_IP_MIN, 1244 if (nla_put_in_addr(skb, OVS_NAT_ATTR_IP_MIN,
1244 info->range.min_addr.ip) || 1245 info->range.min_addr.ip) ||
1245 (info->range.max_addr.ip 1246 (info->range.max_addr.ip
@@ -1247,8 +1248,8 @@ static bool ovs_ct_nat_to_attr(const struct ovs_conntrack_info *info,
1247 (nla_put_in_addr(skb, OVS_NAT_ATTR_IP_MAX, 1248 (nla_put_in_addr(skb, OVS_NAT_ATTR_IP_MAX,
1248 info->range.max_addr.ip)))) 1249 info->range.max_addr.ip))))
1249 return false; 1250 return false;
1250#if IS_ENABLED(CONFIG_NF_NAT_IPV6) 1251 } else if (IS_ENABLED(CONFIG_NF_NAT_IPV6) &&
1251 } else if (info->family == NFPROTO_IPV6) { 1252 info->family == NFPROTO_IPV6) {
1252 if (nla_put_in6_addr(skb, OVS_NAT_ATTR_IP_MIN, 1253 if (nla_put_in6_addr(skb, OVS_NAT_ATTR_IP_MIN,
1253 &info->range.min_addr.in6) || 1254 &info->range.min_addr.in6) ||
1254 (memcmp(&info->range.max_addr.in6, 1255 (memcmp(&info->range.max_addr.in6,
@@ -1257,7 +1258,6 @@ static bool ovs_ct_nat_to_attr(const struct ovs_conntrack_info *info,
1257 (nla_put_in6_addr(skb, OVS_NAT_ATTR_IP_MAX, 1258 (nla_put_in6_addr(skb, OVS_NAT_ATTR_IP_MAX,
1258 &info->range.max_addr.in6)))) 1259 &info->range.max_addr.in6))))
1259 return false; 1260 return false;
1260#endif
1261 } else { 1261 } else {
1262 return false; 1262 return false;
1263 } 1263 }