netfilter: nft_payload: layer 4 checksum adjustment for pseudoheader fields
This patch adds a new flag that signals the kernel to update layer 4 checksum if the packet field belongs to the layer 4 pseudoheader. This implicitly provides stateless NAT 1:1 that is useful under very specific usecases. Since rules mangling layer 3 fields that are part of the pseudoheader may potentially convey any layer 4 packet, we have to deal with the layer 4 checksum adjustment using protocol specific code. This patch adds support for TCP, UDP and ICMPv6, since they include the pseudoheader in the layer 4 checksum calculation. ICMP doesn't, so we can skip it. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
@@ -45,6 +45,7 @@ struct nft_payload_set {
|
||||
enum nft_registers sreg:8;
|
||||
u8 csum_type;
|
||||
u8 csum_offset;
|
||||
u8 csum_flags;
|
||||
};
|
||||
|
||||
extern const struct nft_expr_ops nft_payload_fast_ops;
|
||||
|
@@ -659,6 +659,10 @@ enum nft_payload_csum_types {
|
||||
NFT_PAYLOAD_CSUM_INET,
|
||||
};
|
||||
|
||||
enum nft_payload_csum_flags {
|
||||
NFT_PAYLOAD_L4CSUM_PSEUDOHDR = (1 << 0),
|
||||
};
|
||||
|
||||
/**
|
||||
* enum nft_payload_attributes - nf_tables payload expression netlink attributes
|
||||
*
|
||||
@@ -669,6 +673,7 @@ enum nft_payload_csum_types {
|
||||
* @NFTA_PAYLOAD_SREG: source register to load data from (NLA_U32: nft_registers)
|
||||
* @NFTA_PAYLOAD_CSUM_TYPE: checksum type (NLA_U32)
|
||||
* @NFTA_PAYLOAD_CSUM_OFFSET: checksum offset relative to base (NLA_U32)
|
||||
* @NFTA_PAYLOAD_CSUM_FLAGS: checksum flags (NLA_U32)
|
||||
*/
|
||||
enum nft_payload_attributes {
|
||||
NFTA_PAYLOAD_UNSPEC,
|
||||
@@ -679,6 +684,7 @@ enum nft_payload_attributes {
|
||||
NFTA_PAYLOAD_SREG,
|
||||
NFTA_PAYLOAD_CSUM_TYPE,
|
||||
NFTA_PAYLOAD_CSUM_OFFSET,
|
||||
NFTA_PAYLOAD_CSUM_FLAGS,
|
||||
__NFTA_PAYLOAD_MAX
|
||||
};
|
||||
#define NFTA_PAYLOAD_MAX (__NFTA_PAYLOAD_MAX - 1)
|
||||
|
Reference in New Issue
Block a user