| 1556 | } |
| 1557 | |
| 1558 | int |
| 1559 | pipeline_table_rule_add_bulk(const char *pipeline_name, |
| 1560 | uint32_t table_id, |
| 1561 | struct table_rule_list *list, |
| 1562 | uint32_t *n_rules_added, |
| 1563 | uint32_t *n_rules_not_added) |
| 1564 | { |
| 1565 | struct pipeline *p; |
| 1566 | struct table *table; |
| 1567 | struct pipeline_msg_req *req; |
| 1568 | struct pipeline_msg_rsp *rsp; |
| 1569 | struct table_rule *rule; |
| 1570 | int status = 0; |
| 1571 | |
| 1572 | /* Check input params */ |
| 1573 | if ((pipeline_name == NULL) || |
| 1574 | (list == NULL) || |
| 1575 | TAILQ_EMPTY(list) || |
| 1576 | (n_rules_added == NULL) || |
| 1577 | (n_rules_not_added == NULL)) { |
| 1578 | table_rule_list_free(list); |
| 1579 | return -EINVAL; |
| 1580 | } |
| 1581 | |
| 1582 | p = pipeline_find(pipeline_name); |
| 1583 | if ((p == NULL) || |
| 1584 | (table_id >= p->n_tables)) { |
| 1585 | table_rule_list_free(list); |
| 1586 | return -EINVAL; |
| 1587 | } |
| 1588 | |
| 1589 | table = &p->table[table_id]; |
| 1590 | |
| 1591 | TAILQ_FOREACH(rule, list, node) |
| 1592 | if (match_check(&rule->match, p, table_id) || |
| 1593 | action_check(&rule->action, p, table_id)) { |
| 1594 | table_rule_list_free(list); |
| 1595 | return -EINVAL; |
| 1596 | } |
| 1597 | |
| 1598 | if (!pipeline_is_running(p)) { |
| 1599 | struct table_ll table_ll = { |
| 1600 | .p = p->p, |
| 1601 | .table_id = table_id, |
| 1602 | .a = table->a, |
| 1603 | .bulk_supported = table->params.match_type == TABLE_ACL, |
| 1604 | }; |
| 1605 | |
| 1606 | status = table_rule_add_bulk_ll(&table_ll, list, n_rules_added); |
| 1607 | if (status) { |
| 1608 | table_rule_list_free(list); |
| 1609 | return status; |
| 1610 | } |
| 1611 | |
| 1612 | table_rule_add_bulk(table, list, *n_rules_added); |
| 1613 | *n_rules_not_added = table_rule_list_free(list); |
| 1614 | return 0; |
| 1615 | } |
no test coverage detected