path: root/src/rt.c
diff options
authorFlorian Westphal <>2017-09-29 13:54:21 +0200
committerFlorian Westphal <>2017-09-29 13:54:21 +0200
commitd53f6caace0759c0e79fe6e7b647bd6f20201e28 (patch)
treef793ace2785a17a767d58ac521451ae659eddecd /src/rt.c
parent2440711cf07ee582db4f0fff3b274acd158dd98f (diff)
src: rt: add keyword distinction for nexthop vs nexthop6
the rt expression currently always sets NFT_RT_NEXTHOP4 and then uses the network base to determine if its really supposed to be NEXTHOP6. For inet, this will fail because the network base is not known, so this currently enforces need for "meta nfproto" to dermine the type. Allow following syntax instead: rt ip nexthop rt ip6 nexthop There is no need for a dependency anymore, as rt expression checks the hook protocol, ie. NEXTHOP4 will break if the hook pf is not NFPROTO_IPV4. Cc: Anders K. Pedersen <> Signed-off-by: Florian Westphal <>
Diffstat (limited to 'src/rt.c')
1 files changed, 14 insertions, 1 deletions
diff --git a/src/rt.c b/src/rt.c
index 9ad9e398..041dbc2f 100644
--- a/src/rt.c
+++ b/src/rt.c
@@ -82,7 +82,20 @@ static const struct rt_template rt_templates[] = {
static void rt_expr_print(const struct expr *expr, struct output_ctx *octx)
- nft_print(octx, "rt %s", rt_templates[expr->rt.key].token);
+ const char *ip = "";
+ switch (expr->rt.key) {
+ ip = "ip ";
+ break;
+ ip = "ip6 ";
+ break;
+ default:
+ break;
+ }
+ nft_print(octx, "rt %s%s", ip, rt_templates[expr->rt.key].token);
static bool rt_expr_cmp(const struct expr *e1, const struct expr *e2)