| 77 | } |
| 78 | |
| 79 | static int |
| 80 | route_ip4_add(struct route_ipv4_config *route) |
| 81 | { |
| 82 | struct route_ipv4_config *ipv4route; |
| 83 | int rc = -EINVAL; |
| 84 | |
| 85 | ipv4route = find_route4_entry(route); |
| 86 | |
| 87 | if (!ipv4route) { |
| 88 | ipv4route = malloc(sizeof(struct route_ipv4_config)); |
| 89 | if (!ipv4route) |
| 90 | return -ENOMEM; |
| 91 | } else { |
| 92 | return 0; |
| 93 | } |
| 94 | |
| 95 | ipv4route->ip = route->ip; |
| 96 | ipv4route->netmask = route->netmask; |
| 97 | ipv4route->via = route->via; |
| 98 | ipv4route->is_used = true; |
| 99 | |
| 100 | if (!graph_status_get()) |
| 101 | goto exit; |
| 102 | |
| 103 | rc = route4_rewirte_table_update(ipv4route); |
| 104 | if (rc) |
| 105 | goto free; |
| 106 | |
| 107 | exit: |
| 108 | TAILQ_INSERT_TAIL(&route4, ipv4route, next); |
| 109 | return 0; |
| 110 | free: |
| 111 | free(ipv4route); |
| 112 | return rc; |
| 113 | } |
| 114 | |
| 115 | int |
| 116 | route_ip4_add_to_lookup(void) |
no test coverage detected