David Ahern <dsah...@gmail.com> writes: > On 6/12/19 10:01 AM, Roman Mashak wrote: >> Hangbin Liu <liuhang...@gmail.com> writes: >> >>> Add a new parameter '-Numeric' to show the number of protocol, scope, >>> dsfield, etc directly instead of converting it to human readable name. >>> Do the same on tc and ss. >>> >>> This patch is based on David Ahern's previous patch. >>> >> >> [...] >> >> It would be good idea to specify the numerical format, e.g. hex or dec, >> very often hex is more conveninet representation (for example, when >> skbmark is encoded of IP address or such). >> >> Could you think of extending it '-Numeric' to have an optional argument >> hex, and use decimal as default. >> > > I do not see how such an option could work.
'numeric' is extern object, so can be accessible from other modules. But yes, it would require to add some wrappers around print_*int() APIs to take into account this new parameter. Yes, it is all-or-nothing approach, one can't have filters dumping their integers values in hex but actions attached to the filters in decimal (or the other way around). > It would be best for iproute2 commands to output fields as hex > or decimal based on what makes sense for each. For example, m_police.c historically dumps its index value in hex, although it's not very sensible IMHO :) Now it's risky to change the code, because many scripts will likely break. > That said, I do not see how this patch affects fields > such as skbmark. Can you give an example? The patch looks fine to me. The patch only exposes 'numeric' to tc, so yes -- it does not affect anything. I only suggested to think of more generic approach. On the 2nd thought: there already exists argument "-raw" for tc which currently instructs printing handles in hex representation. Why not to adopt this for ip and ss as well rather then adding new key?