I am in the process of implementing a new protocol package and I have found some limitations with OpenWRT /etc/config/network that I believe will force me to use "ip route add" instead.
- It appears that the "option table " is ignored in a route stanza for IPv4 routes. Is this expected?
- If I add "option gateway " to an interface, it is added as a default route next-hop, rather than a next-hop for the subnet specified for the interface. Is this also expected behavior?
No, it is not - but hard to tell without further context. But guessing from your second question it might be related to the subnet route implicitly created for an interface, in this case you'd probably want
option ip4table (or
ip6table for IPv6) in the interface section itself.
Yes. If you want a subnet route, use
proto_add_ipv4_route in your protocol handler. A
grep -r proto_add_ipv4_route package/network/config/ will yield various examples.
Regarding question #1, it is not related to the route in question #2, so that solution will not suffice.
I need to add install a long route, which seems to translate to a two-part configuration:
- a rule for the source addr that points to a non-default routing table.
- a route for the dest addr in the non-default routing table.
When I have attempted this via /etc/config/network, I verify that the rule is installed with "ip rule show" but the route appears in the default table with "ip route show table all". I attempted to follow the netifd code to determine the issue and it looked as though the "option table" is only used in IPv6 route stanzas.
You are using table numbers and not names, correct?
Named tables have to be enumerated in another file before they will work (standard Linux).