Instead of the generic "left" and "right", use "key" and "value".
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
=== MANGLE
[verse]
*{ "mangle": {
- "left":* 'EXPRESSION'*,
- "right":* 'EXPRESSION'
+ "key":* 'EXPRESSION'*,
+ "value":* 'EXPRESSION'
*}}*
Change packet data or meta info.
-*left*::
- Packet data to be changed.
-*right*::
+*key*::
+ Packet data to be changed, given as *exthdr*, *payload*, *meta*, *ct* or
+ *ct helper* expression.
+*value*::
Value to change data to.
=== QUOTA
json_t *payload_stmt_json(const struct stmt *stmt, struct output_ctx *octx)
{
return json_pack("{s: {s:o, s:o}}", "mangle",
- "left", expr_print_json(stmt->payload.expr, octx),
- "right", expr_print_json(stmt->payload.val, octx));
+ "key", expr_print_json(stmt->payload.expr, octx),
+ "value", expr_print_json(stmt->payload.val, octx));
}
json_t *exthdr_stmt_json(const struct stmt *stmt, struct output_ctx *octx)
{
return json_pack("{s: {s:o, s:o}}", "mangle",
- "left", expr_print_json(stmt->exthdr.expr, octx),
- "right", expr_print_json(stmt->exthdr.val, octx));
+ "key", expr_print_json(stmt->exthdr.expr, octx),
+ "value", expr_print_json(stmt->exthdr.val, octx));
}
json_t *quota_stmt_json(const struct stmt *stmt, struct output_ctx *octx)
};
return json_pack("{s:{s:o, s:o}}", "mangle",
- "left", ct_expr_json(&expr, octx),
- "right", expr_print_json(stmt->ct.expr, octx));
+ "key", ct_expr_json(&expr, octx),
+ "value", expr_print_json(stmt->ct.expr, octx));
}
json_t *limit_stmt_json(const struct stmt *stmt, struct output_ctx *octx)
root = json_pack("{s:{s:s}}", "meta",
"key", meta_templates[stmt->meta.key].token);
root = json_pack("{s:o, s:o}",
- "left", root,
- "right", expr_print_json(stmt->meta.expr, octx));
+ "key", root,
+ "value", expr_print_json(stmt->meta.expr, octx));
return json_pack("{s:o}", "mangle", root);
}
}
static struct stmt *json_parse_mangle_stmt(struct json_ctx *ctx,
- const char *key, json_t *value)
+ const char *type, json_t *root)
{
- json_t *jleft, *jright;
- struct expr *left, *right;
+ json_t *jkey, *jvalue;
+ struct expr *key, *value;
struct stmt *stmt;
- if (json_unpack_err(ctx, value, "{s:o, s:o}",
- "left", &jleft, "right", &jright))
+ if (json_unpack_err(ctx, root, "{s:o, s:o}",
+ "key", &jkey, "value", &jvalue))
return NULL;
- left = json_parse_mangle_lhs_expr(ctx, jleft);
- if (!left) {
- json_error(ctx, "Invalid LHS of mangle statement");
+ key = json_parse_mangle_lhs_expr(ctx, jkey);
+ if (!key) {
+ json_error(ctx, "Invalid mangle statement key");
return NULL;
}
- right = json_parse_stmt_expr(ctx, jright);
- if (!right) {
- json_error(ctx, "Invalid RHS of mangle statement");
- expr_free(left);
+ value = json_parse_stmt_expr(ctx, jvalue);
+ if (!value) {
+ json_error(ctx, "Invalid mangle statement value");
+ expr_free(key);
return NULL;
}
- switch (left->ops->type) {
+ switch (key->ops->type) {
case EXPR_EXTHDR:
- return exthdr_stmt_alloc(int_loc, left, right);
+ return exthdr_stmt_alloc(int_loc, key, value);
case EXPR_PAYLOAD:
- return payload_stmt_alloc(int_loc, left, right);
+ return payload_stmt_alloc(int_loc, key, value);
case EXPR_META:
- stmt = meta_stmt_alloc(int_loc, left->meta.key, right);
- expr_free(left);
+ stmt = meta_stmt_alloc(int_loc, key->meta.key, value);
+ expr_free(key);
return stmt;
case EXPR_CT:
- if (left->ct.key == NFT_CT_HELPER) {
+ if (key->ct.key == NFT_CT_HELPER) {
stmt = objref_stmt_alloc(int_loc);
stmt->objref.type = NFT_OBJECT_CT_HELPER;
- stmt->objref.expr = right;
+ stmt->objref.expr = value;
} else {
- stmt = ct_stmt_alloc(int_loc, left->ct.key,
- left->ct.direction, right);
+ stmt = ct_stmt_alloc(int_loc, key->ct.key,
+ key->ct.direction, value);
}
- expr_free(left);
+ expr_free(key);
return stmt;
default:
- json_error(ctx, "Invalid LHS expression type for mangle statement.");
+ json_error(ctx, "Invalid mangle statement key expression type.");
return NULL;
}
}
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "mark"
}
},
- "right": { "^": [ "0x11", "0x1331" ] }
+ "value": { "^": [ "0x11", "0x1331" ] }
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "mark"
}
},
- "right": { "&": [ "0x11333", "0x11" ] }
+ "value": { "&": [ "0x11333", "0x11" ] }
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "mark"
}
},
- "right": { "|": [ "0x12", "0x11" ] }
+ "value": { "|": [ "0x12", "0x11" ] }
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "mark"
}
},
- "right": "0x11"
+ "value": "0x11"
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "mark"
}
},
- "right": {
+ "value": {
"meta": { "key": "mark" }
}
}
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "mark"
}
},
- "right": {
+ "value": {
"map": {
"key": {
"meta": { "key": "mark" }
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "event"
}
},
- "right": "new"
+ "value": "new"
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "event"
}
},
- "right": [
+ "value": [
"new",
"related",
"destroy",
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "event"
}
},
- "right": [
+ "value": [
"new",
"related",
"destroy",
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "event"
}
},
- "right": [
+ "value": [
"new",
"destroy"
]
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "event"
}
},
- "right": 1
+ "value": 1
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "event"
}
},
- "right": "0x0"
+ "value": "0x0"
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "label"
}
},
- "right": 127
+ "value": 127
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "zone"
}
},
- "right": 1
+ "value": 1
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"dir": "original",
"key": "zone"
}
},
- "right": 1
+ "value": 1
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"dir": "reply",
"key": "zone"
}
},
- "right": 1
+ "value": 1
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "zone"
}
},
- "right": {
+ "value": {
"map": {
"key": {
"meta": { "key": "mark" }
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "mark"
}
},
- "right": 4896
+ "value": 4896
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "mark"
}
},
- "right": 17
+ "value": 17
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "mark"
}
},
- "right": 19
+ "value": 19
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "mark"
}
},
- "right": 17
+ "value": 17
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "event"
}
},
- "right": "new"
+ "value": "new"
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "event"
}
},
- "right": 0
+ "value": 0
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"meta": { "key": "priority" }
},
- "right": "cafe:beef"
+ "value": "cafe:beef"
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"meta": { "key": "mark" }
},
- "right": { "^": [ "0xffffffc8", "0x16" ] }
+ "value": { "^": [ "0xffffffc8", "0x16" ] }
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"meta": { "key": "mark" }
},
- "right": { "&": [ "0x16", "0x16" ] }
+ "value": { "&": [ "0x16", "0x16" ] }
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"meta": { "key": "mark" }
},
- "right": { "|": [ "0xffffffe9", "0x16" ] }
+ "value": { "|": [ "0xffffffe9", "0x16" ] }
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"meta": { "key": "mark" }
},
- "right": { "&": [ "0xffffffde", "0x16" ] }
+ "value": { "&": [ "0xffffffde", "0x16" ] }
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"meta": { "key": "mark" }
},
- "right": { "|": [ "0xf045ffde", "0x10" ] }
+ "value": { "|": [ "0xf045ffde", "0x10" ] }
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"meta": { "key": "mark" }
},
- "right": { "|": [ "0xffffffde", "0x16" ] }
+ "value": { "|": [ "0xffffffde", "0x16" ] }
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"meta": { "key": "mark" }
},
- "right": { "|": [ "0x32", "0xfffff" ] }
+ "value": { "|": [ "0x32", "0xfffff" ] }
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"meta": { "key": "mark" }
},
- "right": { "^": [ "0xfffe", "0x16" ] }
+ "value": { "^": [ "0xfffe", "0x16" ] }
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"meta": { "key": "mark" }
},
- "right": 4294967262
+ "value": 4294967262
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"meta": { "key": "mark" }
},
- "right": 22
+ "value": 22
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"meta": { "key": "mark" }
},
- "right": 4294967295
+ "value": 4294967295
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"meta": { "key": "mark" }
},
- "right": 22
+ "value": 22
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"meta": { "key": "mark" }
},
- "right": 4031119326
+ "value": 4031119326
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"meta": { "key": "mark" }
},
- "right": 4294967262
+ "value": 4294967262
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"meta": { "key": "mark" }
},
- "right": 1048575
+ "value": 1048575
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"meta": { "key": "mark" }
},
- "right": 65512
+ "value": 65512
}
}
]
},
{
"mangle": {
- "left": {
+ "key": {
"payload": {
"base": "nh",
"len": 48,
"offset": 144
}
},
- "right": "0x112233445566"
+ "value": "0x112233445566"
}
}
]
},
{
"mangle": {
- "left": {
+ "key": {
"payload": {
"base": "nh",
"len": 48,
"offset": 144
}
},
- "right": 18838586676582
+ "value": 18838586676582
}
}
]
},
{
"mangle": {
- "left": {
+ "key": {
"payload": {
"field": "saddr",
"protocol": "ether"
}
},
- "right": "ff:fe:dc:ba:98:76"
+ "value": "ff:fe:dc:ba:98:76"
}
},
{
[
{
"mangle": {
- "left": {
+ "key": {
"meta": { "key": "mark" }
},
- "right": {
+ "value": {
"map": {
"key": {
"payload": {
[
{
"mangle": {
- "left": {
+ "key": {
"meta": { "key": "mark" }
},
- "right": {
+ "value": {
"map": {
"key": {
"payload": {
[
{
"mangle": {
- "left": {
+ "key": {
"meta": { "key": "mark" }
},
- "right": {
+ "value": {
"map": {
"key": {
"payload": {
[
{
"mangle": {
- "left": {
+ "key": {
"meta": { "key": "mark" }
},
- "right": {
+ "value": {
"map": {
"key": {
"payload": {
[
{
"mangle": {
- "left": {
+ "key": {
"tcp option": {
"field": "size",
"name": "maxseg"
}
},
- "right": {
+ "value": {
"rt": {
"key": "mtu"
}
[
{
"mangle": {
- "left": {
+ "key": {
"tcp option": {
"field": "size",
"name": "maxseg"
}
},
- "right": 1360
+ "value": 1360
}
}
]
},
{
"mangle": {
- "left": {
+ "key": {
"payload": {
"field": "checksum",
"protocol": "udp"
}
},
- "right": 0
+ "value": 0
}
}
]
},
{
"mangle": {
- "left": {
+ "key": {
"payload": {
"field": "dport",
"protocol": "udp"
}
},
- "right": 65535
+ "value": 65535
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "mark"
}
},
- "right": {
+ "value": {
"jhash": {
"expr": {
"concat": [
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "mark"
}
},
- "right": {
+ "value": {
"jhash": {
"expr": {
"concat": [
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "mark"
}
},
- "right": {
+ "value": {
"jhash": {
"expr": {
"concat": [
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "mark"
}
},
- "right": {
+ "value": {
"jhash": {
"expr": {
"concat": [
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "mark"
}
},
- "right": {
+ "value": {
"jhash": {
"expr": {
"concat": [
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "mark"
}
},
- "right": {
+ "value": {
"symhash": {
"mod": 2,
"offset": 100
},
{
"mangle": {
- "left": {
+ "key": {
"payload": {
"field": "daddr",
"protocol": "ip"
}
},
- "right": "127.0.0.1"
+ "value": "127.0.0.1"
}
}
]
},
{
"mangle": {
- "left": {
+ "key": {
"payload": {
"field": "checksum",
"protocol": "ip"
}
},
- "right": 0
+ "value": 0
}
}
]
},
{
"mangle": {
- "left": {
+ "key": {
"payload": {
"field": "id",
"protocol": "ip"
}
},
- "right": 0
+ "value": 0
}
}
]
},
{
"mangle": {
- "left": {
+ "key": {
"payload": {
"field": "ecn",
"protocol": "ip"
}
},
- "right": 1
+ "value": 1
}
}
]
},
{
"mangle": {
- "left": {
+ "key": {
"payload": {
"field": "ecn",
"protocol": "ip"
}
},
- "right": "ce"
+ "value": "ce"
}
}
]
},
{
"mangle": {
- "left": {
+ "key": {
"payload": {
"field": "ttl",
"protocol": "ip"
}
},
- "right": 23
+ "value": 23
}
}
]
},
{
"mangle": {
- "left": {
+ "key": {
"payload": {
"field": "protocol",
"protocol": "ip"
}
},
- "right": 1
+ "value": 1
}
}
]
},
{
"mangle": {
- "left": {
+ "key": {
"payload": {
"field": "dscp",
"protocol": "ip"
}
},
- "right": "af23"
+ "value": "af23"
}
}
]
},
{
"mangle": {
- "left": {
+ "key": {
"payload": {
"field": "dscp",
"protocol": "ip"
}
},
- "right": "cs0"
+ "value": "cs0"
}
}
]
},
{
"mangle": {
- "left": {
+ "key": {
"payload": {
"field": "ecn",
"protocol": "ip"
}
},
- "right": "ect1"
+ "value": "ect1"
}
}
]
},
{
"mangle": {
- "left": {
+ "key": {
"meta": { "key": "mark" }
},
- "right": 1
+ "value": 1
}
},
{
},
{
"mangle": {
- "left": {
+ "key": {
"meta": { "key": "mark" }
},
- "right": 1
+ "value": 1
}
},
{
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "mark"
}
},
- "right": {
+ "value": {
"numgen": {
"mod": 2,
"mode": "inc"
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "mark"
}
},
- "right": {
+ "value": {
"numgen": {
"mod": 2,
"mode": "inc",
[
{
"mangle": {
- "left": {
+ "key": {
"ct": {
"key": "mark"
}
},
- "right": {
+ "value": {
"numgen": {
"mod": 2,
"mode": "inc",
},
{
"mangle": {
- "left": {
+ "key": {
"payload": {
"field": "daddr",
"protocol": "ip6"
}
},
- "right": "::1"
+ "value": "::1"
}
}
]
},
{
"mangle": {
- "left": {
+ "key": {
"payload": {
"field": "hoplimit",
"protocol": "ip6"
}
},
- "right": 1
+ "value": 1
}
}
]
},
{
"mangle": {
- "left": {
+ "key": {
"payload": {
"field": "dscp",
"protocol": "ip6"
}
},
- "right": "af42"
+ "value": "af42"
}
}
]
},
{
"mangle": {
- "left": {
+ "key": {
"payload": {
"field": "dscp",
"protocol": "ip6"
}
},
- "right": 63
+ "value": 63
}
}
]
},
{
"mangle": {
- "left": {
+ "key": {
"payload": {
"field": "ecn",
"protocol": "ip6"
}
},
- "right": "ect0"
+ "value": "ect0"
}
}
]
},
{
"mangle": {
- "left": {
+ "key": {
"payload": {
"field": "ecn",
"protocol": "ip6"
}
},
- "right": "ce"
+ "value": "ce"
}
}
]
},
{
"mangle": {
- "left": {
+ "key": {
"payload": {
"field": "flowlabel",
"protocol": "ip6"
}
},
- "right": 0
+ "value": 0
}
}
]
},
{
"mangle": {
- "left": {
+ "key": {
"payload": {
"field": "flowlabel",
"protocol": "ip6"
}
},
- "right": 12345
+ "value": 12345
}
}
]
},
{
"mangle": {
- "left": {
+ "key": {
"payload": {
"field": "flowlabel",
"protocol": "ip6"
}
},
- "right": "0xfffff"
+ "value": "0xfffff"
}
}
]
},
{
"mangle": {
- "left": {
+ "key": {
"payload": {
"field": "flowlabel",
"protocol": "ip6"
}
},
- "right": 1048575
+ "value": 1048575
}
}
]
[
{
"mangle": {
- "left": {
+ "key": {
"meta": { "key": "mark" }
},
- "right": {
+ "value": {
"map": {
"key": {
"&": [
[
{
"mangle": {
- "left": {
+ "key": {
"meta": { "key": "mark" }
},
- "right": {
+ "value": {
"map": {
"key": {
"&": [