Skip to contentSkip to conversation

expr: nat: add support for the new flags attribute

PATCH New Arturo Borrero Gonzalez 1 participant 2 messages Jun 26, 2014 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 expr: nat: add support for the new flags attribute

This patchs adds support for the new flags attribute in the nft_nat expression.

---

 0 files changed
include/libnftnl/expr.h +1 -0
index cfa5c66..4200c4e 100644
@@ -100,6 +100,7 @@ enum {
 	NFT_EXPR_NAT_REG_ADDR_MAX,
 	NFT_EXPR_NAT_REG_PROTO_MIN,
 	NFT_EXPR_NAT_REG_PROTO_MAX,
+	NFT_EXPR_NAT_FLAGS,
 };
 
 enum {
include/linux/netfilter/nf_tables.h +2 -0
index 2a88f64..92c211b 100644
@@ -773,6 +773,7 @@ enum nft_nat_types {
  * @NFTA_NAT_REG_ADDR_MAX: source register of address range end (NLA_U32: nft_registers)
  * @NFTA_NAT_REG_PROTO_MIN: source register of proto range start (NLA_U32: nft_registers)
  * @NFTA_NAT_REG_PROTO_MAX: source register of proto range end (NLA_U32: nft_registers)
+ * @NFTA_NAT_FLAGS: additional NAT configuration (NF_NAT_RANGE_*) (NLA_U32)
  */
 enum nft_nat_attributes {
 	NFTA_NAT_UNSPEC,
@@ -782,6 +783,7 @@ enum nft_nat_attributes {
 	NFTA_NAT_REG_ADDR_MAX,
 	NFTA_NAT_REG_PROTO_MIN,
 	NFTA_NAT_REG_PROTO_MAX,
+	NFTA_NAT_FLAGS,
 	__NFTA_NAT_MAX
 };
 #define NFTA_NAT_MAX		(__NFTA_NAT_MAX - 1)
src/expr/nat.c +45 -3

130 lines not on this page · raw message

#1 lore raw

PATCH 2/2 expr: nat: add masquerade support

This patch adds masquerade support for the nat expression.

---

 0 files changed
include/linux/netfilter/nf_tables.h +2 -0
index 92c211b..18c9365 100644
@@ -758,10 +758,12 @@ enum nft_reject_attributes {
  *
  * @NFT_NAT_SNAT: source NAT
  * @NFT_NAT_DNAT: destination NAT
+ * @NFT_NAT_MASQUERADE: masquerade NAT
  */
 enum nft_nat_types {
 	NFT_NAT_SNAT,
 	NFT_NAT_DNAT,
+	NFT_NAT_MASQUERADE,
 };
 
 /**
src/expr/nat.c +4 -0
index 51188c1..092c871 100644
@@ -205,6 +205,8 @@ static inline const char *nft_nat2str(uint16_t nat)
 		return "snat";
 	case NFT_NAT_DNAT:
 		return "dnat";
+	case NFT_NAT_MASQUERADE:
+		return "masquerade";
 	default:
 		return "unknown";
 	}
@@ -216,6 +218,8 @@ static inline int nft_str2nat(const char *nat)
 		return NFT_NAT_SNAT;
 	else if (strcmp(nat, "dnat") == 0)
 		return NFT_NAT_DNAT;
+	else if (strcmp(nat, "masquerade") == 0)
+		return NFT_NAT_MASQUERADE;
 	else {
 		errno = EINVAL;
 		return -1;