Prefix in different VRF wrongly sees global prefix as its parent #7624

Closed
opened 2025-12-29 20:26:12 +01:00 by adam · 4 comments
Owner

Originally created by @candlerb on GitHub (Feb 9, 2023).

Originally assigned to: @DanSheps on GitHub.

NetBox version

v3.4.4

Python version

3.8

Steps to Reproduce

  1. Create VRF "testvrf"
  2. Create prefix 192.168.0.0/24 in global VRF
  3. Create prefix 192.168.0.0/28 in "testvrf"
  4. Browse to 192.168.0.0/28 (which is where you'll be right after creation)

Expected Behavior

192.168.0.0/28@testvrf and 192.168.0.0/24 should be independent from each other, as they are in different VRFs.

Observed Behavior

192.168.0.0/28@testvrf sees 192.168.0.0/24 as its parent.

image

However, 192.168.0.0/24 does not see 192.168.0.0/28@testvrf as its child.

This is inconsistent: this child<->parent relationship should either work in both ways, or neither.

In this case, I think it should be neither: otherwise 192.168.0.0/24 could see many different prefixes and IP addresses in different VRFs as its children, which would mix lots of VRFs together in the same view.

EDIT: the current behaviour does appear to be intentional in the code:

        # Parent prefixes table
        parent_prefixes = Prefix.objects.restrict(request.user, 'view').filter(
            Q(vrf=instance.vrf) | Q(vrf__isnull=True)
Originally created by @candlerb on GitHub (Feb 9, 2023). Originally assigned to: @DanSheps on GitHub. ### NetBox version v3.4.4 ### Python version 3.8 ### Steps to Reproduce 1. Create VRF "testvrf" 2. Create prefix 192.168.0.0/24 in global VRF 3. Create prefix 192.168.0.0/28 in "testvrf" 4. Browse to 192.168.0.0/28 (which is where you'll be right after creation) ### Expected Behavior 192.168.0.0/28@testvrf and 192.168.0.0/24 should be independent from each other, as they are in different VRFs. ### Observed Behavior 192.168.0.0/28@testvrf sees 192.168.0.0/24 as its parent. ![image](https://user-images.githubusercontent.com/44789/217877506-1e926779-8829-4f31-b6ed-b0035195efdb.png) However, 192.168.0.0/24 does *not* see 192.168.0.0/28@testvrf as its child. This is inconsistent: this child<->parent relationship should either work in both ways, or neither. In this case, I think it should be neither: otherwise 192.168.0.0/24 could see many different prefixes and IP addresses in different VRFs as its children, which would mix lots of VRFs together in the same view. EDIT: the current behaviour *does* appear to be intentional in the [code](https://github.com/netbox-community/netbox/blob/v3.4.4/netbox/ipam/views.py#L461-L463): ``` # Parent prefixes table parent_prefixes = Prefix.objects.restrict(request.user, 'view').filter( Q(vrf=instance.vrf) | Q(vrf__isnull=True) ```
adam added the type: bugstatus: accepted labels 2025-12-29 20:26:12 +01:00
adam closed this issue 2025-12-29 20:26:12 +01:00
Author
Owner

@jsenecal commented on GitHub (Feb 10, 2023):

The current behavior is indeed intentional. This allows for Container prefixes in the Global VRF to nest under it smaller prefixes in the table views.

Can you clarify what you would like fixed in that case, if anything ?

@jsenecal commented on GitHub (Feb 10, 2023): The current behavior is indeed intentional. This allows for Container prefixes in the Global VRF to nest under it smaller prefixes in the table views. Can you clarify what you would like fixed in that case, if anything ?
Author
Owner

@candlerb commented on GitHub (Feb 10, 2023):

If A is the parent of B, then B should be the child of A. This isn't the case currently.

If you want to make a container prefix for prefixes in VRF X, then the container should also be within VRF X (IMO).

@candlerb commented on GitHub (Feb 10, 2023): If A is the parent of B, then B should be the child of A. This isn't the case currently. If you want to make a container prefix for prefixes in VRF X, then the container should also be within VRF X (IMO).
Author
Owner

@bobbwest commented on GitHub (Feb 11, 2023):

Worse still, if there are two 192.168.0.0/24 prefixes, one in global, one in the VRF "testvrf", which one would be the parent of 192.168.0.0/28@testvrf ? Both? It should be the one in the same VRF.

VRFs are separate routing domains; there's no reason for a prefix in global to show up in a VRF. In the rare cases when route leaking is happening between VRFs, then I think that the prefix should be listed in each VRF with a note as to how it is appearing there.

@bobbwest commented on GitHub (Feb 11, 2023): Worse still, if there are two 192.168.0.0/24 prefixes, one in global, one in the VRF "testvrf", which one would be the parent of 192.168.0.0/28@testvrf ? Both? It should be the one in the same VRF. VRFs are separate routing domains; there's no reason for a prefix in global to show up in a VRF. In the rare cases when route leaking is happening between VRFs, then I think that the prefix should be listed in each VRF with a note as to how it is appearing there.
Author
Owner

@DanSheps commented on GitHub (Feb 18, 2023):

The current behavior is indeed intentional. This allows for Container prefixes in the Global VRF to nest under it smaller prefixes in the table views.

Can you clarify what you would like fixed in that case, if anything ?

It is only suppose to work this way if it is set as "Container" for status.

@DanSheps commented on GitHub (Feb 18, 2023): > The current behavior is indeed intentional. This allows for Container prefixes in the Global VRF to nest under it smaller prefixes in the table views. > > Can you clarify what you would like fixed in that case, if anything ? It is only suppose to work this way if it is set as "Container" for status.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7624