MCPcopy Create free account
hub / github.com/F-Stack/f-stack / pipeline_table_default_entry_add

Function pipeline_table_default_entry_add

dpdk/examples/pipeline/cli.c:1045–1092  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1043}
1044
1045static int
1046pipeline_table_default_entry_add(struct rte_swx_ctl_pipeline *p,
1047 const char *table_name,
1048 FILE *file,
1049 uint32_t *file_line_number)
1050{
1051 char *line = NULL;
1052 uint32_t line_id = 0;
1053 int status = 0;
1054
1055 /* Buffer allocation. */
1056 line = malloc(MAX_LINE_SIZE);
1057 if (!line)
1058 return -ENOMEM;
1059
1060 /* File read. */
1061 for (line_id = 1; ; line_id++) {
1062 struct rte_swx_table_entry *entry;
1063 int is_blank_or_comment;
1064
1065 if (fgets(line, MAX_LINE_SIZE, file) == NULL)
1066 break;
1067
1068 entry = rte_swx_ctl_pipeline_table_entry_read(p,
1069 table_name,
1070 line,
1071 &is_blank_or_comment);
1072 if (!entry) {
1073 if (is_blank_or_comment)
1074 continue;
1075
1076 status = -EINVAL;
1077 goto error;
1078 }
1079
1080 status = rte_swx_ctl_pipeline_table_default_entry_add(p,
1081 table_name,
1082 entry);
1083 table_entry_free(entry);
1084 if (status)
1085 goto error;
1086 }
1087
1088error:
1089 *file_line_number = line_id;
1090 free(line);
1091 return status;
1092}
1093
1094static const char cmd_pipeline_table_default_help[] =
1095"pipeline <pipeline_name> table <table_name> default <file_name>\n";

Callers 1

Calls 5

mallocFunction · 0.85
table_entry_freeFunction · 0.70
freeFunction · 0.50

Tested by

no test coverage detected