[FROG] OSPF, FreeBSD and aliases

Eugene Grosbein eugen at grosbein.net
Sun Jul 18 22:17:28 UTC 2021


18.07.2021 18:30, Chriztoffer Hansen wrote:

>> I'm trying to move from quagga to frr 7.5.1. I have existing working setup with OSPF
>> and FreeBSD servers that have some aliases on its OSPF-enabled interfaces.
>> In FreeBSD, if one needs several IP addresses in same IP subnet on one interfaces (for CARP etc.)
>> then one assigns one of IPs with "real" subnet mask and others with /32 mask:

[skip]

I've used "show interface" command and noted that FRR marked my aliases as "unnumbered"
instead of needed "secondary".

I've spent some time making me familiar with FRR code a bit, and came with a patch that
teaches FRR to flag aliases as "secondary" and this solves my problem: OSPF neighborship
with Quagga is established. The patch is pretty naive and straightforward
but I'm not sure if it is completely correct and/or effective.

--- zebra/interface.c.orig      2021-03-04 02:14:50 UTC
+++ zebra/interface.c
@@ -358,7 +358,36 @@ int if_subnet_add(struct interface *ifp, struct connec

        if ((addr_list = rn->info))
                SET_FLAG(ifc->flags, ZEBRA_IFA_SECONDARY);
-       else {
+#ifdef __FreeBSD__
+       else if (cp.prefixlen == 32) {
+               struct listnode *node;
+               struct connected *pc;
+               struct prefix *p;
+               uint32_t mask;
+
+               /*
+                * Find any non-secondary AF_INET node with non-NULL info
+                * that covers ifc.
+               */
+                for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, pc)) {
+                       if (CHECK_FLAG(pc->flags, ZEBRA_IFA_SECONDARY))
+                               continue;
+                       p = pc->address;
+                       if (p->family != AF_INET)
+                               continue;
+                       mask = ((1 << (32-p->prefixlen))-1);
+                       if ((p->u.prefix4.s_addr & mask) ==
+                           (cp.u.prefix4.s_addr & mask)) {
+                               rn = route_node_get(zebra_if->ipv4_subnets, p);
+                               if ((addr_list = rn->info)) {
+                                       SET_FLAG(ifc->flags, ZEBRA_IFA_SECONDARY);
+                                       break;
+                               }
+                       }
+               }
+       }
+#endif
+       if(!addr_list) {
                UNSET_FLAG(ifc->flags, ZEBRA_IFA_SECONDARY);
                rn->info = addr_list = list_new();
                route_lock_node(rn);
 





More information about the frog mailing list