> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/fpp/latest/llms.txt) (all documentation: [llms.txt](https://docs.cennso.com/llms.txt)). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cennso.com/components/fpp/latest/operation-guides/source-based-forwarding.md).

# Configure source-based routing

> **CAUTION:** This feature is obsolete and replaced by [VPPABF CR](https://docs.cennso.com/components/fpp/latest/operation-guides/abf.md) but may still be used to debug interfaces not managed by FPP.

FPP allows source-based routing with the use of the VPP ACL-based forwarding (ABF) feature. The enablement requires creating a matching access-control list (ACL) for the incoming traffic and a dedicated policy to apply to it. The `VPPConfig` and `RoutingTable` CRs used in this guide are created on the Core Cluster.

## ACL creation

VPP uses `acl-plugin` to manage ACLs. Each ACL consists of a pattern for traffic matching and a rule to perform on it. For the ABF feature, ACLs with the apply action `permit` are required. A dedicated command to create an ACL using VPP CLI should be placed in the `afterCommands` section of the VPPConfig CR. The VPP CLI command:

```bash
set acl-plugin acl permit src {PREFIX} dst {PREFIX} proto X sport X-Y dport X-Y [tag FOO]
```

As an example, an ACL that matches input traffic from network `10.0.0.0/24` looks as follows:

```bash
set acl-plugin acl permit src 10.0.0.0/24
```

CLI returns `ACL index:<X>` where `X` is a positive integer index of the ACL created. This index will be used to create the ABF policy.

## Policy-based routing activation

To use an existing ACL that matches certain traffic and to make a routing decision, run the following:

```bash
abf policy [add|del] id {INDEX} acl {INDEX} via {FIB_PATH_FORMAT}
```

As an example, ABF Policy with index `0` uses ACL with index `0` and performs lookup in table  `100` for IPv4 traffic:

```bash
abf policy add id 0 acl 0 via ip4-lookup-in-table 100
```

The table ID must match the corresponding `RoutingTable` spec. Example:

```yaml
# Apply this on the Core Cluster
apiVersion: fpp-manager.cennso.com/v1alpha1
kind: RoutingTable
metadata:
  labels:
    fpp-manager.cennso.com/plumbing-instance: upg
    name: upg-access-routes
  name: upg-access-routes
  namespace: fpp-sample
spec:
  addressFamily: IPv4
  id: 100
  routes:
(...)
```

Attach the policy to the input interface through the CLI command:

```bash
abf attach {IP4|IP6} [del] policy {VALUE} {INTERFACE}
```

An example of an attachment policy with index `0` to interface named `net-1`:

```bash
abf attach ip4 policy 0 net-1
```

Several ABF policies can be attached to a single input interface.

## VPPConfig example

ABF policies creation and attachment must be added in the `afterCommands` section:

```yaml
# Apply this on the Core Cluster
apiVersion: fpp-manager.cennso.com/v1alpha1
kind: VPPConfig
metadata:
  name: vpp-example
  namespace: fpp-sample
  labels:
...
spec:
  afterCommands:
  - set acl-plugin acl permit src 10.0.0.0/24
  - abf policy add id 0 acl 0 via ip4-lookup-in-table 100
  - abf attach ip4 policy 0 {{ .Ifs.srv.Name }}
  interfaces:
  - srv
  routingTables:
  - 100
...

```

The `routingTables: [100]` is equivalent to `ip table add 100`, which adds an empty routing table 100 before `afterCommands` are executed.
