Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save paigeadelethompson/9832cc17f000cbf1719fa638b9045268 to your computer and use it in GitHub Desktop.

Select an option

Save paigeadelethompson/9832cc17f000cbf1719fa638b9045268 to your computer and use it in GitHub Desktop.
# TODO: FreeBSD FIB / Multi-Instance Support in FRR
This document outlines the roadmap for adapting FRR's VRF implementation to support FreeBSD FIBs (Routing Tables).
## Technical Constraints & Standards
- [ ] **Platform Gating**: All FreeBSD-specific system calls (like `SO_SETFIB`) and logic must be wrapped in `#ifdef __FreeBSD__` blocks to prevent regressions or build failures on other BSDs or Linux.
- [ ] **Feature Detection**: Where possible, use existing FRR macros for BSD feature detection to maintain compatibility with different FreeBSD versions.
## 1. YANG & Northbound Abstraction
- [ ] **Extend `frr-vrf.yang`**: Add a `table-id` leaf to the `/frr-vrf:lib/vrf` list. This allows users to manually map a VRF name to a kernel FIB ID.
- **Files**: `yang/frr-vrf.yang`
- [ ] **Update `lib/vrf.c` callbacks**:
- **Implement `modify` and `destroy` callbacks**: Create C functions to handle the `/frr-vrf:lib/vrf/table-id` path and register them in the `frr_vrf_info` module info.
- **Propagate to `struct vrf`**: Ensure that when the `table-id` is set via Northbound, the value is saved into the `vrf->data.l.table_id` field.
- **Files**: `lib/vrf.c`, `lib/vrf.h`
- [ ] **CLI Enhancement**: Add `table <1-N>` command under the `vrf NAME` configuration block.
- **Files**: `lib/vrf.c`
## 2. Zebra VRF Integration
- [ ] **Table-to-VRF Mapping**: Ensure `zebra_vrf_lookup_by_table()` correctly handles the `VRF_BACKEND_VRF_LITE` case for BSD by checking the configured `table_id` in `struct zebra_vrf`.
- **Files**: `zebra/zebra_vrf.c`
- [ ] **Interface Binding**: On FreeBSD, interfaces aren't "enslaved" to a VRF device. Ensure that when a VRF is enabled, Zebra correctly associates it with the configured FIB.
- **Files**: `zebra/interface.c`, `zebra/zebra_vrf.c`, `zebra/if_sysctl.c`
## 3. Kernel Routing Socket (Writes)
- [ ] **Multi-FIB Writes**: Update `rtm_write()` to support multiple FIBs. On FreeBSD, use `setsockopt(fd, IPPROTO_IP, SO_SETFIB, ...)` on the routing socket before calling `write()`.
- **Files**: `zebra/kernel_socket.c`, `zebra/kernel_socket.h`
- [ ] **Dataplane Integration**: Ensure the `kernel_route_update` retrieves the correct `table_id` from the `zebra_dplane_ctx` and passes it to the socket logic.
- **Files**: `zebra/rt_socket.c`
## 4. Kernel Message Reading (Reads)
- [ ] **FIB Identification**: When reading messages in `rtm_read()`, identify the FIB ID (e.g., via `rtm_fib` or socket options) to map it back to the correct VRF.
- **Files**: `zebra/kernel_socket.c`
## 5. Socket Options & VRF Bind
- [ ] **`vrf_bind()`**: Update for FreeBSD. Replace or supplement `SO_BINDTODEVICE` logic with `SO_SETFIB` for standard sockets created within a VRF context.
- **Files**: `lib/vrf.c`
## 6. Testing & Validation
- [ ] **Unit Tests**: Verify VRF-to-FIB mapping in Zebra.
- [ ] **Topotests**: Create a FreeBSD-specific topotest to verify multi-instance routing isolation.
- **Files**: `tests/topotests/`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment