static int handle_pool6_config(struct nlmsghdr *nl_hdr, struct request_hdr *jool_hdr, union request_pool6 *request) { __u64 count; int error; switch (jool_hdr->operation) { case OP_DISPLAY: return handle_pool6_display(nl_hdr, request); case OP_COUNT: log_debug("Returning IPv6 prefix count."); error = pool6_count(&count); if (error) return respond_error(nl_hdr, error); return respond_setcfg(nl_hdr, &count, sizeof(count)); case OP_ADD: case OP_UPDATE: if (verify_superpriv()) return respond_error(nl_hdr, -EPERM); log_debug("Adding a prefix to the IPv6 pool."); return respond_error(nl_hdr, pool6_add(&request->add.prefix)); case OP_REMOVE: if (verify_superpriv()) return respond_error(nl_hdr, -EPERM); log_debug("Removing a prefix from the IPv6 pool."); error = pool6_remove(&request->remove.prefix); if (error) return respond_error(nl_hdr, error); if (nat64_is_stateful() && !request->flush.quick) error = sessiondb_delete_by_prefix6(&request->remove.prefix); return respond_error(nl_hdr, error); case OP_FLUSH: if (verify_superpriv()) return respond_error(nl_hdr, -EPERM); log_debug("Flushing the IPv6 pool..."); error = pool6_flush(); if (error) return respond_error(nl_hdr, error); if (nat64_is_stateful() && !request->flush.quick) error = sessiondb_flush(); return respond_error(nl_hdr, error); default: log_err("Unknown operation: %d", jool_hdr->operation); return respond_error(nl_hdr, -EINVAL); } }
static int handle_pool4_flush(struct nlmsghdr *nl_hdr, union request_pool4 *request) { int error; if (verify_superpriv()) return respond_error(nl_hdr, -EPERM); log_debug("Flushing the IPv4 pool..."); error = pool4db_flush(); /* * Well, pool4db_flush only errors on memory allocation failures, * so I guess clearing BIB and session even if pool4db_flush fails * is a good idea. */ if (xlat_is_nat64() && !request->flush.quick) { sessiondb_flush(); bibdb_flush(); } return respond_error(nl_hdr, error); }