netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2] ip-rule/trivial: add comment about json key "to_tbl" for unspecific rule action
@ 2019-02-19 14:03 Thomas Haller
  2019-02-19 18:19 ` Stephen Hemminger
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Haller @ 2019-02-19 14:03 UTC (permalink / raw)
  To: netdev; +Cc: stephen, Thomas Haller

The key should not be called "to_tbl" because it is exactly
not a FR_ACT_TO_TBL action.

    # ip rule add blackhole
    # ip -j rule | python -m json.tool
    ...
    {
        "priority": 0,
        "src": "all",
        "to_tbl": "blackhole"
    },

Still, as this is already released API from v4.17.0, stick to it.
Only add a comment for this oddity.

Related: 0dd4ccc56c0e ("iprule: add json support")

Signed-off-by: Thomas Haller <thaller@redhat.com>
---
If it is still permissible to change the API, I can also send a patch to
rename "to_tbl" key to "action".

 ip/iprule.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ip/iprule.c b/ip/iprule.c
index 2f58d8c2..aea175aa 100644
--- a/ip/iprule.c
+++ b/ip/iprule.c
@@ -459,6 +459,8 @@ int print_rule(struct nlmsghdr *n, void *arg)
 	} else if (frh->action == FR_ACT_NOP) {
 		print_null(PRINT_ANY, "nop", "nop", NULL);
 	} else if (frh->action != FR_ACT_TO_TBL) {
+		/* The action is not(!) to-tbl, however for historic
+		 * reasons, this JSON key is called "to_tbl". */
 		print_string(PRINT_ANY, "to_tbl", "%s",
 			     rtnl_rtntype_n2a(frh->action, b1, sizeof(b1)));
 	}
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-02-19 23:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-19 14:03 [PATCH iproute2] ip-rule/trivial: add comment about json key "to_tbl" for unspecific rule action Thomas Haller
2019-02-19 18:19 ` Stephen Hemminger
2019-02-19 20:50   ` [PATCH iproute2, v2] ip-rule: fix " Thomas Haller
2019-02-19 23:22     ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).