Skip to content

Commit

Permalink
[CUMULUS] zebra: goto "from all lookup local" rule
Browse files Browse the repository at this point in the history
If a pbr rule is going to set the table as the default vrf,
i.e. "set vrf default" or "set vrf unchanged" (for interfaces already
in the default vrf), use a "goto" action to hit the default
"from all lookup local" rule:
```
1000:   from all lookup [l3mdev-table]
32765:  from all lookup local  <<<
32766:  from all lookup main
32767:  from all lookup default
```

This ensures matched traffic will lookup all 3 tables associated
with the default vrf and conclude rule evaluation, rather than
evaluating all rules between the FRR-installed rule and the
local/main/default rules.

Signed-off-by: Trey Aspelund <[email protected]>
  • Loading branch information
Trey Aspelund authored and donaldsharp committed Dec 7, 2024
1 parent 30f521c commit 9432b82
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion zebra/rule_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ static ssize_t netlink_rule_msg_encode(
const struct prefix *dst_ip, uint32_t fwmark, uint8_t dsfield,
uint8_t ip_protocol, void *buf, size_t buflen)
{
/*
* CL ships with the "from all lookup local" rule set to prio 32765.
* Other distros seem to ship this rule with prio 0, so for now we'll
* hardcode this and make it Cumulus-specific.
*/
uint32_t goto_target = 32765;
uint8_t protocol = RTPROT_ZEBRA;
int family;
int bytelen;
Expand Down Expand Up @@ -127,8 +133,16 @@ static ssize_t netlink_rule_msg_encode(
if (filter_bm & PBR_FILTER_IP_PROTOCOL)
nl_attr_put8(&req->n, buflen, FRA_IP_PROTO, ip_protocol);

/*
* If vrf is default, jump to "from all lookup local" rule, that way
* packets will lookup local -> main -> default tables.
*/
if (table == RT_TABLE_MAIN) {
req->frh.action = FR_ACT_GOTO;
if (!nl_attr_put32(&req->n, buflen, FRA_GOTO, goto_target))
return 0;
/* Route table to use to forward, if filter criteria matches. */
if (table < 256)
} else if (table < 256)
req->frh.table = table;
else {
req->frh.table = RT_TABLE_UNSPEC;
Expand Down

0 comments on commit 9432b82

Please sign in to comment.