Skip to content

Conversation

fujita
Copy link
Member

@fujita fujita commented Aug 3, 2025

Add Family argument to NewPath function in order to avoid getting Family from NLRI. The NLRI type and Family do not have a one-to-one correspondence, we can only obtain an incomplete value for Family.

Add Family argument to NewPath function in order to avoid getting
Family from NLRI. The NLRI type and Family do not have a one-to-one
correspondence, we can only obtain an incomplete value for Family.

Signed-off-by: FUJITA Tomonori <[email protected]>
@@ -175,7 +175,7 @@ func NewPath(nlri bgp.AddrPrefixInterface, isWithdraw bool, attrs []bgp.PathAttr
Pattrs: a,
Age: tspb.New(age),
IsWithdraw: isWithdraw,
Family: ToApiFamily(nlri.AFI(), nlri.SAFI()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in which case getting the family from the nlri/prefix is not the right way ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RF_IPv4_MC and RF_IPv6_MC.

Copy link
Contributor

@nplanelcisco nplanelcisco Aug 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not doing it in the prefix itself ? something like

func NewIPAddrPrefix(bits uint8, prefix string) *IPAddrPrefix
   p := netip.ParsePrefix("....")
   return &IPAddrPrefix{ isMulticast: p.Addr().IsMulticast() , .... }

func (ip4 *IPAddrPrefix) SAFI() {
    if ip4.isMulticast {
       return RF_IPv4_MC
    }
   return RF_IPv4_UC
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can. The point to discuss is where to store the relationship between Family and NLRI.

Since the number of AddrPrefixInterfaces increases proportionally to both the number of routes and the number of peers, in a full route environment with 10 peers, if NLRI increases by 4 bytes, memory usage would increase by 40MB. Storing Family information in NLRI does not seem ideal.

Note that Paths in the same Destination should share the NLRI. We need to remove PathID info (that is, PrefixDefault) from NLRI before that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can do this way #3081

Copy link
Contributor

@nplanelcisco nplanelcisco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall I think the prefix contain the family and need to parse/handle it correctly
via netip.Parse() prefix.IsMulticast() IsUnicast(), may Is4In6() ....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants