Commit 49499c3e authored by Patrick McHardy's avatar Patrick McHardy Committed by Pablo Neira Ayuso

netfilter: nf_tables: switch registers to 32 bit addressing

Switch the nf_tables registers from 128 bit addressing to 32 bit
addressing to support so called concatenations, where multiple values
can be concatenated over multiple registers for O(1) exact matches of
multiple dimensions using sets.

The old register values are mapped to areas of 128 bits for compatibility.
When dumping register numbers, values are expressed using the old values
if they refer to the beginning of a 128 bit area for compatibility.

To support concatenations, register loads of less than a full 32 bit
value need to be padded. This mainly affects the payload and exthdr
expressions, which both unconditionally zero the last word before
copying the data.

Userspace fully passes the testsuite using both old and new register
addressing.
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent b1c96ed3
...@@ -64,17 +64,15 @@ struct nft_data { ...@@ -64,17 +64,15 @@ struct nft_data {
*/ */
struct nft_regs { struct nft_regs {
union { union {
struct nft_data data[NFT_REG_MAX + 1]; u32 data[20];
struct nft_verdict verdict; struct nft_verdict verdict;
}; };
}; };
static inline void nft_data_copy(struct nft_data *dst, static inline void nft_data_copy(u32 *dst, const struct nft_data *src,
const struct nft_data *src) unsigned int len)
{ {
BUILD_BUG_ON(__alignof__(*dst) != __alignof__(u64)); memcpy(dst, src, len);
*(u64 *)&dst->data[0] = *(u64 *)&src->data[0];
*(u64 *)&dst->data[2] = *(u64 *)&src->data[2];
} }
static inline void nft_data_debug(const struct nft_data *data) static inline void nft_data_debug(const struct nft_data *data)
...@@ -502,8 +500,7 @@ static inline struct nft_set_ext *nft_set_elem_ext(const struct nft_set *set, ...@@ -502,8 +500,7 @@ static inline struct nft_set_ext *nft_set_elem_ext(const struct nft_set *set,
void *nft_set_elem_init(const struct nft_set *set, void *nft_set_elem_init(const struct nft_set *set,
const struct nft_set_ext_tmpl *tmpl, const struct nft_set_ext_tmpl *tmpl,
const struct nft_data *key, const u32 *key, const u32 *data,
const struct nft_data *data,
u64 timeout, gfp_t gfp); u64 timeout, gfp_t gfp);
void nft_set_elem_destroy(const struct nft_set *set, void *elem); void nft_set_elem_destroy(const struct nft_set *set, void *elem);
......
...@@ -5,16 +5,45 @@ ...@@ -5,16 +5,45 @@
#define NFT_CHAIN_MAXNAMELEN 32 #define NFT_CHAIN_MAXNAMELEN 32
#define NFT_USERDATA_MAXLEN 256 #define NFT_USERDATA_MAXLEN 256
/**
* enum nft_registers - nf_tables registers
*
* nf_tables used to have five registers: a verdict register and four data
* registers of size 16. The data registers have been changed to 16 registers
* of size 4. For compatibility reasons, the NFT_REG_[1-4] registers still
* map to areas of size 16, the 4 byte registers are addressed using
* NFT_REG32_00 - NFT_REG32_15.
*/
enum nft_registers { enum nft_registers {
NFT_REG_VERDICT, NFT_REG_VERDICT,
NFT_REG_1, NFT_REG_1,
NFT_REG_2, NFT_REG_2,
NFT_REG_3, NFT_REG_3,
NFT_REG_4, NFT_REG_4,
__NFT_REG_MAX __NFT_REG_MAX,
NFT_REG32_00 = 8,
MFT_REG32_01,
NFT_REG32_02,
NFT_REG32_03,
NFT_REG32_04,
NFT_REG32_05,
NFT_REG32_06,
NFT_REG32_07,
NFT_REG32_08,
NFT_REG32_09,
NFT_REG32_10,
NFT_REG32_11,
NFT_REG32_12,
NFT_REG32_13,
NFT_REG32_14,
NFT_REG32_15,
}; };
#define NFT_REG_MAX (__NFT_REG_MAX - 1) #define NFT_REG_MAX (__NFT_REG_MAX - 1)
#define NFT_REG_SIZE 16
#define NFT_REG32_SIZE 4
/** /**
* enum nft_verdicts - nf_tables internal verdicts * enum nft_verdicts - nf_tables internal verdicts
* *
......
...@@ -24,7 +24,7 @@ static void nft_meta_bridge_get_eval(const struct nft_expr *expr, ...@@ -24,7 +24,7 @@ static void nft_meta_bridge_get_eval(const struct nft_expr *expr,
{ {
const struct nft_meta *priv = nft_expr_priv(expr); const struct nft_meta *priv = nft_expr_priv(expr);
const struct net_device *in = pkt->in, *out = pkt->out; const struct net_device *in = pkt->in, *out = pkt->out;
u32 *dest = &regs->data[priv->dreg].data[0]; u32 *dest = &regs->data[priv->dreg];
const struct net_bridge_port *p; const struct net_bridge_port *p;
switch (priv->key) { switch (priv->key) {
......
...@@ -27,9 +27,9 @@ static void nft_redir_ipv4_eval(const struct nft_expr *expr, ...@@ -27,9 +27,9 @@ static void nft_redir_ipv4_eval(const struct nft_expr *expr,
memset(&mr, 0, sizeof(mr)); memset(&mr, 0, sizeof(mr));
if (priv->sreg_proto_min) { if (priv->sreg_proto_min) {
mr.range[0].min.all = mr.range[0].min.all =
*(__be16 *)&regs->data[priv->sreg_proto_min].data[0]; *(__be16 *)&regs->data[priv->sreg_proto_min];
mr.range[0].max.all = mr.range[0].max.all =
*(__be16 *)&regs->data[priv->sreg_proto_max].data[0]; *(__be16 *)&regs->data[priv->sreg_proto_max];
mr.range[0].flags |= NF_NAT_RANGE_PROTO_SPECIFIED; mr.range[0].flags |= NF_NAT_RANGE_PROTO_SPECIFIED;
} }
......
...@@ -27,9 +27,9 @@ static void nft_redir_ipv6_eval(const struct nft_expr *expr, ...@@ -27,9 +27,9 @@ static void nft_redir_ipv6_eval(const struct nft_expr *expr,
memset(&range, 0, sizeof(range)); memset(&range, 0, sizeof(range));
if (priv->sreg_proto_min) { if (priv->sreg_proto_min) {
range.min_proto.all = range.min_proto.all =
*(__be16 *)&regs->data[priv->sreg_proto_min].data[0]; *(__be16 *)&regs->data[priv->sreg_proto_min],
range.max_proto.all = range.max_proto.all =
*(__be16 *)&regs->data[priv->sreg_proto_max].data[0]; *(__be16 *)&regs->data[priv->sreg_proto_max],
range.flags |= NF_NAT_RANGE_PROTO_SPECIFIED; range.flags |= NF_NAT_RANGE_PROTO_SPECIFIED;
} }
......
...@@ -3201,8 +3201,7 @@ static struct nft_trans *nft_trans_elem_alloc(struct nft_ctx *ctx, ...@@ -3201,8 +3201,7 @@ static struct nft_trans *nft_trans_elem_alloc(struct nft_ctx *ctx,
void *nft_set_elem_init(const struct nft_set *set, void *nft_set_elem_init(const struct nft_set *set,
const struct nft_set_ext_tmpl *tmpl, const struct nft_set_ext_tmpl *tmpl,
const struct nft_data *key, const u32 *key, const u32 *data,
const struct nft_data *data,
u64 timeout, gfp_t gfp) u64 timeout, gfp_t gfp)
{ {
struct nft_set_ext *ext; struct nft_set_ext *ext;
...@@ -3357,7 +3356,7 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set, ...@@ -3357,7 +3356,7 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set,
} }
err = -ENOMEM; err = -ENOMEM;
elem.priv = nft_set_elem_init(set, &tmpl, &elem.key, &data, elem.priv = nft_set_elem_init(set, &tmpl, elem.key.data, data.data,
timeout, GFP_KERNEL); timeout, GFP_KERNEL);
if (elem.priv == NULL) if (elem.priv == NULL)
goto err3; goto err3;
...@@ -4122,14 +4121,47 @@ static int nf_tables_check_loops(const struct nft_ctx *ctx, ...@@ -4122,14 +4121,47 @@ static int nf_tables_check_loops(const struct nft_ctx *ctx,
return 0; return 0;
} }
/**
* nft_parse_register - parse a register value from a netlink attribute
*
* @attr: netlink attribute
*
* Parse and translate a register value from a netlink attribute.
* Registers used to be 128 bit wide, these register numbers will be
* mapped to the corresponding 32 bit register numbers.
*/
unsigned int nft_parse_register(const struct nlattr *attr) unsigned int nft_parse_register(const struct nlattr *attr)
{ {
return ntohl(nla_get_be32(attr)); unsigned int reg;
reg = ntohl(nla_get_be32(attr));
switch (reg) {
case NFT_REG_VERDICT...NFT_REG_4:
return reg * NFT_REG_SIZE / NFT_REG32_SIZE;
default:
return reg + NFT_REG_SIZE / NFT_REG32_SIZE - NFT_REG32_00;
}
} }
EXPORT_SYMBOL_GPL(nft_parse_register); EXPORT_SYMBOL_GPL(nft_parse_register);
/**
* nft_dump_register - dump a register value to a netlink attribute
*
* @skb: socket buffer
* @attr: attribute number
* @reg: register number
*
* Construct a netlink attribute containing the register number. For
* compatibility reasons, register numbers being a multiple of 4 are
* translated to the corresponding 128 bit register numbers.
*/
int nft_dump_register(struct sk_buff *skb, unsigned int attr, unsigned int reg) int nft_dump_register(struct sk_buff *skb, unsigned int attr, unsigned int reg)
{ {
if (reg % (NFT_REG_SIZE / NFT_REG32_SIZE) == 0)
reg = reg / (NFT_REG_SIZE / NFT_REG32_SIZE);
else
reg = reg - NFT_REG_SIZE / NFT_REG32_SIZE + NFT_REG32_00;
return nla_put_be32(skb, attr, htonl(reg)); return nla_put_be32(skb, attr, htonl(reg));
} }
EXPORT_SYMBOL_GPL(nft_dump_register); EXPORT_SYMBOL_GPL(nft_dump_register);
...@@ -4145,14 +4177,13 @@ EXPORT_SYMBOL_GPL(nft_dump_register); ...@@ -4145,14 +4177,13 @@ EXPORT_SYMBOL_GPL(nft_dump_register);
*/ */
int nft_validate_register_load(enum nft_registers reg, unsigned int len) int nft_validate_register_load(enum nft_registers reg, unsigned int len)
{ {
if (reg <= NFT_REG_VERDICT) if (reg < NFT_REG_1 * NFT_REG_SIZE / NFT_REG32_SIZE)
return -EINVAL; return -EINVAL;
if (reg > NFT_REG_MAX)
return -ERANGE;
if (len == 0) if (len == 0)
return -EINVAL; return -EINVAL;
if (len > FIELD_SIZEOF(struct nft_data, data)) if (reg * NFT_REG32_SIZE + len > FIELD_SIZEOF(struct nft_regs, data))
return -ERANGE; return -ERANGE;
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(nft_validate_register_load); EXPORT_SYMBOL_GPL(nft_validate_register_load);
...@@ -4200,13 +4231,12 @@ int nft_validate_register_store(const struct nft_ctx *ctx, ...@@ -4200,13 +4231,12 @@ int nft_validate_register_store(const struct nft_ctx *ctx,
return 0; return 0;
default: default:
if (reg < NFT_REG_1) if (reg < NFT_REG_1 * NFT_REG_SIZE / NFT_REG32_SIZE)
return -EINVAL; return -EINVAL;
if (reg > NFT_REG_MAX)
return -ERANGE;
if (len == 0) if (len == 0)
return -EINVAL; return -EINVAL;
if (len > FIELD_SIZEOF(struct nft_data, data)) if (reg * NFT_REG32_SIZE + len >
FIELD_SIZEOF(struct nft_regs, data))
return -ERANGE; return -ERANGE;
if (data != NULL && type != NFT_DATA_VALUE) if (data != NULL && type != NFT_DATA_VALUE)
......
...@@ -70,7 +70,7 @@ static void nft_cmp_fast_eval(const struct nft_expr *expr, ...@@ -70,7 +70,7 @@ static void nft_cmp_fast_eval(const struct nft_expr *expr,
const struct nft_cmp_fast_expr *priv = nft_expr_priv(expr); const struct nft_cmp_fast_expr *priv = nft_expr_priv(expr);
u32 mask = nft_cmp_fast_mask(priv->len); u32 mask = nft_cmp_fast_mask(priv->len);
if ((regs->data[priv->sreg].data[0] & mask) == priv->data) if ((regs->data[priv->sreg] & mask) == priv->data)
return; return;
regs->verdict.code = NFT_BREAK; regs->verdict.code = NFT_BREAK;
} }
...@@ -81,7 +81,7 @@ static bool nft_payload_fast_eval(const struct nft_expr *expr, ...@@ -81,7 +81,7 @@ static bool nft_payload_fast_eval(const struct nft_expr *expr,
{ {
const struct nft_payload *priv = nft_expr_priv(expr); const struct nft_payload *priv = nft_expr_priv(expr);
const struct sk_buff *skb = pkt->skb; const struct sk_buff *skb = pkt->skb;
u32 *dest = &regs->data[priv->dreg].data[0]; u32 *dest = &regs->data[priv->dreg];
unsigned char *ptr; unsigned char *ptr;
if (priv->base == NFT_PAYLOAD_NETWORK_HEADER) if (priv->base == NFT_PAYLOAD_NETWORK_HEADER)
...@@ -94,6 +94,7 @@ static bool nft_payload_fast_eval(const struct nft_expr *expr, ...@@ -94,6 +94,7 @@ static bool nft_payload_fast_eval(const struct nft_expr *expr,
if (unlikely(ptr + priv->len >= skb_tail_pointer(skb))) if (unlikely(ptr + priv->len >= skb_tail_pointer(skb)))
return false; return false;
*dest = 0;
if (priv->len == 2) if (priv->len == 2)
*(u16 *)dest = *(u16 *)ptr; *(u16 *)dest = *(u16 *)ptr;
else if (priv->len == 4) else if (priv->len == 4)
......
...@@ -30,8 +30,8 @@ static void nft_bitwise_eval(const struct nft_expr *expr, ...@@ -30,8 +30,8 @@ static void nft_bitwise_eval(const struct nft_expr *expr,
const struct nft_pktinfo *pkt) const struct nft_pktinfo *pkt)
{ {
const struct nft_bitwise *priv = nft_expr_priv(expr); const struct nft_bitwise *priv = nft_expr_priv(expr);
const u32 *src = &regs->data[priv->sreg].data[0]; const u32 *src = &regs->data[priv->sreg];
u32 *dst = &regs->data[priv->dreg].data[0]; u32 *dst = &regs->data[priv->dreg];
unsigned int i; unsigned int i;
for (i = 0; i < DIV_ROUND_UP(priv->len, 4); i++) for (i = 0; i < DIV_ROUND_UP(priv->len, 4); i++)
......
...@@ -30,8 +30,8 @@ static void nft_byteorder_eval(const struct nft_expr *expr, ...@@ -30,8 +30,8 @@ static void nft_byteorder_eval(const struct nft_expr *expr,
const struct nft_pktinfo *pkt) const struct nft_pktinfo *pkt)
{ {
const struct nft_byteorder *priv = nft_expr_priv(expr); const struct nft_byteorder *priv = nft_expr_priv(expr);
u32 *src = &regs->data[priv->sreg].data[0]; u32 *src = &regs->data[priv->sreg];
u32 *dst = &regs->data[priv->dreg].data[0]; u32 *dst = &regs->data[priv->dreg];
union { u32 u32; u16 u16; } *s, *d; union { u32 u32; u16 u16; } *s, *d;
unsigned int i; unsigned int i;
......
...@@ -35,7 +35,7 @@ static void nft_ct_get_eval(const struct nft_expr *expr, ...@@ -35,7 +35,7 @@ static void nft_ct_get_eval(const struct nft_expr *expr,
const struct nft_pktinfo *pkt) const struct nft_pktinfo *pkt)
{ {
const struct nft_ct *priv = nft_expr_priv(expr); const struct nft_ct *priv = nft_expr_priv(expr);
u32 *dest = &regs->data[priv->dreg].data[0]; u32 *dest = &regs->data[priv->dreg];
enum ip_conntrack_info ctinfo; enum ip_conntrack_info ctinfo;
const struct nf_conn *ct; const struct nf_conn *ct;
const struct nf_conn_help *help; const struct nf_conn_help *help;
...@@ -156,7 +156,7 @@ static void nft_ct_set_eval(const struct nft_expr *expr, ...@@ -156,7 +156,7 @@ static void nft_ct_set_eval(const struct nft_expr *expr,
const struct nft_ct *priv = nft_expr_priv(expr); const struct nft_ct *priv = nft_expr_priv(expr);
struct sk_buff *skb = pkt->skb; struct sk_buff *skb = pkt->skb;
#ifdef CONFIG_NF_CONNTRACK_MARK #ifdef CONFIG_NF_CONNTRACK_MARK
u32 value = regs->data[priv->sreg].data[0]; u32 value = regs->data[priv->sreg];
#endif #endif
enum ip_conntrack_info ctinfo; enum ip_conntrack_info ctinfo;
struct nf_conn *ct; struct nf_conn *ct;
......
...@@ -30,7 +30,7 @@ static void nft_exthdr_eval(const struct nft_expr *expr, ...@@ -30,7 +30,7 @@ static void nft_exthdr_eval(const struct nft_expr *expr,
const struct nft_pktinfo *pkt) const struct nft_pktinfo *pkt)
{ {
struct nft_exthdr *priv = nft_expr_priv(expr); struct nft_exthdr *priv = nft_expr_priv(expr);
u32 *dest = &regs->data[priv->dreg].data[0]; u32 *dest = &regs->data[priv->dreg];
unsigned int offset = 0; unsigned int offset = 0;
int err; int err;
...@@ -39,6 +39,7 @@ static void nft_exthdr_eval(const struct nft_expr *expr, ...@@ -39,6 +39,7 @@ static void nft_exthdr_eval(const struct nft_expr *expr,
goto err; goto err;
offset += priv->offset; offset += priv->offset;
dest[priv->len / NFT_REG32_SIZE] = 0;
if (skb_copy_bits(pkt->skb, offset, dest, priv->len) < 0) if (skb_copy_bits(pkt->skb, offset, dest, priv->len) < 0)
goto err; goto err;
return; return;
......
...@@ -29,7 +29,7 @@ static void nft_immediate_eval(const struct nft_expr *expr, ...@@ -29,7 +29,7 @@ static void nft_immediate_eval(const struct nft_expr *expr,
{ {
const struct nft_immediate_expr *priv = nft_expr_priv(expr); const struct nft_immediate_expr *priv = nft_expr_priv(expr);
nft_data_copy(&regs->data[priv->dreg], &priv->data); nft_data_copy(&regs->data[priv->dreg], &priv->data, priv->dlen);
} }
static const struct nla_policy nft_immediate_policy[NFTA_IMMEDIATE_MAX + 1] = { static const struct nla_policy nft_immediate_policy[NFTA_IMMEDIATE_MAX + 1] = {
......
...@@ -36,7 +36,7 @@ static void nft_lookup_eval(const struct nft_expr *expr, ...@@ -36,7 +36,7 @@ static void nft_lookup_eval(const struct nft_expr *expr,
if (set->ops->lookup(set, &regs->data[priv->sreg], &ext)) { if (set->ops->lookup(set, &regs->data[priv->sreg], &ext)) {
if (set->flags & NFT_SET_MAP) if (set->flags & NFT_SET_MAP)
nft_data_copy(&regs->data[priv->dreg], nft_data_copy(&regs->data[priv->dreg],
nft_set_ext_data(ext)); nft_set_ext_data(ext), set->dlen);
return; return;
} }
regs->verdict.code = NFT_BREAK; regs->verdict.code = NFT_BREAK;
......
...@@ -31,13 +31,14 @@ void nft_meta_get_eval(const struct nft_expr *expr, ...@@ -31,13 +31,14 @@ void nft_meta_get_eval(const struct nft_expr *expr,
const struct nft_meta *priv = nft_expr_priv(expr); const struct nft_meta *priv = nft_expr_priv(expr);
const struct sk_buff *skb = pkt->skb; const struct sk_buff *skb = pkt->skb;
const struct net_device *in = pkt->in, *out = pkt->out; const struct net_device *in = pkt->in, *out = pkt->out;
u32 *dest = &regs->data[priv->dreg].data[0]; u32 *dest = &regs->data[priv->dreg];
switch (priv->key) { switch (priv->key) {
case NFT_META_LEN: case NFT_META_LEN:
*dest = skb->len; *dest = skb->len;
break; break;
case NFT_META_PROTOCOL: case NFT_META_PROTOCOL:
*dest = 0;
*(__be16 *)dest = skb->protocol; *(__be16 *)dest = skb->protocol;
break; break;
case NFT_META_NFPROTO: case NFT_META_NFPROTO:
...@@ -75,11 +76,13 @@ void nft_meta_get_eval(const struct nft_expr *expr, ...@@ -75,11 +76,13 @@ void nft_meta_get_eval(const struct nft_expr *expr,
case NFT_META_IIFTYPE: case NFT_META_IIFTYPE:
if (in == NULL) if (in == NULL)
goto err; goto err;
*dest = 0;
*(u16 *)dest = in->type; *(u16 *)dest = in->type;
break; break;
case NFT_META_OIFTYPE: case NFT_META_OIFTYPE:
if (out == NULL) if (out == NULL)
goto err; goto err;
*dest = 0;
*(u16 *)dest = out->type; *(u16 *)dest = out->type;
break; break;
case NFT_META_SKUID: case NFT_META_SKUID:
...@@ -185,7 +188,7 @@ void nft_meta_set_eval(const struct nft_expr *expr, ...@@ -185,7 +188,7 @@ void nft_meta_set_eval(const struct nft_expr *expr,
{ {
const struct nft_meta *meta = nft_expr_priv(expr); const struct nft_meta *meta = nft_expr_priv(expr);
struct sk_buff *skb = pkt->skb; struct sk_buff *skb = pkt->skb;
u32 value = regs->data[meta->sreg].data[0]; u32 value = regs->data[meta->sreg];
switch (meta->key) { switch (meta->key) {
case NFT_META_MARK: case NFT_META_MARK:
......
...@@ -49,26 +49,26 @@ static void nft_nat_eval(const struct nft_expr *expr, ...@@ -49,26 +49,26 @@ static void nft_nat_eval(const struct nft_expr *expr,
if (priv->sreg_addr_min) { if (priv->sreg_addr_min) {
if (priv->family == AF_INET) { if (priv->family == AF_INET) {
range.min_addr.ip = (__force __be32) range.min_addr.ip = (__force __be32)
regs->data[priv->sreg_addr_min].data[0]; regs->data[priv->sreg_addr_min];
range.max_addr.ip = (__force __be32) range.max_addr.ip = (__force __be32)
regs->data[priv->sreg_addr_max].data[0]; regs->data[priv->sreg_addr_max];
} else { } else {
memcpy(range.min_addr.ip6, memcpy(range.min_addr.ip6,
&regs->data[priv->sreg_addr_min].data, &regs->data[priv->sreg_addr_min],
sizeof(struct nft_data)); sizeof(range.min_addr.ip6));
memcpy(range.max_addr.ip6, memcpy(range.max_addr.ip6,
&regs->data[priv->sreg_addr_max].data, &regs->data[priv->sreg_addr_max],
sizeof(struct nft_data)); sizeof(range.max_addr.ip6));
} }
range.flags |= NF_NAT_RANGE_MAP_IPS; range.flags |= NF_NAT_RANGE_MAP_IPS;
} }
if (priv->sreg_proto_min) { if (priv->sreg_proto_min) {
range.min_proto.all = range.min_proto.all =
*(__be16 *)&regs->data[priv->sreg_proto_min].data[0]; *(__be16 *)&regs->data[priv->sreg_proto_min];
range.max_proto.all = range.max_proto.all =
*(__be16 *)&regs->data[priv->sreg_proto_max].data[0]; *(__be16 *)&regs->data[priv->sreg_proto_max];
range.flags |= NF_NAT_RANGE_PROTO_SPECIFIED; range.flags |= NF_NAT_RANGE_PROTO_SPECIFIED;
} }
......
...@@ -23,7 +23,7 @@ static void nft_payload_eval(const struct nft_expr *expr, ...@@ -23,7 +23,7 @@ static void nft_payload_eval(const struct nft_expr *expr,
{ {
const struct nft_payload *priv = nft_expr_priv(expr); const struct nft_payload *priv = nft_expr_priv(expr);
const struct sk_buff *skb = pkt->skb; const struct sk_buff *skb = pkt->skb;
u32 *dest = &regs->data[priv->dreg].data[0]; u32 *dest = &regs->data[priv->dreg];
int offset; int offset;
switch (priv->base) { switch (priv->base) {
...@@ -43,6 +43,7 @@ static void nft_payload_eval(const struct nft_expr *expr, ...@@ -43,6 +43,7 @@ static void nft_payload_eval(const struct nft_expr *expr,
} }
offset += priv->offset; offset += priv->offset;
dest[priv->len / NFT_REG32_SIZE] = 0;
if (skb_copy_bits(skb, offset, dest, priv->len) < 0) if (skb_copy_bits(skb, offset, dest, priv->len) < 0)
goto err; goto err;
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment