forked from openvswitch/ovs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compat code required to make the NAT code in the following patch compile with Linux 3.10 - 4.6. Some compat code applies to the conntrack.c itself; these are added after the main NAT backport for conntrack.c later in the series. Signed-off-by: Jarno Rajahalme <[email protected]> Acked-by: Jesse Gross <[email protected]>
- Loading branch information
Jarno Rajahalme
committed
Jun 21, 2016
1 parent
71ce9ed
commit 0d330e4
Showing
5 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
datapath/linux/compat/include/net/netfilter/nf_conntrack_seqadj.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#ifndef _NF_CONNTRACK_SEQADJ_WRAPPER_H | ||
#define _NF_CONNTRACK_SEQADJ_WRAPPER_H | ||
|
||
#ifdef HAVE_NF_CT_SEQ_ADJUST | ||
#include_next <net/netfilter/nf_conntrack_seqadj.h> | ||
#else | ||
|
||
#include <net/netfilter/nf_nat_helper.h> | ||
|
||
/* TCP sequence number adjustment. Returns 1 on success, 0 on failure */ | ||
static inline int | ||
nf_ct_seq_adjust(struct sk_buff *skb, | ||
struct nf_conn *ct, enum ip_conntrack_info ctinfo, | ||
unsigned int protoff) | ||
{ | ||
typeof(nf_nat_seq_adjust_hook) seq_adjust; | ||
|
||
seq_adjust = rcu_dereference(nf_nat_seq_adjust_hook); | ||
if (!seq_adjust || | ||
!seq_adjust(skb, ct, ctinfo, ip_hdrlen(skb))) { | ||
NF_CT_STAT_INC_ATOMIC(nf_ct_net(ct), drop); | ||
return 0; | ||
} | ||
|
||
return 1; | ||
} | ||
|
||
#endif /* HAVE_NF_CT_SEQ_ADJUST */ | ||
|
||
#endif /* _NF_CONNTRACK_SEQADJ_WRAPPER_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#ifndef _NF_NAT_WRAPPER_H | ||
#define _NF_NAT_WRAPPER_H | ||
|
||
#include_next <net/netfilter/nf_nat.h> | ||
|
||
#ifndef HAVE_NF_CT_NAT_EXT_ADD | ||
|
||
static inline struct nf_conn_nat * | ||
nf_ct_nat_ext_add(struct nf_conn *ct) | ||
{ | ||
struct nf_conn_nat *nat = nfct_nat(ct); | ||
if (nat) | ||
return nat; | ||
|
||
if (!nf_ct_is_confirmed(ct)) | ||
nat = nf_ct_ext_add(ct, NF_CT_EXT_NAT, GFP_ATOMIC); | ||
|
||
return nat; | ||
} | ||
#endif /* HAVE_NF_CT_NAT_EXT_ADD */ | ||
|
||
#ifndef HAVE_NF_NAT_ALLOC_NULL_BINDING | ||
static inline unsigned int | ||
nf_nat_alloc_null_binding(struct nf_conn *ct, unsigned int hooknum) | ||
{ | ||
/* Force range to this IP; let proto decide mapping for | ||
* per-proto parts (hence not IP_NAT_RANGE_PROTO_SPECIFIED). | ||
* Use reply in case it's already been mangled (eg local packet). | ||
*/ | ||
union nf_inet_addr ip = | ||
(HOOK2MANIP(hooknum) == NF_NAT_MANIP_SRC ? | ||
ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3 : | ||
ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3); | ||
struct nf_nat_range range = { | ||
.flags = NF_NAT_RANGE_MAP_IPS, | ||
.min_addr = ip, | ||
.max_addr = ip, | ||
}; | ||
return nf_nat_setup_info(ct, &range, HOOK2MANIP(hooknum)); | ||
} | ||
|
||
#endif /* HAVE_NF_NAT_ALLOC_NULL_BINDING */ | ||
|
||
#endif /* _NF_NAT_WRAPPER_H */ |