| 1 | #cxx . . $ `<file>/src/expr/flow_offload.c`/include "internal.h"cxx . . $ `<file>/include/internal.h`/ |
| 2 | |
| 3 | #include <stdio.h> |
| 4 | #include <stdint.h> |
| 5 | #include <string.h> /* for memcpy */ |
| 6 | #include <arpa/inet.h> |
| 7 | #include <errno.h> |
| 8 | #include <libmnl/libmnl.h> |
| 9 | #include <linux/netfilter/nf_tables.h>cxx . . $ `<file>/include/linux/netfilter/nf_tables.h`/ |
| 10 | #include <libnftnl/rule.h>cxx . . $ `<file>/include/libnftnl/rule.h`/ |
| 11 | #include <libnftnl/expr.h>cxx . . $ `<file>/include/libnftnl/expr.h`/ |
| 12 | |
| 13 | struct nftnl_expr_flowcxx . . $ nftnl_expr_flow# { |
| 14 | char *table_namecxx . . $ nftnl_expr_flow#table_name.; |
| 15 | }; |
| 16 | |
| 17 | static int |
| 18 | nftnl_expr_flow_setcxx . . $ nftnl_expr_flow_set(211371a3e3842127).(struct nftnl_exprcxx . . $ nftnl_expr# *e, uint16_tcxx . . $ uint16_t# type, |
| 19 | const void *data, uint32_tcxx . . $ uint32_t# data_len, uint32_tcxx . . $ uint32_t# byteorder) |
| 20 | { |
| 21 | struct nftnl_expr_flowcxx . . $ nftnl_expr_flow# *flow = nftnl_expr_datacxx . . $ `include/expr_ops.h:31:9`!(e); |
| 22 | |
| 23 | switch (type) { |
| 24 | case NFTNL_EXPR_FLOW_TABLE_NAMEcxx . . $ NFTNL_EXPR_FLOW_TABLE_NAME.: |
| 25 | flow->table_namecxx . . $ nftnl_expr_flow#table_name. = strdupcxx . . $ strdup(a8b8e32347182212).((const char *)data); |
| 26 | if (!flow->table_namecxx . . $ nftnl_expr_flow#table_name.) |
| 27 | return -1; |
| 28 | break; |
| 29 | } |
| 30 | return 0; |
| 31 | } |
| 32 | |
| 33 | static const void *nftnl_expr_flow_getcxx . . $ nftnl_expr_flow_get(9de263c4f9e71c4b).(const struct nftnl_exprcxx . . $ nftnl_expr# *e, |
| 34 | uint16_tcxx . . $ uint16_t# type, uint32_tcxx . . $ uint32_t# *data_len) |
| 35 | { |
| 36 | struct nftnl_expr_flowcxx . . $ nftnl_expr_flow# *flow = nftnl_expr_datacxx . . $ `include/expr_ops.h:31:9`!(e); |
| 37 | |
| 38 | switch(type) { |
| 39 | case NFTNL_EXPR_FLOW_TABLE_NAMEcxx . . $ NFTNL_EXPR_FLOW_TABLE_NAME.: |
| 40 | *data_len = strlencxx . . $ strlen(751346f8406fd082).(flow->table_namecxx . . $ nftnl_expr_flow#table_name.) + 1; |
| 41 | return flow->table_namecxx . . $ nftnl_expr_flow#table_name.; |
| 42 | } |
| 43 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 44 | } |
| 45 | |
| 46 | static int nftnl_expr_flow_cbcxx . . $ nftnl_expr_flow_cb(de2ef18c48fd675c).(const struct nlattrcxx . . $ nlattr# *attr, void *data) |
| 47 | { |
| 48 | const struct nlattrcxx . . $ nlattr# **tb = data; |
| 49 | int type = mnl_attr_get_typecxx . . $ mnl_attr_get_type(1da47bcc4c4b975).(attr); |
| 50 | |
| 51 | if (mnl_attr_type_validcxx . . $ mnl_attr_type_valid(47df1cce1c7be855).(attr, NFTA_FLOW_MAXcxx . . $ `include/linux/netfilter/nf_tables.h:1211:9`!) < 0) |
| 52 | return MNL_CB_OKcxx . . $ `<external>/12386019527593959648/libmnl.h:174:9`!; |
| 53 | |
| 54 | switch(type) { |
| 55 | case NFTA_FLOW_TABLE_NAMEcxx . . $ NFTA_FLOW_TABLE_NAME.: |
| 56 | if (mnl_attr_validatecxx . . $ mnl_attr_validate(e419697a5e1ae2b1).(attr, MNL_TYPE_STRINGcxx . . $ MNL_TYPE_STRING.) < 0) |
| 57 | abi_breakagecxx . . $ `include/utils.h:28:9`!(); |
| 58 | break; |
| 59 | } |
| 60 | |
| 61 | tb[type] = attr; |
| 62 | return MNL_CB_OKcxx . . $ `<external>/12386019527593959648/libmnl.h:174:9`!; |
| 63 | } |
| 64 | |
| 65 | static void nftnl_expr_flow_buildcxx . . $ nftnl_expr_flow_build(93c7528a9cf90b41).(struct nlmsghdrcxx . . $ nlmsghdr# *nlh, |
| 66 | const struct nftnl_exprcxx . . $ nftnl_expr# *e) |
| 67 | { |
| 68 | struct nftnl_expr_flowcxx . . $ nftnl_expr_flow# *flow = nftnl_expr_datacxx . . $ `include/expr_ops.h:31:9`!(e); |
| 69 | |
| 70 | if (e->flagscxx . . $ nftnl_expr#flags. & (1 << NFTNL_EXPR_FLOW_TABLE_NAMEcxx . . $ NFTNL_EXPR_FLOW_TABLE_NAME.)) |
| 71 | mnl_attr_put_strzcxx . . $ mnl_attr_put_strz(eb76286d4bfc1a8d).(nlh, NFTA_FLOW_TABLE_NAMEcxx . . $ NFTA_FLOW_TABLE_NAME., flow->table_namecxx . . $ nftnl_expr_flow#table_name.); |
| 72 | } |
| 73 | |
| 74 | static int nftnl_expr_flow_parsecxx . . $ nftnl_expr_flow_parse(ed61207049d8af9a).(struct nftnl_exprcxx . . $ nftnl_expr# *e, struct nlattrcxx . . $ nlattr# *attr) |
| 75 | { |
| 76 | struct nftnl_expr_flowcxx . . $ nftnl_expr_flow# *flow = nftnl_expr_datacxx . . $ `include/expr_ops.h:31:9`!(e); |
| 77 | struct nlattrcxx . . $ nlattr# *tb[NFTA_FLOW_MAXcxx . . $ `include/linux/netfilter/nf_tables.h:1211:9`!+1] = {}; |
| 78 | int ret = 0; |
| 79 | |
| 80 | if (mnl_attr_parse_nestedcxx . . $ mnl_attr_parse_nested(f99c0e9fa94f99d9).(attr, nftnl_expr_flow_cbcxx . . $ nftnl_expr_flow_cb(de2ef18c48fd675c)., tb) < 0) |
| 81 | return -1; |
| 82 | |
| 83 | if (nftnl_parse_str_attrcxx . . $ nftnl_parse_str_attr(2002c8408bf98f7f).(tb[NFTA_FLOW_TABLE_NAMEcxx . . $ NFTA_FLOW_TABLE_NAME.], |
| 84 | NFTNL_EXPR_FLOW_TABLE_NAMEcxx . . $ NFTNL_EXPR_FLOW_TABLE_NAME., |
| 85 | (const char **)&flow->table_namecxx . . $ nftnl_expr_flow#table_name., |
| 86 | &e->flagscxx . . $ nftnl_expr#flags.) < 0) |
| 87 | return -1; |
| 88 | |
| 89 | return ret; |
| 90 | } |
| 91 | |
| 92 | static int nftnl_expr_flow_snprintfcxx . . $ nftnl_expr_flow_snprintf(2b4af69501aef780).(char *buf, size_t remain, |
| 93 | uint32_tcxx . . $ uint32_t# flags, const struct nftnl_exprcxx . . $ nftnl_expr# *e) |
| 94 | { |
| 95 | struct nftnl_expr_flowcxx . . $ nftnl_expr_flow# *l = nftnl_expr_datacxx . . $ `include/expr_ops.h:31:9`!(e); |
| 96 | int offset = 0, ret; |
| 97 | |
| 98 | ret = snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, remain, "flowtable %s ", l->table_namecxx . . $ nftnl_expr_flow#table_name.); |
| 99 | SNPRINTF_BUFFER_SIZEcxx . . $ `include/utils.h:55:9`!(ret, remain, offset); |
| 100 | |
| 101 | return offset; |
| 102 | } |
| 103 | |
| 104 | static void nftnl_expr_flow_freecxx . . $ nftnl_expr_flow_free(cbe1a28527736226).(const struct nftnl_exprcxx . . $ nftnl_expr# *e) |
| 105 | { |
| 106 | struct nftnl_expr_flowcxx . . $ nftnl_expr_flow# *flow = nftnl_expr_datacxx . . $ `include/expr_ops.h:31:9`!(e); |
| 107 | |
| 108 | xfreecxx . . $ `include/utils.h:22:9`!(flow->table_name); |
| 109 | } |
| 110 | |
| 111 | static struct attr_policycxx . . $ attr_policy# flow_offload_attr_policycxx . . $ flow_offload_attr_policy.[__NFTNL_EXPR_FLOW_MAXcxx . . $ __NFTNL_EXPR_FLOW_MAX.] = { |
| 112 | [NFTNL_EXPR_FLOW_TABLE_NAMEcxx . . $ NFTNL_EXPR_FLOW_TABLE_NAME.] = { .maxlen = NFT_NAME_MAXLENcxx . . $ `include/linux/netfilter/nf_tables.h:5:9`! }, |
| 113 | }; |
| 114 | |
| 115 | struct expr_opscxx . . $ expr_ops# expr_ops_flowcxx . . $ expr_ops_flow. = { |
| 116 | .name = "flow_offload", |
| 117 | .alloc_len = sizeof(struct nftnl_expr_flowcxx . . $ nftnl_expr_flow#), |
| 118 | .nftnl_max_attr = __NFTNL_EXPR_FLOW_MAXcxx . . $ __NFTNL_EXPR_FLOW_MAX. - 1, |
| 119 | .attr_policy = flow_offload_attr_policycxx . . $ flow_offload_attr_policy., |
| 120 | .free = nftnl_expr_flow_freecxx . . $ nftnl_expr_flow_free(cbe1a28527736226)., |
| 121 | .set = nftnl_expr_flow_setcxx . . $ nftnl_expr_flow_set(211371a3e3842127)., |
| 122 | .get = nftnl_expr_flow_getcxx . . $ nftnl_expr_flow_get(9de263c4f9e71c4b)., |
| 123 | .parse = nftnl_expr_flow_parsecxx . . $ nftnl_expr_flow_parse(ed61207049d8af9a)., |
| 124 | .build = nftnl_expr_flow_buildcxx . . $ nftnl_expr_flow_build(93c7528a9cf90b41)., |
| 125 | .output = nftnl_expr_flow_snprintfcxx . . $ nftnl_expr_flow_snprintf(2b4af69501aef780)., |
| 126 | }; |