Skip to content

Commit

Permalink
infra: forbid manual deletion of loopback iface
Browse files Browse the repository at this point in the history
Loopback interfaces are created/deleted upon vrf creation
and deleation.
Forbid the user to delete it.

Signed-off-by: Christophe Fontaine <[email protected]>
  • Loading branch information
christophefontaine authored and rjarry committed Dec 5, 2024
1 parent e27fab5 commit 5c91e81
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions modules/infra/api/iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,17 @@ static struct api_out iface_add(const void *request, void **response) {

static struct api_out iface_del(const void *request, void ** /*response*/) {
const struct gr_infra_iface_del_req *req = request;
struct iface *iface;
int ret;

// Loopback interfaces are special, and are deleted
// when the last interface of a VRF is destroyed.
if ((iface = iface_from_id(req->iface_id)) == NULL)
return api_out(ENODEV, 0);

if (iface->type_id == GR_IFACE_TYPE_LOOPBACK)
return api_out(EINVAL, 0);

ret = iface_destroy(req->iface_id);

return api_out(-ret, 0);
Expand Down

0 comments on commit 5c91e81

Please sign in to comment.